]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Renderer.php
Merge branch 'master' 2019.12 into develop
[friendica.git] / src / Core / Renderer.php
index 72073086ab33d5bfcbab1bdf0a5e9748dcc4c70f..d9d913050fe32a34f324e6900640eff1cc853ceb 100644 (file)
@@ -52,22 +52,20 @@ class Renderer extends BaseObject
        /**
         * @brief This is our template processor
         *
-        * @param string|FriendicaSmarty $s            The string requiring macro substitution or an instance of FriendicaSmarty
-        * @param array                  $vars         key value pairs (search => replace)
-        * @param bool                   $overwriteURL Overwrite the base url with the system wide set base url
+        * @param string|FriendicaSmarty $s    The string requiring macro substitution or an instance of FriendicaSmarty
+        * @param array                  $vars Key value pairs (search => replace)
         *
         * @return string substituted string
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws Exception
         */
-       public static function replaceMacros($s, $vars, $overwriteURL = true)
+       public static function replaceMacros($s, array $vars = [])
        {
                $stamp1 = microtime(true);
                $a = self::getApp();
 
-               // pass $baseurl to all templates
-               if ($overwriteURL) {
-                       $vars['$baseurl'] = System::baseUrl();
-               }
+               // pass $baseurl to all templates if it isn't set
+               $vars = array_merge(['$baseurl' => $a->getBaseURL()], $vars);
+
                $t = self::getTemplateEngine();
 
                try {
@@ -138,7 +136,7 @@ class Renderer extends BaseObject
         */
        public static function getTemplateEngine()
        {
-               $template_engine = defaults(self::$theme, 'template_engine', 'smarty3');
+               $template_engine = (self::$theme['template_engine'] ?? '') ?: 'smarty3';
 
                if (isset(self::$template_engines[$template_engine])) {
                        if (isset(self::$template_engine_instance[$template_engine])) {