diff --git a/CHANGELOG.md b/CHANGELOG.md index 00723903..63d9332e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1776,7 +1776,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 27.09.2011 - bugfix possible warning "attempt to modify property of non-object" in {section} (issue #34) -- added chaining to Smarty_Internal_Data so $smarty->assign('a',1)->assign('b',2); is possible now +- added chaining to \Smarty\Data so $smarty->assign('a',1)->assign('b',2); is possible now - bugfix remove race condition when a custom resource did change timestamp during compilation - bugfix variable property did not work on objects variable in template - bugfix smarty_make_timestamp() failed to process DateTime objects properly @@ -2111,7 +2111,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - optimize smarty_modified_escape for hex, hexentity, decentity. 28/12/2010 -- changed $tpl_vars, $config_vars and $parent to belong to Smarty_Internal_Data +- changed $tpl_vars, $config_vars and $parent to belong to \Smarty\Data - added Smarty::registerCacheResource() for dynamic cache resource object registration 27/12/2010 diff --git a/docs/programmers/api-functions.md b/docs/programmers/api-functions.md index 6f120fa9..e2ea1f51 100644 --- a/docs/programmers/api-functions.md +++ b/docs/programmers/api-functions.md @@ -31,7 +31,6 @@ Smarty Class Methods {#api.functions} - [getConfigVars()](./api-functions/api-get-config-vars.md) — returns the given loaded config variable value - [getPluginsDir()](./api-functions/api-get-plugins-dir.md) — return the directory where plugins are stored - [getRegisteredObject()](./api-functions/api-get-registered-object.md) — returns a reference to a registered object -- [getTags()](./api-functions/api-get-tags.md) — return tags used by template - [getTemplateDir()](./api-functions/api-get-template-dir.md) — return the directory where templates are stored - [getTemplateVars()](./api-functions/api-get-template-vars.md) — returns assigned variable value(s) - [isCached()](./api-functions/api-is-cached.md) — returns true if there is a valid cache for this template @@ -55,7 +54,6 @@ Smarty Class Methods {#api.functions} - [unregisterPlugin()](./api-functions/api-unregister-plugin.md) — dynamically unregister plugins - [unregisterObject()](./api-functions/api-unregister-object.md) — dynamically unregister an object - [unregisterResource()](./api-functions/api-unregister-resource.md) — dynamically unregister a resource plugin -- [testInstall()](./api-functions/api-test-install.md) — checks Smarty installation > **Note** > diff --git a/docs/programmers/api-functions/api-get-tags.md b/docs/programmers/api-functions/api-get-tags.md deleted file mode 100644 index 7729b468..00000000 --- a/docs/programmers/api-functions/api-get-tags.md +++ /dev/null @@ -1,40 +0,0 @@ -getTags() - -return tags used by template - -Description -=========== - -string - -getTags - -object - -template - -This function returns an array of tagname/attribute pairs for all tags -used by the template. It uses the following parameters: - -- `template` is the template object. - -> **Note** -> -> This function is experimental. - - - createTemplate('index.tpl'); - - // get tags - $tags = $smarty->getTags($tpl); - - print_r($tags); - - ?> - - diff --git a/docs/programmers/api-variables.md b/docs/programmers/api-variables.md index ee9c0761..902116c3 100644 --- a/docs/programmers/api-variables.md +++ b/docs/programmers/api-variables.md @@ -31,7 +31,6 @@ them directly, or use the corresponding setter/getter methods. - [$default_resource_type](./api-variables/variable-default-resource-type.md) - [$default_config_handler_func](./api-variables/variable-default-config-handler-func.md) - [$default_template_handler_func](./api-variables/variable-default-template-handler-func.md) -- [$direct_access_security](./api-variables/variable-direct-access-security.md) - [$error_reporting](./api-variables/variable-error-reporting.md) - [$escape_html](./api-variables/variable-escape-html.md) - [$force_cache](./api-variables/variable-force-cache.md) diff --git a/docs/programmers/api-variables/variable-direct-access-security.md b/docs/programmers/api-variables/variable-direct-access-security.md deleted file mode 100644 index f471f5de..00000000 --- a/docs/programmers/api-variables/variable-direct-access-security.md +++ /dev/null @@ -1,13 +0,0 @@ -\$direct\_access\_security {#variable.direct.access.security} -========================== - -Direct access security inhibits direct browser access to compiled or -cached template files. - -Direct access security is enabled by default. To disable it set -`$direct_access_security` to FALSE. - -> **Note** -> -> This is a compile time option. If you change the setting you must make -> sure that the templates get recompiled. diff --git a/docs/programmers/plugins/plugins-block-functions.md b/docs/programmers/plugins/plugins-block-functions.md index 47281fef..bb3033d1 100644 --- a/docs/programmers/plugins/plugins-block-functions.md +++ b/docs/programmers/plugins/plugins-block-functions.md @@ -60,12 +60,6 @@ cannot have both custom function `{func}` and block function function implementation is called again with the new block contents in the parameter `$content`. -If you have nested block functions, it\'s possible to find out what the -parent block function is by accessing `$smarty->_tag_stack` variable. -Just do a [`var_dump()`](&url.php-manual;var_dump) on it and the -structure should be apparent. - - template = $this->compiler->template; $this->smarty = $this->template->smarty; $this->security = isset($this->smarty->security_policy) ? $this->smarty->security_policy : false; - $this->current_buffer = $this->root_buffer = new Smarty_Internal_ParseTree_Template(); + $this->current_buffer = $this->root_buffer = new \Smarty\ParseTree\Template(); } /** @@ -163,7 +163,7 @@ class Smarty_Internal_Templateparser */ public function insertPhpCode($code) { - $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Tag($this, $code)); + $this->current_buffer->append_subtree($this, new \Smarty\ParseTree\Tag($this, $code)); } /** @@ -185,7 +185,7 @@ class Smarty_Internal_Templateparser * * @param string $code * - * @return Smarty_Internal_ParseTree_Tag + * @return \Smarty\ParseTree\Tag */ public function mergePrefixCode($code) { @@ -195,7 +195,7 @@ class Smarty_Internal_Templateparser } $this->compiler->prefix_code = array(); $tmp .= $code; - return new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp, true)); + return new \Smarty\ParseTree\Tag($this, $this->compiler->processNocacheCode($tmp, true)); } } @@ -244,7 +244,7 @@ template ::= template TEXT(B). { $this->current_buffer->append_subtree($this, null); } - $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Text($text, $this->strip)); + $this->current_buffer->append_subtree($this, new \Smarty\ParseTree\Text($text, $this->strip)); } // strip on template ::= template STRIPON. { @@ -257,7 +257,7 @@ template ::= template STRIPOFF. { // Literal template ::= template LITERALSTART literal_e2(B) LITERALEND. { - $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Text(B)); + $this->current_buffer->append_subtree($this, new \Smarty\ParseTree\Text(B)); } @@ -1236,34 +1236,34 @@ doublequoted(res) ::= doublequoted(o1) doublequotedcontent(o2). { } doublequoted(res) ::= doublequotedcontent(o). { - res = new Smarty_Internal_ParseTree_Dq($this, o); + res = new \Smarty\ParseTree\Dq($this, o); } doublequotedcontent(res) ::= BACKTICK variable(v) BACKTICK. { - res = new Smarty_Internal_ParseTree_Code('(string)'.v); + res = new \Smarty\ParseTree\Code('(string)'.v); } doublequotedcontent(res) ::= BACKTICK expr(e) BACKTICK. { - res = new Smarty_Internal_ParseTree_Code('(string)('.e.')'); + res = new \Smarty\ParseTree\Code('(string)('.e.')'); } doublequotedcontent(res) ::= DOLLARID(i). { - res = new Smarty_Internal_ParseTree_Code('(string)$_smarty_tpl->tpl_vars[\''. substr(i,1) .'\']->value'); + res = new \Smarty\ParseTree\Code('(string)$_smarty_tpl->tpl_vars[\''. substr(i,1) .'\']->value'); } doublequotedcontent(res) ::= LDEL variable(v) RDEL. { - res = new Smarty_Internal_ParseTree_Code('(string)'.v); + res = new \Smarty\ParseTree\Code('(string)'.v); } doublequotedcontent(res) ::= LDEL expr(e) RDEL. { - res = new Smarty_Internal_ParseTree_Code('(string)('.e.')'); + res = new \Smarty\ParseTree\Code('(string)('.e.')'); } doublequotedcontent(res) ::= smartytag(st). { - res = new Smarty_Internal_ParseTree_Tag($this, st); + res = new \Smarty\ParseTree\Tag($this, st); } doublequotedcontent(res) ::= TEXT(o). { - res = new Smarty_Internal_ParseTree_DqContent(o); + res = new \Smarty\ParseTree\DqContent(o); } diff --git a/libs/sysplugins/smarty_internal_method_gettags.php b/libs/sysplugins/smarty_internal_method_gettags.php deleted file mode 100644 index 0d1335a8..00000000 --- a/libs/sysplugins/smarty_internal_method_gettags.php +++ /dev/null @@ -1,63 +0,0 @@ -_getSmartyObj(); - if ($obj->_isTplObj() && !isset($template)) { - $tpl = clone $obj; - } elseif (isset($template) && $template->_isTplObj()) { - $tpl = clone $template; - } elseif (isset($template) && is_string($template)) { - /* @var Smarty_Internal_Template $tpl */ - $tpl = new $smarty->template_class($template, $smarty); - // checks if template exists - if (!$tpl->source->exists) { - throw new SmartyException("Unable to load template {$tpl->source->type} '{$tpl->source->name}'"); - } - } - if (isset($tpl)) { - $tpl->smarty = clone $tpl->smarty; - $tpl->smarty->_cache[ 'get_used_tags' ] = true; - $tpl->_cache[ 'used_tags' ] = array(); - $tpl->smarty->merge_compiled_includes = false; - $tpl->smarty->disableSecurity(); - $tpl->caching = Smarty::CACHING_OFF; - $tpl->loadCompiler(); - $tpl->compiler->compileTemplate($tpl); - return $tpl->_cache[ 'used_tags' ]; - } - throw new SmartyException('Missing template specification'); - } -} diff --git a/libs/sysplugins/smarty_internal_testinstall.php b/libs/sysplugins/smarty_internal_testinstall.php deleted file mode 100644 index c8ffd4cc..00000000 --- a/libs/sysplugins/smarty_internal_testinstall.php +++ /dev/null @@ -1,605 +0,0 @@ -\n"; - echo "Smarty Installation test...\n"; - echo "Testing template directory...\n"; - } - $_stream_resolve_include_path = function_exists('stream_resolve_include_path'); - // test if all registered template_dir are accessible - foreach ($smarty->getTemplateDir() as $template_dir) { - $_template_dir = $template_dir; - $template_dir = realpath($template_dir); - // resolve include_path or fail existence - if (!$template_dir) { - if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) { - // try PHP include_path - if ($_stream_resolve_include_path) { - $template_dir = stream_resolve_include_path($_template_dir); - } else { - $template_dir = $smarty->ext->_getIncludePath->getIncludePath($_template_dir, null, $smarty); - } - if ($template_dir !== false) { - if ($errors === null) { - echo "$template_dir is OK.\n"; - } - continue; - } else { - $status = false; - $message = - "FAILED: $_template_dir does not exist (and couldn't be found in include_path either)"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'template_dir' ] = $message; - } - continue; - } - } else { - $status = false; - $message = "FAILED: $_template_dir does not exist"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'template_dir' ] = $message; - } - continue; - } - } - if (!is_dir($template_dir)) { - $status = false; - $message = "FAILED: $template_dir is not a directory"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'template_dir' ] = $message; - } - } elseif (!is_readable($template_dir)) { - $status = false; - $message = "FAILED: $template_dir is not readable"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'template_dir' ] = $message; - } - } else { - if ($errors === null) { - echo "$template_dir is OK.\n"; - } - } - } - if ($errors === null) { - echo "Testing compile directory...\n"; - } - // test if registered compile_dir is accessible - $__compile_dir = $smarty->getCompileDir(); - $_compile_dir = realpath($__compile_dir); - if (!$_compile_dir) { - $status = false; - $message = "FAILED: {$__compile_dir} does not exist"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'compile_dir' ] = $message; - } - } elseif (!is_dir($_compile_dir)) { - $status = false; - $message = "FAILED: {$_compile_dir} is not a directory"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'compile_dir' ] = $message; - } - } elseif (!is_readable($_compile_dir)) { - $status = false; - $message = "FAILED: {$_compile_dir} is not readable"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'compile_dir' ] = $message; - } - } elseif (!is_writable($_compile_dir)) { - $status = false; - $message = "FAILED: {$_compile_dir} is not writable"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'compile_dir' ] = $message; - } - } else { - if ($errors === null) { - echo "{$_compile_dir} is OK.\n"; - } - } - if ($errors === null) { - echo "Testing plugins directory...\n"; - } - // test if all registered plugins_dir are accessible - // and if core plugins directory is still registered - $_core_plugins_dir = realpath(__DIR__ . '/../plugins'); - $_core_plugins_available = false; - foreach ($smarty->getPluginsDir() as $plugin_dir) { - $_plugin_dir = $plugin_dir; - $plugin_dir = realpath($plugin_dir); - // resolve include_path or fail existence - if (!$plugin_dir) { - if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { - // try PHP include_path - if ($_stream_resolve_include_path) { - $plugin_dir = stream_resolve_include_path($_plugin_dir); - } else { - $plugin_dir = $smarty->ext->_getIncludePath->getIncludePath($_plugin_dir, null, $smarty); - } - if ($plugin_dir !== false) { - if ($errors === null) { - echo "$plugin_dir is OK.\n"; - } - continue; - } else { - $status = false; - $message = "FAILED: $_plugin_dir does not exist (and couldn't be found in include_path either)"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'plugins_dir' ] = $message; - } - continue; - } - } else { - $status = false; - $message = "FAILED: $_plugin_dir does not exist"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'plugins_dir' ] = $message; - } - continue; - } - } - if (!is_dir($plugin_dir)) { - $status = false; - $message = "FAILED: $plugin_dir is not a directory"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'plugins_dir' ] = $message; - } - } elseif (!is_readable($plugin_dir)) { - $status = false; - $message = "FAILED: $plugin_dir is not readable"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'plugins_dir' ] = $message; - } - } elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) { - $_core_plugins_available = true; - if ($errors === null) { - echo "$plugin_dir is OK.\n"; - } - } else { - if ($errors === null) { - echo "$plugin_dir is OK.\n"; - } - } - } - if (!$_core_plugins_available) { - $status = false; - $message = "WARNING: Smarty's own libs/plugins is not available"; - if ($errors === null) { - echo $message . ".\n"; - } elseif (!isset($errors[ 'plugins_dir' ])) { - $errors[ 'plugins_dir' ] = $message; - } - } - if ($errors === null) { - echo "Testing cache directory...\n"; - } - // test if all registered cache_dir is accessible - $__cache_dir = $smarty->getCacheDir(); - $_cache_dir = realpath($__cache_dir); - if (!$_cache_dir) { - $status = false; - $message = "FAILED: {$__cache_dir} does not exist"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'cache_dir' ] = $message; - } - } elseif (!is_dir($_cache_dir)) { - $status = false; - $message = "FAILED: {$_cache_dir} is not a directory"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'cache_dir' ] = $message; - } - } elseif (!is_readable($_cache_dir)) { - $status = false; - $message = "FAILED: {$_cache_dir} is not readable"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'cache_dir' ] = $message; - } - } elseif (!is_writable($_cache_dir)) { - $status = false; - $message = "FAILED: {$_cache_dir} is not writable"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'cache_dir' ] = $message; - } - } else { - if ($errors === null) { - echo "{$_cache_dir} is OK.\n"; - } - } - if ($errors === null) { - echo "Testing configs directory...\n"; - } - // test if all registered config_dir are accessible - foreach ($smarty->getConfigDir() as $config_dir) { - $_config_dir = $config_dir; - // resolve include_path or fail existence - if (!$config_dir) { - if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) { - // try PHP include_path - if ($_stream_resolve_include_path) { - $config_dir = stream_resolve_include_path($_config_dir); - } else { - $config_dir = $smarty->ext->_getIncludePath->getIncludePath($_config_dir, null, $smarty); - } - if ($config_dir !== false) { - if ($errors === null) { - echo "$config_dir is OK.\n"; - } - continue; - } else { - $status = false; - $message = "FAILED: $_config_dir does not exist (and couldn't be found in include_path either)"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'config_dir' ] = $message; - } - continue; - } - } else { - $status = false; - $message = "FAILED: $_config_dir does not exist"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'config_dir' ] = $message; - } - continue; - } - } - if (!is_dir($config_dir)) { - $status = false; - $message = "FAILED: $config_dir is not a directory"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'config_dir' ] = $message; - } - } elseif (!is_readable($config_dir)) { - $status = false; - $message = "FAILED: $config_dir is not readable"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'config_dir' ] = $message; - } - } else { - if ($errors === null) { - echo "$config_dir is OK.\n"; - } - } - } - if ($errors === null) { - echo "Testing sysplugin files...\n"; - } - // test if sysplugins are available - $source = SMARTY_SYSPLUGINS_DIR; - if (is_dir($source)) { - $expectedSysplugins = array( - 'smartycompilerexception.php' => true, - 'smartyexception.php' => true, - 'smarty_cacheresource.php' => true, - 'smarty_cacheresource_custom.php' => true, - 'smarty_cacheresource_keyvaluestore.php' => true, - 'smarty_data.php' => true, - 'smarty_internal_block.php' => true, - 'smarty_internal_cacheresource_file.php' => true, - 'smarty_internal_compilebase.php' => true, - 'smarty_internal_compile_append.php' => true, - 'smarty_internal_compile_assign.php' => true, - 'smarty_internal_compile_block.php' => true, - 'smarty_internal_compile_block_child.php' => true, - 'smarty_internal_compile_block_parent.php' => true, - 'smarty_internal_compile_child.php' => true, - 'smarty_internal_compile_parent.php' => true, - 'smarty_internal_compile_break.php' => true, - 'smarty_internal_compile_call.php' => true, - 'smarty_internal_compile_capture.php' => true, - 'smarty_internal_compile_config_load.php' => true, - 'smarty_internal_compile_continue.php' => true, - 'smarty_internal_compile_debug.php' => true, - 'smarty_internal_compile_eval.php' => true, - 'smarty_internal_compile_extends.php' => true, - 'smarty_internal_compile_for.php' => true, - 'smarty_internal_compile_foreach.php' => true, - 'smarty_internal_compile_function.php' => true, - 'smarty_internal_compile_if.php' => true, - 'smarty_internal_compile_include.php' => true, - 'smarty_internal_compile_insert.php' => true, - 'smarty_internal_compile_ldelim.php' => true, - 'smarty_internal_compile_make_nocache.php' => true, - 'smarty_internal_compile_nocache.php' => true, - 'smarty_internal_compile_private_block_plugin.php' => true, - 'smarty_internal_compile_private_foreachsection.php' => true, - 'smarty_internal_compile_private_function_plugin.php' => true, - 'smarty_internal_compile_private_modifier.php' => true, - 'smarty_internal_compile_private_object_block_function.php' => true, - 'smarty_internal_compile_private_object_function.php' => true, - 'smarty_internal_compile_private_print_expression.php' => true, - 'smarty_internal_compile_private_registered_block.php' => true, - 'smarty_internal_compile_private_registered_function.php' => true, - 'smarty_internal_compile_private_special_variable.php' => true, - 'smarty_internal_compile_rdelim.php' => true, - 'smarty_internal_compile_section.php' => true, - 'smarty_internal_compile_setfilter.php' => true, - 'smarty_internal_compile_shared_inheritance.php' => true, - 'smarty_internal_compile_while.php' => true, - 'smarty_internal_configfilelexer.php' => true, - 'smarty_internal_configfileparser.php' => true, - 'smarty_internal_config_file_compiler.php' => true, - 'smarty_internal_data.php' => true, - 'smarty_internal_debug.php' => true, - 'smarty_internal_extension_handler.php' => true, - 'smarty_internal_method_addautoloadfilters.php' => true, - 'smarty_internal_method_adddefaultmodifiers.php' => true, - 'smarty_internal_method_append.php' => true, - 'smarty_internal_method_appendbyref.php' => true, - 'smarty_internal_method_assignbyref.php' => true, - 'smarty_internal_method_assignglobal.php' => true, - 'smarty_internal_method_clearallassign.php' => true, - 'smarty_internal_method_clearallcache.php' => true, - 'smarty_internal_method_clearassign.php' => true, - 'smarty_internal_method_clearcache.php' => true, - 'smarty_internal_method_clearcompiledtemplate.php' => true, - 'smarty_internal_method_clearconfig.php' => true, - 'smarty_internal_method_compileallconfig.php' => true, - 'smarty_internal_method_compilealltemplates.php' => true, - 'smarty_internal_method_configload.php' => true, - 'smarty_internal_method_createdata.php' => true, - 'smarty_internal_method_getautoloadfilters.php' => true, - 'smarty_internal_method_getconfigvariable.php' => true, - 'smarty_internal_method_getconfigvars.php' => 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, - 'smarty_internal_method_gettemplatevars.php' => true, - 'smarty_internal_method_literals.php' => true, - 'smarty_internal_method_loadfilter.php' => true, - 'smarty_internal_method_loadplugin.php' => true, - 'smarty_internal_method_mustcompile.php' => true, - 'smarty_internal_method_registercacheresource.php' => true, - 'smarty_internal_method_registerclass.php' => true, - 'smarty_internal_method_registerdefaultconfighandler.php' => true, - 'smarty_internal_method_registerdefaultpluginhandler.php' => true, - 'smarty_internal_method_registerdefaulttemplatehandler.php' => true, - 'smarty_internal_method_registerfilter.php' => true, - 'smarty_internal_method_registerobject.php' => true, - 'smarty_internal_method_registerplugin.php' => true, - 'smarty_internal_method_registerresource.php' => true, - 'smarty_internal_method_setautoloadfilters.php' => true, - 'smarty_internal_method_setdebugtemplate.php' => true, - 'smarty_internal_method_setdefaultmodifiers.php' => true, - 'smarty_internal_method_unloadfilter.php' => true, - 'smarty_internal_method_unregistercacheresource.php' => true, - 'smarty_internal_method_unregisterfilter.php' => true, - 'smarty_internal_method_unregisterobject.php' => true, - 'smarty_internal_method_unregisterplugin.php' => true, - 'smarty_internal_method_unregisterresource.php' => true, - 'smarty_internal_nocache_insert.php' => true, - 'smarty_internal_parsetree.php' => true, - 'smarty_internal_parsetree_code.php' => true, - 'smarty_internal_parsetree_dq.php' => true, - 'smarty_internal_parsetree_dqcontent.php' => true, - 'smarty_internal_parsetree_tag.php' => true, - 'smarty_internal_parsetree_template.php' => true, - 'smarty_internal_parsetree_text.php' => true, - 'smarty_internal_resource_eval.php' => true, - 'smarty_internal_resource_extends.php' => true, - 'smarty_internal_resource_file.php' => true, - 'smarty_internal_resource_php.php' => true, - 'smarty_internal_resource_stream.php' => true, - 'smarty_internal_resource_string.php' => true, - 'smarty_internal_runtime_cachemodify.php' => true, - 'smarty_internal_runtime_cacheresourcefile.php' => true, - 'smarty_internal_runtime_capture.php' => true, - 'smarty_internal_runtime_codeframe.php' => true, - 'smarty_internal_runtime_filterhandler.php' => true, - 'smarty_internal_runtime_foreach.php' => true, - 'smarty_internal_runtime_getincludepath.php' => true, - 'smarty_internal_runtime_inheritance.php' => true, - 'smarty_internal_runtime_make_nocache.php' => true, - 'smarty_internal_runtime_tplfunction.php' => true, - 'smarty_internal_runtime_updatecache.php' => true, - 'smarty_internal_runtime_updatescope.php' => true, - 'smarty_internal_runtime_writefile.php' => true, - 'smarty_internal_smartytemplatecompiler.php' => true, - 'smarty_internal_template.php' => true, - 'smarty_internal_templatebase.php' => true, - 'smarty_internal_templatecompilerbase.php' => true, - 'smarty_internal_templatelexer.php' => true, - 'smarty_internal_templateparser.php' => true, - 'smarty_internal_testinstall.php' => true, - 'smarty_internal_undefined.php' => true, - 'smarty_resource.php' => true, - 'smarty_resource_custom.php' => true, - 'smarty_resource_recompiled.php' => true, - 'smarty_resource_uncompiled.php' => true, - 'smarty_security.php' => true, - 'smarty_template_cached.php' => true, - 'smarty_template_compiled.php' => true, - 'smarty_template_config.php' => true, - 'smarty_template_resource_base.php' => true, - 'smarty_template_source.php' => true, - 'smarty_undefined_variable.php' => true, - 'smarty_variable.php' => true, - ); - $iterator = new DirectoryIterator($source); - foreach ($iterator as $file) { - if (!$file->isDot()) { - $filename = $file->getFilename(); - if (isset($expectedSysplugins[ $filename ])) { - unset($expectedSysplugins[ $filename ]); - } - } - } - if ($expectedSysplugins) { - $status = false; - $message = "FAILED: files missing from libs/sysplugins: " . join(', ', array_keys($expectedSysplugins)); - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'sysplugins' ] = $message; - } - } elseif ($errors === null) { - echo "... OK\n"; - } - } else { - $status = false; - $message = "FAILED: " . SMARTY_SYSPLUGINS_DIR . ' is not a directory'; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'sysplugins_dir_constant' ] = $message; - } - } - if ($errors === null) { - echo "Testing plugin files...\n"; - } - // test if core plugins are available - $source = SMARTY_PLUGINS_DIR; - if (is_dir($source)) { - $expectedPlugins = array( - 'block.textformat.php' => true, - 'function.counter.php' => true, - 'function.cycle.php' => true, - 'function.fetch.php' => true, - 'function.html_checkboxes.php' => true, - 'function.html_image.php' => true, - 'function.html_options.php' => true, - 'function.html_radios.php' => true, - 'function.html_select_date.php' => true, - 'function.html_select_time.php' => true, - 'function.html_table.php' => true, - 'function.mailto.php' => true, - 'function.math.php' => true, - 'modifier.capitalize.php' => true, - 'modifier.date_format.php' => true, - 'modifier.debug_print_var.php' => true, - 'modifier.escape.php' => true, - 'modifier.mb_wordwrap.php' => true, - 'modifier.regex_replace.php' => true, - 'modifier.replace.php' => true, - 'modifier.spacify.php' => true, - 'modifier.truncate.php' => true, - 'modifiercompiler.cat.php' => true, - 'modifiercompiler.count_characters.php' => true, - 'modifiercompiler.count_paragraphs.php' => true, - 'modifiercompiler.count_sentences.php' => true, - 'modifiercompiler.count_words.php' => true, - 'modifiercompiler.default.php' => true, - 'modifiercompiler.escape.php' => true, - 'modifiercompiler.from_charset.php' => true, - 'modifiercompiler.indent.php' => true, - 'modifiercompiler.lower.php' => true, - 'modifiercompiler.noprint.php' => true, - 'modifiercompiler.string_format.php' => true, - 'modifiercompiler.strip.php' => true, - 'modifiercompiler.strip_tags.php' => true, - 'modifiercompiler.to_charset.php' => true, - 'modifiercompiler.unescape.php' => true, - 'modifiercompiler.upper.php' => true, - 'modifiercompiler.wordwrap.php' => true, - 'outputfilter.trimwhitespace.php' => true, - 'shared.escape_special_chars.php' => true, - 'shared.literal_compiler_param.php' => true, - 'shared.make_timestamp.php' => true, - 'shared.mb_str_replace.php' => true, - 'shared.mb_unicode.php' => true, - 'variablefilter.htmlspecialchars.php' => true, - ); - $iterator = new DirectoryIterator($source); - foreach ($iterator as $file) { - if (!$file->isDot()) { - $filename = $file->getFilename(); - if (isset($expectedPlugins[ $filename ])) { - unset($expectedPlugins[ $filename ]); - } - } - } - if ($expectedPlugins) { - $status = false; - $message = "FAILED: files missing from libs/plugins: " . join(', ', array_keys($expectedPlugins)); - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'plugins' ] = $message; - } - } elseif ($errors === null) { - echo "... OK\n"; - } - } else { - $status = false; - $message = "FAILED: " . SMARTY_PLUGINS_DIR . ' is not a directory'; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'plugins_dir_constant' ] = $message; - } - } - if ($errors === null) { - echo "Tests complete.\n"; - echo "\n"; - } - return $status; - } -} diff --git a/libs/plugins/block.textformat.php b/plugins/block.textformat.php similarity index 100% rename from libs/plugins/block.textformat.php rename to plugins/block.textformat.php diff --git a/libs/plugins/function.counter.php b/plugins/function.counter.php similarity index 100% rename from libs/plugins/function.counter.php rename to plugins/function.counter.php diff --git a/libs/plugins/function.cycle.php b/plugins/function.cycle.php similarity index 100% rename from libs/plugins/function.cycle.php rename to plugins/function.cycle.php diff --git a/libs/plugins/function.fetch.php b/plugins/function.fetch.php similarity index 100% rename from libs/plugins/function.fetch.php rename to plugins/function.fetch.php diff --git a/libs/plugins/function.html_checkboxes.php b/plugins/function.html_checkboxes.php similarity index 100% rename from libs/plugins/function.html_checkboxes.php rename to plugins/function.html_checkboxes.php diff --git a/libs/plugins/function.html_image.php b/plugins/function.html_image.php similarity index 100% rename from libs/plugins/function.html_image.php rename to plugins/function.html_image.php diff --git a/libs/plugins/function.html_options.php b/plugins/function.html_options.php similarity index 100% rename from libs/plugins/function.html_options.php rename to plugins/function.html_options.php diff --git a/libs/plugins/function.html_radios.php b/plugins/function.html_radios.php similarity index 100% rename from libs/plugins/function.html_radios.php rename to plugins/function.html_radios.php diff --git a/libs/plugins/function.html_select_date.php b/plugins/function.html_select_date.php similarity index 100% rename from libs/plugins/function.html_select_date.php rename to plugins/function.html_select_date.php diff --git a/libs/plugins/function.html_select_time.php b/plugins/function.html_select_time.php similarity index 100% rename from libs/plugins/function.html_select_time.php rename to plugins/function.html_select_time.php diff --git a/libs/plugins/function.html_table.php b/plugins/function.html_table.php similarity index 100% rename from libs/plugins/function.html_table.php rename to plugins/function.html_table.php diff --git a/libs/plugins/function.mailto.php b/plugins/function.mailto.php similarity index 100% rename from libs/plugins/function.mailto.php rename to plugins/function.mailto.php diff --git a/libs/plugins/function.math.php b/plugins/function.math.php similarity index 100% rename from libs/plugins/function.math.php rename to plugins/function.math.php diff --git a/libs/plugins/modifier.capitalize.php b/plugins/modifier.capitalize.php similarity index 100% rename from libs/plugins/modifier.capitalize.php rename to plugins/modifier.capitalize.php diff --git a/libs/plugins/modifier.count.php b/plugins/modifier.count.php similarity index 100% rename from libs/plugins/modifier.count.php rename to plugins/modifier.count.php diff --git a/libs/plugins/modifier.date_format.php b/plugins/modifier.date_format.php similarity index 100% rename from libs/plugins/modifier.date_format.php rename to plugins/modifier.date_format.php diff --git a/libs/plugins/modifier.debug_print_var.php b/plugins/modifier.debug_print_var.php similarity index 100% rename from libs/plugins/modifier.debug_print_var.php rename to plugins/modifier.debug_print_var.php diff --git a/libs/plugins/modifier.escape.php b/plugins/modifier.escape.php similarity index 100% rename from libs/plugins/modifier.escape.php rename to plugins/modifier.escape.php diff --git a/libs/plugins/modifier.explode.php b/plugins/modifier.explode.php similarity index 100% rename from libs/plugins/modifier.explode.php rename to plugins/modifier.explode.php diff --git a/libs/plugins/modifier.mb_wordwrap.php b/plugins/modifier.mb_wordwrap.php similarity index 100% rename from libs/plugins/modifier.mb_wordwrap.php rename to plugins/modifier.mb_wordwrap.php diff --git a/libs/plugins/modifier.number_format.php b/plugins/modifier.number_format.php similarity index 100% rename from libs/plugins/modifier.number_format.php rename to plugins/modifier.number_format.php diff --git a/libs/plugins/modifier.regex_replace.php b/plugins/modifier.regex_replace.php similarity index 100% rename from libs/plugins/modifier.regex_replace.php rename to plugins/modifier.regex_replace.php diff --git a/libs/plugins/modifier.replace.php b/plugins/modifier.replace.php similarity index 100% rename from libs/plugins/modifier.replace.php rename to plugins/modifier.replace.php diff --git a/libs/plugins/modifier.spacify.php b/plugins/modifier.spacify.php similarity index 100% rename from libs/plugins/modifier.spacify.php rename to plugins/modifier.spacify.php diff --git a/libs/plugins/modifier.truncate.php b/plugins/modifier.truncate.php similarity index 100% rename from libs/plugins/modifier.truncate.php rename to plugins/modifier.truncate.php diff --git a/libs/plugins/modifiercompiler.cat.php b/plugins/modifiercompiler.cat.php similarity index 100% rename from libs/plugins/modifiercompiler.cat.php rename to plugins/modifiercompiler.cat.php diff --git a/libs/plugins/modifiercompiler.count_characters.php b/plugins/modifiercompiler.count_characters.php similarity index 100% rename from libs/plugins/modifiercompiler.count_characters.php rename to plugins/modifiercompiler.count_characters.php diff --git a/libs/plugins/modifiercompiler.count_paragraphs.php b/plugins/modifiercompiler.count_paragraphs.php similarity index 100% rename from libs/plugins/modifiercompiler.count_paragraphs.php rename to plugins/modifiercompiler.count_paragraphs.php diff --git a/libs/plugins/modifiercompiler.count_sentences.php b/plugins/modifiercompiler.count_sentences.php similarity index 100% rename from libs/plugins/modifiercompiler.count_sentences.php rename to plugins/modifiercompiler.count_sentences.php diff --git a/libs/plugins/modifiercompiler.count_words.php b/plugins/modifiercompiler.count_words.php similarity index 100% rename from libs/plugins/modifiercompiler.count_words.php rename to plugins/modifiercompiler.count_words.php diff --git a/libs/plugins/modifiercompiler.default.php b/plugins/modifiercompiler.default.php similarity index 100% rename from libs/plugins/modifiercompiler.default.php rename to plugins/modifiercompiler.default.php diff --git a/libs/plugins/modifiercompiler.escape.php b/plugins/modifiercompiler.escape.php similarity index 100% rename from libs/plugins/modifiercompiler.escape.php rename to plugins/modifiercompiler.escape.php diff --git a/libs/plugins/modifiercompiler.from_charset.php b/plugins/modifiercompiler.from_charset.php similarity index 100% rename from libs/plugins/modifiercompiler.from_charset.php rename to plugins/modifiercompiler.from_charset.php diff --git a/libs/plugins/modifiercompiler.indent.php b/plugins/modifiercompiler.indent.php similarity index 100% rename from libs/plugins/modifiercompiler.indent.php rename to plugins/modifiercompiler.indent.php diff --git a/libs/plugins/modifiercompiler.lower.php b/plugins/modifiercompiler.lower.php similarity index 100% rename from libs/plugins/modifiercompiler.lower.php rename to plugins/modifiercompiler.lower.php diff --git a/libs/plugins/modifiercompiler.nl2br.php b/plugins/modifiercompiler.nl2br.php similarity index 100% rename from libs/plugins/modifiercompiler.nl2br.php rename to plugins/modifiercompiler.nl2br.php diff --git a/libs/plugins/modifiercompiler.noprint.php b/plugins/modifiercompiler.noprint.php similarity index 100% rename from libs/plugins/modifiercompiler.noprint.php rename to plugins/modifiercompiler.noprint.php diff --git a/libs/plugins/modifiercompiler.round.php b/plugins/modifiercompiler.round.php similarity index 100% rename from libs/plugins/modifiercompiler.round.php rename to plugins/modifiercompiler.round.php diff --git a/libs/plugins/modifiercompiler.str_repeat.php b/plugins/modifiercompiler.str_repeat.php similarity index 100% rename from libs/plugins/modifiercompiler.str_repeat.php rename to plugins/modifiercompiler.str_repeat.php diff --git a/libs/plugins/modifiercompiler.string_format.php b/plugins/modifiercompiler.string_format.php similarity index 100% rename from libs/plugins/modifiercompiler.string_format.php rename to plugins/modifiercompiler.string_format.php diff --git a/libs/plugins/modifiercompiler.strip.php b/plugins/modifiercompiler.strip.php similarity index 100% rename from libs/plugins/modifiercompiler.strip.php rename to plugins/modifiercompiler.strip.php diff --git a/libs/plugins/modifiercompiler.strip_tags.php b/plugins/modifiercompiler.strip_tags.php similarity index 100% rename from libs/plugins/modifiercompiler.strip_tags.php rename to plugins/modifiercompiler.strip_tags.php diff --git a/libs/plugins/modifiercompiler.strlen.php b/plugins/modifiercompiler.strlen.php similarity index 100% rename from libs/plugins/modifiercompiler.strlen.php rename to plugins/modifiercompiler.strlen.php diff --git a/libs/plugins/modifiercompiler.to_charset.php b/plugins/modifiercompiler.to_charset.php similarity index 100% rename from libs/plugins/modifiercompiler.to_charset.php rename to plugins/modifiercompiler.to_charset.php diff --git a/libs/plugins/modifiercompiler.unescape.php b/plugins/modifiercompiler.unescape.php similarity index 100% rename from libs/plugins/modifiercompiler.unescape.php rename to plugins/modifiercompiler.unescape.php diff --git a/libs/plugins/modifiercompiler.upper.php b/plugins/modifiercompiler.upper.php similarity index 100% rename from libs/plugins/modifiercompiler.upper.php rename to plugins/modifiercompiler.upper.php diff --git a/libs/plugins/modifiercompiler.wordwrap.php b/plugins/modifiercompiler.wordwrap.php similarity index 100% rename from libs/plugins/modifiercompiler.wordwrap.php rename to plugins/modifiercompiler.wordwrap.php diff --git a/libs/plugins/outputfilter.trimwhitespace.php b/plugins/outputfilter.trimwhitespace.php similarity index 100% rename from libs/plugins/outputfilter.trimwhitespace.php rename to plugins/outputfilter.trimwhitespace.php diff --git a/libs/plugins/shared.escape_special_chars.php b/plugins/shared.escape_special_chars.php similarity index 100% rename from libs/plugins/shared.escape_special_chars.php rename to plugins/shared.escape_special_chars.php diff --git a/libs/plugins/shared.literal_compiler_param.php b/plugins/shared.literal_compiler_param.php similarity index 100% rename from libs/plugins/shared.literal_compiler_param.php rename to plugins/shared.literal_compiler_param.php diff --git a/libs/plugins/shared.make_timestamp.php b/plugins/shared.make_timestamp.php similarity index 100% rename from libs/plugins/shared.make_timestamp.php rename to plugins/shared.make_timestamp.php diff --git a/libs/plugins/shared.mb_str_replace.php b/plugins/shared.mb_str_replace.php similarity index 100% rename from libs/plugins/shared.mb_str_replace.php rename to plugins/shared.mb_str_replace.php diff --git a/libs/plugins/shared.mb_unicode.php b/plugins/shared.mb_unicode.php similarity index 100% rename from libs/plugins/shared.mb_unicode.php rename to plugins/shared.mb_unicode.php diff --git a/libs/plugins/variablefilter.htmlspecialchars.php b/plugins/variablefilter.htmlspecialchars.php similarity index 100% rename from libs/plugins/variablefilter.htmlspecialchars.php rename to plugins/variablefilter.htmlspecialchars.php diff --git a/libs/Autoloader.php b/src/Autoloader.php similarity index 100% rename from libs/Autoloader.php rename to src/Autoloader.php diff --git a/libs/sysplugins/smarty_cacheresource.php b/src/Cacheresource/smarty_cacheresource.php similarity index 92% rename from libs/sysplugins/smarty_cacheresource.php rename to src/Cacheresource/smarty_cacheresource.php index db68f9bf..c3dbbfd8 100644 --- a/libs/sysplugins/smarty_cacheresource.php +++ b/src/Cacheresource/smarty_cacheresource.php @@ -195,23 +195,23 @@ abstract class Smarty_CacheResource $type = $smarty->caching_type; } // try smarty's cache - if (isset($smarty->_cache[ 'cacheresource_handlers' ][ $type ])) { - return $smarty->_cache[ 'cacheresource_handlers' ][ $type ]; + if (isset($smarty->_cacheresource_handlers[ $type ])) { + return $smarty->_cacheresource_handlers[ $type ]; } // try registered resource if (isset($smarty->registered_cache_resources[ $type ])) { // do not cache these instances as they may vary from instance to instance - return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = $smarty->registered_cache_resources[ $type ]; + return $smarty->_cacheresource_handlers[ $type ] = $smarty->registered_cache_resources[ $type ]; } // try sysplugins dir if (isset(self::$sysplugins[ $type ])) { $cache_resource_class = 'Smarty_Internal_CacheResource_' . smarty_ucfirst_ascii($type); - return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class(); + return $smarty->_cacheresource_handlers[ $type ] = new $cache_resource_class(); } // try plugins dir $cache_resource_class = 'Smarty_CacheResource_' . smarty_ucfirst_ascii($type); if ($smarty->loadPlugin($cache_resource_class)) { - return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class(); + return $smarty->_cacheresource_handlers[ $type ] = new $cache_resource_class(); } // give up throw new SmartyException("Unable to load cache resource '{$type}'"); diff --git a/libs/sysplugins/smarty_cacheresource_custom.php b/src/Cacheresource/smarty_cacheresource_custom.php similarity index 100% rename from libs/sysplugins/smarty_cacheresource_custom.php rename to src/Cacheresource/smarty_cacheresource_custom.php diff --git a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php b/src/Cacheresource/smarty_cacheresource_keyvaluestore.php similarity index 100% rename from libs/sysplugins/smarty_cacheresource_keyvaluestore.php rename to src/Cacheresource/smarty_cacheresource_keyvaluestore.php diff --git a/libs/sysplugins/smarty_internal_compile_append.php b/src/Compile/Append.php similarity index 95% rename from libs/sysplugins/smarty_internal_compile_append.php rename to src/Compile/Append.php index 1a9befbf..224a3099 100644 --- a/libs/sysplugins/smarty_internal_compile_append.php +++ b/src/Compile/Append.php @@ -1,4 +1,7 @@ required_attributes = array('var', 'value'); $this->shorttag_order = array('var', 'value'); $this->optional_attributes = array('scope'); diff --git a/libs/sysplugins/smarty_internal_compile_block.php b/src/Compile/smarty_internal_compile_block.php similarity index 95% rename from libs/sysplugins/smarty_internal_compile_block.php rename to src/Compile/smarty_internal_compile_block.php index cbaccd2b..ac507298 100644 --- a/libs/sysplugins/smarty_internal_compile_block.php +++ b/src/Compile/smarty_internal_compile_block.php @@ -85,7 +85,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher ); $compiler->saveRequiredPlugins(true); $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; - $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); + $compiler->parser->current_buffer = new \Smarty\ParseTree\Template(); $compiler->template->compiled->has_nocache_code = false; $compiler->suppressNocacheProcessing = true; } @@ -123,7 +123,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_ // get compiled block code $_functionCode = $compiler->parser->current_buffer; // setup buffer for template function code - $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); + $compiler->parser->current_buffer = new \Smarty\ParseTree\Template(); $output = "cStyleComment(" {block {$_name}} ") . "\n"; $output .= "class {$_className} extends Smarty_Internal_Block\n"; @@ -143,7 +143,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_ $output .= "?>\n"; $compiler->parser->current_buffer->append_subtree( $compiler->parser, - new Smarty_Internal_ParseTree_Tag( + new \Smarty\ParseTree\Tag( $compiler->parser, $output ) @@ -159,13 +159,13 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_ $output .= "?>\n"; $compiler->parser->current_buffer->append_subtree( $compiler->parser, - new Smarty_Internal_ParseTree_Tag( + new \Smarty\ParseTree\Tag( $compiler->parser, $output ) ); $compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser); - $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); + $compiler->parser->current_buffer = new \Smarty\ParseTree\Template(); // restore old status $compiler->template->compiled->has_nocache_code = $_has_nocache_code; $compiler->tag_nocache = $compiler->nocache; diff --git a/libs/sysplugins/smarty_internal_compile_block_child.php b/src/Compile/smarty_internal_compile_block_child.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_block_child.php rename to src/Compile/smarty_internal_compile_block_child.php diff --git a/libs/sysplugins/smarty_internal_compile_block_parent.php b/src/Compile/smarty_internal_compile_block_parent.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_block_parent.php rename to src/Compile/smarty_internal_compile_block_parent.php diff --git a/libs/sysplugins/smarty_internal_compile_break.php b/src/Compile/smarty_internal_compile_break.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_break.php rename to src/Compile/smarty_internal_compile_break.php diff --git a/libs/sysplugins/smarty_internal_compile_call.php b/src/Compile/smarty_internal_compile_call.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_call.php rename to src/Compile/smarty_internal_compile_call.php diff --git a/libs/sysplugins/smarty_internal_compile_capture.php b/src/Compile/smarty_internal_compile_capture.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_capture.php rename to src/Compile/smarty_internal_compile_capture.php diff --git a/libs/sysplugins/smarty_internal_compile_child.php b/src/Compile/smarty_internal_compile_child.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_child.php rename to src/Compile/smarty_internal_compile_child.php diff --git a/libs/sysplugins/smarty_internal_compile_config_load.php b/src/Compile/smarty_internal_compile_config_load.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_config_load.php rename to src/Compile/smarty_internal_compile_config_load.php diff --git a/libs/sysplugins/smarty_internal_compile_continue.php b/src/Compile/smarty_internal_compile_continue.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_continue.php rename to src/Compile/smarty_internal_compile_continue.php diff --git a/libs/sysplugins/smarty_internal_compile_debug.php b/src/Compile/smarty_internal_compile_debug.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_debug.php rename to src/Compile/smarty_internal_compile_debug.php diff --git a/libs/sysplugins/smarty_internal_compile_eval.php b/src/Compile/smarty_internal_compile_eval.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_eval.php rename to src/Compile/smarty_internal_compile_eval.php diff --git a/libs/sysplugins/smarty_internal_compile_extends.php b/src/Compile/smarty_internal_compile_extends.php similarity index 96% rename from libs/sysplugins/smarty_internal_compile_extends.php rename to src/Compile/smarty_internal_compile_extends.php index d72d2b76..839005de 100644 --- a/libs/sysplugins/smarty_internal_compile_extends.php +++ b/src/Compile/smarty_internal_compile_extends.php @@ -107,7 +107,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh $inlineUids = $match[ 1 ]; } } - $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag( + $compiler->parser->template_postfix[] = new \Smarty\ParseTree\Tag( $compiler->parser, 'inheritance->endChild($_smarty_tpl' . (isset($template) ? @@ -127,7 +127,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh */ private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $template) { - $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag( + $compiler->parser->template_postfix[] = new \Smarty\ParseTree\Tag( $compiler->parser, $compiler->compileTag( 'include', diff --git a/libs/sysplugins/smarty_internal_compile_for.php b/src/Compile/smarty_internal_compile_for.php similarity index 97% rename from libs/sysplugins/smarty_internal_compile_for.php rename to src/Compile/smarty_internal_compile_for.php index 969e22c1..60ed31c8 100644 --- a/libs/sysplugins/smarty_internal_compile_for.php +++ b/src/Compile/smarty_internal_compile_for.php @@ -55,7 +55,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase $var = $_statement[ 'var' ]; $index = ''; } - $output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable(null, \$_smarty_tpl->isRenderingCache);\n"; + $output .= "\$_smarty_tpl->tpl_vars[$var] = new \\Smarty\\Variable(null, \$_smarty_tpl->isRenderingCache);\n"; $output .= "\$_smarty_tpl->tpl_vars[$var]->value{$index} = {$_statement['value']};\n"; } if (is_array($_attr[ 'var' ])) { @@ -75,7 +75,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase $var = $_statement[ 'var' ]; $index = ''; } - $output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable(null, \$_smarty_tpl->isRenderingCache);"; + $output .= "\$_smarty_tpl->tpl_vars[$var] = new \\Smarty\\Variable(null, \$_smarty_tpl->isRenderingCache);"; if (isset($_attr[ 'step' ])) { $output .= "\$_smarty_tpl->tpl_vars[$var]->step = $_attr[step];"; } else { diff --git a/libs/sysplugins/smarty_internal_compile_foreach.php b/src/Compile/smarty_internal_compile_foreach.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_foreach.php rename to src/Compile/smarty_internal_compile_foreach.php diff --git a/libs/sysplugins/smarty_internal_compile_function.php b/src/Compile/smarty_internal_compile_function.php similarity index 92% rename from libs/sysplugins/smarty_internal_compile_function.php rename to src/Compile/smarty_internal_compile_function.php index b05a82b7..c924bd27 100644 --- a/libs/sysplugins/smarty_internal_compile_function.php +++ b/src/Compile/smarty_internal_compile_function.php @@ -70,7 +70,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase ); $this->openTag($compiler, 'function', $save); // Init temporary context - $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); + $compiler->parser->current_buffer = new \Smarty\ParseTree\Template(); $compiler->template->compiled->has_nocache_code = false; $compiler->saveRequiredPlugins(true); return true; @@ -128,7 +128,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase } $_functionCode = $compiler->parser->current_buffer; // setup buffer for template function code - $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); + $compiler->parser->current_buffer = new \Smarty\ParseTree\Template(); $_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}"; $_funcNameCaching = $_funcName . '_nocache'; if ($compiler->template->compiled->has_nocache_code) { @@ -141,14 +141,14 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output .= $compiler->compileRequiredPlugins(); $output .= "\$_smarty_tpl->compiled->has_nocache_code = true;\n"; $output .= $_paramsCode; - $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n"; + $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new \\Smarty\\Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n"; $output .= "\$params = var_export(\$params, true);\n"; $output .= "echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/smarty->ext->_tplFunction->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value, \\\$_smarty_tpl->isRenderingCache);\n}\n?>"; + $output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new \\Smarty\\Variable(\\\$value, \\\$_smarty_tpl->isRenderingCache);\n}\n?>"; $output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";?>"; $compiler->parser->current_buffer->append_subtree( $compiler->parser, - new Smarty_Internal_ParseTree_Tag( + new \Smarty\ParseTree\Tag( $compiler->parser, $output ) @@ -163,12 +163,12 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output .= "?>\n"; $compiler->parser->current_buffer->append_subtree( $compiler->parser, - new Smarty_Internal_ParseTree_Tag( + new \Smarty\ParseTree\Tag( $compiler->parser, $output ) ); - $_functionCode = new Smarty_Internal_ParseTree_Tag( + $_functionCode = new \Smarty\ParseTree\Tag( $compiler->parser, preg_replace_callback( "/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", @@ -183,13 +183,13 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output .= "if (!function_exists('{$_funcName}')) {\n"; $output .= "function {$_funcName}(Smarty_Internal_Template \$_smarty_tpl,\$params) {\n"; $output .= $_paramsCode; - $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n"; + $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new \\Smarty\\Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n"; $output .= $compiler->compileCheckPlugins(array_merge($compiler->required_plugins[ 'compiled' ], $compiler->required_plugins[ 'nocache' ])); $output .= "?>\n"; $compiler->parser->current_buffer->append_subtree( $compiler->parser, - new Smarty_Internal_ParseTree_Tag( + new \Smarty\ParseTree\Tag( $compiler->parser, $output ) @@ -200,7 +200,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output .= "?>\n"; $compiler->parser->current_buffer->append_subtree( $compiler->parser, - new Smarty_Internal_ParseTree_Tag( + new \Smarty\ParseTree\Tag( $compiler->parser, $output ) diff --git a/libs/sysplugins/smarty_internal_compile_if.php b/src/Compile/smarty_internal_compile_if.php similarity index 94% rename from libs/sysplugins/smarty_internal_compile_if.php rename to src/Compile/smarty_internal_compile_if.php index df3dc3fa..e33e316a 100644 --- a/libs/sysplugins/smarty_internal_compile_if.php +++ b/src/Compile/smarty_internal_compile_if.php @@ -8,6 +8,8 @@ * @author Uwe Tews */ +use Smarty\Compile\Assign; + /** * Smarty Internal Plugin Compile If Class * @@ -50,7 +52,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase $_output = "\n"; $assignAttr = array(); $assignAttr[][ 'value' ] = $prefixVar; - $assignCompiler = new Smarty_Internal_Compile_Assign(); + $assignCompiler = new Assign(); if (is_array($parameter[ 'if condition' ][ 'var' ])) { $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; $_output .= $assignCompiler->compile( @@ -88,7 +90,7 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase */ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) { - list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); + [$nesting, $compiler->tag_nocache] = $this->closeTag($compiler, array('if', 'elseif')); $this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache)); return ''; } @@ -116,7 +118,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); + [$nesting, $compiler->tag_nocache] = $this->closeTag($compiler, array('if', 'elseif')); if (!isset($parameter[ 'if condition' ])) { $compiler->trigger_template_error('missing elseif condition', null, true); } @@ -135,7 +137,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase } $prefixVar = $compiler->getNewPrefixVariable(); $assignCode = "\n"; - $assignCompiler = new Smarty_Internal_Compile_Assign(); + $assignCompiler = new Assign(); $assignAttr = array(); $assignAttr[][ 'value' ] = $prefixVar; if (is_array($parameter[ 'if condition' ][ 'var' ])) { @@ -197,7 +199,7 @@ class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase if ($compiler->nocache) { $compiler->tag_nocache = true; } - list($nesting, $compiler->nocache) = $this->closeTag($compiler, array('if', 'else', 'elseif')); + [$nesting, $compiler->nocache] = $this->closeTag($compiler, array('if', 'else', 'elseif')); $tmp = ''; for ($i = 0; $i < $nesting; $i++) { $tmp .= '}'; diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/src/Compile/smarty_internal_compile_include.php similarity index 99% rename from libs/sysplugins/smarty_internal_compile_include.php rename to src/Compile/smarty_internal_compile_include.php index bf62461b..a5c38635 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/src/Compile/smarty_internal_compile_include.php @@ -238,7 +238,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase } if (!empty($_attr) && $_caching === 9999 && $compiler->template->caching) { $_vars_nc = "foreach ($_vars as \$ik => \$iv) {\n"; - $_vars_nc .= "\$_smarty_tpl->tpl_vars[\$ik] = new Smarty_Variable(\$iv);\n"; + $_vars_nc .= "\$_smarty_tpl->tpl_vars[\$ik] = new \\Smarty\\Variable(\$iv);\n"; $_vars_nc .= "}\n"; $_output .= substr($compiler->processNocacheCode('\n", true), 6, -3); } diff --git a/libs/sysplugins/smarty_internal_compile_insert.php b/src/Compile/smarty_internal_compile_insert.php similarity index 98% rename from libs/sysplugins/smarty_internal_compile_insert.php rename to src/Compile/smarty_internal_compile_insert.php index 29031d91..e0e2a256 100644 --- a/libs/sysplugins/smarty_internal_compile_insert.php +++ b/src/Compile/smarty_internal_compile_insert.php @@ -74,7 +74,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase if (isset($compiler->template->tpl_vars[ $var ])) { $compiler->template->tpl_vars[ $var ]->nocache = true; } else { - $compiler->template->tpl_vars[ $var ] = new Smarty_Variable(null, true); + $compiler->template->tpl_vars[ $var ] = new \Smarty\Variable(null, true); } } if (isset($_attr[ 'script' ])) { diff --git a/libs/sysplugins/smarty_internal_compile_ldelim.php b/src/Compile/smarty_internal_compile_ldelim.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_ldelim.php rename to src/Compile/smarty_internal_compile_ldelim.php diff --git a/libs/sysplugins/smarty_internal_compile_make_nocache.php b/src/Compile/smarty_internal_compile_make_nocache.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_make_nocache.php rename to src/Compile/smarty_internal_compile_make_nocache.php diff --git a/libs/sysplugins/smarty_internal_compile_nocache.php b/src/Compile/smarty_internal_compile_nocache.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_nocache.php rename to src/Compile/smarty_internal_compile_nocache.php diff --git a/libs/sysplugins/smarty_internal_compile_parent.php b/src/Compile/smarty_internal_compile_parent.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_parent.php rename to src/Compile/smarty_internal_compile_parent.php diff --git a/libs/sysplugins/smarty_internal_compile_private_block_plugin.php b/src/Compile/smarty_internal_compile_private_block_plugin.php similarity index 96% rename from libs/sysplugins/smarty_internal_compile_private_block_plugin.php rename to src/Compile/smarty_internal_compile_private_block_plugin.php index 199a296c..02b617aa 100644 --- a/libs/sysplugins/smarty_internal_compile_private_block_plugin.php +++ b/src/Compile/smarty_internal_compile_private_block_plugin.php @@ -63,7 +63,6 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi if (isset($callable)) { $output .= "if (!is_callable({$callable})) {\nthrow new SmartyException('block tag \'{$tag}\' not callable or registered');\n}\n"; } - $output .= "\$_smarty_tpl->smarty->_cache['_tag_stack'][] = array('{$tag}', {$_params});\n"; $output .= "\$_block_repeat=true;\necho {$callback}({$_params}, null, \$_smarty_tpl, \$_block_repeat);\nwhile (\$_block_repeat) {\nob_start();?>"; $this->openTag($compiler, $tag, array($_params, $compiler->nocache, $callback)); // maybe nocache because of nocache variables or nocache plugin @@ -94,7 +93,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi } $output = "smarty->_cache[\'_tag_stack\']);?>'; + $output .= '?>'; } return $output; } diff --git a/libs/sysplugins/smarty_internal_compile_private_foreachsection.php b/src/Compile/smarty_internal_compile_private_foreachsection.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_private_foreachsection.php rename to src/Compile/smarty_internal_compile_private_foreachsection.php diff --git a/libs/sysplugins/smarty_internal_compile_private_function_plugin.php b/src/Compile/smarty_internal_compile_private_function_plugin.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_private_function_plugin.php rename to src/Compile/smarty_internal_compile_private_function_plugin.php diff --git a/libs/sysplugins/smarty_internal_compile_private_modifier.php b/src/Compile/smarty_internal_compile_private_modifier.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_private_modifier.php rename to src/Compile/smarty_internal_compile_private_modifier.php diff --git a/libs/sysplugins/smarty_internal_compile_private_object_block_function.php b/src/Compile/smarty_internal_compile_private_object_block_function.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_private_object_block_function.php rename to src/Compile/smarty_internal_compile_private_object_block_function.php diff --git a/libs/sysplugins/smarty_internal_compile_private_object_function.php b/src/Compile/smarty_internal_compile_private_object_function.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_private_object_function.php rename to src/Compile/smarty_internal_compile_private_object_function.php diff --git a/libs/sysplugins/smarty_internal_compile_private_print_expression.php b/src/Compile/smarty_internal_compile_private_print_expression.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_private_print_expression.php rename to src/Compile/smarty_internal_compile_private_print_expression.php diff --git a/libs/sysplugins/smarty_internal_compile_private_registered_block.php b/src/Compile/smarty_internal_compile_private_registered_block.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_private_registered_block.php rename to src/Compile/smarty_internal_compile_private_registered_block.php diff --git a/libs/sysplugins/smarty_internal_compile_private_registered_function.php b/src/Compile/smarty_internal_compile_private_registered_function.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_private_registered_function.php rename to src/Compile/smarty_internal_compile_private_registered_function.php diff --git a/libs/sysplugins/smarty_internal_compile_private_special_variable.php b/src/Compile/smarty_internal_compile_private_special_variable.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_private_special_variable.php rename to src/Compile/smarty_internal_compile_private_special_variable.php diff --git a/libs/sysplugins/smarty_internal_compile_rdelim.php b/src/Compile/smarty_internal_compile_rdelim.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_rdelim.php rename to src/Compile/smarty_internal_compile_rdelim.php diff --git a/libs/sysplugins/smarty_internal_compile_section.php b/src/Compile/smarty_internal_compile_section.php similarity index 99% rename from libs/sysplugins/smarty_internal_compile_section.php rename to src/Compile/smarty_internal_compile_section.php index 0dee2082..6568da5c 100644 --- a/libs/sysplugins/smarty_internal_compile_section.php +++ b/src/Compile/smarty_internal_compile_section.php @@ -358,7 +358,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo $output .= "{$local}{$key} = {$code};\n"; } $_vars = 'array(' . join(', ', $initNamedProperty) . ')'; - $output .= "{$sectionVar} = new Smarty_Variable({$_vars});\n"; + $output .= "{$sectionVar} = new \\Smarty\\Variable({$_vars});\n"; $cond_code = "{$propValue['total']} !== 0"; if ($propType[ 'total' ] === 0) { if ($propValue[ 'total' ] === 0) { diff --git a/libs/sysplugins/smarty_internal_compile_setfilter.php b/src/Compile/smarty_internal_compile_setfilter.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_setfilter.php rename to src/Compile/smarty_internal_compile_setfilter.php diff --git a/libs/sysplugins/smarty_internal_compile_shared_inheritance.php b/src/Compile/smarty_internal_compile_shared_inheritance.php similarity index 100% rename from libs/sysplugins/smarty_internal_compile_shared_inheritance.php rename to src/Compile/smarty_internal_compile_shared_inheritance.php diff --git a/libs/sysplugins/smarty_internal_compile_while.php b/src/Compile/smarty_internal_compile_while.php similarity index 98% rename from libs/sysplugins/smarty_internal_compile_while.php rename to src/Compile/smarty_internal_compile_while.php index 5aa3a733..3d9e8f48 100644 --- a/libs/sysplugins/smarty_internal_compile_while.php +++ b/src/Compile/smarty_internal_compile_while.php @@ -8,6 +8,8 @@ * @author Uwe Tews */ +use Smarty\Compile\Assign; + /** * Smarty Internal Plugin Compile While Class * @@ -48,7 +50,7 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase $compiler->setNocacheInVariable($var); } $prefixVar = $compiler->getNewPrefixVariable(); - $assignCompiler = new Smarty_Internal_Compile_Assign(); + $assignCompiler = new Assign(); $assignAttr = array(); $assignAttr[][ 'value' ] = $prefixVar; if (is_array($parameter[ 'if condition' ][ 'var' ])) { diff --git a/libs/sysplugins/smarty_internal_data.php b/src/Data.php similarity index 80% rename from libs/sysplugins/smarty_internal_data.php rename to src/Data.php index 1b64185b..bd784744 100644 --- a/libs/sysplugins/smarty_internal_data.php +++ b/src/Data.php @@ -1,4 +1,7 @@ _assignInScope($tpl_var, $value, $nocache); } else { - $this->tpl_vars[ $tpl_var ] = new Smarty_Variable($value, $nocache); + $this->tpl_vars[ $tpl_var ] = new Variable($value, $nocache); } } } @@ -120,16 +123,16 @@ abstract class Smarty_Internal_Data /** * appends values to template variables * - * @api Smarty::append() - * @link https://www.smarty.net/docs/en/api.append.tpl - * * @param array|string $tpl_var the template variable name(s) * @param mixed $value the value to append * @param bool $merge flag if array elements shall be merged * @param bool $nocache if true any output of this variable will * be not cached * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return Data|\Smarty_Internal_Template|\Smarty + *@link https://www.smarty.net/docs/en/api.append.tpl + * + * @api Smarty::append() */ public function append($tpl_var, $value = null, $merge = false, $nocache = false) { @@ -143,7 +146,7 @@ abstract class Smarty_Internal_Data * @param mixed $value the value to assign * @param boolean $nocache if true any output of this variable will be not cached * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return Data|\Smarty_Internal_Template|\Smarty */ public function assignGlobal($varName, $value = null, $nocache = false) { @@ -157,7 +160,7 @@ abstract class Smarty_Internal_Data * @param mixed &$value the referenced value to append * @param boolean $merge flag if array elements shall be merged * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return Data|\Smarty_Internal_Template|\Smarty */ public function appendByRef($tpl_var, &$value, $merge = false) { @@ -171,7 +174,7 @@ abstract class Smarty_Internal_Data * @param $value * @param boolean $nocache if true any output of this variable will be not cached * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return Data|\Smarty_Internal_Template|\Smarty */ public function assignByRef($tpl_var, &$value, $nocache = false) { @@ -181,16 +184,16 @@ abstract class Smarty_Internal_Data /** * Returns a single or all template variables * - * @api Smarty::getTemplateVars() - * @link https://www.smarty.net/docs/en/api.get.template.vars.tpl - * * @param string $varName variable name or null - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object - * @param bool $searchParents include parent templates? + * @param Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object + * @param bool $searchParents include parent templates? * * @return mixed variable value or or array of variables + *@api Smarty::getTemplateVars() + * @link https://www.smarty.net/docs/en/api.get.template.vars.tpl + * */ - public function getTemplateVars($varName = null, Smarty_Internal_Data $_ptr = null, $searchParents = true) + public function getTemplateVars($varName = null, Data $_ptr = null, $searchParents = true) { return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents); } @@ -198,9 +201,9 @@ abstract class Smarty_Internal_Data /** * Follow the parent chain an merge template and config variables * - * @param \Smarty_Internal_Data|null $data + * @param Data|null $data */ - public function _mergeVars(Smarty_Internal_Data $data = null) + public function _mergeVars(Data $data = null) { if (isset($data)) { if (!empty($this->tpl_vars)) { @@ -237,16 +240,6 @@ abstract class Smarty_Internal_Data return $this->_objType === 2; } - /** - * Return true if this instance is a Smarty obj - * - * @return bool - */ - public function _isSmartyObj() - { - return $this->_objType === 1; - } - /** * Get Smarty object * diff --git a/libs/sysplugins/smarty_internal_method_addautoloadfilters.php b/src/Method/smarty_internal_method_addautoloadfilters.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_addautoloadfilters.php rename to src/Method/smarty_internal_method_addautoloadfilters.php diff --git a/libs/sysplugins/smarty_internal_method_adddefaultmodifiers.php b/src/Method/smarty_internal_method_adddefaultmodifiers.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_adddefaultmodifiers.php rename to src/Method/smarty_internal_method_adddefaultmodifiers.php diff --git a/libs/sysplugins/smarty_internal_method_append.php b/src/Method/smarty_internal_method_append.php similarity index 87% rename from libs/sysplugins/smarty_internal_method_append.php rename to src/Method/smarty_internal_method_append.php index e207734e..f3d9f546 100644 --- a/libs/sysplugins/smarty_internal_method_append.php +++ b/src/Method/smarty_internal_method_append.php @@ -24,16 +24,16 @@ class Smarty_Internal_Method_Append * @api Smarty::append() * @link https://www.smarty.net/docs/en/api.append.tpl * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param array|string $tpl_var the template variable name(s) * @param mixed $value the value to append * @param bool $merge flag if array elements shall be merged * @param bool $nocache if true any output of this variable will * be not cached * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return \Smarty\Data|\Smarty_Internal_Template|\Smarty */ - public function append(Smarty_Internal_Data $data, $tpl_var, $value = null, $merge = false, $nocache = false) + public function append(\Smarty\Data $data, $tpl_var, $value = null, $merge = false, $nocache = false) { if (is_array($tpl_var)) { // $tpl_var is an array, ignore $value @@ -47,7 +47,7 @@ class Smarty_Internal_Method_Append if (!isset($data->tpl_vars[ $tpl_var ])) { $tpl_var_inst = $data->ext->getTemplateVars->_getVariable($data, $tpl_var, null, true, false); if ($tpl_var_inst instanceof Smarty_Undefined_Variable) { - $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache); + $data->tpl_vars[ $tpl_var ] = new \Smarty\Variable(null, $nocache); } else { $data->tpl_vars[ $tpl_var ] = clone $tpl_var_inst; } diff --git a/libs/sysplugins/smarty_internal_method_appendbyref.php b/src/Method/smarty_internal_method_appendbyref.php similarity index 82% rename from libs/sysplugins/smarty_internal_method_appendbyref.php rename to src/Method/smarty_internal_method_appendbyref.php index b5be69b5..a7407e45 100644 --- a/libs/sysplugins/smarty_internal_method_appendbyref.php +++ b/src/Method/smarty_internal_method_appendbyref.php @@ -17,18 +17,18 @@ class Smarty_Internal_Method_AppendByRef * @api Smarty::appendByRef() * @link https://www.smarty.net/docs/en/api.append.by.ref.tpl * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param string $tpl_var the template variable name * @param mixed &$value the referenced value to append * @param bool $merge flag if array elements shall be merged * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return \Smarty\Data|\Smarty_Internal_Template|\Smarty */ - public static function appendByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $merge = false) + public static function appendByRef(\Smarty\Data $data, $tpl_var, &$value, $merge = false) { if ($tpl_var !== '' && isset($value)) { if (!isset($data->tpl_vars[ $tpl_var ])) { - $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(); + $data->tpl_vars[ $tpl_var ] = new \Smarty\Variable(); } if (!is_array($data->tpl_vars[ $tpl_var ]->value)) { settype($data->tpl_vars[ $tpl_var ]->value, 'array'); diff --git a/libs/sysplugins/smarty_internal_method_assignbyref.php b/src/Method/smarty_internal_method_assignbyref.php similarity index 75% rename from libs/sysplugins/smarty_internal_method_assignbyref.php rename to src/Method/smarty_internal_method_assignbyref.php index fa705bb8..b9a75332 100644 --- a/libs/sysplugins/smarty_internal_method_assignbyref.php +++ b/src/Method/smarty_internal_method_assignbyref.php @@ -14,18 +14,18 @@ class Smarty_Internal_Method_AssignByRef /** * assigns values to template variables by reference * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param string $tpl_var the template variable name * @param $value * @param boolean $nocache if true any output of this variable will * be not cached * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return \Smarty\Data|\Smarty_Internal_Template|\Smarty */ - public function assignByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $nocache) + public function assignByRef(\Smarty\Data $data, $tpl_var, &$value, $nocache) { if ($tpl_var !== '') { - $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache); + $data->tpl_vars[ $tpl_var ] = new \Smarty\Variable(null, $nocache); $data->tpl_vars[ $tpl_var ]->value = &$value; if ($data->_isTplObj() && $data->scope) { $data->ext->_updateScope->_updateScope($data, $tpl_var); diff --git a/libs/sysplugins/smarty_internal_method_assignglobal.php b/src/Method/smarty_internal_method_assignglobal.php similarity index 75% rename from libs/sysplugins/smarty_internal_method_assignglobal.php rename to src/Method/smarty_internal_method_assignglobal.php index 08cfa469..da2c8582 100644 --- a/libs/sysplugins/smarty_internal_method_assignglobal.php +++ b/src/Method/smarty_internal_method_assignglobal.php @@ -21,18 +21,18 @@ class Smarty_Internal_Method_AssignGlobal /** * assigns a global Smarty variable * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param string $varName the global variable name * @param mixed $value the value to assign * @param boolean $nocache if true any output of this variable will * be not cached * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return \Smarty\Data|\Smarty_Internal_Template|\Smarty */ - public function assignGlobal(Smarty_Internal_Data $data, $varName, $value = null, $nocache = false) + public function assignGlobal(\Smarty\Data $data, $varName, $value = null, $nocache = false) { if ($varName !== '') { - Smarty::$global_tpl_vars[ $varName ] = new Smarty_Variable($value, $nocache); + Smarty::$global_tpl_vars[ $varName ] = new \Smarty\Variable($value, $nocache); $ptr = $data; while ($ptr->_isTplObj()) { $ptr->tpl_vars[ $varName ] = clone Smarty::$global_tpl_vars[ $varName ]; diff --git a/libs/sysplugins/smarty_internal_method_clearallassign.php b/src/Method/smarty_internal_method_clearallassign.php similarity index 73% rename from libs/sysplugins/smarty_internal_method_clearallassign.php rename to src/Method/smarty_internal_method_clearallassign.php index 6fb0c8f3..efeea368 100644 --- a/libs/sysplugins/smarty_internal_method_clearallassign.php +++ b/src/Method/smarty_internal_method_clearallassign.php @@ -24,11 +24,11 @@ class Smarty_Internal_Method_ClearAllAssign * @api Smarty::clearAllAssign() * @link https://www.smarty.net/docs/en/api.clear.all.assign.tpl * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return \Smarty\Data|\Smarty_Internal_Template|\Smarty */ - public function clearAllAssign(Smarty_Internal_Data $data) + public function clearAllAssign(\Smarty\Data $data) { $data->tpl_vars = array(); return $data; diff --git a/libs/sysplugins/smarty_internal_method_clearallcache.php b/src/Method/smarty_internal_method_clearallcache.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_clearallcache.php rename to src/Method/smarty_internal_method_clearallcache.php diff --git a/libs/sysplugins/smarty_internal_method_clearassign.php b/src/Method/smarty_internal_method_clearassign.php similarity index 79% rename from libs/sysplugins/smarty_internal_method_clearassign.php rename to src/Method/smarty_internal_method_clearassign.php index 12b755c0..b0a6b73d 100644 --- a/libs/sysplugins/smarty_internal_method_clearassign.php +++ b/src/Method/smarty_internal_method_clearassign.php @@ -24,12 +24,12 @@ class Smarty_Internal_Method_ClearAssign * @api Smarty::clearAssign() * @link https://www.smarty.net/docs/en/api.clear.assign.tpl * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param string|array $tpl_var the template variable(s) to clear * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return \Smarty\Data|\Smarty_Internal_Template|\Smarty */ - public function clearAssign(Smarty_Internal_Data $data, $tpl_var) + public function clearAssign(\Smarty\Data $data, $tpl_var) { if (is_array($tpl_var)) { foreach ($tpl_var as $curr_var) { diff --git a/libs/sysplugins/smarty_internal_method_clearcache.php b/src/Method/smarty_internal_method_clearcache.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_clearcache.php rename to src/Method/smarty_internal_method_clearcache.php diff --git a/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php b/src/Method/smarty_internal_method_clearcompiledtemplate.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php rename to src/Method/smarty_internal_method_clearcompiledtemplate.php diff --git a/libs/sysplugins/smarty_internal_method_clearconfig.php b/src/Method/smarty_internal_method_clearconfig.php similarity index 77% rename from libs/sysplugins/smarty_internal_method_clearconfig.php rename to src/Method/smarty_internal_method_clearconfig.php index d1b73032..b28fa379 100644 --- a/libs/sysplugins/smarty_internal_method_clearconfig.php +++ b/src/Method/smarty_internal_method_clearconfig.php @@ -24,12 +24,12 @@ class Smarty_Internal_Method_ClearConfig * @api Smarty::clearConfig() * @link https://www.smarty.net/docs/en/api.clear.config.tpl * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param string|null $name variable name or null * - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty + * @return \Smarty\Data|\Smarty_Internal_Template|\Smarty */ - public function clearConfig(Smarty_Internal_Data $data, $name = null) + public function clearConfig(\Smarty\Data $data, $name = null) { if (isset($name)) { unset($data->config_vars[ $name ]); diff --git a/libs/sysplugins/smarty_internal_method_compileallconfig.php b/src/Method/smarty_internal_method_compileallconfig.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_compileallconfig.php rename to src/Method/smarty_internal_method_compileallconfig.php diff --git a/libs/sysplugins/smarty_internal_method_compilealltemplates.php b/src/Method/smarty_internal_method_compilealltemplates.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_compilealltemplates.php rename to src/Method/smarty_internal_method_compilealltemplates.php diff --git a/libs/sysplugins/smarty_internal_method_configload.php b/src/Method/smarty_internal_method_configload.php similarity index 88% rename from libs/sysplugins/smarty_internal_method_configload.php rename to src/Method/smarty_internal_method_configload.php index c3174d2d..2d67b7f7 100644 --- a/libs/sysplugins/smarty_internal_method_configload.php +++ b/src/Method/smarty_internal_method_configload.php @@ -24,15 +24,15 @@ class Smarty_Internal_Method_ConfigLoad * @api Smarty::configLoad() * @link https://www.smarty.net/docs/en/api.config.load.tpl * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param string $config_file filename * @param mixed $sections array of section names, single * section or null * - * @return \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template + * @return \Smarty|\Smarty\Data|\Smarty_Internal_Template * @throws \Exception */ - public function configLoad(Smarty_Internal_Data $data, $config_file, $sections = null) + public function configLoad(\Smarty\Data $data, $config_file, $sections = null) { $this->_loadConfigFile($data, $config_file, $sections, null); return $data; @@ -44,7 +44,7 @@ class Smarty_Internal_Method_ConfigLoad * @api Smarty::configLoad() * @link https://www.smarty.net/docs/en/api.config.load.tpl * - * @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data + * @param \Smarty|\Smarty\Data|\Smarty_Internal_Template $data * @param string $config_file filename * @param mixed $sections array of section names, single * section or null @@ -53,7 +53,7 @@ class Smarty_Internal_Method_ConfigLoad * * @throws \Exception */ - public function _loadConfigFile(Smarty_Internal_Data $data, $config_file, $sections = null, $scope = 0) + public function _loadConfigFile(\Smarty\Data $data, $config_file, $sections = null, $scope = 0) { /* @var \Smarty $smarty */ $smarty = $data->_getSmartyObj(); @@ -92,10 +92,10 @@ class Smarty_Internal_Method_ConfigLoad $mergedScope = $tagScope | $tpl->scope; if ($mergedScope) { // update scopes - /* @var \Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $ptr */ + /* @var \Smarty_Internal_Template|\Smarty|\Smarty\Data $ptr */ foreach ($tpl->smarty->ext->_updateScope->_getAffectedScopes($tpl->parent, $mergedScope) as $ptr) { $this->_assignConfigVars($ptr->config_vars, $tpl, $new_config_vars); - if ($tagScope && $ptr->_isTplObj() && isset($tpl->_cache[ 'varStack' ])) { + if ($tagScope && $ptr->_isTplObj() && isset($tpl->_var_stack)) { $this->_updateVarStack($tpl, $new_config_vars); } } @@ -147,8 +147,8 @@ class Smarty_Internal_Method_ConfigLoad public function _updateVarStack(Smarty_Internal_Template $tpl, $config_vars) { $i = 0; - while (isset($tpl->_cache[ 'varStack' ][ $i ])) { - $this->_assignConfigVars($tpl->_cache[ 'varStack' ][ $i ][ 'config' ], $tpl, $config_vars); + while (isset($tpl->_var_stack[ $i ])) { + $this->_assignConfigVars($tpl->_var_stack[ $i ][ 'config' ], $tpl, $config_vars); $i++; } } @@ -156,13 +156,13 @@ class Smarty_Internal_Method_ConfigLoad /** * gets a config variable value * - * @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data + * @param \Smarty|\Smarty\Data|\Smarty_Internal_Template $data * @param string $varName the name of the config variable * @param bool $errorEnable * * @return null|string the value of the config variable */ - public function _getConfigVariable(Smarty_Internal_Data $data, $varName, $errorEnable = true) + public function _getConfigVariable(\Smarty\Data $data, $varName, $errorEnable = true) { $_ptr = $data; while ($_ptr !== null) { diff --git a/libs/sysplugins/smarty_internal_method_createdata.php b/src/Method/smarty_internal_method_createdata.php similarity index 87% rename from libs/sysplugins/smarty_internal_method_createdata.php rename to src/Method/smarty_internal_method_createdata.php index c684c087..70f009fa 100644 --- a/libs/sysplugins/smarty_internal_method_createdata.php +++ b/src/Method/smarty_internal_method_createdata.php @@ -25,13 +25,13 @@ class Smarty_Internal_Method_CreateData * @link https://www.smarty.net/docs/en/api.create.data.tpl * * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj - * @param \Smarty_Internal_Template|\Smarty_Internal_Data|\Smarty_Data|\Smarty $parent next higher level of Smarty + * @param \Smarty_Internal_Template|\Smarty\Data|\Smarty_Data|\Smarty $parent next higher level of Smarty * variables * @param string $name optional data block name * * @return \Smarty_Data data object */ - public function createData(Smarty_Internal_TemplateBase $obj, Smarty_Internal_Data $parent = null, $name = null) + public function createData(Smarty_Internal_TemplateBase $obj, \Smarty\Data $parent = null, $name = null) { /* @var Smarty $smarty */ $smarty = $obj->_getSmartyObj(); diff --git a/libs/sysplugins/smarty_internal_method_getautoloadfilters.php b/src/Method/smarty_internal_method_getautoloadfilters.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_getautoloadfilters.php rename to src/Method/smarty_internal_method_getautoloadfilters.php diff --git a/libs/sysplugins/smarty_internal_method_getconfigvariable.php b/src/Method/smarty_internal_method_getconfigvariable.php similarity index 80% rename from libs/sysplugins/smarty_internal_method_getconfigvariable.php rename to src/Method/smarty_internal_method_getconfigvariable.php index b5481512..b08dbee8 100644 --- a/libs/sysplugins/smarty_internal_method_getconfigvariable.php +++ b/src/Method/smarty_internal_method_getconfigvariable.php @@ -21,13 +21,13 @@ class Smarty_Internal_Method_GetConfigVariable /** * gets a config variable value * - * @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data + * @param \Smarty|\Smarty\Data|\Smarty_Internal_Template $data * @param string $varName the name of the config variable * @param bool $errorEnable * * @return null|string the value of the config variable */ - public function getConfigVariable(Smarty_Internal_Data $data, $varName = null, $errorEnable = true) + public function getConfigVariable(\Smarty\Data $data, $varName = null, $errorEnable = true) { return $data->ext->configLoad->_getConfigVariable($data, $varName, $errorEnable); } diff --git a/libs/sysplugins/smarty_internal_method_getconfigvars.php b/src/Method/smarty_internal_method_getconfigvars.php similarity index 89% rename from libs/sysplugins/smarty_internal_method_getconfigvars.php rename to src/Method/smarty_internal_method_getconfigvars.php index 763bdf98..666410d7 100644 --- a/libs/sysplugins/smarty_internal_method_getconfigvars.php +++ b/src/Method/smarty_internal_method_getconfigvars.php @@ -24,13 +24,13 @@ class Smarty_Internal_Method_GetConfigVars * @api Smarty::getConfigVars() * @link https://www.smarty.net/docs/en/api.get.config.vars.tpl * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param string $varname variable name or null * @param bool $search_parents include parent templates? * * @return mixed variable value or or array of variables */ - public function getConfigVars(Smarty_Internal_Data $data, $varname = null, $search_parents = true) + public function getConfigVars(\Smarty\Data $data, $varname = null, $search_parents = true) { $_ptr = $data; $var_array = array(); diff --git a/libs/sysplugins/smarty_internal_method_getdebugtemplate.php b/src/Method/smarty_internal_method_getdebugtemplate.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_getdebugtemplate.php rename to src/Method/smarty_internal_method_getdebugtemplate.php diff --git a/libs/sysplugins/smarty_internal_method_getdefaultmodifiers.php b/src/Method/smarty_internal_method_getdefaultmodifiers.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_getdefaultmodifiers.php rename to src/Method/smarty_internal_method_getdefaultmodifiers.php diff --git a/libs/sysplugins/smarty_internal_method_getglobal.php b/src/Method/smarty_internal_method_getglobal.php similarity index 89% rename from libs/sysplugins/smarty_internal_method_getglobal.php rename to src/Method/smarty_internal_method_getglobal.php index 2be11d7e..bb3aef3e 100644 --- a/libs/sysplugins/smarty_internal_method_getglobal.php +++ b/src/Method/smarty_internal_method_getglobal.php @@ -23,12 +23,12 @@ class Smarty_Internal_Method_GetGlobal * * @api Smarty::getGlobal() * - * @param \Smarty_Internal_Data $data + * @param \Smarty\Data $data * @param string $varName variable name or null * * @return string|array variable value or or array of variables */ - public function getGlobal(Smarty_Internal_Data $data, $varName = null) + public function getGlobal(\Smarty\Data $data, $varName = null) { if (isset($varName)) { if (isset(Smarty::$global_tpl_vars[ $varName ])) { diff --git a/libs/sysplugins/smarty_internal_method_getregisteredobject.php b/src/Method/smarty_internal_method_getregisteredobject.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_getregisteredobject.php rename to src/Method/smarty_internal_method_getregisteredobject.php diff --git a/libs/sysplugins/smarty_internal_method_getstreamvariable.php b/src/Method/smarty_internal_method_getstreamvariable.php similarity index 87% rename from libs/sysplugins/smarty_internal_method_getstreamvariable.php rename to src/Method/smarty_internal_method_getstreamvariable.php index 8db39c52..552803ae 100644 --- a/libs/sysplugins/smarty_internal_method_getstreamvariable.php +++ b/src/Method/smarty_internal_method_getstreamvariable.php @@ -23,13 +23,13 @@ class Smarty_Internal_Method_GetStreamVariable * * @api Smarty::getStreamVariable() * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param string $variable the stream of the variable * * @return mixed * @throws \SmartyException */ - public function getStreamVariable(Smarty_Internal_Data $data, $variable) + public function getStreamVariable(\Smarty\Data $data, $variable) { $_result = ''; $fp = fopen($variable, 'r+'); diff --git a/libs/sysplugins/smarty_internal_method_gettemplatevars.php b/src/Method/smarty_internal_method_gettemplatevars.php similarity index 85% rename from libs/sysplugins/smarty_internal_method_gettemplatevars.php rename to src/Method/smarty_internal_method_gettemplatevars.php index 0470785b..0c850014 100644 --- a/libs/sysplugins/smarty_internal_method_gettemplatevars.php +++ b/src/Method/smarty_internal_method_gettemplatevars.php @@ -24,17 +24,17 @@ class Smarty_Internal_Method_GetTemplateVars * @api Smarty::getTemplateVars() * @link https://www.smarty.net/docs/en/api.get.template.vars.tpl * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param string $varName variable name or null - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object * @param bool $searchParents include parent templates? * * @return mixed variable value or or array of variables */ public function getTemplateVars( - Smarty_Internal_Data $data, + \Smarty\Data $data, $varName = null, - Smarty_Internal_Data $_ptr = null, + \Smarty\Data $_ptr = null, $searchParents = true ) { if (isset($varName)) { @@ -76,18 +76,18 @@ class Smarty_Internal_Method_GetTemplateVars /** * gets the object of a Smarty variable * - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $data * @param string $varName the name of the Smarty variable - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object + * @param \Smarty\Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object * @param bool $searchParents search also in parent data * @param bool $errorEnable * - * @return \Smarty_Variable + * @return \Smarty\Variable */ public function _getVariable( - Smarty_Internal_Data $data, + \Smarty\Data $data, $varName, - Smarty_Internal_Data $_ptr = null, + \Smarty\Data $_ptr = null, $searchParents = true, $errorEnable = true ) { diff --git a/libs/sysplugins/smarty_internal_method_literals.php b/src/Method/smarty_internal_method_literals.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_literals.php rename to src/Method/smarty_internal_method_literals.php diff --git a/libs/sysplugins/smarty_internal_method_loadfilter.php b/src/Method/smarty_internal_method_loadfilter.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_loadfilter.php rename to src/Method/smarty_internal_method_loadfilter.php diff --git a/libs/sysplugins/smarty_internal_method_loadplugin.php b/src/Method/smarty_internal_method_loadplugin.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_loadplugin.php rename to src/Method/smarty_internal_method_loadplugin.php diff --git a/libs/sysplugins/smarty_internal_method_mustcompile.php b/src/Method/smarty_internal_method_mustcompile.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_mustcompile.php rename to src/Method/smarty_internal_method_mustcompile.php diff --git a/libs/sysplugins/smarty_internal_method_registercacheresource.php b/src/Method/smarty_internal_method_registercacheresource.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_registercacheresource.php rename to src/Method/smarty_internal_method_registercacheresource.php diff --git a/libs/sysplugins/smarty_internal_method_registerclass.php b/src/Method/smarty_internal_method_registerclass.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_registerclass.php rename to src/Method/smarty_internal_method_registerclass.php diff --git a/libs/sysplugins/smarty_internal_method_registerdefaultconfighandler.php b/src/Method/smarty_internal_method_registerdefaultconfighandler.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_registerdefaultconfighandler.php rename to src/Method/smarty_internal_method_registerdefaultconfighandler.php diff --git a/libs/sysplugins/smarty_internal_method_registerdefaultpluginhandler.php b/src/Method/smarty_internal_method_registerdefaultpluginhandler.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_registerdefaultpluginhandler.php rename to src/Method/smarty_internal_method_registerdefaultpluginhandler.php diff --git a/libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php b/src/Method/smarty_internal_method_registerdefaulttemplatehandler.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php rename to src/Method/smarty_internal_method_registerdefaulttemplatehandler.php diff --git a/libs/sysplugins/smarty_internal_method_registerfilter.php b/src/Method/smarty_internal_method_registerfilter.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_registerfilter.php rename to src/Method/smarty_internal_method_registerfilter.php diff --git a/libs/sysplugins/smarty_internal_method_registerobject.php b/src/Method/smarty_internal_method_registerobject.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_registerobject.php rename to src/Method/smarty_internal_method_registerobject.php diff --git a/libs/sysplugins/smarty_internal_method_registerplugin.php b/src/Method/smarty_internal_method_registerplugin.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_registerplugin.php rename to src/Method/smarty_internal_method_registerplugin.php diff --git a/libs/sysplugins/smarty_internal_method_registerresource.php b/src/Method/smarty_internal_method_registerresource.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_registerresource.php rename to src/Method/smarty_internal_method_registerresource.php diff --git a/libs/sysplugins/smarty_internal_method_setautoloadfilters.php b/src/Method/smarty_internal_method_setautoloadfilters.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_setautoloadfilters.php rename to src/Method/smarty_internal_method_setautoloadfilters.php diff --git a/libs/sysplugins/smarty_internal_method_setdebugtemplate.php b/src/Method/smarty_internal_method_setdebugtemplate.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_setdebugtemplate.php rename to src/Method/smarty_internal_method_setdebugtemplate.php diff --git a/libs/sysplugins/smarty_internal_method_setdefaultmodifiers.php b/src/Method/smarty_internal_method_setdefaultmodifiers.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_setdefaultmodifiers.php rename to src/Method/smarty_internal_method_setdefaultmodifiers.php diff --git a/libs/sysplugins/smarty_internal_method_unloadfilter.php b/src/Method/smarty_internal_method_unloadfilter.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_unloadfilter.php rename to src/Method/smarty_internal_method_unloadfilter.php diff --git a/libs/sysplugins/smarty_internal_method_unregistercacheresource.php b/src/Method/smarty_internal_method_unregistercacheresource.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_unregistercacheresource.php rename to src/Method/smarty_internal_method_unregistercacheresource.php diff --git a/libs/sysplugins/smarty_internal_method_unregisterfilter.php b/src/Method/smarty_internal_method_unregisterfilter.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_unregisterfilter.php rename to src/Method/smarty_internal_method_unregisterfilter.php diff --git a/libs/sysplugins/smarty_internal_method_unregisterobject.php b/src/Method/smarty_internal_method_unregisterobject.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_unregisterobject.php rename to src/Method/smarty_internal_method_unregisterobject.php diff --git a/libs/sysplugins/smarty_internal_method_unregisterplugin.php b/src/Method/smarty_internal_method_unregisterplugin.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_unregisterplugin.php rename to src/Method/smarty_internal_method_unregisterplugin.php diff --git a/libs/sysplugins/smarty_internal_method_unregisterresource.php b/src/Method/smarty_internal_method_unregisterresource.php similarity index 100% rename from libs/sysplugins/smarty_internal_method_unregisterresource.php rename to src/Method/smarty_internal_method_unregisterresource.php diff --git a/libs/sysplugins/smarty_internal_parsetree.php b/src/ParseTree/Base.php similarity index 79% rename from libs/sysplugins/smarty_internal_parsetree.php rename to src/ParseTree/Base.php index 9f767852..a1e05785 100644 --- a/libs/sysplugins/smarty_internal_parsetree.php +++ b/src/ParseTree/Base.php @@ -1,6 +1,9 @@ data); } diff --git a/libs/sysplugins/smarty_internal_parsetree_dq.php b/src/ParseTree/Dq.php similarity index 71% rename from libs/sysplugins/smarty_internal_parsetree_dq.php rename to src/ParseTree/Dq.php index 8655f586..2099445b 100644 --- a/libs/sysplugins/smarty_internal_parsetree_dq.php +++ b/src/ParseTree/Dq.php @@ -1,4 +1,6 @@ subtrees[] = $subtree; - if ($subtree instanceof Smarty_Internal_ParseTree_Tag) { + if ($subtree instanceof Tag) { $parser->block_nesting_level = count($parser->compiler->_tag_stack); } } @@ -34,21 +36,21 @@ class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree * Append buffer to subtree * * @param \Smarty_Internal_Templateparser $parser - * @param Smarty_Internal_ParseTree $subtree parse tree buffer + * @param Base $subtree parse tree buffer */ - public function append_subtree(Smarty_Internal_Templateparser $parser, Smarty_Internal_ParseTree $subtree) + public function append_subtree(\Smarty_Internal_Templateparser $parser, Base $subtree) { $last_subtree = count($this->subtrees) - 1; - if ($last_subtree >= 0 && $this->subtrees[ $last_subtree ] instanceof Smarty_Internal_ParseTree_Tag + if ($last_subtree >= 0 && $this->subtrees[ $last_subtree ] instanceof Tag && $this->subtrees[ $last_subtree ]->saved_block_nesting < $parser->block_nesting_level ) { - if ($subtree instanceof Smarty_Internal_ParseTree_Code) { + if ($subtree instanceof Code) { $this->subtrees[ $last_subtree ]->data = $parser->compiler->appendCode( $this->subtrees[ $last_subtree ]->data, 'data . ';?>' ); - } elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) { + } elseif ($subtree instanceof DqContent) { $this->subtrees[ $last_subtree ]->data = $parser->compiler->appendCode( $this->subtrees[ $last_subtree ]->data, @@ -61,7 +63,7 @@ class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree } else { $this->subtrees[] = $subtree; } - if ($subtree instanceof Smarty_Internal_ParseTree_Tag) { + if ($subtree instanceof Tag) { $parser->block_nesting_level = count($parser->compiler->_tag_stack); } } @@ -73,20 +75,20 @@ class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree * * @return string compiled template code */ - public function to_smarty_php(Smarty_Internal_Templateparser $parser) + public function to_smarty_php(\Smarty_Internal_Templateparser $parser) { $code = ''; foreach ($this->subtrees as $subtree) { if ($code !== '') { $code .= '.'; } - if ($subtree instanceof Smarty_Internal_ParseTree_Tag) { + if ($subtree instanceof Tag) { $more_php = $subtree->assign_to_var($parser); } else { $more_php = $subtree->to_smarty_php($parser); } $code .= $more_php; - if (!$subtree instanceof Smarty_Internal_ParseTree_DqContent) { + if (!$subtree instanceof DqContent) { $parser->compiler->has_variable_string = true; } } diff --git a/libs/sysplugins/smarty_internal_parsetree_dqcontent.php b/src/ParseTree/DqContent.php similarity index 83% rename from libs/sysplugins/smarty_internal_parsetree_dqcontent.php rename to src/ParseTree/DqContent.php index a8ca389d..8f3b78d7 100644 --- a/libs/sysplugins/smarty_internal_parsetree_dqcontent.php +++ b/src/ParseTree/DqContent.php @@ -1,4 +1,6 @@ data . '"'; } diff --git a/libs/sysplugins/smarty_internal_parsetree_tag.php b/src/ParseTree/Tag.php similarity index 83% rename from libs/sysplugins/smarty_internal_parsetree_tag.php rename to src/ParseTree/Tag.php index e6c75560..892c2c9f 100644 --- a/libs/sysplugins/smarty_internal_parsetree_tag.php +++ b/src/ParseTree/Tag.php @@ -1,4 +1,7 @@ data = $data; $this->saved_block_nesting = $parser->block_nesting_level; @@ -44,7 +47,7 @@ class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree * * @return string content */ - public function to_smarty_php(Smarty_Internal_Templateparser $parser) + public function to_smarty_php(\Smarty_Internal_Templateparser $parser) { return $this->data; } @@ -56,7 +59,7 @@ class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree * * @return string template code */ - public function assign_to_var(Smarty_Internal_Templateparser $parser) + public function assign_to_var(\Smarty_Internal_Templateparser $parser) { $var = $parser->compiler->getNewPrefixVariable(); $tmp = $parser->compiler->appendCode('', $this->data); diff --git a/libs/sysplugins/smarty_internal_parsetree_template.php b/src/ParseTree/Template.php similarity index 84% rename from libs/sysplugins/smarty_internal_parsetree_template.php rename to src/ParseTree/Template.php index 829c420f..09eb2fc1 100644 --- a/libs/sysplugins/smarty_internal_parsetree_template.php +++ b/src/ParseTree/Template.php @@ -1,4 +1,7 @@ subtrees)) { $this->subtrees = array_merge($this->subtrees, $subtree->subtrees); @@ -53,9 +56,9 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree * Append array to subtree * * @param \Smarty_Internal_Templateparser $parser - * @param \Smarty_Internal_ParseTree[] $array + * @param Base[] $array */ - public function append_array(Smarty_Internal_Templateparser $parser, $array = array()) + public function append_array(\Smarty_Internal_Templateparser $parser, $array = array()) { if (!empty($array)) { $this->subtrees = array_merge($this->subtrees, (array)$array); @@ -66,9 +69,9 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree * Prepend array to subtree * * @param \Smarty_Internal_Templateparser $parser - * @param \Smarty_Internal_ParseTree[] $array + * @param Base[] $array */ - public function prepend_array(Smarty_Internal_Templateparser $parser, $array = array()) + public function prepend_array(\Smarty_Internal_Templateparser $parser, $array = array()) { if (!empty($array)) { $this->subtrees = array_merge((array)$array, $this->subtrees); @@ -82,7 +85,7 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree * * @return string template code content */ - public function to_smarty_php(Smarty_Internal_Templateparser $parser) + public function to_smarty_php(\Smarty_Internal_Templateparser $parser) { $code = ''; @@ -136,12 +139,12 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree continue; } - if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text + if ($this->subtrees[ $key ] instanceof Text && $this->subtrees[ $key ]->isToBeStripped()) { $newMode = 'textstripped'; - } elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) { + } elseif ($this->subtrees[ $key ] instanceof Text) { $newMode = 'text'; - } elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) { + } elseif ($this->subtrees[ $key ] instanceof Tag) { $newMode = 'tag'; } else { $newMode = 'other'; diff --git a/libs/sysplugins/smarty_internal_parsetree_text.php b/src/ParseTree/Text.php similarity index 89% rename from libs/sysplugins/smarty_internal_parsetree_text.php rename to src/ParseTree/Text.php index 58116c81..51441b30 100644 --- a/libs/sysplugins/smarty_internal_parsetree_text.php +++ b/src/ParseTree/Text.php @@ -1,5 +1,7 @@ data; } diff --git a/libs/sysplugins/smarty_resource.php b/src/Resource/Base.php similarity index 72% rename from libs/sysplugins/smarty_resource.php rename to src/Resource/Base.php index 3c43a9f4..4aceed7b 100644 --- a/libs/sysplugins/smarty_resource.php +++ b/src/Resource/Base.php @@ -1,4 +1,7 @@ 'smarty_internal_resource_file.php', - 'string' => 'smarty_internal_resource_string.php', - 'extends' => 'smarty_internal_resource_extends.php', - 'stream' => 'smarty_internal_resource_stream.php', - 'eval' => 'smarty_internal_resource_eval.php', - 'php' => 'smarty_internal_resource_php.php' + 'file' => File::class, + 'string' => String::class, + 'extends' => Extending::class, + 'stream' => Stream::class, + 'eval' => StringEval::class, + 'php' => Php::class, ); /** @@ -58,32 +61,32 @@ abstract class Smarty_Resource /** * Load Resource Handler * - * @param Smarty $smarty smarty object + * @param \Smarty $smarty smarty object * @param string $type name of the resource * - * @throws SmartyException - * @return Smarty_Resource Resource Handler + * @throws \SmartyException + * @return Base Resource Handler */ - public static function load(Smarty $smarty, $type) + public static function load(\Smarty $smarty, $type) { // try smarty's cache - if (isset($smarty->_cache[ 'resource_handlers' ][ $type ])) { - return $smarty->_cache[ 'resource_handlers' ][ $type ]; + if (isset($smarty->_resource_handlers[ $type ])) { + return $smarty->_resource_handlers[ $type ]; } // try registered resource if (isset($smarty->registered_resources[ $type ])) { - return $smarty->_cache[ 'resource_handlers' ][ $type ] = $smarty->registered_resources[ $type ]; + return $smarty->_resource_handlers[ $type ] = $smarty->registered_resources[ $type ]; } // try sysplugins dir if (isset(self::$sysplugins[ $type ])) { - $_resource_class = 'Smarty_Internal_Resource_' . smarty_ucfirst_ascii($type); - return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class(); + $_resource_class = 'Smarty_Internal_Resource_' . \smarty_ucfirst_ascii($type); + return $smarty->_resource_handlers[ $type ] = new $_resource_class(); } // try plugins dir - $_resource_class = 'Smarty_Resource_' . smarty_ucfirst_ascii($type); + $_resource_class = 'Smarty_Resource_' . \smarty_ucfirst_ascii($type); if ($smarty->loadPlugin($_resource_class)) { if (class_exists($_resource_class, false)) { - return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class(); + return $smarty->_resource_handlers[ $type ] = new $_resource_class(); } else { $smarty->registerResource( $type, @@ -103,11 +106,11 @@ abstract class Smarty_Resource if (is_object($smarty->security_policy)) { $smarty->security_policy->isTrustedStream($type); } - return $smarty->_cache[ 'resource_handlers' ][ $type ] = new Smarty_Internal_Resource_Stream(); + return $smarty->_resource_handlers[ $type ] = new Stream(); } // TODO: try default_(template|config)_handler // give up - throw new SmartyException("Unknown resource type '{$type}'"); + throw new \SmartyException("Unknown resource type '{$type}'"); } /** @@ -149,7 +152,7 @@ abstract class Smarty_Resource $smarty = $obj->_getSmartyObj(); list($name, $type) = self::parseResourceName($template_resource, $smarty->default_resource_type); // TODO: optimize for Smarty's internal resource types - $resource = Smarty_Resource::load($smarty, $type); + $resource = Base::load($smarty, $type); // go relative to a given template? $_file_is_dotted = $name[ 0 ] === '.' && ($name[ 1 ] === '.' || $name[ 1 ] === '/'); if ($obj->_isTplObj() && $_file_is_dotted @@ -165,45 +168,45 @@ abstract class Smarty_Resource * wrapper for backward compatibility to versions < 3.1.22 * Either [$_template] or [$smarty, $template_resource] must be specified * - * @param Smarty_Internal_Template $_template template object - * @param Smarty $smarty smarty object + * @param \Smarty_Internal_Template $_template template object + * @param \Smarty $smarty smarty object * @param string $template_resource resource identifier * * @return \Smarty_Template_Source Source Object * @throws \SmartyException */ public static function source( - Smarty_Internal_Template $_template = null, - Smarty $smarty = null, + \Smarty_Internal_Template $_template = null, + \Smarty $smarty = null, $template_resource = null ) { - return Smarty_Template_Source::load($_template, $smarty, $template_resource); + return \Smarty_Template_Source::load($_template, $smarty, $template_resource); } /** * Load template's source into current template object * - * @param Smarty_Template_Source $source source object + * @param \Smarty_Template_Source $source source object * * @return string template source - * @throws SmartyException if source cannot be loaded + * @throws \SmartyException if source cannot be loaded */ - abstract public function getContent(Smarty_Template_Source $source); + abstract public function getContent(\Smarty_Template_Source $source); /** * populate Source Object with meta data from Resource * - * @param Smarty_Template_Source $source source object - * @param Smarty_Internal_Template $_template template object + * @param \Smarty_Template_Source $source source object + * @param \Smarty_Internal_Template $_template template object */ - abstract public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null); + abstract public function populate(\Smarty_Template_Source $source, \Smarty_Internal_Template $_template = null); /** * populate Source Object with timestamp and exists from Resource * - * @param Smarty_Template_Source $source source object + * @param \Smarty_Template_Source $source source object */ - public function populateTimestamp(Smarty_Template_Source $source) + public function populateTimestamp(\Smarty_Template_Source $source) { // intentionally left blank } @@ -211,13 +214,13 @@ abstract class Smarty_Resource /** * modify resource_name according to resource handlers specifications * - * @param Smarty $smarty Smarty instance + * @param \Smarty $smarty Smarty instance * @param string $resource_name resource_name to make unique * @param boolean $isConfig flag for config resource * * @return string unique resource name */ - public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) + public function buildUniqueResourceName(\Smarty $smarty, $resource_name, $isConfig = false) { if ($isConfig) { if (!isset($smarty->_joined_config_dir)) { @@ -241,11 +244,11 @@ abstract class Smarty_Resource /** * Determine basename for compiled filename * - * @param Smarty_Template_Source $source source object + * @param \Smarty_Template_Source $source source object * * @return string resource's basename */ - public function getBasename(Smarty_Template_Source $source) + public function getBasename(\Smarty_Template_Source $source) { return basename(preg_replace('![^\w]+!', '_', $source->name)); } diff --git a/libs/sysplugins/smarty_internal_resource_extends.php b/src/Resource/Extending.php similarity index 71% rename from libs/sysplugins/smarty_internal_resource_extends.php rename to src/Resource/Extending.php index 80946932..68b6b62a 100644 --- a/libs/sysplugins/smarty_internal_resource_extends.php +++ b/src/Resource/Extending.php @@ -1,4 +1,7 @@ type === 'php') { - throw new SmartyException("Resource type {$_s->type} cannot be used with the extends resource type"); + throw new \SmartyException("Resource type {$_s->type} cannot be used with the extends resource type"); } $sources[ $_s->uid ] = $_s; $uid .= $_s->filepath; @@ -63,9 +66,9 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource /** * populate Source Object with timestamp and exists from Resource * - * @param Smarty_Template_Source $source source object + * @param \Smarty_Template_Source $source source object */ - public function populateTimestamp(Smarty_Template_Source $source) + public function populateTimestamp(\Smarty_Template_Source $source) { $source->exists = true; /* @var \Smarty_Template_Source $_s */ @@ -78,15 +81,15 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource /** * Load template's source from files into current template object * - * @param Smarty_Template_Source $source source object + * @param \Smarty_Template_Source $source source object * * @return string template source - * @throws SmartyException if source cannot be loaded + * @throws \SmartyException if source cannot be loaded */ - public function getContent(Smarty_Template_Source $source) + public function getContent(\Smarty_Template_Source $source) { if (!$source->exists) { - throw new SmartyException("Unable to load template '{$source->type}:{$source->name}'"); + throw new \SmartyException("Unable to load template '{$source->type}:{$source->name}'"); } $_components = array_reverse($source->components); $_content = ''; @@ -101,11 +104,11 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource /** * Determine basename for compiled filename * - * @param Smarty_Template_Source $source source object + * @param \Smarty_Template_Source $source source object * * @return string resource's basename */ - public function getBasename(Smarty_Template_Source $source) + public function getBasename(\Smarty_Template_Source $source) { return str_replace(':', '.', basename($source->filepath)); } diff --git a/libs/sysplugins/smarty_internal_resource_eval.php b/src/Resource/StringEval.php similarity index 74% rename from libs/sysplugins/smarty_internal_resource_eval.php rename to src/Resource/StringEval.php index 3b552a58..2a88bfb1 100644 --- a/libs/sysplugins/smarty_internal_resource_eval.php +++ b/src/Resource/StringEval.php @@ -1,4 +1,7 @@ uid = $source->filepath = sha1($source->name); $source->timestamp = $source->exists = true; @@ -37,11 +40,11 @@ class Smarty_Internal_Resource_Eval extends Smarty_Resource_Recompiled * * @uses decode() to decode base64 and urlencoded template_resources * - * @param Smarty_Template_Source $source source object + * @param \Smarty_Template_Source $source source object * * @return string template source */ - public function getContent(Smarty_Template_Source $source) + public function getContent(\Smarty_Template_Source $source) { return $this->decode($source->name); } @@ -69,13 +72,13 @@ class Smarty_Internal_Resource_Eval extends Smarty_Resource_Recompiled /** * modify resource_name according to resource handlers specifications * - * @param Smarty $smarty Smarty instance + * @param \Smarty $smarty Smarty instance * @param string $resource_name resource_name to make unique * @param boolean $isConfig flag for config resource * * @return string unique resource name */ - public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) + public function buildUniqueResourceName(\Smarty $smarty, $resource_name, $isConfig = false) { return get_class($this) . '#' . $this->decode($resource_name); } @@ -83,11 +86,11 @@ class Smarty_Internal_Resource_Eval extends Smarty_Resource_Recompiled /** * Determine basename for compiled filename * - * @param Smarty_Template_Source $source source object + * @param \Smarty_Template_Source $source source object * * @return string resource's basename */ - public function getBasename(Smarty_Template_Source $source) + public function getBasename(\Smarty_Template_Source $source) { return ''; } diff --git a/libs/sysplugins/smarty_internal_resource_file.php b/src/Resource/smarty_internal_resource_file.php similarity index 97% rename from libs/sysplugins/smarty_internal_resource_file.php rename to src/Resource/smarty_internal_resource_file.php index ae206067..46703781 100644 --- a/libs/sysplugins/smarty_internal_resource_file.php +++ b/src/Resource/smarty_internal_resource_file.php @@ -110,9 +110,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource if ($file[ 0 ] === '.' && $_template && $_template->_isSubTpl() && preg_match('#^[.]{1,2}[\\\/]#', $file) ) { - if ($_template->parent->source->type !== 'file' && $_template->parent->source->type !== 'extends' - && !isset($_template->parent->_cache[ 'allow_relative_path' ]) - ) { + if ($_template->parent->source->type !== 'file' && $_template->parent->source->type !== 'extends') { throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'"); } // normalize path diff --git a/libs/sysplugins/smarty_internal_resource_php.php b/src/Resource/smarty_internal_resource_php.php similarity index 100% rename from libs/sysplugins/smarty_internal_resource_php.php rename to src/Resource/smarty_internal_resource_php.php diff --git a/libs/sysplugins/smarty_internal_resource_stream.php b/src/Resource/smarty_internal_resource_stream.php similarity index 100% rename from libs/sysplugins/smarty_internal_resource_stream.php rename to src/Resource/smarty_internal_resource_stream.php diff --git a/libs/sysplugins/smarty_internal_resource_string.php b/src/Resource/smarty_internal_resource_string.php similarity index 100% rename from libs/sysplugins/smarty_internal_resource_string.php rename to src/Resource/smarty_internal_resource_string.php diff --git a/libs/sysplugins/smarty_resource_custom.php b/src/Resource/smarty_resource_custom.php similarity index 100% rename from libs/sysplugins/smarty_resource_custom.php rename to src/Resource/smarty_resource_custom.php diff --git a/libs/sysplugins/smarty_resource_recompiled.php b/src/Resource/smarty_resource_recompiled.php similarity index 100% rename from libs/sysplugins/smarty_resource_recompiled.php rename to src/Resource/smarty_resource_recompiled.php diff --git a/libs/sysplugins/smarty_resource_uncompiled.php b/src/Resource/smarty_resource_uncompiled.php similarity index 100% rename from libs/sysplugins/smarty_resource_uncompiled.php rename to src/Resource/smarty_resource_uncompiled.php diff --git a/libs/sysplugins/smarty_internal_runtime_cachemodify.php b/src/Runtime/smarty_internal_runtime_cachemodify.php similarity index 100% rename from libs/sysplugins/smarty_internal_runtime_cachemodify.php rename to src/Runtime/smarty_internal_runtime_cachemodify.php diff --git a/libs/sysplugins/smarty_internal_runtime_cacheresourcefile.php b/src/Runtime/smarty_internal_runtime_cacheresourcefile.php similarity index 100% rename from libs/sysplugins/smarty_internal_runtime_cacheresourcefile.php rename to src/Runtime/smarty_internal_runtime_cacheresourcefile.php diff --git a/libs/sysplugins/smarty_internal_runtime_capture.php b/src/Runtime/smarty_internal_runtime_capture.php similarity index 96% rename from libs/sysplugins/smarty_internal_runtime_capture.php rename to src/Runtime/smarty_internal_runtime_capture.php index c9dca83d..8e74c093 100644 --- a/libs/sysplugins/smarty_internal_runtime_capture.php +++ b/src/Runtime/smarty_internal_runtime_capture.php @@ -9,12 +9,6 @@ */ class Smarty_Internal_Runtime_Capture { - /** - * Flag that this instance will not be cached - * - * @var bool - */ - public $isPrivateExtension = true; /** * Stack of capture parameter diff --git a/libs/sysplugins/smarty_internal_runtime_filterhandler.php b/src/Runtime/smarty_internal_runtime_filterhandler.php similarity index 100% rename from libs/sysplugins/smarty_internal_runtime_filterhandler.php rename to src/Runtime/smarty_internal_runtime_filterhandler.php diff --git a/libs/sysplugins/smarty_internal_runtime_foreach.php b/src/Runtime/smarty_internal_runtime_foreach.php similarity index 95% rename from libs/sysplugins/smarty_internal_runtime_foreach.php rename to src/Runtime/smarty_internal_runtime_foreach.php index badead16..62fa22bd 100644 --- a/libs/sysplugins/smarty_internal_runtime_foreach.php +++ b/src/Runtime/smarty_internal_runtime_foreach.php @@ -62,7 +62,7 @@ class Smarty_Internal_Runtime_Foreach $tpl->tpl_vars[ $item ] ); } - $tpl->tpl_vars[ $item ] = new Smarty_Variable(null, $tpl->isRenderingCache); + $tpl->tpl_vars[ $item ] = new \Smarty\Variable(null, $tpl->isRenderingCache); if ($total === 0) { $from = null; } else { @@ -73,7 +73,7 @@ class Smarty_Internal_Runtime_Foreach $tpl->tpl_vars[ $key ] ); } - $tpl->tpl_vars[ $key ] = new Smarty_Variable(null, $tpl->isRenderingCache); + $tpl->tpl_vars[ $key ] = new \Smarty\Variable(null, $tpl->isRenderingCache); } } if ($needTotal) { @@ -100,7 +100,7 @@ class Smarty_Internal_Runtime_Foreach if (isset($properties[ 'show' ])) { $namedProp[ 'show' ] = ($total > 0); } - $tpl->tpl_vars[ $namedVar ] = new Smarty_Variable($namedProp); + $tpl->tpl_vars[ $namedVar ] = new \Smarty\Variable($namedProp); } $this->stack[] = $saveVars; return $from; diff --git a/libs/sysplugins/smarty_internal_runtime_getincludepath.php b/src/Runtime/smarty_internal_runtime_getincludepath.php similarity index 100% rename from libs/sysplugins/smarty_internal_runtime_getincludepath.php rename to src/Runtime/smarty_internal_runtime_getincludepath.php diff --git a/libs/sysplugins/smarty_internal_runtime_inheritance.php b/src/Runtime/smarty_internal_runtime_inheritance.php similarity index 100% rename from libs/sysplugins/smarty_internal_runtime_inheritance.php rename to src/Runtime/smarty_internal_runtime_inheritance.php diff --git a/libs/sysplugins/smarty_internal_runtime_make_nocache.php b/src/Runtime/smarty_internal_runtime_make_nocache.php similarity index 91% rename from libs/sysplugins/smarty_internal_runtime_make_nocache.php rename to src/Runtime/smarty_internal_runtime_make_nocache.php index 7994aa04..fe931cc1 100644 --- a/libs/sysplugins/smarty_internal_runtime_make_nocache.php +++ b/src/Runtime/smarty_internal_runtime_make_nocache.php @@ -22,7 +22,7 @@ class Smarty_Internal_Runtime_Make_Nocache { if (isset($tpl->tpl_vars[ $var ])) { $export = - preg_replace('/^\\\\?Smarty_Variable::__set_state[(]|[)]$/', '', var_export($tpl->tpl_vars[ $var ], true)); + preg_replace('/^\\\\Smarty\\\\Variable::__set_state[(]|[)]$/', '', var_export($tpl->tpl_vars[ $var ], true)); if (preg_match('/(\w+)::__set_state/', $export, $match)) { throw new SmartyException("{make_nocache \${$var}} in template '{$tpl->source->name}': variable does contain object '{$match[1]}' not implementing method '__set_state'"); } @@ -43,7 +43,7 @@ class Smarty_Internal_Runtime_Make_Nocache { // do not overwrite existing nocache variables if (!isset($tpl->tpl_vars[ $var ]) || !$tpl->tpl_vars[ $var ]->nocache) { - $newVar = new Smarty_Variable(); + $newVar = new \Smarty\Variable(); unset($properties[ 'nocache' ]); foreach ($properties as $k => $v) { $newVar->$k = $v; diff --git a/libs/sysplugins/smarty_internal_runtime_tplfunction.php b/src/Runtime/smarty_internal_runtime_tplfunction.php similarity index 98% rename from libs/sysplugins/smarty_internal_runtime_tplfunction.php rename to src/Runtime/smarty_internal_runtime_tplfunction.php index e5f8e48f..511f03b1 100644 --- a/libs/sysplugins/smarty_internal_runtime_tplfunction.php +++ b/src/Runtime/smarty_internal_runtime_tplfunction.php @@ -156,7 +156,7 @@ class Smarty_Internal_Runtime_TplFunction */ public function saveTemplateVariables(Smarty_Internal_Template $tpl, $name) { - $tpl->_cache[ 'varStack' ][] = + $tpl->_var_stack[] = array('tpl' => $tpl->tpl_vars, 'config' => $tpl->config_vars, 'name' => "_tplFunction_{$name}"); } @@ -168,8 +168,8 @@ class Smarty_Internal_Runtime_TplFunction */ public function restoreTemplateVariables(Smarty_Internal_Template $tpl, $name) { - if (isset($tpl->_cache[ 'varStack' ])) { - $vars = array_pop($tpl->_cache[ 'varStack' ]); + if (isset($tpl->_var_stack)) { + $vars = array_pop($tpl->_var_stack); $tpl->tpl_vars = $vars[ 'tpl' ]; $tpl->config_vars = $vars[ 'config' ]; } diff --git a/libs/sysplugins/smarty_internal_runtime_updatecache.php b/src/Runtime/smarty_internal_runtime_updatecache.php similarity index 97% rename from libs/sysplugins/smarty_internal_runtime_updatecache.php rename to src/Runtime/smarty_internal_runtime_updatecache.php index c1abbb32..20f1e727 100644 --- a/libs/sysplugins/smarty_internal_runtime_updatecache.php +++ b/src/Runtime/smarty_internal_runtime_updatecache.php @@ -64,7 +64,7 @@ class Smarty_Internal_Runtime_UpdateCache * * @throws \SmartyException */ - public function removeNoCacheHash( + private function removeNoCacheHash( Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $no_output_filter @@ -144,7 +144,7 @@ class Smarty_Internal_Runtime_UpdateCache if (!isset($_template->cached)) { $_template->loadCached(); } - $content = $_template->smarty->ext->_codeFrame->create($_template, $content, '', true); + $content = $_template->createCodeFrame($content, '', true); return $this->write($_template, $content); } diff --git a/libs/sysplugins/smarty_internal_runtime_updatescope.php b/src/Runtime/smarty_internal_runtime_updatescope.php similarity index 95% rename from libs/sysplugins/smarty_internal_runtime_updatescope.php rename to src/Runtime/smarty_internal_runtime_updatescope.php index 2240f97c..3e003e80 100644 --- a/libs/sysplugins/smarty_internal_runtime_updatescope.php +++ b/src/Runtime/smarty_internal_runtime_updatescope.php @@ -33,7 +33,7 @@ class Smarty_Internal_Runtime_UpdateScope // update scopes foreach ($this->_getAffectedScopes($tpl, $mergedScope) as $ptr) { $this->_updateVariableInOtherScope($ptr->tpl_vars, $tpl, $varName); - if ($tagScope && $ptr->_isTplObj() && isset($tpl->_cache[ 'varStack' ])) { + if ($tagScope && $ptr->_isTplObj() && isset($tpl->_var_stack)) { $this->_updateVarStack($ptr, $varName); } } @@ -107,8 +107,8 @@ class Smarty_Internal_Runtime_UpdateScope public function _updateVarStack(Smarty_Internal_Template $tpl, $varName) { $i = 0; - while (isset($tpl->_cache[ 'varStack' ][ $i ])) { - $this->_updateVariableInOtherScope($tpl->_cache[ 'varStack' ][ $i ][ 'tpl' ], $tpl, $varName); + while (isset($tpl->_var_stack[ $i ])) { + $this->_updateVariableInOtherScope($tpl->_var_stack[ $i ][ 'tpl' ], $tpl, $varName); $i++; } } diff --git a/libs/sysplugins/smarty_internal_runtime_writefile.php b/src/Runtime/smarty_internal_runtime_writefile.php similarity index 100% rename from libs/sysplugins/smarty_internal_runtime_writefile.php rename to src/Runtime/smarty_internal_runtime_writefile.php diff --git a/libs/Smarty.class.php b/src/Smarty.class.php similarity index 92% rename from libs/Smarty.class.php rename to src/Smarty.class.php index 5351b579..a1d80b21 100644 --- a/libs/Smarty.class.php +++ b/src/Smarty.class.php @@ -78,12 +78,11 @@ if (!class_exists('Smarty_Autoloader')) { /** * Load always needed external class files */ -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php'; +require_once SMARTY_SYSPLUGINS_DIR . 'Data.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_extension_handler.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php'; -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php'; -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_variable.php'; +require_once SMARTY_SYSPLUGINS_DIR . 'Base.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_source.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_resource_base.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_resource_file.php'; @@ -627,34 +626,24 @@ class Smarty extends Smarty_Internal_TemplateBase */ protected $cache_dir = './cache/'; - /** - * removed properties - * - * @var string[] - */ - protected $obsoleteProperties = array( - 'resource_caching', 'template_resource_caching', 'direct_access_security', - '_dir_perms', '_file_perms', 'plugin_search_order', - 'inheritance_merge_compiled_includes', 'resource_cache_mode', - ); - - /** - * List of private properties which will call getter/setter on a direct access - * - * @var string[] - */ - protected $accessMap = array( - 'template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir', - 'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir', - 'cache_dir' => 'CacheDir', - ); - /** * PHP7 Compatibility mode * @var bool */ private $isMutingUndefinedOrNullWarnings = false; + /** + * Cache of loaded resource handlers. + * @var array + */ + public $_resource_handlers = []; + + /** + * Cache of loaded cacheresource handlers. + * @var array + */ + public $_cacheresource_handlers = []; + /** * Initialize new Smarty object */ @@ -667,7 +656,7 @@ class Smarty extends Smarty_Internal_TemplateBase } $this->start_time = microtime(true); if (isset($_SERVER[ 'SCRIPT_NAME' ])) { - Smarty::$global_tpl_vars[ 'SCRIPT_NAME' ] = new Smarty_Variable($_SERVER[ 'SCRIPT_NAME' ]); + Smarty::$global_tpl_vars[ 'SCRIPT_NAME' ] = new \Smarty\Variable($_SERVER[ 'SCRIPT_NAME' ]); } // Check if we're running on windows Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; @@ -878,7 +867,6 @@ class Smarty extends Smarty_Internal_TemplateBase foreach ($this->plugins_dir as $k => $v) { $this->plugins_dir[ $k ] = $this->_realpath(rtrim($v ?? '', '/\\') . DIRECTORY_SEPARATOR, true); } - $this->_cache[ 'plugin_files' ] = array(); $this->_pluginsDirNormalized = true; } return $this->plugins_dir; @@ -1004,7 +992,7 @@ class Smarty extends Smarty_Internal_TemplateBase if (!empty($data) && is_array($data)) { // set up variable values foreach ($data as $_key => $_val) { - $tpl->tpl_vars[ $_key ] = new Smarty_Variable($_val); + $tpl->tpl_vars[ $_key ] = new \Smarty\Variable($_val); } } if ($this->debugging || $this->debugging_ctrl === 'URL') { @@ -1286,7 +1274,7 @@ class Smarty extends Smarty_Internal_TemplateBase */ public function testInstall(&$errors = null) { - Smarty_Internal_TestInstall::testInstall($this, $errors); + \Smarty\TestInstall::testInstall($this, $errors); } /** @@ -1299,53 +1287,6 @@ class Smarty extends Smarty_Internal_TemplateBase return $this; } - /** - * <> Generic getter. - * Calls the appropriate getter function. - * Issues an E_USER_NOTICE if no valid getter is found. - * - * @param string $name property name - * - * @return mixed - */ - public function __get($name) - { - if (isset($this->accessMap[ $name ])) { - $method = 'get' . $this->accessMap[ $name ]; - return $this->{$method}(); - } elseif (isset($this->_cache[ $name ])) { - return $this->_cache[ $name ]; - } elseif (in_array($name, $this->obsoleteProperties)) { - return null; - } else { - trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); - } - return null; - } - - /** - * <> Generic setter. - * Calls the appropriate setter function. - * Issues an E_USER_NOTICE if no valid setter is found. - * - * @param string $name property name - * @param mixed $value parameter passed to setter - * - */ - public function __set($name, $value) - { - if (isset($this->accessMap[ $name ])) { - $method = 'set' . $this->accessMap[ $name ]; - $this->{$method}($value); - } elseif (in_array($name, $this->obsoleteProperties)) { - return; - } elseif (is_object($value) && method_exists($value, $name)) { - $this->$name = $value; - } else { - trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); - } - } - /** * Normalize and set directory string * diff --git a/libs/sysplugins/smarty_internal_runtime_codeframe.php b/src/Template/CodeFrame.php similarity index 93% rename from libs/sysplugins/smarty_internal_runtime_codeframe.php rename to src/Template/CodeFrame.php index d0ca751e..1ccf7f5f 100644 --- a/libs/sysplugins/smarty_internal_runtime_codeframe.php +++ b/src/Template/CodeFrame.php @@ -1,4 +1,7 @@ compiled->has_nocache_code; diff --git a/libs/sysplugins/smarty_template_cached.php b/src/Template/smarty_template_cached.php similarity index 100% rename from libs/sysplugins/smarty_template_cached.php rename to src/Template/smarty_template_cached.php diff --git a/libs/sysplugins/smarty_template_compiled.php b/src/Template/smarty_template_compiled.php similarity index 100% rename from libs/sysplugins/smarty_template_compiled.php rename to src/Template/smarty_template_compiled.php diff --git a/libs/sysplugins/smarty_template_config.php b/src/Template/smarty_template_config.php similarity index 100% rename from libs/sysplugins/smarty_template_config.php rename to src/Template/smarty_template_config.php diff --git a/libs/sysplugins/smarty_template_resource_base.php b/src/Template/smarty_template_resource_base.php similarity index 100% rename from libs/sysplugins/smarty_template_resource_base.php rename to src/Template/smarty_template_resource_base.php diff --git a/libs/sysplugins/smarty_template_source.php b/src/Template/smarty_template_source.php similarity index 96% rename from libs/sysplugins/smarty_template_source.php rename to src/Template/smarty_template_source.php index 16b47f23..a86e4feb 100644 --- a/libs/sysplugins/smarty_template_source.php +++ b/src/Template/smarty_template_source.php @@ -135,9 +135,8 @@ class Smarty_Template_Source */ public function __construct(Smarty $smarty, $resource, $type, $name) { - $this->handler = - isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] : - Smarty_Resource::load($smarty, $type); + $this->handler = Smarty_Resource::load($smarty, $type); + $this->smarty = $smarty; $this->resource = $resource; $this->type = $type; diff --git a/src/TestInstall.php b/src/TestInstall.php new file mode 100644 index 00000000..57a4e7ad --- /dev/null +++ b/src/TestInstall.php @@ -0,0 +1,338 @@ +\n"; + echo "Smarty Installation test...\n"; + echo "Testing template directory...\n"; + } + $_stream_resolve_include_path = function_exists('stream_resolve_include_path'); + // test if all registered template_dir are accessible + foreach ($smarty->getTemplateDir() as $template_dir) { + $_template_dir = $template_dir; + $template_dir = realpath($template_dir); + // resolve include_path or fail existence + if (!$template_dir) { + if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) { + // try PHP include_path + if ($_stream_resolve_include_path) { + $template_dir = stream_resolve_include_path($_template_dir); + } else { + $template_dir = $smarty->ext->_getIncludePath->getIncludePath($_template_dir, null, $smarty); + } + if ($template_dir !== false) { + if ($errors === null) { + echo "$template_dir is OK.\n"; + } + continue; + } else { + $status = false; + $message = + "FAILED: $_template_dir does not exist (and couldn't be found in include_path either)"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'template_dir' ] = $message; + } + continue; + } + } else { + $status = false; + $message = "FAILED: $_template_dir does not exist"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'template_dir' ] = $message; + } + continue; + } + } + if (!is_dir($template_dir)) { + $status = false; + $message = "FAILED: $template_dir is not a directory"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'template_dir' ] = $message; + } + } elseif (!is_readable($template_dir)) { + $status = false; + $message = "FAILED: $template_dir is not readable"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'template_dir' ] = $message; + } + } else { + if ($errors === null) { + echo "$template_dir is OK.\n"; + } + } + } + if ($errors === null) { + echo "Testing compile directory...\n"; + } + // test if registered compile_dir is accessible + $__compile_dir = $smarty->getCompileDir(); + $_compile_dir = realpath($__compile_dir); + if (!$_compile_dir) { + $status = false; + $message = "FAILED: {$__compile_dir} does not exist"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'compile_dir' ] = $message; + } + } elseif (!is_dir($_compile_dir)) { + $status = false; + $message = "FAILED: {$_compile_dir} is not a directory"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'compile_dir' ] = $message; + } + } elseif (!is_readable($_compile_dir)) { + $status = false; + $message = "FAILED: {$_compile_dir} is not readable"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'compile_dir' ] = $message; + } + } elseif (!is_writable($_compile_dir)) { + $status = false; + $message = "FAILED: {$_compile_dir} is not writable"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'compile_dir' ] = $message; + } + } else { + if ($errors === null) { + echo "{$_compile_dir} is OK.\n"; + } + } + if ($errors === null) { + echo "Testing plugins directory...\n"; + } + // test if all registered plugins_dir are accessible + // and if core plugins directory is still registered + $_core_plugins_dir = realpath(__DIR__ . '/../plugins'); + $_core_plugins_available = false; + foreach ($smarty->getPluginsDir() as $plugin_dir) { + $_plugin_dir = $plugin_dir; + $plugin_dir = realpath($plugin_dir); + // resolve include_path or fail existence + if (!$plugin_dir) { + if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { + // try PHP include_path + if ($_stream_resolve_include_path) { + $plugin_dir = stream_resolve_include_path($_plugin_dir); + } else { + $plugin_dir = $smarty->ext->_getIncludePath->getIncludePath($_plugin_dir, null, $smarty); + } + if ($plugin_dir !== false) { + if ($errors === null) { + echo "$plugin_dir is OK.\n"; + } + continue; + } else { + $status = false; + $message = "FAILED: $_plugin_dir does not exist (and couldn't be found in include_path either)"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'plugins_dir' ] = $message; + } + continue; + } + } else { + $status = false; + $message = "FAILED: $_plugin_dir does not exist"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'plugins_dir' ] = $message; + } + continue; + } + } + if (!is_dir($plugin_dir)) { + $status = false; + $message = "FAILED: $plugin_dir is not a directory"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'plugins_dir' ] = $message; + } + } elseif (!is_readable($plugin_dir)) { + $status = false; + $message = "FAILED: $plugin_dir is not readable"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'plugins_dir' ] = $message; + } + } elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) { + $_core_plugins_available = true; + if ($errors === null) { + echo "$plugin_dir is OK.\n"; + } + } else { + if ($errors === null) { + echo "$plugin_dir is OK.\n"; + } + } + } + if (!$_core_plugins_available) { + $status = false; + $message = "WARNING: Smarty's own libs/plugins is not available"; + if ($errors === null) { + echo $message . ".\n"; + } elseif (!isset($errors[ 'plugins_dir' ])) { + $errors[ 'plugins_dir' ] = $message; + } + } + if ($errors === null) { + echo "Testing cache directory...\n"; + } + // test if all registered cache_dir is accessible + $__cache_dir = $smarty->getCacheDir(); + $_cache_dir = realpath($__cache_dir); + if (!$_cache_dir) { + $status = false; + $message = "FAILED: {$__cache_dir} does not exist"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'cache_dir' ] = $message; + } + } elseif (!is_dir($_cache_dir)) { + $status = false; + $message = "FAILED: {$_cache_dir} is not a directory"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'cache_dir' ] = $message; + } + } elseif (!is_readable($_cache_dir)) { + $status = false; + $message = "FAILED: {$_cache_dir} is not readable"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'cache_dir' ] = $message; + } + } elseif (!is_writable($_cache_dir)) { + $status = false; + $message = "FAILED: {$_cache_dir} is not writable"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'cache_dir' ] = $message; + } + } else { + if ($errors === null) { + echo "{$_cache_dir} is OK.\n"; + } + } + if ($errors === null) { + echo "Testing configs directory...\n"; + } + // test if all registered config_dir are accessible + foreach ($smarty->getConfigDir() as $config_dir) { + $_config_dir = $config_dir; + // resolve include_path or fail existence + if (!$config_dir) { + if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) { + // try PHP include_path + if ($_stream_resolve_include_path) { + $config_dir = stream_resolve_include_path($_config_dir); + } else { + $config_dir = $smarty->ext->_getIncludePath->getIncludePath($_config_dir, null, $smarty); + } + if ($config_dir !== false) { + if ($errors === null) { + echo "$config_dir is OK.\n"; + } + continue; + } else { + $status = false; + $message = "FAILED: $_config_dir does not exist (and couldn't be found in include_path either)"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'config_dir' ] = $message; + } + continue; + } + } else { + $status = false; + $message = "FAILED: $_config_dir does not exist"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'config_dir' ] = $message; + } + continue; + } + } + if (!is_dir($config_dir)) { + $status = false; + $message = "FAILED: $config_dir is not a directory"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'config_dir' ] = $message; + } + } elseif (!is_readable($config_dir)) { + $status = false; + $message = "FAILED: $config_dir is not readable"; + if ($errors === null) { + echo $message . ".\n"; + } else { + $errors[ 'config_dir' ] = $message; + } + } else { + if ($errors === null) { + echo "$config_dir is OK.\n"; + } + } + } + if ($errors === null) { + echo "Tests complete.\n"; + echo "\n"; + } + return $status; + } +} diff --git a/libs/sysplugins/smarty_variable.php b/src/Variable.php similarity index 96% rename from libs/sysplugins/smarty_variable.php rename to src/Variable.php index 6a534228..55676685 100644 --- a/libs/sysplugins/smarty_variable.php +++ b/src/Variable.php @@ -1,5 +1,7 @@ smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' . var_export($this->config_data, true) . '); ?>'; - return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code); + return $template_header . $this->createCodeFrame($code); } /** diff --git a/libs/sysplugins/smarty_internal_configfilelexer.php b/src/smarty_internal_configfilelexer.php similarity index 100% rename from libs/sysplugins/smarty_internal_configfilelexer.php rename to src/smarty_internal_configfilelexer.php diff --git a/libs/sysplugins/smarty_internal_configfileparser.php b/src/smarty_internal_configfileparser.php similarity index 100% rename from libs/sysplugins/smarty_internal_configfileparser.php rename to src/smarty_internal_configfileparser.php diff --git a/libs/sysplugins/smarty_internal_debug.php b/src/smarty_internal_debug.php similarity index 99% rename from libs/sysplugins/smarty_internal_debug.php rename to src/smarty_internal_debug.php index 570819d2..092f3a5d 100644 --- a/libs/sysplugins/smarty_internal_debug.php +++ b/src/smarty_internal_debug.php @@ -14,7 +14,7 @@ * @package Smarty * @subpackage Debug */ -class Smarty_Internal_Debug extends Smarty_Internal_Data +class Smarty_Internal_Debug extends \Smarty\Data { /** * template data diff --git a/libs/sysplugins/smarty_internal_errorhandler.php b/src/smarty_internal_errorhandler.php similarity index 100% rename from libs/sysplugins/smarty_internal_errorhandler.php rename to src/smarty_internal_errorhandler.php diff --git a/libs/sysplugins/smarty_internal_extension_handler.php b/src/smarty_internal_extension_handler.php similarity index 97% rename from libs/sysplugins/smarty_internal_extension_handler.php rename to src/smarty_internal_extension_handler.php index 3ef040ab..1f3a666d 100644 --- a/libs/sysplugins/smarty_internal_extension_handler.php +++ b/src/smarty_internal_extension_handler.php @@ -13,7 +13,6 @@ * @property Smarty_Internal_Runtime_CacheModify $_cacheModify * @property Smarty_Internal_Runtime_CacheResourceFile $_cacheResourceFile * @property Smarty_Internal_Runtime_Capture $_capture - * @property Smarty_Internal_Runtime_CodeFrame $_codeFrame * @property Smarty_Internal_Runtime_FilterHandler $_filterHandler * @property Smarty_Internal_Runtime_Foreach $_foreach * @property Smarty_Internal_Runtime_GetIncludePath $_getIncludePath @@ -58,13 +57,13 @@ class Smarty_Internal_Extension_Handler /** * Call external Method * - * @param \Smarty_Internal_Data $data + * @param \Smarty\Data $data * @param string $name external method names * @param array $args argument array * * @return mixed */ - public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args) + public function _callExternalMethod(\Smarty\Data $data, $name, $args) { /* @var Smarty $data ->smarty */ $smarty = isset($data->smarty) ? $data->smarty : $data; diff --git a/libs/sysplugins/smarty_internal_nocache_insert.php b/src/smarty_internal_nocache_insert.php similarity index 100% rename from libs/sysplugins/smarty_internal_nocache_insert.php rename to src/smarty_internal_nocache_insert.php diff --git a/libs/sysplugins/smarty_internal_smartytemplatecompiler.php b/src/smarty_internal_smartytemplatecompiler.php similarity index 100% rename from libs/sysplugins/smarty_internal_smartytemplatecompiler.php rename to src/smarty_internal_smartytemplatecompiler.php diff --git a/libs/sysplugins/smarty_internal_template.php b/src/smarty_internal_template.php similarity index 96% rename from libs/sysplugins/smarty_internal_template.php rename to src/smarty_internal_template.php index 72d1d52e..a40d4e67 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/src/smarty_internal_template.php @@ -134,7 +134,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase * * @param string $template_resource template resource string * @param Smarty $smarty Smarty instance - * @param null|\Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $_parent back pointer to parent + * @param null|\Smarty_Internal_Template|\Smarty|\Smarty\Data $_parent back pointer to parent * object with variables or * null * @param mixed $_cache_id cache id or null @@ -149,7 +149,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase public function __construct( $template_resource, Smarty $smarty, - Smarty_Internal_Data $_parent = null, + \Smarty\Data $_parent = null, $_cache_id = null, $_compile_id = null, $_caching = null, @@ -354,7 +354,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase if (!empty($data)) { // set up variable values foreach ($data as $_key => $_val) { - $tpl->tpl_vars[ $_key ] = new Smarty_Variable($_val, $this->isRenderingCache); + $tpl->tpl_vars[ $_key ] = new \Smarty\Variable($_val, $this->isRenderingCache); } } if ($tpl->caching === 9999) { @@ -429,7 +429,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase $this->tpl_vars[ $varName ]->nocache = true; } } else { - $this->tpl_vars[ $varName ] = new Smarty_Variable($value, $nocache || $this->isRenderingCache); + $this->tpl_vars[ $varName ] = new \Smarty\Variable($value, $nocache || $this->isRenderingCache); } if ($scope >= 0) { if ($scope > 0 || $this->scope > 0) { @@ -656,6 +656,20 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase ); } + /** + * Create code frame for compiled and cached templates + * + * @param string $content optional template content + * @param string $functions compiled template function and block code + * @param bool $cache flag for cache file + * @param \Smarty_Internal_TemplateCompilerBase $compiler + * + * @return string + */ + public function createCodeFrame($content = '', $functions = '', $cache = false, Smarty_Internal_TemplateCompilerBase $compiler = null) { + return \Smarty\Template\CodeFrame::create($this, $content, $functions, $cache, $compiler); + } + /** * Handle unknown class methods * diff --git a/libs/sysplugins/smarty_internal_templatebase.php b/src/smarty_internal_templatebase.php similarity index 97% rename from libs/sysplugins/smarty_internal_templatebase.php rename to src/smarty_internal_templatebase.php index 918362e9..032b1a60 100644 --- a/libs/sysplugins/smarty_internal_templatebase.php +++ b/src/smarty_internal_templatebase.php @@ -22,12 +22,11 @@ * @method Smarty_Internal_TemplateBase addAutoloadFilters(mixed $filters, string $type = null) * @method Smarty_Internal_TemplateBase addDefaultModifiers(mixed $modifiers) * @method Smarty_Internal_TemplateBase addLiterals(mixed $literals) - * @method Smarty_Internal_TemplateBase createData(Smarty_Internal_Data $parent = null, string $name = null) + * @method Smarty_Internal_TemplateBase createData(\Smarty\Data $parent = null, string $name = null) * @method array getAutoloadFilters(string $type = null) * @method string getDebugTemplate() * @method array getDefaultModifier() * @method array getLiterals() - * @method array getTags(mixed $template = null) * @method object getRegisteredObject(string $object_name) * @method Smarty_Internal_TemplateBase registerCacheResource(string $name, Smarty_CacheResource $resource_handler) * @method Smarty_Internal_TemplateBase registerClass(string $class_name, string $class_impl) @@ -46,7 +45,7 @@ * @method Smarty_Internal_TemplateBase unregisterFilter(string $type, mixed $callback) * @method Smarty_Internal_TemplateBase unregisterResource(string $name) */ -abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data +abstract class Smarty_Internal_TemplateBase extends \Smarty\Data { /** * Set this if you want different sets of cache files for the same @@ -93,11 +92,11 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data public $tplFunctions = array(); /** - * universal cache + * When initialized to an (empty) array, this variable will hold a stack of template variables. * - * @var array() + * @var null|array */ - public $_cache = array(); + public $_var_stack = null; /** * fetches a rendered Smarty template diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/src/smarty_internal_templatecompilerbase.php similarity index 99% rename from libs/sysplugins/smarty_internal_templatecompilerbase.php rename to src/smarty_internal_templatecompilerbase.php index d5c18d31..5587828b 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/src/smarty_internal_templatecompilerbase.php @@ -313,13 +313,6 @@ abstract class Smarty_Internal_TemplateCompilerBase 'class' ); - /** - * General storage area for tag compiler plugins - * - * @var array - */ - public $_cache = array(); - /** * Lexer preg pattern for left delimiter * @@ -389,8 +382,7 @@ abstract class Smarty_Internal_TemplateCompilerBase Smarty_Internal_TemplateCompilerBase $parent_compiler = null ) { // get code frame of compiled template - $_compiled_code = $template->smarty->ext->_codeFrame->create( - $template, + $_compiled_code = $template->createCodeFrame( $this->compileTemplateSource( $template, $nocache, @@ -1008,7 +1000,7 @@ abstract class Smarty_Internal_TemplateCompilerBase $this->template->tpl_vars[ $_var ] = clone $this->template->tpl_vars[ $_var ]; $this->template->tpl_vars[ $_var ]->nocache = true; } else { - $this->template->tpl_vars[ $_var ] = new Smarty_Variable(null, true); + $this->template->tpl_vars[ $_var ] = new \Smarty\Variable(null, true); } } } @@ -1461,13 +1453,7 @@ abstract class Smarty_Internal_TemplateCompilerBase // $args contains the attributes parsed and compiled by the lexer/parser // assume that tag does compile into code, but creates no HTML output $this->has_code = true; - // log tag/attributes - if (isset($this->smarty->_cache[ 'get_used_tags' ])) { - $this->template->_cache[ 'used_tags' ][] = array( - $tag, - $args - ); - } + // check nocache option flag foreach ($args as $arg) { if (!is_array($arg)) { diff --git a/libs/sysplugins/smarty_internal_templatelexer.php b/src/smarty_internal_templatelexer.php similarity index 99% rename from libs/sysplugins/smarty_internal_templatelexer.php rename to src/smarty_internal_templatelexer.php index 5ca48205..75ff5889 100644 --- a/libs/sysplugins/smarty_internal_templatelexer.php +++ b/src/smarty_internal_templatelexer.php @@ -67,13 +67,6 @@ class Smarty_Internal_Templatelexer */ public $taglineno; - /** - * php code type - * - * @var string - */ - public $phpType = ''; - /** * state number * diff --git a/libs/sysplugins/smarty_internal_templateparser.php b/src/smarty_internal_templateparser.php similarity index 98% rename from libs/sysplugins/smarty_internal_templateparser.php rename to src/smarty_internal_templateparser.php index a2dd0d6f..4be2c2f4 100644 --- a/libs/sysplugins/smarty_internal_templateparser.php +++ b/src/smarty_internal_templateparser.php @@ -63,14 +63,14 @@ class Smarty_Internal_Templateparser /** * root parse tree buffer * - * @var Smarty_Internal_ParseTree_Template + * @var \Smarty\ParseTree\Template */ public $root_buffer; /** * current parse tree object * - * @var Smarty_Internal_ParseTree + * @var \Smarty\ParseTree\Base */ public $current_buffer; @@ -132,14 +132,14 @@ class Smarty_Internal_Templateparser /** * template prefix array * - * @var \Smarty_Internal_ParseTree[] + * @var \Smarty\ParseTree\Base[] */ public $template_prefix = array(); /** * template prefix array * - * @var \Smarty_Internal_ParseTree[] + * @var \Smarty\ParseTree\Base[] */ public $template_postfix = array(); @@ -156,7 +156,7 @@ class Smarty_Internal_Templateparser $this->template = $this->compiler->template; $this->smarty = $this->template->smarty; $this->security = isset($this->smarty->security_policy) ? $this->smarty->security_policy : false; - $this->current_buffer = $this->root_buffer = new Smarty_Internal_ParseTree_Template(); + $this->current_buffer = $this->root_buffer = new \Smarty\ParseTree\Template(); } /** @@ -166,7 +166,7 @@ class Smarty_Internal_Templateparser */ public function insertPhpCode($code) { - $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Tag($this, $code)); + $this->current_buffer->append_subtree($this, new \Smarty\ParseTree\Tag($this, $code)); } /** @@ -188,7 +188,7 @@ class Smarty_Internal_Templateparser * * @param string $code * - * @return Smarty_Internal_ParseTree_Tag + * @return \Smarty\ParseTree\Tag */ public function mergePrefixCode($code) { @@ -198,7 +198,7 @@ class Smarty_Internal_Templateparser } $this->compiler->prefix_code = array(); $tmp .= $code; - return new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp, true)); + return new \Smarty\ParseTree\Tag($this, $this->compiler->processNocacheCode($tmp, true)); } @@ -2037,7 +2037,7 @@ public static $yy_action = array( $this->current_buffer->append_subtree($this, null); } - $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Text($text, $this->strip)); + $this->current_buffer->append_subtree($this, new \Smarty\ParseTree\Text($text, $this->strip)); } // line 250 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r2(){ @@ -2049,7 +2049,7 @@ public static $yy_action = array( } // line 259 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r4(){ - $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Text($this->yystack[$this->yyidx + -1]->minor)); + $this->current_buffer->append_subtree($this, new \Smarty\ParseTree\Text($this->yystack[$this->yyidx + -1]->minor)); } // line 264 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r5(){ @@ -2736,27 +2736,27 @@ public static $yy_action = array( } // line 1235 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r178(){ - $this->_retvalue = new Smarty_Internal_ParseTree_Dq($this, $this->yystack[$this->yyidx + 0]->minor); + $this->_retvalue = new \Smarty\ParseTree\Dq($this, $this->yystack[$this->yyidx + 0]->minor); } // line 1239 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r179(){ - $this->_retvalue = new Smarty_Internal_ParseTree_Code('(string)'.$this->yystack[$this->yyidx + -1]->minor); + $this->_retvalue = new \Smarty\ParseTree\Code('(string)'.$this->yystack[$this->yyidx + -1]->minor); } // line 1243 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r180(){ - $this->_retvalue = new Smarty_Internal_ParseTree_Code('(string)('.$this->yystack[$this->yyidx + -1]->minor.')'); + $this->_retvalue = new \Smarty\ParseTree\Code('(string)('.$this->yystack[$this->yyidx + -1]->minor.')'); } // line 1247 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r181(){ - $this->_retvalue = new Smarty_Internal_ParseTree_Code('(string)$_smarty_tpl->tpl_vars[\''. substr($this->yystack[$this->yyidx + 0]->minor,1) .'\']->value'); + $this->_retvalue = new \Smarty\ParseTree\Code('(string)$_smarty_tpl->tpl_vars[\''. substr($this->yystack[$this->yyidx + 0]->minor,1) .'\']->value'); } // line 1259 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r184(){ - $this->_retvalue = new Smarty_Internal_ParseTree_Tag($this, $this->yystack[$this->yyidx + 0]->minor); + $this->_retvalue = new \Smarty\ParseTree\Tag($this, $this->yystack[$this->yyidx + 0]->minor); } // line 1263 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r185(){ - $this->_retvalue = new Smarty_Internal_ParseTree_DqContent($this->yystack[$this->yyidx + 0]->minor); + $this->_retvalue = new \Smarty\ParseTree\DqContent($this->yystack[$this->yyidx + 0]->minor); } private $_retvalue; diff --git a/libs/sysplugins/smarty_internal_undefined.php b/src/smarty_internal_undefined.php similarity index 100% rename from libs/sysplugins/smarty_internal_undefined.php rename to src/smarty_internal_undefined.php diff --git a/libs/sysplugins/smarty_data.php b/src/sysplugins/smarty_data.php similarity index 93% rename from libs/sysplugins/smarty_data.php rename to src/sysplugins/smarty_data.php index 2545ed3a..08205aaa 100644 --- a/libs/sysplugins/smarty_data.php +++ b/src/sysplugins/smarty_data.php @@ -15,7 +15,7 @@ * @package Smarty * @subpackage Template */ -class Smarty_Data extends Smarty_Internal_Data +class Smarty_Data extends \Smarty\Data { /** * Counter @@ -59,7 +59,7 @@ class Smarty_Data extends Smarty_Internal_Data } elseif (is_array($_parent)) { // set up variable values foreach ($_parent as $_key => $_val) { - $this->tpl_vars[ $_key ] = new Smarty_Variable($_val); + $this->tpl_vars[ $_key ] = new \Smarty\Variable($_val); } } elseif ($_parent !== null) { throw new SmartyException('Wrong type for template variables'); diff --git a/libs/sysplugins/smarty_security.php b/src/sysplugins/smarty_security.php similarity index 100% rename from libs/sysplugins/smarty_security.php rename to src/sysplugins/smarty_security.php diff --git a/libs/sysplugins/smarty_undefined_variable.php b/src/sysplugins/smarty_undefined_variable.php similarity index 89% rename from libs/sysplugins/smarty_undefined_variable.php rename to src/sysplugins/smarty_undefined_variable.php index 6d31a8a0..4dab16aa 100644 --- a/libs/sysplugins/smarty_undefined_variable.php +++ b/src/sysplugins/smarty_undefined_variable.php @@ -7,7 +7,7 @@ * @package Smarty * @subpackage Template */ -class Smarty_Undefined_Variable extends Smarty_Variable +class Smarty_Undefined_Variable extends \Smarty\Variable { /** * Returns null for not existing properties diff --git a/libs/sysplugins/smartycompilerexception.php b/src/sysplugins/smartycompilerexception.php similarity index 100% rename from libs/sysplugins/smartycompilerexception.php rename to src/sysplugins/smartycompilerexception.php diff --git a/libs/sysplugins/smartyexception.php b/src/sysplugins/smartyexception.php similarity index 100% rename from libs/sysplugins/smartyexception.php rename to src/sysplugins/smartyexception.php diff --git a/tests/PHPUnit_Smarty.php b/tests/PHPUnit_Smarty.php index de4a3776..4bcca74f 100644 --- a/tests/PHPUnit_Smarty.php +++ b/tests/PHPUnit_Smarty.php @@ -637,8 +637,8 @@ KEY `name` (`name`) } public static function getSmartyPluginsDir(){ - if (is_dir(__DIR__ . '/../smarty/libs/plugins')) { - return __DIR__ . '/../smarty/libs/plugins'; + if (is_dir(__DIR__ . '/../smarty/src/plugins')) { + return __DIR__ . '/../smarty/src/plugins'; } else if(is_dir(__DIR__ . '/../libs/plugins')) { return __DIR__ . '/../libs/plugins'; } diff --git a/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php b/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php index a6fb46a3..db8691f8 100644 --- a/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php +++ b/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php @@ -27,7 +27,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testTemplateDirDirectRelative() { $s = new Smarty(); - $s->template_dir = './foo'; + $s->setTemplateDir('./foo'); $d = $s->getTemplateDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); } @@ -35,8 +35,8 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testTemplateDirDirectRelativeArray() { $s = new Smarty(); - $s->template_dir = array('./foo', './bar/'); - $d = $s->template_dir; + $s->setTemplateDir(array('./foo', './bar/')); + $d = $s->getTemplateDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); } @@ -44,7 +44,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testTemplateDirDirectRelativeArrayAdd() { $s = new Smarty(); - $s->template_dir = './foo'; + $s->setTemplateDir('./foo'); $s->addTemplateDir('./bar/'); $d = $s->getTemplateDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); @@ -61,7 +61,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testTemplateDirDirectRelativeExtends2() { $s = new FolderT(); - $s->template_dir = './bar'; + $s->setTemplateDir('./bar'); $d = $s->getTemplateDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); } @@ -73,7 +73,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testConfigDirDirectRelative() { $s = new Smarty(); - $s->config_dir = './foo'; + $s->setConfigDir('./foo'); $d = $s->getConfigDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); } @@ -81,8 +81,8 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testConfigDirDirectRelativeArray() { $s = new Smarty(); - $s->config_dir = array('./foo', './bar/'); - $d = $s->config_dir; + $s->setConfigDir(array('./foo', './bar/')); + $d = $s->getConfigDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); } @@ -90,7 +90,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testConfigDirDirectRelativeArrayAdd() { $s = new Smarty(); - $s->config_dir = './foo'; + $s->setConfigDir('./foo'); $s->addConfigDir('./bar/'); $d = $s->getConfigDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); @@ -107,7 +107,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testConfigDirDirectRelativeExtends2() { $s = new FolderT(); - $s->config_dir = './bar'; + $s->setConfigDir('./bar'); $d = $s->getConfigDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); } @@ -119,7 +119,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testPluginDirDirectRelative() { $s = new Smarty(); - $s->plugins_dir = './foo'; + $s->setPluginsDir('./foo'); $d = $s->getPluginsDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); } @@ -127,8 +127,8 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testPluginDirDirectRelativeArray() { $s = new Smarty(); - $s->plugins_dir = array('./foo', './bar/'); - $d = $s->plugins_dir; + $s->setPluginsDir(array('./foo', './bar/')); + $d = $s->getPluginsDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); } @@ -136,7 +136,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testPluginDirDirectRelativeArrayAdd() { $s = new Smarty(); - $s->plugins_dir = './foo'; + $s->setPluginsDir('./foo'); $s->addPluginsDir('./bar/'); $d = $s->getPluginsDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); @@ -153,7 +153,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testPluginDirDirectRelativeExtends2() { $s = new FolderT(); - $s->plugins_dir = './bar'; + $s->setPluginsDir('./bar'); $d = $s->getPluginsDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); } @@ -164,7 +164,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testCompileDirDirectRelative() { $s = new Smarty(); - $s->compile_dir = './foo'; + $s->setCompileDir('./foo'); $d = $s->getCompileDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d); } @@ -179,7 +179,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testCompileDirDirectRelativeExtends2() { $s = new FolderT(); - $s->compile_dir = './bar'; + $s->setCompileDir('./bar'); $d = $s->getCompileDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d); } @@ -190,7 +190,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testCacheDirDirectRelative() { $s = new Smarty(); - $s->cache_dir = './foo'; + $s->setCacheDir('./foo'); $d = $s->getCacheDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d); } @@ -205,7 +205,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty public function testCacheDirDirectRelativeExtends2() { $s = new FolderT(); - $s->cache_dir = './bar'; + $s->setCacheDir('./bar'); $d = $s->getCacheDir(); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d); } diff --git a/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php b/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php index 5d549c8b..30646486 100644 --- a/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php +++ b/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php @@ -28,9 +28,9 @@ function smarty_function_checkvar($params, $template) $output .= "#{$ptr->source->name}:\${$var} ="; $output .= isset($ptr->tpl_vars[$var]) ? preg_replace('/\s/', '', var_export($ptr->tpl_vars[$var]->value, true)) : '>unassigned<'; $i = 0; - while (isset($ptr->_cache[ 'varStack' ][ $i ])) { - $output .= "#{$ptr->_cache[ 'varStack' ][ $i ]['name']} = "; - $output .= isset($ptr->_cache[ 'varStack' ][ $i ][ 'tpl' ][$var]) ? preg_replace('/\s/', '', var_export($ptr->_cache[ 'varStack' ][ $i ][ 'tpl' ][$var]->value, true)) : '>unassigned<'; + while (isset($ptr->_var_stack[ $i ])) { + $output .= "#{$ptr->_var_stack[ $i ]['name']} = "; + $output .= isset($ptr->_var_stack[ $i ][ 'tpl' ][$var]) ? preg_replace('/\s/', '', var_export($ptr->_var_stack[ $i ][ 'tpl' ][$var]->value, true)) : '>unassigned<'; $i ++; } $ptr = $ptr->parent; diff --git a/utilities/BuildExpectedFiles.php b/utilities/BuildExpectedFiles.php deleted file mode 100644 index 5945a350..00000000 --- a/utilities/BuildExpectedFiles.php +++ /dev/null @@ -1,29 +0,0 @@ -isDot() && 'php' == $file->getExtension()) { - $filename = $file->getBasename(); - $sysplugins[ $filename ] = true; - } -} -$plugins = array(); -$iterator = new DirectoryIterator(__DIR__ . '/../libs/plugins'); -foreach ($iterator as $file) { - if (!$file->isDot() && 'php' == $file->getExtension()) { - $filename = $file->getBasename(); - $plugins[ $filename ] = true; - } -} -$code = file_get_contents(__DIR__ . '/../libs/sysplugins/smarty_internal_testinstall.php'); -$expectedPlugins = '$expectedPlugins = ' . var_export($plugins, true); -$code = preg_replace('#\$expectedPlugins =[^;]+#', $expectedPlugins, $code); -$expectedSysplugins = '$expectedSysplugins = ' . var_export($sysplugins, true); -$code = preg_replace('#\$expectedSysplugins =[^;]+#', $expectedSysplugins, $code); -file_put_contents(__DIR__ . '/../libs/sysplugins/smarty_internal_testinstall.php', $code);