# HG changeset patch # User Matti Hamalainen # Date 1522082262 -10800 # Node ID e618280253cac9f9e43b7886c353618f0a2ab2e8 # Parent 2731d2d8400ec2cbef144a050c45c770a3a2e0bc 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. diff -r 2731d2d8400e -r e618280253ca mgallery.inc.php --- a/mgallery.inc.php Mon Mar 26 17:06:12 2018 +0300 +++ b/mgallery.inc.php Mon Mar 26 19:37:42 2018 +0300 @@ -290,19 +290,6 @@ } -function mgGetTrans($val, $useEntities = FALSE) -{ - global $pageLang; - - if (is_array($val)) - $str = array_key_exists($pageLang, $val) ? $val[$pageLang] : reset($val); - else - $str = $val; - - return $useEntities ? chentities($str) : $str; -} - - function mgGetArr($data, $skeys, $sfmt1 = "%1", $sfmt2 = "", $func = NULL) { global $pageLang; diff -r 2731d2d8400e -r e618280253ca mgallery.php --- a/mgallery.php Mon Mar 26 17:06:12 2018 +0300 +++ b/mgallery.php Mon Mar 26 19:37:42 2018 +0300 @@ -109,6 +109,22 @@ } +function mgGetTrans($val, $filter = NULL) +{ + global $pageLang; + + if (is_array($val)) + $str = array_key_exists($pageLang, $val) ? $val[$pageLang] : reset($val); + else + $str = $val; + + if (is_callable($filter)) + return call_user_func($filter, $str); + else + return $str; +} + + function mgMangleURI($filename) { global $pageDebug; @@ -325,11 +341,13 @@ $atmp = $galAlbumIcon; echo - " ". - "\"".\n". - "
".mgGetTrans($data["caption"], TRUE)."
\n"; + " ". + "\"".\n". + "
". + mgGetTrans($data["caption"], "chentities"). + "
\n"; } if ($galUseTables) @@ -409,7 +427,7 @@ { return "". - mgGetTrans($pdata["caption"], TRUE). + mgGetTrans($pdata["caption"], "chentities"). ""; }