本文整理汇总了PHP中eZContentObjectTreeNode::findMainNodeArray方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::findMainNodeArray方法的具体用法?PHP eZContentObjectTreeNode::findMainNodeArray怎么用?PHP eZContentObjectTreeNode::findMainNodeArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::findMainNodeArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFindMainNodeArray
/**
* Unit test for eZContentObjectTreeNode::fetchMainNodeArray
*
* Outline:
* 1) Call the function with an empty array and check that the output is null
* 2) Create a few objects/nodes
* 3) Call the method with these objects' IDs as a parameter
* 3) Check that the returned values are eZContentObjectTreeNodes, and match
* the parameter list
*
* @todo Also test with $asObject = false
**/
public function testFindMainNodeArray()
{
// 1) Check that the method returns null on an empty array
$this->assertNull(eZContentObjectTreeNode::findMainNodeArray(array()));
// 2) Create a few objects/nodes
$objectIDArray = $objectsArray = $nodesIDArray = array();
for ($i = 0; $i < 5; $i++) {
$object = new ezpObject('article', 2);
$object->title = "Test object #{$i} for " . __FUNCTION__;
$object->publish();
$objectsIDArray[] = $object->attribute('id');
}
// 3) Call the method
$mainNodeArray = eZContentObjectTreeNode::findMainNodeArray($objectsIDArray);
// 4) Check the result
$this->assertEquals(count($objectsIDArray), count($mainNodeArray), "Return value count doesn't matche parameter count");
foreach ($mainNodeArray as $mainNode) {
$mainNodeContentObjectID = $mainNode->attribute('contentobject_id');
$this->assertType('eZContentObjectTreeNode', $mainNode);
$this->assertTrue($mainNode->attribute('is_main'));
$this->assertTrue(in_array($mainNodeContentObjectID, $objectsIDArray), "A returned node's contentobject_id isn't part of the original parameters");
}
}
示例2: ini_set
ini_set('max_execution_time', 0);
ini_set('memory_limit', '-1');
eZDebug::addTimingPoint('Fetch update pending list');
// Get list of paex objects marked to updatechildren
$pendingList = eZPaEx::fetchUpdateChildrenPendingList();
$pendingListCount = count($pendingList);
if (!$pendingListCount) {
$cli->output("No pending update subtrees found");
} else {
$cli->output("Found " . $pendingListCount . " ezpaex objects with pending updatechildren");
$pendingIdList = array();
foreach ($pendingList as $pendingObject) {
$pendingIdList[] = $pendingObject->attribute('contentobject_id');
}
// Fetch array of nodes corresponding to objects in the pendingIDList to sort them by depth
$nodeArray = eZContentObjectTreeNode::findMainNodeArray($pendingIdList, false);
// Make an array of objects ids with its deph based on the corresponding node
$objectDepthList = array();
foreach ($nodeArray as $key => $node) {
$objectDepthList[0][$key] = $node["depth"];
$objectDepthList[1][$key] = $node["contentobject_id"];
}
// Sort objectDepthList by depth to apply updatechildren in the right order
if (!array_multisort($objectDepthList[0], SORT_ASC, $objectDepthList[1], SORT_ASC)) {
eZDebug::writeError('Error in array_multisort', 'ezmbpaex_updatechildren.php');
} else {
// Generate array of paex objects to update
$paexObjectArray = array();
foreach ($objectDepthList[1] as $contentobjectId) {
if (isset($pendingList[$contentobjectId])) {
// Generate update children data for every pending object in pendingIDList
示例3: relatedObjects
function relatedObjects()
{
$return = false;
if ($this->ObjectAttributeID) {
$return = array();
// Fetch words
$db = eZDB::instance();
$wordArray = $db->arrayQuery("SELECT * FROM ezkeyword_attribute_link\n WHERE objectattribute_id='" . $this->ObjectAttributeID . "' ");
$keywordIDArray = array();
// Fetch the objects which have one of these words
foreach ($wordArray as $word) {
$keywordIDArray[] = $word['keyword_id'];
}
$keywordCondition = $db->generateSQLINStatement($keywordIDArray, 'keyword_id');
if (count($keywordIDArray) > 0) {
$objectArray = $db->arrayQuery("SELECT DISTINCT ezcontentobject_attribute.contentobject_id FROM ezkeyword_attribute_link, ezcontentobject_attribute\n WHERE {$keywordCondition} AND\n ezcontentobject_attribute.id = ezkeyword_attribute_link.objectattribute_id\n AND objectattribute_id <> '" . $this->ObjectAttributeID . "' ");
$objectIDArray = array();
foreach ($objectArray as $object) {
$objectIDArray[] = $object['contentobject_id'];
}
if (count($objectIDArray) > 0) {
$aNodes = eZContentObjectTreeNode::findMainNodeArray($objectIDArray);
foreach ($aNodes as $key => $node) {
$theObject = $node->object();
if ($theObject->canRead()) {
$return[] = $node;
}
}
}
}
}
return $return;
}