Mercurial > hg > mgallery
comparison mgallery.php @ 285:25324e33fc78
Refactor gallery path handling somewhat.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 20 May 2019 14:06:59 +0300 |
parents | be152168d945 |
children | 290a42c52e35 |
comparison
equal
deleted
inserted
replaced
284:403f2e1e5e79 | 285:25324e33fc78 |
---|---|
182 chentities($filename). | 182 chentities($filename). |
183 mgGetArr($data, "datetime", " - %1", "", "mgTimeStr"); | 183 mgGetArr($data, "datetime", " - %1", "", "mgTimeStr"); |
184 } | 184 } |
185 | 185 |
186 | 186 |
187 function mgGetImageURL($fpath, $filename, $ffmt) | 187 function mgGetImageURL($galPath, $fpath, $filename, $ffmt) |
188 { | 188 { |
189 global $galImageURL, $galPath; | 189 global $galImageURL; |
190 return str_replace("//", "/", $galImageURL.$galPath."/".$fpath.$filename.".".$ffmt); | 190 return mgCleanPathStr($galImageURL.$galPath."/".$fpath.$filename.".".$ffmt); |
191 } | 191 } |
192 | 192 |
193 | 193 |
194 function mgGetURL($path, $image, $entities = TRUE) | 194 function mgGetURL($path, $image, $entities = TRUE) |
195 { | 195 { |
205 $url = | 205 $url = |
206 $galBaseURL.mgGetSetting("mgallery_php")."?path=". | 206 $galBaseURL.mgGetSetting("mgallery_php")."?path=". |
207 $path.($image !== FALSE ? $amp."image=".$image : ""); | 207 $path.($image !== FALSE ? $amp."image=".$image : ""); |
208 } | 208 } |
209 | 209 |
210 return str_replace("//", "/", $url); | 210 return mgCleanPathStr($url); |
211 } | 211 } |
212 | 212 |
213 | 213 |
214 function mgGetNaviActive(&$galIndex, $index, $delta, &$res, $entities) | 214 function mgGetNaviActive($galPath, &$galIndex, $index, $delta, &$res, $entities) |
215 { | 215 { |
216 global $galPath; | |
217 $res = $index + $delta; | 216 $res = $index + $delta; |
218 | 217 |
219 if ($res >= 0 && $res <= sizeof($galIndex) - 1) | 218 if ($res >= 0 && $res <= sizeof($galIndex) - 1) |
220 return mgGetURL($galPath, $galIndex[$res], $entities); | 219 return mgGetURL($galPath, $galIndex[$res], $entities); |
221 else | 220 else |
222 return FALSE; | 221 return FALSE; |
223 } | 222 } |
224 | 223 |
225 | 224 |
226 function mgGetNaviControlImage(&$galIndex, $index, $class, $url) | 225 function mgGetNaviControlImage($galPath, &$galIndex, &$galEntries, $index, $class, $url) |
227 { | 226 { |
228 global $galTNPath, $galTNFormat; | 227 global $galTNPath, $galTNFormat; |
229 | 228 |
230 if ($url !== FALSE) | 229 if ($url !== FALSE) |
231 { | 230 { |
231 $imgName = $galIndex[$index]; | |
232 $imgEntry = $galEntries[$imgName]; | |
233 $imgPath = isset($imgEntry["path"]) ? $imgEntry["path"] : $galPath; | |
232 return | 234 return |
233 "<div class=\"imageCtrl ".$class."\">". | 235 "<div class=\"imageCtrl ".$class."\">". |
234 "<a href=\"".$url."\"><img src=\"". | 236 "<a href=\"".$url."\"><img src=\"". |
235 mgGetImageURL($galTNPath, $galIndex[$index], $galTNFormat). | 237 mgGetImageURL($imgPath, $galTNPath, $imgName, $galTNFormat). |
236 "\" alt=\"".$galIndex[$index]."\" /></a></div>"; | 238 "\" alt=\"".$galIndex[$index]."\" /></a></div>"; |
237 } | 239 } |
238 else | 240 else |
239 return ""; | 241 return ""; |
240 } | 242 } |
241 | 243 |
242 | 244 |
243 function mgGetNaviControlImageBox(&$galIndex, $index, $class, $delta) | 245 function mgGetNaviControlImageBox($galPath, &$galIndex, &$galEntries, $index, $class, $delta) |
244 { | 246 { |
245 $url = mgGetNaviActive($galIndex, $index, $delta, $res, TRUE); | 247 $url = mgGetNaviActive($galPath, $galIndex, $index, $delta, $res, TRUE); |
246 return mgGetNaviControlImage($galIndex, $res, $class, $url); | 248 return mgGetNaviControlImage($galPath, $galIndex, $galEntries, $res, $class, $url); |
247 } | 249 } |
248 | 250 |
249 | 251 |
250 function mgGetNaviControlImageBoxJS(&$galIndex, $index, $class, $delta) | 252 function mgGetNaviControlImageBoxJS($galPath, &$galIndex, &$galEntries, $index, $class, $delta) |
251 { | 253 { |
252 $str = mgGetNaviControlImageBox($galIndex, $index, $class, $delta); | 254 $str = mgGetNaviControlImageBox($galPath, $galIndex, $galEntries, $index, $class, $delta); |
253 | 255 |
254 if ($str != "") | 256 if ($str != "") |
255 return | 257 return |
256 "<script>". | 258 "<script>". |
257 "document.write(\"".str_replace("\"", "\\\"", $str)."\");". | 259 "document.write(\"".str_replace("\"", "\\\"", $str)."\");". |
259 else | 261 else |
260 return ""; | 262 return ""; |
261 } | 263 } |
262 | 264 |
263 | 265 |
264 function mgPrintTable($class, &$galEntries, &$galIndex, $start, $limit) | 266 function mgPrintTable($class, $galPath, &$galEntries, &$galIndex, $start, $limit) |
265 { | 267 { |
266 global $galAlbumIcon, $galPath, $galTNPath, $galTNFormat, | 268 global $galAlbumIcon, $galTNPath, $galTNFormat, |
267 $galImageURL, $galUseCoverImages; | 269 $galImageURL, $galUseCoverImages; |
268 | 270 |
269 $galCount = count($galIndex); | 271 $galCount = count($galIndex); |
270 if ($start >= $galCount) | 272 if ($start >= $galCount) |
271 return $start; | 273 return $start; |
285 if ($data["type"] == 0) | 287 if ($data["type"] == 0) |
286 { | 288 { |
287 echo | 289 echo |
288 " <div class=\"imageBox\" title=\"".mgGetImageTitleStr($filename, $data). | 290 " <div class=\"imageBox\" title=\"".mgGetImageTitleStr($filename, $data). |
289 "\"><a href=\"".mgGetURL($galPath, $filename)."\"><img src=\"". | 291 "\"><a href=\"".mgGetURL($galPath, $filename)."\"><img src=\"". |
290 mgGetImageURL($galTNPath, $filename, $galTNFormat). | 292 mgGetImageURL(isset($data["path"]) ? $data["path"] : $galPath, $galTNPath, $filename, $galTNFormat). |
291 "\" alt=\"".dhentities($filename)."\"></a></div>\n". | 293 "\" alt=\"".dhentities($filename)."\"></a></div>\n". |
292 mgGetArr($data, "caption", " <div class=\"imageCaption\">%1</div>\n", "", "chentities"); | 294 mgGetArr($data, "caption", " <div class=\"imageCaption\">%1</div>\n", "", "chentities"); |
293 /* | 295 /* |
294 if ($mode == "") | 296 if ($mode == "") |
295 { | 297 { |
320 } | 322 } |
321 | 323 |
322 $ptmp[] = $galTNPath; | 324 $ptmp[] = $galTNPath; |
323 $ptmp[] = $curr["image"]; | 325 $ptmp[] = $curr["image"]; |
324 | 326 |
325 $atmp = $galImageURL.implode("/", mgCleanPathArray(TRUE, 0, count($ptmp), $ptmp)).".".$galTNFormat; | 327 $atmp = mgCleanPathStr($galImageURL.implode("/", mgCleanPathArray(TRUE, 0, count($ptmp), $ptmp)).".".$galTNFormat); |
326 } | 328 } |
327 else | 329 else |
328 // No album cover, use default | 330 // No album cover, use default |
329 $atmp = $galAlbumIcon; | 331 $atmp = $galAlbumIcon; |
330 | 332 |
567 // Hovering navigation buttons | 569 // Hovering navigation buttons |
568 "<a id=\"pageInfoButton\" href=\"#\" title=\"".mgQM("page_info_button_title")."\">_</a>\n". | 570 "<a id=\"pageInfoButton\" href=\"#\" title=\"".mgQM("page_info_button_title")."\">_</a>\n". |
569 "<a id=\"pageUpNaviButton\" href=\"".mgGetURL($galData["path"], FALSE)."\" title=\"".mgQM("page_up_navi_button_title")."\">^</a>\n". | 571 "<a id=\"pageUpNaviButton\" href=\"".mgGetURL($galData["path"], FALSE)."\" title=\"".mgQM("page_up_navi_button_title")."\">^</a>\n". |
570 // pageImageBox | 572 // pageImageBox |
571 "<div id=\"pageImageBox\">\n". | 573 "<div id=\"pageImageBox\">\n". |
572 mgGetNaviControlImageBoxJS($galImagesIndex, $index, "prevBtm", -1)."\n". | 574 mgGetNaviControlImageBoxJS($galPath, $galImagesIndex, $galEntries, $index, "prevBtm", -1)."\n". |
573 mgGetNaviControlImageBox($galImagesIndex, $index, "prev", -1)."\n". | 575 mgGetNaviControlImageBox($galPath, $galImagesIndex, $galEntries, $index, "prev", -1)."\n". |
574 "<div id=\"imageImageBox\" class=\"imageBox\">". | 576 "<div id=\"imageImageBox\" class=\"imageBox\">". |
575 "<img id=\"imageImage\" src=\"".mgGetImageURL($galMedPath, $galImage, $galMedFormat). | 577 "<img id=\"imageImage\" src=\"". |
578 mgGetImageURL(isset($data["path"]) ? $data["path"] : $galPath, $galMedPath, $galImage, $galMedFormat). | |
576 "\" alt=\"".chentities($galImage)."\">". | 579 "\" alt=\"".chentities($galImage)."\">". |
577 "</div>\n". | 580 "</div>\n". |
578 mgGetNaviControlImageBoxJS($galImagesIndex, $index, "nextBtm", 1)."\n". | 581 mgGetNaviControlImageBoxJS($galPath, $galImagesIndex, $galEntries, $index, "nextBtm", 1)."\n". |
579 mgGetNaviControlImageBox($galImagesIndex, $index, "next", 1)."\n". | 582 mgGetNaviControlImageBox($galPath, $galImagesIndex, $galEntries, $index, "next", 1)."\n". |
580 "</div>\n". // pageImageBox | 583 "</div>\n". // pageImageBox |
581 (isset($data["caption"]) ? "<div id=\"pageImageCaption\" class=\"imageCaption\">".mgGetArrStr($data, "caption", "%1")."</div>\n" : ""). | 584 (isset($data["caption"]) ? "<div id=\"pageImageCaption\" class=\"imageCaption\">".mgGetArrStr($data, "caption", "%1")."</div>\n" : ""). |
582 // infoBox | 585 // infoBox |
583 "<div id=\"infoBox\">\n". | 586 "<div id=\"infoBox\">\n". |
584 mgGetArr($data, "datetime", "<span class=\"infoDateTime\">%1</span>\n", "", "mgTimeStr"). | 587 mgGetArr($data, "datetime", "<span class=\"infoDateTime\">%1</span>\n", "", "mgTimeStr"). |
588 "</div>\n"; // infoBox | 591 "</div>\n"; // infoBox |
589 | 592 |
590 // Javascript navigation | 593 // Javascript navigation |
591 if ($ctrlFlags & MGF_JAVASCRIPT) | 594 if ($ctrlFlags & MGF_JAVASCRIPT) |
592 { | 595 { |
593 $prevURL = mgGetNaviActive($galImagesIndex, $index, -1, $res, FALSE); | 596 $prevURL = mgGetNaviActive($galPath, $galImagesIndex, $index, -1, $res, FALSE); |
594 $nextURL = mgGetNaviActive($galImagesIndex, $index, 1, $res, FALSE); | 597 $nextURL = mgGetNaviActive($galPath, $galImagesIndex, $index, 1, $res, FALSE); |
595 echo | 598 echo |
596 "<script>\n". | 599 "<script>\n". |
597 "var mgalPrevURL = \"".($prevURL !== FALSE ? $prevURL : "")."\";\n". | 600 "var mgalPrevURL = \"".($prevURL !== FALSE ? $prevURL : "")."\";\n". |
598 "var mgalNextURL = \"".($nextURL !== FALSE ? $nextURL : "")."\";\n". | 601 "var mgalNextURL = \"".($nextURL !== FALSE ? $nextURL : "")."\";\n". |
599 "var mgalUpURL = \"".mgGetURL($galData["path"], FALSE)."\";\n". | 602 "var mgalUpURL = \"".mgGetURL($galData["path"], FALSE)."\";\n". |
667 echo "<div class=\"albumHeaderText\">".$headerText."</div>\n"; | 670 echo "<div class=\"albumHeaderText\">".$headerText."</div>\n"; |
668 } | 671 } |
669 | 672 |
670 echo mgGetPageInfoHeaderEnd(); | 673 echo mgGetPageInfoHeaderEnd(); |
671 | 674 |
672 mgPrintTable("albumTable", $galEntries, $galAlbumsIndex, 0, FALSE); | 675 mgPrintTable("albumTable", $galPath, $galEntries, $galAlbumsIndex, 0, FALSE); |
673 mgPrintTable("imageTable", $galEntries, $galImagesIndex, 0, FALSE); | 676 mgPrintTable("imageTable", $galPath, $galEntries, $galImagesIndex, 0, FALSE); |
674 } | 677 } |
675 | 678 |
676 mgPrintPageFooter(); | 679 mgPrintPageFooter(); |
677 ?> | 680 ?> |