From ccdf702f14e6b15449a1fa93fb4be815e592028e Mon Sep 17 00:00:00 2001 From: Marius Cramer Date: Thu, 23 Jan 2014 11:08:24 +0100 Subject: [PATCH] Changed: Template class tag processing. Tags can now contain any amount of attributes. --- interface/lib/classes/tpl.inc.php | 109 ++++++++++++++++-------------- server/lib/classes/tpl.inc.php | 80 ++++++++-------------- 2 files changed, 88 insertions(+), 101 deletions(-) diff --git a/interface/lib/classes/tpl.inc.php b/interface/lib/classes/tpl.inc.php index 4b411e2c3c..a8533bb8ed 100644 --- a/interface/lib/classes/tpl.inc.php +++ b/interface/lib/classes/tpl.inc.php @@ -864,7 +864,7 @@ if (!defined('vlibTemplateClassLoaded')) { $regex = '/(<|<\/|{|{\/|){1}'; - $regex.= '([\r\n|\n|\r])?/i'; - $data = preg_replace_callback($regex, array($this, _parseTag), $data); + $regex.= '/i'; + $data = preg_replace_callback($regex, array($this, '_parseTag'), $data); if ($this->_cache) { // add cache if need be $this->_createCache($data); @@ -1026,8 +1006,7 @@ if (!defined('vlibTemplateClassLoaded')) { * @access private * @return string used for eval'ing */ - private function _parseIf($varname, $value = null, $op = null, $namespace = null) - { + function _parseIf ($varname, $value=null, $op=null, $namespace=null, $format=null) { if (isset($namespace)) $namespace = substr($namespace, 0, -1); $comp_str = ''; // used for extended if statements @@ -1065,9 +1044,19 @@ if (!defined('vlibTemplateClassLoaded')) { } } if ($this->OPTIONS['GLOBAL_VARS'] && empty($namespace)) { - return '(('.$retstr.'[\''.$varname.'\'] !== null) ? '.$retstr.'[\''.$varname.'\'] : $this->_vars[\''.$varname.'\'])'.$comp_str; - } else { - return $retstr."['".$varname."']".$comp_str; + $retstr = '(('.$retstr.'[\''.$varname.'\'] !== null) ? '.$retstr.'[\''.$varname.'\'] : $this->_vars[\''.$varname.'\'])'; + if(isset($format) && isset($value) && $format == 'version') { + return 'version_compare(' . $retstr . ', \'' . $value . '\', ' . (!empty($op) ? $op : '==') . ')'; + } else { + return $retstr.$comp_str; + } + } + else { + if(isset($format) && isset($value) && $format == 'version') { + return 'version_compare(' . $retstr."['".$varname."']" . ', \'' . $value . '\', ' . (!empty($op) ? $op : '==') . ')'; + } else { + return $retstr."['".$varname."']".$comp_str; + } } } @@ -1186,28 +1175,38 @@ if (!defined('vlibTemplateClassLoaded')) { $wholetag = $args[0]; $openclose = $args[1]; $tag = strtolower($args[2]); - $newline = $args[9]; - - if ($tag == 'else') return ''.$newline; + + if ($tag == 'else') return ''; if ($tag == 'tmpl_include') return $wholetag; // ignore tmpl_include tags if (preg_match("/^<\/|{\/|){1}'; $regex.= '/i'; - //$regex.= '([\r\n|\n|\r])?/ie'; $data = preg_replace_callback($regex, array($this, '_parseTag'), $data); if ($this->_cache) { // add cache if need be @@ -1300,28 +1269,37 @@ if (!defined('vlibTemplateClassLoaded')) { $wholetag = $args[0]; $openclose = $args[1]; $tag = strtolower($args[2]); - $newline = $args[11]; - //echo "1#$newline#2"; - - if ($tag == 'else') return ''.$newline; + + if ($tag == 'else') return ''; if ($tag == 'tmpl_include') return $wholetag; // ignore tmpl_include tags if (preg_match("/^<\/|{\/|