| 1: | <?php |
| 2: | /** |
| 3: | * Smarty plugin |
| 4: | * |
| 5: | * @package Smarty |
| 6: | * @subpackage PluginsModifier |
| 7: | */ |
| 8: | /** |
| 9: | * Smarty replace modifier plugin |
| 10: | * Type: modifier |
| 11: | * Name: replace |
| 12: | * Purpose: simple search/replace |
| 13: | * |
| 14: | * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) |
| 15: | * @author Monte Ohrt <monte at ohrt dot com> |
| 16: | * @author Uwe Tews |
| 17: | * |
| 18: | * @param string $string input string |
| 19: | * @param string $search text to search for |
| 20: | * @param string $replace replacement text |
| 21: | * |
| 22: | * @return string |
| 23: | */ |
| 24: | function smarty_modifier_replace($string, $search, $replace) |
| 25: | { |
| 26: | static $is_loaded = false; |
| 27: | if (Smarty::$_MBSTRING) { |
| 28: | if (!$is_loaded) { |
| 29: | if (!is_callable('smarty_mb_str_replace')) { |
| 30: | include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'; |
| 31: | } |
| 32: | $is_loaded = true; |
| 33: | } |
| 34: | return smarty_mb_str_replace($search, $replace, $string); |
| 35: | } |
| 36: | return str_replace($search, $replace, $string); |
| 37: | } |
| 38: |