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;
    }