2009-03-22 16:09:05 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2010-07-06 20:00:41 +00:00
|
|
|
* Smarty plugin
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
|
|
|
* @package Smarty
|
2010-07-06 20:00:41 +00:00
|
|
|
* @subpackage PluginsModifier
|
|
|
|
*/
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-07-06 20:00:41 +00:00
|
|
|
* Smarty replace modifier plugin
|
2017-11-11 07:11:33 +01:00
|
|
|
* Type: modifier
|
|
|
|
* Name: replace
|
2010-07-06 20:00:41 +00:00
|
|
|
* Purpose: simple search/replace
|
2013-07-14 22:15:45 +00:00
|
|
|
*
|
2021-10-13 12:15:17 +02:00
|
|
|
* @link https://www.smarty.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
2013-07-14 22:15:45 +00:00
|
|
|
* @author Monte Ohrt <monte at ohrt dot com>
|
|
|
|
* @author Uwe Tews
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2011-09-16 14:19:56 +00:00
|
|
|
* @param string $string input string
|
|
|
|
* @param string $search text to search for
|
|
|
|
* @param string $replace replacement text
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return string
|
2010-07-06 20:00:41 +00:00
|
|
|
*/
|
2009-03-22 16:09:05 +00:00
|
|
|
function smarty_modifier_replace($string, $search, $replace)
|
|
|
|
{
|
2017-05-27 11:04:00 +02:00
|
|
|
static $is_loaded = false;
|
2011-12-18 18:20:09 +00:00
|
|
|
if (Smarty::$_MBSTRING) {
|
2017-05-27 11:04:00 +02:00
|
|
|
if (!$is_loaded) {
|
|
|
|
if (!is_callable('smarty_mb_str_replace')) {
|
2018-06-12 09:58:15 +02:00
|
|
|
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
|
2017-05-27 11:04:00 +02:00
|
|
|
}
|
|
|
|
$is_loaded = true;
|
2016-09-02 01:08:50 +02:00
|
|
|
}
|
2018-08-31 16:45:09 +02:00
|
|
|
return smarty_mb_str_replace($search, $replace, $string);
|
2011-03-01 19:47:44 +00:00
|
|
|
}
|
2013-07-14 22:15:45 +00:00
|
|
|
return str_replace($search, $replace, $string);
|
|
|
|
}
|