aboutsummaryrefslogtreecommitdiffstats
path: root/include/template_processor.php
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-09-15 10:39:41 +0200
committerFabio Comuni <fabrix.xm@gmail.com>2011-09-15 10:39:41 +0200
commit019b735ec75989336826e5ad5db6377803ecb050 (patch)
tree15b642ec6e24d07d9d5c6009ec2ebf2a0b720742 /include/template_processor.php
parent7e806429cca6ac39a9ef1bd1fd400d03e626389b (diff)
parentd284f8017cefb79571fe51c4ae3f85b9b4e517c9 (diff)
downloadvolse-hubzilla-019b735ec75989336826e5ad5db6377803ecb050.tar.gz
volse-hubzilla-019b735ec75989336826e5ad5db6377803ecb050.tar.bz2
volse-hubzilla-019b735ec75989336826e5ad5db6377803ecb050.zip
Merge branch 'newui' of github.com:fabrixxm/friendika 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){