mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
- performance require_once should be called only once for shared plugins https://github.com/smarty-php/smarty/issues/280
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
===== 3.1.31-dev ===== (xx.xx.xx)
|
||||
01.09.2016
|
||||
- performance require_once should be called only once for shared plugins https://github.com/smarty-php/smarty/issues/280
|
||||
|
||||
26.08.2016
|
||||
- bugfix change of 23.08.2016 failed on linux when use_include_path = true
|
||||
|
||||
|
@@ -114,7 +114,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.31-dev/7';
|
||||
const SMARTY_VERSION = '3.1.31-dev/8';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
|
@@ -38,6 +38,9 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
if (is_null($content)) {
|
||||
return;
|
||||
}
|
||||
if (Smarty::$_MBSTRING && !is_callable('smarty_mb_wordwrap')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
|
||||
}
|
||||
|
||||
$style = null;
|
||||
$indent = 0;
|
||||
@@ -92,7 +95,6 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
}
|
||||
// wordwrap sentences
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
|
||||
$_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
} else {
|
||||
$_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
|
@@ -45,7 +45,9 @@
|
||||
*/
|
||||
function smarty_function_html_checkboxes($params, $template)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
if (!is_callable('smarty_function_escape_special_chars')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
}
|
||||
|
||||
$name = 'checkbox';
|
||||
$values = null;
|
||||
|
@@ -38,7 +38,9 @@
|
||||
*/
|
||||
function smarty_function_html_image($params, $template)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
if (!is_callable('smarty_function_escape_special_chars')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
}
|
||||
|
||||
$alt = '';
|
||||
$file = '';
|
||||
|
@@ -35,7 +35,9 @@
|
||||
*/
|
||||
function smarty_function_html_options($params)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
if (!is_callable('smarty_function_escape_special_chars')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
}
|
||||
|
||||
$name = null;
|
||||
$values = null;
|
||||
|
@@ -45,7 +45,9 @@
|
||||
*/
|
||||
function smarty_function_html_radios($params, $template)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
if (!is_callable('smarty_function_escape_special_chars')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
}
|
||||
|
||||
$name = 'radio';
|
||||
$values = null;
|
||||
|
@@ -6,15 +6,6 @@
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
|
||||
/**
|
||||
* Smarty {html_select_date} plugin
|
||||
* Type: function<br>
|
||||
@@ -52,6 +43,12 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
*/
|
||||
function smarty_function_html_select_date($params)
|
||||
{
|
||||
if (!is_callable('smarty_function_escape_special_chars')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
}
|
||||
if (!is_callable('smarty_make_timestamp')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
}
|
||||
// generate timestamps used for month names only
|
||||
static $_month_timestamps = null;
|
||||
static $_current_year = null;
|
||||
|
@@ -6,15 +6,6 @@
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
|
||||
/**
|
||||
* Smarty {html_select_time} function plugin
|
||||
* Type: function<br>
|
||||
@@ -33,6 +24,12 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
*/
|
||||
function smarty_function_html_select_time($params)
|
||||
{
|
||||
if (!is_callable('smarty_function_escape_special_chars')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
}
|
||||
if (!is_callable('smarty_make_timestamp')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
}
|
||||
$prefix = "Time_";
|
||||
$field_array = null;
|
||||
$field_separator = "\n";
|
||||
|
@@ -32,10 +32,6 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
||||
if ($format === null) {
|
||||
$format = Smarty::$_DATE_FORMAT;
|
||||
}
|
||||
/**
|
||||
* require_once the {@link shared.make_timestamp.php} plugin
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
|
||||
$timestamp = smarty_make_timestamp($string);
|
||||
} elseif ($default_date != '') {
|
||||
@@ -44,7 +40,7 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
||||
return;
|
||||
}
|
||||
if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) {
|
||||
if (DIRECTORY_SEPARATOR == '\\') {
|
||||
if (Smarty::$_IS_WINDOWS) {
|
||||
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
|
||||
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
|
||||
if (strpos($format, '%e') !== false) {
|
||||
|
@@ -116,7 +116,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
case 'hexentity':
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
}
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
|
||||
@@ -135,7 +137,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
case 'decentity':
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
}
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
@@ -158,8 +162,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
|
||||
case 'mail':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
|
||||
if (!is_callable('smarty_mb_str_replace')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
}
|
||||
return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
|
||||
}
|
||||
// no MBString fallback
|
||||
@@ -169,7 +174,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
// escape non-standard chars, such as ms document quotes
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
}
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
if ($unicode >= 126) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
|
@@ -25,8 +25,9 @@
|
||||
function smarty_modifier_replace($string, $search, $replace)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
|
||||
if (!is_callable('smarty_mb_str_replace')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
}
|
||||
return smarty_mb_str_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
|
@@ -6,11 +6,6 @@
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
|
||||
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
* Type: modifier<br>
|
||||
@@ -28,6 +23,9 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
|
||||
function smarty_modifiercompiler_escape($params, $compiler)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
if (!is_callable('smarty_literal_compiler_param')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
|
||||
}
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
|
Reference in New Issue
Block a user