3 * @file src/Render/FriendicaSmarty.php
5 namespace Friendica\Render;
10 * Friendica extension of the Smarty3 template engine
12 * @author Hypolite Petovan <mrpetovan@gmail.com>
14 class FriendicaSmarty extends Smarty
16 const SMARTY3_TEMPLATE_FOLDER = 'templates';
20 function __construct()
22 parent::__construct();
25 $theme = $a->getCurrentTheme();
27 // setTemplateDir can be set to an array, which Smarty will parse in order.
28 // The order is thus very important here
29 $template_dirs = ['theme' => "view/theme/$theme/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
30 if (x($a->theme_info, "extends")) {
31 $template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
34 $template_dirs = $template_dirs + ['base' => "view/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
35 $this->setTemplateDir($template_dirs);
37 $this->setCompileDir('view/smarty3/compiled/');
38 $this->setConfigDir('view/smarty3/config/');
39 $this->setCacheDir('view/smarty3/cache/');
41 $this->left_delimiter = $a->get_template_ldelim('smarty3');
42 $this->right_delimiter = $a->get_template_rdelim('smarty3');
44 // Don't report errors so verbosely
45 $this->error_reporting = E_ALL & ~E_NOTICE;
48 function parsed($template = '')
51 return $this->fetch('string:' . $template);
53 return $this->fetch('file:' . $this->filename);