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_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 @@ class Smarty
$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 _run_insert_handler($args)
\*======================================================================*/
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 @@ function _run_insert_handler($args)
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 @@ function _run_insert_handler($args)
} 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 @@ function _run_insert_handler($args)
} 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;

View File

@@ -402,9 +402,17 @@ $smarty->autoload_filters = array('pre' => array('trim', 'stamp'),
<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 @@ $smarty->clear_assign(array("Name","Address","Zip"));</programlisting>
<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 @@ $smarty->clear_compiled_tpl();</programlisting>
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 @@ $smarty->display("db:header.tpl");</programlisting>
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>

View File

@@ -175,7 +175,6 @@ class Smarty
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 @@ class Smarty
$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 _run_insert_handler($args)
\*======================================================================*/
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 @@ function _run_insert_handler($args)
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 @@ function _run_insert_handler($args)
} 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 @@ function _run_insert_handler($args)
} 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;

View File

@@ -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");
}
}

View File

@@ -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");
}
}