mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-02 21:31:48 +01: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:
@@ -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 . ';';
|
||||
|
||||
Reference in New Issue
Block a user