summaryrefslogtreecommitdiff
path: root/lib/smarty/plugins/modifier.replace.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/smarty/plugins/modifier.replace.php')
-rw-r--r--lib/smarty/plugins/modifier.replace.php34
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/smarty/plugins/modifier.replace.php b/lib/smarty/plugins/modifier.replace.php
index 4d71a6e..a98f5a4 100644
--- a/lib/smarty/plugins/modifier.replace.php
+++ b/lib/smarty/plugins/modifier.replace.php
@@ -1,33 +1,37 @@
<?php
/**
* Smarty plugin
- * @package Smarty
+ *
+ * @package Smarty
* @subpackage PluginsModifier
*/
-
/**
* Smarty replace modifier plugin
- *
- * Type: modifier<br>
- * Name: replace<br>
+ * Type: modifier
+ * Name: replace
* Purpose: simple search/replace
- *
- * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
- * @author Monte Ohrt <monte at ohrt dot com>
- * @author Uwe Tews
+ *
+ * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author Uwe Tews
+ *
* @param string $string input string
* @param string $search text to search for
* @param string $replace replacement text
- * @return string
+ *
+ * @return string
*/
function smarty_modifier_replace($string, $search, $replace)
{
+ static $is_loaded = false;
if (Smarty::$_MBSTRING) {
- require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
+ if (!$is_loaded) {
+ if (!is_callable('smarty_mb_str_replace')) {
+ include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
+ }
+ $is_loaded = true;
+ }
return smarty_mb_str_replace($search, $replace, $string);
}
-
return str_replace($search, $replace, $string);
-}
-
-?> \ No newline at end of file
+}