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


PHP eZContentObjectTreeNode::findNode方法代码示例

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


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

示例1: storeNodeAssignments

function storeNodeAssignments( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage )
{
    $http = eZHTTPTool::instance();

    // If the object has been previously published we do not allow node assignment operations
    if ( $object->attribute( 'status' ) != eZContentObject::STATUS_DRAFT )
    {
        return;
    }

    // If node assignment handling is diabled we return immedieately
    $useNodeAssigments = true;
    if ( $http->hasPostVariable( 'UseNodeAssigments' ) )
        $useNodeAssigments = (bool)$http->postVariable( 'UseNodeAssigments' );

    if ( !$useNodeAssigments )
        return;

    $setPlacementNodeIDArray = array();
    if ( $http->hasPostVariable( 'SetPlacementNodeIDArray' ) )
        $setPlacementNodeIDArray = $http->postVariable( 'SetPlacementNodeIDArray' );

    // We will quit if some important POST variables are missing
    if ( !$http->hasPostVariable( 'MainNodeID' ) and
         !$http->hasPostVariable( 'SortOrderMap' ) and
         !$http->hasPostVariable( 'SortFieldMap' ) )
        return;

    $mainNodeID = false;
    if ( $http->hasPostVariable( 'MainNodeID' ) )
    {
        $mainNodeID = trim( $http->postVariable( 'MainNodeID' ) );
        if ( strlen( $mainNodeID ) == 0 )
            return;
    }

    // Check if dropdown placement is used
    if ( $http->hasPostVariable( 'MainAssignmentElementNumber' ) )
    {
        $elementNumber = $http->postVariable( 'MainAssignmentElementNumber' );

        $mainNodeID = $setPlacementNodeIDArray[$elementNumber];
    }

    $nodeID = eZContentObjectTreeNode::findNode( $mainNodeID, $object->attribute('id') );
    eZDebugSetting::writeDebug( 'kernel-content-edit', $nodeID, 'nodeID' );
//    $object->setAttribute( 'main_node_id', $nodeID );
    $nodeAssignments = eZNodeAssignment::fetchForObject( $object->attribute( 'id' ), $version->attribute( 'version' ) ) ;
    eZDebugSetting::writeDebug( 'kernel-content-edit', $mainNodeID, "mainNodeID" );


    $setPlacementNodeIDArray = array_unique( $setPlacementNodeIDArray );
    eZDebugSetting::writeDebug( 'kernel-content-edit', $setPlacementNodeIDArray, '$setPlacementNodeIDArray' );
    $remoteIDFieldMap = array();
    if ( $http->hasPostVariable( 'SetRemoteIDFieldMap' ) )
        $remoteIDFieldMap = $http->postVariable( 'SetRemoteIDFieldMap' );
    $remoteIDOrderMap = array();
    if ( $http->hasPostVariable( 'SetRemoteIDOrderMap' ) )
        $remoteIDOrderMap = $http->postVariable( 'SetRemoteIDOrderMap' );

    $db = eZDB::instance();
    $db->begin();
    if ( count( $setPlacementNodeIDArray ) > 0 )
    {
        foreach ( $setPlacementNodeIDArray as $setPlacementRemoteID => $setPlacementNodeID )
        {
            $hasAssignment = false;
            foreach ( $nodeAssignments as $nodeAssignment )
            {
                if ( $nodeAssignment->attribute( 'remote_id' ) == $setPlacementRemoteID )
                {
                    eZDebugSetting::writeDebug( 'kernel-content-edit', "Remote ID $setPlacementRemoteID already in use for node " . $nodeAssignment->attribute( 'parent_node' ), 'node_edit' );
                    if ( isset( $remoteIDFieldMap[$setPlacementRemoteID] ) )
                        $nodeAssignment->setAttribute( 'sort_field',  $remoteIDFieldMap[$setPlacementRemoteID] );
                    if ( isset( $remoteIDOrderMap[$setPlacementRemoteID] ) )
                        $nodeAssignment->setAttribute( 'sort_order', $remoteIDOrderMap[$setPlacementRemoteID] );
                    $nodeAssignment->setAttribute( 'parent_node', $setPlacementNodeID );
                    $nodeAssignment->sync();
                    $hasAssignment = true;
                    break;
                }
            }
            if ( !$hasAssignment )
            {
                eZDebugSetting::writeDebug( 'kernel-content-edit', "Adding to node $setPlacementNodeID", 'node_edit' );
                $sortField = null;
                $sortOrder = null;
                if ( isset( $remoteIDFieldMap[$setPlacementRemoteID] ) )
                    $sortField = $remoteIDFieldMap[$setPlacementRemoteID];
                if ( isset( $remoteIDOrderMap[$setPlacementRemoteID] ) )
                    $sortOrder = $remoteIDOrderMap[$setPlacementRemoteID];
                $version->assignToNode( $setPlacementNodeID, 0, 0, $sortField, $sortOrder, $setPlacementRemoteID );
            }
        }
        $nodeAssignments = eZNodeAssignment::fetchForObject( $object->attribute( 'id' ), $version->attribute( 'version' ) );
    }

    $sortOrderMap = false;
    if ( $http->hasPostVariable( 'SortOrderMap' ) )
        $sortOrderMap = $http->postVariable( 'SortOrderMap' );
//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:node_edit.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: deleteNodeWhereParent

 static function deleteNodeWhereParent($node, $id)
 {
     eZContentObjectTreeNode::removeNode(eZContentObjectTreeNode::findNode($node, $id));
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:4,代码来源:ezcontentobjecttreenode.php


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