From d4d1ead7754ed394f5d429c58dc313c0d2c07046 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Fri, 07 Feb 2014 08:18:41 -0500
Subject: [PATCH] Merge remote-tracking branch 'origin/stable-3.0.5'

---
 interface/lib/classes/tpl.inc.php |   33 ++++++++++++---------------------
 1 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/interface/lib/classes/tpl.inc.php b/interface/lib/classes/tpl.inc.php
index a8533bb..34df2a9 100644
--- a/interface/lib/classes/tpl.inc.php
+++ b/interface/lib/classes/tpl.inc.php
@@ -234,12 +234,12 @@
 			if (is_array($k)) {
 				foreach($k as $key => $value){
 					$key = ($this->OPTIONS['CASELESS']) ? strtolower(trim($key)) : trim($key);
-					if (preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $key) && $value !== null ) {
+					if (preg_match('/^[A-Za-z_]+[A-Za-z0-9_]*$/', $key) && $value !== null ) {
 						$this->_vars[$key] = $value;
 					}
 				}
 			} else {
-				if (preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $k) && $v !== null) {
+				if (preg_match('/^[A-Za-z_]+[A-Za-z0-9_]*$/', $k) && $v !== null) {
 					if ($this->OPTIONS['CASELESS']) $k = strtolower($k);
 					$this->_vars[trim($k)] = $v;
 				} else {
@@ -287,7 +287,7 @@
 			for ($i = 0; $i < $num_args; $i++) {
 				$var = func_get_arg($i);
 				if ($this->OPTIONS['CASELESS']) $var = strtolower($var);
-				if (!preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $var)) continue;
+				if (!preg_match('/^[A-Za-z_]+[A-Za-z0-9_]*$/', $var)) continue;
 				unset($this->_vars[$var]);
 			}
 			return true;
@@ -344,7 +344,7 @@
 		 */
 		public function setLoop($k, $v)
 		{
-			if (is_array($v) && preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $k)) {
+			if (is_array($v) && preg_match('/^[A-Za-z_]+[A-Za-z0-9_]*$/', $k)) {
 				$k = ($this->OPTIONS['CASELESS']) ? strtolower(trim($k)) : trim($k);
 				$this->_arrvars[$k] = array();
 				if ($this->OPTIONS['SET_LOOP_VAR'] && !empty($v)) $this->setvar($k, 1);
@@ -1006,7 +1006,8 @@
 		 * @access private
 		 * @return string used for eval'ing
 		 */
-		function _parseIf ($varname, $value=null, $op=null, $namespace=null, $format=null) {
+		private 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
 
@@ -1046,14 +1047,14 @@
 			if ($this->OPTIONS['GLOBAL_VARS'] && empty($namespace)) {
 				$retstr = '(('.$retstr.'[\''.$varname.'\'] !== null) ? '.$retstr.'[\''.$varname.'\'] : $this->_vars[\''.$varname.'\'])';
 				if(isset($format) && isset($value) && $format == 'version') {
-					return 'version_compare(' . $retstr . ', \'' . $value . '\', ' . (!empty($op) ? $op : '==') . ')';
+					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 : '==') . ')';
+					return 'version_compare(' . $retstr."['".$varname."']" . ', \'' . $value . '\', \'' . (!empty($op) ? $op : '==') . '\')';
 				} else {
 					return $retstr."['".$varname."']".$comp_str;
 				}
@@ -1183,8 +1184,7 @@
 				if ($tag == 'loop' || $tag == 'endloop') array_pop($this->_namespace);
 				if ($tag == 'comment' || $tag == 'endcomment') {
 					return '<?php */ ?>';
-				}
-				else {
+				} else {
 					return '<?php } ?>';
 				}
 			}
@@ -1207,6 +1207,7 @@
 					$$key = $match[2];
 				}
 			}
+
 			$var = ($this->OPTIONS['CASELESS']) ? strtolower($name) : $name;
 
 			if ($this->_debug && !empty($var)) {
@@ -1228,47 +1229,37 @@
 				if (empty($escape) && (!empty($this->OPTIONS['DEFAULT_ESCAPE']) && strtolower($this->OPTIONS['DEFAULT_ESCAPE']) != 'none')) {
 					$escape = strtolower($this->OPTIONS['DEFAULT_ESCAPE']);
 				}
-				return '<?php '.$this->_parseVar ($wholetag, $tag, $var, @$escape, @$format, @$namespace).' ?>'."\n";
-				break;
+				return '<?php '.$this->_parseVar ($wholetag, $tag, $var, @$escape, @$format, @$namespace)." ?>\n";
 
 			case 'if':
 				return '<?php if ('. $this->_parseIf($var, @$value, @$op, @$namespace, @$format) .') { ?>';
-				break;
 
 			case 'unless':
 				return '<?php if (!'. $this->_parseIf($var, @$value, @$op, @$namespace, @$format) .') { ?>';
-				break;
 
 			case 'elseif':
 				return '<?php } elseif ('. $this->_parseIf($var, @$value, @$op, @$namespace, @$format) .') { ?>';
-				break;
 
 			case 'loop':
 				return '<?php '. $this->_parseLoop($var) .'?>';
-				break;
 
 			case 'comment':
 				if (empty($var)) { // full open/close style comment
 					return '<?php /* ?>';
-				}
-				else { // just ignore tag if it was a one line comment
+				} else { // just ignore tag if it was a one line comment
 					return;
 				}
-				break;
 
 			case 'phpinclude':
 				if ($this->OPTIONS['ENABLE_PHPINCLUDE']) {
 					return '<?php include(\''.$file.'\'); ?>';
 				}
-				break;
 
 			case 'include':
 				return '<?php $this->_getData($this->_fileSearch(\''.$file.'\'), 1); ?>';
-				break;
 
 			case 'dyninclude':
 				return '<?php $this->_getData($this->_fileSearch($this->_dyninclude[\''.$name.'\']), 1); ?>';
-				break;
 
 			default:
 				if ($this->OPTIONS['STRICT']) vlibTemplateError::raiseError('VT_ERROR_INVALID_TAG', KILL, htmlspecialchars($wholetag, ENT_QUOTES));

--
Gitblit v1.9.1