mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
add default modifier logic, minor doc updates
This commit is contained in:
@@ -152,6 +152,9 @@ class Smarty
|
|||||||
// sub directories are more efficient, but
|
// sub directories are more efficient, but
|
||||||
// you can set this to false if your PHP environment
|
// you can set this to false if your PHP environment
|
||||||
// does not allow the creation of them.
|
// does not allow the creation of them.
|
||||||
|
var $default_modifiers = '';
|
||||||
|
// modifier string to implicitly append to every var
|
||||||
|
// example: '|escape:"htmlall"'
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* END SMARTY CONFIGURATION SECTION */
|
/* END SMARTY CONFIGURATION SECTION */
|
||||||
@@ -1073,6 +1076,7 @@ function _generate_debug_output() {
|
|||||||
$smarty_compiler->trusted_dir = $this->trusted_dir;
|
$smarty_compiler->trusted_dir = $this->trusted_dir;
|
||||||
$smarty_compiler->_plugins = &$this->_plugins;
|
$smarty_compiler->_plugins = &$this->_plugins;
|
||||||
$smarty_compiler->_tpl_vars = &$this->_tpl_vars;
|
$smarty_compiler->_tpl_vars = &$this->_tpl_vars;
|
||||||
|
$smarty_compiler->default_modifiers = $this->default_modifiers;
|
||||||
|
|
||||||
if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled))
|
if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled))
|
||||||
return true;
|
return true;
|
||||||
|
@@ -1109,6 +1109,13 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$var_ref = $parts[0];
|
$var_ref = $parts[0];
|
||||||
$modifiers = isset($parts[1]) ? $parts[1] : '';
|
$modifiers = isset($parts[1]) ? $parts[1] : '';
|
||||||
|
|
||||||
|
|
||||||
|
if(!empty($this->default_modifiers) && !strstr($modifiers,'smarty:nodefaults')) {
|
||||||
|
$modifiers = empty($modifiers) ? $this->default_modifiers : $this->default_modifiers . '|' . $modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
$modifiers = str_replace(array('smarty:nodefaults','||'),array('','|'),$modifiers);
|
||||||
|
|
||||||
preg_match_all('!\[(?:\$\w+|\w+(\.\w+)?)\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match);
|
preg_match_all('!\[(?:\$\w+|\w+(\.\w+)?)\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match);
|
||||||
$indexes = $match[0];
|
$indexes = $match[0];
|
||||||
$var_name = array_shift($indexes);
|
$var_name = array_shift($indexes);
|
||||||
|
@@ -670,7 +670,7 @@ no title</programlisting>
|
|||||||
<entry>1</entry>
|
<entry>1</entry>
|
||||||
<entry>string</entry>
|
<entry>string</entry>
|
||||||
<entry>No</entry>
|
<entry>No</entry>
|
||||||
<entry>html,url,quotes,hex,hexentity</entry>
|
<entry>html,htmlall,url,quotes,hex,hexentity</entry>
|
||||||
<entry>html</entry>
|
<entry>html</entry>
|
||||||
<entry>This is the escape format to use.</entry>
|
<entry>This is the escape format to use.</entry>
|
||||||
</row>
|
</row>
|
||||||
@@ -678,12 +678,12 @@ no title</programlisting>
|
|||||||
</tgroup>
|
</tgroup>
|
||||||
</informaltable>
|
</informaltable>
|
||||||
<para>
|
<para>
|
||||||
This is used to html (or htmlall) escape, url escape, escape single
|
This is used to html escape, url escape, escape single quotes on a
|
||||||
quotes on a variable not already escaped, hex escape or hexentity
|
variable not already escaped, hex escape or hexentity escape. hex
|
||||||
escape. hex and hexentity escape can be used in conjunction to hide
|
and hexentity escape can be used in conjunction to hide "mailto:"
|
||||||
"mailto:" links on a page from web spiders (spam collectors) and
|
links on a page from web spiders (spam collectors) and yet keep
|
||||||
yet keep them readable and linkable. By default, the variable is
|
them readable and linkable. By default, the variable is html
|
||||||
html escaped.
|
escaped.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>escape</title>
|
<title>escape</title>
|
||||||
@@ -1195,8 +1195,8 @@ Blind woman gets new kidney<br>
|
|||||||
from dad she hasn't seen in years.
|
from dad she hasn't seen in years.
|
||||||
|
|
||||||
Blind woman gets new kidney fr
|
Blind woman gets new kidney fr
|
||||||
om dad she hasn't seen in
|
om dad she hasn't seen in year
|
||||||
years.</programlisting>
|
s.</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
@@ -152,6 +152,9 @@ class Smarty
|
|||||||
// sub directories are more efficient, but
|
// sub directories are more efficient, but
|
||||||
// you can set this to false if your PHP environment
|
// you can set this to false if your PHP environment
|
||||||
// does not allow the creation of them.
|
// does not allow the creation of them.
|
||||||
|
var $default_modifiers = '';
|
||||||
|
// modifier string to implicitly append to every var
|
||||||
|
// example: '|escape:"htmlall"'
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* END SMARTY CONFIGURATION SECTION */
|
/* END SMARTY CONFIGURATION SECTION */
|
||||||
@@ -1073,6 +1076,7 @@ function _generate_debug_output() {
|
|||||||
$smarty_compiler->trusted_dir = $this->trusted_dir;
|
$smarty_compiler->trusted_dir = $this->trusted_dir;
|
||||||
$smarty_compiler->_plugins = &$this->_plugins;
|
$smarty_compiler->_plugins = &$this->_plugins;
|
||||||
$smarty_compiler->_tpl_vars = &$this->_tpl_vars;
|
$smarty_compiler->_tpl_vars = &$this->_tpl_vars;
|
||||||
|
$smarty_compiler->default_modifiers = $this->default_modifiers;
|
||||||
|
|
||||||
if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled))
|
if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled))
|
||||||
return true;
|
return true;
|
||||||
|
@@ -1109,6 +1109,13 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$var_ref = $parts[0];
|
$var_ref = $parts[0];
|
||||||
$modifiers = isset($parts[1]) ? $parts[1] : '';
|
$modifiers = isset($parts[1]) ? $parts[1] : '';
|
||||||
|
|
||||||
|
|
||||||
|
if(!empty($this->default_modifiers) && !strstr($modifiers,'smarty:nodefaults')) {
|
||||||
|
$modifiers = empty($modifiers) ? $this->default_modifiers : $this->default_modifiers . '|' . $modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
$modifiers = str_replace(array('smarty:nodefaults','||'),array('','|'),$modifiers);
|
||||||
|
|
||||||
preg_match_all('!\[(?:\$\w+|\w+(\.\w+)?)\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match);
|
preg_match_all('!\[(?:\$\w+|\w+(\.\w+)?)\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match);
|
||||||
$indexes = $match[0];
|
$indexes = $match[0];
|
||||||
$var_name = array_shift($indexes);
|
$var_name = array_shift($indexes);
|
||||||
|
Reference in New Issue
Block a user