Mercurial > hg > mgallery
diff mgallery.php @ 322:2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 09 Apr 2020 11:55:08 +0300 |
parents | f07e3d79c421 |
children | 23625c53e62d |
line wrap: on
line diff
--- a/mgallery.php Thu Apr 09 10:13:45 2020 +0300 +++ b/mgallery.php Thu Apr 09 11:55:08 2020 +0300 @@ -140,9 +140,23 @@ } -function mgPrintPageHeader($pageTitle, $pageClass) +function mgGetJSLine($filename) +{ + return + " <script src=\"".mgMangleURI($filename)."\"></script>\n"; +} + + +function mgIncludeUrchin($filename) { - global $pageCSS, $pageCharset, $pageUrchin, $pageJSFile, $pageLang; + if (file_exists($filename)) + require_once $filename; +} + + +function mgPrintPageHeader($pageTitle, $pageDivID) +{ + global $pageCSS, $pageCharset, $pageUrchin, $pageJS, $pageLang; echo "<!DOCTYPE html>\n". @@ -151,18 +165,27 @@ " <meta charset=\"".$pageCharset."\">\n". // Setting the viewport makes things break especially with the // text-size-adjust CSS settings... so we don't use it. + // XXX: We do now. For now. " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n". - " <script src=\"".mgMangleURI($pageJSFile)."\"></script>\n". " <title>".strip_tags($pageTitle)."</title>\n". - mgGetCSSLine($pageCSS, FALSE). + (is_array($pageJS) ? array_map('mgGetJSLine', $pageJS) : mgGetJSLine($pageJS)). + (is_array($pageCSS) ? array_map('mgGetCSSLine', $pageCSS) : mgGetCSSLine($pageCSS, FALSE)). "</head>\n". "<body>\n"; - if ($pageUrchin !== FALSE && file_exists($pageUrchin)) - require_once $pageUrchin; + if ($pageUrchin !== NULL) + { + if (is_array($pageUrchin)) + { + foreach ($pageUrchin as $filename) + mgIncludeUrchin($filename); + } + else + mgIncludeUrchin($pageUrchin); + } echo - "<div id=\"".$pageClass."\">\n"; + "<div id=\"".$pageDivID."\">\n"; } @@ -460,7 +483,7 @@ } $pageCSS = mgGetSetting("css"); -$pageJSFile = mgGetSetting("js_file"); +$pageJS = mgGetSetting("js_file"); $pageUrchin = mgGetSetting("urchin_file"); $galBasePath = mgGetSetting("base_path"); $galBaseURL = mgGetSetting("base_url");