cvs: smarty / Smarty.class.php /docs programmers.sgml /plugins function.popup_init.php
| From: | Monte Ohrt | Date: | Fri, 14 Jun 2002 20:58:21 +0000 |
| Subject: | cvs: smarty / Smarty.class.php /docs programmers.sgml /plugins function.popup_init.php | ||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-137@lists.php.net to get a copy of this message | ||
mohrt Fri Jun 14 16:58:21 2002 EDT
Modified files:
/smarty Smarty.class.php
/smarty/docs programmers.sgml
/smarty/plugins function.popup_init.php
Log:
change directory delimiter to "^" for cache and compile files
Index: smarty/Smarty.class.php diff -u smarty/Smarty.class.php:1.282 smarty/Smarty.class.php:1.283 --- smarty/Smarty.class.php:1.282 Tue Jun 11 16:06:34 2002 +++ smarty/Smarty.class.php Fri Jun 14 16:58:19 2002 @@ -175,7 +175,6 @@ var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode var $_smarty_debug_info = array(); // debugging information for debug console var $_cache_info = array(); // info that makes up a cache file - var $_auto_id_delim = '|'; // delimiter for auto_id groups var $_plugins = array( // table keeping track of plugins 'modifier' => array(), 'function' => array(), @@ -457,7 +456,7 @@ $compile_id = $this->compile_id; if (isset($compile_id) || isset($cache_id)) - $auto_id = (isset($compile_id)) ? $compile_id . $this->_auto_id_delim . $cache_id : $cache_id; + $auto_id = (isset($compile_id)) ? $compile_id . '|' . $cache_id : $cache_id; else $auto_id = null; @@ -1403,18 +1402,15 @@ \*======================================================================*/ function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null) { - static $_auto_id_delim_hex = null; static $_dir_sep = null; - - if(!isset($_auto_id_delim_hex)) { - $_auto_id_delim_hex = strtoupper(bin2hex($this->_auto_id_delim)); - } + static $_dir_sep_enc = null; if(!isset($_dir_sep)) { + $_dir_sep_enc = urlencode(DIR_SEP); if($this->use_sub_dirs) { $_dir_sep = DIR_SEP; } else { - $_dir_sep = '%2F'; + $_dir_sep = '^'; } } @@ -1422,15 +1418,15 @@ if(isset($auto_id)) { // make auto_id safe for directory names - $auto_id = str_replace('%'.$_auto_id_delim_hex,$this->_auto_id_delim,(urlencode($auto_id))); + $auto_id = str_replace('%7C','|',(urlencode($auto_id))); // split into separate directories - $auto_id = str_replace($this->_auto_id_delim, $_dir_sep, $auto_id); + $auto_id = str_replace('|', $_dir_sep, $auto_id); $res .= $auto_id . $_dir_sep; } if(isset($auto_source)) { // make source name safe for filename - $auto_source = urlencode($auto_source); + $auto_source = str_replace($_dir_sep_enc,'^',urlencode($auto_source)); $res .= $auto_source . '.php'; } @@ -1551,7 +1547,7 @@ } else { // use local cache file if (isset($compile_id) || isset($cache_id)) - $auto_id = (isset($compile_id)) ? $compile_id . $this->_auto_id_delim . $cache_id : $cache_id; + $auto_id = (isset($compile_id)) ? $compile_id . '|' . $cache_id : $cache_id; else $auto_id = null; @@ -1587,7 +1583,7 @@ } else { // use local file cache if (isset($compile_id) || isset($cache_id)) - $auto_id = (isset($compile_id)) ? $compile_id . $this->_auto_id_delim . $cache_id : $cache_id; + $auto_id = (isset($compile_id)) ? $compile_id . '|' . $cache_id : $cache_id; else $auto_id = null; Index: smarty/docs/programmers.sgml diff -u smarty/docs/programmers.sgml:1.12 smarty/docs/programmers.sgml:1.13 --- smarty/docs/programmers.sgml:1.12 Tue Apr 30 09:57:13 2002 +++ smarty/docs/programmers.sgml Fri Jun 14 16:58:20 2002 @@ -402,9 +402,17 @@ <sect1 id="variable.compile.id"> <title>$compile_id</title> <para> - Persistant compile identifier. As an alternative to passing the - same compile_id to each and every function call, you can set this - compile_id and it will be used implicitly thereafter. + Persistant compile identifier. As an alternative to passing the same + compile_id to each and every function call, you can set this compile_id + and it will be used implicitly thereafter. + </para> + </sect1> + <sect1 id="variable.use.sub.dirs"> + <title>$use_sub_dirs</title> + <para> + Set this to false if your PHP environment does not allow the creation of + sub directories by Smarty. Sub directories are more efficient, so use them + if you can. </para> </sect1> </chapter> @@ -536,14 +544,17 @@ <funcdef>void <function>clear_cache</function></funcdef> <paramdef>string <parameter>template</parameter></paramdef> <paramdef>string <parameter>cache id</parameter></paramdef> + <paramdef>string <parameter>compile id</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - This clears the cache for the specified template. If you have - multiple caches for this template, you can clear a specific - cache by supplying the cache id as the second parameter. See the - <link linkend="features.caching">caching section</link> for more - information. This was added to Smarty 1.3.0. + This clears the cache for a specific template. If you have + multiple caches for this template, you can clear a specific + cache by supplying the cache id as the second parameter. You + can also pass a compile id as a third paramter. You can "group" + templates together so they can be removed as a group. See the + <link linkend="features.caching">caching section</link> for + more information. </para> <example> <title>clear_cache</title> @@ -599,7 +610,13 @@ As an optional third parameter, you can pass a compile id. This is in the event that you want to compile different versions of the same template, such as having separate templates compiled - for different languages. This was added to Smarty 1.4.5. + for different languages. Another use for compile_id is when you + use more than one $template_dir but only one $compile_dir. Set + a separate compile_id for each $template_dir, otherwise + templates of the same name will overwrite each other. You can + also set the <link + linkend="variable.compile.id">$compile_id</link> variable once + instead of passing this to each call to display(). </para> <example> <title>display</title> @@ -673,7 +690,13 @@ As an optional third parameter, you can pass a compile id. This is in the event that you want to compile different versions of the same template, such as having separate templates compiled - for different languages. This was added to Smarty 1.4.5. + for different languages. Another use for compile_id is when you + use more than one $template_dir but only one $compile_dir. Set + a separate compile_id for each $template_dir, otherwise + templates of the same name will overwrite each other. You can + also set the <link + linkend="variable.compile.id">$compile_id</link> variable once + instead of passing this to each call to fetch(). </para> <example> <title>fetch</title> Index: smarty/plugins/function.popup_init.php diff -u smarty/plugins/function.popup_init.php:1.3 smarty/plugins/function.popup_init.php:1.4 --- smarty/plugins/function.popup_init.php:1.3 Wed Feb 20 17:24:32 2002 +++ smarty/plugins/function.popup_init.php Fri Jun 14 16:58:20 2002 @@ -10,16 +10,11 @@ */ function smarty_function_popup_init($params, &$smarty) { - // be sure to place overlib.js where Smarty can locate it. - // overlib.js came with the distribution of Smarty. - extract($params); - echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n"; - if (empty($src)) { - echo '<script language="JavaScript">'."\n".'<!--'."\n"; - readfile(SMARTY_DIR."overlib.js",1); - echo '// -->'."\n".'</script>'."\n"; + if (!empty($params['src'])) { + echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n"; + echo '<script language="JavaScript" src="'.$params['src'].'"></script>'."\n"; } else { - echo '<script language="JavaScript" src="'.$src.'"></script>'."\n"; + $smarty->trigger_error("popup_init: missing src parameter"); } }
Index: smarty/Smarty.class.php diff -u smarty/Smarty.class.php:1.282 smarty/Smarty.class.php:1.283 --- smarty/Smarty.class.php:1.282 Tue Jun 11 16:06:34 2002 +++ smarty/Smarty.class.php Fri Jun 14 16:58:19 2002 @@ -175,7 +175,6 @@ var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode var $_smarty_debug_info = array(); // debugging information for debug console var $_cache_info = array(); // info that makes up a cache file - var $_auto_id_delim = '|'; // delimiter for auto_id groups var $_plugins = array( // table keeping track of plugins 'modifier' => array(), 'function' => array(), @@ -457,7 +456,7 @@ $compile_id = $this->compile_id; if (isset($compile_id) || isset($cache_id)) - $auto_id = (isset($compile_id)) ? $compile_id . $this->_auto_id_delim . $cache_id : $cache_id; + $auto_id = (isset($compile_id)) ? $compile_id . '|' . $cache_id : $cache_id; else $auto_id = null; @@ -1403,18 +1402,15 @@ \*======================================================================*/ function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null) { - static $_auto_id_delim_hex = null; static $_dir_sep = null; - - if(!isset($_auto_id_delim_hex)) { - $_auto_id_delim_hex = strtoupper(bin2hex($this->_auto_id_delim)); - } + static $_dir_sep_enc = null; if(!isset($_dir_sep)) { + $_dir_sep_enc = urlencode(DIR_SEP); if($this->use_sub_dirs) { $_dir_sep = DIR_SEP; } else { - $_dir_sep = '%2F'; + $_dir_sep = '^'; } } @@ -1422,15 +1418,15 @@ if(isset($auto_id)) { // make auto_id safe for directory names - $auto_id = str_replace('%'.$_auto_id_delim_hex,$this->_auto_id_delim,(urlencode($auto_id))); + $auto_id = str_replace('%7C','|',(urlencode($auto_id))); // split into separate directories - $auto_id = str_replace($this->_auto_id_delim, $_dir_sep, $auto_id); + $auto_id = str_replace('|', $_dir_sep, $auto_id); $res .= $auto_id . $_dir_sep; } if(isset($auto_source)) { // make source name safe for filename - $auto_source = urlencode($auto_source); + $auto_source = str_replace($_dir_sep_enc,'^',urlencode($auto_source)); $res .= $auto_source . '.php'; } @@ -1551,7 +1547,7 @@ } else { // use local cache file if (isset($compile_id) || isset($cache_id)) - $auto_id = (isset($compile_id)) ? $compile_id . $this->_auto_id_delim . $cache_id : $cache_id; + $auto_id = (isset($compile_id)) ? $compile_id . '|' . $cache_id : $cache_id; else $auto_id = null; @@ -1587,7 +1583,7 @@ } else { // use local file cache if (isset($compile_id) || isset($cache_id)) - $auto_id = (isset($compile_id)) ? $compile_id . $this->_auto_id_delim . $cache_id : $cache_id; + $auto_id = (isset($compile_id)) ? $compile_id . '|' . $cache_id : $cache_id; else $auto_id = null; Index: smarty/docs/programmers.sgml diff -u smarty/docs/programmers.sgml:1.12 smarty/docs/programmers.sgml:1.13 --- smarty/docs/programmers.sgml:1.12 Tue Apr 30 09:57:13 2002 +++ smarty/docs/programmers.sgml Fri Jun 14 16:58:20 2002 @@ -402,9 +402,17 @@ <sect1 id="variable.compile.id"> <title>$compile_id</title> <para> - Persistant compile identifier. As an alternative to passing the - same compile_id to each and every function call, you can set this - compile_id and it will be used implicitly thereafter. + Persistant compile identifier. As an alternative to passing the same + compile_id to each and every function call, you can set this compile_id + and it will be used implicitly thereafter. + </para> + </sect1> + <sect1 id="variable.use.sub.dirs"> + <title>$use_sub_dirs</title> + <para> + Set this to false if your PHP environment does not allow the creation of + sub directories by Smarty. Sub directories are more efficient, so use them + if you can. </para> </sect1> </chapter> @@ -536,14 +544,17 @@ <funcdef>void <function>clear_cache</function></funcdef> <paramdef>string <parameter>template</parameter></paramdef> <paramdef>string <parameter>cache id</parameter></paramdef> + <paramdef>string <parameter>compile id</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - This clears the cache for the specified template. If you have - multiple caches for this template, you can clear a specific - cache by supplying the cache id as the second parameter. See the - <link linkend="features.caching">caching section</link> for more - information. This was added to Smarty 1.3.0. + This clears the cache for a specific template. If you have + multiple caches for this template, you can clear a specific + cache by supplying the cache id as the second parameter. You + can also pass a compile id as a third paramter. You can "group" + templates together so they can be removed as a group. See the + <link linkend="features.caching">caching section</link> for + more information. </para> <example> <title>clear_cache</title> @@ -599,7 +610,13 @@ As an optional third parameter, you can pass a compile id. This is in the event that you want to compile different versions of the same template, such as having separate templates compiled - for different languages. This was added to Smarty 1.4.5. + for different languages. Another use for compile_id is when you + use more than one $template_dir but only one $compile_dir. Set + a separate compile_id for each $template_dir, otherwise + templates of the same name will overwrite each other. You can + also set the <link + linkend="variable.compile.id">$compile_id</link> variable once + instead of passing this to each call to display(). </para> <example> <title>display</title> @@ -673,7 +690,13 @@ As an optional third parameter, you can pass a compile id. This is in the event that you want to compile different versions of the same template, such as having separate templates compiled - for different languages. This was added to Smarty 1.4.5. + for different languages. Another use for compile_id is when you + use more than one $template_dir but only one $compile_dir. Set + a separate compile_id for each $template_dir, otherwise + templates of the same name will overwrite each other. You can + also set the <link + linkend="variable.compile.id">$compile_id</link> variable once + instead of passing this to each call to fetch(). </para> <example> <title>fetch</title> Index: smarty/plugins/function.popup_init.php diff -u smarty/plugins/function.popup_init.php:1.3 smarty/plugins/function.popup_init.php:1.4 --- smarty/plugins/function.popup_init.php:1.3 Wed Feb 20 17:24:32 2002 +++ smarty/plugins/function.popup_init.php Fri Jun 14 16:58:20 2002 @@ -10,16 +10,11 @@ */ function smarty_function_popup_init($params, &$smarty) { - // be sure to place overlib.js where Smarty can locate it. - // overlib.js came with the distribution of Smarty. - extract($params); - echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n"; - if (empty($src)) { - echo '<script language="JavaScript">'."\n".'<!--'."\n"; - readfile(SMARTY_DIR."overlib.js",1); - echo '// -->'."\n".'</script>'."\n"; + if (!empty($params['src'])) { + echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n"; + echo '<script language="JavaScript" src="'.$params['src'].'"></script>'."\n"; } else { - echo '<script language="JavaScript" src="'.$src.'"></script>'."\n"; + $smarty->trigger_error("popup_init: missing src parameter"); } }