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


PHP eZNodeAssignment::definition方法代码示例

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


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

示例1: checkNodeMovements

function checkNodeMovements( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $FromLanguage, &$validation )
{
    $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;

    $ObjectID = $object->attribute( 'id' );
    // Move to another node
    if ( $module->isCurrentAction( 'MoveNodeAssignment' ) )
    {
        $selectedNodeIDArray = eZContentBrowse::result( 'MoveNodeAssignment' );
        $fromNodeID = $http->postVariable( "FromNodeID" );
        $oldAssignmentParentID = $http->postVariable( 'OldAssignmentParentID' );

        if ( $selectedNodeIDArray != null )
        {
            $assignedNodes = $version->nodeAssignments();
            $assignedIDArray = array();
            foreach ( $assignedNodes as  $assignedNode )
            {
                $assignedNodeID = $assignedNode->attribute( 'parent_node' );
                $assignedIDArray[] = $assignedNodeID;
            }
            foreach ( $selectedNodeIDArray as $nodeID )
            {
                if ( !in_array( $nodeID, $assignedIDArray ) )
                {
                    $isPermitted = true;
                    // Check access
                    $newNode = eZContentObjectTreeNode::fetch( $nodeID );
                    $newNodeObject = $newNode->attribute( 'object' );

                    $canCreate = $newNodeObject->checkAccess( 'create', $class->attribute( 'id' ), $newNodeObject->attribute( 'contentclass_id' ) ) == 1;
                    eZDebug::writeDebug( $canCreate,"can create");
                    if ( !$canCreate )
                    {
                        $isPermitted = false;
                    }
                    else
                    {
                        $canCreateClassList = $newNodeObject->attribute( 'can_create_class_list' );
                        $canCreateClassIDList = array();
                        foreach ( array_keys( $canCreateClassList ) as $key )
                        {
                            $canCreateClassIDList[] = $canCreateClassList[$key]['id'];
                        }
                        $objectClassID = $object->attribute( 'contentclass_id' );
                        if ( !in_array( $objectClassID, $canCreateClassIDList ) )
                             $isPermitted = false;
                    }
                    if ( !$isPermitted )
                    {
                        eZDebug::writeError( $newNode->pathWithNames(), "You are not allowed to place this object under:" );
                        $validation[ 'placement' ][] = array( 'text' => ezpI18n::tr( 'kernel/content', "You are not allowed to place this object under: %1", null, array( $newNode->pathWithNames() ) ) );
                        $validation[ 'processed' ] = true;
                        // Error message.
                    }
                    else
                    {
                        $oldAssignment = eZPersistentObject::fetchObject( eZNodeAssignment::definition(),
                                                                           null,
                                                                           array( 'contentobject_id' => $object->attribute( 'id' ),
                                                                                  'parent_node' => $oldAssignmentParentID,
                                                                                  'contentobject_version' => $version->attribute( 'version' )
                                                                                  ),
                                                                           true );

                        $realNode = eZContentObjectTreeNode::fetchNode( $version->attribute( 'contentobject_id' ), $oldAssignment->attribute( 'parent_node' ) );

                        $db = eZDB::instance();
                        $db->begin();
                        // No longer remove then add assignment, instead change the existing one
                        if ( $realNode  === null )
                        {
                            $fromNodeID = 0;
                        }
                        if ( $oldAssignment->attribute( 'is_main' ) == '1' )
                        {
                            $oldAssignment->setAttribute( 'parent_node', $nodeID );
                            $oldAssignment->setAttribute( 'is_main', 1 );
                            $oldAssignment->setAttribute( 'from_node_id', $fromNodeID );
//                            $version->assignToNode( $nodeID, 1, $fromNodeID, $oldAssignment->attribute( 'sort_field' ), $oldAssignment->attribute( 'sort_order' ) );
                        }
                        else
                        {
                            $oldAssignment->setAttribute( 'parent_node', $nodeID );
                            $oldAssignment->setAttribute( 'is_main', 0 );
                            $oldAssignment->setAttribute( 'from_node_id', $fromNodeID );
//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:node_edit.php

示例2: installSuspendedNodeAssignment

    function installSuspendedNodeAssignment( &$installParameters )
    {
        if ( !isset( $installParameters['suspended-nodes'] ) )
        {
            return;
        }
        foreach ( $installParameters['suspended-nodes'] as $parentNodeRemoteID => $suspendedNodeInfo )
        {
            $parentNode = eZContentObjectTreeNode::fetchByRemoteID( $parentNodeRemoteID );
            if ( $parentNode !== null )
            {
                $nodeInfo = $suspendedNodeInfo['nodeinfo'];
                $nodeInfo['parent_node'] = $parentNode->attribute( 'node_id' );

                $existNodeAssignment = eZPersistentObject::fetchObject( eZNodeAssignment::definition(),
                                                           null,
                                                           $nodeInfo );
                $nodeInfo['priority'] = $suspendedNodeInfo['priority'];
                if( !is_object( $existNodeAssignment ) )
                {
                    $nodeAssignment = eZNodeAssignment::create( $nodeInfo );
                    $nodeAssignment->store();
                }

                $contentObject = eZContentObject::fetch( $nodeInfo['contentobject_id'] );
                if ( is_object( $contentObject ) && $contentObject->attribute( 'current_version' ) == $nodeInfo['contentobject_version'] )
                {
                   eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $nodeInfo['contentobject_id'],
                                                                              'version' =>  $nodeInfo['contentobject_version'] ) );
                }
                if ( isset( $nodeInfo['is_main'] ) && $nodeInfo['is_main'] )
                {
                    $existingMainNode = eZContentObjectTreeNode::fetchByRemoteID( $nodeInfo['parent_remote_id'], false );
                    if ( $existingMainNode )
                    {
                        eZContentObjectTreeNode::updateMainNodeID( $existingMainNode['node_id'],
                                                                   $nodeInfo['contentobject_id'],
                                                                   $nodeInfo['contentobject_version'],
                                                                   $nodeInfo['parent_node'] );
                    }
                }
            }
            else
            {
                eZDebug::writeError( 'Can not find parent node by remote-id ID = ' . $parentNodeRemoteID, __METHOD__ );
            }
            unset( $installParameters['suspended-nodes'][$parentNodeRemoteID] );
        }
    }
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:49,代码来源:ezcontentobjectpackagehandler.php

示例3: unserialize

 static function unserialize($contentNodeDOMNode, $contentObject, $version, $isMain, &$nodeList, &$options, $handlerType = 'ezcontentobject')
 {
     $parentNodeID = -1;
     $remoteID = $contentNodeDOMNode->getAttribute('remote-id');
     $parentNodeRemoteID = $contentNodeDOMNode->getAttribute('parent-node-remote-id');
     $node = eZContentObjectTreeNode::fetchByRemoteID($remoteID);
     if (is_object($node)) {
         $description = "Node with remote ID {$remoteID} already exists.";
         $choosenAction = eZPackageHandler::errorChoosenAction(eZContentObject::PACKAGE_ERROR_EXISTS, $options, $description, $handlerType, false);
         switch ($choosenAction) {
             // In case user have choosen "Keep existing object and create new"
             case eZContentObject::PACKAGE_NEW:
                 $newRemoteID = eZRemoteIdUtility::generate('node');
                 $node->setAttribute('remote_id', $newRemoteID);
                 $node->store();
                 $nodeInfo = array('contentobject_id' => $node->attribute('contentobject_id'), 'contentobject_version' => $node->attribute('contentobject_version'), 'parent_remote_id' => $remoteID);
                 $nodeAssignment = eZPersistentObject::fetchObject(eZNodeAssignment::definition(), null, $nodeInfo);
                 if (is_object($nodeAssignment)) {
                     $nodeAssignment->setAttribute('parent_remote_id', $newRemoteID);
                     $nodeAssignment->store();
                 }
                 break;
                 // When running non-interactively with ezpm.php
             // When running non-interactively with ezpm.php
             case eZPackage::NON_INTERACTIVE:
             case eZContentObject::PACKAGE_UPDATE:
                 // Update existing node settigns.
                 if (!$parentNodeRemoteID) {
                     // when top node of subtree export, only update node sort field and sort order
                     $node->setAttribute('sort_field', eZContentObjectTreeNode::sortFieldID($contentNodeDOMNode->getAttribute('sort-field')));
                     $node->setAttribute('sort_order', $contentNodeDOMNode->getAttribute('sort-order'));
                     $node->store();
                     return true;
                 }
                 break;
             default:
                 // This error may occur only if data integrity is broken
                 $options['error'] = array('error_code' => eZContentObject::PACKAGE_ERROR_NODE_EXISTS, 'element_id' => $remoteID, 'description' => $description);
                 return false;
                 break;
         }
     }
     if ($parentNodeRemoteID) {
         $parentNode = eZContentObjectTreeNode::fetchByRemoteID($parentNodeRemoteID);
         if ($parentNode !== null) {
             $parentNodeID = $parentNode->attribute('node_id');
         }
     } else {
         if (isset($options['top_nodes_map'][$contentNodeDOMNode->getAttribute('node-id')]['new_node_id'])) {
             $parentNodeID = $options['top_nodes_map'][$contentNodeDOMNode->getAttribute('node-id')]['new_node_id'];
         } else {
             if (isset($options['top_nodes_map']['*'])) {
                 $parentNodeID = $options['top_nodes_map']['*'];
             } else {
                 eZDebug::writeError('New parent node not set ' . $contentNodeDOMNode->getAttribute('name'), __METHOD__);
             }
         }
     }
     $isMain = $isMain && $contentNodeDOMNode->getAttribute('is-main-node');
     $nodeInfo = array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => $version, 'is_main' => $isMain, 'parent_node' => $parentNodeID, 'parent_remote_id' => $remoteID, 'sort_field' => eZContentObjectTreeNode::sortFieldID($contentNodeDOMNode->getAttribute('sort-field')), 'sort_order' => $contentNodeDOMNode->getAttribute('sort-order'));
     if ($parentNodeID == -1 && $parentNodeRemoteID) {
         if (!isset($options['suspended-nodes'])) {
             $options['suspended-nodes'] = array();
         }
         $options['suspended-nodes'][$parentNodeRemoteID] = array('nodeinfo' => $nodeInfo, 'priority' => $contentNodeDOMNode->getAttribute('priority'));
         return true;
     }
     $existNodeAssignment = eZPersistentObject::fetchObject(eZNodeAssignment::definition(), null, $nodeInfo);
     $nodeInfo['priority'] = $contentNodeDOMNode->getAttribute('priority');
     if (!is_object($existNodeAssignment)) {
         $nodeAssignment = eZNodeAssignment::create($nodeInfo);
         $nodeList[] = $nodeInfo;
         $nodeAssignment->store();
     }
     return true;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:76,代码来源:ezcontentobjecttreenode.php

示例4: starts

$cli->warning("For more details about this cleanup, see https://jira.ez.no/browse/EZP-22260");
$cli->output();
$cli->output("Found total of {$totalCount} node assignments to be updated");
$cli->output();
if ($totalCount == 0) {
    $cli->output("Nothing to process, exiting");
    $script->shutdown(0);
}
if (!isset($options['n'])) {
    $cli->warning("You have 30 seconds to break the script before actual processing starts (press Ctrl-C)");
    $cli->warning("(execute the script with '-n' switch to skip this delay)");
    sleep(30);
    $cli->output();
}
$db = eZDB::instance();
while ($nodeAssignments = eZPersistentObject::fetchObjectList(eZNodeAssignment::definition(), null, $condition, null, $limit)) {
    $db->begin();
    /** @var $nodeAssignments \ezNodeAssignment[] */
    foreach ($nodeAssignments as $nodeAssignment) {
        $currentParentRemoteId = $nodeAssignment->attribute("parent_remote_id");
        if (!empty($currentParentRemoteId)) {
            $cli->output("Skipped: node assignment #{$nodeAssignment->ID}");
            continue;
        }
        $currentRemoteId = $nodeAssignment->attribute("remote_id");
        if (!empty($currentRemoteId)) {
            $nodeAssignment->setAttribute("remote_id", 0);
            $nodeAssignment->setAttribute("parent_remote_id", $currentRemoteId);
            $cli->output("Updated node assignment #{$nodeAssignment->ID}: copied 'parent_remote_id' from 'remote_id'");
        } else {
            $nodeAssignment->setAttribute("parent_remote_id", eZRemoteIdUtility::generate("eznode_assignment"));
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:31,代码来源:updatenodeassignmentparentremoteids.php

示例5: updateVisibility

 /**
  * Change node`s visibility
  *
  * @private
  * @param eZContentObject $object
  * @param bool $visibility
  * @return void
  */
 private function updateVisibility($object, $visibility = true)
 {
     $action = $visibility ? 'show' : 'hide';
     $nodeAssigments = eZPersistentObject::fetchObjectList(eZNodeAssignment::definition(), null, array('contentobject_id' => $object->attribute('id'), 'contentobject_version' => $object->attribute('current_version')), null, null, true);
     foreach ($nodeAssigments as $nodeAssigment) {
         $node = $nodeAssigment->attribute('node');
         if ($node instanceof eZContentObjectTreeNode === false) {
             continue;
         }
         if ((bool) (!$node->attribute('is_hidden')) === (bool) $visibility) {
             continue;
         }
         if ($action == 'show') {
             eZContentObjectTreeNode::unhideSubTree($node);
         } else {
             eZContentObjectTreeNode::hideSubTree($node);
         }
         eZSearch::updateNodeVisibility($node->attribute('node_id'), $action);
     }
 }
开发者ID:nxc,项目名称:nxc_powercontent,代码行数:28,代码来源:powercontent.php


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