diff --git a/change_log.txt b/change_log.txt index 71719441..a4fd1604 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +03/30/2009 +- added all major setter/getter methodes + 03/28/2009 - {block} tags can be nested now - md5 hash function replace with crc32 for speed optimization diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 447aa118..9c5bae5d 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -100,7 +100,7 @@ class Smarty extends Smarty_Internal_TemplateBase { // config var settings public $config_overwrite = true; //Controls whether variables with the same name overwrite each other. public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean - public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file. + public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file. // config vars public $config_vars = array(); // assigned tpl vars @@ -178,7 +178,7 @@ class Smarty extends Smarty_Internal_TemplateBase { $this->loadPlugin('Smarty_Internal_Plugin_Handler'); $this->plugin_handler = new Smarty_Internal_Plugin_Handler; if (!$this->debugging && $this->debugging_ctrl == 'URL') { - $_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING']; + $_query_string = $this->request_use_auto_globals ? isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING']:'' : isset($GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING']) ? $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING']:''; if (false !== strpos($_query_string, $this->smarty_debug_id)) { if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) { // enable debugging for this browser session @@ -292,7 +292,7 @@ class Smarty extends Smarty_Internal_TemplateBase { } /** - * Load the plugin with securty definition and enables security + * Load the plugin with security definition and enables security * * @param string $security_policy plugin to load */ @@ -311,6 +311,64 @@ class Smarty extends Smarty_Internal_TemplateBase { } } + /** + * Set template directory + * + * @param string $ |array $template_dir folder(s) of template sorces + */ + public function setTemplateDir($template_dir) + { + $this->smarty->template_dir = (array)$template_dir; + return; + } + /** + * Adds template directory(s) to existing ones + * + * @param string|array $template_dir folder(s) of template sources + */ + public function addTemplateDir($template_dir) + { + $this->smarty->template_dir = array_merge((array)$this->smarty->template_dir, (array)$template_dir); + $this->smarty->template_dir = array_unique($this->smarty->template_dir); + return; + } + /** + * Set compile directory + * + * @param string $compile_dir folder of compiled template sources + */ + public function setCompileDir($compile_dir) + { + $this->smarty->compile_dir = $compile_dir; + return; + } + /** + * Set cache directory + * + * @param string $cache_dir folder of cache files + */ + public function setCacheDir($cache_dir) + { + $this->smarty->cache_dir = $cache_dir; + return; + } + /** + * Enable Caching + */ + public function enableCaching() + { + $this->smarty->caching = true; + return; + } + /** + * Set caching life time + * @param integer $lifetime lifetime of cached file in seconds + */ + public function setCachingLifetime($lifetime) + { + $this->smarty->caching_lifetime = $lifetime; + return; + } /** * Takes unknown classes and loads plugin files for them * class name format: Smarty_PluginType_PluginName diff --git a/libs/sysplugins/internal.resource_php.php b/libs/sysplugins/internal.resource_php.php index 05a78369..6b2a30ef 100644 --- a/libs/sysplugins/internal.resource_php.php +++ b/libs/sysplugins/internal.resource_php.php @@ -57,7 +57,7 @@ class Smarty_Internal_Resource_PHP extends Smarty_Internal_Base { public function getTemplateSource($_template) { if (file_exists($_template->getTemplateFilepath())) { - $_template->template_source = file_get_contents($_template->getTemplateFilepath()); + $_template->template_source = file_get_contents($_template->getTemplateFilepath()); return true; } else { return false; diff --git a/libs/sysplugins/internal.template.php b/libs/sysplugins/internal.template.php index 01b17608..ac79ed0f 100644 --- a/libs/sysplugins/internal.template.php +++ b/libs/sysplugins/internal.template.php @@ -259,7 +259,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { if ($this->mustCompile()) { $this->compileTemplateSource(); } else { - $this->compiled_template = !$this->isEvaluated() ? file_get_contents($this->getCompiledFilepath()) : false; + $this->compiled_template = !$this->isEvaluated() && $this->usesCompiler() ? file_get_contents($this->getCompiledFilepath()) : false; } } return $this->compiled_template; diff --git a/libs/sysplugins/method.addpluginsdir.php b/libs/sysplugins/method.addpluginsdir.php new file mode 100644 index 00000000..349bf7d9 --- /dev/null +++ b/libs/sysplugins/method.addpluginsdir.php @@ -0,0 +1,34 @@ +smarty->plugins_dir = array_merge((array)$this->smarty->plugins_dir, (array)$plugins_dir); + $this->smarty->plugins_dir = array_unique($this->smarty->plugins_dir); + return; + } +} + +?> diff --git a/libs/sysplugins/method.disablecaching.php b/libs/sysplugins/method.disablecaching.php new file mode 100644 index 00000000..f4a5cb8e --- /dev/null +++ b/libs/sysplugins/method.disablecaching.php @@ -0,0 +1,25 @@ +smarty->caching = false; + } +} + +?> diff --git a/libs/sysplugins/method.disableforcecompile.php b/libs/sysplugins/method.disableforcecompile.php new file mode 100644 index 00000000..f09771fa --- /dev/null +++ b/libs/sysplugins/method.disableforcecompile.php @@ -0,0 +1,25 @@ +smarty->force_compile = false; + } +} + +?> diff --git a/libs/sysplugins/method.enableforcecompile.php b/libs/sysplugins/method.enableforcecompile.php new file mode 100644 index 00000000..523b519d --- /dev/null +++ b/libs/sysplugins/method.enableforcecompile.php @@ -0,0 +1,25 @@ +smarty->force_compile = true; + } +} + +?> diff --git a/libs/sysplugins/method.getcachedir.php b/libs/sysplugins/method.getcachedir.php new file mode 100644 index 00000000..229f8e10 --- /dev/null +++ b/libs/sysplugins/method.getcachedir.php @@ -0,0 +1,31 @@ +smarty->cache_dir; + } +} + +?> diff --git a/libs/sysplugins/method.getcachelifetime.php b/libs/sysplugins/method.getcachelifetime.php new file mode 100644 index 00000000..56a035c3 --- /dev/null +++ b/libs/sysplugins/method.getcachelifetime.php @@ -0,0 +1,30 @@ +smarty->cache_lifetime; + } +} + +?> diff --git a/libs/sysplugins/method.getcompiledir.php b/libs/sysplugins/method.getcompiledir.php new file mode 100644 index 00000000..c2cf9b55 --- /dev/null +++ b/libs/sysplugins/method.getcompiledir.php @@ -0,0 +1,31 @@ +smarty->compile_dir; + } +} + +?> diff --git a/libs/sysplugins/method.getconfigdir.php b/libs/sysplugins/method.getconfigdir.php new file mode 100644 index 00000000..afae9f83 --- /dev/null +++ b/libs/sysplugins/method.getconfigdir.php @@ -0,0 +1,31 @@ +smarty->config_dir; + } +} + +?> diff --git a/libs/sysplugins/method.getpluginsdir.php b/libs/sysplugins/method.getpluginsdir.php new file mode 100644 index 00000000..aee86943 --- /dev/null +++ b/libs/sysplugins/method.getpluginsdir.php @@ -0,0 +1,31 @@ +smarty->plugins_dir; + } +} + +?> diff --git a/libs/sysplugins/method.gettemplatedir.php b/libs/sysplugins/method.gettemplatedir.php new file mode 100644 index 00000000..9388cedb --- /dev/null +++ b/libs/sysplugins/method.gettemplatedir.php @@ -0,0 +1,31 @@ +smarty->template_dir; + } +} + +?> diff --git a/libs/sysplugins/method.setconfigdir.php b/libs/sysplugins/method.setconfigdir.php new file mode 100644 index 00000000..1956c1af --- /dev/null +++ b/libs/sysplugins/method.setconfigdir.php @@ -0,0 +1,32 @@ +smarty->config_dir = $config_dir; + } +} + +?> diff --git a/libs/sysplugins/method.setpluginsdir.php b/libs/sysplugins/method.setpluginsdir.php new file mode 100644 index 00000000..cbd6dc00 --- /dev/null +++ b/libs/sysplugins/method.setpluginsdir.php @@ -0,0 +1,32 @@ +smarty->plugins_dir = (array)$plugins_dir; + } +} + +?>