mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
- bugfix plugins may not be loaded if {function} or {block} tags are executed in nocache mode
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
* @package Smarty
|
||||
* @subpackage PluginsBlock
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {textformat}{/textformat} block plugin
|
||||
* Type: block function
|
||||
@@ -20,7 +19,7 @@
|
||||
* - wrap_char - string ("\n")
|
||||
* - indent_char - string (" ")
|
||||
* - wrap_boundary - boolean (true)
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
||||
* (Smarty online manual)
|
||||
@@ -32,18 +31,16 @@
|
||||
*
|
||||
* @return string content re-formatted
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
function smarty_block_textformat($params, $content, Smarty_Internal_Template $template, &$repeat)
|
||||
{
|
||||
static $mb_wordwrap_loaded = false;
|
||||
if (is_null($content)) {
|
||||
return;
|
||||
}
|
||||
if (Smarty::$_MBSTRING && !$mb_wordwrap_loaded) {
|
||||
if (!is_callable('smarty_modifier_mb_wordwrap')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php');
|
||||
}
|
||||
$mb_wordwrap_loaded = true;
|
||||
if (Smarty::$_MBSTRING) {
|
||||
$template->_checkPlugins(array(array('function' => 'smarty_modifier_mb_wordwrap',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php')));
|
||||
}
|
||||
|
||||
$style = null;
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_checkboxes} function plugin
|
||||
* File: function.html_checkboxes.php
|
||||
@@ -37,18 +36,17 @@
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
* @version 1.0
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param object $template template object
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_function_html_checkboxes($params, $template)
|
||||
function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
$template->smarty->_cache[ '_required_sesc' ] = true;
|
||||
}
|
||||
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
|
||||
|
||||
$name = 'checkbox';
|
||||
$values = null;
|
||||
|
@@ -36,12 +36,10 @@
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*/
|
||||
function smarty_function_html_image($params, $template)
|
||||
function smarty_function_html_image($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
$template->smarty->_cache[ '_required_sesc' ] = true;
|
||||
}
|
||||
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
|
||||
|
||||
$alt = '';
|
||||
$file = '';
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_options} function plugin
|
||||
* Type: function
|
||||
@@ -34,13 +33,12 @@
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_function_html_options($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
$template->smarty->_cache[ '_required_sesc' ] = true;
|
||||
}
|
||||
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
|
||||
|
||||
$name = null;
|
||||
$values = null;
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_radios} function plugin
|
||||
* File: function.html_radios.php
|
||||
@@ -42,13 +41,12 @@
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_function_html_radios($params, $template)
|
||||
function smarty_function_html_radios($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
$template->smarty->_cache[ '_required_sesc' ] = true;
|
||||
}
|
||||
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
|
||||
|
||||
$name = 'radio';
|
||||
$values = null;
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_select_date} plugin
|
||||
* Type: function
|
||||
@@ -42,17 +41,12 @@
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*
|
||||
* @return string
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_function_html_select_date($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
$template->smarty->_cache[ '_required_sesc' ] = true;
|
||||
}
|
||||
if (!isset($template->smarty->_cache[ '_required_smt' ])) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
$template->smarty->_cache[ '_required_smt' ] = true;
|
||||
}
|
||||
$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;
|
||||
@@ -117,6 +111,8 @@ function smarty_function_html_select_date($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;
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_select_time} function plugin
|
||||
* Type: function
|
||||
@@ -23,17 +22,12 @@
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_make_timestamp()
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_function_html_select_time($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
$template->smarty->_cache[ '_required_sesc' ] = true;
|
||||
}
|
||||
if (!isset($template->smarty->_cache[ '_required_smt' ])) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
$template->smarty->_cache[ '_required_smt' ] = true;
|
||||
}
|
||||
$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";
|
||||
@@ -84,6 +78,8 @@ 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;
|
||||
|
@@ -25,7 +25,8 @@
|
||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
static $is_loaded1 = false;
|
||||
static $is_loaded_1 = false;
|
||||
static $is_loaded_2 = false;
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
@@ -123,11 +124,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
case 'hexentity':
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded1) {
|
||||
if (!$is_loaded_1) {
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
$is_loaded1 = true;
|
||||
}
|
||||
$is_loaded_1 = true;
|
||||
}
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
@@ -147,11 +148,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
case 'decentity':
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded1) {
|
||||
if (!$is_loaded_1) {
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
}
|
||||
$is_loaded1 = true;
|
||||
$is_loaded_1 = true;
|
||||
}
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
@@ -179,8 +180,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
|
||||
case 'mail':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!is_callable('smarty_mb_str_replace')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
if (!$is_loaded_2) {
|
||||
if (!is_callable('smarty_mb_str_replace')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
}
|
||||
$is_loaded_2 = true;
|
||||
}
|
||||
return smarty_mb_str_replace(array('@',
|
||||
'.'), array(' [AT] ',
|
||||
@@ -195,11 +199,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
// escape non-standard chars, such as ms document quotes
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded1) {
|
||||
if (!$is_loaded_1) {
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
}
|
||||
$is_loaded1 = true;
|
||||
$is_loaded_1 = true;
|
||||
}
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
if ($unicode >= 126) {
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
* Type: modifier
|
||||
@@ -15,21 +14,18 @@
|
||||
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param $compiler
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, $compiler)
|
||||
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
static $is_loaded = false;
|
||||
if (!$is_loaded) {
|
||||
if (!is_callable('smarty_literal_compiler_param')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
|
||||
}
|
||||
$is_loaded = true;
|
||||
}
|
||||
$compiler->template->_checkPlugins(array(array('function' => 'smarty_literal_compiler_param',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php')));
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
@@ -104,14 +100,14 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
||||
|
||||
// could not optimize |escape call, so fallback to regular plugin
|
||||
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'file' ] =
|
||||
$compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'file' ] =
|
||||
SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'function' ] =
|
||||
$compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'function' ] =
|
||||
'smarty_modifier_escape';
|
||||
} else {
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'file' ] =
|
||||
$compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'file' ] =
|
||||
SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'function' ] =
|
||||
$compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'function' ] =
|
||||
'smarty_modifier_escape';
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user