3 * @file src/Render/FriendicaSmartyEngine.php
\r
5 namespace Friendica\Render;
\r
7 use Friendica\Core\Addon;
\r
9 class FriendicaSmartyEngine implements ITemplateEngine
\r
11 static $name = "smarty3";
\r
13 public function __construct()
\r
15 if (!is_writable('view/smarty3/')) {
\r
16 echo "<b>ERROR:</b> folder <tt>view/smarty3/</tt> must be writable by webserver.";
\r
21 // ITemplateEngine interface
\r
22 public function replaceMacros($s, $r)
\r
25 if (gettype($s) === 'string') {
\r
27 $s = new FriendicaSmarty();
\r
30 $r['$APP'] = get_app();
\r
32 // "middleware": inject variables into templates
\r
34 "template" => basename($s->filename),
\r
37 Addon::callHooks("template_vars", $arr);
\r
40 foreach ($r as $key => $value) {
\r
41 if ($key[0] === '$') {
\r
42 $key = substr($key, 1);
\r
45 $s->assign($key, $value);
\r
47 return $s->parsed($template);
\r
50 public function getTemplateFile($file, $root = '')
\r
53 $template_file = get_template_file($a, SMARTY3_TEMPLATE_FOLDER . '/' . $file, $root);
\r
54 $template = new FriendicaSmarty();
\r
55 $template->filename = $template_file;
\r