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


PHP eZNodeAssignment::fetchChildCountByVersionStatus方法代码示例

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


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

示例1: testFetchChildListByVersionStatus

 /**
  * test fetchChildListByVersionStatus
  */
 public function testFetchChildListByVersionStatus()
 {
     //create object
     $top = new ezpObject('article', 2);
     $top->name = 'TOP ARTICLE';
     $top->publish();
     $child = new ezpObject('article', $top->mainNode->node_id);
     $child->name = 'THIS IS AN ARTICLE';
     $child->publish();
     $child2 = new ezpObject('article', $top->mainNode->node_id);
     $child2->name = 'THIS IS AN ARTICLE2';
     $child2->publish();
     $pendingChild = new ezpObject('article', $top->mainNode->node_id);
     $pendingChild->name = 'THIS IS A PENDING ARTICLE';
     $pendingChild->publish();
     $version = $pendingChild->currentVersion();
     $version->setAttribute('status', eZContentObjectVersion::STATUS_PENDING);
     $version->store();
     $idList = array($top->mainNode->node_id);
     $arrayResult = eZNodeAssignment::fetchChildListByVersionStatus($idList, eZContentObjectVersion::STATUS_PENDING, false);
     $this->assertEquals($pendingChild->id, $arrayResult[0]['contentobject_id']);
     $arrayResult = eZNodeAssignment::fetchChildListByVersionStatus($idList, eZContentObjectVersion::STATUS_PUBLISHED, true);
     $this->assertEquals($child->id, $arrayResult[0]->attribute('contentobject_id'));
     $countResult = eZNodeAssignment::fetchChildCountByVersionStatus($idList, eZContentObjectVersion::STATUS_PENDING);
     $this->assertEquals(1, $countResult);
     $countResult = eZNodeAssignment::fetchChildCountByVersionStatus($idList, eZContentObjectVersion::STATUS_PUBLISHED);
     $this->assertEquals(2, $countResult);
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:31,代码来源:eznodeassignment_test.php

示例2: removeSubtrees

 static function removeSubtrees($deleteIDArray, $moveToTrash = true, $infoOnly = false)
 {
     $moveToTrashAllowed = true;
     $deleteResult = array();
     $totalChildCount = 0;
     $totalLoneNodeCount = 0;
     $canRemoveAll = true;
     $hasPendingObject = false;
     $db = eZDB::instance();
     $db->begin();
     foreach ($deleteIDArray as $deleteID) {
         $node = eZContentObjectTreeNode::fetch($deleteID);
         if ($node === null) {
             continue;
         }
         $object = $node->attribute('object');
         if ($object === null) {
             continue;
         }
         $class = $object->attribute('content_class');
         $canRemove = $node->attribute('can_remove');
         $canRemoveSubtree = true;
         $nodeID = $node->attribute('node_id');
         $nodeName = $object->attribute('name');
         $childCount = 0;
         $newMainNodeID = false;
         $objectNodeCount = 0;
         $readableChildCount = 0;
         if ($canRemove) {
             $moveToTrashAllowed = $node->isNodeTrashAllowed();
             $readableChildCount = $node->subTreeCount(array('Limitation' => array()));
             $childCount = $node->subTreeCount(array('IgnoreVisibility' => true));
             $totalChildCount += $childCount;
             $allAssignedNodes = $object->attribute('assigned_nodes');
             $objectNodeCount = count($allAssignedNodes);
             // We need to find a new main node ID if we are trying
             // to remove the current main node.
             if ($node->attribute('main_node_id') == $nodeID) {
                 if (count($allAssignedNodes) > 1) {
                     foreach ($allAssignedNodes as $assignedNode) {
                         $assignedNodeID = $assignedNode->attribute('node_id');
                         if ($assignedNodeID == $nodeID) {
                             continue;
                         }
                         $newMainNodeID = $assignedNodeID;
                         break;
                     }
                 }
             }
             if ($infoOnly) {
                 // Find the number of items in the subtree we are allowed to remove
                 // if this differs from the total count it means we have items we cannot remove
                 // We do this by fetching the limitation list for content/remove
                 // and passing it to the subtree count function.
                 $currentUser = eZUser::currentUser();
                 $accessResult = $currentUser->hasAccessTo('content', 'remove');
                 if ($accessResult['accessWord'] == 'limited') {
                     $limitationList = $accessResult['policies'];
                     $removeableChildCount = $node->subTreeCount(array('Limitation' => $limitationList, 'IgnoreVisibility' => true));
                     $canRemoveSubtree = $removeableChildCount == $childCount;
                     $canRemove = $canRemoveSubtree;
                 }
                 //check if there is sub object in pending status
                 $limitCount = 100;
                 $offset = 0;
                 while (1) {
                     $children = $node->subTree(array('Limitation' => array(), 'SortBy' => array('path', false), 'Offset' => $offset, 'Limit' => $limitCount, 'IgnoreVisibility' => true, 'AsObject' => false));
                     // fetch pending node assignment(pending object)
                     $idList = array();
                     //add node itself into idList
                     if ($offset === 0) {
                         $idList[] = $nodeID;
                     }
                     foreach ($children as $child) {
                         $idList[] = $child['node_id'];
                     }
                     if (count($idList) === 0) {
                         break;
                     }
                     $pendingChildCount = eZNodeAssignment::fetchChildCountByVersionStatus($idList, eZContentObjectVersion::STATUS_PENDING);
                     if ($pendingChildCount !== 0) {
                         // there is pending object
                         $hasPendingObject = true;
                         break;
                     }
                     $offset += $limitCount;
                 }
             }
             // We will only remove the subtree if are allowed
             // and are told to do so.
             if ($canRemove and !$infoOnly) {
                 $moveToTrashTemp = $moveToTrash;
                 if (!$moveToTrashAllowed) {
                     $moveToTrashTemp = false;
                 }
                 // Remove children, fetching them by 100 to avoid memory overflow.
                 // removeNodeFromTree -> removeThis handles cache clearing
                 while (1) {
                     // We should remove the latest subitems first,
                     // so we should fetch subitems sorted by 'path_string' DESC
//.........这里部分代码省略.........
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:101,代码来源:ezcontentobjecttreenode.php


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