From: Dan Untenzu Date: Tue, 17 Jan 2017 11:37:34 +0000 (+0100) Subject: [FEATURE] Replace markers in templates X-Git-Tag: 2.0.0~8 X-Git-Url: https://git.p6c8.net/jirafeau_project.git/commitdiff_plain/381f2d6ec29c08264a6fcf5066ff97cc32698595 [FEATURE] Replace markers in templates Add a function to allow a simple marker replacement, eg. for the Terms of Service page. Markers have the scheme "###MARKERNAME###". --- diff --git a/lib/functions.php b/lib/functions.php index 47fbc40..a89d8b8 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1359,3 +1359,31 @@ jirafeau_alias_delete ($alias, $password) return 'Ok'; } +/** + * Replace markers in templates. + * + * Available markers have the scheme "###MARKERNAME###". + * + * @param $content string Template text with markers + * @param $htmllinebreaks boolean Convert linebreaks to BR-Tags + * @return Template with replaced markers + */ +function +jirafeau_replace_markers ($content, $htmllinebreaks = false) +{ + $patterns = array( + '/###ORGANISATION###/', + '/###CONTACTPERSON###/' + ); + $replacements = array( + '[ORGANISATION PROVIDING THIS WEBSITE]', + 'contact@[THIS WEBSITE]' + ); + $content = preg_replace($patterns, $replacements, $content); + + if (true === $htmllinebreaks) { + $content = nl2br($content); + } + + return $content; +} \ No newline at end of file