SMARTY_PLUGIN_MODIFIER,
'name' => 'lower',
'impl' => 'strtolower');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_MODIFIER,
'name' => 'upper',
'impl' => 'strtoupper');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_MODIFIER,
'name' => 'capitalize',
'impl' => 'ucwords');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_MODIFIER,
'name' => 'escape',
'impl' => 'smarty_mod_escape');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_MODIFIER,
'name' => 'truncate',
'impl' => 'smarty_mod_truncate');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_MODIFIER,
'name' => 'spacify',
'impl' => 'smarty_mod_spacify');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_MODIFIER,
'name' => 'date_format',
'impl' => 'smarty_mod_date_format');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_MODIFIER,
'name' => 'string_format',
'impl' => 'smarty_mod_string_format');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_MODIFIER,
'name' => 'replace',
'impl' => 'smarty_mod_replace');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_MODIFIER,
'name' => 'strip_tags',
'impl' => 'smarty_mod_strip_tags');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_MODIFIER,
'name' => 'default',
'impl' => 'smarty_mod_default');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_FUNCTION,
'name' => 'html_options',
'impl' => 'smarty_func_html_options');
$smarty_plugin_info['table'][] = array('type' => SMARTY_PLUGIN_FUNCTION,
'name' => 'html_select_date',
'impl' => 'smarty_func_html_select_date');
/*======================================================================*\
Function: smarty_mod_escape
Purpose: Escape the string according to escapement type
\*======================================================================*/
function smarty_mod_escape($string, $esc_type = 'html')
{
switch ($esc_type) {
case 'html':
return htmlspecialchars($string);
case 'url':
return urlencode($string);
default:
return $string;
}
}
/*======================================================================*\
Function: smarty_mod_truncate
Purpose: Truncate a string to a certain length if necessary,
optionally splitting in the middle of a word, and
appending the $etc string.
\*======================================================================*/
function smarty_mod_truncate($string, $length = 80, $etc = '...', $break_words = false)
{
if ($length == 0)
return '';
if (strlen($string) > $length) {
$length -= strlen($etc);
$fragment = substr($string, 0, $length+1);
if ($break_words)
$fragment = substr($fragment, 0, -1);
else
$fragment = preg_replace('/\s+(\S+)?$/', '', $fragment);
return $fragment.$etc;
} else
return $string;
}
/*======================================================================*\
Function: smarty_mod_spacify
Purpose: Insert a character (space by default) between every
character in the string.
\*======================================================================*/
function smarty_mod_spacify($string, $spacify_char = ' ')
{
return implode($spacify_char, preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
}
/*======================================================================*\
Function: smarty_mod_date_format
Purpose: Output formatted date
\*======================================================================*/
function smarty_mod_date_format($string, $format="%b %e, %Y")
{
return strftime($format, $string);
}
/*======================================================================*\
Function: smarty_mod_string_format
Purpose: Output formatted string
\*======================================================================*/
function smarty_mod_string_format($string, $format)
{
return sprintf($format, $string);
}
/*======================================================================*\
Function: smarty_mod_replace
Purpose: Perform simple search and replace
\*======================================================================*/
function smarty_mod_replace($string, $search, $replace)
{
return str_replace($search, $replace, $string);
}
/*======================================================================*\
Function: smarty_mod_strip_tags
Purpose: Strip HTML tags
\*======================================================================*/
function smarty_mod_strip_tags($string, $replace_with_space = true)
{
if ($replace_with_space)
return preg_replace('!<[^>]*?>!', ' ', $string);
else
return strip_tags($string);
}
/*======================================================================*\
Function: smarty_mod_default
Purpose: Output default value if string is empty
\*======================================================================*/
function smarty_mod_default($string, $default='')
{
if(empty($string))
return $default;
else
return $string;
}
/*======================================================================*\
Function: smarty_func_html_options
Purpose: Prints the list of