Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
3 lars 1
<?php
2
    /**
3
     * Smarty plugin
4
     * @package Smarty
5
     * @subpackage plugins
6
     */
7
 
8
 
9
    /**
10
     * Smarty escape modifier plugin
11
     *
12
     * Type:     modifier<br>
13
     * Name:     str2url<br>
14
     * Purpose:  replace some charactes (e. g. deutsche Umlaute) with others, so that URLs do
15
     *          NOT contain illegal characters
16
     * @link http://smarty.php.net/manual/en/language.modifier.str2url.php
17
     *          str2url (Smarty online manual)
18
     * @author   Lars Tiefland <tiefland at weban dot de>
19
     * @param string
20
     * @return string
21
     */
22
    function smarty_modifier_str2url( $txt )
23
    {
24
        //$txt = strtolower( $txt );
25
        $txt = preg_replace( "/[\(\)\"”´`',\/\.]/", "-", $txt );
26
        $txt = str_replace( "Ä", "Ae", $txt );
27
        $txt = str_replace( "ä", "ae", $txt );
28
        $txt = str_replace( "Ö", "Oe", $txt );
29
        $txt = str_replace( "ö", "oe", $txt );
30
        $txt = str_replace( "Ü", "Ue", $txt );
31
        $txt = str_replace( "ü", "ue", $txt );
32
        $txt = str_replace( "á", "a", $txt );
33
        $txt = str_replace( "à", "a", $txt );
34
        $txt = str_replace( "â", "a", $txt );
35
        $txt = str_replace( "é", "e", $txt );
36
        $txt = str_replace( "è", "e", $txt );
37
        $txt = str_replace( "ê", "e", $txt );
38
        $txt = str_replace( "ë", "e", $txt );
39
        $txt = str_replace( "í", "i", $txt );
40
        $txt = str_replace( "ì", "i", $txt );
41
        $txt = str_replace( "î", "i", $txt );
42
        $txt = str_replace( "ï", "i", $txt );
43
        $txt = str_replace( "ó", "o", $txt );
44
        $txt = str_replace( "ò", "o", $txt );
45
        $txt = str_replace( "ô", "o", $txt );
46
        $txt = str_replace( "õ", "o", $txt );
47
        $txt = str_replace( " ", "-", $txt );
48
        $txt = str_replace( "%", "", $txt );
49
        $txt = str_replace( "ß", "ss", $txt );
50
        $txt = preg_replace( "/-{2,}/", "-", $txt );
51
        return $txt;
52
    }
53
 
54
    /* vim: set expandtab: */
55
 
56
?>