当前位置: 首页>>代码示例>>PHP>>正文


PHP eZURLAliasML::translate方法代码示例

本文整理汇总了PHP中eZURLAliasML::translate方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURLAliasML::translate方法的具体用法?PHP eZURLAliasML::translate怎么用?PHP eZURLAliasML::translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZURLAliasML的用法示例。


在下文中一共展示了eZURLAliasML::translate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: headerOverrideArray

    static function headerOverrideArray( $uri )
    {
        $headerArray = array();

        if ( !eZHTTPHeader::enabled() )
        {
            return $headerArray;
        }

        $contentView = false;

        $uriString = eZURLAliasML::cleanURL( $uri->uriString() );

        // If content/view used, get url alias for node
        if ( strpos( $uriString, 'content/view/' ) === 0 )
        {
            $urlParts = explode( '/', $uriString );
            $nodeID = $urlParts[3];
            if ( !$nodeID )
            {
                return $headerArray;
            }

            $node = eZContentObjectTreeNode::fetch( $nodeID );
            if ( !$node )
            {
                return $headerArray;
            }

            $uriString = $node->pathWithNames();
            $contentView = true;
        }
        else
        {
            $uriCopy = clone $uri;
            eZURLAliasML::translate( $uriCopy );
            if ( strpos( $uriCopy->uriString(), 'content/view' ) === 0 )
            {
                $contentView = true;
            }
        }

        $uriString = '/' . eZURLAliasML::cleanURL( $uriString );
        $ini = eZINI::instance();

        foreach( $ini->variable( 'HTTPHeaderSettings', 'HeaderList' ) as $header )
        {
            foreach( $ini->variable( 'HTTPHeaderSettings', $header ) as $path => $value )
            {
                $path = '/' . eZURLAliasML::cleanURL( $path );
                if ( strlen( $path ) == 1 &&
                     ( !$contentView && ( $ini->variable( 'HTTPHeaderSettings', 'OnlyForContent' ) === 'enabled' ) ) &&
                     $uriString != '/' )
                {
                    continue;
                }

                if ( strpos( $uriString, $path ) === 0 )
                {
                    @list( $headerValue, $depth, $level ) = explode( ';', $value );

                    if ( $header == 'Expires' )
                    {
                        $headerValue = gmdate( 'D, d M Y H:i:s', time() + $headerValue ) . ' GMT';
                    }

                    if ( $depth === null )
                    {
                        $headerArray[$header] = $headerValue;
                    }
                    else
                    {
                        $pathLevel = count( explode( '/', $path ) );
                        $uriLevel = count( explode( '/', $uriString ) );
                        if ( $level === null )
                        {
                            if ( $uriLevel <= $pathLevel + $depth )
                            {
                                $headerArray[$header] = $headerValue;
                            }
                        }
                        else
                        {
                            if ( $uriLevel <= $pathLevel + $depth &&
                                 $uriLevel >= $pathLevel + $level )
                            {
                                $headerArray[$header] = $headerValue;
                            }
                        }
                    }
                }
            }
        }

        return $headerArray;
    }
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:96,代码来源:ezhttpheader.php

示例2: translate

    /**
     * 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
     */
    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;
//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:ezurlwildcard.php

示例3: fetchParentNodeByTranslation

    function fetchParentNodeByTranslation( $nodePathString )
    {
        // Strip extensions. E.g. .jpg
        $nodePathString = $this->fileBasename( $nodePathString );

        // Strip away last slash
        if ( strlen( $nodePathString ) > 0 and
             $nodePathString[strlen( $nodePathString ) - 1] == '/' )
        {
            $nodePathString = substr( $nodePathString, 0, strlen( $nodePathString ) - 1 );
        }

        $nodePathString = $this->splitLastPathElement( $nodePathString, $element );

        if ( strlen( $nodePathString ) == 0 )
            $nodePathString = '/';

        $nodePathString = eZURLAliasML::convertPathToAlias( $nodePathString );

        // Attempt to translate the URL to something like "/content/view/full/84".
        $translateResult = eZURLAliasML::translate( $nodePathString );

        // handle redirects
        while ( $nodePathString == 'error/301' )
        {
            $nodePathString = $translateResult;

            $translateResult = eZURLAliasML::translate( $nodePathString );
        }

        // Get the ID of the node (which is the last part of the translated path).
        if ( preg_match( "#^content/view/full/([0-9]+)$#", $nodePathString, $matches ) )
        {
            $nodeID = $matches[1];
            $this->appendLogEntry( "NodeID: $nodeID", 'CS:fetchParentNodeByTranslation' );
        }
        else
        {
            $this->appendLogEntry( "Root node", 'CS:fetchParentNodeByTranslation' );
            $nodeID = 2;
        }

        // Attempt to fetch the node.
        $node = eZContentObjectTreeNode::fetch( $nodeID );

        // Return the node.
        return $node;
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:48,代码来源:ezwebdavcontentserver.php

示例4: fetchParentNodeByTranslation

 /**
  * Attempts to fetch a possible node by translating the provided
  * string/path to a node-number.
  *
  * The last section of the path is removed before the actual
  * translation: hence, the PARENT node is returned.
  *
  * @param string $nodePathString Eg. 'Folder1/file1.txt'
  * @return eZContentObject Eg. the node of 'Folder1'
  */
 protected function fetchParentNodeByTranslation($nodePathString)
 {
     // Strip extensions. E.g. .jpg
     $nodePathString = $this->fileBasename($nodePathString);
     // Strip away last slash
     if (strlen($nodePathString) > 0 and $nodePathString[strlen($nodePathString) - 1] === '/') {
         $nodePathString = substr($nodePathString, 0, strlen($nodePathString) - 1);
     }
     $nodePathString = $this->splitLastPathElement($nodePathString, $element);
     if (strlen($nodePathString) === 0) {
         $nodePathString = '/';
     }
     $nodePathString = eZURLAliasML::convertPathToAlias($nodePathString);
     // Attempt to translate the URL to something like "/content/view/full/84".
     $translateResult = eZURLAliasML::translate($nodePathString);
     // handle redirects
     while ($nodePathString === 'error/301') {
         $nodePathString = $translateResult;
         $translateResult = eZURLAliasML::translate($nodePathString);
     }
     // Get the ID of the node (which is the last part of the translated path).
     if (preg_match("#^content/view/full/([0-9]+)\$#", $nodePathString, $matches)) {
         $nodeID = $matches[1];
     } else {
         $ini = eZINI::instance('webdav.ini');
         if ($ini->hasVariable('GeneralSettings', 'StartNode')) {
             $nodeID = $ini->variable('GeneralSettings', 'StartNode');
         }
     }
     // Attempt to fetch the node.
     $node = eZContentObjectTreeNode::fetch($nodeID);
     // Return the node.
     return $node;
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:44,代码来源:ezwebdavcontentbackend.php

示例5: redirect

 /**
  * Performs a redirection
  */
 protected function redirect()
 {
     $GLOBALS['eZRedirection'] = true;
     $ini = eZINI::instance();
     $automaticRedirect = true;
     if ($GLOBALS['eZDebugAllowed'] && ($redirUri = $ini->variable('DebugSettings', 'DebugRedirection')) !== 'disabled') {
         if ($redirUri == "enabled") {
             $automaticRedirect = false;
         } else {
             $uri = eZURI::instance(eZSys::requestURI());
             $uri->toBeginning();
             foreach ($ini->variableArray("DebugSettings", "DebugRedirection") as $redirUri) {
                 $redirUri = new eZURI($redirUri);
                 if ($redirUri->matchBase($uri)) {
                     $automaticRedirect = false;
                     break;
                 }
             }
         }
     }
     $redirectURI = eZSys::indexDir();
     $moduleRedirectUri = $this->module->redirectURI();
     if ($ini->variable('URLTranslator', 'Translation') === 'enabled' && eZURLAliasML::urlTranslationEnabledByUri(new eZURI($moduleRedirectUri))) {
         $translatedModuleRedirectUri = $moduleRedirectUri;
         if (eZURLAliasML::translate($translatedModuleRedirectUri, true)) {
             $moduleRedirectUri = $translatedModuleRedirectUri;
             if (strlen($moduleRedirectUri) > 0 && $moduleRedirectUri[0] !== '/') {
                 $moduleRedirectUri = '/' . $moduleRedirectUri;
             }
         }
     }
     if (preg_match('#^(\\w+:)|^//#', $moduleRedirectUri)) {
         $redirectURI = $moduleRedirectUri;
     } else {
         $leftSlash = strlen($redirectURI) > 0 && $redirectURI[strlen($redirectURI) - 1] === '/';
         $rightSlash = strlen($moduleRedirectUri) > 0 && $moduleRedirectUri[0] === '/';
         if (!$leftSlash && !$rightSlash) {
             // Both are without a slash, so add one
             $moduleRedirectUri = '/' . $moduleRedirectUri;
         } else {
             if ($leftSlash && $rightSlash) {
                 // Both are with a slash, so we remove one
                 $moduleRedirectUri = substr($moduleRedirectUri, 1);
             }
         }
         $redirectURI .= $moduleRedirectUri;
     }
     eZStaticCache::executeActions();
     eZDB::checkTransactionCounter();
     if ($automaticRedirect) {
         eZHTTPTool::redirect($redirectURI, array(), $this->module->redirectStatus());
     } else {
         // Make sure any errors or warnings are reported
         if ($ini->variable('DebugSettings', 'DisplayDebugWarnings') === 'enabled') {
             if (isset($GLOBALS['eZDebugError']) && $GLOBALS['eZDebugError']) {
                 eZAppendWarningItem(array('error' => array('type' => 'error', 'number' => 1, 'count' => $GLOBALS['eZDebugErrorCount']), 'identifier' => 'ezdebug-first-error', 'text' => ezpI18n::tr('index.php', 'Some errors occurred, see debug for more information.')));
             }
             if (isset($GLOBALS['eZDebugWarning']) && $GLOBALS['eZDebugWarning']) {
                 eZAppendWarningItem(array('error' => array('type' => 'warning', 'number' => 1, 'count' => $GLOBALS['eZDebugWarningCount']), 'identifier' => 'ezdebug-first-warning', 'text' => ezpI18n::tr('index.php', 'Some general warnings occured, see debug for more information.')));
             }
         }
         $tpl = eZTemplate::factory();
         $tpl->setVariable('site', $this->site);
         $tpl->setVariable('warning_list', !empty($this->warningList) ? $this->warningList : false);
         $tpl->setVariable('redirect_uri', eZURI::encodeURL($redirectURI));
         $templateResult = $tpl->fetch('design:redirect.tpl');
         eZDebug::addTimingPoint("Script end");
         eZDisplayResult($templateResult);
     }
     eZExecution::cleanExit();
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:74,代码来源:ezpkernelweb.php

示例6: foreach

         $uri->toBeginning();
         foreach ($redirUris as $redirUri) {
             $redirUri = new eZURI($redirUri);
             if ($redirUri->matchBase($uri)) {
                 $automatic_redir = false;
                 break;
             }
         }
     }
 }
 $redirectURI = eZSys::indexDir();
 $moduleRedirectUri = $module->redirectURI();
 $redirectStatus = $module->redirectStatus();
 $translatedModuleRedirectUri = $moduleRedirectUri;
 if ($ini->variable('URLTranslator', 'Translation') == 'enabled' && eZURLAliasML::urlTranslationEnabledByUri(new eZURI($moduleRedirectUri))) {
     if (eZURLAliasML::translate($translatedModuleRedirectUri, true)) {
         $moduleRedirectUri = $translatedModuleRedirectUri;
         if (strlen($moduleRedirectUri) > 0 and $moduleRedirectUri[0] != '/') {
             $moduleRedirectUri = '/' . $moduleRedirectUri;
         }
     }
 }
 if (preg_match('#^(\\w+:)|^//#', $moduleRedirectUri)) {
     $redirectURI = $moduleRedirectUri;
 } else {
     $leftSlash = false;
     $rightSlash = false;
     if (strlen($redirectURI) > 0 and $redirectURI[strlen($redirectURI) - 1] == '/') {
         $leftSlash = true;
     }
     if (strlen($moduleRedirectUri) > 0 and $moduleRedirectUri[0] == '/') {
开发者ID:legende91,项目名称:ez,代码行数:31,代码来源:index.php

示例7: foreach

                 if ($isValid) {
                     eZURL::setIsValid($linkID, false);
                 }
                 $cli->output($cli->stylize('warning', "invalid"));
             } else {
                 if (!$isValid) {
                     eZURL::setIsValid($linkID, true);
                 }
                 $cli->output($cli->stylize('success', "valid"));
             }
         } else {
             $cli->output("Couldn't check https protocol");
         }
     }
 } else {
     $translateResult = eZURLAliasML::translate($url);
     if (!$translateResult) {
         $isInternal = false;
         // Check if it is a valid internal link.
         foreach ($siteURLs as $siteURL) {
             $siteURL = preg_replace("/\\/\$/e", "", $siteURL);
             $fp = @fopen($siteURL . "/" . $url, "r");
             if (!$fp) {
                 // do nothing
             } else {
                 $isInternal = true;
                 fclose($fp);
             }
         }
         $translateResult = $isInternal;
     }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:31,代码来源:linkcheck.php

示例8: getNodeFromPath

    /**
     * @param string $nodePath
     * @param eZContentObjectTreeNode[] $publisherFolderNodes
     * @return eZContentObjectTreeNode
     */
    static protected function getNodeFromPath ( $nodePath, $publisherFolderNodes )
    {
        // Remove view parameters
        $nodePath = preg_replace( '#/\([^\)]+\)/.*$#', '', $nodePath );
        $node = false;

        foreach ( $publisherFolderNodes as $publisherFolderNode )
        {
            $nodeFullPath = '/' . $publisherFolderNode->attribute('url_alias') . '/' . $nodePath;
            $node = eZContentObjectTreeNode::fetchByURLPath( $nodeFullPath );

            if (!$node)
            {
                $node = eZContentObjectTreeNode::fetchByPath($nodeFullPath);

                if (!$node)
                {
                    $cleanableHref  = $nodeFullPath;
                    $aliasTranslate = eZURLAliasML::translate($cleanableHref);

                    while ( $aliasTranslate !== true && $aliasTranslate !== false )
                    {
                        $cleanableHref  = $aliasTranslate;
                        $aliasTranslate = eZURLAliasML::translate($cleanableHref);
                    }

                    if ( $aliasTranslate === true )
                    {
                        $lastSlashPosition = strrpos($cleanableHref, '/');

                        if( $lastSlashPosition !== false )
                            $node = eZContentObjectTreeNode::fetch(substr($cleanableHref, $lastSlashPosition+1));
                    }
                }

                if (!$node)
                {
                    $tabNodePath    = explode('/', substr($nodeFullPath, 1));
                    $remoteId       = end($tabNodePath);
                    $nodeRemote     = eZContentObjectTreeNode::fetchByRemoteID($remoteId);

                    if($nodeRemote && $publisherFolderNode)
                    {
                        $rootNodeID     = $publisherFolderNode->attribute('node_id');
                        $tabNodeRemote  = $nodeRemote->pathArray();
                        $nodeId         = $nodeRemote->attribute('node_id');

                        if(in_array($rootNodeID, $tabNodeRemote) && $rootNodeID != $nodeId)
                            $node = $nodeRemote;
                        /*******************************************************************************
                         * TODO : Delete after PF Refactor
                         *******************************************************************************/
                        else
                        {
                            $publisherFolderPathArray = $publisherFolderNode->pathArray();
                            foreach ( $nodeRemote->object()->assignedNodes() as $location )
                            {
                                if ( in_array( $publisherFolderPathArray[2], $location->pathArray() ) )
                                {
                                    $node = $location;
                                    break;
                                }
                            }
                        }
                        /*******************************************************************************
                         * TODO : END : Delete after PF Refactor
                         *******************************************************************************/
                    }
                }
            }
            
            if ($node instanceof eZContentObjectTreeNode)
                break;
        }


        // if we still do not have a node, we try to look in the old locations
        if ( !($node instanceof eZContentObjectTreeNode) )
        {
            $pfrLocation = null;

            if ( preg_match('#node_(?P<node_id>\d+)/?$#', $nodePath, $m) )
            {
                $nodeId = $m['node_id'];
                $pfrLocation = PfrLocation::fetchByNodeId( $nodeId );
            }
            else
            {
                $remoteId = basename( rtrim($nodePath, '/') );
                $pfrLocation = PfrLocation::fetchByRemoteId( $remoteId );
            }

            if ( $pfrLocation instanceof PfrLocation )
            {
                $node = $pfrLocation->node( $publisherFolderNodes );
//.........这里部分代码省略.........
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:101,代码来源:applicationFactory.php


注:本文中的eZURLAliasML::translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。