cvs: smarty / Smarty.class.php Smarty_Compiler.class.php /docs designers.sgml

From: Date: Wed, 17 Jul 2002 21:16:43 +0000
Subject: cvs: smarty / Smarty.class.php Smarty_Compiler.class.php /docs designers.sgml
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-197@lists.php.net to get a copy of this message
mohrt Wed Jul 17 17:16:43 2002 EDT Modified files: /smarty Smarty.class.php Smarty_Compiler.class.php /smarty/docs designers.sgml Log: add default modifier logic, minor doc updates Index: smarty/Smarty.class.php diff -u smarty/Smarty.class.php:1.306 smarty/Smarty.class.php:1.307 --- smarty/Smarty.class.php:1.306 Wed Jul 17 09:42:29 2002 +++ smarty/Smarty.class.php Wed Jul 17 17:16:42 2002 @@ -152,6 +152,9 @@ // sub directories are more efficient, but // you can set this to false if your PHP environment // 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 */ @@ -1073,6 +1076,7 @@ $smarty_compiler->trusted_dir = $this->trusted_dir; $smarty_compiler->_plugins = &$this->_plugins; $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)) return true; Index: smarty/Smarty_Compiler.class.php diff -u smarty/Smarty_Compiler.class.php:1.120 smarty/Smarty_Compiler.class.php:1.121 --- smarty/Smarty_Compiler.class.php:1.120 Thu Jul 11 11:18:39 2002 +++ smarty/Smarty_Compiler.class.php Wed Jul 17 17:16:43 2002 @@ -1109,6 +1109,13 @@ $var_ref = $parts[0]; $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); $indexes = $match[0]; $var_name = array_shift($indexes); Index: smarty/docs/designers.sgml diff -u smarty/docs/designers.sgml:1.37 smarty/docs/designers.sgml:1.38 --- smarty/docs/designers.sgml:1.37 Mon Jul 8 10:59:02 2002 +++ smarty/docs/designers.sgml Wed Jul 17 17:16:43 2002 @@ -670,7 +670,7 @@ <entry>1</entry> <entry>string</entry> <entry>No</entry> - <entry>html,url,quotes,hex,hexentity</entry> + <entry>html,htmlall,url,quotes,hex,hexentity</entry> <entry>html</entry> <entry>This is the escape format to use.</entry> </row> @@ -678,12 +678,12 @@ </tgroup> </informaltable> <para> - This is used to html (or htmlall) escape, url escape, escape single - quotes on a variable not already escaped, hex escape or hexentity - escape. hex and hexentity escape can be used in conjunction to hide - "mailto:" links on a page from web spiders (spam collectors) and - yet keep them readable and linkable. By default, the variable is - html escaped. + This is used to html escape, url escape, escape single quotes on a + variable not already escaped, hex escape or hexentity escape. hex + and hexentity escape can be used in conjunction to hide "mailto:" + links on a page from web spiders (spam collectors) and yet keep + them readable and linkable. By default, the variable is html + escaped. </para> <example> <title>escape</title> @@ -1195,8 +1195,8 @@ from dad she hasn't seen in years. Blind woman gets new kidney fr -om dad she hasn't seen in -years.</programlisting> +om dad she hasn't seen in year +s.</programlisting> </example> </sect1>

« previous php.smarty.cvs (#197) next »