aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-01-06 19:25:01 -0800
committerfriendica <info@friendica.com>2013-01-06 19:25:01 -0800
commit3fc6df1000ea064e8f5ee6e066a79460d90b25cb (patch)
treebca9be1c79ae23bc3bde2c31e4254be5a991a30c /include/text.php
parenta9aa74a8074fd2eec58dd5927313fcef4fd5d930 (diff)
parentc94c500cdcfdc94427d7f7e2509e9af9ee0d78ae (diff)
downloadvolse-hubzilla-3fc6df1000ea064e8f5ee6e066a79460d90b25cb.tar.gz
volse-hubzilla-3fc6df1000ea064e8f5ee6e066a79460d90b25cb.tar.bz2
volse-hubzilla-3fc6df1000ea064e8f5ee6e066a79460d90b25cb.zip
Merge pull request #13 from fermionic/20130105-smarty3
implement smarty3
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php36
1 files changed, 28 insertions, 8 deletions
diff --git a/include/text.php b/include/text.php
index 5438aae73..9db22d9ed 100644
--- a/include/text.php
+++ b/include/text.php
@@ -13,15 +13,35 @@ require_once("include/template_processor.php");
if(! function_exists('replace_macros')) {
function replace_macros($s,$r) {
global $t;
-
- //$ts = microtime();
- $r = $t->replace($s,$r);
- //$tt = microtime() - $ts;
-
- //$a = get_app();
- //$a->page['debug'] .= "$tt <br>\n";
- return template_unescape($r);
+// $ts = microtime();
+ $a = get_app();
+
+ if($a->get_template_engine() === 'smarty3') {
+ $output = '';
+ if(gettype($s) !== 'NULL') {
+ $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);
+ }
+ $output = $s->parsed($template);
+ }
+ }
+ else {
+ $r = $t->replace($s,$r);
+
+ $output = template_unescape($r);
+ }
+// $tt = microtime() - $ts;
+// $a->page['debug'] .= "$tt <br>\n";
+ return $output;
}}