# HG changeset patch # User Matti Hamalainen # Date 1558350419 -10800 # Node ID 25324e33fc78c335b355ba8f717bf15392d72e86 # Parent 403f2e1e5e797ebad97dd8588684532fead1ba7e Refactor gallery path handling somewhat. diff -r 403f2e1e5e79 -r 25324e33fc78 mgallery.inc.php --- a/mgallery.inc.php Fri May 17 03:15:53 2019 +0300 +++ b/mgallery.inc.php Mon May 20 14:06:59 2019 +0300 @@ -246,6 +246,12 @@ } +function mgCleanPathStr($path) +{ + return str_replace("//", "/", $path); +} + + function mgCleanPathArray($refs, $start, $argc, $argv) { $path = []; @@ -274,7 +280,7 @@ $first = FALSE; } } - return $path; + return mgCleanPathStr($path); } diff -r 403f2e1e5e79 -r 25324e33fc78 mgallery.php --- a/mgallery.php Fri May 17 03:15:53 2019 +0300 +++ b/mgallery.php Mon May 20 14:06:59 2019 +0300 @@ -184,10 +184,10 @@ } -function mgGetImageURL($fpath, $filename, $ffmt) +function mgGetImageURL($galPath, $fpath, $filename, $ffmt) { - global $galImageURL, $galPath; - return str_replace("//", "/", $galImageURL.$galPath."/".$fpath.$filename.".".$ffmt); + global $galImageURL; + return mgCleanPathStr($galImageURL.$galPath."/".$fpath.$filename.".".$ffmt); } @@ -207,13 +207,12 @@ $path.($image !== FALSE ? $amp."image=".$image : ""); } - return str_replace("//", "/", $url); + return mgCleanPathStr($url); } -function mgGetNaviActive(&$galIndex, $index, $delta, &$res, $entities) +function mgGetNaviActive($galPath, &$galIndex, $index, $delta, &$res, $entities) { - global $galPath; $res = $index + $delta; if ($res >= 0 && $res <= sizeof($galIndex) - 1) @@ -223,16 +222,19 @@ } -function mgGetNaviControlImage(&$galIndex, $index, $class, $url) +function mgGetNaviControlImage($galPath, &$galIndex, &$galEntries, $index, $class, $url) { global $galTNPath, $galTNFormat; if ($url !== FALSE) { + $imgName = $galIndex[$index]; + $imgEntry = $galEntries[$imgName]; + $imgPath = isset($imgEntry["path"]) ? $imgEntry["path"] : $galPath; return "
". "\"".$galIndex[$index]."\"
"; } else @@ -240,16 +242,16 @@ } -function mgGetNaviControlImageBox(&$galIndex, $index, $class, $delta) +function mgGetNaviControlImageBox($galPath, &$galIndex, &$galEntries, $index, $class, $delta) { - $url = mgGetNaviActive($galIndex, $index, $delta, $res, TRUE); - return mgGetNaviControlImage($galIndex, $res, $class, $url); + $url = mgGetNaviActive($galPath, $galIndex, $index, $delta, $res, TRUE); + return mgGetNaviControlImage($galPath, $galIndex, $galEntries, $res, $class, $url); } -function mgGetNaviControlImageBoxJS(&$galIndex, $index, $class, $delta) +function mgGetNaviControlImageBoxJS($galPath, &$galIndex, &$galEntries, $index, $class, $delta) { - $str = mgGetNaviControlImageBox($galIndex, $index, $class, $delta); + $str = mgGetNaviControlImageBox($galPath, $galIndex, $galEntries, $index, $class, $delta); if ($str != "") return @@ -261,9 +263,9 @@ } -function mgPrintTable($class, &$galEntries, &$galIndex, $start, $limit) +function mgPrintTable($class, $galPath, &$galEntries, &$galIndex, $start, $limit) { - global $galAlbumIcon, $galPath, $galTNPath, $galTNFormat, + global $galAlbumIcon, $galTNPath, $galTNFormat, $galImageURL, $galUseCoverImages; $galCount = count($galIndex); @@ -287,7 +289,7 @@ echo "
\"".dhentities($filename)."\"
\n". mgGetArr($data, "caption", "
%1
\n", "", "chentities"); /* @@ -322,7 +324,7 @@ $ptmp[] = $galTNPath; $ptmp[] = $curr["image"]; - $atmp = $galImageURL.implode("/", mgCleanPathArray(TRUE, 0, count($ptmp), $ptmp)).".".$galTNFormat; + $atmp = mgCleanPathStr($galImageURL.implode("/", mgCleanPathArray(TRUE, 0, count($ptmp), $ptmp)).".".$galTNFormat); } else // No album cover, use default @@ -569,14 +571,15 @@ "^\n". // pageImageBox "
\n". - mgGetNaviControlImageBoxJS($galImagesIndex, $index, "prevBtm", -1)."\n". - mgGetNaviControlImageBox($galImagesIndex, $index, "prev", -1)."\n". + mgGetNaviControlImageBoxJS($galPath, $galImagesIndex, $galEntries, $index, "prevBtm", -1)."\n". + mgGetNaviControlImageBox($galPath, $galImagesIndex, $galEntries, $index, "prev", -1)."\n". "
". - "\"".chentities($galImage)."\"". "
\n". - mgGetNaviControlImageBoxJS($galImagesIndex, $index, "nextBtm", 1)."\n". - mgGetNaviControlImageBox($galImagesIndex, $index, "next", 1)."\n". + mgGetNaviControlImageBoxJS($galPath, $galImagesIndex, $galEntries, $index, "nextBtm", 1)."\n". + mgGetNaviControlImageBox($galPath, $galImagesIndex, $galEntries, $index, "next", 1)."\n". "
\n". // pageImageBox (isset($data["caption"]) ? "
".mgGetArrStr($data, "caption", "%1")."
\n" : ""). // infoBox @@ -590,8 +593,8 @@ // Javascript navigation if ($ctrlFlags & MGF_JAVASCRIPT) { - $prevURL = mgGetNaviActive($galImagesIndex, $index, -1, $res, FALSE); - $nextURL = mgGetNaviActive($galImagesIndex, $index, 1, $res, FALSE); + $prevURL = mgGetNaviActive($galPath, $galImagesIndex, $index, -1, $res, FALSE); + $nextURL = mgGetNaviActive($galPath, $galImagesIndex, $index, 1, $res, FALSE); echo "