kernel/classes/ezurlwildcard.php
public static function translate( &$uri )
    {
        $result = false;

        // get uri string
        $uriString = ( $uri instanceof eZURI ) ? $uri->elements() : $uri;
        $uriString = eZURLAliasML::cleanURL( $uriString );

        eZDebugSetting::writeDebug( 'kernel-urltranslator', "input uriString: '$uriString'", __METHOD__ );

        if ( !$wildcards = self::wildcardsIndex() )
        {
            eZDebugSetting::writeDebug( 'kernel-urltranslator', "no match callbacks", __METHOD__ );
            return false;
        }

        $ini = eZINI::instance();
        $iteration = $ini->variable( 'URLTranslator', 'MaximumWildcardIterations' );

        eZDebugSetting::writeDebug( 'kernel-urltranslator', "MaximumWildcardIterations: '$iteration'", __METHOD__ );

        // translate
        $urlTranslated = false;
        while ( !$urlTranslated && $iteration >= 0 )
        {
            foreach ( $wildcards as $wildcardNum => $wildcard )
            {
                if ( preg_match( $wildcard, $uriString ) )
                {
                    eZDebugSetting::writeDebug( 'kernel-urltranslator', "matched with: '$wildcard'", __METHOD__ );

                    // get new $uriString from wildcard
                    self::translateWithCache( $wildcardNum, $uriString, $wildcardInfo, $wildcard );

                    eZDebugSetting::writeDebug( 'kernel-urltranslator', "new uri string: '$uriString'", __METHOD__ );

                    // optimization: don't try further translation if wildcard type is 'forward'
                    if ( $wildcardInfo['type'] == self::TYPE_FORWARD )
                    {
                        $urlTranslated = true;
                        break;
                    }

                    // try to tranlsate
                    if ( $urlTranslated = eZURLAliasML::translate( $uriString ) )
                    {
                        // success
                        eZDebugSetting::writeDebug( 'kernel-urltranslator', "uri is translated to '$uriString' with result '$urlTranslated'", __METHOD__ );
                        break;
                    }

                    eZDebugSetting::writeDebug( 'kernel-urltranslator', "uri is not translated, trying another wildcard", __METHOD__ );

                    // translation failed. Try to match new $uriString with another wildcard.
                    --$iteration;
                    continue 2;
                }
            }

            // we here if non of the wildcards is matched
            break;
        }

        // check translation result
        // NOTE: 'eZURLAliasML::translate'(see above) can return 'true', 'false' or new url(in case of 'error/301').
        //       $urlTranslated can also be 'false' if no wildcard is matched.
        if ( $urlTranslated )
        {
            // check wildcard type and set appropriate $result and $uriString
            $wildcardType = $wildcardInfo['type'];

            eZDebugSetting::writeDebug( 'kernel-urltranslator', "wildcard type: $wildcardType", __METHOD__ );

            switch ( $wildcardType )
            {
                case self::TYPE_FORWARD:
                {
                    // do redirect:
                    //   => set $result to translated uri
                    //   => set uri string to a MOVED PERMANENTLY HTTP code
                    $result = $uriString;
                    $uriString = 'error/301';
                }
                break;

                default:
                {
                    eZDebug::writeError( 'Invalid wildcard type.', __METHOD__ );
                    // no break, using eZURLWildcard::TYPE_DIRECT as fallback
                }
                case self::TYPE_DIRECT:
                {
                    $result = $urlTranslated;
                    // $uriString already has correct value
                    break;
                }
            }
        }
        else
        {
            // we are here if:
            // - input url is not matched with any wildcard;
            // - url is matched with wildcard and:
            //   - points to module
            //   - invalide url
            eZDebugSetting::writeDebug( 'kernel-urltranslator', "wildcard is not translated", __METHOD__ );
            $result = false;
        }

        // set value back to $uri
        if ( $uri instanceof eZURI )
        {
            $uri->setURIString( $uriString, false );
        }
        else
        {
            $uri = $uriString;
        }

        eZDebugSetting::writeDebug( 'kernel-urltranslator', "finished with url '$uriString' and result '$result'", __METHOD__ );

        return $result;
    }
public static function translate( &$uri )
    {
        $result = false;

        // get uri string
        $uriString = ( $uri instanceof eZURI ) ? $uri->elements() : $uri;
        $uriString = eZURLAliasML::cleanURL( $uriString );

        eZDebugSetting::writeDebug( 'kernel-urltranslator', "input uriString: '$uriString'", __METHOD__ );

        if ( !$wildcards = self::wildcardsIndex() )
        {
            eZDebugSetting::writeDebug( 'kernel-urltranslator', "no match callbacks", __METHOD__ );
            return false;
        }

        $ini = eZINI::instance();
        $iteration = $ini->variable( 'URLTranslator', 'MaximumWildcardIterations' );

        eZDebugSetting::writeDebug( 'kernel-urltranslator', "MaximumWildcardIterations: '$iteration'", __METHOD__ );

        // translate
        $urlTranslated = false;
        while ( !$urlTranslated && $iteration >= 0 )
        {
            foreach ( $wildcards as $wildcardNum => $wildcard )
            {
                if ( preg_match( $wildcard, $uriString ) )
                {
                    eZDebugSetting::writeDebug( 'kernel-urltranslator', "matched with: '$wildcard'", __METHOD__ );

                    // get new $uriString from wildcard
                    self::translateWithCache( $wildcardNum, $uriString, $wildcardInfo, $wildcard );

                    eZDebugSetting::writeDebug( 'kernel-urltranslator', "new uri string: '$uriString'", __METHOD__ );

                    // optimization: don't try further translation if wildcard type is 'forward'
                    if ( $wildcardInfo['type'] == self::TYPE_FORWARD )
                    {
                        $urlTranslated = true;
                        break;
                    }

                    // try to tranlsate
                    if ( $urlTranslated = eZURLAliasML::translate( $uriString ) )
                    {
                        // success
                        eZDebugSetting::writeDebug( 'kernel-urltranslator', "uri is translated to '$uriString' with result '$urlTranslated'", __METHOD__ );
                        break;
                    }

                    eZDebugSetting::writeDebug( 'kernel-urltranslator', "uri is not translated, trying another wildcard", __METHOD__ );

                    // translation failed. Try to match new $uriString with another wildcard.
                    --$iteration;
                    continue 2;
                }
            }

            // we here if non of the wildcards is matched
            break;
        }

        // check translation result
        // NOTE: 'eZURLAliasML::translate'(see above) can return 'true', 'false' or new url(in case of 'error/301').
        //       $urlTranslated can also be 'false' if no wildcard is matched.
        if ( $urlTranslated )
        {
            // check wildcard type and set appropriate $result and $uriString
            $wildcardType = $wildcardInfo['type'];

            eZDebugSetting::writeDebug( 'kernel-urltranslator', "wildcard type: $wildcardType", __METHOD__ );

            switch ( $wildcardType )
            {
                case self::TYPE_FORWARD:
                {
                    // do redirect:
                    //   => set $result to translated uri
                    //   => set uri string to a MOVED PERMANENTLY HTTP code
                    $result = $uriString;
                    $uriString = 'error/301';
                }
                break;

                default:
                {
                    eZDebug::writeError( 'Invalid wildcard type.', __METHOD__ );
                    // no break, using eZURLWildcard::TYPE_DIRECT as fallback
                }
                case self::TYPE_DIRECT:
                {
                    $result = $urlTranslated;
                    // $uriString already has correct value
                    break;
                }
            }
        }
        else
        {
            // we are here if:
            // - input url is not matched with any wildcard;
            // - url is matched with wildcard and:
            //   - points to module
            //   - invalide url
            eZDebugSetting::writeDebug( 'kernel-urltranslator', "wildcard is not translated", __METHOD__ );
            $result = false;
        }

        // set value back to $uri
        if ( $uri instanceof eZURI )
        {
            $uri->setURIString( $uriString, false );
        }
        else
        {
            $uri = $uriString;
        }

        eZDebugSetting::writeDebug( 'kernel-urltranslator', "finished with url '$uriString' and result '$result'", __METHOD__ );

        return $result;
    }
public static function translate ( & $ uri ) { $ result = false ; // get uri string $ uriString = ( $ uri instanceof eZURI ) ? $ uri -> elements ( ) : $ uri ; $ uriString = eZURLAliasML :: cleanURL ( $ uriString ) ; eZDebugSetting :: writeDebug ( 'kernel-urltranslator' , "input uriString: '$uriString'" , __METHOD__ ) ; if ( ! $ wildcards = self :: wildcardsIndex ( ) ) { eZDebugSetting :: writeDebug ( 'kernel-urltranslator' , "no match callbacks" , __METHOD__ ) ; return false ; } $ ini = eZINI :: instance ( ) ; $ iteration = $ ini -> variable ( 'URLTranslator' , 'MaximumWildcardIterations' ) ; eZDebugSetting :: writeDebug ( 'kernel-urltranslator' , "MaximumWildcardIterations: '$iteration'" , __METHOD__ ) ; // translate $ urlTranslated = false ; while ( ! $ urlTranslated && $ iteration >= 0 ) { foreach ( $ wildcards as $ wildcardNum => $ wildcard ) { if ( preg_match ( $ wildcard , $ uriString ) ) { eZDebugSetting :: writeDebug ( 'kernel-urltranslator' , "matched with: '$wildcard'" , __METHOD__ ) ; // get new $uriString from wildcard self :: translateWithCache ( $ wildcardNum , $ uriString , $ wildcardInfo , $ wildcard ) ; eZDebugSetting :: writeDebug ( 'kernel-urltranslator' , "new uri string: '$uriString'" , __METHOD__ ) ; // optimization: don't try further translation if wildcard type is 'forward' if ( $ wildcardInfo [ 'type' ] == self :: TYPE_FORWARD ) { $ urlTranslated = true ; break ; } // try to tranlsate if ( $ urlTranslated = eZURLAliasML :: translate ( $ uriString ) ) { // success eZDebugSetting :: writeDebug ( 'kernel-urltranslator' , "uri is translated to '$uriString' with result '$urlTranslated'" , __METHOD__ ) ; break ; } eZDebugSetting :: writeDebug ( 'kernel-urltranslator' , "uri is not translated, trying another wildcard" , __METHOD__ ) ; // translation failed. Try to match new $uriString with another wildcard. -- $ iteration ; continue 2 ; } } // we here if non of the wildcards is matched break ; } // check translation result // NOTE: 'eZURLAliasML::translate'(see above) can return 'true', 'false' or new url(in case of 'error/301'). //       $urlTranslated can also be 'false' if no wildcard is matched. if ( $ urlTranslated ) { // check wildcard type and set appropriate $result and $uriString $ wildcardType = $ wildcardInfo [ 'type' ] ; eZDebugSetting :: writeDebug ( 'kernel-urltranslator' , "wildcard type: $wildcardType" , __METHOD__ ) ; switch ( $ wildcardType ) { case self :: TYPE_FORWARD : { // do redirect: //   => set $result to translated uri //   => set uri string to a MOVED PERMANENTLY HTTP code $ result = $ uriString ; $ uriString = 'error/301' ; } break ; default : { eZDebug :: writeError ( 'Invalid wildcard type.' , __METHOD__ ) ; // no break, using eZURLWildcard::TYPE_DIRECT as fallback } case self :: TYPE_DIRECT : { $ result = $ urlTranslated ; // $uriString already has correct value break ; } } } else { // we are here if: // - input url is not matched with any wildcard; // - url is matched with wildcard and: //   - points to module //   - invalide url eZDebugSetting :: writeDebug ( 'kernel-urltranslator' , "wildcard is not translated" , __METHOD__ ) ; $ result = false ; } // set value back to $uri if ( $ uri instanceof eZURI ) { $ uri -> setURIString ( $ uriString , false ) ; } else { $ uri = $ uriString ; } eZDebugSetting :: writeDebug ( 'kernel-urltranslator' , "finished with url '$uriString' and result '$result'" , __METHOD__ ) ; return $ result ; }
Transforms the URI if there exists an alias for it.

@param eZURI|string $uri
@return mixed The translated URI if the resource has moved, or true|false
if translation was (un)successful
Transforms the URI if there exists an alias for it .