|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
BenFromTokyo Smarty Rookie
Joined: 15 Oct 2004 Posts: 12 Location: Japan
|
Posted: Fri Dec 17, 2004 4:57 am Post subject: how to submit a plugin ?? [mb_trim trim modifiefor Japanese] |
|
|
Hi all,
I would like to submit this modifier into the wiki plugins .
I did not have time to find out how to do that...
cheers,
Ben
Code: |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty plugin
*
* Type: modifier<br>
* Name: mb_trim<br>
* Date: Dec 17, 2004
* Purpose: does the same as trim() but also delete zenkaku space ' '
* Input:<br>
* - str = str to replace
* Example: {$text|mb_trim}
* @link http://www.php.net/manual/en/function.trim.php
* trim php function (mb_trim does not exists for now)
* @version 1.0
* @author Benjamin layet <benjamin@moonfactory.co.jp>
* @param string
* @return string
*/
function smarty_modifier_mb_trim($str)
{
if(!is_string($str))
{
return $str;
}
$str = trim($str);
$zenspace = mb_convert_kana(' ', 'S');
if($zenspace == substr($str,-2))
{
$str = substr($str, 0 , -2);
$str = smarty_modifier_mb_trim($str);
}
if($zenspace == substr($str,0,2))
{
$str = substr($str, 2);
$str = smarty_modifier_mb_trim($str);
}
return $str;
}
?>
|
|
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|