public static function fetchContentNode($nodeID, $nodePath, $languageCode, $remoteID = false) { $contentNode = null; if ($nodeID) { if (!isset($languageCode)) { $languageCode = false; } $contentNode = eZContentObjectTreeNodeNoLanguage::fetch($nodeID, $languageCode); } else { if ($nodePath) { $nodeID = eZURLAliasML::fetchNodeIDByPath($nodePath); if ($nodeID) { $contentNode = eZContentObjectTreeNodeNoLanguage::fetch($nodeID); } } else { if ($remoteID) { $contentNode = eZContentObjectTreeNodeNoLanguage::fetchByRemoteID($remoteID); } } } if ($contentNode === null) { $retVal = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND)); } else { $retVal = array('result' => $contentNode); } return $retVal; }
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 = eZContentObjectTreeNodeNoLanguage::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', eZContentObjectTreeNodeNoLanguage::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 = eZContentObjectTreeNodeNoLanguage::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' => eZContentObjectTreeNodeNoLanguage::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; }