aboutsummaryrefslogtreecommitdiffstats
path: root/include/template_processor.php
diff options
context:
space:
mode:
authorfabrixxm <fabrix.xm@gmail.com>2011-09-08 20:15:27 +0200
committerfabrixxm <fabrix.xm@gmail.com>2011-09-08 20:15:27 +0200
commitd284f8017cefb79571fe51c4ae3f85b9b4e517c9 (patch)
treefbf1902147b237649048e2ab6ac8a84ffe0bf838 /include/template_processor.php
parent2fabf8d2188516a36589487bfa2ca01dea0c5ca2 (diff)
parent68c23f6c86e2f2e24548b179f00b5bcd5ab8ba87 (diff)
downloadvolse-hubzilla-d284f8017cefb79571fe51c4ae3f85b9b4e517c9.tar.gz
volse-hubzilla-d284f8017cefb79571fe51c4ae3f85b9b4e517c9.tar.bz2
volse-hubzilla-d284f8017cefb79571fe51c4ae3f85b9b4e517c9.zip
Merge remote-tracking branch 'friendika/master' into newui
Diffstat (limited to 'include/template_processor.php')
-rw-r--r--include/template_processor.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/include/template_processor.php b/include/template_processor.php
index 11769bbd0..056d25488 100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -1,5 +1,6 @@
<?php
+
class Template {
var $r;
var $search;
@@ -8,6 +9,8 @@
var $nodes = array();
var $done = false;
var $d = false;
+ var $lang = null;
+
private function _preg_error(){
switch(preg_last_error()){
@@ -156,8 +159,24 @@
krsort($this->nodes);
return $s;
}
+
+ private function _get_lang(){
+ if ($this->lang!=null) return $this->lang;
+
+ $a = get_app();
+ $this->lang=array();
+ foreach ($a->strings as $k=>$v){
+ $k = preg_replace("/[^a-z0-9-]/", "", str_replace(" ","-", strtolower($k)));
+ $this->lang[$k] = $v;
+ }
+ return $this->lang;
+ }
+
public function replace($s, $r) {
+ if (!x($r,'$lang')){
+ $r['$lang'] = &$this->_get_lang();
+ }
$this->r = $r;
$this->search = array();
$this->replace = array();
@@ -171,7 +190,7 @@
// remove comments block
$s = preg_replace('/{#[^#]*#}/', "" , $s);
-
+
// replace strings recursively (limit to 10 loops)
$os = ""; $count=0;
while($os!=$s && $count<10){