Re: [SMARTY] Re: [SMARTY-DEV] SV: [SMARTY] RC2 released
| From: | Hinrich Donner | Date: | Thu, 27 Mar 2003 12:43:15 +0000 |
| Subject: | Re: [SMARTY] Re: [SMARTY-DEV] SV: [SMARTY] RC2 released | ||
| References: | 1 2 3 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-8937@lists.php.net to get a copy of this message | ||
Hi!
On Thursday 27 March 2003 13:28, Pete Morganic wrote:
> Here we go again. This issue keeps repeating itself with problems like
> file permissions, no sheel access etc..
>
> Could there be a special "function" in smarty that can delete the
> templates using the configuration
> eg $smarty->deleteTemplates()
I have created a simple method for this.
/**
* Check Version
*
* This method check the current version of Smarty. On different
* versions the compiled and cached templates are deleted. On a
* version before 2.4.0 the script will be aborted.
*
* @access private
*/
function _CheckVersion()
{
// Test required version
//
if (version_compare('2.4.0', $this->_version, '>'))
die("Please install Smarty 2.4.0 or later in 'lib/smarty/'");
$filename = _TIS_PATH_MAIN.'/tmp/version.smarty';
if (file_exists($filename))
{
// Check last used version
//
if (false === ($file_handle = fopen($filename, 'r')))
trigger_error("Can't read the file '{$filename}'!",
E_USER_WARNING);
else
{
$_old_version = fgets($file_handle, 254);
fclose($file_handle);
// If the versions are equal, leave here
//
if (strcmp($this->_version, $_old_version) == 0)
return;
}
}
// Remove old data
//
$this->clear_all_cache();
$this->clear_compiled_tpl();
// Write down the current version
//
if (false === ($file_handle = fopen($filename, 'w')))
{
trigger_error("Can't write the file '{$filename}'!",
E_USER_WARNING);
return;
}
fputs($file_handle, $this->_version);
fclose($file_handle);
return;
}
NOTE: version_compare were not valid in 4.0.x
NOTE: _TIS_PATH_MAIN is the absolute path to the root of the script
NOTE: Smarty 2.4.0 is just for personal use implemented
NOTE: Write access on the directory for $filename required
--
Hinrich Donner
http://sourceforge.net/projects/tiro/