fusionpbx/resources/templates/engine/smarty/plugins/modifier.replace.php

38 lines
999 B
PHP
Raw Normal View History

2013-11-09 21:02:56 +01:00
<?php
/**
* Smarty plugin
2018-11-07 08:18:14 +01:00
*
* @package Smarty
2013-11-09 21:02:56 +01:00
* @subpackage PluginsModifier
*/
/**
* Smarty replace modifier plugin
2018-11-07 08:18:14 +01:00
* Type: modifier
* Name: replace
2013-11-09 21:02:56 +01:00
* Purpose: simple search/replace
*
2018-11-07 08:18:14 +01:00
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
2013-11-09 21:02:56 +01:00
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
2018-11-07 08:18:14 +01:00
*
2013-11-09 21:02:56 +01:00
* @param string $string input string
* @param string $search text to search for
* @param string $replace replacement text
2018-11-07 08:18:14 +01:00
*
2013-11-09 21:02:56 +01:00
* @return string
*/
function smarty_modifier_replace($string, $search, $replace)
{
2018-11-07 08:18:14 +01:00
static $is_loaded = false;
2013-11-09 21:02:56 +01:00
if (Smarty::$_MBSTRING) {
2018-11-07 08:18:14 +01:00
if (!$is_loaded) {
if (!is_callable('smarty_mb_str_replace')) {
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
}
$is_loaded = true;
}
2013-11-09 21:02:56 +01:00
return smarty_mb_str_replace($search, $replace, $string);
}
return str_replace($search, $replace, $string);
}