mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04:26 +02:00
WIP converting code to PSR-4
This commit is contained in:
@@ -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
|
||||
|
@@ -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**
|
||||
>
|
||||
|
@@ -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.
|
||||
|
||||
|
||||
<?php
|
||||
include('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
|
||||
// create template object
|
||||
$tpl = $smarty->createTemplate('index.tpl');
|
||||
|
||||
// get tags
|
||||
$tags = $smarty->getTags($tpl);
|
||||
|
||||
print_r($tags);
|
||||
|
||||
?>
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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.
|
@@ -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.
|
||||
|
||||
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
|
@@ -67,13 +67,6 @@ class Smarty_Internal_Templatelexer
|
||||
*/
|
||||
public $taglineno;
|
||||
|
||||
/**
|
||||
* php code type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $phpType = '';
|
||||
|
||||
/**
|
||||
* state number
|
||||
*
|
||||
|
@@ -60,14 +60,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;
|
||||
|
||||
@@ -129,14 +129,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();
|
||||
|
||||
@@ -153,7 +153,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Method GetTags
|
||||
*
|
||||
* Smarty::getTags() method
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Method_GetTags
|
||||
{
|
||||
/**
|
||||
* Valid for Smarty and template object
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $objMap = 3;
|
||||
|
||||
/**
|
||||
* Return array of tag/attributes of all tags used by an template
|
||||
*
|
||||
* @api Smarty::getTags()
|
||||
* @link https://www.smarty.net/docs/en/api.get.tags.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param null|string|Smarty_Internal_Template $template
|
||||
*
|
||||
* @return array of tag/attributes
|
||||
* @throws \Exception
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function getTags(Smarty_Internal_TemplateBase $obj, $template = null)
|
||||
{
|
||||
/* @var Smarty $smarty */
|
||||
$smarty = $obj->_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');
|
||||
}
|
||||
}
|
@@ -1,605 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal TestInstall
|
||||
* Test Smarty installation
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Utilities
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* TestInstall class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Utilities
|
||||
*/
|
||||
class Smarty_Internal_TestInstall
|
||||
{
|
||||
/**
|
||||
* diagnose Smarty setup
|
||||
* If $errors is secified, the diagnostic report will be appended to the array, rather than being output.
|
||||
*
|
||||
* @param \Smarty $smarty
|
||||
* @param array $errors array to push results into rather than outputting them
|
||||
*
|
||||
* @return bool status, true if everything is fine, false else
|
||||
*/
|
||||
public static function testInstall(Smarty $smarty, &$errors = null)
|
||||
{
|
||||
$status = true;
|
||||
if ($errors === null) {
|
||||
echo "<PRE>\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 "</PRE>\n";
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
}
|
@@ -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}'");
|
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Append
|
||||
* Compiles the {append} tag
|
||||
@@ -14,7 +17,7 @@
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign
|
||||
class Append extends Assign
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {append} tag
|
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\CompileBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Assign
|
||||
* Compiles the {assign} tag
|
||||
@@ -14,7 +19,7 @@
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
||||
class Assign extends CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
@@ -47,7 +52,7 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// the following must be assigned at runtime because it will be overwritten in Smarty_Internal_Compile_Append
|
||||
// the following must be assigned at runtime because it will be overwritten in Append
|
||||
$this->required_attributes = array('var', 'value');
|
||||
$this->shorttag_order = array('var', 'value');
|
||||
$this->optional_attributes = array('scope');
|
@@ -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 = "<?php\n";
|
||||
$output .= $compiler->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;
|
@@ -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,
|
||||
'<?php $_smarty_tpl->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',
|
@@ -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 {
|
@@ -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}%%*/<?php ";
|
||||
$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 .= "\\\$_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
|
||||
)
|
@@ -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 = "<?php {$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]};?>\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 '<?php } else { ?>';
|
||||
}
|
||||
@@ -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 = "<?php {$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]};?>\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 .= '}';
|
@@ -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('<?php ' . $_vars_nc . "?>\n", true), 6, -3);
|
||||
}
|
@@ -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' ])) {
|
@@ -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 =
|
||||
"<?php {$mod_content}\$_block_repeat=false;\n{$mod_pre}echo {$callback}({$_params}, {$mod_content2}, \$_smarty_tpl, \$_block_repeat);\n{$mod_post}}\n";
|
||||
$output .= 'array_pop($_smarty_tpl->smarty->_cache[\'_tag_stack\']);?>';
|
||||
$output .= '?>';
|
||||
}
|
||||
return $output;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user