From b0691dd05617275908966731eaf2e2b603cda748 Mon Sep 17 00:00:00 2001 From: uwetews Date: Sun, 27 Dec 2015 07:18:35 +0100 Subject: [PATCH] - update external methods --- change_log.txt | 1 + libs/Smarty.class.php | 42 +++-------------- libs/sysplugins/smarty_internal_data.php | 7 ++- .../smarty_internal_method_getglobal.php | 46 +++++++++++++++++++ .../smarty_internal_method_mustcompile.php | 2 +- libs/sysplugins/smarty_internal_template.php | 4 ++ .../smarty_internal_templatebase.php | 37 ++++++++------- .../smarty_internal_testinstall.php | 1 + 8 files changed, 86 insertions(+), 54 deletions(-) create mode 100644 libs/sysplugins/smarty_internal_method_getglobal.php diff --git a/change_log.txt b/change_log.txt index 17f3ffa2..22966a56 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,7 @@  ===== 3.1.30-dev ===== (xx.xx.xx) 27.12.2015 - improve inheritance code + - update external methods 25.12.2015 - compile {block} tag code and its processing into classes diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index c8057428..f37fbd75 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -103,11 +103,14 @@ require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_resource_base.php'; * * @package Smarty * + * The following methods will be dynamically loaded by the extension handler when they are called. + * They are located in a corresponding Smarty_Internal_Method_xxxx class + * * @method int clearAllCache(int $exp_time = null, string $type = null) * @method int clearCache(string $template_name, string $cache_id = null, string $compile_id = null, int $exp_time = null, string $type = null) * @method int compileAllTemplates(Smarty $smarty, string $extension = '.tpl', bool $force_compile = false, int $time_limit = 0, int $max_errors = null) * @method int compileAllConfig(Smarty $smarty, string $extension = '.conf', bool $force_compile = false, int $time_limit = 0, int $max_errors = null) - * + * @method int clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null) */ class Smarty extends Smarty_Internal_TemplateBase { @@ -731,31 +734,6 @@ class Smarty extends Smarty_Internal_TemplateBase return $source->exists; } - /** - * Returns a single or all global variables - * - * @param string $varname variable name or null - * - * @return string variable value or or array of variables - */ - public function getGlobal($varname = null) - { - if (isset($varname)) { - if (isset(self::$global_tpl_vars[ $varname ])) { - return self::$global_tpl_vars[ $varname ]->value; - } else { - return ''; - } - } else { - $_result = array(); - foreach (self::$global_tpl_vars AS $key => $var) { - $_result[ $key ] = $var->value; - } - - return $_result; - } - } - /** * Loads security class and enables security * @@ -1339,14 +1317,6 @@ class Smarty extends Smarty_Internal_TemplateBase Smarty_Internal_TestInstall::testInstall($this, $errors); } - /** - * Class destructor - */ - public function __destruct() - { - $i = 0;// intentionally left blank - } - /** * <> Generic getter. * Calls the appropriate getter function. @@ -1367,6 +1337,7 @@ class Smarty extends Smarty_Internal_TemplateBase } else { trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); } + return null; } /** @@ -1436,8 +1407,7 @@ class Smarty extends Smarty_Internal_TemplateBase break; } } - - // pass to next error handler if this error did not occur inside SMARTY_DIR + // pass to next error handler if this error did not occur inside SMARTY_DIR // or the error was within smarty but masked to be ignored if (!$_is_muted_directory || ($errno && $errno & error_reporting())) { if (Smarty::$_previous_error_handler) { diff --git a/libs/sysplugins/smarty_internal_data.php b/libs/sysplugins/smarty_internal_data.php index bba95d30..44cf56ed 100644 --- a/libs/sysplugins/smarty_internal_data.php +++ b/libs/sysplugins/smarty_internal_data.php @@ -14,13 +14,18 @@ * @package Smarty * @subpackage Template * + * @property int $scope + + * The following methods will be dynamically loaded by the extension handler when they are called. + * They are located in a corresponding Smarty_Internal_Method_xxxx class + * * @method mixed getConfigVars(string $varName = null, bool $searchParents = true) + * @method mixed getGlobal(string $varName = null) * @method mixed getStreamVariable(string $variable) * @method Smarty_Internal_Data clearAssign(mixed $tpl_var) * @method Smarty_Internal_Data clearAllAssign() * @method Smarty_Internal_Data clearConfig(string $varName = null) * @method Smarty_Internal_Data configLoad(string $config_file, mixed $sections = null, string $scope = 'local') - * @property int $scope */ class Smarty_Internal_Data { diff --git a/libs/sysplugins/smarty_internal_method_getglobal.php b/libs/sysplugins/smarty_internal_method_getglobal.php new file mode 100644 index 00000000..b2b19316 --- /dev/null +++ b/libs/sysplugins/smarty_internal_method_getglobal.php @@ -0,0 +1,46 @@ +value; + } else { + return ''; + } + } else { + $_result = array(); + foreach (Smarty::$global_tpl_vars AS $key => $var) { + $_result[ $key ] = $var->value; + } + return $_result; + } + } +} \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_method_mustcompile.php b/libs/sysplugins/smarty_internal_method_mustcompile.php index f28a68e6..341de8b3 100644 --- a/libs/sysplugins/smarty_internal_method_mustcompile.php +++ b/libs/sysplugins/smarty_internal_method_mustcompile.php @@ -1,7 +1,7 @@ true, 'smarty_internal_method_getdebugtemplate.php' => true, 'smarty_internal_method_getdefaultmodifiers.php' => true, + 'smarty_internal_method_getglobal.php' => true, 'smarty_internal_method_getregisteredobject.php' => true, 'smarty_internal_method_getstreamvariable.php' => true, 'smarty_internal_method_gettags.php' => true,