added url_title function to HTML class
Showing
1 changed file
with
42 additions
and
0 deletions
| ... | @@ -265,6 +265,48 @@ function form_linked_dropdown($name = '', $parent = '', $options = array(), $par | ... | @@ -265,6 +265,48 @@ function form_linked_dropdown($name = '', $parent = '', $options = array(), $par |
| 265 | return $form; | 265 | return $form; |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | if ( ! function_exists('url_title')) | ||
| 269 | { | ||
| 270 | function url_title($str, $separator = 'dash', $lowercase = FALSE) | ||
| 271 | { | ||
| 272 | if ($separator == 'dash') | ||
| 273 | { | ||
| 274 | $search = '_'; | ||
| 275 | $replace = '-'; | ||
| 276 | } | ||
| 277 | else | ||
| 278 | { | ||
| 279 | $search = '-'; | ||
| 280 | $replace = '_'; | ||
| 281 | } | ||
| 282 | |||
| 283 | $trans = array( | ||
| 284 | '&\#\d+?;' => '', | ||
| 285 | '&\S+?;' => '', | ||
| 286 | '\s+' => $replace, | ||
| 287 | '[^a-z0-9\-\._]' => '', | ||
| 288 | $replace.'+' => $replace, | ||
| 289 | $replace.'$' => $replace, | ||
| 290 | '^'.$replace => $replace, | ||
| 291 | '\.+$' => '' | ||
| 292 | ); | ||
| 293 | |||
| 294 | $str = strip_tags($str); | ||
| 295 | |||
| 296 | foreach ($trans as $key => $val) | ||
| 297 | { | ||
| 298 | $str = preg_replace("#".$key."#i", $val, $str); | ||
| 299 | } | ||
| 300 | |||
| 301 | if ($lowercase === TRUE) | ||
| 302 | { | ||
| 303 | $str = strtolower($str); | ||
| 304 | } | ||
| 305 | |||
| 306 | return trim(stripslashes($str)); | ||
| 307 | } | ||
| 308 | } | ||
| 309 | |||
| 268 | class Vars { | 310 | class Vars { |
| 269 | 311 | ||
| 270 | public static $prefixes = Array( | 312 | public static $prefixes = Array( | ... | ... |
-
Please register or sign in to post a comment