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


PHP eZNodeAssignment::setNewMainAssignment方法代码示例

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


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

示例1: checkNodeActions


//.........这里部分代码省略.........
                    $hasChildren = true;

                unset( $assignment );
            }

            if ( $hasChildren )
            {
                // We need user confirmation if at least one node we want to remove assignment for contains children.
                // Aactual removal is done in content/removeassignment in this case.
                $http->setSessionVariable( 'AssignmentRemoveData',
                                           array( 'remove_list'   => $assignmentsIDs,
                                                  'object_id'     => $objectID,
                                                  'edit_version'  => $versionInt,
                                                  'edit_language' => $editLanguage,
                                                  'from_language' => $fromLanguage ) );
                $module->redirectToView( 'removeassignment' );
                return eZModule::HOOK_STATUS_CANCEL_RUN;

            }
            else
            {
                // Just remove all the selected locations.
                $mainNodeChanged = false;
                $db = eZDB::instance();
                $db->begin();
                foreach ( $assignments as $assignment )
                {
                    $assignmentID = $assignment->attribute( 'id' );
                    if ( $assignment->attribute( 'is_main' ) )
                        $mainNodeChanged = true;
                    eZNodeAssignment::removeByID( $assignmentID );
                }
                if ( $mainNodeChanged )
                    eZNodeAssignment::setNewMainAssignment( $objectID, $versionInt );
                $db->commit();
                unset( $mainNodeChanged );
            }
            unset( $assignmentsIDs, $assignments );

        }
        else
        {
            eZDebug::writeNotice( 'No nodes to remove selected' );
        }
    }

    if ( $module->isCurrentAction( 'MoveNode' ) )
    {
        $objectID = $object->attribute( 'id' );
        if ( $http->hasPostVariable( 'MoveNodeID' ) )
        {
            $fromNodeID = $http->postVariable( 'MoveNodeID' ); //$sourceNodeID[0];
            $oldAssignmentParentID = $fromNodeID;
            $fromNodeAssignment = eZNodeAssignment::fetch( $objectID, $version->attribute( 'version' ), $fromNodeID );
            $publishParentNodeID = $fromNodeAssignment->attribute( 'parent_node' );
            if ( $publishParentNodeID > 1 )
            {
                if( $fromNodeAssignment->attribute( 'from_node_id' ) != 0 )
                {
                    $fromNodeID = $fromNodeAssignment->attribute( 'from_node_id' );
                    $oldAssignmentParentID = $fromNodeAssignment->attribute( 'parent_node' );
                }

                // we don't allow moving object to itself, to its descendants or parent object(s)
                $objectAssignedNodes = $object->attribute( 'assigned_nodes' );
开发者ID:nottavi,项目名称:ezpublish,代码行数:66,代码来源:node_edit.php

示例2: foreach

// process current action
if ($module->isCurrentAction('ConfirmRemoval')) {
    $http->removeSessionVariable('AssignmentRemoveData');
    $assignments = eZNodeAssignment::fetchListByID($removeList);
    $mainNodeChanged = false;
    $db = eZDB::instance();
    $db->begin();
    foreach ($assignments as $assignment) {
        $assignmentID = $assignment->attribute('id');
        if ($assignment->attribute('is_main')) {
            $mainNodeChanged = true;
        }
        eZNodeAssignment::purgeByID($assignmentID);
    }
    if ($mainNodeChanged) {
        eZNodeAssignment::setNewMainAssignment($objectID, $editVersion);
    }
    $db->commit();
    return $module->redirectToView('edit', array($objectID, $editVersion, $editLanguage, $fromLanguage));
} else {
    if ($module->isCurrentAction('CancelRemoval')) {
        $http->removeSessionVariable('AssignmentRemoveData');
        return $module->redirectToView('edit', array($objectID, $editVersion, $editLanguage, $fromLanguage));
    }
}
// default action: show the confirmation dialog
$assignmentsToRemove = eZNodeAssignment::fetchListByID($removeList);
$removeList = array();
$canRemoveAll = true;
foreach ($assignmentsToRemove as $assignment) {
    $node = $assignment->attribute('node');
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:31,代码来源:removeassignment.php

示例3: unserialize


//.........这里部分代码省略.........
            unset( $nodeList );
            $nodeList = array();
            $contentObjectVersion = eZContentObjectVersion::unserialize( $versionDOMNode,
                                                                         $contentObject,
                                                                         $ownerID,
                                                                         $sectionID,
                                                                         $versionListActiveVersion,
                                                                         $firstVersion,
                                                                         $nodeList,
                                                                         $options,
                                                                         $package,
                                                                         'ezcontentobject',
                                                                         $initialLanguage );

            if ( !$contentObjectVersion )
            {
                $db->commit();

                $retValue = false;
                return $retValue;
            }

            $versionStatus = $versionDOMNode->getAttributeNS( 'http://ez.no/ezobject', 'status' );
            $versionList[$versionDOMNode->getAttributeNS( 'http://ez.no/ezobject', 'version' )] = array( 'node_list' => $nodeList,
                                                                                                         'status' =>    $versionStatus );
            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;
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:67,代码来源:ezcontentobject.php

示例4: removeNodeAssignments

 /**
  * Removes previously selected, now unselected assignments.
  * 
  * This hook is run at "post_store" time.
  *
  * @param mixed  $module                  Is eZModule.
  * @param mixed  $class                   Is eZContentClass.
  * @param mixed  $object                  Is eZContentObject.
  * @param mixed  $version                 Is eZContentObjectVersion.
  * @param mixed  $contentObjectAttributes Is eZContentObjectAttribute.
  * @param string $editVersion             Number as String.
  * @param string $editLanguage            E.g. eng-GB.
  * @param mixed  $fromLanguage            Or false.
  * @param mixed  &$validation             Array.
  * 
  * @return int eZModule::HOOK_STATUS_CANCEL_RUN
  */
 public function removeNodeAssignments($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage, &$validation)
 {
     $http = eZHTTPTool::instance();
     if (!$http->hasPostVariable('ymcNodeAssignmentsPool')) {
         return eZModule::HOOK_STATUS_OK;
     }
     $ymcActiveNodeAssignmentsPool = $http->postVariable('ymcActiveNodeAssignmentsPool');
     $ymcNodeAssignmentsPool = $http->postVariable('ymcNodeAssignmentsPool');
     if (!is_array($ymcActiveNodeAssignmentsPool)) {
         $ymcActiveNodeAssignmentsPool = array();
     }
     if (!is_array($ymcNodeAssignmentsPool)) {
         $ymcNodeAssignmentsPool = array();
     }
     $selected = array();
     foreach ($ymcNodeAssignmentsPool as $ymcAllNodeAssignment) {
         if ((int) $ymcAllNodeAssignment > 0 and !in_array($ymcAllNodeAssignment, $ymcActiveNodeAssignmentsPool)) {
             $selected[] = (int) $ymcAllNodeAssignment;
         }
     }
     $objectID = $object->attribute('id');
     $versionInt = $version->attribute('version');
     $hasChildren = false;
     $assignmentsIDs = array();
     $assignments = array();
     // Determine if at least one node of ones we remove assignments for has children.
     foreach ($selected as $parentNodeID) {
         $assignment = eZNodeAssignment::fetch($objectID, $versionInt, $parentNodeID);
         if (!$assignment) {
             eZDebug::writeWarning("[ymcEdit] No assignment found for object {$objectID} version {$versionInt},\n                                       parent node {$parentNodeID}");
             continue;
         }
         $assignmentID = $assignment->attribute('id');
         $assignmentsIDs[] = $assignmentID;
         $assignments[] =& $assignment;
         $node =& $assignment->attribute('node');
         if (!$node) {
             continue;
         }
         if ($node->childrenCount(false) > 0) {
             $hasChildren = true;
         }
         unset($assignment);
     }
     if ($hasChildren) {
         // We need user confirmation if at least one node we want to
         // remove assignment for contains children.  Aactual removal is
         // done in content/removeassignment in this case.
         $http->setSessionVariable('AssignmentRemoveData', array('remove_list' => $assignmentsIDs, 'object_id' => $objectID, 'edit_version' => $versionInt, 'edit_language' => $editLanguage, 'from_language' => $fromLanguage));
         $module->redirectToView('removeassignment');
         return eZModule::HOOK_STATUS_CANCEL_RUN;
     } else {
         // Just remove all the selected locations.
         $mainNodeChanged = false;
         $db = eZDB::instance();
         $db->begin();
         foreach ($assignments as $assignment) {
             $assignmentID = $assignment->attribute('id');
             if ($assignment->attribute('is_main')) {
                 $mainNodeChanged = true;
             }
             eZNodeAssignment::removeByID($assignmentID);
         }
         if ($mainNodeChanged) {
             eZNodeAssignment::setNewMainAssignment($objectID, $versionInt);
         }
         $db->commit();
         unset($mainNodeChanged);
     }
     unset($assignmentsIDs, $assignments);
 }
开发者ID:kmajkowski,项目名称:ymc-ezp-datatypes,代码行数:88,代码来源:ymc_edit_hooks.php


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