Mercurial > hg > mgallery
changeset 16:3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 14 Sep 2015 10:57:10 +0300 |
parents | 805f93962cf9 |
children | 3f7bc4202df3 |
files | mgtool.php |
diffstat | 1 files changed, 19 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mgtool.php Mon Sep 14 09:54:01 2015 +0300 +++ b/mgtool.php Mon Sep 14 10:57:10 2015 +0300 @@ -34,7 +34,6 @@ define("GCLEAN_THUMBNAILS", 0x02); define("GCLEAN_ALL" , 0x0f); - define("GUPD_MED_IMAGE" , 0x01); define("GUPD_TN_IMAGE" , 0x02); define("GUPD_IMAGES" , 0x0f); @@ -327,7 +326,7 @@ } -function mgWriteGalleryCache($cacheFilename, &$gallery, &$entries) +function mgWriteGalleryCache($cacheFilename, &$gallery, &$entries, &$parentEntry) { // Store gallery cache for this directory $images = array(); @@ -346,6 +345,13 @@ ksort($images); ksort($albums); + // Choose gallery album image + if (count($images) > 0) + { + end($images); + $parentEntry["image"] = key($images); + } + $str = "<?\n". "\$galData = ".var_export($gallery, TRUE).";\n". @@ -360,7 +366,8 @@ return TRUE; } -function mgHandleDirectory($mode, $basepath, $path, $parentData, $parentEntry, $writeMode, $startAt) + +function mgHandleDirectory($mode, $basepath, $path, &$parentData, &$parentEntry, $writeMode, $startAt) { global $galExifConversions, $galTNPath, $galCleanFlags; @@ -423,7 +430,7 @@ $gallery = mgGetAlbumData($basepath, $path); if ($parentData !== NULL && $parentEntry !== NULL) { - $gallery["parent"] = $parentData; + $gallery["parent"] = &$parentData; mgCopyEntryData($gallery, $parentEntry, MG_STR, "caption", "caption"); } @@ -540,14 +547,6 @@ echo "\r".$path." ..... DONE\n"; mgCheckQuit(TRUE); - - // Store gallery cache for this directory - if ($writeMode && !mgWriteGalleryCache($cacheFilename, $gallery, $entries)) - return FALSE; - { - { - } - } } else mgFatal("Invalid work mode '".$mode."'.\n"); @@ -565,6 +564,14 @@ return FALSE; } + // Finish update modes + if ($mode == GCMD_UPDATE || $mode == GCMD_RESCAN) + { + // Store gallery cache for this directory + if ($writeMode && !mgWriteGalleryCache($cacheFilename, $gallery, $entries, $parentEntry)) + return FALSE; + } + mgCheckQuit(TRUE); return TRUE;