comparison mgallery.php @ 232:e618280253ca

Move mgGetTrans() to mgallery.php as it is used only there. Also change how the second function argument works, instead of being a boolean to filter through chentities() use it as a callable which defaults to NULL for greater flexibility.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 26 Mar 2018 19:37:42 +0300
parents 2731d2d8400e
children 028291a78acb
comparison
equal deleted inserted replaced
231:2731d2d8400e 232:e618280253ca
104 104
105 105
106 function dhentities($str) 106 function dhentities($str)
107 { 107 {
108 return htmlentities($str, ENT_COMPAT, "UTF-8"); 108 return htmlentities($str, ENT_COMPAT, "UTF-8");
109 }
110
111
112 function mgGetTrans($val, $filter = NULL)
113 {
114 global $pageLang;
115
116 if (is_array($val))
117 $str = array_key_exists($pageLang, $val) ? $val[$pageLang] : reset($val);
118 else
119 $str = $val;
120
121 if (is_callable($filter))
122 return call_user_func($filter, $str);
123 else
124 return $str;
109 } 125 }
110 126
111 127
112 function mgMangleURI($filename) 128 function mgMangleURI($filename)
113 { 129 {
323 else 339 else
324 // No album cover, use default 340 // No album cover, use default
325 $atmp = $galAlbumIcon; 341 $atmp = $galAlbumIcon;
326 342
327 echo 343 echo
328 " <a href=\"".mgGetURL(mgCleanPath(TRUE, $galPath, $filename), FALSE)."\">". 344 " <a href=\"".mgGetURL(mgCleanPath(TRUE, $galPath, $filename), FALSE)."\">".
329 "<img class=\"albumIcon\" src=\"".$atmp."\" alt=\"". 345 "<img class=\"albumIcon\" src=\"".$atmp."\" alt=\"".
330 dhentities(mgGetTrans($data["caption"], TRUE)). 346 mgGetTrans($data["caption"], "dhentities").
331 "\" />\n". 347 "\" />\n".
332 " <div class=\"albumTitle\">".mgGetTrans($data["caption"], TRUE)."</div></a>\n"; 348 " <div class=\"albumTitle\">".
349 mgGetTrans($data["caption"], "chentities").
350 "</div></a>\n";
333 } 351 }
334 352
335 if ($galUseTables) 353 if ($galUseTables)
336 { 354 {
337 echo " </td>\n"; 355 echo " </td>\n";
407 425
408 function mgGetBreadCrump($class, &$pdata) 426 function mgGetBreadCrump($class, &$pdata)
409 { 427 {
410 return 428 return
411 "<a class=\"".$class."\" href=\"".mgGetURL($pdata["path"], FALSE)."\">". 429 "<a class=\"".$class."\" href=\"".mgGetURL($pdata["path"], FALSE)."\">".
412 mgGetTrans($pdata["caption"], TRUE). 430 mgGetTrans($pdata["caption"], "chentities").
413 "</a>"; 431 "</a>";
414 } 432 }
415 433
416 434
417 function mgPrintBreadCrumbs($galData) 435 function mgPrintBreadCrumbs($galData)