mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 09:54:27 +02:00
More PSR4 rewriting
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
*
|
||||
* @package Example-application
|
||||
*/
|
||||
require '../libs/Smarty.class.php';
|
||||
$smarty = new Smarty;
|
||||
|
||||
$smarty = new \Smarty\Smarty;
|
||||
//$smarty->force_compile = true;
|
||||
$smarty->debugging = true;
|
||||
$smarty->caching = true;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* @package CacheResource-examples
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
|
||||
class Smarty_CacheResource_Apc extends \Smarty\Cacheresource\KeyValueStore
|
||||
{
|
||||
/**
|
||||
* Smarty_CacheResource_Apc constructor.
|
||||
|
@@ -10,7 +10,7 @@
|
||||
* @package CacheResource-examples
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
||||
class Smarty_CacheResource_Memcache extends \Smarty\Cacheresource\KeyValueStore
|
||||
{
|
||||
/**
|
||||
* memcache instance
|
||||
|
@@ -22,7 +22,7 @@
|
||||
* @package CacheResource-examples
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
||||
class Smarty_CacheResource_Mysql extends \Smarty\Cacheresource\Custom
|
||||
{
|
||||
/**
|
||||
* @var \PDO
|
||||
|
@@ -22,12 +22,11 @@
|
||||
* Example usage :
|
||||
* $cnx = new PDO("mysql:host=localhost;dbname=mydb", "username", "password");
|
||||
* $smarty->setCachingType('pdo');
|
||||
* $smarty->loadPlugin('Smarty_CacheResource_Pdo');
|
||||
* $smarty->registerCacheResource('pdo', new Smarty_CacheResource_Pdo($cnx, 'smarty_cache'));
|
||||
*
|
||||
* @author Beno!t POLASZEK - 2014
|
||||
*/
|
||||
class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
||||
class Smarty_CacheResource_Pdo extends \Smarty\Cacheresource\Custom
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
@@ -322,7 +321,7 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
||||
$where[] = 'compile_id = ' . $this->pdo->quote($compile_id);
|
||||
}
|
||||
// for clearing expired caches
|
||||
if ($exp_time === Smarty::CLEAR_EXPIRED) {
|
||||
if ($exp_time === \Smarty\Smarty::CLEAR_EXPIRED) {
|
||||
$where[] = 'expire < CURRENT_TIMESTAMP';
|
||||
} // range test expiration time
|
||||
elseif ($exp_time !== null) {
|
||||
|
@@ -6,7 +6,6 @@ require_once 'cacheresource.pdo.php';
|
||||
* Example usage :
|
||||
* $cnx = new PDO("mysql:host=localhost;dbname=mydb", "username", "password");
|
||||
* $smarty->setCachingType('pdo_gzip');
|
||||
* $smarty->loadPlugin('Smarty_CacheResource_Pdo_Gzip');
|
||||
* $smarty->registerCacheResource('pdo_gzip', new Smarty_CacheResource_Pdo_Gzip($cnx, 'smarty_cache'));
|
||||
*
|
||||
* @require Smarty_CacheResource_Pdo class
|
||||
|
@@ -22,8 +22,8 @@ string
|
||||
compile\_id
|
||||
|
||||
- This only works if [`$caching`](#variable.caching) is set to one of
|
||||
`Smarty::CACHING_LIFETIME_CURRENT` or
|
||||
`Smarty::CACHING_LIFETIME_SAVED` to enable caching. See the [caching
|
||||
`\Smarty\Smarty::CACHING_LIFETIME_CURRENT` or
|
||||
`\Smarty\Smarty::CACHING_LIFETIME_SAVED` to enable caching. See the [caching
|
||||
section](#caching) for more info.
|
||||
|
||||
- You can also pass a `$cache_id` as an optional second parameter in
|
||||
|
@@ -15,7 +15,7 @@ handler merely inspects `$errno` and `$errfile` to determine if the
|
||||
given error was produced deliberately and must be ignored, or should be
|
||||
passed on to the next error handler.
|
||||
|
||||
`Smarty::unmuteExpectedErrors()` removes the current error handler.
|
||||
`\Smarty\Smarty::unmuteExpectedErrors()` removes the current error handler.
|
||||
Please note, that if you\'ve registered any custom error handlers after
|
||||
the muteExpectedErrors() call, the unmute will not remove Smarty\'s
|
||||
muting error handler, but the one registered last.
|
||||
|
@@ -5,8 +5,8 @@ This is the length of time in seconds that a template cache is valid.
|
||||
Once this time has expired, the cache will be regenerated.
|
||||
|
||||
- `$caching` must be turned on (either
|
||||
Smarty::CACHING\_LIFETIME\_CURRENT or
|
||||
Smarty::CACHING\_LIFETIME\_SAVED) for `$cache_lifetime` to have any
|
||||
\Smarty\Smarty::CACHING\_LIFETIME\_CURRENT or
|
||||
\Smarty\Smarty::CACHING\_LIFETIME\_SAVED) for `$cache_lifetime` to have any
|
||||
purpose.
|
||||
|
||||
- A `$cache_lifetime` value of -1 will force the cache to never
|
||||
@@ -14,11 +14,11 @@ Once this time has expired, the cache will be regenerated.
|
||||
|
||||
- A value of 0 will cause the cache to always regenerate (good for
|
||||
testing only, to disable caching a more efficient method is to set
|
||||
[`$caching`](#variable.caching) = Smarty::CACHING\_OFF).
|
||||
[`$caching`](#variable.caching) = \Smarty\Smarty::CACHING\_OFF).
|
||||
|
||||
- If you want to give certain templates their own cache lifetime, you
|
||||
could do this by setting [`$caching`](#variable.caching) =
|
||||
Smarty::CACHING\_LIFETIME\_SAVED, then set `$cache_lifetime` to a
|
||||
\Smarty\Smarty::CACHING\_LIFETIME\_SAVED, then set `$cache_lifetime` to a
|
||||
unique value just before calling [`display()`](#api.display) or
|
||||
[`fetch()`](#api.fetch).
|
||||
|
||||
|
@@ -3,21 +3,21 @@
|
||||
|
||||
This tells Smarty whether or not to cache the output of the templates to
|
||||
the [`$cache_dir`](#variable.cache.dir). By default this is set to the
|
||||
constant Smarty::CACHING\_OFF. If your templates consistently generate
|
||||
constant \Smarty\Smarty::CACHING\_OFF. If your templates consistently generate
|
||||
the same content, it is advisable to turn on `$caching`, as this may
|
||||
result in significant performance gains.
|
||||
|
||||
You can also have [multiple](#caching.multiple.caches) caches for the
|
||||
same template.
|
||||
|
||||
- A constant value of Smarty::CACHING\_LIFETIME\_CURRENT or
|
||||
Smarty::CACHING\_LIFETIME\_SAVED enables caching.
|
||||
- A constant value of \Smarty\Smarty::CACHING\_LIFETIME\_CURRENT or
|
||||
\Smarty\Smarty ::CACHING\_LIFETIME\_SAVED enables caching.
|
||||
|
||||
- A value of Smarty::CACHING\_LIFETIME\_CURRENT tells Smarty to use
|
||||
- A value of \Smarty\Smarty::CACHING\_LIFETIME\_CURRENT tells Smarty to use
|
||||
the current [`$cache_lifetime`](#variable.cache.lifetime) variable
|
||||
to determine if the cache has expired.
|
||||
|
||||
- A value of Smarty::CACHING\_LIFETIME\_SAVED tells Smarty to use the
|
||||
- A value of \Smarty\Smarty::CACHING\_LIFETIME\_SAVED tells Smarty to use the
|
||||
[`$cache_lifetime`](#variable.cache.lifetime) value at the time the
|
||||
cache was generated. This way you can set the
|
||||
[`$cache_lifetime`](#variable.cache.lifetime) just before
|
||||
|
@@ -18,7 +18,7 @@ enabled, then the cache files will get regenerated if an involved
|
||||
template file or config file was updated.
|
||||
|
||||
As of Smarty 3.1 `$compile_check` can be set to the value
|
||||
`Smarty::COMPILECHECK_CACHEMISS`. This enables Smarty to revalidate the
|
||||
`\Smarty\Smarty::COMPILECHECK_CACHEMISS`. This enables Smarty to revalidate the
|
||||
compiled template, once a cache file is regenerated. So if there was a
|
||||
cached template, but it\'s expired, Smarty will run a single
|
||||
compile\_check before regenerating the cache.
|
||||
|
@@ -7,7 +7,7 @@ When this value is set to a non-null-value it\'s value is used as php\'s
|
||||
|
||||
Smarty 3.1.2 introduced the
|
||||
[`muteExpectedErrors()`](#api.mute.expected.errors) function. Calling
|
||||
`Smarty::muteExpectedErrors();` after setting up custom error handling
|
||||
`\Smarty\Smarty::muteExpectedErrors();` after setting up custom error handling
|
||||
will ensure that warnings and notices (deliberately) produced by Smarty
|
||||
will not be passed to other custom error handlers. If your error logs
|
||||
are filling up with warnings regarding `filemtime()` or `unlink()`
|
||||
|
@@ -17,11 +17,11 @@ faster storage engine, centralize the cache to be accessible to multiple
|
||||
servers.
|
||||
|
||||
Smarty allows CacheResource implementations to use one of the APIs
|
||||
`Smarty_CacheResource_Custom` or `Smarty_CacheResource_KeyValueStore`.
|
||||
`Smarty_CacheResource_Custom` is a simple API directing all read, write,
|
||||
`\Smarty\Cacheresource\Custom` or `\Smarty\Cacheresource\KeyValueStore`.
|
||||
`\Smarty\Cacheresource\Custom` is a simple API directing all read, write,
|
||||
clear calls to your implementation. This API allows you to store
|
||||
wherever and however you deem fit. The
|
||||
`Smarty_CacheResource_KeyValueStore` API allows you to turn any \"dumb\"
|
||||
`\Smarty\Cacheresource\KeyValueStore` API allows you to turn any \"dumb\"
|
||||
KeyValue-Store (like APC, Memcache, ...) into a full-featured
|
||||
CacheResource implementation. That is, everything around deep
|
||||
cache-groups like \"a\|b\|c\" is being handled for you in way that
|
||||
@@ -66,7 +66,7 @@ to invoke your custom CacheResource implementation.
|
||||
* @package CacheResource-examples
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
||||
class Smarty_CacheResource_Mysql extends \Smarty\Cacheresource\Custom {
|
||||
// PDO instance
|
||||
protected $db;
|
||||
protected $fetch;
|
||||
@@ -214,7 +214,7 @@ to invoke your custom CacheResource implementation.
|
||||
* @package CacheResource-examples
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
|
||||
class Smarty_CacheResource_Memcache extends \Smarty\Cacheresource\KeyValueStore {
|
||||
/**
|
||||
* memcache instance
|
||||
* @var Memcache
|
||||
|
@@ -3,7 +3,7 @@ Setting Up Caching {#caching.setting.up}
|
||||
|
||||
The first thing to do is enable caching by setting
|
||||
[`$caching`](#variable.caching) to one of
|
||||
`Smarty::CACHING_LIFETIME_CURRENT` or `Smarty::CACHING_LIFETIME_SAVED`.
|
||||
`\Smarty\Smarty::CACHING_LIFETIME_CURRENT` or `Smarty::CACHING_LIFETIME_SAVED`.
|
||||
|
||||
|
||||
<?php
|
||||
@@ -36,7 +36,7 @@ Each cached page has a limited lifetime determined by
|
||||
seconds, or one hour. After that time expires, the cache is regenerated.
|
||||
It is possible to give individual caches their own expiration time by
|
||||
setting [`$caching`](#variable.caching) to
|
||||
`Smarty::CACHING_LIFETIME_SAVED`. See
|
||||
`\Smarty\Smarty::CACHING_LIFETIME_SAVED`. See
|
||||
[`$cache_lifetime`](#variable.cache.lifetime) for more details.
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ however this also seriously degrades performance.
|
||||
[`$force_compile`](#variable.force.compile) is meant to be used for
|
||||
[debugging](#chapter.debugging.console) purposes. The appropriate way to
|
||||
disable caching is to set [`$caching`](#variable.caching) to
|
||||
Smarty::CACHING\_OFF.
|
||||
\Smarty\Smarty::CACHING\_OFF.
|
||||
|
||||
The [`isCached()`](#api.is.cached) function can be used to test if a
|
||||
template has a valid cache or not. If you have a cached template that
|
||||
|
@@ -5,7 +5,7 @@ Charset Encoding {#charset.encoding}
|
||||
================
|
||||
|
||||
There are a variety of encodings for textual data, ISO-8859-1 (Latin1)
|
||||
and UTF-8 being the most popular. Unless you change `Smarty::$_CHARSET`,
|
||||
and UTF-8 being the most popular. Unless you change `\Smarty\Smarty::$_CHARSET`,
|
||||
Smarty recognizes `UTF-8` as the internal charset if
|
||||
[Multibyte String](https://www.php.net/mbstring) is available,
|
||||
`ISO-8859-1` if not.
|
||||
|
@@ -9,22 +9,6 @@ functions.
|
||||
For the plugins that are registered at runtime, the name of the plugin
|
||||
function(s) does not have to follow the naming convention.
|
||||
|
||||
If a plugin depends on some functionality provided by another plugin (as
|
||||
is the case with some plugins bundled with Smarty), then the proper way
|
||||
to load the needed plugin is this:
|
||||
|
||||
|
||||
<?php
|
||||
function smarty_function_yourPlugin(array $params, Smarty_Internal_Template $template)
|
||||
{
|
||||
// load plugin depended upon
|
||||
$template->smarty->loadPlugin('smarty_shared_make_timestamp');
|
||||
// plugin code
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
As a general rule, the currently evaluated template\'s
|
||||
Smarty\_Internal\_Template object is always passed to the plugins as the
|
||||
last parameter with two exceptions:
|
||||
|
@@ -37,16 +37,6 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
|
||||
if (is_null($content)) {
|
||||
return;
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_modifier_mb_wordwrap',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
$style = null;
|
||||
$indent = 0;
|
||||
$indent_first = 0;
|
||||
@@ -88,8 +78,8 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
|
||||
$_paragraph =
|
||||
preg_replace(
|
||||
array(
|
||||
'!\s+!' . Smarty::$_UTF8_MODIFIER,
|
||||
'!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER
|
||||
'!\s+!' . \Smarty::$_UTF8_MODIFIER,
|
||||
'!(^\s+)|(\s+$)!' . \Smarty::$_UTF8_MODIFIER
|
||||
),
|
||||
array(
|
||||
' ',
|
||||
@@ -102,7 +92,7 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
|
||||
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
|
||||
}
|
||||
// wordwrap sentences
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
$_paragraph = smarty_modifier_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
} else {
|
||||
$_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
|
@@ -56,7 +56,7 @@ function smarty_function_fetch($params, $template)
|
||||
$host = $server_name = $uri_parts[ 'host' ];
|
||||
$timeout = 30;
|
||||
$accept = 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
|
||||
$agent = 'Smarty Template Engine ' . Smarty::SMARTY_VERSION;
|
||||
$agent = 'Smarty Template Engine ' . \Smarty\Smarty::SMARTY_VERSION;
|
||||
$referer = '';
|
||||
$uri = !empty($uri_parts[ 'path' ]) ? $uri_parts[ 'path' ] : '/';
|
||||
$uri .= !empty($uri_parts[ 'query' ]) ? '?' . $uri_parts[ 'query' ] : '';
|
||||
|
@@ -44,14 +44,6 @@
|
||||
*/
|
||||
function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$name = 'checkbox';
|
||||
$values = null;
|
||||
$options = null;
|
||||
@@ -251,7 +243,7 @@ function smarty_function_html_checkboxes_output(
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(
|
||||
preg_replace(
|
||||
'![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER,
|
||||
'![^\w\-\.]!' . \Smarty\Smarty::$_UTF8_MODIFIER,
|
||||
'_',
|
||||
$name . '_' . $value
|
||||
)
|
||||
|
@@ -36,14 +36,6 @@
|
||||
*/
|
||||
function smarty_function_html_image($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$alt = '';
|
||||
$file = '';
|
||||
$height = '';
|
||||
|
@@ -36,14 +36,6 @@
|
||||
*/
|
||||
function smarty_function_html_options($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$name = null;
|
||||
$values = null;
|
||||
$options = null;
|
||||
|
@@ -44,14 +44,6 @@
|
||||
*/
|
||||
function smarty_function_html_radios($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$name = 'radio';
|
||||
$values = null;
|
||||
$options = null;
|
||||
@@ -235,7 +227,7 @@ function smarty_function_html_radios_output(
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(
|
||||
preg_replace(
|
||||
'![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER,
|
||||
'![^\w\-\.]!' . \Smarty\Smarty::$_UTF8_MODIFIER,
|
||||
'_',
|
||||
$name . '_' . $value
|
||||
)
|
||||
|
@@ -44,14 +44,6 @@
|
||||
*/
|
||||
function smarty_function_html_select_date($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
// generate timestamps used for month names only
|
||||
static $_month_timestamps = null;
|
||||
static $_current_year = null;
|
||||
@@ -210,14 +202,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
[$_year, $_month, $_day] = explode('-', date('Y-m-d'));
|
||||
}
|
||||
} else {
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_make_timestamp',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$time = smarty_make_timestamp($time);
|
||||
[$_year, $_month, $_day] = explode('-', date('Y-m-d', $time));
|
||||
}
|
||||
|
@@ -26,14 +26,6 @@
|
||||
*/
|
||||
function smarty_function_html_select_time($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$prefix = 'Time_';
|
||||
$field_array = null;
|
||||
$field_separator = "\n";
|
||||
@@ -76,14 +68,6 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
switch ($_key) {
|
||||
case 'time':
|
||||
if (!is_array($_value) && $_value !== null) {
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_make_timestamp',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$time = smarty_make_timestamp($_value);
|
||||
}
|
||||
break;
|
||||
|
@@ -101,8 +101,8 @@ function smarty_function_mailto($params)
|
||||
return;
|
||||
}
|
||||
|
||||
$string = '<a href="mailto:' . htmlspecialchars($address, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, Smarty::$_CHARSET) .
|
||||
'" ' . $extra . '>' . htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, Smarty::$_CHARSET) . '</a>';
|
||||
$string = '<a href="mailto:' . htmlspecialchars($address, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, \Smarty\Smarty::$_CHARSET) .
|
||||
'" ' . $extra . '>' . htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, \Smarty\Smarty::$_CHARSET) . '</a>';
|
||||
|
||||
if ($encode === 'javascript') {
|
||||
$js_encode = '';
|
||||
@@ -123,7 +123,7 @@ function smarty_function_mailto($params)
|
||||
}
|
||||
$address_encode = '';
|
||||
for ($x = 0, $_length = strlen($address); $x < $_length; $x++) {
|
||||
if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) {
|
||||
if (preg_match('!\w!' . \Smarty\Smarty::$_UTF8_MODIFIER, $address[ $x ])) {
|
||||
$address_encode .= '%' . bin2hex($address[ $x ]);
|
||||
} else {
|
||||
$address_encode .= $address[ $x ];
|
||||
|
@@ -24,14 +24,14 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
{
|
||||
$string = (string) $string;
|
||||
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
if ($lc_rest) {
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET);
|
||||
$upper_string = mb_convert_case($string, MB_CASE_TITLE, \Smarty\Smarty::$_CHARSET);
|
||||
} else {
|
||||
// uppercase word breaks
|
||||
$upper_string = preg_replace_callback(
|
||||
"!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
|
||||
"!(^|[^\p{L}'])([\p{Ll}])!S" . \Smarty\Smarty::$_UTF8_MODIFIER,
|
||||
'smarty_mod_cap_mbconvert_cb',
|
||||
$string
|
||||
);
|
||||
@@ -39,7 +39,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all(
|
||||
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER,
|
||||
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . \Smarty\Smarty::$_UTF8_MODIFIER,
|
||||
$string,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE
|
||||
@@ -49,7 +49,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
$upper_string =
|
||||
substr_replace(
|
||||
$upper_string,
|
||||
mb_strtolower($match[ 0 ], Smarty::$_CHARSET),
|
||||
mb_strtolower($match[ 0 ], \Smarty\Smarty::$_CHARSET),
|
||||
$match[ 1 ],
|
||||
strlen($match[ 0 ])
|
||||
);
|
||||
@@ -58,7 +58,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
}
|
||||
$upper_string =
|
||||
preg_replace_callback(
|
||||
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER,
|
||||
"!((^|\s)['\"])(\w)!" . \Smarty\Smarty::$_UTF8_MODIFIER,
|
||||
'smarty_mod_cap_mbconvert2_cb',
|
||||
$upper_string
|
||||
);
|
||||
@@ -71,14 +71,14 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string =
|
||||
preg_replace_callback(
|
||||
"!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
|
||||
"!(^|[^\p{L}'])([\p{Ll}])!S" . \Smarty\Smarty::$_UTF8_MODIFIER,
|
||||
'smarty_mod_cap_ucfirst_cb',
|
||||
$string
|
||||
);
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all(
|
||||
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER,
|
||||
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . \Smarty\Smarty::$_UTF8_MODIFIER,
|
||||
$string,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE
|
||||
@@ -91,7 +91,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
}
|
||||
}
|
||||
$upper_string = preg_replace_callback(
|
||||
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER,
|
||||
"!((^|\s)['\"])(\w)!" . \Smarty\Smarty::$_UTF8_MODIFIER,
|
||||
'smarty_mod_cap_ucfirst2_cb',
|
||||
$upper_string
|
||||
);
|
||||
@@ -113,7 +113,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
*/
|
||||
function smarty_mod_cap_mbconvert_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, Smarty::$_CHARSET);
|
||||
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, \Smarty\Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ function smarty_mod_cap_mbconvert_cb($matches)
|
||||
*/
|
||||
function smarty_mod_cap_mbconvert2_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, Smarty::$_CHARSET);
|
||||
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, \Smarty\Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -29,18 +29,9 @@
|
||||
function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto')
|
||||
{
|
||||
if ($format === null) {
|
||||
$format = Smarty::$_DATE_FORMAT;
|
||||
}
|
||||
/**
|
||||
* require_once the {@link shared.make_timestamp.php} plugin
|
||||
*/
|
||||
static $is_loaded = false;
|
||||
if (!$is_loaded) {
|
||||
if (!is_callable('smarty_make_timestamp')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
|
||||
}
|
||||
$is_loaded = true;
|
||||
$format = \Smarty\Smarty::$_DATE_FORMAT;
|
||||
}
|
||||
|
||||
if (!empty($string) && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') {
|
||||
$timestamp = smarty_make_timestamp($string);
|
||||
} elseif (!empty($default_date)) {
|
||||
@@ -49,7 +40,7 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
||||
return;
|
||||
}
|
||||
if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) {
|
||||
if (Smarty::$_IS_WINDOWS) {
|
||||
if (\Smarty\Smarty::$_IS_WINDOWS) {
|
||||
$_win_from = array(
|
||||
'%D',
|
||||
'%h',
|
||||
|
@@ -74,30 +74,30 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
|
||||
break;
|
||||
case 'string':
|
||||
$results = strtr($var, $_replace);
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
|
||||
$results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($var, \Smarty\Smarty::$_CHARSET) > $length) {
|
||||
$results = mb_substr($var, 0, $length - 3, \Smarty\Smarty::$_CHARSET) . '...';
|
||||
}
|
||||
} else {
|
||||
if (isset($var[ $length ])) {
|
||||
$results = substr($var, 0, $length - 3) . '...';
|
||||
}
|
||||
}
|
||||
$results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET);
|
||||
$results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, \Smarty\Smarty::$_CHARSET);
|
||||
break;
|
||||
case 'unknown type':
|
||||
default:
|
||||
$results = strtr((string)$var, $_replace);
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
|
||||
$results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($results, \Smarty\Smarty::$_CHARSET) > $length) {
|
||||
$results = mb_substr($results, 0, $length - 3, \Smarty\Smarty::$_CHARSET) . '...';
|
||||
}
|
||||
} else {
|
||||
if (strlen($results) > $length) {
|
||||
$results = substr($results, 0, $length - 3) . '...';
|
||||
}
|
||||
}
|
||||
$results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET);
|
||||
$results = htmlspecialchars($results, ENT_QUOTES, \Smarty\Smarty::$_CHARSET);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
@@ -23,10 +23,8 @@
|
||||
*/
|
||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||
{
|
||||
static $is_loaded_1 = false;
|
||||
static $is_loaded_2 = false;
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
$char_set = \Smarty\Smarty::$_CHARSET;
|
||||
}
|
||||
|
||||
$string = (string)$string;
|
||||
@@ -36,7 +34,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
// no break
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
$string = mb_convert_encoding($string, 'UTF-8', $char_set);
|
||||
return htmlentities($string, ENT_QUOTES, 'UTF-8', $double_encode);
|
||||
}
|
||||
@@ -61,15 +59,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
return $return;
|
||||
case 'hexentity':
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded_1) {
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
|
||||
}
|
||||
$is_loaded_1 = true;
|
||||
}
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
|
||||
}
|
||||
return $return;
|
||||
@@ -82,15 +74,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
return $return;
|
||||
case 'decentity':
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded_1) {
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
|
||||
}
|
||||
$is_loaded_1 = true;
|
||||
}
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
}
|
||||
return $return;
|
||||
@@ -119,13 +105,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
)
|
||||
);
|
||||
case 'mail':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded_2) {
|
||||
if (!is_callable('smarty_mb_str_replace')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
|
||||
}
|
||||
$is_loaded_2 = true;
|
||||
}
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
return smarty_mb_str_replace(
|
||||
array(
|
||||
'@',
|
||||
@@ -153,14 +133,8 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
case 'nonstd':
|
||||
// escape non-standard chars, such as ms document quotes
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded_1) {
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
|
||||
}
|
||||
$is_loaded_1 = true;
|
||||
}
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) {
|
||||
if ($unicode >= 126) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
} else {
|
||||
|
@@ -24,18 +24,18 @@
|
||||
function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = false)
|
||||
{
|
||||
// break words into tokens using white space as a delimiter
|
||||
$tokens = preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
$tokens = preg_split('!(\s)!S' . \Smarty\Smarty::$_UTF8_MODIFIER, $str, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
$length = 0;
|
||||
$t = '';
|
||||
$_previous = false;
|
||||
$_space = false;
|
||||
foreach ($tokens as $_token) {
|
||||
$token_length = mb_strlen($_token, Smarty::$_CHARSET);
|
||||
$token_length = mb_strlen($_token, \Smarty\Smarty::$_CHARSET);
|
||||
$_tokens = array($_token);
|
||||
if ($token_length > $width) {
|
||||
if ($cut) {
|
||||
$_tokens = preg_split(
|
||||
'!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER,
|
||||
'!(.{' . $width . '})!S' . \Smarty\Smarty::$_UTF8_MODIFIER,
|
||||
$_token,
|
||||
-1,
|
||||
PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE
|
||||
@@ -43,13 +43,13 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
|
||||
}
|
||||
}
|
||||
foreach ($_tokens as $token) {
|
||||
$_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token);
|
||||
$token_length = mb_strlen($token, Smarty::$_CHARSET);
|
||||
$_space = !!preg_match('!^\s$!S' . \Smarty\Smarty::$_UTF8_MODIFIER, $token);
|
||||
$token_length = mb_strlen($token, \Smarty\Smarty::$_CHARSET);
|
||||
$length += $token_length;
|
||||
if ($length > $width) {
|
||||
// remove space before inserted break
|
||||
if ($_previous) {
|
||||
$t = mb_substr($t, 0, -1, Smarty::$_CHARSET);
|
||||
$t = mb_substr($t, 0, -1, \Smarty\Smarty::$_CHARSET);
|
||||
}
|
||||
if (!$_space) {
|
||||
// add the break before the token
|
||||
|
@@ -23,14 +23,7 @@
|
||||
*/
|
||||
function smarty_modifier_replace($string, $search, $replace)
|
||||
{
|
||||
static $is_loaded = false;
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded) {
|
||||
if (!is_callable('smarty_mb_str_replace')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
|
||||
}
|
||||
$is_loaded = true;
|
||||
}
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
return smarty_mb_str_replace($search, $replace, $string);
|
||||
}
|
||||
return str_replace($search, $replace, $string);
|
||||
|
@@ -22,5 +22,5 @@
|
||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||
{
|
||||
// well… what about charsets besides latin and UTF-8?
|
||||
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||
return implode($spacify_char, preg_split('//' . \Smarty\Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||
}
|
||||
|
@@ -29,21 +29,21 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
||||
if ($length === 0) {
|
||||
return '';
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
|
||||
$length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($string, \Smarty\Smarty::$_CHARSET) > $length) {
|
||||
$length -= min($length, mb_strlen($etc, \Smarty\Smarty::$_CHARSET));
|
||||
if (!$break_words && !$middle) {
|
||||
$string = preg_replace(
|
||||
'/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER,
|
||||
'/\s+?(\S+)?$/' . \Smarty\Smarty::$_UTF8_MODIFIER,
|
||||
'',
|
||||
mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)
|
||||
mb_substr($string, 0, $length + 1, \Smarty\Smarty::$_CHARSET)
|
||||
);
|
||||
}
|
||||
if (!$middle) {
|
||||
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
||||
return mb_substr($string, 0, $length, \Smarty\Smarty::$_CHARSET) . $etc;
|
||||
}
|
||||
return mb_substr($string, 0, intval($length / 2), Smarty::$_CHARSET) . $etc .
|
||||
mb_substr($string, -intval($length / 2), $length, Smarty::$_CHARSET);
|
||||
return mb_substr($string, 0, intval($length / 2), \Smarty\Smarty::$_CHARSET) . $etc .
|
||||
mb_substr($string, -intval($length / 2), $length, \Smarty\Smarty::$_CHARSET);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
@@ -22,10 +22,10 @@
|
||||
function smarty_modifiercompiler_count_characters($params)
|
||||
{
|
||||
if (!isset($params[ 1 ]) || $params[ 1 ] !== 'true') {
|
||||
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)';
|
||||
return 'preg_match_all(\'/[^\s]/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)';
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strlen(' . $params[ 0 ] . ')';
|
||||
|
@@ -22,5 +22,5 @@
|
||||
function smarty_modifiercompiler_count_sentences($params)
|
||||
{
|
||||
// find periods, question marks, exclamation marks with a word before but not after.
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)';
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . \Smarty\Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)';
|
||||
}
|
||||
|
@@ -20,10 +20,9 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_count_words($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' .
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\', ' .
|
||||
$params[ 0 ] . ', $tmp)';
|
||||
}
|
||||
// no MBString fallback
|
||||
|
@@ -22,20 +22,12 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$compiler->template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_literal_compiler_param',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
try {
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||
$char_set = smarty_literal_compiler_param($params, 2, \Smarty\Smarty::$_CHARSET);
|
||||
$double_encode = smarty_literal_compiler_param($params, 3, true);
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
$char_set = \Smarty\Smarty::$_CHARSET;
|
||||
}
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
@@ -43,7 +35,7 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
||||
var_export($double_encode, true) . ')';
|
||||
// no break
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
return 'htmlentities(mb_convert_encoding((string)' . $params[ 0 ] . ', \'UTF-8\', ' .
|
||||
var_export($char_set, true) . '), ENT_QUOTES, \'UTF-8\', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
@@ -69,17 +61,5 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
||||
} catch (SmartyException $e) {
|
||||
// pass through to regular plugin fallback
|
||||
}
|
||||
// could not optimize |escape call, so fallback to regular plugin
|
||||
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
|
||||
$compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'file' ] =
|
||||
SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'function' ] =
|
||||
'smarty_modifier_escape';
|
||||
} else {
|
||||
$compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'file' ] =
|
||||
SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'function' ] =
|
||||
'smarty_modifier_escape';
|
||||
}
|
||||
return 'smarty_modifier_escape(' . join(', ', $params) . ')';
|
||||
}
|
||||
|
@@ -19,12 +19,12 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_from_charset($params)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
if (!\Smarty\Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[ 0 ];
|
||||
}
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = '"ISO-8859-1"';
|
||||
}
|
||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')';
|
||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(\Smarty\Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')';
|
||||
}
|
||||
|
@@ -21,8 +21,8 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_lower($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtolower(' . $params[ 0 ] . ')';
|
||||
|
@@ -26,5 +26,5 @@ function smarty_modifiercompiler_strip($params)
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = "' '";
|
||||
}
|
||||
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||
return "preg_replace('!\s+!" . \Smarty\Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||
}
|
||||
|
@@ -19,12 +19,12 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_to_charset($params)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
if (!\Smarty\Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[ 0 ];
|
||||
}
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = '"ISO-8859-1"';
|
||||
}
|
||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
|
||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(\Smarty\Smarty::$_CHARSET) . '")';
|
||||
}
|
||||
|
@@ -20,25 +20,16 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$compiler->template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_literal_compiler_param',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
|
||||
if (!isset($params[ 2 ])) {
|
||||
$params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
$params[ 2 ] = '\'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\'';
|
||||
}
|
||||
|
||||
switch ($esc_type) {
|
||||
case 'entity':
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
return 'html_entity_decode(mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'UTF-8\'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
|
||||
}
|
||||
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
|
||||
|
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_upper($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtoupper(' . $params[ 0 ] . ' ?? \'\')';
|
||||
|
@@ -32,7 +32,7 @@ function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompi
|
||||
$params[ 3 ] = 'false';
|
||||
}
|
||||
$function = 'wordwrap';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (\Smarty\Smarty::$_MBSTRING) {
|
||||
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
|
||||
}
|
||||
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
|
||||
|
@@ -20,7 +20,7 @@
|
||||
function smarty_function_escape_special_chars($string)
|
||||
{
|
||||
if (!is_array($string)) {
|
||||
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
|
||||
$string = htmlspecialchars($string, ENT_COMPAT, \Smarty\Smarty::$_CHARSET, false);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
@@ -54,12 +54,12 @@ if (!function_exists('smarty_mb_str_replace')) {
|
||||
|
||||
// See if charset used by Smarty is matching one used by regex...
|
||||
$current_charset = mb_regex_encoding();
|
||||
$convert_result = (bool)strcasecmp(Smarty::$_CHARSET, $current_charset);
|
||||
$convert_result = (bool)strcasecmp(\Smarty\Smarty::$_CHARSET, $current_charset);
|
||||
if($convert_result) {
|
||||
// ...convert to it if not.
|
||||
$subject = mb_convert_encoding($subject, $current_charset, Smarty::$_CHARSET);
|
||||
$search = mb_convert_encoding($search, $current_charset, Smarty::$_CHARSET);
|
||||
$replace = mb_convert_encoding($replace, $current_charset, Smarty::$_CHARSET);
|
||||
$subject = mb_convert_encoding($subject, $current_charset, \Smarty\Smarty::$_CHARSET);
|
||||
$search = mb_convert_encoding($search, $current_charset, \Smarty\Smarty::$_CHARSET);
|
||||
$replace = mb_convert_encoding($replace, $current_charset, \Smarty\Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
$parts = mb_split(preg_quote($search), $subject ?? "") ?: array();
|
||||
@@ -79,7 +79,7 @@ if (!function_exists('smarty_mb_str_replace')) {
|
||||
$subject = implode($replace, $parts);
|
||||
// Convert results back to charset used by Smarty, if needed.
|
||||
if($convert_result) {
|
||||
$subject = mb_convert_encoding($subject, Smarty::$_CHARSET, $current_charset);
|
||||
$subject = mb_convert_encoding($subject, \Smarty\Smarty::$_CHARSET, $current_charset);
|
||||
}
|
||||
}
|
||||
return $subject;
|
||||
|
@@ -15,5 +15,5 @@
|
||||
*/
|
||||
function smarty_variablefilter_htmlspecialchars($source, Smarty_Internal_Template $template)
|
||||
{
|
||||
return htmlspecialchars($source, ENT_QUOTES, Smarty::$_CHARSET);
|
||||
return htmlspecialchars($source, ENT_QUOTES, \Smarty\Smarty::$_CHARSET);
|
||||
}
|
||||
|
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Autoloader
|
||||
*
|
||||
* @package Smarty
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) {
|
||||
include __DIR__ . '/functions.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Autoloader
|
||||
*
|
||||
* @package Smarty
|
||||
* @author Uwe Tews
|
||||
* Usage:
|
||||
* require_once '...path/Autoloader.php';
|
||||
* Smarty_Autoloader::register();
|
||||
* or
|
||||
* include '...path/bootstrap.php';
|
||||
*
|
||||
* $smarty = new Smarty();
|
||||
*/
|
||||
class Smarty_Autoloader
|
||||
{
|
||||
/**
|
||||
* Filepath to Smarty root
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $SMARTY_DIR = null;
|
||||
|
||||
/**
|
||||
* Filepath to Smarty internal plugins
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $SMARTY_SYSPLUGINS_DIR = null;
|
||||
|
||||
/**
|
||||
* Array with Smarty core classes and their filename
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $rootClasses = array('smarty' => 'Smarty.class.php');
|
||||
|
||||
/**
|
||||
* Registers Smarty_Autoloader backward compatible to older installations.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not.
|
||||
*/
|
||||
public static function registerBC($prepend = false)
|
||||
{
|
||||
/**
|
||||
* register the class autoloader
|
||||
*/
|
||||
if (!defined('SMARTY_SPL_AUTOLOAD')) {
|
||||
define('SMARTY_SPL_AUTOLOAD', 0);
|
||||
}
|
||||
if (SMARTY_SPL_AUTOLOAD
|
||||
&& set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
|
||||
) {
|
||||
$registeredAutoLoadFunctions = spl_autoload_functions();
|
||||
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {
|
||||
spl_autoload_register();
|
||||
}
|
||||
} else {
|
||||
self::register($prepend);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers Smarty_Autoloader as an SPL autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not.
|
||||
*/
|
||||
public static function register($prepend = false)
|
||||
{
|
||||
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : __DIR__ . DIRECTORY_SEPARATOR;
|
||||
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
|
||||
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles auto loading of classes.
|
||||
*
|
||||
* @param string $class A class name.
|
||||
*/
|
||||
public static function autoload($class)
|
||||
{
|
||||
if ($class[ 0 ] !== 'S' || strpos($class, 'Smarty') !== 0) {
|
||||
return;
|
||||
}
|
||||
$_class = smarty_strtolower_ascii($class);
|
||||
if (isset(self::$rootClasses[ $_class ])) {
|
||||
$file = self::$SMARTY_DIR . self::$rootClasses[ $_class ];
|
||||
if (is_file($file)) {
|
||||
include $file;
|
||||
}
|
||||
} else {
|
||||
$file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
|
||||
if (is_file($file)) {
|
||||
include $file;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty;
|
||||
|
||||
/**
|
||||
* Smarty {block} tag class
|
||||
*
|
||||
@@ -7,7 +9,7 @@
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Block
|
||||
class Block
|
||||
{
|
||||
/**
|
||||
* Block name
|
||||
@@ -47,14 +49,14 @@ class Smarty_Internal_Block
|
||||
/**
|
||||
* Inheritance child block
|
||||
*
|
||||
* @var Smarty_Internal_Block|null
|
||||
* @var Block|null
|
||||
*/
|
||||
public $child = null;
|
||||
|
||||
/**
|
||||
* Inheritance calling parent block
|
||||
*
|
||||
* @var Smarty_Internal_Block|null
|
||||
* @var Block|null
|
||||
*/
|
||||
public $parent = null;
|
||||
|
||||
@@ -66,7 +68,7 @@ class Smarty_Internal_Block
|
||||
public $tplIndex = 0;
|
||||
|
||||
/**
|
||||
* Smarty_Internal_Block constructor.
|
||||
* Block constructor.
|
||||
* - if outer level {block} of child template ($state === 1) save it as child root block
|
||||
* - otherwise process inheritance and render
|
||||
*
|
||||
@@ -84,7 +86,7 @@ class Smarty_Internal_Block
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
*/
|
||||
public function callBlock(Smarty_Internal_Template $tpl)
|
||||
public function callBlock(\Smarty_Internal_Template $tpl)
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,4 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Cacheresource;
|
||||
|
||||
use Smarty\Smarty;
|
||||
use Smarty_Internal_Template;
|
||||
use Smarty_Template_Cached;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin
|
||||
*
|
||||
@@ -13,24 +20,24 @@
|
||||
* @subpackage Cacher
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
abstract class Smarty_CacheResource
|
||||
abstract class Base
|
||||
{
|
||||
/**
|
||||
* resource types provided by the core
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $sysplugins = array('file' => 'smarty_internal_cacheresource_file.php',);
|
||||
protected static $sysplugins = array('file' => 'File.php',);
|
||||
|
||||
/**
|
||||
* populate Cached Object with meta data from Resource
|
||||
*
|
||||
* @param \Smarty_Template_Cached $cached cached object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function populate(\Smarty_Template_Cached $cached, Smarty_Internal_Template $_template);
|
||||
abstract public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template);
|
||||
|
||||
/**
|
||||
* populate Cached Object with timestamp and exists from Resource
|
||||
@@ -187,7 +194,7 @@ abstract class Smarty_CacheResource
|
||||
* @param string $type name of the cache resource
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @return Smarty_CacheResource Cache Resource Handler
|
||||
* @return Base Cache Resource Handler
|
||||
*/
|
||||
public static function load(Smarty $smarty, $type = null)
|
||||
{
|
||||
@@ -205,15 +212,11 @@ abstract class Smarty_CacheResource
|
||||
}
|
||||
// try sysplugins dir
|
||||
if (isset(self::$sysplugins[ $type ])) {
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . smarty_ucfirst_ascii($type);
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . \smarty_ucfirst_ascii($type);
|
||||
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)) {
|
||||
$cache_resource_class = 'Smarty_CacheResource_' . \smarty_ucfirst_ascii($type);
|
||||
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\Cacheresource;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin
|
||||
*
|
||||
@@ -6,6 +9,8 @@
|
||||
* @subpackage Cacher
|
||||
*/
|
||||
|
||||
use Smarty\Cacheresource\Base;
|
||||
|
||||
/**
|
||||
* Cache Handler API
|
||||
*
|
||||
@@ -13,7 +18,7 @@
|
||||
* @subpackage Cacher
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
abstract class Custom extends Base
|
||||
{
|
||||
/**
|
||||
* fetch cached content and its modification time from data source
|
||||
@@ -187,8 +192,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
*/
|
||||
public function readCachedContent(Smarty_Internal_Template $_template)
|
||||
{
|
||||
$content = $_template->cached->content ? $_template->cached->content : null;
|
||||
$timestamp = null;
|
||||
$content = $_template->cached->content ?: null;
|
||||
if ($content === null) {
|
||||
$timestamp = null;
|
||||
$this->fetch(
|
||||
@@ -209,12 +213,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
/**
|
||||
* Empty cache
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||
* @param \Smarty\Smarty $smarty Smarty object
|
||||
* @param null $exp_time expiration time (number of seconds, not timestamp)
|
||||
*
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
public function clearAll(Smarty $smarty, $exp_time = null)
|
||||
public function clearAll(\Smarty\Smarty $smarty, $exp_time = null)
|
||||
{
|
||||
return $this->delete(null, null, null, $exp_time);
|
||||
}
|
||||
@@ -222,7 +226,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
/**
|
||||
* Empty cache for a specific template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param \Smarty\Smarty $smarty Smarty object
|
||||
* @param string $resource_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
@@ -231,7 +235,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
* @return int number of cache files deleted
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||
public function clear(\Smarty\Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||
{
|
||||
$cache_name = null;
|
||||
if (isset($resource_name)) {
|
||||
@@ -248,12 +252,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
/**
|
||||
* Check is cache is locked for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param \Smarty\Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return boolean true or false if cache is locked
|
||||
*/
|
||||
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
public function hasLock(\Smarty\Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$id = $cached->lock_id;
|
||||
$name = $cached->source->name . '.lock';
|
||||
@@ -267,12 +271,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
/**
|
||||
* Lock cache for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param \Smarty\Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
public function acquireLock(\Smarty\Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$cached->is_locked = true;
|
||||
$id = $cached->lock_id;
|
||||
@@ -283,12 +287,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
/**
|
||||
* Unlock cache for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param \Smarty\Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
public function releaseLock(\Smarty\Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$cached->is_locked = false;
|
||||
$name = $cached->source->name . '.lock';
|
@@ -1,4 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Cacheresource;
|
||||
|
||||
use Smarty\Smarty;
|
||||
use Smarty_Internal_Template;
|
||||
use Smarty_Template_Cached;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin CacheResource File
|
||||
*
|
||||
@@ -15,7 +22,7 @@
|
||||
* @package Smarty
|
||||
* @subpackage Cacher
|
||||
*/
|
||||
class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
class File extends Base
|
||||
{
|
||||
/**
|
||||
* populate Cached Object with metadata from Resource
|
||||
@@ -88,8 +95,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
/**
|
||||
* Read the cached template and process its header
|
||||
*
|
||||
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||
* @param Smarty_Template_Cached|null $cached cached object
|
||||
* @param bool $update flag if called because cache update
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
@@ -211,7 +218,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
* @return void
|
||||
*/
|
||||
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
@@ -225,7 +232,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
* @return void
|
||||
*/
|
||||
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
@@ -1,4 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Cacheresource;
|
||||
|
||||
use Smarty\Smarty;
|
||||
use Smarty_Internal_Template;
|
||||
use Smarty_Template_Cached;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin
|
||||
*
|
||||
@@ -28,7 +35,7 @@
|
||||
* @subpackage Cacher
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
abstract class KeyValueStore extends Base
|
||||
{
|
||||
/**
|
||||
* cache for contents
|
||||
@@ -88,8 +95,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
/**
|
||||
* Read the cached template and process the header
|
||||
*
|
||||
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||
* @param Smarty_Template_Cached|null $cached cached object
|
||||
* @param boolean $update flag if called because cache update
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
@@ -102,8 +109,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
if (!$cached) {
|
||||
$cached = $_smarty_tpl->cached;
|
||||
}
|
||||
$content = $cached->content ? $cached->content : null;
|
||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||
$content = $cached->content ?: null;
|
||||
$timestamp = $cached->timestamp ?: null;
|
||||
if ($content === null || !$timestamp) {
|
||||
if (!$this->fetch(
|
||||
$_smarty_tpl->cached->filepath,
|
||||
@@ -380,10 +387,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
$compile_id = null,
|
||||
$resource_uid = null
|
||||
) {
|
||||
// abort if there is no CacheID
|
||||
if (false && !$cid) {
|
||||
return 0;
|
||||
}
|
||||
// abort if there are no InvalidationKeys to check
|
||||
if (!($_cid = $this->listInvalidationKeys($cid, $resource_name, $cache_id, $compile_id, $resource_uid))) {
|
||||
return 0;
|
||||
@@ -489,7 +492,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
* @return void
|
||||
*/
|
||||
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
@@ -29,7 +29,7 @@ class Append extends Assign
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compile($args, \Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// the following must be assigned at runtime because it will be overwritten in parent class
|
||||
$this->required_attributes = array('var', 'value');
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\CompileBase;
|
||||
use Smarty\Smarty;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Assign
|
||||
@@ -50,7 +51,7 @@ class Assign extends CompileBase
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compile($args, \Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// the following must be assigned at runtime because it will be overwritten in Append
|
||||
$this->required_attributes = array('var', 'value');
|
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Shared Inheritance
|
||||
* Shared methods for {extends} and {block} tags
|
||||
@@ -14,7 +17,7 @@
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_CompileBase
|
||||
abstract class Inheritance extends \Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compile inheritance initialization code as prefix
|
||||
@@ -22,7 +25,7 @@ class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_Compile
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param bool|false $initChildSequence if true force child template
|
||||
*/
|
||||
public static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||
public static function postCompile(\Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||
{
|
||||
$compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " .
|
||||
var_export($initChildSequence, true) . ");\n?>\n";
|
||||
@@ -34,11 +37,11 @@ class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_Compile
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param bool|false $initChildSequence if true force child template
|
||||
*/
|
||||
public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||
public function registerInit(\Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||
{
|
||||
if ($initChildSequence || !isset($compiler->_cache[ 'inheritanceInit' ])) {
|
||||
$compiler->registerPostCompileCallback(
|
||||
array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
|
||||
array(self::class, 'postCompile'),
|
||||
array($initChildSequence),
|
||||
'inheritanceInit',
|
||||
$initChildSequence
|
@@ -8,6 +8,8 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Inheritance;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Class
|
||||
*
|
||||
@@ -83,7 +85,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
||||
$compiler->template->caching
|
||||
)
|
||||
);
|
||||
$compiler->saveRequiredPlugins(true);
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
$compiler->parser->current_buffer = new \Smarty\ParseTree\Template();
|
||||
$compiler->template->compiled->has_nocache_code = false;
|
||||
@@ -94,7 +95,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
||||
/**
|
||||
* Smarty Internal Plugin Compile BlockClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_Inheritance
|
||||
class Smarty_Internal_Compile_Blockclose extends Inheritance
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/block} tag
|
||||
@@ -107,7 +108,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
list($_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching) = $this->closeTag($compiler, array('block'));
|
||||
[$_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching] = $this->closeTag($compiler, array('block'));
|
||||
// init block parameter
|
||||
$_block = $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ];
|
||||
unset($compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]);
|
||||
@@ -126,14 +127,12 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
||||
$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";
|
||||
$output .= "class {$_className} extends \\Smarty\\Block\n";
|
||||
$output .= "{\n";
|
||||
foreach ($_block as $property => $value) {
|
||||
$output .= "public \${$property} = " . var_export($value, true) . ";\n";
|
||||
}
|
||||
$output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||
$output .= $compiler->compileRequiredPlugins();
|
||||
$compiler->restoreRequiredPlugins();
|
||||
if ($compiler->template->compiled->has_nocache_code) {
|
||||
$output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n";
|
||||
}
|
||||
|
@@ -54,9 +54,9 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
||||
* @var array
|
||||
*/
|
||||
public $valid_scopes = array(
|
||||
'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
||||
'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
|
||||
'smarty' => Smarty::SCOPE_SMARTY, 'global' => Smarty::SCOPE_SMARTY
|
||||
'local' => \Smarty\Smarty::SCOPE_LOCAL, 'parent' => \Smarty\Smarty::SCOPE_PARENT,
|
||||
'root' => \Smarty\Smarty::SCOPE_ROOT, 'tpl_root' => \Smarty\Smarty::SCOPE_TPL_ROOT,
|
||||
'smarty' => \Smarty\Smarty::SCOPE_SMARTY, 'global' => \Smarty\Smarty::SCOPE_SMARTY
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -27,13 +27,14 @@ class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// check and get attributes, may trigger errors
|
||||
$this->getAttributes($compiler, $args);
|
||||
|
||||
// compile always as nocache
|
||||
$compiler->tag_nocache = true;
|
||||
// display debug template
|
||||
$_output =
|
||||
"<?php \$_smarty_debug = new Smarty_Internal_Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
|
||||
"<?php \$_smarty_debug = new \\Smarty\\Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
|
||||
$_output .= "unset(\$_smarty_debug);\n?>";
|
||||
return $_output;
|
||||
}
|
||||
|
@@ -8,13 +8,15 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Inheritance;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile extend Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inheritance
|
||||
class Smarty_Internal_Compile_Extends extends Inheritance
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
|
@@ -72,7 +72,6 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
// Init temporary context
|
||||
$compiler->parser->current_buffer = new \Smarty\ParseTree\Template();
|
||||
$compiler->template->compiled->has_nocache_code = false;
|
||||
$compiler->saveRequiredPlugins(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -138,7 +137,6 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$output .= "if (!function_exists('{$_funcNameCaching}')) {\n";
|
||||
$output .= "function {$_funcNameCaching} (Smarty_Internal_Template \$_smarty_tpl,\$params) {\n";
|
||||
$output .= "ob_start();\n";
|
||||
$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";
|
||||
@@ -184,8 +182,6 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$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 .= $compiler->compileCheckPlugins(array_merge($compiler->required_plugins[ 'compiled' ],
|
||||
$compiler->required_plugins[ 'nocache' ]));
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
@@ -209,7 +205,6 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
// restore old buffer
|
||||
$compiler->parser->current_buffer = $saved_data[ 1 ];
|
||||
// restore old status
|
||||
$compiler->restoreRequiredPlugins();
|
||||
$compiler->template->compiled->has_nocache_code = $saved_data[ 2 ];
|
||||
$compiler->template->caching = $saved_data[ 3 ];
|
||||
return true;
|
||||
|
@@ -59,9 +59,9 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
* @var array
|
||||
*/
|
||||
public $valid_scopes = array(
|
||||
'parent' => Smarty::SCOPE_PARENT, 'root' => Smarty::SCOPE_ROOT,
|
||||
'global' => Smarty::SCOPE_GLOBAL, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
|
||||
'smarty' => Smarty::SCOPE_SMARTY
|
||||
'parent' => \Smarty\Smarty::SCOPE_PARENT, 'root' => \Smarty\Smarty::SCOPE_ROOT,
|
||||
'global' => \Smarty\Smarty::SCOPE_GLOBAL, 'tpl_root' => \Smarty\Smarty::SCOPE_TPL_ROOT,
|
||||
'smarty' => \Smarty\Smarty::SCOPE_SMARTY
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
$_cache_tpl = 'false';
|
||||
}
|
||||
// assume caching is off
|
||||
$_caching = Smarty::CACHING_OFF;
|
||||
$_caching = \Smarty\Smarty::CACHING_OFF;
|
||||
$call_nocache = $compiler->tag_nocache || $compiler->nocache;
|
||||
// caching was on and {include} is not in nocache mode
|
||||
if ($compiler->template->caching && !$compiler->nocache && !$compiler->tag_nocache) {
|
||||
@@ -156,7 +156,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
$_caching = $_new_caching = (int)$_attr[ 'caching' ];
|
||||
$call_nocache = true;
|
||||
} else {
|
||||
$_new_caching = Smarty::CACHING_LIFETIME_CURRENT;
|
||||
$_new_caching = \Smarty\Smarty::CACHING_LIFETIME_CURRENT;
|
||||
}
|
||||
if (isset($_attr[ 'cache_lifetime' ])) {
|
||||
$_cache_lifetime = $_attr[ 'cache_lifetime' ];
|
||||
|
@@ -48,12 +48,12 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
switch ($type) {
|
||||
case 1:
|
||||
// registered modifier
|
||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ])) {
|
||||
if (is_callable($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ])) {
|
||||
if (isset($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ])) {
|
||||
if (is_callable($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ])) {
|
||||
$output =
|
||||
sprintf(
|
||||
'call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], array( %s ))',
|
||||
Smarty::PLUGIN_MODIFIER,
|
||||
\Smarty\Smarty::PLUGIN_MODIFIER,
|
||||
var_export($modifier, true),
|
||||
$params
|
||||
);
|
||||
@@ -64,10 +64,10 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
break;
|
||||
case 2:
|
||||
// registered modifier compiler
|
||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ])) {
|
||||
if (isset($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ])) {
|
||||
$output =
|
||||
call_user_func(
|
||||
$compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ],
|
||||
$compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ],
|
||||
$single_modifier,
|
||||
$compiler->smarty
|
||||
);
|
||||
@@ -77,7 +77,6 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
break;
|
||||
case 3:
|
||||
// modifiercompiler plugin
|
||||
if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
@@ -87,11 +86,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
}
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// modifier plugin
|
||||
if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
|
||||
if ($function = $compiler->getPlugin($modifier, \Smarty\Smarty::PLUGIN_MODIFIER)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
@@ -120,11 +117,11 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
break;
|
||||
case 6:
|
||||
// default plugin handler
|
||||
if (isset($compiler->default_handler_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ])
|
||||
if (isset($compiler->default_handler_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ])
|
||||
|| (is_callable($compiler->smarty->default_plugin_handler_func)
|
||||
&& $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))
|
||||
&& $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIER))
|
||||
) {
|
||||
$function = $compiler->default_handler_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ];
|
||||
$function = $compiler->default_handler_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ];
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
@@ -139,15 +136,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($compiler->required_plugins[ 'nocache' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ])
|
||||
||
|
||||
isset($compiler->required_plugins[ 'compiled' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ])
|
||||
) {
|
||||
// was a plugin
|
||||
$compiler->known_modifier_type[ $modifier ] = 4;
|
||||
} else {
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
}
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
@@ -93,25 +93,25 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
}
|
||||
// autoescape html
|
||||
if ($compiler->template->smarty->escape_html) {
|
||||
$output = "htmlspecialchars((string) {$output}, ENT_QUOTES, '" . addslashes(Smarty::$_CHARSET) . "')";
|
||||
$output = "htmlspecialchars((string) {$output}, ENT_QUOTES, '" . addslashes(\Smarty\Smarty::$_CHARSET) . "')";
|
||||
}
|
||||
// loop over registered filters
|
||||
if (!empty($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ])) {
|
||||
foreach ($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ] as $key =>
|
||||
if (!empty($compiler->template->smarty->registered_filters[ \Smarty\Smarty::FILTER_VARIABLE ])) {
|
||||
foreach ($compiler->template->smarty->registered_filters[ \Smarty\Smarty::FILTER_VARIABLE ] as $key =>
|
||||
$function) {
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$output},\$_smarty_tpl)";
|
||||
} elseif (is_object($function[ 0 ])) {
|
||||
$output =
|
||||
"\$_smarty_tpl->smarty->registered_filters[Smarty::FILTER_VARIABLE]['{$key}'][0]->{$function[1]}({$output},\$_smarty_tpl)";
|
||||
"\$_smarty_tpl->smarty->registered_filters[\Smarty\Smarty::FILTER_VARIABLE]['{$key}'][0]->{$function[1]}({$output},\$_smarty_tpl)";
|
||||
} else {
|
||||
$output = "{$function[0]}::{$function[1]}({$output},\$_smarty_tpl)";
|
||||
}
|
||||
}
|
||||
}
|
||||
// auto loaded filters
|
||||
if (isset($compiler->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ])) {
|
||||
foreach ((array)$compiler->template->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ] as $name) {
|
||||
if (isset($compiler->smarty->autoload_filters[ \Smarty\Smarty::FILTER_VARIABLE ])) {
|
||||
foreach ((array)$compiler->template->smarty->autoload_filters[ \Smarty\Smarty::FILTER_VARIABLE ] as $name) {
|
||||
$result = $this->compile_variable_filter($compiler, $name, $output);
|
||||
if ($result !== false) {
|
||||
$output = $result;
|
||||
|
@@ -28,8 +28,8 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
|
||||
*/
|
||||
public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function)
|
||||
{
|
||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ];
|
||||
if (isset($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_BLOCK ][ $tag ])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_BLOCK ][ $tag ];
|
||||
$callback = $tag_info[ 0 ];
|
||||
if (is_array($callback)) {
|
||||
if (is_object($callback[ 0 ])) {
|
||||
@@ -46,7 +46,7 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
|
||||
$callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0]", '');
|
||||
}
|
||||
} else {
|
||||
$tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ];
|
||||
$tag_info = $compiler->default_handler_plugins[ \Smarty\Smarty::PLUGIN_BLOCK ][ $tag ];
|
||||
$callback = $tag_info[ 0 ];
|
||||
if (is_array($callback)) {
|
||||
$callable = "array('{$callback[0]}', '{$callback[1]}')";
|
||||
|
@@ -41,11 +41,11 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
unset($_attr[ 'nocache' ]);
|
||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ];
|
||||
if (isset($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ $tag ])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ $tag ];
|
||||
$is_registered = true;
|
||||
} else {
|
||||
$tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ];
|
||||
$tag_info = $compiler->default_handler_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ $tag ];
|
||||
$is_registered = false;
|
||||
}
|
||||
// not cacheable?
|
||||
@@ -66,7 +66,7 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
||||
// compile code
|
||||
if ($is_registered) {
|
||||
$output =
|
||||
"call_user_func_array( \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0], array( {$_params},\$_smarty_tpl ) )";
|
||||
"call_user_func_array( \$_smarty_tpl->smarty->registered_plugins[\\Smarty\\Smarty::PLUGIN_FUNCTION]['{$tag}'][0], array( {$_params},\$_smarty_tpl ) )";
|
||||
} else {
|
||||
$function = $tag_info[ 0 ];
|
||||
if (!is_array($function)) {
|
||||
|
@@ -89,7 +89,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
case 'current_dir':
|
||||
return 'dirname($_smarty_tpl->source->filepath)';
|
||||
case 'version':
|
||||
return "Smarty::SMARTY_VERSION";
|
||||
return "\\Smarty\\Smarty::SMARTY_VERSION";
|
||||
case 'const':
|
||||
if (isset($compiler->smarty->security_policy)
|
||||
&& !$compiler->smarty->security_policy->allow_constants
|
||||
|
@@ -110,7 +110,7 @@ class Smarty_Internal_Config_File_Compiler
|
||||
);
|
||||
if ($this->smarty->debugging) {
|
||||
if (!isset($this->smarty->_debug)) {
|
||||
$this->smarty->_debug = new Smarty_Internal_Debug();
|
||||
$this->smarty->_debug = new \Smarty\Debug();
|
||||
}
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ class Smarty_Internal_Config_File_Compiler
|
||||
// template header code
|
||||
$template_header = sprintf(
|
||||
"<?php /* Smarty version %s, created on %s\n compiled from '%s' */ ?>\n",
|
||||
Smarty::SMARTY_VERSION,
|
||||
\Smarty\Smarty::SMARTY_VERSION,
|
||||
date("Y-m-d H:i:s"),
|
||||
str_replace('*/', '* /' , $this->template->source->filepath)
|
||||
);
|
@@ -84,20 +84,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public $_tag_stack_count = array();
|
||||
|
||||
/**
|
||||
* Plugins used by template
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $required_plugins = array('compiled' => array(), 'nocache' => array());
|
||||
|
||||
/**
|
||||
* Required plugins stack
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $required_plugins_stack = array();
|
||||
|
||||
/**
|
||||
* current template
|
||||
*
|
||||
@@ -416,7 +402,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$this->template = $template;
|
||||
if ($this->smarty->debugging) {
|
||||
if (!isset($this->smarty->_debug)) {
|
||||
$this->smarty->_debug = new Smarty_Internal_Debug();
|
||||
$this->smarty->_debug = new \Smarty\Debug();
|
||||
}
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
@@ -456,9 +442,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$_content = $this->template->source->getContent();
|
||||
}
|
||||
$_compiled_code = $this->postFilter($this->doCompile($this->preFilter($_content), true));
|
||||
if (!empty($this->required_plugins[ 'compiled' ]) || !empty($this->required_plugins[ 'nocache' ])) {
|
||||
$_compiled_code = '<?php ' . $this->compileRequiredPlugins() . "?>\n" . $_compiled_code;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
if ($this->smarty->debugging) {
|
||||
$this->smarty->_debug->end_compile($this->template);
|
||||
@@ -777,64 +760,16 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
* @param string $plugin_type type of plugin
|
||||
*
|
||||
* @return string call name of function
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function getPlugin($plugin_name, $plugin_type)
|
||||
{
|
||||
$function = null;
|
||||
if ($this->caching && ($this->nocache || $this->tag_nocache)) {
|
||||
if (isset($this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) {
|
||||
$function =
|
||||
$this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ];
|
||||
} elseif (isset($this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) {
|
||||
$this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ] =
|
||||
$this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ];
|
||||
$function =
|
||||
$this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ];
|
||||
}
|
||||
} else {
|
||||
if (isset($this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) {
|
||||
$function =
|
||||
$this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ];
|
||||
} elseif (isset($this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) {
|
||||
$this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ] =
|
||||
$this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ];
|
||||
$function =
|
||||
$this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ];
|
||||
}
|
||||
}
|
||||
if (isset($function)) {
|
||||
if ($plugin_type === 'modifier') {
|
||||
$this->modifier_plugins[ $plugin_name ] = true;
|
||||
}
|
||||
return $function;
|
||||
}
|
||||
// loop through plugin dirs and find the plugin
|
||||
$function = 'smarty_' . $plugin_type . '_' . $plugin_name;
|
||||
$file = $this->smarty->loadPlugin($function, false);
|
||||
if (is_string($file)) {
|
||||
if ($this->caching && ($this->nocache || $this->tag_nocache)) {
|
||||
$this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'file' ] =
|
||||
$file;
|
||||
$this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ] =
|
||||
$function;
|
||||
} else {
|
||||
$this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'file' ] =
|
||||
$file;
|
||||
$this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ] =
|
||||
$function;
|
||||
}
|
||||
if ($plugin_type === 'modifier') {
|
||||
$this->modifier_plugins[ $plugin_name ] = true;
|
||||
}
|
||||
return $function;
|
||||
}
|
||||
if (is_callable($function)) {
|
||||
// plugin function is defined in the script
|
||||
return $function;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for plugins by default plugin handler
|
||||
@@ -865,17 +800,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$this->tag_nocache = $this->tag_nocache || !$cacheable;
|
||||
if ($script !== null) {
|
||||
if (is_file($script)) {
|
||||
if ($this->caching && ($this->nocache || $this->tag_nocache)) {
|
||||
$this->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'file' ] =
|
||||
$script;
|
||||
$this->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'function' ] =
|
||||
$callback;
|
||||
} else {
|
||||
$this->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'file' ] =
|
||||
$script;
|
||||
$this->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'function' ] =
|
||||
$callback;
|
||||
}
|
||||
include_once $script;
|
||||
} else {
|
||||
$this->trigger_template_error("Default plugin handler: Returned script file '{$script}' for '{$tag}' not found");
|
||||
@@ -938,13 +862,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$_output = str_replace('^#^', '\'', $_output);
|
||||
$_output =
|
||||
"<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/{$_output}/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
|
||||
// make sure we include modifier plugins for nocache code
|
||||
foreach ($this->modifier_plugins as $plugin_name => $dummy) {
|
||||
if (isset($this->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) {
|
||||
$this->required_plugins[ 'nocache' ][ $plugin_name ][ 'modifier' ] =
|
||||
$this->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$_output = $content;
|
||||
}
|
||||
@@ -1363,65 +1280,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save current required plugins
|
||||
*
|
||||
* @param bool $init if true init required plugins
|
||||
*/
|
||||
public function saveRequiredPlugins($init = false)
|
||||
{
|
||||
$this->required_plugins_stack[] = $this->required_plugins;
|
||||
if ($init) {
|
||||
$this->required_plugins = array('compiled' => array(), 'nocache' => array());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore required plugins
|
||||
*/
|
||||
public function restoreRequiredPlugins()
|
||||
{
|
||||
$this->required_plugins = array_pop($this->required_plugins_stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile code to call Smarty_Internal_Template::_checkPlugins()
|
||||
* for required plugins
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function compileRequiredPlugins()
|
||||
{
|
||||
$code = $this->compileCheckPlugins($this->required_plugins[ 'compiled' ]);
|
||||
if ($this->caching && !empty($this->required_plugins[ 'nocache' ])) {
|
||||
$code .= $this->makeNocacheCode($this->compileCheckPlugins($this->required_plugins[ 'nocache' ]));
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile code to call Smarty_Internal_Template::_checkPlugins
|
||||
* - checks if plugin is callable require otherwise
|
||||
*
|
||||
* @param $requiredPlugins
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function compileCheckPlugins($requiredPlugins)
|
||||
{
|
||||
if (!empty($requiredPlugins)) {
|
||||
$plugins = array();
|
||||
foreach ($requiredPlugins as $plugin) {
|
||||
foreach ($plugin as $data) {
|
||||
$plugins[] = $data;
|
||||
}
|
||||
}
|
||||
return '$_smarty_tpl->_checkPlugins(' . $this->getVarExport($plugins) . ');' . "\n";
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* method to compile a Smarty template
|
||||
*
|
||||
@@ -1528,13 +1386,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
// check if tag is registered
|
||||
foreach (array(
|
||||
Smarty::PLUGIN_COMPILER,
|
||||
Smarty::PLUGIN_FUNCTION,
|
||||
Smarty::PLUGIN_BLOCK,
|
||||
\Smarty\Smarty::PLUGIN_COMPILER,
|
||||
\Smarty\Smarty::PLUGIN_FUNCTION,
|
||||
\Smarty\Smarty::PLUGIN_BLOCK,
|
||||
) as $plugin_type) {
|
||||
if (isset($this->smarty->registered_plugins[ $plugin_type ][ $tag ])) {
|
||||
// if compiler function plugin call it now
|
||||
if ($plugin_type === Smarty::PLUGIN_COMPILER) {
|
||||
if ($plugin_type === \Smarty\Smarty::PLUGIN_COMPILER) {
|
||||
$new_args = array();
|
||||
foreach ($args as $key => $mixed) {
|
||||
if (is_array($mixed)) {
|
||||
@@ -1555,7 +1413,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
);
|
||||
}
|
||||
// compile registered function or block function
|
||||
if ($plugin_type === Smarty::PLUGIN_FUNCTION || $plugin_type === Smarty::PLUGIN_BLOCK) {
|
||||
if ($plugin_type === \Smarty\Smarty::PLUGIN_FUNCTION || $plugin_type === \Smarty\Smarty::PLUGIN_BLOCK) {
|
||||
return $this->callTagCompiler(
|
||||
'private_registered_' . $plugin_type,
|
||||
$args,
|
||||
@@ -1567,8 +1425,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
// check plugins from plugins folder
|
||||
foreach ($this->plugin_search_order as $plugin_type) {
|
||||
if ($plugin_type === Smarty::PLUGIN_COMPILER
|
||||
&& $this->smarty->loadPlugin('smarty_compiler_' . $tag)
|
||||
if ($plugin_type === \Smarty\Smarty::PLUGIN_COMPILER
|
||||
&& (!isset($this->smarty->security_policy)
|
||||
|| $this->smarty->security_policy->isTrustedTag($tag, $this))
|
||||
) {
|
||||
@@ -1628,7 +1485,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
if ($found) {
|
||||
// if compiler function plugin call it now
|
||||
if ($plugin_type === Smarty::PLUGIN_COMPILER) {
|
||||
if ($plugin_type === \Smarty\Smarty::PLUGIN_COMPILER) {
|
||||
$new_args = array();
|
||||
foreach ($args as $key => $mixed) {
|
||||
if (is_array($mixed)) {
|
||||
@@ -1679,21 +1536,21 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
}
|
||||
// registered block tag ?
|
||||
if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ])
|
||||
|| isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ])
|
||||
if (isset($this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_BLOCK ][ $base_tag ])
|
||||
|| isset($this->default_handler_plugins[ \Smarty\Smarty::PLUGIN_BLOCK ][ $base_tag ])
|
||||
) {
|
||||
return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag);
|
||||
}
|
||||
// registered function tag ?
|
||||
if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) {
|
||||
if (isset($this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ $tag ])) {
|
||||
return $this->callTagCompiler('private_registered_function', $args, $parameter, $tag);
|
||||
}
|
||||
// block plugin?
|
||||
if ($function = $this->getPlugin($base_tag, Smarty::PLUGIN_BLOCK)) {
|
||||
if ($function = $this->getPlugin($base_tag, \Smarty\Smarty::PLUGIN_BLOCK)) {
|
||||
return $this->callTagCompiler('private_block_plugin', $args, $parameter, $tag, $function);
|
||||
}
|
||||
// function plugin?
|
||||
if ($function = $this->getPlugin($tag, Smarty::PLUGIN_FUNCTION)) {
|
||||
if ($function = $this->getPlugin($tag, \Smarty\Smarty::PLUGIN_FUNCTION)) {
|
||||
if (!isset($this->smarty->security_policy)
|
||||
|| $this->smarty->security_policy->isTrustedTag($tag, $this)
|
||||
) {
|
||||
@@ -1701,21 +1558,20 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
}
|
||||
// registered compiler plugin ?
|
||||
if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ])) {
|
||||
if (isset($this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_COMPILER ][ $tag ])) {
|
||||
// if compiler function plugin call it now
|
||||
$args = array();
|
||||
if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) {
|
||||
if (!$this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) {
|
||||
$this->tag_nocache = true;
|
||||
}
|
||||
return call_user_func_array(
|
||||
$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ],
|
||||
$this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ],
|
||||
array(
|
||||
$args,
|
||||
$this
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
|
||||
$plugin = 'smarty_compiler_' . $tag;
|
||||
if (is_callable($plugin)) {
|
||||
return $plugin($args, $this->smarty);
|
||||
@@ -1728,7 +1584,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
throw new SmartyException("Plugin '{$tag}' not callable");
|
||||
}
|
||||
}
|
||||
$this->trigger_template_error("unknown tag '{$tag}'", null, true);
|
||||
}
|
||||
}
|
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Debug
|
||||
* Class to collect data for the Smarty Debugging Console
|
||||
@@ -14,7 +17,7 @@
|
||||
* @package Smarty
|
||||
* @subpackage Debug
|
||||
*/
|
||||
class Smarty_Internal_Debug extends \Smarty\Data
|
||||
class Debug extends Data
|
||||
{
|
||||
/**
|
||||
* template data
|
||||
@@ -50,7 +53,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
* @param \Smarty_Internal_Template $template template
|
||||
* @param null $mode true: display false: fetch null: subtemplate
|
||||
*/
|
||||
public function start_template(Smarty_Internal_Template $template, $mode = null)
|
||||
public function start_template(\Smarty_Internal_Template $template, $mode = null)
|
||||
{
|
||||
if (isset($mode) && !$template->_isSubTpl()) {
|
||||
$this->index++;
|
||||
@@ -66,12 +69,11 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template cached template
|
||||
*/
|
||||
public function end_template(Smarty_Internal_Template $template)
|
||||
public function end_template(\Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'total_time' ] +=
|
||||
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_template_time' ];
|
||||
//$this->template_data[$this->index][$key]['properties'] = $template->properties;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,21 +81,13 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*/
|
||||
public function start_compile(Smarty_Internal_Template $template)
|
||||
public function start_compile(\Smarty_Internal_Template $template)
|
||||
{
|
||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||
if (!empty($template->compiler->trace_uid)) {
|
||||
$key = $template->compiler->trace_uid;
|
||||
if (!isset($this->template_data[ $this->index ][ $key ])) {
|
||||
if (isset($_is_stringy[ $template->source->type ])) {
|
||||
$this->template_data[ $this->index ][ $key ][ 'name' ] =
|
||||
'\'' . substr($template->source->name, 0, 25) . '...\'';
|
||||
} else {
|
||||
$this->template_data[ $this->index ][ $key ][ 'name' ] = $template->source->filepath;
|
||||
}
|
||||
$this->template_data[ $this->index ][ $key ][ 'compile_time' ] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'render_time' ] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'cache_time' ] = 0;
|
||||
$this->saveTemplateData($_is_stringy, $template, $key);
|
||||
}
|
||||
} else {
|
||||
if (isset($this->ignore_uid[ $template->source->uid ])) {
|
||||
@@ -109,7 +103,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*/
|
||||
public function end_compile(Smarty_Internal_Template $template)
|
||||
public function end_compile(\Smarty_Internal_Template $template)
|
||||
{
|
||||
if (!empty($template->compiler->trace_uid)) {
|
||||
$key = $template->compiler->trace_uid;
|
||||
@@ -128,7 +122,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*/
|
||||
public function start_render(Smarty_Internal_Template $template)
|
||||
public function start_render(\Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true);
|
||||
@@ -139,7 +133,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*/
|
||||
public function end_render(Smarty_Internal_Template $template)
|
||||
public function end_render(\Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'render_time' ] +=
|
||||
@@ -151,7 +145,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template cached template
|
||||
*/
|
||||
public function start_cache(Smarty_Internal_Template $template)
|
||||
public function start_cache(\Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true);
|
||||
@@ -162,7 +156,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template cached template
|
||||
*/
|
||||
public function end_cache(Smarty_Internal_Template $template)
|
||||
public function end_cache(\Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'cache_time' ] +=
|
||||
@@ -174,23 +168,23 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template cached template
|
||||
*/
|
||||
public function register_template(Smarty_Internal_Template $template)
|
||||
public function register_template(\Smarty_Internal_Template $template)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Register data object
|
||||
*
|
||||
* @param \Smarty_Data $data data object
|
||||
* @param Data $data data object
|
||||
*/
|
||||
public static function register_data(Smarty_Data $data)
|
||||
public static function register_data(Data $data)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a window for the Smarty Debugging Console and display the data
|
||||
*
|
||||
* @param Smarty_Internal_Template|Smarty $obj object to debug
|
||||
* @param \Smarty_Internal_Template|\Smarty $obj object to debug
|
||||
* @param bool $full
|
||||
*
|
||||
* @throws \Exception
|
||||
@@ -206,14 +200,11 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
// create fresh instance of smarty for displaying the debug console
|
||||
// to avoid problems if the application did overload the Smarty class
|
||||
$debObj = new Smarty();
|
||||
$debObj = new \Smarty();
|
||||
// copy the working dirs from application
|
||||
$debObj->setCompileDir($smarty->getCompileDir());
|
||||
// init properties by hand as user may have edited the original Smarty class
|
||||
$debObj->setPluginsDir(is_dir(__DIR__ . '/../plugins') ? __DIR__ .
|
||||
'/../plugins' : $smarty->getPluginsDir());
|
||||
$debObj->force_compile = false;
|
||||
$debObj->compile_check = Smarty::COMPILECHECK_ON;
|
||||
$debObj->compile_check = \Smarty::COMPILECHECK_ON;
|
||||
$debObj->left_delimiter = '{';
|
||||
$debObj->right_delimiter = '}';
|
||||
$debObj->security_policy = null;
|
||||
@@ -228,7 +219,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
$debObj->autoload_filters = array();
|
||||
$debObj->default_modifiers = array();
|
||||
$debObj->escape_html = true;
|
||||
$debObj->caching = Smarty::CACHING_OFF;
|
||||
$debObj->caching = \Smarty::CACHING_OFF;
|
||||
$debObj->compile_id = null;
|
||||
$debObj->cache_id = null;
|
||||
// prepare information of assigned variables
|
||||
@@ -238,7 +229,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
$_config_vars = $ptr->config_vars;
|
||||
ksort($_config_vars);
|
||||
$debugging = $smarty->debugging;
|
||||
$_template = new Smarty_Internal_Template($debObj->debug_tpl, $debObj);
|
||||
$_template = new \Smarty_Internal_Template($debObj->debug_tpl, $debObj);
|
||||
if ($obj->_isTplObj()) {
|
||||
$_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
|
||||
}
|
||||
@@ -264,9 +255,9 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
/**
|
||||
* Recursively gets variables from all template/data scopes
|
||||
*
|
||||
* @param Smarty_Internal_Template|Smarty_Data $obj object to debug
|
||||
* @param \Smarty_Internal_Template|\Smarty_Data $obj object to debug
|
||||
*
|
||||
* @return StdClass
|
||||
* @return \StdClass
|
||||
*/
|
||||
public function get_debug_vars($obj)
|
||||
{
|
||||
@@ -321,7 +312,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
}
|
||||
$config_vars = array_merge($parent->config_vars, $config_vars);
|
||||
} else {
|
||||
foreach (Smarty::$global_tpl_vars as $key => $var) {
|
||||
foreach (\Smarty\Smarty::$global_tpl_vars as $key => $var) {
|
||||
if (!array_key_exists($key, $tpl_vars)) {
|
||||
foreach ($var as $varkey => $varvalue) {
|
||||
if ($varkey === 'value') {
|
||||
@@ -352,7 +343,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
*
|
||||
* @return string key into $template_data
|
||||
*/
|
||||
private function get_key(Smarty_Internal_Template $template)
|
||||
private function get_key(\Smarty_Internal_Template $template)
|
||||
{
|
||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||
// calculate Uid if not already done
|
||||
@@ -363,15 +354,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
if (isset($this->template_data[ $this->index ][ $key ])) {
|
||||
return $key;
|
||||
} else {
|
||||
if (isset($_is_stringy[ $template->source->type ])) {
|
||||
$this->template_data[ $this->index ][ $key ][ 'name' ] =
|
||||
'\'' . substr($template->source->name, 0, 25) . '...\'';
|
||||
} else {
|
||||
$this->template_data[ $this->index ][ $key ][ 'name' ] = $template->source->filepath;
|
||||
}
|
||||
$this->template_data[ $this->index ][ $key ][ 'compile_time' ] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'render_time' ] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'cache_time' ] = 0;
|
||||
$this->saveTemplateData($_is_stringy, $template, $key);
|
||||
$this->template_data[ $this->index ][ $key ][ 'total_time' ] = 0;
|
||||
return $key;
|
||||
}
|
||||
@@ -382,7 +365,7 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*/
|
||||
public function ignore(Smarty_Internal_Template $template)
|
||||
public function ignore(\Smarty_Internal_Template $template)
|
||||
{
|
||||
// calculate Uid if not already done
|
||||
if ($template->source->uid === '') {
|
||||
@@ -394,9 +377,9 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
/**
|
||||
* handle 'URL' debugging mode
|
||||
*
|
||||
* @param Smarty $smarty
|
||||
* @param \Smarty $smarty
|
||||
*/
|
||||
public function debugUrl(Smarty $smarty)
|
||||
public function debugUrl(\Smarty $smarty)
|
||||
{
|
||||
if (isset($_SERVER[ 'QUERY_STRING' ])) {
|
||||
$_query_string = $_SERVER[ 'QUERY_STRING' ];
|
||||
@@ -422,4 +405,23 @@ class Smarty_Internal_Debug extends \Smarty\Data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $_is_stringy
|
||||
* @param \Smarty_Internal_Template $template
|
||||
* @param string $key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function saveTemplateData(array $_is_stringy, \Smarty_Internal_Template $template, string $key): void {
|
||||
if (isset($_is_stringy[$template->source->type])) {
|
||||
$this->template_data[$this->index][$key]['name'] =
|
||||
'\'' . substr($template->source->name, 0, 25) . '...\'';
|
||||
} else {
|
||||
$this->template_data[$this->index][$key]['name'] = $template->source->filepath;
|
||||
}
|
||||
$this->template_data[$this->index][$key]['compile_time'] = 0;
|
||||
$this->template_data[$this->index][$key]['render_time'] = 0;
|
||||
$this->template_data[$this->index][$key]['cache_time'] = 0;
|
||||
}
|
||||
}
|
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty;
|
||||
|
||||
/**
|
||||
* Smarty error handler to fix new error levels in PHP8 for backwards compatibility
|
||||
*
|
||||
@@ -8,7 +10,7 @@
|
||||
* @author Simon Wisselink
|
||||
*
|
||||
*/
|
||||
class Smarty_Internal_ErrorHandler
|
||||
class ErrorHandler
|
||||
{
|
||||
|
||||
/**
|
@@ -32,10 +32,10 @@ class Smarty_Internal_Method_AssignGlobal
|
||||
public function assignGlobal(\Smarty\Data $data, $varName, $value = null, $nocache = false)
|
||||
{
|
||||
if ($varName !== '') {
|
||||
Smarty::$global_tpl_vars[ $varName ] = new \Smarty\Variable($value, $nocache);
|
||||
\Smarty\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 ];
|
||||
$ptr->tpl_vars[ $varName ] = clone \Smarty\Smarty::$global_tpl_vars[ $varName ];
|
||||
$ptr = $ptr->parent;
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ class Smarty_Internal_Method_ClearAllCache
|
||||
{
|
||||
$smarty->_clearTemplateCache();
|
||||
// load cache resource and call clearAll
|
||||
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
|
||||
$_cache_resource = \Smarty\Cacheresource\Base::load($smarty, $type);
|
||||
return $_cache_resource->clearAll($smarty, $exp_time);
|
||||
}
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ class Smarty_Internal_Method_ClearCache
|
||||
) {
|
||||
$smarty->_clearTemplateCache();
|
||||
// load cache resource and call clear
|
||||
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
|
||||
$_cache_resource = \Smarty\Cacheresource\Base::load($smarty, $type);
|
||||
return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ class Smarty_Internal_Method_ClearCompiledTemplate
|
||||
$_dir_sep = $smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
|
||||
if (isset($resource_name)) {
|
||||
$_save_stat = $smarty->caching;
|
||||
$smarty->caching = Smarty::CACHING_OFF;
|
||||
$smarty->caching = \Smarty\Smarty::CACHING_OFF;
|
||||
/* @var Smarty_Internal_Template $tpl */
|
||||
$tpl = $smarty->createTemplate($resource_name);
|
||||
$smarty->caching = $_save_stat;
|
||||
|
@@ -99,7 +99,7 @@ class Smarty_Internal_Method_CompileAllTemplates
|
||||
try {
|
||||
/* @var Smarty_Internal_Template $_tpl */
|
||||
$_tpl = new $smarty->template_class($_file, $_smarty);
|
||||
$_tpl->caching = Smarty::CACHING_OFF;
|
||||
$_tpl->caching = \Smarty\Smarty::CACHING_OFF;
|
||||
$_tpl->source =
|
||||
$isConfig ? Smarty_Template_Config::load($_tpl) : Smarty_Template_Source::load($_tpl);
|
||||
if ($_tpl->mustCompile()) {
|
||||
|
@@ -59,7 +59,7 @@ class Smarty_Internal_Method_ConfigLoad
|
||||
$smarty = $data->_getSmartyObj();
|
||||
/* @var \Smarty_Internal_Template $confObj */
|
||||
$confObj = new Smarty_Internal_Template($config_file, $smarty, $data, null, null, null, null, true);
|
||||
$confObj->caching = Smarty::CACHING_OFF;
|
||||
$confObj->caching = \Smarty\Smarty::CACHING_OFF;
|
||||
$confObj->source->config_sections = $sections;
|
||||
$confObj->source->scope = $scope;
|
||||
$confObj->compiled = Smarty_Template_Compiled::load($confObj);
|
||||
@@ -81,7 +81,7 @@ class Smarty_Internal_Method_ConfigLoad
|
||||
$this->_assignConfigVars($tpl->parent->config_vars, $tpl, $new_config_vars);
|
||||
$tagScope = $tpl->source->scope;
|
||||
if ($tagScope >= 0) {
|
||||
if ($tagScope === Smarty::SCOPE_LOCAL) {
|
||||
if ($tagScope === \Smarty\Smarty::SCOPE_LOCAL) {
|
||||
$this->_updateVarStack($tpl, $new_config_vars);
|
||||
$tagScope = 0;
|
||||
if (!$tpl->scope) {
|
||||
|
@@ -37,7 +37,7 @@ class Smarty_Internal_Method_CreateData
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$dataObj = new Smarty_Data($parent, $smarty, $name);
|
||||
if ($smarty->debugging) {
|
||||
Smarty_Internal_Debug::register_data($dataObj);
|
||||
\Smarty\Debug::register_data($dataObj);
|
||||
}
|
||||
return $dataObj;
|
||||
}
|
||||
|
@@ -31,14 +31,14 @@ class Smarty_Internal_Method_GetGlobal
|
||||
public function getGlobal(\Smarty\Data $data, $varName = null)
|
||||
{
|
||||
if (isset($varName)) {
|
||||
if (isset(Smarty::$global_tpl_vars[ $varName ])) {
|
||||
return Smarty::$global_tpl_vars[ $varName ]->value;
|
||||
if (isset(\Smarty\Smarty::$global_tpl_vars[ $varName ])) {
|
||||
return \Smarty\Smarty::$global_tpl_vars[ $varName ]->value;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$_result = array();
|
||||
foreach (Smarty::$global_tpl_vars as $key => $var) {
|
||||
foreach (\Smarty\Smarty::$global_tpl_vars as $key => $var) {
|
||||
$_result[ $key ] = $var->value;
|
||||
}
|
||||
return $_result;
|
||||
|
@@ -62,8 +62,8 @@ class Smarty_Internal_Method_GetTemplateVars
|
||||
$_ptr = null;
|
||||
}
|
||||
}
|
||||
if ($searchParents && isset(Smarty::$global_tpl_vars)) {
|
||||
foreach (Smarty::$global_tpl_vars as $key => $var) {
|
||||
if ($searchParents && isset(\Smarty\Smarty::$global_tpl_vars)) {
|
||||
foreach (\Smarty\Smarty::$global_tpl_vars as $key => $var) {
|
||||
if (!array_key_exists($key, $_result)) {
|
||||
$_result[ $key ] = $var->value;
|
||||
}
|
||||
@@ -106,9 +106,9 @@ class Smarty_Internal_Method_GetTemplateVars
|
||||
$_ptr = null;
|
||||
}
|
||||
}
|
||||
if (isset(Smarty::$global_tpl_vars[ $varName ])) {
|
||||
if (isset(\Smarty\Smarty::$global_tpl_vars[ $varName ])) {
|
||||
// found it, return it
|
||||
return Smarty::$global_tpl_vars[ $varName ];
|
||||
return \Smarty\Smarty::$global_tpl_vars[ $varName ];
|
||||
}
|
||||
if ($errorEnable && $data->_getSmartyObj()->error_unassigned) {
|
||||
// force a notice
|
||||
|
@@ -49,7 +49,6 @@ class Smarty_Internal_Method_LoadFilter
|
||||
$smarty->registered_filters[ $type ][ $_filter_name ] = $_plugin;
|
||||
return true;
|
||||
}
|
||||
if ($smarty->loadPlugin($_plugin)) {
|
||||
if (class_exists($_plugin, false)) {
|
||||
$_plugin = array($_plugin, 'execute');
|
||||
}
|
||||
@@ -57,7 +56,6 @@ class Smarty_Internal_Method_LoadFilter
|
||||
$smarty->registered_filters[ $type ][ $_filter_name ] = $_plugin;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
throw new SmartyException("{$type}filter '{$name}' not found or callable");
|
||||
}
|
||||
|
||||
|
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Extension Loadplugin
|
||||
*
|
||||
* $smarty->loadPlugin() method
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Method_LoadPlugin
|
||||
{
|
||||
/**
|
||||
* Cache of searched plugin files
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $plugin_files = array();
|
||||
|
||||
/**
|
||||
* Takes unknown classes and loads plugin files for them
|
||||
* class name format: Smarty_PluginType_PluginName
|
||||
* plugin filename format: plugintype.pluginname.php
|
||||
*
|
||||
* @param \Smarty $smarty
|
||||
* @param string $plugin_name class plugin name to load
|
||||
* @param bool $check check if already loaded
|
||||
*
|
||||
* @return bool|string
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function loadPlugin(Smarty $smarty, $plugin_name, $check)
|
||||
{
|
||||
// if function or class exists, exit silently (already loaded)
|
||||
if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
|
||||
return true;
|
||||
}
|
||||
if (!preg_match('#^smarty_((internal)|([^_]+))_(.+)$#i', $plugin_name, $match)) {
|
||||
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
|
||||
}
|
||||
if (!empty($match[ 2 ])) {
|
||||
$file = SMARTY_SYSPLUGINS_DIR . smarty_strtolower_ascii($plugin_name) . '.php';
|
||||
if (isset($this->plugin_files[ $file ])) {
|
||||
if ($this->plugin_files[ $file ] !== false) {
|
||||
return $this->plugin_files[ $file ];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (is_file($file)) {
|
||||
$this->plugin_files[ $file ] = $file;
|
||||
include_once $file;
|
||||
return $file;
|
||||
} else {
|
||||
$this->plugin_files[ $file ] = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// plugin filename is expected to be: [type].[name].php
|
||||
$_plugin_filename = "{$match[1]}.{$match[4]}.php";
|
||||
$_lower_filename = smarty_strtolower_ascii($_plugin_filename);
|
||||
if (isset($this->plugin_files)) {
|
||||
if (isset($this->plugin_files[ 'plugins_dir' ][ $_lower_filename ])) {
|
||||
if (!$smarty->use_include_path || $this->plugin_files[ 'plugins_dir' ][ $_lower_filename ] !== false) {
|
||||
return $this->plugin_files[ 'plugins_dir' ][ $_lower_filename ];
|
||||
}
|
||||
}
|
||||
if (!$smarty->use_include_path || $smarty->ext->_getIncludePath->isNewIncludePath($smarty)) {
|
||||
unset($this->plugin_files[ 'include_path' ]);
|
||||
} else {
|
||||
if (isset($this->plugin_files[ 'include_path' ][ $_lower_filename ])) {
|
||||
return $this->plugin_files[ 'include_path' ][ $_lower_filename ];
|
||||
}
|
||||
}
|
||||
}
|
||||
$_file_names = array($_plugin_filename);
|
||||
if ($_lower_filename !== $_plugin_filename) {
|
||||
$_file_names[] = $_lower_filename;
|
||||
}
|
||||
$_p_dirs = $smarty->getPluginsDir();
|
||||
if (!isset($this->plugin_files[ 'plugins_dir' ][ $_lower_filename ])) {
|
||||
// loop through plugin dirs and find the plugin
|
||||
foreach ($_p_dirs as $_plugin_dir) {
|
||||
foreach ($_file_names as $name) {
|
||||
$file = $_plugin_dir . $name;
|
||||
if (is_file($file)) {
|
||||
$this->plugin_files[ 'plugins_dir' ][ $_lower_filename ] = $file;
|
||||
include_once $file;
|
||||
return $file;
|
||||
}
|
||||
$this->plugin_files[ 'plugins_dir' ][ $_lower_filename ] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($smarty->use_include_path) {
|
||||
foreach ($_file_names as $_file_name) {
|
||||
// try PHP include_path
|
||||
$file = $smarty->ext->_getIncludePath->getIncludePath($_p_dirs, $_file_name, $smarty);
|
||||
$this->plugin_files[ 'include_path' ][ $_lower_filename ] = $file;
|
||||
if ($file !== false) {
|
||||
include_once $file;
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
// no plugin loaded
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -26,14 +26,14 @@ class Smarty_Internal_Method_RegisterCacheResource
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $name name of resource type
|
||||
* @param \Smarty_CacheResource $resource_handler
|
||||
* @param \Smarty\Cacheresource\Base $resource_handler
|
||||
*
|
||||
* @return \Smarty|\Smarty_Internal_Template
|
||||
*/
|
||||
public function registerCacheResource(
|
||||
Smarty_Internal_TemplateBase $obj,
|
||||
$name,
|
||||
Smarty_CacheResource $resource_handler
|
||||
\Smarty\Cacheresource\Base $resource_handler
|
||||
) {
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$smarty->registered_cache_resources[ $name ] = $resource_handler;
|
||||
|
@@ -1,3 +1,8 @@
|
||||
|
||||
namespace Smarty\Parser;
|
||||
|
||||
use \Smarty\Lexer\Configfile as Lexer;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Configfileparser
|
||||
*
|
||||
@@ -19,7 +24,7 @@
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Configfileparser
|
||||
class Configfile
|
||||
}
|
||||
%include_class
|
||||
{
|
||||
@@ -42,7 +47,7 @@ class Smarty_Internal_Configfileparser
|
||||
/**
|
||||
* lexer object
|
||||
*
|
||||
* @var Smarty_Internal_Configfilelexer
|
||||
* @var Lexer
|
||||
*/
|
||||
private $lex;
|
||||
/**
|
||||
@@ -86,10 +91,10 @@ class Smarty_Internal_Configfileparser
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param Smarty_Internal_Configfilelexer $lex
|
||||
* @param Lexer $lex
|
||||
* @param Smarty_Internal_Config_File_Compiler $compiler
|
||||
*/
|
||||
public function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
|
||||
public function __construct(Lexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
|
||||
{
|
||||
$this->lex = $lex;
|
||||
$this->smarty = $compiler->smarty;
|
@@ -84,7 +84,6 @@ abstract class Base
|
||||
}
|
||||
// try plugins dir
|
||||
$_resource_class = 'Smarty_Resource_' . \smarty_ucfirst_ascii($type);
|
||||
if ($smarty->loadPlugin($_resource_class)) {
|
||||
if (class_exists($_resource_class, false)) {
|
||||
return $smarty->_resource_handlers[ $type ] = new $_resource_class();
|
||||
} else {
|
||||
@@ -98,7 +97,6 @@ abstract class Base
|
||||
// give it another try, now that the resource is registered properly
|
||||
return self::load($smarty, $type);
|
||||
}
|
||||
}
|
||||
// try streams
|
||||
$_known_stream = stream_get_wrappers();
|
||||
if (in_array($type, $_known_stream)) {
|
||||
|
@@ -48,7 +48,7 @@ class Smarty_Internal_Runtime_CacheResourceFile
|
||||
}
|
||||
if (isset($resource_name)) {
|
||||
$_save_stat = $smarty->caching;
|
||||
$smarty->caching = Smarty::CACHING_LIFETIME_CURRENT;
|
||||
$smarty->caching = \Smarty\Smarty::CACHING_LIFETIME_CURRENT;
|
||||
$tpl = new $smarty->template_class($resource_name, $smarty);
|
||||
$smarty->caching = $_save_stat;
|
||||
// remove from template cache
|
||||
|
@@ -40,7 +40,7 @@ class Smarty_Internal_Runtime_FilterHandler
|
||||
$callback = $plugin_name;
|
||||
} elseif (class_exists($plugin_name, false) && is_callable(array($plugin_name, 'execute'))) {
|
||||
$callback = array($plugin_name, 'execute');
|
||||
} elseif ($template->smarty->loadPlugin($plugin_name, false)) {
|
||||
} else {
|
||||
if (function_exists($plugin_name)) {
|
||||
// use loaded Smarty2 style plugin
|
||||
$callback = $plugin_name;
|
||||
@@ -50,9 +50,6 @@ class Smarty_Internal_Runtime_FilterHandler
|
||||
} else {
|
||||
throw new SmartyException("Auto load {$type}-filter plugin method '{$plugin_name}::execute' not callable");
|
||||
}
|
||||
} else {
|
||||
// nothing found, throw exception
|
||||
throw new SmartyException("Unable to auto load {$type}-filter plugin '{$plugin_name}'");
|
||||
}
|
||||
$content = call_user_func($callback, $content, $template);
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
/**
|
||||
* Array of root child {block} objects
|
||||
*
|
||||
* @var Smarty_Internal_Block[]
|
||||
* @var \Smarty\Block[]
|
||||
*/
|
||||
public $childRoot = array();
|
||||
|
||||
@@ -128,7 +128,7 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty_Internal_Block constructor.
|
||||
* \Smarty\Block constructor.
|
||||
* - if outer level {block} of child template ($state === 1) save it as child root block
|
||||
* - otherwise process inheritance and render
|
||||
*
|
||||
@@ -159,16 +159,16 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
/**
|
||||
* Goto child block or render this
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param \Smarty_Internal_Block $block
|
||||
* @param \Smarty_Internal_Block|null $parent
|
||||
* @param Smarty_Internal_Template $tpl
|
||||
* @param \Smarty\Block $block
|
||||
* @param \Smarty\Block|null $parent
|
||||
*
|
||||
* @throws \SmartyException
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function process(
|
||||
Smarty_Internal_Template $tpl,
|
||||
Smarty_Internal_Block $block,
|
||||
Smarty_Internal_Block $parent = null
|
||||
\Smarty\Block $block,
|
||||
\Smarty\Block $parent = null
|
||||
) {
|
||||
if ($block->hide && !isset($block->child)) {
|
||||
return;
|
||||
@@ -203,13 +203,13 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
/**
|
||||
* Render child on \$smarty.block.child
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param \Smarty_Internal_Block $block
|
||||
* @param Smarty_Internal_Template $tpl
|
||||
* @param \Smarty\Block $block
|
||||
*
|
||||
* @return null|string block content
|
||||
* @throws \SmartyException
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function callChild(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block)
|
||||
public function callChild(Smarty_Internal_Template $tpl, \Smarty\Block $block)
|
||||
{
|
||||
if (isset($block->child)) {
|
||||
$this->process($tpl, $block->child, $block);
|
||||
@@ -219,14 +219,14 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
/**
|
||||
* Render parent block on \$smarty.block.parent or {block append/prepend}
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param \Smarty_Internal_Block $block
|
||||
* @param Smarty_Internal_Template $tpl
|
||||
* @param \Smarty\Block $block
|
||||
* @param string $tag
|
||||
*
|
||||
* @return null|string block content
|
||||
* @throws \SmartyException
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function callParent(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block, $tag)
|
||||
public function callParent(Smarty_Internal_Template $tpl, \Smarty\Block $block, $tag)
|
||||
{
|
||||
if (isset($block->parent)) {
|
||||
$this->callBlock($block->parent, $tpl);
|
||||
@@ -238,10 +238,10 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
/**
|
||||
* render block
|
||||
*
|
||||
* @param \Smarty_Internal_Block $block
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param \Smarty\Block $block
|
||||
* @param Smarty_Internal_Template $tpl
|
||||
*/
|
||||
public function callBlock(Smarty_Internal_Block $block, Smarty_Internal_Template $tpl)
|
||||
public function callBlock(\Smarty\Block $block, Smarty_Internal_Template $tpl)
|
||||
{
|
||||
$this->sourceStack[] = $tpl->source;
|
||||
$tpl->source = $this->sources[ $block->tplIndex ];
|
||||
|
@@ -41,7 +41,7 @@ class Smarty_Internal_Runtime_UpdateCache
|
||||
}
|
||||
$this->removeNoCacheHash($cached, $_template, $no_output_filter);
|
||||
$compile_check = (int)$_template->compile_check;
|
||||
$_template->compile_check = Smarty::COMPILECHECK_OFF;
|
||||
$_template->compile_check = \Smarty\Smarty::COMPILECHECK_OFF;
|
||||
if ($_template->_isSubTpl()) {
|
||||
$_template->compiled->unifunc = $_template->parent->compiled->unifunc;
|
||||
}
|
||||
|
@@ -20,15 +20,15 @@ class Smarty_Internal_Runtime_UpdateScope
|
||||
{
|
||||
if ($tagScope) {
|
||||
$this->_updateVarStack($tpl, $varName);
|
||||
$tagScope = $tagScope & ~Smarty::SCOPE_LOCAL;
|
||||
$tagScope = $tagScope & ~\Smarty\Smarty::SCOPE_LOCAL;
|
||||
if (!$tpl->scope && !$tagScope) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$mergedScope = $tagScope | $tpl->scope;
|
||||
if ($mergedScope) {
|
||||
if ($mergedScope & Smarty::SCOPE_GLOBAL && $varName) {
|
||||
Smarty::$global_tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ];
|
||||
if ($mergedScope & \Smarty\Smarty::SCOPE_GLOBAL && $varName) {
|
||||
\Smarty\Smarty::$global_tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ];
|
||||
}
|
||||
// update scopes
|
||||
foreach ($this->_getAffectedScopes($tpl, $mergedScope) as $ptr) {
|
||||
@@ -54,7 +54,7 @@ class Smarty_Internal_Runtime_UpdateScope
|
||||
$ptr = $tpl->parent;
|
||||
if ($mergedScope && isset($ptr) && $ptr->_isTplObj()) {
|
||||
$_stack[] = $ptr;
|
||||
$mergedScope = $mergedScope & ~Smarty::SCOPE_PARENT;
|
||||
$mergedScope = $mergedScope & ~\Smarty\Smarty::SCOPE_PARENT;
|
||||
if (!$mergedScope) {
|
||||
// only parent was set, we are done
|
||||
return $_stack;
|
||||
@@ -65,11 +65,11 @@ class Smarty_Internal_Runtime_UpdateScope
|
||||
$_stack[] = $ptr;
|
||||
$ptr = $ptr->parent;
|
||||
}
|
||||
if ($mergedScope & Smarty::SCOPE_SMARTY) {
|
||||
if ($mergedScope & \Smarty\Smarty::SCOPE_SMARTY) {
|
||||
if (isset($tpl->smarty)) {
|
||||
$_stack[] = $tpl->smarty;
|
||||
}
|
||||
} elseif ($mergedScope & Smarty::SCOPE_ROOT) {
|
||||
} elseif ($mergedScope & \Smarty\Smarty::SCOPE_ROOT) {
|
||||
while (isset($ptr)) {
|
||||
if (!$ptr->_isTplObj()) {
|
||||
$_stack[] = $ptr;
|
||||
|
@@ -60,7 +60,7 @@ class Smarty_Internal_Runtime_WriteFile
|
||||
* currently reading that file to fail, but linux' rename()
|
||||
* seems to be smart enough to handle that for us.
|
||||
*/
|
||||
if (Smarty::$_IS_WINDOWS) {
|
||||
if (\Smarty\Smarty::$_IS_WINDOWS) {
|
||||
// remove original file
|
||||
if (is_file($_filepath)) {
|
||||
@unlink($_filepath);
|
||||
|
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty;
|
||||
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: Smarty.class.php
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -26,34 +28,10 @@
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews <uwe dot tews at gmail dot com>
|
||||
* @author Rodney Rehm
|
||||
* @author Simon Wisselink
|
||||
* @package Smarty
|
||||
*/
|
||||
/**
|
||||
* set SMARTY_DIR to absolute path to Smarty library files.
|
||||
* Sets SMARTY_DIR only if user application has not already defined it.
|
||||
*/
|
||||
if (!defined('SMARTY_DIR')) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
define('SMARTY_DIR', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
/**
|
||||
* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
|
||||
* Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it.
|
||||
*/
|
||||
if (!defined('SMARTY_SYSPLUGINS_DIR')) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
if (!defined('SMARTY_PLUGINS_DIR')) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
if (!defined('SMARTY_MBSTRING')) {
|
||||
/**
|
||||
*
|
||||
@@ -61,32 +39,6 @@ if (!defined('SMARTY_MBSTRING')) {
|
||||
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load helper functions
|
||||
*/
|
||||
if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) {
|
||||
include __DIR__ . '/functions.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Smarty_Autoloader
|
||||
*/
|
||||
if (!class_exists('Smarty_Autoloader')) {
|
||||
include __DIR__ . '/bootstrap.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load always needed external class files
|
||||
*/
|
||||
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 . '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';
|
||||
|
||||
/**
|
||||
* This is the main Smarty class
|
||||
*
|
||||
@@ -101,7 +53,7 @@ require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_resource_file.php';
|
||||
* @method int compileAllConfig(string $extension = '.conf', bool $force_compile = false, int $time_limit = 0, $max_errors = null)
|
||||
* @method int clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null)
|
||||
*/
|
||||
class Smarty extends Smarty_Internal_TemplateBase
|
||||
class Smarty extends \Smarty_Internal_TemplateBase
|
||||
{
|
||||
/**
|
||||
* smarty version
|
||||
@@ -131,14 +83,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
const COMPILECHECK_OFF = 0;
|
||||
const COMPILECHECK_ON = 1;
|
||||
const COMPILECHECK_CACHEMISS = 2;
|
||||
/**
|
||||
* define debug modes
|
||||
*/
|
||||
const DEBUG_OFF = 0;
|
||||
const DEBUG_ON = 1;
|
||||
const DEBUG_INDIVIDUAL = 2;
|
||||
|
||||
/**
|
||||
* filter types
|
||||
*/
|
||||
@@ -344,17 +288,17 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
|
||||
/**
|
||||
* class name
|
||||
* This should be instance of Smarty_Security.
|
||||
* This should be instance of \Smarty_Security.
|
||||
*
|
||||
* @var string
|
||||
* @see Smarty_Security
|
||||
* @see \Smarty_Security
|
||||
*/
|
||||
public $security_class = 'Smarty_Security';
|
||||
public $security_class = \Smarty_Security::class;
|
||||
|
||||
/**
|
||||
* implementation of security class
|
||||
*
|
||||
* @var Smarty_Security
|
||||
* @var \Smarty_Security
|
||||
*/
|
||||
public $security_policy = null;
|
||||
|
||||
@@ -451,7 +395,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
|
||||
/**
|
||||
* resource type used if none given
|
||||
* Must be an valid key of $registered_resources.
|
||||
* Must be a valid key of $registered_resources.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
@@ -573,7 +517,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* Debug object
|
||||
*
|
||||
* @var Smarty_Internal_Debug
|
||||
* @var \Smarty\Debug
|
||||
*/
|
||||
public $_debug = null;
|
||||
|
||||
@@ -652,17 +596,17 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
$this->_clearTemplateCache();
|
||||
parent::__construct();
|
||||
if (is_callable('mb_internal_encoding')) {
|
||||
mb_internal_encoding(Smarty::$_CHARSET);
|
||||
mb_internal_encoding(\Smarty\Smarty::$_CHARSET);
|
||||
}
|
||||
$this->start_time = microtime(true);
|
||||
if (isset($_SERVER[ 'SCRIPT_NAME' ])) {
|
||||
Smarty::$global_tpl_vars[ 'SCRIPT_NAME' ] = new \Smarty\Variable($_SERVER[ 'SCRIPT_NAME' ]);
|
||||
\Smarty\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';
|
||||
// Check if we're running on Windows
|
||||
\Smarty\Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
|
||||
// let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8
|
||||
if (Smarty::$_CHARSET !== 'UTF-8') {
|
||||
Smarty::$_UTF8_MODIFIER = '';
|
||||
if (\Smarty\Smarty::$_CHARSET !== 'UTF-8') {
|
||||
\Smarty\Smarty::$_UTF8_MODIFIER = '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,21 +621,21 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
public function templateExists($resource_name)
|
||||
{
|
||||
// create source object
|
||||
$source = Smarty_Template_Source::load(null, $this, $resource_name);
|
||||
$source = \Smarty_Template_Source::load(null, $this, $resource_name);
|
||||
return $source->exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads security class and enables security
|
||||
*
|
||||
* @param string|Smarty_Security $security_class if a string is used, it must be class-name
|
||||
* @param string|\Smarty_Security $security_class if a string is used, it must be class-name
|
||||
*
|
||||
* @return Smarty current Smarty instance for chaining
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function enableSecurity($security_class = null)
|
||||
{
|
||||
Smarty_Security::enableSecurity($this, $security_class);
|
||||
\Smarty_Security::enableSecurity($this, $security_class);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -780,7 +724,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @param string|array $template_dir directory(s) of template sources
|
||||
* @param bool $isConfig true for config_dir
|
||||
*
|
||||
* @return \Smarty current Smarty instance for chaining
|
||||
* @return Smarty current Smarty instance for chaining
|
||||
*/
|
||||
public function setTemplateDir($template_dir, $isConfig = false)
|
||||
{
|
||||
@@ -841,37 +785,11 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public function addPluginsDir($plugins_dir)
|
||||
{
|
||||
if (empty($this->plugins_dir)) {
|
||||
$this->plugins_dir[] = SMARTY_PLUGINS_DIR;
|
||||
}
|
||||
$this->plugins_dir = array_merge($this->plugins_dir, (array)$plugins_dir);
|
||||
$this->_pluginsDirNormalized = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin directories
|
||||
*
|
||||
* @return array list of plugin directories
|
||||
*/
|
||||
public function getPluginsDir()
|
||||
{
|
||||
if (empty($this->plugins_dir)) {
|
||||
$this->plugins_dir[] = SMARTY_PLUGINS_DIR;
|
||||
$this->_pluginsDirNormalized = false;
|
||||
}
|
||||
if (!$this->_pluginsDirNormalized) {
|
||||
if (!is_array($this->plugins_dir)) {
|
||||
$this->plugins_dir = (array)$this->plugins_dir;
|
||||
}
|
||||
foreach ($this->plugins_dir as $k => $v) {
|
||||
$this->plugins_dir[ $k ] = $this->_realpath(rtrim($v ?? '', '/\\') . DIRECTORY_SEPARATOR, true);
|
||||
}
|
||||
$this->_pluginsDirNormalized = true;
|
||||
}
|
||||
return $this->plugins_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set plugins directory
|
||||
*
|
||||
@@ -970,17 +888,17 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
}
|
||||
$_templateId = $this->_getTemplateId($template, $cache_id, $compile_id);
|
||||
$tpl = null;
|
||||
if ($this->caching && isset(Smarty_Internal_Template::$isCacheTplObj[ $_templateId ])) {
|
||||
$tpl = $do_clone ? clone Smarty_Internal_Template::$isCacheTplObj[ $_templateId ] :
|
||||
Smarty_Internal_Template::$isCacheTplObj[ $_templateId ];
|
||||
if ($this->caching && isset(\Smarty_Internal_Template::$isCacheTplObj[ $_templateId ])) {
|
||||
$tpl = $do_clone ? clone \Smarty_Internal_Template::$isCacheTplObj[ $_templateId ] :
|
||||
\Smarty_Internal_Template::$isCacheTplObj[ $_templateId ];
|
||||
$tpl->inheritance = null;
|
||||
$tpl->tpl_vars = $tpl->config_vars = array();
|
||||
} elseif (!$do_clone && isset(Smarty_Internal_Template::$tplObjCache[ $_templateId ])) {
|
||||
$tpl = clone Smarty_Internal_Template::$tplObjCache[ $_templateId ];
|
||||
} elseif (!$do_clone && isset(\Smarty_Internal_Template::$tplObjCache[ $_templateId ])) {
|
||||
$tpl = clone \Smarty_Internal_Template::$tplObjCache[ $_templateId ];
|
||||
$tpl->inheritance = null;
|
||||
$tpl->tpl_vars = $tpl->config_vars = array();
|
||||
} else {
|
||||
/* @var Smarty_Internal_Template $tpl */
|
||||
/* @var \Smarty_Internal_Template $tpl */
|
||||
$tpl = new $this->template_class($template, $this, null, $cache_id, $compile_id, null, null);
|
||||
$tpl->templateId = $_templateId;
|
||||
}
|
||||
@@ -996,7 +914,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
}
|
||||
}
|
||||
if ($this->debugging || $this->debugging_ctrl === 'URL') {
|
||||
$tpl->smarty->_debug = new Smarty_Internal_Debug();
|
||||
$tpl->smarty->_debug = new \Smarty\Debug();
|
||||
// check URL debugging control
|
||||
if (!$this->debugging && $this->debugging_ctrl === 'URL') {
|
||||
$tpl->smarty->_debug->debugUrl($tpl->smarty);
|
||||
@@ -1005,22 +923,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
return $tpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes unknown classes and loads plugin files for them
|
||||
* class name format: Smarty_PluginType_PluginName
|
||||
* plugin filename format: plugintype.pluginname.php
|
||||
*
|
||||
* @param string $plugin_name class plugin name to load
|
||||
* @param bool $check check if already loaded
|
||||
*
|
||||
* @return string |boolean filepath of loaded file or false
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function loadPlugin($plugin_name, $check = true)
|
||||
{
|
||||
return $this->ext->loadPlugin->loadPlugin($this, $plugin_name, $check);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get unique template id
|
||||
*
|
||||
@@ -1038,7 +940,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
$cache_id = null,
|
||||
$compile_id = null,
|
||||
$caching = null,
|
||||
Smarty_Internal_Template $template = null
|
||||
\Smarty_Internal_Template $template = null
|
||||
) {
|
||||
$template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" :
|
||||
$template_name;
|
||||
@@ -1047,7 +949,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
$caching = (int)($caching === null ? $this->caching : $caching);
|
||||
if ((isset($template) && strpos($template_name, ':.') !== false) || $this->allow_ambiguous_resources) {
|
||||
$_templateId =
|
||||
Smarty_Resource::getUniqueTemplateName((isset($template) ? $template : $this), $template_name) .
|
||||
\Smarty_Resource::getUniqueTemplateName((isset($template) ? $template : $this), $template_name) .
|
||||
"#{$cache_id}#{$compile_id}#{$caching}";
|
||||
} else {
|
||||
$_templateId = $this->_joined_template_dir . "#{$template_name}#{$cache_id}#{$compile_id}#{$caching}";
|
||||
@@ -1107,8 +1009,8 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public function _clearTemplateCache()
|
||||
{
|
||||
Smarty_Internal_Template::$isCacheTplObj = array();
|
||||
Smarty_Internal_Template::$tplObjCache = array();
|
||||
\Smarty_Internal_Template::$isCacheTplObj = array();
|
||||
\Smarty_Internal_Template::$tplObjCache = array();
|
||||
}
|
||||
|
||||
/**
|
@@ -26,7 +26,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
|
||||
/**
|
||||
* CacheResource Handler
|
||||
*
|
||||
* @var Smarty_CacheResource
|
||||
* @var \Smarty\Cacheresource\Base
|
||||
*/
|
||||
public $handler = null;
|
||||
|
||||
@@ -91,10 +91,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
|
||||
$this->compile_id = $_template->compile_id;
|
||||
$this->cache_id = $_template->cache_id;
|
||||
$this->source = $_template->source;
|
||||
if (!class_exists('Smarty_CacheResource', false)) {
|
||||
include SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php';
|
||||
}
|
||||
$this->handler = Smarty_CacheResource::load($_template->smarty);
|
||||
$this->handler = \Smarty\Cacheresource\Base::load($_template->smarty);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +124,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
|
||||
if ($this->isCached($_template)) {
|
||||
if ($_template->smarty->debugging) {
|
||||
if (!isset($_template->smarty->_debug)) {
|
||||
$_template->smarty->_debug = new Smarty_Internal_Debug();
|
||||
$_template->smarty->_debug = new \Smarty\Debug();
|
||||
}
|
||||
$_template->smarty->_debug->start_cache($_template);
|
||||
}
|
||||
@@ -163,13 +160,13 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
|
||||
} else {
|
||||
$this->valid = true;
|
||||
}
|
||||
if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_CURRENT
|
||||
if ($this->valid && $_template->caching === \Smarty\Smarty::CACHING_LIFETIME_CURRENT
|
||||
&& $_template->cache_lifetime >= 0 && time() > ($this->timestamp + $_template->cache_lifetime)
|
||||
) {
|
||||
// lifetime expired
|
||||
$this->valid = false;
|
||||
}
|
||||
if ($this->valid && $_template->compile_check === Smarty::COMPILECHECK_ON
|
||||
if ($this->valid && $_template->compile_check === \Smarty\Smarty::COMPILECHECK_ON
|
||||
&& $_template->source->getTimeStamp() > $this->timestamp
|
||||
) {
|
||||
$this->valid = false;
|
||||
@@ -204,7 +201,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
|
||||
} else {
|
||||
return $this->valid;
|
||||
}
|
||||
if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED
|
||||
if ($this->valid && $_template->caching === \Smarty\Smarty::CACHING_LIFETIME_SAVED
|
||||
&& $_template->cached->cache_lifetime >= 0
|
||||
&& (time() > ($_template->cached->timestamp + $_template->cached->cache_lifetime))
|
||||
) {
|
||||
|
@@ -97,7 +97,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
}
|
||||
if ($_template->smarty->debugging) {
|
||||
if (!isset($_template->smarty->_debug)) {
|
||||
$_template->smarty->_debug = new Smarty_Internal_Debug();
|
||||
$_template->smarty->_debug = new \Smarty\Debug();
|
||||
}
|
||||
$_template->smarty->_debug->start_render($_template);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
) {
|
||||
$this->compileTemplateSource($_smarty_tpl);
|
||||
$compileCheck = $_smarty_tpl->compile_check;
|
||||
$_smarty_tpl->compile_check = Smarty::COMPILECHECK_OFF;
|
||||
$_smarty_tpl->compile_check = \Smarty\Smarty::COMPILECHECK_OFF;
|
||||
$this->loadCompiledTemplate($_smarty_tpl);
|
||||
$_smarty_tpl->compile_check = $compileCheck;
|
||||
} else {
|
||||
@@ -149,7 +149,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
if ($_smarty_tpl->mustCompile) {
|
||||
$this->compileTemplateSource($_smarty_tpl);
|
||||
$compileCheck = $_smarty_tpl->compile_check;
|
||||
$_smarty_tpl->compile_check = Smarty::COMPILECHECK_OFF;
|
||||
$_smarty_tpl->compile_check = \Smarty\Smarty::COMPILECHECK_OFF;
|
||||
$this->loadCompiledTemplate($_smarty_tpl);
|
||||
$_smarty_tpl->compile_check = $compileCheck;
|
||||
}
|
||||
|
@@ -145,84 +145,6 @@ class TestInstall
|
||||
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";
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user