SanitizeUrl.php

Go to the documentation of this file.
00001 <?php
00002 
00033 class Robo47_Filter_SanitizeUrl implements Zend_Filter_Interface
00034 {
00035 
00041     public function filter($value)
00042     {
00043         // all signs to replace
00044         $search = array('ä' => 'ae',
00045             'ö' => 'oe',
00046             'ü' => 'ue',
00047             'ß' => 's',
00048             'Ä' => 'Ae',
00049             'Ö' => 'Oe',
00050             'Ü' => 'Ue',
00051             'ß' => 's',
00052             ' ' => '-');
00053 
00054         // replace them
00055         $value = str_replace(array_keys($search), $search, $value);
00056 
00057         // remove everything which is not a-z 0-9 or - or .
00058         $value = preg_replace('~[^a-z0-9\.\-_]~i', '-', $value);
00059 
00060         // remove double -
00061         $value = preg_replace('~(-)+~', '-', $value);
00062 
00063         // remove trailing -
00064         return trim($value, '-');
00065     }
00066 }