From 31a21ac24cd5cbe19e40ab3838fcc179d812da13 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Wed, 8 May 2013 03:51:38 -0400 Subject: use smarty3 as default template engine. add pluggable template system --- include/friendica_smarty.php | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) mode change 100644 => 100755 include/friendica_smarty.php (limited to 'include/friendica_smarty.php') diff --git a/include/friendica_smarty.php b/include/friendica_smarty.php old mode 100644 new mode 100755 index b9ed2e982..5f247a528 --- a/include/friendica_smarty.php +++ b/include/friendica_smarty.php @@ -1,7 +1,8 @@ ERROR: folder view/tpl/smarty3/ must be writable by webserver."; killme(); + } + } + + // ITemplateEngine interface + public function replace_macros($s, $r) { + $template = ''; + if(gettype($s) === 'string') { + $template = $s; + $s = new FriendicaSmarty(); + } + foreach($r as $key=>$value) { + if($key[0] === '$') { + $key = substr($key, 1); + } + $s->assign($key, $value); + } + return $s->parsed($template); + } + + public function get_markup_template($file, $root=''){ + $template_file = theme_include('smarty3/'.$file, $root); + if($template_file) { + $template = new FriendicaSmarty(); + $template->filename = $template_file; + + return $template; + } + return ""; + } +} \ No newline at end of file -- cgit v1.2.3