Mercurial > hg > mgallery
changeset 13:951752fb1c21
Add translation of relative URLs in header text blocks.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 21 Aug 2015 16:46:26 +0300 |
parents | 79987aa7ee9a |
children | c9fad00199f9 |
files | mgallery.php |
diffstat | 1 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mgallery.php Fri Aug 21 16:45:53 2015 +0300 +++ b/mgallery.php Fri Aug 21 16:46:26 2015 +0300 @@ -410,7 +410,26 @@ mgPrintBreadCrumbs($galData); if (isset($galData["header"]) && strlen($galData["header"]) > 0) - echo "<div class=\"albumHeaderText\">".$galData["header"]."</div>\n"; + { + // Translate relative URLs in header, if needed + $baseURL = mgGetSetting("image_url"); + + $headerText = preg_replace_callback( + "@href\s*=\s*\"([^\"]+)\"@i", + function ($matches) use($galPath, $baseURL) + { + $mstmp = $matches[1]; + if (preg_match("@^[a-z]+://@i", $mstmp) === 0) + { + if ($mstmp[0] != "/") + $mstmp = $baseURL."/".$galPath."/".$mstmp; + } + return "href=\"".str_replace("//", "/", $mstmp)."\""; + }, + $galData["header"]); + + echo "<div class=\"albumHeaderText\">".$headerText."</div>\n"; + } mgPrintTable("albumTable", $galEntries, $galAlbumsIndex, 0, FALSE); mgPrintTable("imageTable", $galEntries, $galImagesIndex, 0, FALSE);