0d2e1302 by Kevin Burton

added url_title function to HTML class

1 parent 4b05591d
......@@ -265,6 +265,48 @@ function form_linked_dropdown($name = '', $parent = '', $options = array(), $par
return $form;
}
if ( ! function_exists('url_title'))
{
function url_title($str, $separator = 'dash', $lowercase = FALSE)
{
if ($separator == 'dash')
{
$search = '_';
$replace = '-';
}
else
{
$search = '-';
$replace = '_';
}
$trans = array(
'&\#\d+?;' => '',
'&\S+?;' => '',
'\s+' => $replace,
'[^a-z0-9\-\._]' => '',
$replace.'+' => $replace,
$replace.'$' => $replace,
'^'.$replace => $replace,
'\.+$' => ''
);
$str = strip_tags($str);
foreach ($trans as $key => $val)
{
$str = preg_replace("#".$key."#i", $val, $str);
}
if ($lowercase === TRUE)
{
$str = strtolower($str);
}
return trim(stripslashes($str));
}
}
class Vars {
public static $prefixes = Array(
......