lib/ezutils/classes/ezuri.php
public static function transformURI( &$href, $ignoreIndexDir = false, $serverURL = null, $htmlEscape = true )
    {
        // When using ezroot, immediately stop if the linked element is external
        if ( $ignoreIndexDir )
        {
            // The initial / needs to be removed as it is not expected by the cluster handler,
            // but we must use a temp variable since $href is required later
            $trimmedHref = ltrim( $href, '/' );
            $modifiedHref = eZClusterFileHandler::instance()->applyServerUri( $trimmedHref );
            if ( $modifiedHref != $trimmedHref )
            {
                $href = $htmlEscape ? self::escapeHtmlTransformUri( $href ) : $href;
                return true;
            }
            unset( $modifiedHref );
        }

        if ( $serverURL === null )
        {
            $serverURL = self::$transformURIMode;
        }

        if ( preg_match( "#^[a-zA-Z0-9]+:#", $href ) || substr( $href, 0, 2 ) == '//' )
            return false;

        if ( strlen( $href ) == 0 )
            $href = '/';
        else if ( $href[0] == '#' )
        {
            $href = $htmlEscape ? htmlspecialchars( $href ) : $href;
            return true;
        }
        else if ( $href[0] != '/' )
        {
            $href = '/' . $href;
        }

        $sys = eZSys::instance();
        $dir = !$ignoreIndexDir ? $sys->indexDir() : $sys->wwwDir();
        $serverURL = $serverURL === 'full' ? $sys->serverURL() : '' ;
        $href = $serverURL . $dir . $href;
        if ( !$ignoreIndexDir )
        {
            $href = preg_replace( "#^(//)#", "/", $href );
            $href = preg_replace( "#(^.*)(/+)$#", "\$1", $href );
        }
        $href = $htmlEscape ? self::escapeHtmlTransformUri( $href ) : $href;

        if ( $href == "" )
            $href = "/";

        return true;
    }
public static function transformURI( &$href, $ignoreIndexDir = false, $serverURL = null, $htmlEscape = true )
    {
        // When using ezroot, immediately stop if the linked element is external
        if ( $ignoreIndexDir )
        {
            // The initial / needs to be removed as it is not expected by the cluster handler,
            // but we must use a temp variable since $href is required later
            $trimmedHref = ltrim( $href, '/' );
            $modifiedHref = eZClusterFileHandler::instance()->applyServerUri( $trimmedHref );
            if ( $modifiedHref != $trimmedHref )
            {
                $href = $htmlEscape ? self::escapeHtmlTransformUri( $href ) : $href;
                return true;
            }
            unset( $modifiedHref );
        }

        if ( $serverURL === null )
        {
            $serverURL = self::$transformURIMode;
        }

        if ( preg_match( "#^[a-zA-Z0-9]+:#", $href ) || substr( $href, 0, 2 ) == '//' )
            return false;

        if ( strlen( $href ) == 0 )
            $href = '/';
        else if ( $href[0] == '#' )
        {
            $href = $htmlEscape ? htmlspecialchars( $href ) : $href;
            return true;
        }
        else if ( $href[0] != '/' )
        {
            $href = '/' . $href;
        }

        $sys = eZSys::instance();
        $dir = !$ignoreIndexDir ? $sys->indexDir() : $sys->wwwDir();
        $serverURL = $serverURL === 'full' ? $sys->serverURL() : '' ;
        $href = $serverURL . $dir . $href;
        if ( !$ignoreIndexDir )
        {
            $href = preg_replace( "#^(//)#", "/", $href );
            $href = preg_replace( "#(^.*)(/+)$#", "\$1", $href );
        }
        $href = $htmlEscape ? self::escapeHtmlTransformUri( $href ) : $href;

        if ( $href == "" )
            $href = "/";

        return true;
    }
public static function transformURI ( & $ href , $ ignoreIndexDir = false , $ serverURL = null , $ htmlEscape = true ) { // When using ezroot, immediately stop if the linked element is external if ( $ ignoreIndexDir ) { // The initial / needs to be removed as it is not expected by the cluster handler, // but we must use a temp variable since $href is required later $ trimmedHref = ltrim ( $ href , '/' ) ; $ modifiedHref = eZClusterFileHandler :: instance ( ) -> applyServerUri ( $ trimmedHref ) ; if ( $ modifiedHref != $ trimmedHref ) { $ href = $ htmlEscape ? self :: escapeHtmlTransformUri ( $ href ) : $ href ; return true ; } unset ( $ modifiedHref ) ; } if ( $ serverURL === null ) { $ serverURL = self :: $ transformURIMode ; } if ( preg_match ( "#^[a-zA-Z0-9]+:#" , $ href ) || substr ( $ href , 0 , 2 ) == '//' ) return false ; if ( strlen ( $ href ) == 0 ) $ href = '/' ; else if ( $ href [ 0 ] == '#' ) { $ href = $ htmlEscape ? htmlspecialchars ( $ href ) : $ href ; return true ; } else if ( $ href [ 0 ] != '/' ) { $ href = '/' . $ href ; } $ sys = eZSys :: instance ( ) ; $ dir = ! $ ignoreIndexDir ? $ sys -> indexDir ( ) : $ sys -> wwwDir ( ) ; $ serverURL = $ serverURL === 'full' ? $ sys -> serverURL ( ) : '' ; $ href = $ serverURL . $ dir . $ href ; if ( ! $ ignoreIndexDir ) { $ href = preg_replace ( "#^(//)#" , "/" , $ href ) ; $ href = preg_replace ( "#(^.*)(/+)$#" , "\$1" , $ href ) ; } $ href = $ htmlEscape ? self :: escapeHtmlTransformUri ( $ href ) : $ href ; if ( $ href == "" ) $ href = "/" ; return true ; }
Implementation of an 'ezurl' template operator
Makes valid eZ Publish urls to use in links

@param string &$href
@param boolean $ignoreIndexDir
@param string $serverURL full|relative
@param boolean $htmlEscape true to html escape the result for HTML
@return string the link to use
Implementation of an ezurl template operator Makes valid eZ Publish urls to use in links