diff options
Diffstat (limited to 'inc/rain.tpl.class.php')
-rw-r--r-- | inc/rain.tpl.class.php | 170 |
1 files changed, 98 insertions, 72 deletions
diff --git a/inc/rain.tpl.class.php b/inc/rain.tpl.class.php index 30b6deb8..e9f3bd29 100644 --- a/inc/rain.tpl.class.php +++ b/inc/rain.tpl.class.php | |||
@@ -6,7 +6,7 @@ | |||
6 | * Realized by Federico Ulfo & maintained by the Rain Team | 6 | * Realized by Federico Ulfo & maintained by the Rain Team |
7 | * Distributed under GNU/LGPL 3 License | 7 | * Distributed under GNU/LGPL 3 License |
8 | * | 8 | * |
9 | * @version 2.6.4 | 9 | * @version 2.7 |
10 | */ | 10 | */ |
11 | 11 | ||
12 | 12 | ||
@@ -84,6 +84,16 @@ class RainTPL{ | |||
84 | 84 | ||
85 | 85 | ||
86 | /** | 86 | /** |
87 | * PHP tags <? ?> | ||
88 | * True: php tags are enabled into the template | ||
89 | * False: php tags are disabled into the template and rendered as html | ||
90 | * | ||
91 | * @var bool | ||
92 | */ | ||
93 | static $php_enabled = false; | ||
94 | |||
95 | |||
96 | /** | ||
87 | * Debug mode flag. | 97 | * Debug mode flag. |
88 | * True: debug mode is used, syntax errors are displayed directly in template. Execution of script is not terminated. | 98 | * True: debug mode is used, syntax errors are displayed directly in template. Execution of script is not terminated. |
89 | * False: exception is thrown on found error. | 99 | * False: exception is thrown on found error. |
@@ -106,11 +116,11 @@ class RainTPL{ | |||
106 | */ | 116 | */ |
107 | public $var = array(); | 117 | public $var = array(); |
108 | 118 | ||
109 | private $tpl = array(), // variables to keep the template directories and info | 119 | protected $tpl = array(), // variables to keep the template directories and info |
110 | $cache = false, // static cache enabled / disabled | 120 | $cache = false, // static cache enabled / disabled |
111 | $cache_id = null; // identify only one cache | 121 | $cache_id = null; // identify only one cache |
112 | 122 | ||
113 | private static $config_name_sum = null; // takes all the config to create the md5 of the file | 123 | protected static $config_name_sum = array(); // takes all the config to create the md5 of the file |
114 | 124 | ||
115 | // ------------------------- | 125 | // ------------------------- |
116 | 126 | ||
@@ -178,8 +188,7 @@ class RainTPL{ | |||
178 | ob_start(); | 188 | ob_start(); |
179 | extract( $this->var ); | 189 | extract( $this->var ); |
180 | include $this->tpl['compiled_filename']; | 190 | include $this->tpl['compiled_filename']; |
181 | $raintpl_contents = ob_get_contents(); | 191 | $raintpl_contents = ob_get_clean(); |
182 | ob_end_clean(); | ||
183 | //---------------------- | 192 | //---------------------- |
184 | 193 | ||
185 | 194 | ||
@@ -199,7 +208,6 @@ class RainTPL{ | |||
199 | 208 | ||
200 | 209 | ||
201 | 210 | ||
202 | |||
203 | /** | 211 | /** |
204 | * If exists a valid cache for this template it returns the cache | 212 | * If exists a valid cache for this template it returns the cache |
205 | * | 213 | * |
@@ -235,7 +243,7 @@ class RainTPL{ | |||
235 | self::configure( $key, $value ); | 243 | self::configure( $key, $value ); |
236 | else if( property_exists( __CLASS__, $setting ) ){ | 244 | else if( property_exists( __CLASS__, $setting ) ){ |
237 | self::$$setting = $value; | 245 | self::$$setting = $value; |
238 | self::$config_name_sum .= $value; // take trace of all config | 246 | self::$config_name_sum[$key] = $value; // take trace of all config |
239 | } | 247 | } |
240 | } | 248 | } |
241 | 249 | ||
@@ -243,7 +251,7 @@ class RainTPL{ | |||
243 | 251 | ||
244 | // check if has to compile the template | 252 | // check if has to compile the template |
245 | // return true if the template has changed | 253 | // return true if the template has changed |
246 | private function check_template( $tpl_name ){ | 254 | protected function check_template( $tpl_name ){ |
247 | 255 | ||
248 | if( !isset($this->tpl['checked']) ){ | 256 | if( !isset($this->tpl['checked']) ){ |
249 | 257 | ||
@@ -251,9 +259,9 @@ class RainTPL{ | |||
251 | $tpl_basedir = strpos($tpl_name,"/") ? dirname($tpl_name) . '/' : null; // template basedirectory | 259 | $tpl_basedir = strpos($tpl_name,"/") ? dirname($tpl_name) . '/' : null; // template basedirectory |
252 | $tpl_dir = self::$tpl_dir . $tpl_basedir; // template directory | 260 | $tpl_dir = self::$tpl_dir . $tpl_basedir; // template directory |
253 | $this->tpl['tpl_filename'] = $tpl_dir . $tpl_basename . '.' . self::$tpl_ext; // template filename | 261 | $this->tpl['tpl_filename'] = $tpl_dir . $tpl_basename . '.' . self::$tpl_ext; // template filename |
254 | $temp_compiled_filename = self::$cache_dir . $tpl_basename . "." . md5( $tpl_dir . self::$config_name_sum ); | 262 | $temp_compiled_filename = self::$cache_dir . $tpl_basename . "." . md5( $tpl_dir . implode('', self::$config_name_sum)); |
255 | $this->tpl['compiled_filename'] = $temp_compiled_filename . '.php'; // cache filename | 263 | $this->tpl['compiled_filename'] = $temp_compiled_filename . '.rtpl.php'; // cache filename |
256 | $this->tpl['cache_filename'] = $temp_compiled_filename . '.s_' . $this->cache_id . '.php'; // static cache filename | 264 | $this->tpl['cache_filename'] = $temp_compiled_filename . '.s_' . $this->cache_id . '.rtpl.php'; // static cache filename |
257 | 265 | ||
258 | // if the template doesn't exsist throw an error | 266 | // if the template doesn't exsist throw an error |
259 | if( self::$check_template_update && !file_exists( $this->tpl['tpl_filename'] ) ){ | 267 | if( self::$check_template_update && !file_exists( $this->tpl['tpl_filename'] ) ){ |
@@ -273,17 +281,17 @@ class RainTPL{ | |||
273 | 281 | ||
274 | /** | 282 | /** |
275 | * execute stripslaches() on the xml block. Invoqued by preg_replace_callback function below | 283 | * execute stripslaches() on the xml block. Invoqued by preg_replace_callback function below |
276 | * @access private | 284 | * @access protected |
277 | */ | 285 | */ |
278 | private function xml_reSubstitution($capture) { | 286 | protected function xml_reSubstitution($capture) { |
279 | return "<?php echo '<?xml ".stripslashes($capture[1])." ?>'; ?>"; | 287 | return "<?php echo '<?xml ".stripslashes($capture[1])." ?>'; ?>"; |
280 | } | 288 | } |
281 | 289 | ||
282 | /** | 290 | /** |
283 | * Compile and write the compiled template file | 291 | * Compile and write the compiled template file |
284 | * @access private | 292 | * @access protected |
285 | */ | 293 | */ |
286 | private function compileFile( $tpl_basename, $tpl_basedir, $tpl_filename, $cache_dir, $compiled_filename ){ | 294 | protected function compileFile( $tpl_basename, $tpl_basedir, $tpl_filename, $cache_dir, $compiled_filename ){ |
287 | 295 | ||
288 | //read template file | 296 | //read template file |
289 | $this->tpl['source'] = $template_code = file_get_contents( $tpl_filename ); | 297 | $this->tpl['source'] = $template_code = file_get_contents( $tpl_filename ); |
@@ -292,7 +300,8 @@ class RainTPL{ | |||
292 | $template_code = preg_replace( "/<\?xml(.*?)\?>/s", "##XML\\1XML##", $template_code ); | 300 | $template_code = preg_replace( "/<\?xml(.*?)\?>/s", "##XML\\1XML##", $template_code ); |
293 | 301 | ||
294 | //disable php tag | 302 | //disable php tag |
295 | $template_code = str_replace( array("<?","?>"), array("<?","?>"), $template_code ); | 303 | if( !self::$php_enabled ) |
304 | $template_code = str_replace( array("<?","?>"), array("<?","?>"), $template_code ); | ||
296 | 305 | ||
297 | //xml re-substitution | 306 | //xml re-substitution |
298 | $template_code = preg_replace_callback ( "/##XML(.*?)XML##/s", array($this, 'xml_reSubstitution'), $template_code ); | 307 | $template_code = preg_replace_callback ( "/##XML(.*?)XML##/s", array($this, 'xml_reSubstitution'), $template_code ); |
@@ -319,24 +328,25 @@ class RainTPL{ | |||
319 | 328 | ||
320 | /** | 329 | /** |
321 | * Compile template | 330 | * Compile template |
322 | * @access private | 331 | * @access protected |
323 | */ | 332 | */ |
324 | private function compileTemplate( $template_code, $tpl_basedir ){ | 333 | protected function compileTemplate( $template_code, $tpl_basedir ){ |
325 | 334 | ||
326 | //tag list | 335 | //tag list |
327 | $tag_regexp = array( 'loop' => '(\{loop(?: name){0,1}="\${0,1}[^"]*"\})', | 336 | $tag_regexp = array( 'loop' => '(\{loop(?: name){0,1}="\${0,1}[^"]*"\})', |
328 | 'loop_close' => '(\{\/loop\})', | 337 | 'loop_close' => '(\{\/loop\})', |
329 | 'if' => '(\{if(?: condition){0,1}="[^"]*"\})', | 338 | 'if' => '(\{if(?: condition){0,1}="[^"]*"\})', |
330 | 'elseif' => '(\{elseif(?: condition){0,1}="[^"]*"\})', | 339 | 'elseif' => '(\{elseif(?: condition){0,1}="[^"]*"\})', |
331 | 'else' => '(\{else\})', | 340 | 'else' => '(\{else\})', |
332 | 'if_close' => '(\{\/if\})', | 341 | 'if_close' => '(\{\/if\})', |
333 | 'function' => '(\{function="[^"]*"\})', | 342 | 'function' => '(\{function="[^"]*"\})', |
334 | 'noparse' => '(\{noparse\})', | 343 | 'noparse' => '(\{noparse\})', |
335 | 'noparse_close' => '(\{\/noparse\})', | 344 | 'noparse_close'=> '(\{\/noparse\})', |
336 | 'ignore' => '(\{ignore\})', | 345 | 'ignore' => '(\{ignore\})', |
337 | 'ignore_close' => '(\{\/ignore\})', | 346 | 'ignore_close' => '(\{\/ignore\})', |
338 | 'include' => '(\{include="[^"]*"(?: cache="[^"]*")?\})', | 347 | 'include' => '(\{include="[^"]*"(?: cache="[^"]*")?\})', |
339 | 'template_info' => '(\{\$template_info\})', | 348 | 'template_info'=> '(\{\$template_info\})', |
349 | 'function' => '(\{function="(\w*?)(?:.*?)"\})' | ||
340 | ); | 350 | ); |
341 | 351 | ||
342 | $tag_regexp = "/" . join( "|", $tag_regexp ) . "/"; | 352 | $tag_regexp = "/" . join( "|", $tag_regexp ) . "/"; |
@@ -359,15 +369,14 @@ class RainTPL{ | |||
359 | 369 | ||
360 | /** | 370 | /** |
361 | * Compile the code | 371 | * Compile the code |
362 | * @access private | 372 | * @access protected |
363 | */ | 373 | */ |
364 | private function compileCode( $parsed_code ){ | 374 | protected function compileCode( $parsed_code ){ |
365 | 375 | ||
366 | //variables initialization | 376 | //variables initialization |
367 | $compiled_code = $open_if = $comment_is_open = $ignore_is_open = null; | 377 | $compiled_code = $open_if = $comment_is_open = $ignore_is_open = null; |
368 | $loop_level = 0; | 378 | $loop_level = 0; |
369 | 379 | ||
370 | |||
371 | //read all parsed code | 380 | //read all parsed code |
372 | while( $html = array_shift( $parsed_code ) ){ | 381 | while( $html = array_shift( $parsed_code ) ){ |
373 | 382 | ||
@@ -397,32 +406,37 @@ class RainTPL{ | |||
397 | $comment_is_open = true; | 406 | $comment_is_open = true; |
398 | 407 | ||
399 | //include tag | 408 | //include tag |
400 | elseif( preg_match( '/(?:\{include="([^"]*)"(?: cache="([^"]*)"){0,1}\})/', $html, $code ) ){ | 409 | elseif( preg_match( '/\{include="([^"]*)"(?: cache="([^"]*)"){0,1}\}/', $html, $code ) ){ |
401 | 410 | ||
402 | //variables substitution | 411 | //variables substitution |
403 | $include_var = $this->var_replace( $code[ 1 ], $left_delimiter = null, $right_delimiter = null, $php_left_delimiter = '".' , $php_right_delimiter = '."', $loop_level ); | 412 | $include_var = $this->var_replace( $code[ 1 ], $left_delimiter = null, $right_delimiter = null, $php_left_delimiter = '".' , $php_right_delimiter = '."', $loop_level ); |
404 | 413 | ||
405 | // if the cache is active | 414 | // if the cache is active |
406 | if( isset($code[ 2 ]) ) | 415 | if( isset($code[ 2 ]) ){ |
416 | |||
407 | //dynamic include | 417 | //dynamic include |
408 | $compiled_code .= '<?php $tpl = new RainTPL;' . | 418 | $compiled_code .= '<?php $tpl = new RainTpl;' . |
409 | 'if( $cache = $tpl->cache( $template = basename("'.$include_var.'") ) )' . | 419 | 'if( $cache = $tpl->cache( $template = basename("'.$include_var.'") ) )' . |
410 | ' echo $cache;' . | 420 | ' echo $cache;' . |
411 | 'else{ ' . | 421 | 'else{' . |
412 | '$tpl_dir_temp = self::$tpl_dir;' . | 422 | ' $tpl_dir_temp = self::$tpl_dir;' . |
413 | '$tpl->assign( $this->var );' . | 423 | ' $tpl->assign( $this->var );' . |
414 | ( !$loop_level ? null : '$tpl->assign( "key", $key'.$loop_level.' ); $tpl->assign( "value", $value'.$loop_level.' );' ). | 424 | ( !$loop_level ? null : '$tpl->assign( "key", $key'.$loop_level.' ); $tpl->assign( "value", $value'.$loop_level.' );' ). |
415 | '$tpl->draw( dirname("'.$include_var.'") . ( substr("'.$include_var.'",-1,1) != "/" ? "/" : "" ) . $template );'. | 425 | ' $tpl->draw( dirname("'.$include_var.'") . ( substr("'.$include_var.'",-1,1) != "/" ? "/" : "" ) . basename("'.$include_var.'") );'. |
416 | '}' . | 426 | '} ?>'; |
417 | '?>'; | 427 | } |
418 | else | 428 | else{ |
429 | |||
419 | //dynamic include | 430 | //dynamic include |
420 | $compiled_code .= '<?php $tpl = new RainTPL;' . | 431 | $compiled_code .= '<?php $tpl = new RainTpl;' . |
421 | '$tpl_dir_temp = self::$tpl_dir;' . | 432 | '$tpl_dir_temp = self::$tpl_dir;' . |
422 | '$tpl->assign( $this->var );' . | 433 | '$tpl->assign( $this->var );' . |
423 | ( !$loop_level ? null : '$tpl->assign( "key", $key'.$loop_level.' ); $tpl->assign( "value", $value'.$loop_level.' );' ). | 434 | ( !$loop_level ? null : '$tpl->assign( "key", $key'.$loop_level.' ); $tpl->assign( "value", $value'.$loop_level.' );' ). |
424 | '$tpl->draw( dirname("'.$include_var.'") . ( substr("'.$include_var.'",-1,1) != "/" ? "/" : "" ) . basename("'.$include_var.'") );'. | 435 | '$tpl->draw( dirname("'.$include_var.'") . ( substr("'.$include_var.'",-1,1) != "/" ? "/" : "" ) . basename("'.$include_var.'") );'. |
425 | '?>'; | 436 | '?>'; |
437 | |||
438 | |||
439 | } | ||
426 | 440 | ||
427 | } | 441 | } |
428 | 442 | ||
@@ -518,7 +532,7 @@ class RainTPL{ | |||
518 | } | 532 | } |
519 | 533 | ||
520 | //function | 534 | //function |
521 | elseif( preg_match( '/\{function="([^(]*)(\([^)]*\)){0,1}"\}/', $html, $code ) ){ | 535 | elseif( preg_match( '/\{function="(\w*)(.*?)"\}/', $html, $code ) ){ |
522 | 536 | ||
523 | //tag | 537 | //tag |
524 | $tag = $code[ 0 ]; | 538 | $tag = $code[ 0 ]; |
@@ -529,11 +543,14 @@ class RainTPL{ | |||
529 | // check if there's any function disabled by black_list | 543 | // check if there's any function disabled by black_list |
530 | $this->function_check( $tag ); | 544 | $this->function_check( $tag ); |
531 | 545 | ||
532 | //parse the parameters | 546 | if( empty( $code[ 2 ] ) ) |
533 | $parsed_param = isset( $code[2] ) ? $this->var_replace( $code[2], $tag_left_delimiter = null, $tag_right_delimiter = null, $php_left_delimiter = null, $php_right_delimiter = null, $loop_level ) : '()'; | 547 | $parsed_function = $function . "()"; |
534 | 548 | else | |
549 | // parse the function | ||
550 | $parsed_function = $function . $this->var_replace( $code[ 2 ], $tag_left_delimiter = null, $tag_right_delimiter = null, $php_left_delimiter = null, $php_right_delimiter = null, $loop_level ); | ||
551 | |||
535 | //if code | 552 | //if code |
536 | $compiled_code .= "<?php echo {$function}{$parsed_param}; ?>"; | 553 | $compiled_code .= "<?php echo $parsed_function; ?>"; |
537 | } | 554 | } |
538 | 555 | ||
539 | // show all vars | 556 | // show all vars |
@@ -565,6 +582,13 @@ class RainTPL{ | |||
565 | } | 582 | } |
566 | return $compiled_code; | 583 | return $compiled_code; |
567 | } | 584 | } |
585 | |||
586 | |||
587 | |||
588 | protected function reduce_path( $path ){ | ||
589 | $path = str_replace( "//", "/", $path ); | ||
590 | return preg_replace('/\w+\/\.\.\//', '', $path ); | ||
591 | } | ||
568 | 592 | ||
569 | 593 | ||
570 | 594 | ||
@@ -577,28 +601,30 @@ class RainTPL{ | |||
577 | * @param string $html | 601 | * @param string $html |
578 | * @return string html sostituito | 602 | * @return string html sostituito |
579 | */ | 603 | */ |
580 | private function path_replace( $html, $tpl_basedir ){ | 604 | protected function path_replace( $html, $tpl_basedir ){ |
581 | 605 | ||
582 | if( self::$path_replace ){ | 606 | if( self::$path_replace ){ |
583 | 607 | ||
584 | // reduce the path | 608 | $tpl_dir = self::$base_url . self::$tpl_dir . $tpl_basedir; |
585 | $path = preg_replace('/\w+\/\.\.\//', '', self::$base_url . self::$tpl_dir . $tpl_basedir ); | 609 | |
610 | // reduce the path | ||
611 | $path = $this->reduce_path($tpl_dir); | ||
586 | 612 | ||
587 | $exp = $sub = array(); | 613 | $exp = $sub = array(); |
588 | 614 | ||
589 | if( in_array( "img", self::$path_replace_list ) ){ | 615 | if( in_array( "img", self::$path_replace_list ) ){ |
590 | $exp = array( '/<img(.*?)src=(?:")(http|https)\:\/\/([^"]+?)(?:")/i', '/<img(.*?)src=(?:")([^"]+?)#(?:")/i', '/<img(.*?)src="(.*?)"/', '/<img(.*?)src=(?:\@)([^"]+?)(?:\@)/i' ); | 616 | $exp = array( '/<img(.*?)src=(?:")(http|https)\:\/\/([^"]+?)(?:")/i', '/<img(.*?)src=(?:")([^"]+?)#(?:")/i', '/<img(.*?)src="(.*?)"/', '/<img(.*?)src=(?:\@)([^"]+?)(?:\@)/i' ); |
591 | $sub = array( '<img$1src=@$2://$3@', '<img$1src=@$2@', '<img$1src="' . self::$base_url . self::$tpl_dir . $tpl_basedir . '$2"', '<img$1src="$2"' ); | 617 | $sub = array( '<img$1src=@$2://$3@', '<img$1src=@$2@', '<img$1src="' . $path . '$2"', '<img$1src="$2"' ); |
592 | } | 618 | } |
593 | 619 | ||
594 | if( in_array( "script", self::$path_replace_list ) ){ | 620 | if( in_array( "script", self::$path_replace_list ) ){ |
595 | $exp = array_merge( $exp , array( '/<script(.*?)src=(?:")(http|https)\:\/\/([^"]+?)(?:")/i', '/<script(.*?)src=(?:")([^"]+?)#(?:")/i', '/<script(.*?)src="(.*?)"/', '/<script(.*?)src=(?:\@)([^"]+?)(?:\@)/i' ) ); | 621 | $exp = array_merge( $exp , array( '/<script(.*?)src=(?:")(http|https)\:\/\/([^"]+?)(?:")/i', '/<script(.*?)src=(?:")([^"]+?)#(?:")/i', '/<script(.*?)src="(.*?)"/', '/<script(.*?)src=(?:\@)([^"]+?)(?:\@)/i' ) ); |
596 | $sub = array_merge( $sub , array( '<script$1src=@$2://$3@', '<script$1src=@$2@', '<script$1src="' . self::$base_url . self::$tpl_dir . $tpl_basedir . '$2"', '<script$1src="$2"' ) ); | 622 | $sub = array_merge( $sub , array( '<script$1src=@$2://$3@', '<script$1src=@$2@', '<script$1src="' . $path . '$2"', '<script$1src="$2"' ) ); |
597 | } | 623 | } |
598 | 624 | ||
599 | if( in_array( "link", self::$path_replace_list ) ){ | 625 | if( in_array( "link", self::$path_replace_list ) ){ |
600 | $exp = array_merge( $exp , array( '/<link(.*?)href=(?:")(http|https)\:\/\/([^"]+?)(?:")/i', '/<link(.*?)href=(?:")([^"]+?)#(?:")/i', '/<link(.*?)href="(.*?)"/', '/<link(.*?)href=(?:\@)([^"]+?)(?:\@)/i' ) ); | 626 | $exp = array_merge( $exp , array( '/<link(.*?)href=(?:")(http|https)\:\/\/([^"]+?)(?:")/i', '/<link(.*?)href=(?:")([^"]+?)#(?:")/i', '/<link(.*?)href="(.*?)"/', '/<link(.*?)href=(?:\@)([^"]+?)(?:\@)/i' ) ); |
601 | $sub = array_merge( $sub , array( '<link$1href=@$2://$3@', '<link$1href=@$2@' , '<link$1href="' . self::$base_url . self::$tpl_dir . $tpl_basedir . '$2"', '<link$1href="$2"' ) ); | 627 | $sub = array_merge( $sub , array( '<link$1href=@$2://$3@', '<link$1href=@$2@' , '<link$1href="' . $path . '$2"', '<link$1href="$2"' ) ); |
602 | } | 628 | } |
603 | 629 | ||
604 | if( in_array( "a", self::$path_replace_list ) ){ | 630 | if( in_array( "a", self::$path_replace_list ) ){ |
@@ -608,7 +634,7 @@ class RainTPL{ | |||
608 | 634 | ||
609 | if( in_array( "input", self::$path_replace_list ) ){ | 635 | if( in_array( "input", self::$path_replace_list ) ){ |
610 | $exp = array_merge( $exp , array( '/<input(.*?)src=(?:")(http|https)\:\/\/([^"]+?)(?:")/i', '/<input(.*?)src=(?:")([^"]+?)#(?:")/i', '/<input(.*?)src="(.*?)"/', '/<input(.*?)src=(?:\@)([^"]+?)(?:\@)/i' ) ); | 636 | $exp = array_merge( $exp , array( '/<input(.*?)src=(?:")(http|https)\:\/\/([^"]+?)(?:")/i', '/<input(.*?)src=(?:")([^"]+?)#(?:")/i', '/<input(.*?)src="(.*?)"/', '/<input(.*?)src=(?:\@)([^"]+?)(?:\@)/i' ) ); |
611 | $sub = array_merge( $sub , array( '<input$1src=@$2://$3@', '<input$1src=@$2@', '<input$1src="' . self::$base_url . self::$tpl_dir . $tpl_basedir . '$2"', '<input$1src="$2"' ) ); | 637 | $sub = array_merge( $sub , array( '<input$1src=@$2://$3@', '<input$1src=@$2@', '<input$1src="' . $path . '$2"', '<input$1src="$2"' ) ); |
612 | } | 638 | } |
613 | 639 | ||
614 | return preg_replace( $exp, $sub, $html ); | 640 | return preg_replace( $exp, $sub, $html ); |
@@ -753,7 +779,7 @@ class RainTPL{ | |||
753 | $extra_var = $this->var_replace( $extra_var, null, null, null, null, $loop_level ); | 779 | $extra_var = $this->var_replace( $extra_var, null, null, null, null, $loop_level ); |
754 | 780 | ||
755 | // check if there's an operator = in the variable tags, if there's this is an initialization so it will not output any value | 781 | // check if there's an operator = in the variable tags, if there's this is an initialization so it will not output any value |
756 | $is_init_variable = preg_match( "/^(\s*?)\=[^=](.*?)$/", $extra_var ); | 782 | $is_init_variable = preg_match( "/^[a-z_A-Z\.\[\](\-\>)]*=[^=]*$/", $extra_var ); |
757 | 783 | ||
758 | //function associate to variable | 784 | //function associate to variable |
759 | $function_var = ( $extra_var and $extra_var[0] == '|') ? substr( $extra_var, 1 ) : null; | 785 | $function_var = ( $extra_var and $extra_var[0] == '|') ? substr( $extra_var, 1 ) : null; |
@@ -847,7 +873,7 @@ class RainTPL{ | |||
847 | * @param string $code | 873 | * @param string $code |
848 | * @param string $tag | 874 | * @param string $tag |
849 | */ | 875 | */ |
850 | private function function_check( $code ){ | 876 | protected function function_check( $code ){ |
851 | 877 | ||
852 | $preg = '#(\W|\s)' . implode( '(\W|\s)|(\W|\s)', self::$black_list ) . '(\W|\s)#'; | 878 | $preg = '#(\W|\s)' . implode( '(\W|\s)|(\W|\s)', self::$black_list ) . '(\W|\s)#'; |
853 | 879 | ||
@@ -875,7 +901,7 @@ class RainTPL{ | |||
875 | * @param RainTpl_Exception $e | 901 | * @param RainTpl_Exception $e |
876 | * @return string | 902 | * @return string |
877 | */ | 903 | */ |
878 | private function printDebug(RainTpl_Exception $e){ | 904 | protected function printDebug(RainTpl_Exception $e){ |
879 | if (!self::$debug) { | 905 | if (!self::$debug) { |
880 | throw $e; | 906 | throw $e; |
881 | } | 907 | } |
@@ -913,7 +939,7 @@ class RainTpl_Exception extends Exception{ | |||
913 | /** | 939 | /** |
914 | * Path of template file with error. | 940 | * Path of template file with error. |
915 | */ | 941 | */ |
916 | private $templateFile = ''; | 942 | protected $templateFile = ''; |
917 | 943 | ||
918 | /** | 944 | /** |
919 | * Returns path of template file with error. | 945 | * Returns path of template file with error. |
@@ -953,14 +979,14 @@ class RainTpl_SyntaxException extends RainTpl_Exception{ | |||
953 | * | 979 | * |
954 | * @var int | null | 980 | * @var int | null |
955 | */ | 981 | */ |
956 | private $templateLine = null; | 982 | protected $templateLine = null; |
957 | 983 | ||
958 | /** | 984 | /** |
959 | * Tag which caused an error. | 985 | * Tag which caused an error. |
960 | * | 986 | * |
961 | * @var string | null | 987 | * @var string | null |
962 | */ | 988 | */ |
963 | private $tag = null; | 989 | protected $tag = null; |
964 | 990 | ||
965 | /** | 991 | /** |
966 | * Returns line in template file where error has occured | 992 | * Returns line in template file where error has occured |
@@ -1008,4 +1034,4 @@ class RainTpl_SyntaxException extends RainTpl_Exception{ | |||
1008 | } | 1034 | } |
1009 | } | 1035 | } |
1010 | 1036 | ||
1011 | ?> \ No newline at end of file | 1037 | // -- end |