@@ -234,12 +234,12 @@ public function setVar($k, $v = null)
234234 if (is_array ($ k )) {
235235 foreach ($ k as $ key => $ value ){
236236 $ key = ($ this ->OPTIONS ['CASELESS ' ]) ? strtolower (trim ($ key )) : trim ($ key );
237- if (preg_match ('/^[A-Za-z ]+[A-Za-z0-9_]*$/ ' , $ key ) && $ value !== null ) {
237+ if (preg_match ('/^[A-Za-z_ ]+[A-Za-z0-9_]*$/ ' , $ key ) && $ value !== null ) {
238238 $ this ->_vars [$ key ] = $ value ;
239239 }
240240 }
241241 } else {
242- if (preg_match ('/^[A-Za-z ]+[A-Za-z0-9_]*$/ ' , $ k ) && $ v !== null ) {
242+ if (preg_match ('/^[A-Za-z_ ]+[A-Za-z0-9_]*$/ ' , $ k ) && $ v !== null ) {
243243 if ($ this ->OPTIONS ['CASELESS ' ]) $ k = strtolower ($ k );
244244 $ this ->_vars [trim ($ k )] = $ v ;
245245 } else {
@@ -287,7 +287,7 @@ public function unsetVar()
287287 for ($ i = 0 ; $ i < $ num_args ; $ i ++) {
288288 $ var = func_get_arg ($ i );
289289 if ($ this ->OPTIONS ['CASELESS ' ]) $ var = strtolower ($ var );
290- if (!preg_match ('/^[A-Za-z ]+[A-Za-z0-9_]*$/ ' , $ var )) continue ;
290+ if (!preg_match ('/^[A-Za-z_ ]+[A-Za-z0-9_]*$/ ' , $ var )) continue ;
291291 unset($ this ->_vars [$ var ]);
292292 }
293293 return true ;
@@ -344,7 +344,7 @@ public function setContextVars()
344344 */
345345 public function setLoop ($ k , $ v )
346346 {
347- if (is_array ($ v ) && preg_match ('/^[A-Za-z ]+[A-Za-z0-9_]*$/ ' , $ k )) {
347+ if (is_array ($ v ) && preg_match ('/^[A-Za-z_ ]+[A-Za-z0-9_]*$/ ' , $ k )) {
348348 $ k = ($ this ->OPTIONS ['CASELESS ' ]) ? strtolower (trim ($ k )) : trim ($ k );
349349 $ this ->_arrvars [$ k ] = array ();
350350 if ($ this ->OPTIONS ['SET_LOOP_VAR ' ] && !empty ($ v )) $ this ->setvar ($ k , 1 );
@@ -1006,7 +1006,8 @@ private function _arrayBuild($arr)
10061006 * @access private
10071007 * @return string used for eval'ing
10081008 */
1009- function _parseIf ($ varname , $ value =null , $ op =null , $ namespace =null , $ format =null ) {
1009+ private function _parseIf ($ varname , $ value = null , $ op = null , $ namespace = null , $ format = null )
1010+ {
10101011 if (isset ($ namespace )) $ namespace = substr ($ namespace , 0 , -1 );
10111012 $ comp_str = '' ; // used for extended if statements
10121013
@@ -1046,14 +1047,14 @@ function _parseIf ($varname, $value=null, $op=null, $namespace=null, $format=nul
10461047 if ($ this ->OPTIONS ['GLOBAL_VARS ' ] && empty ($ namespace )) {
10471048 $ retstr = '(( ' .$ retstr .'[ \'' .$ varname .'\'] !== null) ? ' .$ retstr .'[ \'' .$ varname .'\'] : $this->_vars[ \'' .$ varname .'\']) ' ;
10481049 if (isset ($ format ) && isset ($ value ) && $ format == 'version ' ) {
1049- return 'version_compare( ' . $ retstr . ', \'' . $ value . '\', ' . (!empty ($ op ) ? $ op : '== ' ) . ') ' ;
1050+ return 'version_compare( ' . $ retstr . ', \'' . $ value . '\', \'' . (!empty ($ op ) ? $ op : '== ' ) . '\ ') ' ;
10501051 } else {
10511052 return $ retstr .$ comp_str ;
10521053 }
10531054 }
10541055 else {
10551056 if (isset ($ format ) && isset ($ value ) && $ format == 'version ' ) {
1056- return 'version_compare( ' . $ retstr ."[' " .$ varname ."'] " . ', \'' . $ value . '\', ' . (!empty ($ op ) ? $ op : '== ' ) . ') ' ;
1057+ return 'version_compare( ' . $ retstr ."[' " .$ varname ."'] " . ', \'' . $ value . '\', \'' . (!empty ($ op ) ? $ op : '== ' ) . '\ ') ' ;
10571058 } else {
10581059 return $ retstr ."[' " .$ varname ."'] " .$ comp_str ;
10591060 }
@@ -1183,8 +1184,7 @@ private function _parseTag ($args)
11831184 if ($ tag == 'loop ' || $ tag == 'endloop ' ) array_pop ($ this ->_namespace );
11841185 if ($ tag == 'comment ' || $ tag == 'endcomment ' ) {
11851186 return '<?php */ ?> ' ;
1186- }
1187- else {
1187+ } else {
11881188 return '<?php } ?> ' ;
11891189 }
11901190 }
@@ -1207,6 +1207,7 @@ private function _parseTag ($args)
12071207 $ $ key = $ match [2 ];
12081208 }
12091209 }
1210+
12101211 $ var = ($ this ->OPTIONS ['CASELESS ' ]) ? strtolower ($ name ) : $ name ;
12111212
12121213 if ($ this ->_debug && !empty ($ var )) {
@@ -1228,47 +1229,37 @@ private function _parseTag ($args)
12281229 if (empty ($ escape ) && (!empty ($ this ->OPTIONS ['DEFAULT_ESCAPE ' ]) && strtolower ($ this ->OPTIONS ['DEFAULT_ESCAPE ' ]) != 'none ' )) {
12291230 $ escape = strtolower ($ this ->OPTIONS ['DEFAULT_ESCAPE ' ]);
12301231 }
1231- return '<?php ' .$ this ->_parseVar ($ wholetag , $ tag , $ var , @$ escape , @$ format , @$ namespace ).' ?> ' ."\n" ;
1232- break ;
1232+ return '<?php ' .$ this ->_parseVar ($ wholetag , $ tag , $ var , @$ escape , @$ format , @$ namespace )." ?> \n" ;
12331233
12341234 case 'if ' :
12351235 return '<?php if ( ' . $ this ->_parseIf ($ var , @$ value , @$ op , @$ namespace , @$ format ) .') { ?> ' ;
1236- break ;
12371236
12381237 case 'unless ' :
12391238 return '<?php if (! ' . $ this ->_parseIf ($ var , @$ value , @$ op , @$ namespace , @$ format ) .') { ?> ' ;
1240- break ;
12411239
12421240 case 'elseif ' :
12431241 return '<?php } elseif ( ' . $ this ->_parseIf ($ var , @$ value , @$ op , @$ namespace , @$ format ) .') { ?> ' ;
1244- break ;
12451242
12461243 case 'loop ' :
12471244 return '<?php ' . $ this ->_parseLoop ($ var ) .'?> ' ;
1248- break ;
12491245
12501246 case 'comment ' :
12511247 if (empty ($ var )) { // full open/close style comment
12521248 return '<?php /* ?> ' ;
1253- }
1254- else { // just ignore tag if it was a one line comment
1249+ } else { // just ignore tag if it was a one line comment
12551250 return ;
12561251 }
1257- break ;
12581252
12591253 case 'phpinclude ' :
12601254 if ($ this ->OPTIONS ['ENABLE_PHPINCLUDE ' ]) {
12611255 return '<?php include( \'' .$ file .'\'); ?> ' ;
12621256 }
1263- break ;
12641257
12651258 case 'include ' :
12661259 return '<?php $this->_getData($this->_fileSearch( \'' .$ file .'\'), 1); ?> ' ;
1267- break ;
12681260
12691261 case 'dyninclude ' :
12701262 return '<?php $this->_getData($this->_fileSearch($this->_dyninclude[ \'' .$ name .'\']), 1); ?> ' ;
1271- break ;
12721263
12731264 default :
12741265 if ($ this ->OPTIONS ['STRICT ' ]) vlibTemplateError::raiseError ('VT_ERROR_INVALID_TAG ' , KILL , htmlspecialchars ($ wholetag , ENT_QUOTES ));
0 commit comments