mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
fix order of php tag comparisons
This commit is contained in:
20
NEWS
20
NEWS
@@ -1,19 +1,21 @@
|
||||
- fix known problems with php tag handling in templates
|
||||
(recursion, echoing <?xml tags) (Monte)
|
||||
- add support for object registration (Monte)
|
||||
- add debug template to secure dir, add template_dir
|
||||
- add debug template to secure_dir, add template_dir
|
||||
to secure_dir by default (Ferdinand Beyer, Monte)
|
||||
- added support for object method access (Monte)
|
||||
- added support for assigned object access (Monte)
|
||||
- fixed bug with directories named '0' (Frank Bauer, Monte)
|
||||
- add javascript parameter to escape modifier (Monte)
|
||||
- added correct line numbers to syntax error messages
|
||||
in compiler (Monte)
|
||||
- added calling function line numbers to syntax error
|
||||
messages in compiler (Monte)
|
||||
- added support for modifiers to function calls (Monte)
|
||||
- support return value for custom functions (Monte)
|
||||
- can access constants via $smarty.const.FOO (Monte)
|
||||
- cleaned up regex code in compiler (Monte)
|
||||
- can now pass modifiers to static content (Monte)
|
||||
- fix up regex code in compiler, more flexible and
|
||||
- support return value for custom functions
|
||||
instead of echoing (but echo still works) (Monte)
|
||||
- added direct access to constants
|
||||
via $smarty.const.FOO (Monte)
|
||||
- added support for passing modifiers
|
||||
to static values (Monte)
|
||||
- fix up regex code in compiler, more accurate and
|
||||
maintainable (Monte)
|
||||
- added day_value_format to html_select_date (Marcus
|
||||
Bointon, Monte)
|
||||
|
@@ -247,6 +247,8 @@ class Smarty_Compiler extends Smarty {
|
||||
/* match anything resembling php tags */
|
||||
if (preg_match_all('!(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)!is', $text_blocks[$curr_tb], $sp_match)) {
|
||||
/* replace tags with placeholders to prevent recursive replacements */
|
||||
$sp_match[1] = array_unique($sp_match[1]);
|
||||
usort($sp_match[1], '_smarty_sort_length');
|
||||
for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
|
||||
$text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]);
|
||||
}
|
||||
@@ -264,7 +266,7 @@ class Smarty_Compiler extends Smarty {
|
||||
} else {
|
||||
/* SMARTY_PHP_ALLOW, but echo non php starting tags */
|
||||
$sp_match[1][$curr_sp] = preg_replace('%(<\?(?!php|=|$))%i', '<?php echo \'\\1\'?>'."\n", $sp_match[1][$curr_sp]);
|
||||
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%',$sp_match[1][$curr_sp],$text_blocks[$curr_tb]);
|
||||
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,7 +345,6 @@ class Smarty_Compiler extends Smarty {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compile a template tag
|
||||
*
|
||||
@@ -1818,6 +1819,25 @@ class Smarty_Compiler extends Smarty {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* compare to values by their string length
|
||||
*
|
||||
* @access private
|
||||
* @param $a
|
||||
* @param $b
|
||||
*/
|
||||
function _smarty_sort_length($a, $b)
|
||||
{
|
||||
if($a == $b)
|
||||
return 0;
|
||||
|
||||
if(strlen($a) == strlen($b))
|
||||
return ($a > $b) ? -1 : 1;
|
||||
|
||||
return (strlen($a) > strlen($b)) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
/* vim: set et: */
|
||||
|
||||
?>
|
||||
|
4
TODO
4
TODO
@@ -1,15 +1,11 @@
|
||||
* handle asp style tags in $php_handler
|
||||
* correctly capture nested php tag syntax in templates:
|
||||
<?php echo "<?php exit(); ?>"; ?>
|
||||
* support implementations of prefiltes, mods, and others as class methods.
|
||||
* ability to concatenate values/strings together
|
||||
* fix all E_NOTICE warnings
|
||||
* make simple math easier
|
||||
* caching all but parts of the template
|
||||
* change plugins so $smarty variable always comes first
|
||||
* being able to load config files from PHP scripts
|
||||
* get cache ttl with function call
|
||||
* make Config_File booleanize configurable through Smarty
|
||||
FIX: make inserts use normal functions before plugins
|
||||
UPD: change it so that if template comes from some resource,
|
||||
that resource stays as the default, no need to specify it
|
||||
|
@@ -247,6 +247,8 @@ class Smarty_Compiler extends Smarty {
|
||||
/* match anything resembling php tags */
|
||||
if (preg_match_all('!(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)!is', $text_blocks[$curr_tb], $sp_match)) {
|
||||
/* replace tags with placeholders to prevent recursive replacements */
|
||||
$sp_match[1] = array_unique($sp_match[1]);
|
||||
usort($sp_match[1], '_smarty_sort_length');
|
||||
for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
|
||||
$text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]);
|
||||
}
|
||||
@@ -264,7 +266,7 @@ class Smarty_Compiler extends Smarty {
|
||||
} else {
|
||||
/* SMARTY_PHP_ALLOW, but echo non php starting tags */
|
||||
$sp_match[1][$curr_sp] = preg_replace('%(<\?(?!php|=|$))%i', '<?php echo \'\\1\'?>'."\n", $sp_match[1][$curr_sp]);
|
||||
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%',$sp_match[1][$curr_sp],$text_blocks[$curr_tb]);
|
||||
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,7 +345,6 @@ class Smarty_Compiler extends Smarty {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compile a template tag
|
||||
*
|
||||
@@ -1818,6 +1819,25 @@ class Smarty_Compiler extends Smarty {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* compare to values by their string length
|
||||
*
|
||||
* @access private
|
||||
* @param $a
|
||||
* @param $b
|
||||
*/
|
||||
function _smarty_sort_length($a, $b)
|
||||
{
|
||||
if($a == $b)
|
||||
return 0;
|
||||
|
||||
if(strlen($a) == strlen($b))
|
||||
return ($a > $b) ? -1 : 1;
|
||||
|
||||
return (strlen($a) > strlen($b)) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
/* vim: set et: */
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user