change directory delimiter to "^" for cache and compile files

This commit is contained in:
mohrt
2002-06-14 20:58:20 +00:00
parent 5a04baca9f
commit d790f915f4
5 changed files with 59 additions and 54 deletions

View File

@@ -175,7 +175,6 @@ class Smarty
var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode
var $_smarty_debug_info = array(); // debugging information for debug console var $_smarty_debug_info = array(); // debugging information for debug console
var $_cache_info = array(); // info that makes up a cache file 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 var $_plugins = array( // table keeping track of plugins
'modifier' => array(), 'modifier' => array(),
'function' => array(), 'function' => array(),
@@ -457,7 +456,7 @@ class Smarty
$compile_id = $this->compile_id; $compile_id = $this->compile_id;
if (isset($compile_id) || isset($cache_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 else
$auto_id = null; $auto_id = null;
@@ -1403,18 +1402,15 @@ function _run_insert_handler($args)
\*======================================================================*/ \*======================================================================*/
function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null) function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
{ {
static $_auto_id_delim_hex = null;
static $_dir_sep = null; static $_dir_sep = null;
static $_dir_sep_enc = null;
if(!isset($_auto_id_delim_hex)) {
$_auto_id_delim_hex = strtoupper(bin2hex($this->_auto_id_delim));
}
if(!isset($_dir_sep)) { if(!isset($_dir_sep)) {
$_dir_sep_enc = urlencode(DIR_SEP);
if($this->use_sub_dirs) { if($this->use_sub_dirs) {
$_dir_sep = DIR_SEP; $_dir_sep = DIR_SEP;
} else { } else {
$_dir_sep = '%2F'; $_dir_sep = '^';
} }
} }
@@ -1422,15 +1418,15 @@ function _run_insert_handler($args)
if(isset($auto_id)) { if(isset($auto_id)) {
// make auto_id safe for directory names // 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 // 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; $res .= $auto_id . $_dir_sep;
} }
if(isset($auto_source)) { if(isset($auto_source)) {
// make source name safe for filename // 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'; $res .= $auto_source . '.php';
} }
@@ -1551,7 +1547,7 @@ function _run_insert_handler($args)
} else { } else {
// use local cache file // use local cache file
if (isset($compile_id) || isset($cache_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 else
$auto_id = null; $auto_id = null;
@@ -1587,7 +1583,7 @@ function _run_insert_handler($args)
} else { } else {
// use local file cache // use local file cache
if (isset($compile_id) || isset($cache_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 else
$auto_id = null; $auto_id = null;

View File

@@ -402,9 +402,17 @@ $smarty->autoload_filters = array('pre' => array('trim', 'stamp'),
<sect1 id="variable.compile.id"> <sect1 id="variable.compile.id">
<title>$compile_id</title> <title>$compile_id</title>
<para> <para>
Persistant compile identifier. As an alternative to passing the Persistant compile identifier. As an alternative to passing the same
same compile_id to each and every function call, you can set this compile_id to each and every function call, you can set this compile_id
compile_id and it will be used implicitly thereafter. 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> </para>
</sect1> </sect1>
</chapter> </chapter>
@@ -536,14 +544,17 @@ $smarty->clear_assign(array("Name","Address","Zip"));</programlisting>
<funcdef>void <function>clear_cache</function></funcdef> <funcdef>void <function>clear_cache</function></funcdef>
<paramdef>string <parameter>template</parameter></paramdef> <paramdef>string <parameter>template</parameter></paramdef>
<paramdef>string <parameter>cache id</parameter></paramdef> <paramdef>string <parameter>cache id</parameter></paramdef>
<paramdef>string <parameter>compile id</parameter></paramdef>
</funcprototype> </funcprototype>
</funcsynopsis> </funcsynopsis>
<para> <para>
This clears the cache for the specified template. If you have This clears the cache for a specific template. If you have
multiple caches for this template, you can clear a specific multiple caches for this template, you can clear a specific
cache by supplying the cache id as the second parameter. See the cache by supplying the cache id as the second parameter. You
<link linkend="features.caching">caching section</link> for more can also pass a compile id as a third paramter. You can "group"
information. This was added to Smarty 1.3.0. templates together so they can be removed as a group. See the
<link linkend="features.caching">caching section</link> for
more information.
</para> </para>
<example> <example>
<title>clear_cache</title> <title>clear_cache</title>
@@ -599,7 +610,13 @@ $smarty->clear_compiled_tpl();</programlisting>
As an optional third parameter, you can pass a compile id. This As an optional third parameter, you can pass a compile id. This
is in the event that you want to compile different versions of is in the event that you want to compile different versions of
the same template, such as having separate templates compiled 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> </para>
<example> <example>
<title>display</title> <title>display</title>
@@ -673,7 +690,13 @@ $smarty->display("db:header.tpl");</programlisting>
As an optional third parameter, you can pass a compile id. This As an optional third parameter, you can pass a compile id. This
is in the event that you want to compile different versions of is in the event that you want to compile different versions of
the same template, such as having separate templates compiled 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> </para>
<example> <example>
<title>fetch</title> <title>fetch</title>

View File

@@ -175,7 +175,6 @@ class Smarty
var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode
var $_smarty_debug_info = array(); // debugging information for debug console var $_smarty_debug_info = array(); // debugging information for debug console
var $_cache_info = array(); // info that makes up a cache file 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 var $_plugins = array( // table keeping track of plugins
'modifier' => array(), 'modifier' => array(),
'function' => array(), 'function' => array(),
@@ -457,7 +456,7 @@ class Smarty
$compile_id = $this->compile_id; $compile_id = $this->compile_id;
if (isset($compile_id) || isset($cache_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 else
$auto_id = null; $auto_id = null;
@@ -1403,18 +1402,15 @@ function _run_insert_handler($args)
\*======================================================================*/ \*======================================================================*/
function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null) function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
{ {
static $_auto_id_delim_hex = null;
static $_dir_sep = null; static $_dir_sep = null;
static $_dir_sep_enc = null;
if(!isset($_auto_id_delim_hex)) {
$_auto_id_delim_hex = strtoupper(bin2hex($this->_auto_id_delim));
}
if(!isset($_dir_sep)) { if(!isset($_dir_sep)) {
$_dir_sep_enc = urlencode(DIR_SEP);
if($this->use_sub_dirs) { if($this->use_sub_dirs) {
$_dir_sep = DIR_SEP; $_dir_sep = DIR_SEP;
} else { } else {
$_dir_sep = '%2F'; $_dir_sep = '^';
} }
} }
@@ -1422,15 +1418,15 @@ function _run_insert_handler($args)
if(isset($auto_id)) { if(isset($auto_id)) {
// make auto_id safe for directory names // 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 // 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; $res .= $auto_id . $_dir_sep;
} }
if(isset($auto_source)) { if(isset($auto_source)) {
// make source name safe for filename // 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'; $res .= $auto_source . '.php';
} }
@@ -1551,7 +1547,7 @@ function _run_insert_handler($args)
} else { } else {
// use local cache file // use local cache file
if (isset($compile_id) || isset($cache_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 else
$auto_id = null; $auto_id = null;
@@ -1587,7 +1583,7 @@ function _run_insert_handler($args)
} else { } else {
// use local file cache // use local file cache
if (isset($compile_id) || isset($cache_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 else
$auto_id = null; $auto_id = null;

View File

@@ -10,16 +10,11 @@
*/ */
function smarty_function_popup_init($params, &$smarty) function smarty_function_popup_init($params, &$smarty)
{ {
// be sure to place overlib.js where Smarty can locate it. if (!empty($params['src'])) {
// overlib.js came with the distribution of Smarty. echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n";
extract($params); echo '<script language="JavaScript" src="'.$params['src'].'"></script>'."\n";
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";
} else { } else {
echo '<script language="JavaScript" src="'.$src.'"></script>'."\n"; $smarty->trigger_error("popup_init: missing src parameter");
} }
} }

View File

@@ -10,16 +10,11 @@
*/ */
function smarty_function_popup_init($params, &$smarty) function smarty_function_popup_init($params, &$smarty)
{ {
// be sure to place overlib.js where Smarty can locate it. if (!empty($params['src'])) {
// overlib.js came with the distribution of Smarty. echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n";
extract($params); echo '<script language="JavaScript" src="'.$params['src'].'"></script>'."\n";
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";
} else { } else {
echo '<script language="JavaScript" src="'.$src.'"></script>'."\n"; $smarty->trigger_error("popup_init: missing src parameter");
} }
} }