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


PHP eZURLAliasML::fetchByPath方法代码示例

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


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

示例1:

 if (count($existingElements) > 0) {
     $parentID = (int) $existingElements[0]->attribute('parent');
     $linkID = (int) $existingElements[0]->attribute('id');
 }
 if ($parentIsRoot) {
     $parentID = 0;
     // Start from the top
 }
 $mask = $language->attribute('id');
 $obj = $node->object();
 $alwaysMask = $obj->attribute('language_mask') & 1;
 $mask |= $alwaysMask;
 $origAliasText = $aliasText;
 $result = eZURLAliasML::storePath($aliasText, 'eznode:' . $node->attribute('node_id'), $language, $linkID, $alwaysMask, $parentID, true, false, false, $aliasRedirects);
 if ($result['status'] === eZURLAliasML::LINK_ALREADY_TAKEN) {
     $lastElements = eZURLAliasML::fetchByPath($result['path']);
     if (count($lastElements) > 0) {
         $lastElement = $lastElements[0];
         $infoCode = "feedback-alias-exists";
         $infoData['new_alias'] = $aliasText;
         $infoData['url'] = $lastElement->attribute('path');
         $infoData['action_url'] = $lastElement->actionURL();
         $aliasText = $origAliasText;
     }
 } else {
     if ($result['status'] === true) {
         $aliasText = $result['path'];
         if (strcmp($aliasText, $origAliasText) != 0) {
             $infoCode = "feedback-alias-cleanup";
             $infoData['orig_alias'] = $origAliasText;
             $infoData['new_alias'] = $aliasText;
开发者ID:legende91,项目名称:ez,代码行数:31,代码来源:urlalias.php

示例2: fetchNodeIDByPath

 public static function fetchNodeIDByPath($uriString, $glob = false)
 {
     $nodeID = false;
     $urlAliasMLList = eZURLAliasML::fetchByPath($uriString, $glob);
     if (is_array($urlAliasMLList) && count($urlAliasMLList) > 0) {
         $nodeID = eZURLAliasML::nodeIDFromAction($urlAliasMLList[0]->Action);
     }
     return $nodeID;
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:9,代码来源:ezurlaliasml.php

示例3: list

     }
     $newSourceWildcard = $matches[1];
     $sourceWildcard = $newSourceWildcard;
 }
 $toPathSQL = $db->escapeString($toPath);
 $query = "SELECT * FROM ezurlalias WHERE source_url = '{$toPathSQL}' AND is_wildcard = 0 AND forward_to_id = 0";
 $rowsw = $db->arrayQuery($query);
 if (count($rowsw) > 0) {
     list($action, $alwaysAvailable) = decodeAction($rowsw[0]['destination_url']);
     list($actionType, $actionValue) = explode(":", $action, 2);
     $elements = eZURLAliasML::fetchByAction($actionType, $actionValue);
     if ($elements) {
         $toPath = $elements[0]->getPath();
     }
 }
 $elements = eZURLAliasML::fetchByPath($toPath);
 if (count($elements) == 0) {
     // Referenced url does not exist
     logError("The referenced path '{$toPath}' can not be found among the new URL alias entries, url entry ID is " . $row['id']);
     list($column, $counter) = displayProgress('E', $urlImportStartTime, $counter, $urlCount, $column);
     continue;
 }
 // Fetch the ID of the element to redirect to.
 $linkID = $elements[0]->attribute('id');
 $action = $elements[0]->attribute('action');
 if ($action == 'nop:') {
     // Cannot redirect to nops
     logError("The referenced path '{$toPath}' with ID " . $elements[0]->attribute('id') . " is a 'nop:' entry and cannot be used");
     list($column, $counter) = displayProgress('E', $urlImportStartTime, $counter, $urlCount, $column);
     continue;
 }
开发者ID:legende91,项目名称:ez,代码行数:31,代码来源:updateniceurls.php

示例4: generateCache

    /**
     * Generates the static cache from the configured INI settings.
     *
     * @param bool $force If true then it will create all static caches even if it is not outdated.
     * @param bool $quiet If true then the function will not output anything.
     * @param eZCLI|false $cli The eZCLI object or false if no output can be done.
     * @param bool $delay
     */
    public function generateCache( $force = false, $quiet = false, $cli = false, $delay = true )
    {
        $staticURLArray = $this->cachedURLArray();
        $db = eZDB::instance();
        $configSettingCount = count( $staticURLArray );
        $currentSetting = 0;

        // This contains parent elements which must checked to find new urls and put them in $generateList
        // Each entry contains:
        // - url - Url of parent
        // - glob - A glob string to filter direct children based on name
        // - org_url - The original url which was requested
        // - parent_id - The element ID of the parent (optional)
        // The parent_id will be used to quickly fetch the children, if not it will use the url
        $parentList = array();
        // A list of urls which must generated, each entry is a string with the url
        $generateList = array();
        foreach ( $staticURLArray as $url )
        {
            $currentSetting++;
            if ( strpos( $url, '*') === false )
            {
                $generateList[] = $url;
            }
            else
            {
                $queryURL = ltrim( str_replace( '*', '', $url ), '/' );
                $dir = dirname( $queryURL );
                if ( $dir == '.' )
                    $dir = '';
                $glob = basename( $queryURL );
                $parentList[] = array( 'url' => $dir,
                                       'glob' => $glob,
                                       'org_url' => $url );
            }
        }

        // As long as we have urls to generate or parents to check we loop
        while ( count( $generateList ) > 0 || count( $parentList ) > 0 )
        {
            // First generate single urls
            foreach ( $generateList as $generateURL )
            {
                if ( !$quiet and $cli )
                    $cli->output( "caching: $generateURL ", false );
                $this->cacheURL( $generateURL, false, !$force, $delay );
                if ( !$quiet and $cli )
                    $cli->output( "done" );
            }
            $generateList = array();

            // Then check for more data
            $newParentList = array();
            foreach ( $parentList as $parentURL )
            {
                if ( isset( $parentURL['parent_id'] ) )
                {
                    $elements = eZURLAliasML::fetchByParentID( $parentURL['parent_id'], true, true, false );
                    foreach ( $elements as $element )
                    {
                        $path = '/' . $element->getPath();
                        $generateList[] = $path;
                        $newParentList[] = array( 'parent_id' => $element->attribute( 'id' ) );
                    }
                }
                else
                {
                    if ( !$quiet and $cli and $parentURL['glob'] )
                        $cli->output( "wildcard cache: " . $parentURL['url'] . '/' . $parentURL['glob'] . "*" );
                    $elements = eZURLAliasML::fetchByPath( $parentURL['url'], $parentURL['glob'] );
                    foreach ( $elements as $element )
                    {
                        $path = '/' . $element->getPath();
                        $generateList[] = $path;
                        $newParentList[] = array( 'parent_id' => $element->attribute( 'id' ) );
                    }
                }
            }
            $parentList = $newParentList;
        }
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:89,代码来源:ezstaticcache.php

示例5: getSSLZones

 /**
  * \static
  * Load content SSL zones definitions.
  * Substitute URIs with corresponding path strings
  * (e.g. "/news" would be subsituted with "/1/2/50").
  * The result is cached in memory to save time on multiple invocations.
  * It is also saved in a cache file that is usually updated by eZContentCacheManager along with content cache.
  */
 static function getSSLZones()
 {
     if (!isset($GLOBALS['eZSSLZonesCachedPathStrings'])) {
         $cacheFileName = eZSSLZone::cacheFileName();
         $cacheDirName = eZSys::cacheDirectory();
         // if file cache does not exist then create it
         if (!is_readable($cacheFileName)) {
             $ini = eZINI::instance();
             $sslSubtrees = $ini->variable('SSLZoneSettings', 'SSLSubtrees');
             if (!isset($sslSubtrees) || !$sslSubtrees) {
                 return array();
             }
             // if there are some content SSL zones defined in the ini settings
             // then let's calculate path strings for them
             $pathStringsArray = array();
             foreach ($sslSubtrees as $uri) {
                 $elements = eZURLAliasML::fetchByPath($uri);
                 if (count($elements) == 0) {
                     eZDebug::writeError("Cannot fetch URI '{$uri}'", __METHOD__);
                     continue;
                 }
                 $action = $elements[0]->attribute('action');
                 if (!preg_match("#^eznode:(.+)#", $action, $matches)) {
                     eZDebug::writeError("Cannot decode action '{$action}' for URI '{$uri}'", __METHOD__);
                     continue;
                 }
                 $nodeID = (int) $matches[1];
                 $node = eZContentObjectTreeNode::fetch($nodeID);
                 if (!$node instanceof eZContentObjectTreeNode) {
                     eZDebug::writeError("cannot fetch node by URI '{$uri}'", __METHOD__);
                     continue;
                 }
                 $pathStringsArray[$uri] = $node->attribute('path_string');
                 unset($node);
             }
             // write calculated path strings to the file
             if (!file_exists($cacheDirName)) {
                 eZDir::mkdir($cacheDirName, false, true);
             }
             $fh = fopen($cacheFileName, 'w');
             if ($fh) {
                 fwrite($fh, "<?php\n\$pathStringsArray = " . var_export($pathStringsArray, true) . ";\n?>");
                 fclose($fh);
                 $perm = eZINI::instance()->variable('FileSettings', 'StorageFilePermissions');
                 chmod($cacheFileName, octdec($perm));
             }
             return $GLOBALS['eZSSLZonesCachedPathStrings'] = $pathStringsArray;
         } else {
             // let's read its contents and return them
             include_once $cacheFileName;
             // stores array to $pathStringsArray
             return $GLOBALS['eZSSLZonesCachedPathStrings'] = $pathStringsArray;
         }
     }
     // else if in-memory cache already exists then return its contents
     $pathStringsArray = $GLOBALS['eZSSLZonesCachedPathStrings'];
     return $pathStringsArray;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:66,代码来源:ezsslzone.php

示例6: addUrlALias

 /**
  * Code taken from content/urlalias module
  */
 static function addUrlALias($node, $aliasText, $languageId, $aliasRedirects = false, $parentIsRoot = false)
 {
     $infoCode = 'no-errors';
     $language = eZContentLanguage::fetch($languageId);
     if (!$language) {
         $infoCode = "error-invalid-language";
         $infoData['language'] = $languageCode;
     } else {
         $parentID = 0;
         $linkID = 0;
         $filter = new eZURLAliasQuery();
         $filter->actions = array('eznode:' . $node->attribute('node_id'));
         $filter->type = 'name';
         $filter->limit = false;
         $existingElements = $filter->fetchAll();
         // TODO: add error handling when $existingElements is empty
         if (count($existingElements) > 0) {
             $parentID = (int) $existingElements[0]->attribute('parent');
             $linkID = (int) $existingElements[0]->attribute('id');
         }
         if ($parentIsRoot) {
             $parentID = 0;
             // Start from the top
         }
         $mask = $language->attribute('id');
         $obj = $node->object();
         $alwaysMask = $obj->attribute('language_mask') & 1;
         $mask |= $alwaysMask;
         $origAliasText = $aliasText;
         $result = eZURLAliasML::storePath($aliasText, 'eznode:' . $node->attribute('node_id'), $language, $linkID, $alwaysMask, $parentID, true, false, false, $aliasRedirects);
         if ($result['status'] === eZURLAliasML::LINK_ALREADY_TAKEN) {
             $lastElements = eZURLAliasML::fetchByPath($result['path']);
             if (count($lastElements) > 0) {
                 $lastElement = $lastElements[0];
                 $infoCode = "feedback-alias-exists";
                 $infoData['new_alias'] = $aliasText;
                 $infoData['url'] = $lastElement->attribute('path');
                 $infoData['action_url'] = $lastElement->actionURL();
                 //$aliasText = $origAliasText;
             }
         } else {
             if ($result['status'] === true) {
                 $aliasText = $result['path'];
                 if (strcmp($aliasText, $origAliasText) != 0) {
                     $infoCode = "feedback-alias-cleanup";
                     $infoData['orig_alias'] = $origAliasText;
                     $infoData['new_alias'] = $aliasText;
                 } else {
                     $infoData['new_alias'] = $aliasText;
                 }
                 if ($infoCode == 'no-errors') {
                     $infoCode = "feedback-alias-created";
                 }
                 //$aliasText = false;
             }
         }
     }
     return array('infoCode' => $infoCode, 'infoData' => $infoData);
 }
开发者ID:gggeek,项目名称:ezworkflowcollection,代码行数:62,代码来源:addurlaliastype.php

示例7: merge_ContentActionHandler


//.........这里部分代码省略.........
            $http->setSessionVariable('MergeNodeSelectionList', $selected_array);
            // Check master node
            if (!in_array($merge_node_master, $selected_array)) {
                $merge_node_master = 0;
                $http->setSessionVariable('MergeNodeMaster', 0);
            }
            // Remove any related selected translations
            $update_translation_map = false;
            foreach ($translation_map as $language => $node_id) {
                if (in_array($node_id, $remove_list)) {
                    unset($translation_map[$language]);
                    $update_translation_map = true;
                }
            }
            if ($update_translation_map) {
                $http->setSessionVariable('MergeObjectTranslationMap', $translation_map);
            }
        }
        $module->redirectTo('/merge/select');
    }
    // Go to browse module to choose nodes to merge
    if ($http->hasPostVariable('MergeBrowse')) {
        $ini = eZINI::instance('merge.ini');
        $class_list = $ini->variable('MergeSettings', 'ClassList');
        $start_node_id = $ini->variable('MergeSettings', 'BrowseNodeID');
        eZContentBrowse::browse(array('action_name' => 'MergeObjects', 'description_template' => 'design:content/browse_placement.tpl', 'ignore_nodes_select' => $selected_array, 'ignore_nodes_click' => array(), 'selection' => 'radio', 'class_array' => $class_list, 'start_node' => $start_node_id, 'from_page' => '/merge/select'), $module);
    }
    // Actual merge operation
    if ($http->hasPostVariable('MergeAction')) {
        if (count($selected_array) != 2) {
            $module->redirectTo('/merge/select');
        }
        // Set up correct order according to selected master
        if ($selected_array[1] == $merge_node_master) {
            $selected_array = array_reverse($selected_array);
        }
        // Fetch objects to merge
        $mnode1 = eZFunctionHandler::execute('content', 'node', array('node_id' => $selected_array[0]));
        $mnode2 = eZFunctionHandler::execute('content', 'node', array('node_id' => $selected_array[1]));
        $mobject1 = $mnode1->attribute('object');
        $mobject2 = $mnode2->attribute('object');
        // Do sanity check
        if ($mobject1->attribute('contentclass_id') != $mobject2->attribute('contentclass_id')) {
            $module->redirectTo('/merge/select');
        }
        // Make sure merge process does not get a PHP timeout
        set_time_limit(0);
        $db = eZDB::instance();
        $db->begin();
        foreach ($translation_map as $language => $node_id) {
            $object1 = $object2 = null;
            $node1 = eZFunctionHandler::execute('content', 'node', array('node_id' => $selected_array[0], 'language_code' => $language));
            $node2 = eZFunctionHandler::execute('content', 'node', array('node_id' => $selected_array[1], 'language_code' => $language));
            // Make sure we get correct language
            if ($node1) {
                $object1 = $node1->attribute('object');
                if (!in_array($language, $object1->attribute('available_languages'))) {
                    $object1 = $mobject1;
                }
            } else {
                $object1 = $mobject1;
            }
            if ($node2) {
                $object2 = $node2->attribute('object');
                if (!in_array($language, $object2->attribute('available_languages'))) {
                    $object2 = null;
                }
            }
            // Copy language in specified direction, if it exist in both objects
            $use_object1_values = $node_id == $selected_array[0];
            if ($object1 and $object2) {
                // Need to redirect node 2 current url alias to avoid added "2" in the new url alias of merged object
                $urlalias_array = eZURLAliasML::fetchByPath($node2->attribute('url_alias'));
                foreach ($urlalias_array as $urlalias) {
                    $urlalias = eZURLAliasML::fetchObject(eZURLAliasML::definition(), null, array('id' => $urlalias->attribute('id'), 'lang_mask' => $urlalias->attribute('lang_mask')));
                    $urlalias->setAttribute('action', 'eznode:' . $mnode1->attribute('node_id'));
                    $urlalias->store();
                }
                doContentObjectMerge($object1, $object2, $language, $use_object1_values);
            }
        }
        $main_node_id1 = $mobject1->attribute('main_node_id');
        foreach ($mobject2->attribute('assigned_nodes') as $node2) {
            // Move any children of object2 nodes to object1 main node
            $children2 = eZFunctionHandler::execute('content', 'list', array('parent_node_id' => $node2->attribute('node_id')));
            foreach ($children2 as $child2) {
                eZContentObjectTreeNodeOperations::move($child2->attribute('node_id'), $main_node_id1);
            }
        }
        // Delete object2
        $mobject2->purge();
        $db->commit();
        //        $db->rollback(); // For debugging
        // Clean up session variables
        $http->removeSessionVariable('MergeNodeSelectionList');
        $http->removeSessionVariable('MergeNodeMaster');
        $http->removeSessionVariable('MergeObjectTranslationMap');
        $module->redirectTo($mnode1->attribute('url_alias'));
    }
}
开发者ID:informaticatrentina,项目名称:merge,代码行数:101,代码来源:content_actionhandler.php


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