mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 11:54:26 +02:00
- update of mb support in plugins
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
08/10/2009
|
||||
- update of mb support in plugins
|
||||
|
||||
|
||||
08/09/2009
|
||||
- fixed problems with doublequoted strings at name attribute of {block} tag
|
||||
- bugfix at scope attribute of {append} tag
|
||||
|
@@ -20,8 +20,7 @@
|
||||
*/
|
||||
function smarty_modifier_lower($string)
|
||||
{
|
||||
$smarty = Smarty::instance();
|
||||
if ($smarty->has_mb) {
|
||||
if (function_exists('mb_strtolower')) {
|
||||
return mb_strtolower($string);
|
||||
} else {
|
||||
return strtolower($string);
|
||||
|
@@ -1,61 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty regex_replace modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: regex_replace<br>
|
||||
* Purpose: regular expression search/replace
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php regex_replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $
|
||||
* @param string $ |array
|
||||
* @param string $ |array
|
||||
* @return string
|
||||
*/
|
||||
* Smarty regex_replace modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: regex_replace<br>
|
||||
* Purpose: regular expression search/replace
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
|
||||
* regex_replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string
|
||||
* @param string|array
|
||||
* @param string|array
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_regex_replace($string, $search, $replace)
|
||||
{
|
||||
$smarty = Smarty::instance();
|
||||
|
||||
if (is_array($search)) {
|
||||
if(is_array($search)) {
|
||||
foreach($search as $idx => $s)
|
||||
$search[$idx] = _smarty_regex_replace_check($s);
|
||||
} else {
|
||||
$search = _smarty_regex_replace_check($search);
|
||||
}
|
||||
|
||||
if ($smarty->has_mb) {
|
||||
return mb_ereg_replace($search, $replace, $string);
|
||||
} else {
|
||||
return preg_replace($search, $replace, $string);
|
||||
}
|
||||
}
|
||||
|
||||
function _smarty_regex_replace_check($search)
|
||||
{
|
||||
if ($smarty->has_mb) {
|
||||
if (($pos = mb_strpos($search, "\0")) !== false)
|
||||
$search = mb_substr($search, 0, $pos);
|
||||
if (mb_preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (mb_strpos($match[1], 'e') !== false)) {
|
||||
if (($pos = strpos($search,"\0")) !== false)
|
||||
$search = substr($search,0,$pos);
|
||||
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
|
||||
/* remove eval-modifier from $search */
|
||||
$search = mb_substr($search, 0, - mb_strlen($match[1])) . mb_ereg_replace('![e\s]+!', '', $match[1]);
|
||||
}
|
||||
} else {
|
||||
if (($pos = strpos($search, "\0")) !== false)
|
||||
$search = substr($search, 0, $pos);
|
||||
if (mb_preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
|
||||
/* remove eval-modifier from $search */
|
||||
$search = substr($search, 0, - strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
|
||||
}
|
||||
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
|
||||
}
|
||||
return $search;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
@@ -38,8 +38,7 @@ function smarty_modifier_replace($string, $search, $replace)
|
||||
return $haystack;
|
||||
}
|
||||
}
|
||||
$smarty = Smarty::instance();
|
||||
if ($smarty->has_mb) {
|
||||
if (function_exists('mb_substr')) {
|
||||
return mb_str_replace($search, $replace, $string);
|
||||
} else {
|
||||
return str_replace($search, $replace, $string);
|
||||
|
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||
{
|
||||
$smarty = Smarty::instance();
|
||||
return implode($spacify_char, preg_split('//', $string, -1));
|
||||
}
|
||||
|
||||
|
@@ -25,12 +25,7 @@
|
||||
*/
|
||||
function smarty_modifier_strip($text, $replace = ' ')
|
||||
{
|
||||
$smarty = Smarty::instance();
|
||||
if ($smarty->has_mb) {
|
||||
return mb_ereg_replace("\s+", $replace, $text, 'p');
|
||||
} else {
|
||||
return preg_replace('!\s+!', $replace, $text);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -21,13 +21,8 @@
|
||||
*/
|
||||
function smarty_modifier_strip_tags($string, $replace_with_space = true)
|
||||
{
|
||||
$smarty = Smarty::instance();
|
||||
if ($replace_with_space) {
|
||||
if ($smarty->has_mb) {
|
||||
return mb_ereg_replace("<[^>]*?>", ' ', $string, 'p');
|
||||
} else {
|
||||
return preg_replace('!<[^>]*?>!', ' ', $string);
|
||||
}
|
||||
} else {
|
||||
return strip_tags($string);
|
||||
}
|
||||
|
@@ -20,8 +20,7 @@
|
||||
*/
|
||||
function smarty_modifier_upper($string)
|
||||
{
|
||||
$smarty = Smarty::instance();
|
||||
if ($smarty->has_mb) {
|
||||
if (function_exists('mb_strtoupper')) {
|
||||
return mb_strtoupper($string);
|
||||
} else {
|
||||
return strtoupper($string);
|
||||
|
Reference in New Issue
Block a user