namespace Friendica\Core;
use Exception;
-use Friendica\BaseObject;
+use Friendica\DI;
use Friendica\Render\FriendicaSmarty;
use Friendica\Render\ITemplateEngine;
/**
* @brief This class handles Renderer related functions.
*/
-class Renderer extends BaseObject
+class Renderer
{
/**
* @brief An array of registered template engines ('name'=>'class name')
/**
* @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();
+ $a = DI::app();
+
+ // pass $baseurl to all templates if it isn't set
+ $vars = array_merge(['$baseurl' => $a->getBaseURL()], $vars);
- // pass $baseurl to all templates
- if ($overwriteURL) {
- $vars['$baseurl'] = System::baseUrl();
- }
$t = self::getTemplateEngine();
try {
exit();
}
- $a->getProfiler()->saveTimestamp($stamp1, "rendering", System::callstack());
+ DI::profiler()->saveTimestamp($stamp1, "rendering", System::callstack());
return $output;
}
public static function getMarkupTemplate($s, $root = '')
{
$stamp1 = microtime(true);
- $a = self::getApp();
+ $a = DI::app();
$t = self::getTemplateEngine();
try {
exit();
}
- $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
+ DI::profiler()->saveTimestamp($stamp1, "file", System::callstack());
return $template;
}
*/
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])) {