本文整理汇总了PHP中eZContentObjectTreeNode::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::fetch方法的具体用法?PHP eZContentObjectTreeNode::fetch怎么用?PHP eZContentObjectTreeNode::fetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
public function fetch($parameters, $publishedAfter, $publishedBeforeOrAt)
{
if (isset($parameters['Source'])) {
$nodeID = $parameters['Source'];
$node = eZContentObjectTreeNode::fetch($nodeID, false, false);
// not as an object
if ($node && $node['modified_subnode'] <= $publishedAfter) {
return array();
}
} else {
$nodeID = 0;
}
$subTreeParameters = array();
$subTreeParameters['AsObject'] = false;
$subTreeParameters['SortBy'] = array('published', false);
// first the latest
$subTreeParameters['AttributeFilter'] = array('and', array('published', '>', $publishedAfter), array('published', '<=', $publishedBeforeOrAt), array('visibility', '=', true));
if (isset($parameters['Class'])) {
$subTreeParameters['ClassFilterType'] = 'include';
$subTreeParameters['ClassFilterArray'] = explode(';', $parameters['Class']);
}
if (isset($parameters['Limit'])) {
$subTreeParameters['Limit'] = (int) $parameters['Limit'];
}
$result = eZContentObjectTreeNode::subTreeByNodeID($subTreeParameters, $nodeID);
if ($result === null) {
return array();
}
$fetchResult = array();
foreach ($result as $item) {
$fetchResult[] = array('object_id' => $item['id'], 'node_id' => $item['node_id'], 'ts_publication' => $item['published']);
}
return $fetchResult;
}
示例2: modify
function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
$parentNodeID = $namedParameters['parent_node_id'];
switch ($operatorName) {
case 'ezkeywordlist':
include_once 'lib/ezdb/classes/ezdb.php';
$db = eZDB::instance();
if ($parentNodeID) {
$node = eZContentObjectTreeNode::fetch($parentNodeID);
if ($node) {
$pathString = "AND ezcontentobject_tree.path_string like '" . $node->attribute('path_string') . "%'";
}
$parentNodeIDSQL = "AND ezcontentobject_tree.node_id != " . (int) $parentNodeID;
}
$showInvisibleNodesCond = eZContentObjectTreeNode::createShowInvisibleSQLString(true, false);
$limitation = false;
$limitationList = eZContentObjectTreeNode::getLimitationList($limitation);
$sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL($limitationList);
$versionNameJoins = " AND ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id AND\n ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version AND ";
$languageFilter = " AND " . eZContentLanguage::languagesSQLFilter('ezcontentobject');
$versionNameJoins .= eZContentLanguage::sqlFilter('ezcontentobject_name', 'ezcontentobject');
$quotedClassIdentifiers = array();
foreach ((array) $namedParameters['class_identifier'] as $classIdentifier) {
$quotedClassIdentifiers[] = "'" . $db->escapeString($classIdentifier) . "'";
}
$rs = $db->arrayQuery("SELECT DISTINCT ezkeyword.keyword\n FROM ezkeyword_attribute_link,\n ezkeyword,\n ezcontentobject,\n ezcontentobject_name,\n ezcontentobject_attribute,\n ezcontentobject_tree,\n ezcontentclass\n {$sqlPermissionChecking['from']}\n WHERE ezkeyword.id = ezkeyword_attribute_link.keyword_id\n AND ezkeyword_attribute_link.objectattribute_id = ezcontentobject_attribute.id\n AND ezcontentobject_tree.contentobject_id = ezcontentobject_attribute.contentobject_id\n AND ezkeyword.class_id = ezcontentclass.id\n AND " . $db->generateSQLINStatement($quotedClassIdentifiers, 'ezcontentclass.identifier') . "\n {$pathString}\n {$parentNodeIDSQL} " . ($namedParameters['depth'] > 0 ? "AND ezcontentobject_tree.depth=" . (int) $namedParameters['depth'] : '') . "\n {$showInvisibleNodesCond}\n {$sqlPermissionChecking['where']}\n {$languageFilter}\n {$versionNameJoins}\n ORDER BY ezkeyword.keyword ASC");
$operatorValue = $rs;
break;
}
}
示例3: execute
public function execute($process, $event)
{
$params = $process->attribute('parameter_list');
$object_id = $params['object_id'];
$object = eZContentObject::fetch($object_id);
if (!is_object($object)) {
eZDebug::writeError("Unable to fetch object: '{$object_id}'", __METHOD__);
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
// current parent node(s)
$parentNodeIds = $object->attribute('parent_nodes');
$checkedObjs = array();
foreach ($parentNodeIds as $parentNodeId) {
//eZDebug::writeDebug( "Checking parent node: " . $parentNodeId, __METHOD__ );
$parentNode = eZContentObjectTreeNode::fetch($parentNodeId);
$parentObj = $parentNode->attribute('object');
if (!in_array($parentObj->attribute('id'), $checkedObjs)) {
//eZDebug::writeDebug( "Checking all nodes of parent obj: " . $parentObj->attribute( 'id' ), __METHOD__ );
foreach ($parentObj->attribute('assigned_nodes') as $node) {
if (!in_array($node->attribute('node_id'), $parentNodeIds)) {
//eZDebug::writeDebug( "Found a node which is not parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ );
// the current obj has no node which is children of the given node of one of its parent objects
$operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $object->attribute('main_node_id'), 'object_id' => $object->attribute('id'), 'select_node_id_array' => array($node->attribute('node_id'))), null, true);
if ($operationResult == null || $operationResult['status'] != true) {
eZDebug::writeError("Unable to add new location to object: " . $object->attribute('id'), __METHOD__);
}
} else {
//eZDebug::writeDebug( "Found a node which is already parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ );
}
}
}
$checkedObjs[] = $parentObj->attribute('id');
}
return eZWorkflowType::STATUS_ACCEPTED;
}
示例4: getMetaTitle
public static function getMetaTitle( $pathArray )
{
$metaINI = eZINI::instance( 'ezmetadata.ini' );
$allowedClasses = $metaINI->variable( 'TitleSettings', 'ParentClasses' );
$maxDepth = $metaINI->variable( 'TitleSettings', 'MaxDepth' );
$separator = ' '.$metaINI->variable( 'TitleSettings', 'PathSeparator' ).' ';
$contentINI = eZINI::instance( 'content.ini' );
$rootNodeID = $contentINI->variable( 'NodeSettings', 'RootNode' );
$titleArray = array();
$depth = -1;
$currentItem = array_pop( $pathArray );
foreach ( $pathArray as $item )
{
if ( $item['node_id'] == $rootNodeID ) $depth = 0;
if ( $depth < 0 ) continue;
$itemNode = eZContentObjectTreeNode::fetch( $item['node_id'] );
$itemClass = $itemNode->attribute( 'class_identifier' );
if ( in_array( $itemClass, $allowedClasses ) )
{
$titleArray[] = self::getMetaTitleItem( $itemNode );
$depth++;
if ( $depth >= $maxDepth ) break;
}
}
$itemNode = eZContentObjectTreeNode::fetch( $currentItem['node_id'] );
if ( $itemNode ) $titleArray[] = self::getMetaTitleItem( $itemNode );
$titleArray = array_reverse( $titleArray );
return implode( $separator, $titleArray );
}
示例5: copyObject
/**
* Create a copy of an object.
*
* The basis for this method is taken from kernel/content/copy.php
*
* @todo Merge this method into kernel wrapper's object class.
*
* @param eZContentObject $object
* @param int $newParentNodeID
* @return eZContentObject
*/
public static function copyObject($object, $newParentNodeID)
{
$newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID);
$db = eZDB::instance();
$db->begin();
$newObject = $object->copy(true);
// We should reset section that will be updated in updateSectionID().
// If sectionID is 0 than the object has been newly created
$newObject->setAttribute('section_id', 0);
$newObject->store();
$curVersion = $newObject->attribute('current_version');
$curVersionObject = $newObject->attribute('current');
$newObjAssignments = $curVersionObject->attribute('node_assignments');
unset($curVersionObject);
// remove old node assignments
foreach ($newObjAssignments as $assignment) {
$assignment->purge();
}
// and create a new one
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $newObject->attribute('id'), 'contentobject_version' => $curVersion, 'parent_node' => $newParentNodeID, 'is_main' => 1));
$nodeAssignment->store();
// publish the newly created object
eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute('id'), 'version' => $curVersion));
// Update "is_invisible" attribute for the newly created node.
$newNode = $newObject->attribute('main_node');
eZContentObjectTreeNode::updateNodeVisibility($newNode, $newParentNode);
$db->commit();
return $newObject;
}
示例6: testUnauthorizedContentByNode
/**
* @group issue18073
* @link http://issues.ez.no/18073
*/
public function testUnauthorizedContentByNode()
{
$this->setExpectedException('ezpContentAccessDeniedException');
// Let's take content node #5 / object #4 (users) as unauthorized content for anonymous user
$unauthorizedNodeID = 5;
$content = ezpContent::fromNode(eZContentObjectTreeNode::fetch($unauthorizedNodeID));
}
示例7: testDisplayVariableWithObject
/**
* Tests that the output process works with objects.
*
* There should be no crash from casting errors.
* @group templateOperators
* @group attributeOperator
*/
public function testDisplayVariableWithObject()
{
$db = eZDB::instance();
// STEP 1: Add test folder
$folder = new ezpObject( "folder", 2 );
$folder->name = __METHOD__;
$folder->publish();
$nodeId = $folder->mainNode->node_id;
$node = eZContentObjectTreeNode::fetch( $nodeId );
$attrOp = new eZTemplateAttributeOperator();
$outputTxt = '';
$formatterMock = $this->getMock( 'ezpAttributeOperatorFormatterInterface' );
$formatterMock->expects( $this->any() )
->method( 'line' )
->will( $this->returnValue( __METHOD__ ) );
try
{
$attrOp->displayVariable( $node, $formatterMock, true, 2, 0, $outputTxt );
}
catch ( PHPUnit_Framework_Error $e )
{
self::fail( "eZTemplateAttributeOperator raises an error when working with objects." );
}
self::assertNotNull( $outputTxt, "Output text is empty." );
// this is an approxmiate test. The output shoudl contain the name of the object it has been generated correctly.
self::assertContains( __METHOD__, $outputTxt, "There is something wrong with the output of the attribute operator. Object name not found." );
}
示例8: getNextItems
/**
* Returns block item XHTML
*
* @param mixed $args
* @return array
*/
public static function getNextItems($args)
{
$http = eZHTTPTool::instance();
$tpl = eZTemplate::factory();
$result = array();
$galleryID = $http->postVariable('gallery_id');
$offset = $http->postVariable('offset');
$limit = $http->postVariable('limit');
$galleryNode = eZContentObjectTreeNode::fetch($galleryID);
if ($galleryNode instanceof eZContentObjectTreeNode) {
$params = array('Depth' => 1, 'Offset' => $offset, 'Limit' => $limit);
$pictureNodes = $galleryNode->subtree($params);
foreach ($pictureNodes as $validNode) {
$tpl->setVariable('node', $validNode);
$tpl->setVariable('view', 'block_item');
$tpl->setVariable('image_class', 'blockgallery1');
$content = $tpl->fetch('design:node/view/view.tpl');
$result[] = $content;
if ($counter === $limit) {
break;
}
}
}
return $result;
}
示例9: fetch
public function fetch($parameters, $publishedAfter, $publishedBeforeOrAt)
{
if (isset($parameters['Source'])) {
$nodeID = $parameters['Source'];
$node = eZContentObjectTreeNode::fetch($nodeID, false, false);
// not as an object
if ($node && $node['modified_subnode'] <= $publishedAfter) {
return array();
}
} else {
$nodeID = 0;
}
$subTreeParameters = array();
$subTreeParameters['AsObject'] = false;
$subTreeParameters['SortBy'] = array('published', true);
// first the oldest
$subTreeParameters['AttributeFilter'] = array('and', array('published', '>', $publishedAfter), array('published', '<=', $publishedBeforeOrAt));
if (isset($parameters['Classes'])) {
$subTreeParameters['ClassFilterType'] = 'include';
$subTreeParameters['ClassFilterArray'] = explode(',', $parameters['Classes']);
}
// Do not fetch hidden nodes even when ShowHiddenNodes=true
$subTreeParameters['AttributeFilter'] = array('and', array('visibility', '=', true));
$nodes = eZContentObjectTreeNode::subTreeByNodeID($subTreeParameters, $nodeID);
if ($nodes === null) {
return array();
}
$fetchResult = array();
foreach ($nodes as $node) {
$fetchResult[] = array('object_id' => $node['contentobject_id'], 'node_id' => $node['node_id'], 'ts_publication' => $node['published']);
}
return $fetchResult;
}
示例10: validNodes
/**
* Return valid items for block with given $blockID
*
* @static
* @param string $blockID
* @param bool $asObject
* @return array(eZContentObjectTreeNode)
*/
static function validNodes($blockID, $asObject = true)
{
if (isset($GLOBALS['eZFlowPool']) === false) {
$GLOBALS['eZFlowPool'] = array();
}
if (isset($GLOBALS['eZFlowPool'][$blockID])) {
return $GLOBALS['eZFlowPool'][$blockID];
}
$visibilitySQL = "";
if (eZINI::instance('site.ini')->variable('SiteAccessSettings', 'ShowHiddenNodes') !== 'true') {
$visibilitySQL = "AND ezcontentobject_tree.is_invisible = 0 ";
}
$db = eZDB::instance();
$validNodes = $db->arrayQuery("SELECT ezm_pool.node_id\n FROM ezm_pool, ezcontentobject_tree, ezcontentobject\n WHERE ezm_pool.block_id='{$blockID}'\n AND ezm_pool.ts_visible>0\n AND ezm_pool.ts_hidden=0\n AND ezcontentobject_tree.node_id = ezm_pool.node_id\n AND ezcontentobject.id = ezm_pool.object_id\n AND " . eZContentLanguage::languagesSQLFilter('ezcontentobject') . "\n {$visibilitySQL}\n ORDER BY ezm_pool.priority DESC");
if ($asObject && !empty($validNodes)) {
$validNodesObjects = array();
foreach ($validNodes as $node) {
$validNodeObject = eZContentObjectTreeNode::fetch($node['node_id']);
if ($validNodeObject instanceof eZContentObjectTreeNode && $validNodeObject->canRead()) {
$validNodesObjects[] = $validNodeObject;
}
}
$GLOBALS['eZFlowPool'][$blockID] = $validNodesObjects;
return $validNodesObjects;
} else {
return $validNodes;
}
}
示例11: process
/**
* Kicks of the process of purging orphan nodes
*
* We delete orphans in a two step process:
* - 1. Iterate over a subtree and check if the node is an orphan and
* store it's node id if it is
* - 2. Loop over all node ids of orhpant nodes found in step 1 and delete
* them.
*
* This is needed as we cannot directly fetch a list of orphan nodes. This
* also prevents issues with using offset when fetching a list of nodes we
* intend to delete.
**/
public function process()
{
$iterator = $this->getSubtreeIterator();
$this->output->outputText(
'Looking for orphans under ' . $this->subTreeNode->urlAlias(). "\n", 'info'
);
$this->output->outputText(
'Will search ' . $iterator->count() . " objects for orphans ", 'info'
);
$orphanIds = array();
foreach( $iterator as $node )
{
if ( !$this->isNodeOrphan( $node ) )
continue;
$orphanIds[] = $node->NodeID;
$this->output->outputText( "." );
}
$orphanCount = count($orphanIds);
$this->output->outputText( "\nFound {$orphanCount} orphan objects\n", 'info' );
$count = 0;
foreach( $orphanIds as $nodeId )
{
if ($count % 200 == 0)
{
$this->output->outputText(
"Treated : {$count} / {$orphanCount}\n" , 'success'
);
}
$node = eZContentObjectTreeNode::fetch( $nodeId );
if ( !$node )
{
$this->output->outputText(
"Could not fetch node with id {$nodeId}'\n", 'error'
);
continue;
}
if ( $this->isDryRun )
{
$this->output->outputText(
"Found orphan, but not deleting {$nodeId} '" . $node->urlAlias() . "'\n"
);
}
else
{
$this->output->outputText(
"Deleting orphan {$nodeId} '" . $node->urlAlias() . "'\n"
);
$this->deleteNode( $node );
}
$count++;
if ( $count % 1000 == 0 )
eZContentObject::clearCache();
}
}
示例12: createUser
/**
* Creates a user with provided auth data
*
* @param array $authResult
*
* @return bool|eZUser
*/
public static function createUser($authResult)
{
$ngConnectINI = eZINI::instance('ngconnect.ini');
$siteINI = eZINI::instance('site.ini');
$defaultUserPlacement = $ngConnectINI->variable('LoginMethod_' . $authResult['login_method'], 'DefaultUserPlacement');
$placementNode = eZContentObjectTreeNode::fetch($defaultUserPlacement);
if (!$placementNode instanceof eZContentObjectTreeNode) {
$defaultUserPlacement = $siteINI->variable('UserSettings', 'DefaultUserPlacement');
$placementNode = eZContentObjectTreeNode::fetch($defaultUserPlacement);
if (!$placementNode instanceof eZContentObjectTreeNode) {
return false;
}
}
$contentClass = eZContentClass::fetch($siteINI->variable('UserSettings', 'UserClassID'));
$userCreatorID = $siteINI->variable('UserSettings', 'UserCreatorID');
$defaultSectionID = $siteINI->variable('UserSettings', 'DefaultSectionID');
$db = eZDB::instance();
$db->begin();
$contentObject = $contentClass->instantiate($userCreatorID, $defaultSectionID);
$contentObject->store();
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => 1, 'parent_node' => $placementNode->attribute('node_id'), 'is_main' => 1));
$nodeAssignment->store();
$currentTimeStamp = eZDateTime::currentTimeStamp();
/** @var eZContentObjectVersion $version */
$version = $contentObject->currentVersion();
$version->setAttribute('modified', $currentTimeStamp);
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$dataMap = $version->dataMap();
self::fillUserObject($version->dataMap(), $authResult);
if (!isset($dataMap['user_account'])) {
$db->rollback();
return false;
}
$userLogin = 'ngconnect_' . $authResult['login_method'] . '_' . $authResult['id'];
$userPassword = (string) rand() . 'ngconnect_' . $authResult['login_method'] . '_' . $authResult['id'] . (string) rand();
$userExists = false;
if (eZUser::requireUniqueEmail()) {
$userExists = eZUser::fetchByEmail($authResult['email']) instanceof eZUser;
}
if (empty($authResult['email']) || $userExists) {
$email = md5('ngconnect_' . $authResult['login_method'] . '_' . $authResult['id']) . '@localhost.local';
} else {
$email = $authResult['email'];
}
$user = new eZUser(array('contentobject_id' => $contentObject->attribute('id'), 'email' => $email, 'login' => $userLogin, 'password_hash' => md5("{$userLogin}\n{$userPassword}"), 'password_hash_type' => 1));
$user->store();
$userSetting = new eZUserSetting(array('is_enabled' => true, 'max_login' => 0, 'user_id' => $contentObject->attribute('id')));
$userSetting->store();
$dataMap['user_account']->setContent($user);
$dataMap['user_account']->store();
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObject->attribute('id'), 'version' => $version->attribute('version')));
if (array_key_exists('status', $operationResult) && $operationResult['status'] == eZModuleOperationInfo::STATUS_CONTINUE) {
$db->commit();
return $user;
}
$db->rollback();
return false;
}
示例13: getNode
protected static function getNode($parentNodeId)
{
$parentNode = $parentNodeId;
if (!$parentNode instanceof eZContentObjectTreeNode) {
$parentNode = eZContentObjectTreeNode::fetch($parentNodeId);
}
return $parentNode instanceof eZContentObjectTreeNode ? $parentNode : null;
}
示例14: mainNode
protected function mainNode()
{
if ( is_null($this->_mainNode) )
{
$this->_mainNode = eZContentObjectTreeNode::fetch( $this->mainNodeId );
}
return $this->_mainNode;
}
示例15: 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;
}