Subversion-Projekte lars-tiefland.php_share

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?php
    /**
     * Smarty plugin
     * @package Smarty
     * @subpackage plugins
     */


    /**
     * Smarty escape modifier plugin
     *
     * Type:     modifier<br>
     * Name:     str2url<br>
     * Purpose:  replace some charactes (e. g. deutsche Umlaute) with others, so that URLs do 
     *          NOT contain illegal characters
     * @link http://smarty.php.net/manual/en/language.modifier.str2url.php
     *          str2url (Smarty online manual)
     * @author   Lars Tiefland <tiefland at weban dot de>
     * @param string
     * @return string
     */
    function smarty_modifier_str2url( $txt )
    {
        //$txt = strtolower( $txt );
        $txt = preg_replace( "/[\(\)\"”´`',\/\.]/", "-", $txt );
        $txt = str_replace( "Ä", "Ae", $txt );
        $txt = str_replace( "ä", "ae", $txt );
        $txt = str_replace( "Ö", "Oe", $txt );
        $txt = str_replace( "ö", "oe", $txt );
        $txt = str_replace( "Ü", "Ue", $txt );
        $txt = str_replace( "ü", "ue", $txt );
        $txt = str_replace( "á", "a", $txt );
        $txt = str_replace( "à", "a", $txt );
        $txt = str_replace( "â", "a", $txt );
        $txt = str_replace( "é", "e", $txt );
        $txt = str_replace( "è", "e", $txt );
        $txt = str_replace( "ê", "e", $txt );
        $txt = str_replace( "ë", "e", $txt );
        $txt = str_replace( "í", "i", $txt );
        $txt = str_replace( "ì", "i", $txt );
        $txt = str_replace( "î", "i", $txt );
        $txt = str_replace( "ï", "i", $txt );
        $txt = str_replace( "ó", "o", $txt );
        $txt = str_replace( "ò", "o", $txt );
        $txt = str_replace( "ô", "o", $txt );
        $txt = str_replace( "õ", "o", $txt );
        $txt = str_replace( " ", "-", $txt );
        $txt = str_replace( "%", "", $txt );
        $txt = str_replace( "ß", "ss", $txt );
        $txt = preg_replace( "/-{2,}/", "-", $txt );
        return $txt;
    }

    /* vim: set expandtab: */

?>