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


PHP eZContentOperationCollection::moveNode方法代码示例

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


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

示例1: array

         if (!$selectedNode->canMoveTo($classID)) {
             eZDebug::writeError("Cannot move node {$nodeID} as child of parent node {$selectedNodeID}, the current user does not have create permission for class ID {$classID}", 'content/action');
             return $module->redirectToView('view', array('full', 2));
         }
         // Check if we try to move the node as child of itself or one of its children
         if (in_array($node->attribute('node_id'), $selectedNode->pathArray())) {
             eZDebug::writeError("Cannot move node {$nodeID} as child of itself or one of its own children (node {$selectedNodeID}).", 'content/action');
             return $module->redirectToView('view', array('full', $node->attribute('node_id')));
         }
     }
     // move selected nodes, this should probably be inside a transaction
     foreach ($nodeToMoveList as $nodeToMove) {
         if (eZOperationHandler::operationIsAvailable('content_move')) {
             $operationResult = eZOperationHandler::execute('content', 'move', array('node_id' => $nodeToMove['node_id'], 'object_id' => $nodeToMove['object_id'], 'new_parent_node_id' => $selectedNodeID), null, true);
         } else {
             eZContentOperationCollection::moveNode($nodeToMove['node_id'], $nodeToMove['object_id'], $selectedNodeID);
         }
     }
     return $module->redirectToView('view', array($viewMode, $selectedNodeID, $languageCode));
 } else {
     if ($module->isCurrentAction('MoveNodeRequest')) {
         /* This action is started through the pop-up menu when a "Move" is
          * requested and through the use of the "Move" button. It will start the
          * browser to select where the node should be moved to. */
         if (!$module->hasActionParameter('NodeID')) {
             eZDebug::writeError("Missing NodeID parameter for action " . $module->currentAction(), 'content/action');
             return $module->redirectToView('view', array('full', 2));
         }
         $nodeID = $module->actionParameter('NodeID');
         $node = eZContentObjectTreeNode::fetch($nodeID);
         if (!$node) {
开发者ID:heliopsis,项目名称:ezpublish-legacy,代码行数:31,代码来源:action.php

示例2: updateObject

 /**
  * Updates content object
  *
  * @param $params array(
  *     'object'                  => eZContentObject         Content object
  *     'attributes'              => array(                  Content object`s attributes
  *         string identifier => string stringValue
  *     ),
  *     'parentNode'              => eZContentObjectTreeNode Parent node object, not necessary
  *     'parentNodeID'            => int                     Content object`s parent node ID, not necessary
  *     'additionalParentNodeIDs' => array                   additionalParentNodeIDs, Additional parent node ids
  *     'visibility'              => bool                    Nodes visibility
  * )
  * @return bool true if object was updated, otherwise false
  */
 public function updateObject($params)
 {
     $this->db->begin();
     $object = $params['object'];
     if ($object instanceof eZContentObject === false) {
         $this->error('Content object is empty');
         $this->db->rollback();
         return false;
     }
     $this->debug('Starting update "' . $object->attribute('name') . '" object (class: ' . $object->attribute('class_name') . ') with remote ID ' . $object->attribute('remote_id'));
     $visibility = isset($params['visibility']) ? (bool) $params['visibility'] : true;
     $parentNode = false;
     if (isset($params['parentNode'])) {
         $parentNode = $params['parentNode'];
     } elseif (isset($params['parentNodeID'])) {
         $parentNode = eZContentObjectTreeNode::fetch($params['parentNodeID']);
     }
     if ($parentNode instanceof eZContentObjectTreeNode && $object->attribute('main_node') instanceof eZContentObjectTreeNode) {
         if ($parentNode->attribute('node_id') != $object->attribute('main_node')->attribute('parent_node_id')) {
             eZContentOperationCollection::moveNode($object->attribute('main_node_id'), $object->attribute('id'), $parentNode->attribute('node_id'));
         }
     }
     $additionalParentNodeIDs = isset($params['additionalParentNodeIDs']) ? (array) $params['additionalParentNodeIDs'] : array();
     $additionalParentNodes = array();
     foreach ($additionalParentNodeIDs as $nodeID) {
         $additionalParentNode = eZContentObjectTreeNode::fetch($nodeID);
         if ($additionalParentNode instanceof eZContentObjectTreeNode) {
             if ($parentNode instanceof eZContentObjectTreeNode && $nodeID != $parentNode->attribute('node_id')) {
                 $additionalParentNodes[] = $additionalParentNode;
             }
         } else {
             $this->error('Can`t fetch additional parent node by ID: ' . $nodeID);
         }
     }
     if (count($additionalParentNodes) > 0) {
         $nodeAssigments = eZPersistentObject::fetchObjectList(eZNodeAssignment::definition(), null, array('contentobject_id' => $object->attribute('id'), 'contentobject_version' => $object->attribute('current_version'), 'is_main' => 0), null, null, true);
         $removeNodeIDs = array();
         foreach ($nodeAssigments as $assigment) {
             $node = $assigment->attribute('node');
             if ($node instanceof eZContentObjectTreeNode) {
                 if (in_array($node->attribute('parent_node_id'), $additionalParentNodeIDs) === false) {
                     $removeNodeIDs[] = $node->attribute('node_id');
                     $assigment->purge();
                 }
             }
         }
         if (count($removeNodeIDs) > 0) {
             $info = eZContentObjectTreeNode::subtreeRemovalInformation($removeNodeIDs);
             foreach ($info['delete_list'] as $deleteItem) {
                 $node = $deleteItem['node'];
                 if ($node === null) {
                     continue;
                 }
                 if ($deleteItem['can_remove']) {
                     eZContentObjectTreeNode::removeSubtrees(array($node->attribute('node_id')), false);
                     $this->debug('[Removed additional location] "' . $node->attribute('name') . '"', array('red'));
                 }
             }
         }
         foreach ($additionalParentNodes as $node) {
             $nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $object->attribute('id'), 'contentobject_version' => $object->attribute('current_version'), 'parent_node' => $node->attribute('node_id'), 'is_main' => 0));
             $nodeAssignment->store();
         }
     }
     $this->setObjectAttributes($object, $params['attributes']);
     $object->commitInputRelations($object->attribute('current_version'));
     $object->resetInputRelationList();
     eZOperationHandler::execute('content', 'publish', array('object_id' => $object->attribute('id'), 'version' => $object->attribute('current_version')));
     $this->db->commit();
     $this->updateVisibility($object, $visibility);
     $this->debug('[Updated] "' . $object->attribute('name') . '"', array('yellow'));
     return true;
 }
开发者ID:nxc,项目名称:nxc_powercontent,代码行数:88,代码来源:powercontent.php


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