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


PHP eZSearch::addNodeAssignment方法代码示例

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


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

示例1: move

 static function move($nodeID, $newParentNodeID)
 {
     $result = false;
     if (!is_numeric($nodeID) || !is_numeric($newParentNodeID)) {
         return false;
     }
     $node = eZContentObjectTreeNode::fetch($nodeID);
     if (!$node) {
         return false;
     }
     $object = $node->object();
     if (!$object) {
         return false;
     }
     $objectID = $object->attribute('id');
     $oldParentNode = $node->fetchParent();
     $oldParentObject = $oldParentNode->object();
     // clear user policy cache if this is a user object
     if (in_array($object->attribute('contentclass_id'), eZUser::contentClassIDs())) {
         eZUser::purgeUserCacheByUserId($object->attribute('id'));
     }
     // clear cache for old placement.
     // If child count exceeds threshold, do nothing here, and instead clear all view cache at the end.
     $childCountInThresholdRange = eZContentCache::inCleanupThresholdRange($node->childrenCount(false));
     if ($childCountInThresholdRange) {
         eZContentCacheManager::clearContentCacheIfNeeded($objectID);
     }
     $db = eZDB::instance();
     $db->begin();
     $node->move($newParentNodeID);
     $newNode = eZContentObjectTreeNode::fetchNode($objectID, $newParentNodeID);
     if ($newNode) {
         $newNode->updateSubTreePath(true, true);
         if ($newNode->attribute('main_node_id') == $newNode->attribute('node_id')) {
             // If the main node is moved we need to check if the section ID must change
             $newParentNode = $newNode->fetchParent();
             $newParentObject = $newParentNode->object();
             if ($object->attribute('section_id') != $newParentObject->attribute('section_id')) {
                 eZContentObjectTreeNode::assignSectionToSubTree($newNode->attribute('main_node_id'), $newParentObject->attribute('section_id'), $oldParentObject->attribute('section_id'));
             }
         }
         // modify assignment
         $curVersion = $object->attribute('current_version');
         $nodeAssignment = eZNodeAssignment::fetch($objectID, $curVersion, $oldParentNode->attribute('node_id'));
         if ($nodeAssignment) {
             $nodeAssignment->setAttribute('parent_node', $newParentNodeID);
             $nodeAssignment->setAttribute('op_code', eZNodeAssignment::OP_CODE_MOVE);
             $nodeAssignment->store();
             // update search index specifying we are doing a move operation
             $nodeIDList = array($nodeID);
             eZSearch::removeNodeAssignment($node->attribute('main_node_id'), $newNode->attribute('main_node_id'), $object->attribute('id'), $nodeIDList);
             eZSearch::addNodeAssignment($newNode->attribute('main_node_id'), $object->attribute('id'), $nodeIDList, true);
         }
         $result = true;
     } else {
         eZDebug::writeError("Node {$nodeID} was moved to {$newParentNodeID} but fetching the new node failed");
     }
     $db->commit();
     // clear cache for new placement.
     // If child count exceeds threshold, clear all view cache instead.
     if ($childCountInThresholdRange) {
         eZContentCacheManager::clearContentCacheIfNeeded($objectID);
     } else {
         eZContentCacheManager::clearAllContentCache();
     }
     return $result;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:67,代码来源:ezcontentobjecttreenodeoperations.php

示例2: addAssignment

 /**
  * Adds a new nodeAssignment
  *
  * @param int $nodeID
  * @param int $objectId
  * @param array $selectedNodeIDArray
  *
  * @return array An array with operation status, always true
  */
 public static function addAssignment($nodeID, $objectID, $selectedNodeIDArray)
 {
     $userClassIDArray = eZUser::contentClassIDs();
     $object = eZContentObject::fetch($objectID);
     $class = $object->contentClass();
     $nodeAssignmentList = eZNodeAssignment::fetchForObject($objectID, $object->attribute('current_version'), 0, false);
     $assignedNodes = $object->assignedNodes();
     $parentNodeIDArray = array();
     foreach ($assignedNodes as $assignedNode) {
         $append = false;
         foreach ($nodeAssignmentList as $nodeAssignment) {
             if ($nodeAssignment['parent_node'] == $assignedNode->attribute('parent_node_id')) {
                 $append = true;
                 break;
             }
         }
         if ($append) {
             $parentNodeIDArray[] = $assignedNode->attribute('parent_node_id');
         }
     }
     $db = eZDB::instance();
     $db->begin();
     $locationAdded = false;
     $node = eZContentObjectTreeNode::fetch($nodeID);
     foreach ($selectedNodeIDArray as $selectedNodeID) {
         if (!in_array($selectedNodeID, $parentNodeIDArray)) {
             $parentNode = eZContentObjectTreeNode::fetch($selectedNodeID);
             $parentNodeObject = $parentNode->attribute('object');
             $canCreate = $parentNode->checkAccess('create', $class->attribute('id'), $parentNodeObject->attribute('contentclass_id')) == 1 || $parentNode->canAddLocation() && $node->canRead();
             if ($canCreate) {
                 $insertedNode = $object->addLocation($selectedNodeID, true);
                 // Now set is as published and fix main_node_id
                 $insertedNode->setAttribute('contentobject_is_published', 1);
                 $insertedNode->setAttribute('main_node_id', $node->attribute('main_node_id'));
                 $insertedNode->setAttribute('contentobject_version', $node->attribute('contentobject_version'));
                 // Make sure the url alias is set updated.
                 $insertedNode->updateSubTreePath();
                 $insertedNode->sync();
                 $locationAdded = true;
             }
         }
     }
     if ($locationAdded) {
         //call appropriate method from search engine
         eZSearch::addNodeAssignment($nodeID, $objectID, $selectedNodeIDArray);
         // clear user policy cache if this was a user object
         if (in_array($object->attribute('contentclass_id'), $userClassIDArray)) {
             eZUser::purgeUserCacheByUserId($object->attribute('id'));
         }
     }
     $db->commit();
     eZContentCacheManager::clearContentCacheIfNeeded($objectID);
     return array('status' => true);
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:63,代码来源:ezcontentoperationcollection.php

示例3: move

    static function move( $nodeID, $newParentNodeID )
    {
        $result = false;

        if ( !is_numeric( $nodeID ) || !is_numeric( $newParentNodeID ) )
            return false;

        $node = eZContentObjectTreeNode::fetch( $nodeID );
        if ( !$node )
            return false;

        $object = $node->object();
        if ( !$object )
            return false;

        $objectID = $object->attribute( 'id' );
        $oldParentNode = $node->fetchParent();
        $oldParentObject = $oldParentNode->object();

        // clear user policy cache if this is a user object
        if ( in_array( $object->attribute( 'contentclass_id' ), eZUser::contentClassIDs() ) )
        {
            eZUser::purgeUserCacheByUserId( $object->attribute( 'id' ) );
        }

        // clear cache for old placement.
        eZContentCacheManager::clearContentCacheIfNeeded( $objectID );

        $db = eZDB::instance();
        $db->begin();

        $node->move( $newParentNodeID );

        $newNode = eZContentObjectTreeNode::fetchNode( $objectID, $newParentNodeID );

        if ( $newNode )
        {
            $newNode->updateSubTreePath( true, true );
            if ( $newNode->attribute( 'main_node_id' ) == $newNode->attribute( 'node_id' ) )
            {
                // If the main node is moved we need to check if the section ID must change
                $newParentNode = $newNode->fetchParent();
                $newParentObject = $newParentNode->object();
                if ( $object->attribute( 'section_id' ) != $newParentObject->attribute( 'section_id' ) )
                {

                    eZContentObjectTreeNode::assignSectionToSubTree( $newNode->attribute( 'main_node_id' ),
                                                                     $newParentObject->attribute( 'section_id' ),
                                                                     $oldParentObject->attribute( 'section_id' ) );
                }
            }

            // modify assignment
            $curVersion     = $object->attribute( 'current_version' );
            $nodeAssignment = eZNodeAssignment::fetch( $objectID, $curVersion, $oldParentNode->attribute( 'node_id' ) );

            if ( $nodeAssignment )
            {
                $nodeAssignment->setAttribute( 'parent_node', $newParentNodeID );
                $nodeAssignment->setAttribute( 'op_code', eZNodeAssignment::OP_CODE_MOVE );
                $nodeAssignment->store();

                // update search index
                $nodeIDList = array( $nodeID );
                eZSearch::removeNodeAssignment( $node->attribute( 'main_node_id' ), $newNode->attribute( 'main_node_id' ), $object->attribute( 'id' ), $nodeIDList );
                eZSearch::addNodeAssignment( $newNode->attribute( 'main_node_id' ), $object->attribute( 'id' ), $nodeIDList );
            }

            $result = true;
        }
        else
        {
            eZDebug::writeError( "Node $nodeID was moved to $newParentNodeID but fetching the new node failed" );
        }

        $db->commit();

        // clear cache for new placement.
        eZContentCacheManager::clearContentCacheIfNeeded( $objectID );

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


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