/lib/Haanga/Extension/Filter/Slugify.php

http://github.com/crodas/Haanga · PHP · 16 lines · 14 code · 2 blank · 0 comment · 2 complexity · bf974900930e1ca0489e425a66cfda25 MD5 · raw file

  1. <?php
  2. class Haanga_Extension_Filter_Slugify
  3. {
  4. static function generator($compiler, $args)
  5. {
  6. if (count($args) != 1) {
  7. $compiler->Error("slugify filter only needs one parameter");
  8. }
  9. $arg = hexec('strtolower', $args[0]);
  10. $arg = hexec('str_replace'," ","-",$arg);
  11. $arg = hexec('preg_replace',"/[^\d\w-_]/",'',$arg);
  12. return $arg;
  13. }
  14. }