本文整理汇总了PHP中eZContentObjectTreeNode::fetchByContentObjectID方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::fetchByContentObjectID方法的具体用法?PHP eZContentObjectTreeNode::fetchByContentObjectID怎么用?PHP eZContentObjectTreeNode::fetchByContentObjectID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::fetchByContentObjectID方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIssue15263
/**
* Regression test for issue #15263
* Content object name/url of imported content classes aren't generated correctly
*
* @url http://issues.ez.no/15263
*
* @outline
* 1) Expire and force generation of class attribute cache
* 2) Load a test package
* 3) Install the package
* 4) Publish an object of the imported class
* 5) The object name / url alias shouldn't be the expected one
**/
public function testIssue15263()
{
$adminUser = eZUser::fetchByName('admin');
$previousUser = eZUser::currentUser();
eZUser::setCurrentlyLoggedInUser($adminUser, $adminUser->attribute('contentobject_id'));
// 1) Expire and force generation of class attribute cache
$handler = eZExpiryHandler::instance();
$handler->setTimestamp('class-identifier-cache', time() - 1);
$handler->store();
eZContentClassAttribute::classAttributeIdentifierByID(1);
// 1) Load a test package
$packageName = 'ezpackage_regression_testIssue15223.ezpkg';
$packageFilename = dirname(__FILE__) . DIRECTORY_SEPARATOR . $packageName;
$packageImportTried = false;
while (!$packageImportTried) {
$package = eZPackage::import($packageFilename, $packageName);
if (!$package instanceof eZPackage) {
if ($package === eZPackage::STATUS_ALREADY_EXISTS) {
$packageToRemove = eZPackage::fetch($packageName);
$packageToRemove->remove();
} else {
self::fail("An error occured loading the package '{$packageFilename}'");
}
}
$packageImportTried = true;
}
// 2) Install the package
$installParameters = array('site_access_map' => array('*' => false), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => false), 'restore_dates' => true, 'user_id' => $adminUser->attribute('contentobject_id'), 'non-interactive' => true, 'language_map' => $package->defaultLanguageMap());
$result = $package->install($installParameters);
// 3) Publish an object of the imported class
$object = new ezpObject('test_issue_15523', 2, $adminUser->attribute('contentobject_id'), 1);
$object->myname = __METHOD__;
$object->myothername = __METHOD__;
$publishedObjectID = $object->publish();
unset($object);
// 4) Test data from the publish object
$publishedNodeArray = eZContentObjectTreeNode::fetchByContentObjectID($publishedObjectID);
if (count($publishedNodeArray) != 1) {
$this->fail("An error occured fetching node for object #{$publishedObjectID}");
}
$publishedNode = $publishedNodeArray[0];
if (!$publishedNode instanceof eZContentObjectTreeNode) {
$this->fail("An error occured fetching node for object #{$publishedObjectID}");
} else {
$this->assertEquals("eZPackageRegression::testIssue15263", $publishedNode->attribute('name'));
$this->assertEquals("eZPackageRegression-testIssue15263", $publishedNode->attribute('url_alias'));
}
// Remove the installed package & restore the logged in user
$package->remove();
eZUser::setCurrentlyLoggedInUser($previousUser, $previousUser->attribute('contentobject_id'));
}
示例2: getParentListContentObjectIdByListId
/**
* get the objectId of the parent nl list node
* to fetch subscriptions
*/
function getParentListContentObjectIdByListId($virtualListContentObjectId)
{
$listNode = eZContentObjectTreeNode::fetchByContentObjectID($virtualListContentObjectId, true);
if (isset($listNode[0]) && is_object($listNode[0])) {
$parentListNode = $listNode[0]->attribute('parent');
if (is_object($parentListNode) && $parentListNode->attribute('class_identifier') == 'cjw_newsletter_list') {
$parentListContentObjectId = $parentListNode->attribute('contentobject_id');
return $parentListContentObjectId;
} else {
return 0;
}
} else {
return 0;
}
}
示例3: discountPercent
function discountPercent()
{
$discountPercent = 0;
$user = eZUser::currentUser();
$userID = $user->attribute('contentobject_id');
$nodes = eZContentObjectTreeNode::fetchByContentObjectID($userID);
$idArray = array();
$idArray[] = $userID;
foreach ($nodes as $node) {
$parentNodeID = $node->attribute('parent_node_id');
$idArray[] = $parentNodeID;
}
$rules = eZUserDiscountRule::fetchByUserIDArray($idArray);
foreach ($rules as $rule) {
$percent = $rule->attribute('discount_percent');
if ($discountPercent < $percent) {
$discountPercent = $percent;
}
}
return $discountPercent;
}
示例4: hideObject
/**
* Hides an object specified by $objectId.
*
* @param int $objectId
*/
public function hideObject($objectId)
{
$node = eZContentObjectTreeNode::fetchByContentObjectID($objectId);
eZContentObjectTreeNode::hideSubTree($node[0]);
}
示例5: createContentObject
//.........这里部分代码省略.........
$objectIDs = array();
foreach( $relationContent as $relation )
{
$objectIDs[] = $this->getReferenceID( trim ( $relation ) );
}
$attribute->fromString( implode( '-', $objectIDs ) );
}
else
{
eZDebug::writeWarning( $attributesContent['content'], "No relation declared" );
}
} break;
case 'ezauthor':
case 'ezbinaryfile':
case 'ezcountry':
case 'ezdate':
case 'ezdatetime':
case 'ezenum':
case 'ezidentifier':
case 'ezinisetting':
case 'ezisbn':
case 'ezmedia':
case 'ezmultioption':
case 'ezmultiprice':
case 'ezoption':
case 'ezpackage':
case 'ezproductcategory':
case 'ezrangeoption':
case 'ezsubtreesubscription':
case 'eztime':
default:
{
try
{
$attribute->fromString($attributesContent['content']);
}
catch ( Exception $e )
{
$this->writeMessage( "\tDatatype " . $dataType . " fromString function rejected value " . $attributesContent['content'], 'warning' );
}
} break;
}
$attribute->store();
}
}
if ( isset($objectInformation['sectionID']) && $objectInformation['sectionID'] != '' && $objectInformation['sectionID'] != 0 )
{
$contentObject->setAttribute( 'section_id', $objectInformation['sectionID'] );
}
if ( isset($objectInformation['creatorID']) && $objectInformation['creatorID'] != '' && $objectInformation['creatorID'] != 0 )
{
$contentObjectVersion->setAttribute( 'creator_id', $objectInformation['creatorID'] );
}
if ( isset($objectInformation['ownerID']) && $objectInformation['ownerID'] != '' && $objectInformation['ownerID'] != 0 )
{
$contentObject->setAttribute( 'owner_id', $objectInformation['ownerID'] );
}
if( isset( $objectInformation['relations'] ) && is_array( $objectInformation['relations'] ) )
{
foreach( $objectInformation['relations'] as $toObjectID )
{
$contentObject->addContentObjectRelation( $toObjectID );
}
}
$contentObjectVersion->store();
$contentObject->store();
$db->commit();
eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ), 'version' => $versionNumber ) );
$newNodeArray = eZContentObjectTreeNode::fetchByContentObjectID( $contentObject->attribute( 'id' ) );
$refArray = false;
if ( $newNodeArray && count($newNodeArray) >= 1 )
{
$newNode = $newNodeArray[0];
if ( $newNode )
{
$refArray = array( "node_id" => $newNode->attribute( 'node_id' ),
"name" => $contentObjectVersion->attribute( 'name' ),
"object_id" => $contentObject->attribute( 'id' ) );
if( $objectInformation['priority'] )
{
$this->updateNodePriority( $refArray['node_id'], $objectInformation['priority'] );
}
}
}
unset($contentObjectVersion);
unset($contentObject);
return $refArray;
}
return false;
}
示例6: setAlwaysAvailableLanguageID
/**
* @param int $languageID
* @param int|bool $version
*/
function setAlwaysAvailableLanguageID( $languageID, $version = false )
{
$db = eZDB::instance();
$db->begin();
if ( $version == false )
{
$version = $this->currentVersion();
if ( $languageID )
{
$this->setAttribute( 'language_mask', (int)$this->attribute( 'language_mask' ) | 1 );
}
else
{
$this->setAttribute( 'language_mask', (int)$this->attribute( 'language_mask' ) & ~1 );
}
$this->store();
}
$objectID = $this->attribute( 'id' );
$versionID = $version->attribute( 'version' );
// reset 'always available' flag
$sql = "UPDATE ezcontentobject_name SET language_id=";
if ( $db->databaseName() == 'oracle' )
{
$sql .= "bitand( language_id, -2 )";
}
else
{
$sql .= "language_id & ~1";
}
$sql .= " WHERE contentobject_id = '$objectID' AND content_version = '$versionID'";
$db->query( $sql );
if ( $languageID != false )
{
$newLanguageID = $languageID | 1;
$sql = "UPDATE ezcontentobject_name
SET language_id='$newLanguageID'
WHERE language_id='$languageID' AND contentobject_id = '$objectID' AND content_version = '$versionID'";
$db->query( $sql );
}
$version->setAlwaysAvailableLanguageID( $languageID );
// Update url alias for all locations
$nodeRows = eZContentObjectTreeNode::fetchByContentObjectID( $objectID, false );
$actions = array();
foreach ( $nodeRows as $nodeRow )
{
$nodeID = (int)$nodeRow['node_id'];
$actions[] = array( 'eznode', $nodeID );
}
eZURLAliasML::setLangMaskAlwaysAvailable( $languageID, $actions, null );
$db->commit();
}
示例7: publishNewUserGroup
static function publishNewUserGroup($parentNodeIDs, $newGroupAttributes, $isUtf8Encoding = false)
{
$newNodeIDs = array();
if (!is_array($newGroupAttributes) or !isset($newGroupAttributes['name']) or empty($newGroupAttributes['name'])) {
eZDebug::writeWarning('Cannot create user group with empty name.', __METHOD__);
return $newNodeIDs;
}
if (!is_array($parentNodeIDs) or count($parentNodeIDs) < 1) {
eZDebug::writeWarning('No one parent node IDs was passed for publishing new group (group name = "' . $newGroupAttributes['name'] . '")', __METHOD__);
return $newNodeIDs;
}
$ini = eZINI::instance();
$userGroupClassID = $ini->variable("UserSettings", "UserGroupClassID");
$userCreatorID = $ini->variable("UserSettings", "UserCreatorID");
$defaultSectionID = $ini->variable("UserSettings", "DefaultSectionID");
$userGroupClass = eZContentClass::fetch($userGroupClassID);
$contentObject = $userGroupClass->instantiate($userCreatorID, $defaultSectionID);
$contentObject->store();
$contentObjectID = $contentObject->attribute('id');
reset($parentNodeIDs);
$defaultPlacement = current($parentNodeIDs);
array_shift($parentNodeIDs);
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObjectID, 'contentobject_version' => 1, 'parent_node' => $defaultPlacement, 'parent_remote_id' => uniqid('LDAP_'), 'is_main' => 1));
$nodeAssignment->store();
foreach ($parentNodeIDs as $parentNodeID) {
$newNodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObjectID, 'contentobject_version' => 1, 'parent_node' => $parentNodeID, 'parent_remote_id' => uniqid('LDAP_'), 'is_main' => 0));
$newNodeAssignment->store();
}
$version = $contentObject->version(1);
$version->setAttribute('modified', time());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$contentObjectAttributes = $version->contentObjectAttributes();
// find ant set 'name' and 'description' attributes (as standard user group class)
$nameIdentifier = 'name';
$descIdentifier = 'description';
$nameContentAttribute = null;
$descContentAttribute = null;
foreach ($contentObjectAttributes as $attribute) {
if ($attribute->attribute('contentclass_attribute_identifier') == $nameIdentifier) {
$nameContentAttribute = $attribute;
} else {
if ($attribute->attribute('contentclass_attribute_identifier') == $descIdentifier) {
$descContentAttribute = $attribute;
}
}
}
if ($nameContentAttribute) {
if ($isUtf8Encoding) {
$newGroupAttributes['name'] = utf8_decode($newGroupAttributes['name']);
}
$nameContentAttribute->setAttribute('data_text', $newGroupAttributes['name']);
$nameContentAttribute->store();
}
if ($descContentAttribute and isset($newGroupAttributes['description'])) {
if ($isUtf8Encoding) {
$newGroupAttributes['description'] = utf8_decode($newGroupAttributes['description']);
}
$descContentAttribute->setAttribute('data_text', $newGroupAttributes['description']);
$descContentAttribute->store();
}
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
$newNodes = eZContentObjectTreeNode::fetchByContentObjectID($contentObjectID, true, 1);
foreach ($newNodes as $newNode) {
$newNodeIDs[] = $newNode->attribute('node_id');
}
return $newNodeIDs;
}
示例8: serialize
function serialize( $package, $options = false, $contentNodeIDArray = false, $topNodeIDArray = false )
{
$dom = new DOMDocument( '1.0', 'utf-8' );
$versionNode = $dom->createElementNS( 'http://ez.no/object/', 'ezobject:version' );
$dom->appendChild( $versionNode );
$versionNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:version', $this->Version );
$versionNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:status', $this->Status );
$versionNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:created', eZDateUtils::rfc1123Date( $this->attribute( 'created' ) ) );
$versionNode->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:modified', eZDateUtils::rfc1123Date( $this->attribute( 'modified' ) ) );
$translationList = $this->translationList( false, false );
$contentObject = $this->attribute( 'contentobject' );
$db = eZDB::instance();
$db->begin();
$allowedLanguages = $options['language_array'];
if ( $options['only_initial_language'] )
{
$initialLanguageCode = $this->initialLanguageCode();
if ( !in_array( $initialLanguageCode, $allowedLanguages ) )
{
// We can only export initial language but is not in the allowed
// language list so we return false, ie. no export of this version.
return false;
}
// Make sure only the initial language is exported
$allowedLanguages = array( $initialLanguageCode );
}
$exportedLanguages = array();
foreach ( $translationList as $translationItem )
{
$language = $translationItem;
if ( !in_array( $language, $allowedLanguages ) )
{
continue;
}
$translationNode = $dom->createElementNS( 'http://ez.no/object/', 'ezobject:object-translation' );
$translationNode->setAttribute( 'language', $language );
// serialize object name in current version-translation
$objectName = $contentObject->name( $this->Version, $language );
if ( $objectName )
{
$translationNode->setAttribute( 'object_name', $objectName );
}
else
{
eZDebug::writeWarning( sprintf( "Name for object %s of version %s in translation %s not found",
$contentObject->attribute( 'id' ),
$this->Version,
$language ) );
}
$attributes = $this->contentObjectAttributes( $language );
foreach ( $attributes as $attribute )
{
$serializedAttributeNode = $attribute->serialize( $package );
$importedSerializedAttributeNode = $dom->importNode( $serializedAttributeNode, true );
$translationNode->appendChild( $importedSerializedAttributeNode );
}
$versionNode->appendChild( $translationNode );
$exportedLanguages[] = $language;
}
$nodeAssignmentListNode = $dom->createElementNS( 'http://ez.no/object/', 'ezobject:node-assignment-list' );
$versionNode->appendChild( $nodeAssignmentListNode );
$contentNodeArray = eZContentObjectTreeNode::fetchByContentObjectID( $this->ContentObjectID, true, $this->Version );
foreach( $contentNodeArray as $contentNode )
{
$contentNodeDOMNode = $contentNode->serialize( $options, $contentNodeIDArray, $topNodeIDArray );
if ( $contentNodeDOMNode !== false )
{
$importedContentDOMNode = $dom->importNode( $contentNodeDOMNode, true );
$nodeAssignmentListNode->appendChild( $importedContentDOMNode );
}
}
$initialLanguage = $this->attribute( 'initial_language' );
$initialLanguageCode = $initialLanguage->attribute( 'locale' );
if ( in_array( $initialLanguageCode, $exportedLanguages ) )
{
$versionNode->setAttribute( 'initial_language', $initialLanguageCode );
}
if ( $options['related_objects'] === 'selected' )
{
$relatedObjectArray = $contentObject->relatedContentObjectList( $this->Version, $contentObject->ID, 0, false,
array( 'AllRelations' => eZContentObject::RELATION_COMMON ) );
if ( count( $relatedObjectArray ) )
{
$relationListNode = $dom->createElementNS( 'http://ez.no/object/', 'ezobject:object-relation-list' );
foreach( $relatedObjectArray as $relatedObject )
{
$relatedObjectRemoteID = $relatedObject->attribute( 'remote_id' );
//.........这里部分代码省略.........
示例9: foreach
{
$objects = eZContentObject::fetchSameClassList($class->ID, false, $offset, 100);
foreach($objects as $row)
{
$ratingValues = array();
for($i=1; $i <= 10; $i++)
{
$ratingValues[] = sprintf("(%s, 'cluster_france', %s, %s, 1)", $row['id'], $i, mt_rand(0, 200));
}
$db->arrayQuery($ratingQuery . implode(', ', $ratingValues) . ';');
$readValues = array();
$nodes = eZContentObjectTreeNode::fetchByContentObjectID($row['id'], false);
foreach($nodes as $node)
{
if($node['node_id'] != $node['main_node_id'])
{
$readValues[] = sprintf("(%s, 'cluster_france', '%s', %s, 1)", $node['node_id'], date( 'Y-m-d H:i:s'), mt_rand(0, 5000));
}
}
$db->arrayQuery($readQuery . implode(', ', $readValues) . ';');
$progressBar->advance();
$offset += 1;
$count -= 1;
示例10: editContentObject
//.........这里部分代码省略.........
$newRow['name'] = 'Row_' . ( $matrix->NumRows + 1 );
$matrix->NumRows++;
$matrix->Matrix['rows']['sequential'][] = $newRow;
}
$matrix->Cells = $cells;
$attribute->setAttribute( 'data_text', $matrix->xmlString() );
$matrix->decodeXML( $attribute->attribute( 'data_text' ) );
$attribute->setContent( $matrix );
}
} break;
case 'ezauthor':
case 'ezbinaryfile':
case 'ezcountry':
case 'ezdate':
case 'ezdatetime':
case 'ezenum':
case 'ezidentifier':
case 'ezinisetting':
case 'ezisbn':
case 'ezmedia':
case 'ezmultioption':
case 'ezmultiprice':
case 'ezobjectrelationlist':
case 'ezoption':
case 'ezpackage':
case 'ezproductcategory':
case 'ezrangeoption':
case 'ezsubtreesubscription':
case 'eztime':
{
$this->writeMessage( "\tDatatype " . $dataType . " not supported yet.", 'warning' );
} break;
}
$attribute->store();
}
}
if ( isset($objectInformation['sectionID']) && $objectInformation['sectionID'] != '' && $objectInformation['sectionID'] != 0 )
{
$contentObject->setAttribute( 'section_id', $objectInformation['sectionID'] );
}
if ( isset($objectInformation['creatorID']) && $objectInformation['creatorID'] != '' && $objectInformation['creatorID'] != 0 )
{
$contentObjectVersion->setAttribute( 'creator_id', $objectInformation['creatorID'] );
}
if ( isset($objectInformation['ownerID']) && $objectInformation['ownerID'] != '' && $objectInformation['ownerID'] != 0 )
{
$contentObject->setAttribute( 'owner_id', $objectInformation['ownerID'] );
}
$contentObjectVersion->store();
$contentObject->store();
$db->commit();
eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ), 'version' => $versionNumber ) );
// set chosen hidden/invisible attributes for object nodes
$http = eZHTTPTool::instance();
$assignedNodes = $contentObject->assignedNodes( true );
foreach ( $assignedNodes as $node )
{
$nodeID = $node->attribute( 'node_id' );
$parentNodeID = $node->attribute( 'parent_node_id' );
$db = eZDB::instance();
$db->begin();
$parentNode = eZContentObjectTreeNode::fetch( $parentNodeID );
eZContentObjectTreeNode::updateNodeVisibility( $node, $parentNode, /* $recursive = */ false );
$db->commit();
unset( $node, $parentNode );
}
unset( $assignedNodes );
eZContentCacheManager::clearObjectViewCacheIfNeeded( $contentObject->attribute( 'id' ) );
$newNodeArray = eZContentObjectTreeNode::fetchByContentObjectID( $contentObject->attribute( 'id' ) );
$refArray = false;
if ( $newNodeArray && count($newNodeArray) >= 1 )
{
$newNode = $newNodeArray[0];
if ( $newNode )
{
$refArray = array( "node_id" => $newNode->attribute( 'node_id' ),
"name" => $contentObject->attribute( 'name' ),
"object_id" => $contentObject->attribute( 'id' ) );
}
}
unset($contentObjectVersion);
unset($contentObject);
return $refArray;
}
return false;
}