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


PHP eZContentObjectTreeNode::fetchNode方法代码示例

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


在下文中一共展示了eZContentObjectTreeNode::fetchNode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.
     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:jordanmanning,项目名称:ezpublish,代码行数:58,代码来源:ezcontentobjecttreenodeoperations.php

示例2: publishNode

 public static function publishNode($parentNodeID, $objectID, $versionNum, $mainNodeID)
 {
     $object = eZContentObject::fetch($objectID);
     $nodeAssignment = eZNodeAssignment::fetch($objectID, $versionNum, $parentNodeID);
     $version = $object->version($versionNum);
     $fromNodeID = $nodeAssignment->attribute('from_node_id');
     $originalObjectID = $nodeAssignment->attribute('contentobject_id');
     $nodeID = $nodeAssignment->attribute('parent_node');
     $opCode = $nodeAssignment->attribute('op_code');
     $parentNode = eZContentObjectTreeNode::fetch($nodeID);
     // if parent doesn't exist, return. See issue #18320
     if (!$parentNode instanceof eZContentObjectTreeNode) {
         eZDebug::writeError("Parent node doesn't exist. object id: {$objectID}, node_assignment id: " . $nodeAssignment->attribute('id'), __METHOD__);
         return;
     }
     $parentNodeID = $parentNode->attribute('node_id');
     $existingNode = null;
     $db = eZDB::instance();
     $db->begin();
     if (strlen($nodeAssignment->attribute('parent_remote_id')) > 0) {
         $existingNode = eZContentObjectTreeNode::fetchByRemoteID($nodeAssignment->attribute('parent_remote_id'));
     }
     if (!$existingNode) {
     }
     $existingNode = eZContentObjectTreeNode::findNode($nodeID, $object->attribute('id'), true);
     $updateSectionID = false;
     // now we check the op_code to see what to do
     if (($opCode & 1) == eZNodeAssignment::OP_CODE_NOP) {
         // There is nothing to do so just return
         $db->commit();
         if ($mainNodeID == false) {
             return $object->attribute('main_node_id');
         }
         return;
     }
     $updateFields = false;
     if ($opCode == eZNodeAssignment::OP_CODE_MOVE || $opCode == eZNodeAssignment::OP_CODE_CREATE) {
         //            if ( $fromNodeID == 0 || $fromNodeID == -1)
         if ($opCode == eZNodeAssignment::OP_CODE_CREATE || $opCode == eZNodeAssignment::OP_CODE_SET) {
             // If the node already exists it means we have a conflict (for 'CREATE').
             // We resolve this by leaving node-assignment data be.
             if ($existingNode == null) {
                 $parentNode = eZContentObjectTreeNode::fetch($nodeID);
                 $user = eZUser::currentUser();
                 if (!eZSys::isShellExecution() and !$user->isAnonymous()) {
                     eZContentBrowseRecent::createNew($user->id(), $parentNode->attribute('node_id'), $parentNode->attribute('name'));
                 }
                 $updateFields = true;
                 $existingNode = $parentNode->addChild($object->attribute('id'), true);
                 if ($fromNodeID == -1) {
                     $updateSectionID = true;
                 }
             } elseif ($opCode == eZNodeAssignment::OP_CODE_SET) {
                 $updateFields = true;
             }
         } elseif ($opCode == eZNodeAssignment::OP_CODE_MOVE) {
             if ($fromNodeID == 0 || $fromNodeID == -1) {
                 eZDebug::writeError("NodeAssignment '" . $nodeAssignment->attribute('id') . "' is marked with op_code='{$opCode}' but has no data in from_node_id. Cannot use it for moving node.", __METHOD__);
             } else {
                 // clear cache for old placement.
                 $additionalNodeIDList = array($fromNodeID);
                 eZContentCacheManager::clearContentCacheIfNeeded($objectID, $versionNum, $additionalNodeIDList);
                 $originalNode = eZContentObjectTreeNode::fetchNode($originalObjectID, $fromNodeID);
                 if ($originalNode->attribute('main_node_id') == $originalNode->attribute('node_id')) {
                     $updateSectionID = true;
                 }
                 $originalNode->move($parentNodeID);
                 $existingNode = eZContentObjectTreeNode::fetchNode($originalObjectID, $parentNodeID);
                 $updateFields = true;
             }
         }
     } elseif ($opCode == eZNodeAssignment::OP_CODE_REMOVE) {
         $db->commit();
         return;
     }
     if ($updateFields) {
         if (strlen($nodeAssignment->attribute('parent_remote_id')) > 0) {
             $existingNode->setAttribute('remote_id', $nodeAssignment->attribute('parent_remote_id'));
         }
         $existingNode->setAttribute('sort_field', $nodeAssignment->attribute('sort_field'));
         $existingNode->setAttribute('sort_order', $nodeAssignment->attribute('sort_order'));
     }
     $existingNode->setAttribute('contentobject_is_published', 1);
     eZDebug::createAccumulatorGroup('nice_urls_total', 'Nice urls');
     if ($mainNodeID > 0) {
         $existingNodeID = $existingNode->attribute('node_id');
         if ($existingNodeID != $mainNodeID) {
             eZContentBrowseRecent::updateNodeID($existingNodeID, $mainNodeID);
         }
         $existingNode->setAttribute('main_node_id', $mainNodeID);
     } else {
         $existingNode->setAttribute('main_node_id', $existingNode->attribute('node_id'));
     }
     $existingNode->store();
     if ($updateSectionID) {
         eZContentOperationCollection::updateSectionID($objectID, $versionNum);
     }
     $db->commit();
     if ($mainNodeID == false) {
         return $existingNode->attribute('node_id');
//.........这里部分代码省略.........
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:101,代码来源:ezcontentoperationcollection.php

示例3: checkNodeActions


//.........这里部分代码省略.........
    // If node assignment handling is diabled we return
    $useNodeAssigments = true;
    if ( $http->hasPostVariable( 'UseNodeAssigments' ) )
        $useNodeAssigments = (bool)$http->postVariable( 'UseNodeAssigments' );

    if ( !$useNodeAssigments )
        return;

    // Remove custom actions from attribute editing.
    $http->removeSessionVariable( 'BrowseCustomAction' );

    if ( $module->isCurrentAction( 'ConfirmAssignmentDelete' ) && $http->hasPostVariable( 'RemoveNodeID' ) )
    {
        $nodeID = $http->postVariable( 'RemoveNodeID' );
        $db = eZDB::instance();
        $db->begin();
        $version->removeAssignment( $nodeID );
        $db->commit();
    }

    if ( $module->isCurrentAction( 'DeleteNode' ) )
    {

        if ( $http->hasPostVariable( 'RemoveNodeID' ) )
        {
            $nodeID = $http->postVariable( 'RemoveNodeID' );
        }

        $mainNodeID = $http->postVariable( 'MainNodeID' );

//         if ( $nodeID != $mainNodeID )
        {
            $objectID = $object->attribute( 'id' );
            $publishedNode = eZContentObjectTreeNode::fetchNode( $objectID, $nodeID );
            if ( $publishedNode != null )
            {
                $publishParentNodeID = $publishedNode->attribute( 'parent_node_id' );
                if ( $publishParentNodeID > 1 )
                {
                    $childrenCount = $publishedNode->childrenCount();
                    if ( $childrenCount != 0 )
                    {
                        $module->redirectToView( 'removenode', array( $objectID, $editVersion, $editLanguage, $nodeID ) );
                        return eZModule::HOOK_STATUS_CANCEL_RUN;
                    }
                    else
                    {
                        $db = eZDB::instance();
                        $db->begin();
                        $version->removeAssignment( $nodeID );
                        $db->commit();
                    }
                }
            }
            else
            {
                $nodeAssignment = eZNodeAssignment::fetch( $objectID, $version->attribute( 'version' ), $nodeID );
                if ( $nodeAssignment->attribute( 'from_node_id' ) != 0 )
                {
                    $publishedNode = eZContentObjectTreeNode::fetchNode( $objectID, $nodeAssignment->attribute( 'from_node_id' ) );
                    $childrenCount = 0;
                    if ( $publishedNode !== null )
                        $childrenCount = $publishedNode->childrenCount();
                    if ( $childrenCount != 0 )
                    {
                        $module->redirectToView( 'removenode', array( $objectID, $editVersion, $editLanguage, $nodeID ) );
开发者ID:nottavi,项目名称:ezpublish,代码行数:67,代码来源:node_edit.php

示例4: unserialize


//.........这里部分代码省略.........
            unset( $versionStatus );

            $firstVersion = false;
            $lastVersion = $contentObjectVersion->attribute( 'version' );
            if ( $versionDOMNode->getAttribute( 'version' ) == $versionListActiveVersion )
            {
                $activeVersion = $contentObjectVersion->attribute( 'version' );
            }
            eZNodeAssignment::setNewMainAssignment( $contentObject->attribute( 'id' ), $lastVersion );

            eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ),
                                                                      'version' => $lastVersion ) );

            $mainNodeInfo = null;
            foreach ( $nodeList as $nodeInfo )
            {
                if ( $nodeInfo['is_main'] )
                {
                    $mainNodeInfo =& $nodeInfo;
                    break;
                }
            }
            if ( $mainNodeInfo )
            {
                $existingMainNode = eZContentObjectTreeNode::fetchByRemoteID( $mainNodeInfo['parent_remote_id'], false );
                if ( $existingMainNode )
                {
                    eZContentObjectTreeNode::updateMainNodeID( $existingMainNode['node_id'],
                                                               $mainNodeInfo['contentobject_id'],
                                                               $mainNodeInfo['contentobject_version'],
                                                               $mainNodeInfo['parent_node'],
                                                               $updateWithParentSection );
                }
            }
            unset( $mainNodeInfo );
            // Refresh $contentObject from DB.
            $contentObject = eZContentObject::fetch( $contentObject->attribute( 'id' ) );
        }
        if ( !$activeVersion )
        {
            $activeVersion = $lastVersion;
        }

        /*
        $contentObject->setAttribute( 'current_version', $activeVersion );
        */
        $contentObject->setAttribute( 'name', $name );
        if ( isset( $options['use_dates_from_package'] ) && $options['use_dates_from_package'] )
        {
            $contentObject->setAttribute( 'published', eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'published' ) ) );
            $contentObject->setAttribute( 'modified', eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'modified' ) ) );
        }
        $contentObject->store();

        $versions   = $contentObject->versions();
        $objectName = $contentObject->name();
        $objectID   = $contentObject->attribute( 'id' );
        foreach ( $versions as $version )
        {
            $versionNum       = $version->attribute( 'version' );
            $oldVersionStatus = $version->attribute( 'status' );
            $newVersionStatus = isset( $versionList[$versionNum] ) ? $versionList[$versionNum]['status'] : null;

            // set the correct status for non-published versions
            if ( isset( $newVersionStatus ) && $oldVersionStatus != $newVersionStatus && $newVersionStatus != eZContentObjectVersion::STATUS_PUBLISHED )
            {
                $version->setAttribute( 'status', $newVersionStatus );
                $version->store( array( 'status' ) );
            }

            // when translation does not have object name set then we copy object name from the current object version
            $translations = $version->translations( false );
            if ( !$translations )
                continue;
            foreach ( $translations as $translation )
            {
                if ( ! $contentObject->name( $versionNum, $translation ) )
                {
                    eZDebug::writeNotice( "Setting name '$objectName' for version ($versionNum) of the content object ($objectID) in language($translation)" );
                    $contentObject->setName( $objectName, $versionNum, $translation );
                }
            }
        }

        foreach ( $versionList[$versionListActiveVersion]['node_list'] as $nodeInfo )
        {
            unset( $parentNode );
            $parentNode = eZContentObjectTreeNode::fetchNode( $contentObject->attribute( 'id' ),
                                                               $nodeInfo['parent_node'] );
            if ( is_object( $parentNode ) )
            {
                $parentNode->setAttribute( 'priority', $nodeInfo['priority'] );
                $parentNode->store( array( 'priority' ) );
            }
        }

        $db->commit();

        return $contentObject;
    }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:101,代码来源:ezcontentobject.php

示例5:

$Module = $Params['Module'];
$ObjectID = $Params['ObjectID'];

$NodeID = $Params['NodeID'];
if ( !isset( $EditVersion ) )
    $EditVersion = $Params['EditVersion'];

$object = eZContentObject::fetch( $ObjectID );
if ( $object === null )
    return $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' );

if ( !$object->attribute( 'can_remove' ) )
    return $Module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' );

$version = $object->version( $EditVersion );
$node = eZContentObjectTreeNode::fetchNode( $ObjectID, $NodeID );
if ( $node !== null )
    $ChildObjectsCount = $node->subTreeCount();
else
    $ChildObjectsCount = 0;
$ChildObjectsCount .= " ";
if ( $ChildObjectsCount == 1 )
    $ChildObjectsCount .= ezpI18n::tr( 'kernel/content/removenode',
                                  'child',
                                  '1 child' );
else
    $ChildObjectsCount .= ezpI18n::tr( 'kernel/content/removenode',
                                  'children',
                                  'several children' );

if ( $Module->isCurrentAction( 'ConfirmAssignmentRemove' ) )
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:31,代码来源:removenode.php

示例6: publishUpdateUser


//.........这里部分代码省略.........
                         $lastNameAttribute = $attribute;
                     }
                 }
             }
         }
     }
     //================= common part 2: start ========================
     if ($firstNameAttribute) {
         $firstNameAttribute->setAttribute('data_text', $first_name);
         $firstNameAttribute->store();
     }
     if ($lastNameAttribute) {
         $lastNameAttribute->setAttribute('data_text', $last_name);
         $lastNameAttribute->store();
     }
     if (!isset($userDataChanged) or $userDataChanged === true) {
         $contentClass = $contentObject->attribute('content_class');
         $name = $contentClass->contentObjectName($contentObject);
         $contentObject->setName($name);
     }
     if (!isset($emailChanged) or $emailChanged === true) {
         $user->setAttribute('email', $email);
     }
     $user->setAttribute('password_hash', "");
     $user->setAttribute('password_hash_type', 0);
     $user->store();
     $debugArray = array('Updating user data', 'createNewUser' => $createNewUser, 'userDataChanged' => isset($userDataChanged) ? $userDataChanged : null, 'login' => $login, 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'firstNameAttribute is_object' => is_object($firstNameAttribute), 'lastNameAttribute is_object' => is_object($lastNameAttribute), 'content object id' => $contentObjectID, 'version id' => $version->attribute('version'));
     eZDebug::writeNotice(var_export($debugArray, true), __METHOD__);
     //================= common part 2: end ==========================
     if ($createNewUser) {
         reset($parentNodeIDs);
         // prepare node assignments for publishing new user
         foreach ($parentNodeIDs as $parentNodeID) {
             $newNodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObjectID, 'contentobject_version' => 1, 'parent_node' => $parentNodeID, 'parent_remote_id' => uniqid('LDAP_'), 'is_main' => $defaultUserPlacement == $parentNodeID ? 1 : 0));
             $newNodeAssignment->store();
         }
         $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
     } else {
         if ($userDataChanged) {
             // Publish object
             $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => $version->attribute('version')));
             // Refetch object
             $contentObject = eZContentObject::fetch($contentObjectID);
             $version = $contentObject->attribute('current');
         }
         $LDAPIni = eZINI::instance('ldap.ini');
         $keepGroupAssignment = $LDAPIni->hasVariable('LDAPSettings', 'KeepGroupAssignment') ? $LDAPIni->variable('LDAPSettings', 'KeepGroupAssignment') == "enabled" : false;
         if ($keepGroupAssignment == false) {
             $objectIsChanged = false;
             $db = eZDB::instance();
             $db->begin();
             // First check existing assignments, remove any that should not exist
             $assignedNodesList = $contentObject->assignedNodes();
             $existingParentNodeIDs = array();
             foreach ($assignedNodesList as $node) {
                 $parentNodeID = $node->attribute('parent_node_id');
                 if (!in_array($parentNodeID, $parentNodeIDs)) {
                     $node->removeThis();
                     $objectIsChanged = true;
                 } else {
                     $existingParentNodeIDs[] = $parentNodeID;
                 }
             }
             // Then check assignments that should exist, add them if they are missing
             foreach ($parentNodeIDs as $parentNodeID) {
                 if (!in_array($parentNodeID, $existingParentNodeIDs)) {
                     $newNode = $contentObject->addLocation($parentNodeID, true);
                     $newNode->updateSubTreePath();
                     $newNode->setAttribute('contentobject_is_published', 1);
                     $newNode->sync();
                     $existingParentNodeIDs[] = $parentNodeID;
                     $objectIsChanged = true;
                 }
             }
             // Then ensure that the main node is correct
             $currentMainParentNodeID = $contentObject->attribute('main_parent_node_id');
             if ($currentMainParentNodeID != $defaultUserPlacement) {
                 $existingNode = eZContentObjectTreeNode::fetchNode($contentObjectID, $defaultUserPlacement);
                 if (!is_object($existingNode)) {
                     eZDebug::writeError("Cannot find assigned node as {$defaultUserPlacement}'s child.", __METHOD__);
                 } else {
                     $existingNodeID = $existingNode->attribute('node_id');
                     $versionNum = $version->attribute('version');
                     eZContentObjectTreeNode::updateMainNodeID($existingNodeID, $contentObjectID, $versionNum, $defaultUserPlacement);
                     $objectIsChanged = true;
                 }
             }
             $db->commit();
             // Finally, clear object view cache if something was changed
             if ($objectIsChanged) {
                 eZContentCacheManager::clearObjectViewCache($contentObjectID, true);
             }
         }
     }
     eZUser::updateLastVisit($userID);
     //eZUser::setCurrentlyLoggedInUser( $user, $userID );
     // Reset number of failed login attempts
     eZUser::setFailedLoginAttempts($userID, 0);
     return $user;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:101,代码来源:ezldapuser.php

示例7: getExtractableNodesCount

 function getExtractableNodesCount()
 {
     $classList = eZContentObjectAkismet::getExtractableClassList();
     $params = array('ClassFilterType' => 'include', 'ClassFilterArray' => $classList);
     $node = eZContentObjectTreeNode::fetchNode(1, 1);
     $nodeCount = $node->subTreeCount($params, 1);
     return $nodeCount;
 }
开发者ID:BGCX067,项目名称:ezakismet-svn-to-git,代码行数:8,代码来源:ezcontentobjectakismet.php


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