本文整理汇总了PHP中eZContentObjectTreeNode::sortFieldID方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::sortFieldID方法的具体用法?PHP eZContentObjectTreeNode::sortFieldID怎么用?PHP eZContentObjectTreeNode::sortFieldID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::sortFieldID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: install
function install($package, $installType, $parameters, $name, $os, $filename, $subdirectory, $content, &$installParameters, &$installData)
{
$serializedNameListNode = $content->getElementsByTagName('serialized-name-list')->item(0);
$serializedNameList = $serializedNameListNode ? $serializedNameListNode->textContent : false;
$classNameList = new eZContentClassNameList($serializedNameList);
if ($classNameList->isEmpty()) {
$classNameList->initFromString($content->getElementsByTagName('name')->item(0)->textContent);
// for backward compatibility( <= 3.8 )
}
$classNameList->validate();
$serializedDescriptionListNode = $content->getElementsByTagName('serialized-description-list')->item(0);
$serializedDescriptionList = $serializedDescriptionListNode ? $serializedDescriptionListNode->textContent : false;
$classDescriptionList = new eZSerializedObjectNameList($serializedDescriptionList);
$classIdentifier = $content->getElementsByTagName('identifier')->item(0)->textContent;
$classRemoteID = $content->getElementsByTagName('remote-id')->item(0)->textContent;
$classObjectNamePattern = $content->getElementsByTagName('object-name-pattern')->item(0)->textContent;
$classURLAliasPattern = is_object($content->getElementsByTagName('url-alias-pattern')->item(0)) ? $content->getElementsByTagName('url-alias-pattern')->item(0)->textContent : null;
$classIsContainer = $content->getAttribute('is-container');
if ($classIsContainer !== false) {
$classIsContainer = $classIsContainer == 'true' ? 1 : 0;
}
$classRemoteNode = $content->getElementsByTagName('remote')->item(0);
$classID = $classRemoteNode->getElementsByTagName('id')->item(0)->textContent;
$classGroupsNode = $classRemoteNode->getElementsByTagName('groups')->item(0);
$classCreated = $classRemoteNode->getElementsByTagName('created')->item(0)->textContent;
$classModified = $classRemoteNode->getElementsByTagName('modified')->item(0)->textContent;
$classCreatorNode = $classRemoteNode->getElementsByTagName('creator')->item(0);
$classModifierNode = $classRemoteNode->getElementsByTagName('modifier')->item(0);
$classAttributesNode = $content->getElementsByTagName('attributes')->item(0);
$dateTime = time();
$classCreated = $dateTime;
$classModified = $dateTime;
$userID = false;
if (isset($installParameters['user_id'])) {
$userID = $installParameters['user_id'];
}
$class = eZContentClass::fetchByRemoteID($classRemoteID);
if ($class) {
$className = $class->name();
$description = ezpI18n::tr('kernel/package', "Class '%classname' already exists.", false, array('%classname' => $className));
$choosenAction = $this->errorChoosenAction(self::ERROR_EXISTS, $installParameters, $description, $this->HandlerType);
switch ($choosenAction) {
case eZPackage::NON_INTERACTIVE:
case self::ACTION_REPLACE:
if (eZContentClassOperations::remove($class->attribute('id')) == false) {
eZDebug::writeWarning("Unable to remove class '{$className}'.");
return true;
}
eZDebug::writeNotice("Class '{$className}' will be replaced.", 'eZContentClassPackageHandler');
break;
case self::ACTION_SKIP:
return true;
case self::ACTION_NEW:
$class->setAttribute('remote_id', eZRemoteIdUtility::generate('class'));
$class->store();
$classNameList->appendGroupName(" (imported)");
break;
default:
$installParameters['error'] = array('error_code' => self::ERROR_EXISTS, 'element_id' => $classRemoteID, 'description' => $description, 'actions' => array());
if ($class->isRemovable()) {
$errorMsg = ezpI18n::tr('kernel/package', "Replace existing class");
$objectsCount = eZContentObject::fetchSameClassListCount($class->attribute('id'));
if ($objectsCount) {
$errorMsg .= ' ' . ezpI18n::tr('kernel/package', "(Warning! {$objectsCount} content object(s) and their sub-items will be removed)");
}
$installParameters['error']['actions'][self::ACTION_REPLACE] = $errorMsg;
}
$installParameters['error']['actions'][self::ACTION_SKIP] = ezpI18n::tr('kernel/package', 'Skip installing this class');
$installParameters['error']['actions'][self::ACTION_NEW] = ezpI18n::tr('kernel/package', 'Keep existing and create a new one');
return false;
}
}
unset($class);
// Try to create a unique class identifier
$currentClassIdentifier = $classIdentifier;
$unique = false;
while (!$unique) {
$classList = eZContentClass::fetchByIdentifier($currentClassIdentifier);
if ($classList) {
// "increment" class identifier
if (preg_match('/^(.*)_(\\d+)$/', $currentClassIdentifier, $matches)) {
$currentClassIdentifier = $matches[1] . '_' . ($matches[2] + 1);
} else {
$currentClassIdentifier = $currentClassIdentifier . '_1';
}
} else {
$unique = true;
}
unset($classList);
}
$classIdentifier = $currentClassIdentifier;
$values = array('version' => 0, 'serialized_name_list' => $classNameList->serializeNames(), 'serialized_description_list' => $classDescriptionList->serializeNames(), 'create_lang_if_not_exist' => true, 'identifier' => $classIdentifier, 'remote_id' => $classRemoteID, 'contentobject_name' => $classObjectNamePattern, 'url_alias_name' => $classURLAliasPattern, 'is_container' => $classIsContainer, 'created' => $classCreated, 'modified' => $classModified);
if ($content->hasAttribute('sort-field')) {
$values['sort_field'] = eZContentObjectTreeNode::sortFieldID($content->getAttribute('sort-field'));
} else {
eZDebug::writeNotice('The sort field was not specified in the content class package. ' . 'This property is exported and imported since eZ Publish 4.0.2', __METHOD__);
}
if ($content->hasAttribute('sort-order')) {
$values['sort_order'] = $content->getAttribute('sort-order');
} else {
//.........这里部分代码省略.........
示例3: createContentObject
function createContentObject( $objectInformation )
{
$db = eZDB::instance();
$contentObjectVersion = false;
if ( $objectInformation['ownerID'] )
{
$userID = $objectInformation['ownerID'];
}
else
{
$user = eZUser::currentUser();
$userID = $user->attribute( 'contentobject_id' );
}
if ( $objectInformation['remoteID'] )
{
$contentObject = eZContentObject::fetchByRemoteId( $objectInformation['remoteID'] );
if ( $contentObject )
{
$this->writeMessage( "\t[".$objectInformation['remoteID']."] Object exists: " . $contentObject->attribute("name") . ". Creating new version.", 'notice' );
$contentObjectVersion = $contentObject->createNewVersion();
}
}
elseif ( $objectInformation['objectID'] )
{
$contentObject = eZContentObject::fetch( $objectInformation['objectID'] );
if ( $contentObject )
{
$this->writeMessage( "\t[".$objectInformation['remoteID']."] Object exists: " . $contentObject->attribute("name") . ". Creating new version.", 'notice' );
$contentObjectVersion = $contentObject->createNewVersion();
}
}
if ( !$contentObjectVersion )
{
if ( is_numeric( $objectInformation['classID'] ) )
{
$contentClass = eZContentClass::fetch( $objectInformation['classID'] );
}
elseif ( is_string( $objectInformation['classID'] ) && $objectInformation['classID'] != "" )
{
$contentClass = eZContentClass::fetchByIdentifier( $objectInformation['classID'] );
}
else
{
$this->writeMessage( "\tNo class defined. Using class article.", 'warning' );
$contentClass = eZContentClass::fetchByIdentifier( 'article' );
}
if ( !$contentClass )
{
$this->writeMessage( "\tCannot instantiate class '". $objectInformation['classID'] ."'." , 'error' );
return false;
}
$contentObject = $contentClass->instantiate( $userID );
$contentObject->setAttribute( 'remote_id', $objectInformation['remoteID'] );
if ( $contentObject )
{
$contentObjectVersion = $contentObject->currentVersion();
}
}
if ( $contentObjectVersion )
{
$db->begin();
$versionNumber = $contentObjectVersion->attribute( 'version' );
$sortField = intval( eZContentObjectTreeNode::sortFieldID( $objectInformation['sort_field'] ) );
$sortOrder = strtolower( $objectInformation['sort_order'] ) == 'desc' ? eZContentObjectTreeNode::SORT_ORDER_DESC : eZContentObjectTreeNode::SORT_ORDER_ASC;
$nodeAssignment = eZNodeAssignment::create(
array( 'contentobject_id' => $contentObject->attribute( 'id' ),
'contentobject_version' => $versionNumber,
'parent_node' => $objectInformation['parentNode'],
'is_main' => 1,
'sort_field' => $sortField,
'sort_order' => $sortOrder,
)
);
$nodeAssignment->store();
$dataMap = $contentObjectVersion->dataMap();
foreach ( $objectInformation['attributes'] as $attributeName => $attributesContent )
{
if ( array_key_exists( $attributeName, $dataMap ) )
{
$attribute = $dataMap[$attributeName];
$classAttributeID = $attribute->attribute( 'contentclassattribute_id' );
$dataType = $attribute->attribute( 'data_type_string' );
switch ( $dataType )
{
case 'ezstring':
case 'eztext':
case 'ezselection':
case 'ezemail':
{
if ( array_key_exists( 'parseReferences', $attributesContent ) && $attributesContent['parseReferences'] == "true" )
{
$attribute->setAttribute( 'data_text', $this->parseAndReplaceStringReferences( $attributesContent['content'] ) );
}
else
{
$attribute->setAttribute( 'data_text', $attributesContent['content'] );
}
//.........这里部分代码省略.........