本文整理汇总了PHP中eZSection::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSection::fetch方法的具体用法?PHP eZSection::fetch怎么用?PHP eZSection::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSection
的用法示例。
在下文中一共展示了eZSection::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFetchByIdentifier
/**
* test fetchByIdentifier function
*/
public function testFetchByIdentifier()
{
global $eZContentSectionObjectCache;
$section = new eZSection(array());
$section->setAttribute('name', 'Test Section');
$section->setAttribute('identifier', 'test_section');
$section->store();
$sectionID = $section->attribute('id');
// assert that if the cache is set after fetching
$section2 = eZSection::fetchByIdentifier('test_section');
$this->assertEquals($sectionID, $section2->attribute('id'));
// assert that object is cached
$this->assertNotNull($eZContentSectionObjectCache['test_section']);
$this->assertNotNull($eZContentSectionObjectCache[$sectionID]);
// assert that the two object refer to same object
$this->assertSame($eZContentSectionObjectCache[$sectionID], $section2);
$this->assertSame(eZSection::fetch($sectionID), $section2);
// fetchByID and fetchByIdentifier, assert that the result is the same
$section3 = new eZSection(array());
$section3->setAttribute('name', 'Test Section3');
$section3->setAttribute('identifier', 'test_section3');
$section3->store();
$objectByID = eZSection::fetch($section3->attribute('id'));
$objectByIdentifier = eZSection::fetchByIdentifier('test_section3');
$this->assertSame($objectByID, $objectByIdentifier);
$arrayByIdentifier = eZSection::fetch($section3->attribute('id'), false);
$this->assertTrue(is_array($arrayByIdentifier));
}
示例2: fetchSectionObject
/**
* Fetch section object given either section id or section identifier. There should be one and only one parameter.
* @param integer $sectionID
* @param string $sectionIdentifier
* @return object
*/
function fetchSectionObject( $sectionID = false, $sectionIdentifier = false )
{
if( $sectionID !== false )
{
if( $sectionIdentifier !== false )
{
$sectionObject = null;
}
else
{
$sectionObject = eZSection::fetch( $sectionID );
}
}
else
{
if( $sectionIdentifier === false )
{
$sectionObject = null;
}
else
{
$sectionObject = eZSection::fetchByIdentifier( $sectionIdentifier );
}
}
if ( $sectionObject === null )
return array( 'error' => array( 'error_type' => 'kernel',
'error_code' => eZError::KERNEL_NOT_FOUND ) );
return array( 'result' => $sectionObject );
}
示例3: sectionEditActionCheck
function sectionEditActionCheck( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage )
{
if ( $module->isCurrentAction( 'SectionEdit' ) )
{
$http = eZHTTPTool::instance();
if ( $http->hasPostVariable( 'SelectedSectionId' ) )
{
$selectedSectionID = (int) $http->postVariable( 'SelectedSectionId' );
$selectedSection = eZSection::fetch( $selectedSectionID );
if ( is_object( $selectedSection ) )
{
$currentUser = eZUser::currentUser();
if ( $currentUser->canAssignSectionToObject( $selectedSectionID, $object ) )
{
$db = eZDB::instance();
$db->begin();
$assignedNodes = $object->attribute( 'assigned_nodes' );
if ( count( $assignedNodes ) > 0 )
{
foreach ( $assignedNodes as $node )
{
if ( eZOperationHandler::operationIsAvailable( 'content_updatesection' ) )
{
$operationResult = eZOperationHandler::execute( 'content',
'updatesection',
array( 'node_id' => $node->attribute( 'node_id' ),
'selected_section_id' => $selectedSectionID ),
null,
true );
}
else
{
eZContentOperationCollection::updateSection( $node->attribute( 'node_id' ), $selectedSectionID );
}
}
}
else
{
// If there are no assigned nodes we should update db for the current object.
$objectID = $object->attribute( 'id' );
$db->query( "UPDATE ezcontentobject SET section_id='$selectedSectionID' WHERE id = '$objectID'" );
$db->query( "UPDATE ezsearch_object_word_link SET section_id='$selectedSectionID' WHERE contentobject_id = '$objectID'" );
}
$object->expireAllViewCache();
$db->commit();
}
else
{
eZDebug::writeError( "You do not have permissions to assign the section <" . $selectedSection->attribute( 'name' ) .
"> to the object <" . $object->attribute( 'name' ) . ">." );
}
$module->redirectToView( 'edit', array( $object->attribute( 'id' ), $editVersion, $editLanguage, $fromLanguage ) );
}
}
}
}
示例4: sectionEditActionCheck
function sectionEditActionCheck($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage)
{
if (!$module->isCurrentAction('SectionEdit')) {
return;
}
$http = eZHTTPTool::instance();
if (!$http->hasPostVariable('SelectedSectionId')) {
return;
}
$selectedSection = eZSection::fetch((int) $http->postVariable('SelectedSectionId'));
if (!$selectedSection instanceof eZSection) {
return;
}
$selectedSection->applyTo($object);
eZContentCacheManager::clearContentCacheIfNeeded($object->attribute('id'));
$module->redirectToView('edit', array($object->attribute('id'), $editVersion, $editLanguage, $fromLanguage));
}
示例5: foreach
$firstLoop = false;
}
$className = $class->attribute('name');
$limitation .= "'" . $className . "'";
}
}
} else {
$limitation = ezpI18n::tr('kernel/shop', 'Any class');
}
$sectionRuleValues = eZDiscountSubRuleValue::fetchBySubRuleID($discountRuleID, 1);
if ($sectionRuleValues != null) {
$limitation .= ' ' . ezpI18n::tr('kernel/shop', 'in sections') . ' ';
$firstLoop = true;
foreach ($sectionRuleValues as $sectionRuleValue) {
$sectionID = $sectionRuleValue->attribute('value');
$section = eZSection::fetch($sectionID);
if ($section) {
if (!$firstLoop) {
$limitation .= ', ';
} else {
$firstLoop = false;
}
$sectionName = $section->attribute('name');
$limitation .= "'" . $sectionName . "'";
}
}
} else {
$limitation .= ' ' . ezpI18n::tr('kernel/shop', 'in any section');
}
$productRuleValues = eZDiscountSubRuleValue::fetchBySubRuleID($discountRuleID, 2);
if ($productRuleValues != null) {
示例6: array
* @version 2012.6
* @package kernel
* @subpackage content
*/
$tpl = eZTemplate::factory();
$module = $Params['Module'];
$http = eZHTTPTool::instance();
$pContentObjectId = $Params['ContentObjectID'];
$pVersion = $Params['version'];
$tpl->setVariable('contentObjectId', $pContentObjectId);
$tpl->setVariable('version', $pVersion);
$virtualNodeID = 0;
$contentObject = eZContentObject::fetch($pContentObjectId);
$contentObjectVersion = $contentObject->version($pVersion);
$nodeAssignments = $contentObjectVersion->attribute('node_assignments');
$contentClass = eZContentClass::fetch($contentObject->attribute('contentclass_id'));
$section = eZSection::fetch($contentObject->attribute('section_id'));
$navigationPartIdentifier = $section->attribute('navigation_part_identifier');
$res = eZTemplateDesignResource::instance();
$designKeys = array(array('object', $contentObject->attribute('id')), array('node', $virtualNodeID), array('remote_id', $contentObject->attribute('remote_id')), array('class', $contentClass->attribute('id')), array('class_identifier', $contentClass->attribute('identifier')), array('class_group', $contentObject->attribute('match_ingroup_id_list')), array('state', $contentObject->attribute('state_id_array')), array('state_identifier', $contentObject->attribute('state_identifier_array')), array('section', $contentObject->attribute('section_id')), array('section_identifier', $section->attribute('identifier')));
$res->setKeys($designKeys);
if ($http->hasSessionVariable('RedirectURIAfterPublish')) {
$tpl->setVariable('redirect_uri', $http->sessionVariable('RedirectURIAfterPublish'));
}
$tpl->setVariable('content_object', $contentObject);
$tpl->setVariable('content_object_version', $contentObjectVersion);
$tpl->setVariable('content_class', $contentClass);
$Result['path'] = array(array('text' => ezpI18n::tr('kernel/content', 'Content'), 'url' => false), array('text' => ezpI18n::tr('kernel/content', 'Publishing queue'), 'url' => false), array('text' => $contentObject->attribute('name'), 'url' => false));
$Result['content'] = $tpl->fetch('design:content/queued.tpl');
$Result['navigation_part'] = $navigationPartIdentifier;
return $Result;
示例7: array
}
$contentObjectID = $http->postVariable('ContentObjectID', 1);
$hideRemoveConfirm = false;
if ($http->hasPostVariable('HideRemoveConfirmation')) {
$hideRemoveConfirm = $http->postVariable('HideRemoveConfirmation') ? true : false;
}
if ($contentNodeID != null) {
$http->setSessionVariable('CurrentViewMode', $viewMode);
$http->setSessionVariable('ContentNodeID', $parentNodeID);
$http->setSessionVariable('HideRemoveConfirmation', $hideRemoveConfirm);
$http->setSessionVariable('DeleteIDArray', array($contentNodeID));
$http->setSessionVariable('RedirectURIAfterRemove', $http->postVariable('RedirectURIAfterRemove', false));
$http->setSessionVariable('RedirectIfCancel', $http->postVariable('RedirectIfCancel', false));
$object = eZContentObject::fetchByNodeID($contentNodeID);
if ($object instanceof eZContentObject) {
$section = eZSection::fetch($object->attribute('section_id'));
}
if (isset($section) && $section) {
$navigationPartIdentifier = $section->attribute('navigation_part_identifier');
} else {
$navigationPartIdentifier = null;
}
if ($navigationPartIdentifier and $navigationPartIdentifier == 'ezusernavigationpart') {
$module->redirectTo($module->functionURI('removeuserobject') . '/');
} elseif ($navigationPartIdentifier and $navigationPartIdentifier == 'ezmedianavigationpart') {
$module->redirectTo($module->functionURI('removemediaobject') . '/');
} else {
$module->redirectTo($module->functionURI('removeobject') . '/');
}
} else {
$module->redirectToView('view', array($viewMode, $parentNodeID));
示例8: simplify
/**
* Function for simplifying a content object or node
*
* @param mixed $obj
* @param array $params
* @return array
*/
public static function simplify($obj, $params = array())
{
if (!$obj) {
return array();
} else {
if ($obj instanceof eZContentObject) {
$node = $obj->attribute('main_node');
$contentObject = $obj;
} else {
if ($obj instanceof eZContentObjectTreeNode || $obj instanceof eZFindResultNode) {
$node = $obj;
$contentObject = $obj->attribute('object');
} else {
if (isset($params['fetchNodeFunction']) && method_exists($obj, $params['fetchNodeFunction'])) {
// You can supply fetchNodeFunction parameter to be able to support other node related classes
$node = call_user_func(array($obj, $params['fetchNodeFunction']));
if (!$node instanceof eZContentObjectTreeNode) {
return '';
}
$contentObject = $node->attribute('object');
} else {
if (is_array($obj)) {
return $obj;
// Array is returned as is
} else {
return '';
// Other passed objects are not supported
}
}
}
}
}
$ini = eZINI::instance('site.ini');
$params = array_merge(array('dataMap' => array(), 'fetchPath' => false, 'fetchSection' => false, 'fetchChildrenCount' => false, 'dataMapType' => array(), 'loadImages' => false, 'imagePreGenerateSizes' => array('small')), $params);
if (!isset($params['imageSizes'])) {
$imageIni = eZINI::instance('image.ini');
$params['imageSizes'] = $imageIni->variable('AliasSettings', 'AliasList');
}
if ($params['imageSizes'] === null || !isset($params['imageSizes'][0])) {
$params['imageSizes'] = array();
}
if (!isset($params['imageDataTypes'])) {
$params['imageDataTypes'] = $ini->variable('ImageDataTypeSettings', 'AvailableImageDataTypes');
}
$ret = array();
$attrtibuteArray = array();
$ret['name'] = htmlentities($contentObject->attribute('name'), ENT_QUOTES, "UTF-8");
$ret['contentobject_id'] = $ret['id'] = (int) $contentObject->attribute('id');
$ret['contentobject_remote_id'] = $contentObject->attribute('remote_id');
$ret['contentobject_state'] = implode(", ", $contentObject->attribute('state_identifier_array'));
$ret['main_node_id'] = (int) $contentObject->attribute('main_node_id');
$ret['version'] = (int) $contentObject->attribute('current_version');
$ret['modified'] = $contentObject->attribute('modified');
$ret['published'] = $contentObject->attribute('published');
$ret['section_id'] = (int) $contentObject->attribute('section_id');
$ret['current_language'] = $contentObject->attribute('current_language');
$ret['owner_id'] = (int) $contentObject->attribute('owner_id');
$ret['class_id'] = (int) $contentObject->attribute('contentclass_id');
$ret['class_name'] = $contentObject->attribute('class_name');
$ret['path_identification_string'] = $node->attribute('path_identification_string');
$ret['translations'] = eZContentLanguage::decodeLanguageMask($contentObject->attribute('language_mask'), true);
$ret['can_edit'] = $contentObject->attribute('can_edit');
if (isset($params['formatDate'])) {
$ret['modified_date'] = self::formatLocaleDate($contentObject->attribute('modified'), $params['formatDate']);
$ret['published_date'] = self::formatLocaleDate($contentObject->attribute('published'), $params['formatDate']);
}
if (isset($params['fetchCreator'])) {
$creator = $contentObject->attribute('current')->attribute('creator');
if ($creator instanceof eZContentObject) {
$ret['creator'] = array('id' => $creator->attribute('id'), 'name' => $creator->attribute('name'));
} else {
$ret['creator'] = array('id' => $contentObject->attribute('current')->attribute('creator_id'), 'name' => null);
// user has been deleted
}
}
if (isset($params['fetchClassIcon'])) {
$operator = new eZWordToImageOperator();
$tpl = eZTemplate::instance();
$operatorValue = $contentObject->attribute('class_identifier');
$operatorParameters = array(array(array(1, 'small')));
$namedParameters = array();
$operatorName = 'class_icon';
$operator->modify($tpl, $operatorName, $operatorParameters, '', '', $operatorValue, $namedParameters, array());
$ret['class_icon'] = $operatorValue;
}
if (isset($params['fetchThumbPreview'])) {
$thumbUrl = '';
$thumbWidth = 0;
$thumbHeight = 0;
$thumbDataType = isset($params['thumbDataType']) ? $params['thumbDataType'] : 'ezimage';
$thumbImageSize = isset($params['thumbImageSize']) ? $params['thumbImageSize'] : 'small';
foreach ($contentObject->attribute('data_map') as $key => $atr) {
if ($atr->attribute('data_type_string') == $thumbDataType && $atr->attribute('has_content')) {
//.........这里部分代码省略.........
示例9: generateNodeViewData
/**
* Generate result data for a node view
*
* @param eZTemplate $tpl
* @param eZContentObjectTreeNode $node
* @param eZContentObject $object
* @param bool|string $languageCode
* @param string $viewMode
* @param int $offset
* @param array $viewParameters
* @param bool|array $collectionAttributes
* @param bool $validation
* @return array Result array for view
*/
static function generateNodeViewData(eZTemplate $tpl, eZContentObjectTreeNode $node, eZContentObject $object, $languageCode, $viewMode, $offset, array $viewParameters = array('offset' => 0, 'year' => false, 'month' => false, 'day' => false), $collectionAttributes = false, $validation = false)
{
$section = eZSection::fetch($object->attribute('section_id'));
if ($section) {
$navigationPartIdentifier = $section->attribute('navigation_part_identifier');
$sectionIdentifier = $section->attribute('identifier');
} else {
$navigationPartIdentifier = null;
$sectionIdentifier = null;
}
$keyArray = array(array('object', $object->attribute('id')), array('node', $node->attribute('node_id')), array('parent_node', $node->attribute('parent_node_id')), array('class', $object->attribute('contentclass_id')), array('class_identifier', $node->attribute('class_identifier')), array('view_offset', $offset), array('viewmode', $viewMode), array('remote_id', $object->attribute('remote_id')), array('node_remote_id', $node->attribute('remote_id')), array('navigation_part_identifier', $navigationPartIdentifier), array('depth', $node->attribute('depth')), array('url_alias', $node->attribute('url_alias')), array('class_group', $object->attribute('match_ingroup_id_list')), array('state', $object->attribute('state_id_array')), array('state_identifier', $object->attribute('state_identifier_array')), array('section', $object->attribute('section_id')), array('section_identifier', $sectionIdentifier));
$parentClassID = false;
$parentClassIdentifier = false;
$parentNodeRemoteID = false;
$parentObjectRemoteID = false;
$parentNode = $node->attribute('parent');
if (is_object($parentNode)) {
$parentNodeRemoteID = $parentNode->attribute('remote_id');
$keyArray[] = array('parent_node_remote_id', $parentNodeRemoteID);
$parentObject = $parentNode->attribute('object');
if (is_object($parentObject)) {
$parentObjectRemoteID = $parentObject->attribute('remote_id');
$keyArray[] = array('parent_object_remote_id', $parentObjectRemoteID);
$parentClass = $parentObject->contentClass();
if (is_object($parentClass)) {
$parentClassID = $parentClass->attribute('id');
$parentClassIdentifier = $parentClass->attribute('identifier');
$keyArray[] = array('parent_class', $parentClassID);
$keyArray[] = array('parent_class_identifier', $parentClassIdentifier);
}
}
}
$res = eZTemplateDesignResource::instance();
$res->setKeys($keyArray);
if ($languageCode) {
$oldLanguageCode = $node->currentLanguage();
$node->setCurrentLanguage($languageCode);
}
$tpl->setVariable('node', $node);
$tpl->setVariable('viewmode', $viewMode);
$tpl->setVariable('language_code', $languageCode);
if (isset($viewParameters['_custom'])) {
foreach ($viewParameters['_custom'] as $customVarName => $customValue) {
$tpl->setVariable($customVarName, $customValue);
}
unset($viewParameters['_custom']);
}
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('collection_attributes', $collectionAttributes);
$tpl->setVariable('validation', $validation);
$tpl->setVariable('persistent_variable', false);
$parents = $node->attribute('path');
$path = array();
$titlePath = array();
foreach ($parents as $parent) {
$path[] = array('text' => $parent->attribute('name'), 'url' => '/content/view/full/' . $parent->attribute('node_id'), 'url_alias' => $parent->attribute('url_alias'), 'node_id' => $parent->attribute('node_id'));
}
$titlePath = $path;
$path[] = array('text' => $object->attribute('name'), 'url' => false, 'url_alias' => false, 'node_id' => $node->attribute('node_id'));
$titlePath[] = array('text' => $object->attribute('name'), 'url' => false, 'url_alias' => false);
$tpl->setVariable('node_path', $path);
$event = ezpEvent::getInstance();
$event->notify('content/pre_rendering', array($node, $tpl, $viewMode));
$Result = array();
$Result['content'] = $tpl->fetch('design:node/view/' . $viewMode . '.tpl');
$Result['view_parameters'] = $viewParameters;
$Result['path'] = $path;
$Result['title_path'] = $titlePath;
$Result['section_id'] = $object->attribute('section_id');
$Result['node_id'] = $node->attribute('node_id');
$Result['navigation_part'] = $navigationPartIdentifier;
$contentInfoArray = array();
$contentInfoArray['object_id'] = $object->attribute('id');
$contentInfoArray['node_id'] = $node->attribute('node_id');
$contentInfoArray['parent_node_id'] = $node->attribute('parent_node_id');
$contentInfoArray['class_id'] = $object->attribute('contentclass_id');
$contentInfoArray['class_identifier'] = $node->attribute('class_identifier');
$contentInfoArray['remote_id'] = $object->attribute('remote_id');
$contentInfoArray['node_remote_id'] = $node->attribute('remote_id');
$contentInfoArray['offset'] = $offset;
$contentInfoArray['viewmode'] = $viewMode;
$contentInfoArray['navigation_part_identifier'] = $navigationPartIdentifier;
$contentInfoArray['node_depth'] = $node->attribute('depth');
$contentInfoArray['url_alias'] = $node->attribute('url_alias');
$contentInfoArray['current_language'] = $object->attribute('current_language');
$contentInfoArray['language_mask'] = $object->attribute('language_mask');
//.........这里部分代码省略.........
示例10: assignSectionToSubTree
static function assignSectionToSubTree($nodeID, $sectionID, $oldSectionID = false)
{
$db = eZDB::instance();
$node = eZContentObjectTreeNode::fetch($nodeID);
$nodePath = $node->attribute('path_string');
$sectionID = (int) $sectionID;
$pathString = " path_string like '{$nodePath}%' AND ";
// fetch the object id's which needs to be updated
$objectIDArray = $db->arrayQuery("SELECT\n ezcontentobject.id\n FROM\n ezcontentobject_tree, ezcontentobject\n WHERE\n {$pathString}\n ezcontentobject_tree.contentobject_id=ezcontentobject.id AND\n ezcontentobject_tree.main_node_id=ezcontentobject_tree.node_id");
if (count($objectIDArray) == 0) {
return;
}
// Who assigns which section at which node should be logged.
$section = eZSection::fetch($sectionID);
$object = $node->object();
eZAudit::writeAudit('section-assign', array('Section ID' => $sectionID, 'Section name' => $section->attribute('name'), 'Node ID' => $nodeID, 'Content object ID' => $object->attribute('id'), 'Content object name' => $object->attribute('name'), 'Comment' => 'Assigned a section to the current node and all child objects: eZContentObjectTreeNode::assignSectionToSubTree()'));
$objectSimpleIDArray = array();
foreach ($objectIDArray as $objectID) {
$objectSimpleIDArray[] = $objectID['id'];
}
$filterPart = '';
if ($oldSectionID !== false) {
$oldSectionID = (int) $oldSectionID;
$filterPart = " section_id = '{$oldSectionID}' and ";
}
$db->begin();
foreach (array_chunk($objectSimpleIDArray, 100) as $pagedObjectIDs) {
$db->query("UPDATE ezcontentobject SET section_id='{$sectionID}' WHERE {$filterPart} " . $db->generateSQLINStatement($pagedObjectIDs, 'id', false, true, 'int'));
eZSearch::updateObjectsSection($pagedObjectIDs, $sectionID);
}
$db->commit();
// clear caches for updated objects
eZContentObject::clearCache($objectSimpleIDArray);
}
示例11: sectionIdentifier
/**
* Returns object's section identifier
*
* @return string|bool
*/
public function sectionIdentifier()
{
$section = eZSection::fetch( $this->attribute( 'section_id' ) );
if( $section instanceof eZSection )
{
return $section->attribute( 'identifier' );
}
return false;
}
示例12: serializeObject
/**
* Serialize the eZContentObject to be used to build the result in
* JavaScript
*
* @param eZContentObject $object
* @return array
*/
public function serializeObject(eZContentObject $contentObject)
{
$section = eZSection::fetch($contentObject->attribute('section_id'));
return array('object_info' => array('id' => $contentObject->attribute('id'), 'name' => $contentObject->attribute('name'), 'class_name' => $contentObject->attribute('class_name'), 'section_name' => $section->attribute('name'), 'published' => ezpI18n::tr('design/standard/content/datatype', 'Yes')));
}
示例13: createObjectDOMElement
/**
* Create Object element.
*
* @param DOMDocument Owner DOMDocument
* @param eZContentObject eZContentObject object.
*
* @return DOMElement Object DOMDocument, example:
*
* <Object ID="153" mainNodeID="123" initialLanguage="eng-GB" published="123213412" modified="1251231542">
* <Class ID="12" primaryLanguage="eng-GB">
* <NameList>
* <Name locale="eng-GB">eZ Publish rocks</Name>
* </NameList>
* </Class>
* <NameList>
* <Name locale="eng-GB">eZ Publish rocks</Name>
* <Name locale="nor-NO">eZ Publish rokker</Name>
* </NameList>
* <Owner objectID="135" primaryLanguage="nor-NO">
* <NameList>
* <Name locale="nor-NO">Balle Klorin</Name>
* </NameList>
* </Owner>
* <Section ID="2" name="News" />
* </Object>
*/
protected function createObjectDOMElement(DOMDocument $domDocument, eZContentObject $object)
{
$objectElement = $domDocument->createElement('Object');
// Set attributs.
$objectElement->setAttribute('mainNodeID', $object->attribute('main_node_id'));
$objectElement->setAttribute('initialLanguage', $object->attribute('initial_language_code'));
$objectElement->setAttribute('published', $object->attribute('published'));
$objectElement->setAttribute('modified', $object->attribute('modified'));
// Add Class element.
$objectElement->appendChild($this->createClassDOMElement($domDocument, $object->attribute('content_class')));
// Add language list.
$objectElement->appendChild($this->createNameListDOMElementFromContentObject($domDocument, $object));
// Add owner element.
$objectElement->appendChild($this->createOwnerDOMElement($domDocument, $object->attribute('owner')));
// Add Section element.
$objectElement->appendChild($this->createSectionDOMElement($domDocument, eZSection::fetch($object->attribute('section_id'))));
return $objectElement;
}
示例14: unserialize
static function unserialize( $package, $domNode, &$options, $ownerID = false, $handlerType = 'ezcontentobject' )
{
if ( $domNode->localName != 'object' )
{
$retValue = false;
return $retValue;
}
$initialLanguage = eZContentObject::mapLanguage( $domNode->getAttribute( 'initial_language' ), $options );
if( $initialLanguage === 'skip' )
{
$retValue = true;
return $retValue;
}
$sectionID = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'section_id' );
if ( $ownerID === false )
{
$ownerID = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'owner_id' );
}
$remoteID = $domNode->getAttribute( 'remote_id' );
$name = $domNode->getAttribute( 'name' );
$classRemoteID = $domNode->getAttribute( 'class_remote_id' );
$classIdentifier = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'class_identifier' );
$alwaysAvailable = ( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'always_available' ) == '1' );
$contentClass = eZContentClass::fetchByRemoteID( $classRemoteID );
if ( !$contentClass )
{
$contentClass = eZContentClass::fetchByIdentifier( $classIdentifier );
}
if ( !$contentClass )
{
$options['error'] = array( 'error_code' => self::PACKAGE_ERROR_NO_CLASS,
'element_id' => $remoteID,
'description' => "Can't install object '$name': Unable to fetch class with remoteID: $classRemoteID." );
$retValue = false;
return $retValue;
}
$versionListNode = $domNode->getElementsByTagName( 'version-list' )->item( 0 );
$importedLanguages = array();
foreach( $versionListNode->getElementsByTagName( 'version' ) as $versionDOMNode )
{
foreach ( $versionDOMNode->getElementsByTagName( 'object-translation' ) as $versionDOMNodeChild )
{
$importedLanguage = eZContentObject::mapLanguage( $versionDOMNodeChild->getAttribute( 'language' ), $options );
$language = eZContentLanguage::fetchByLocale( $importedLanguage );
// Check if the language is allowed in this setup.
if ( $language )
{
$hasTranslation = true;
}
else
{
if ( $importedLanguage == 'skip' )
continue;
// if there is no needed translation in system then add it
$locale = eZLocale::instance( $importedLanguage );
$translationName = $locale->internationalLanguageName();
$translationLocale = $locale->localeCode();
if ( $locale->isValid() )
{
eZContentLanguage::addLanguage( $locale->localeCode(), $locale->internationalLanguageName() );
$hasTranslation = true;
}
else
$hasTranslation = false;
}
if ( $hasTranslation )
{
$importedLanguages[] = $importedLanguage;
$importedLanguages = array_unique( $importedLanguages );
}
}
}
// If object exists we return a error.
// Minimum install element is an object now.
$contentObject = eZContentObject::fetchByRemoteID( $remoteID );
// Figure out initial language
if ( !$initialLanguage ||
!in_array( $initialLanguage, $importedLanguages ) )
{
$initialLanguage = false;
foreach ( eZContentLanguage::prioritizedLanguages() as $language )
{
if ( in_array( $language->attribute( 'locale' ), $importedLanguages ) )
{
$initialLanguage = $language->attribute( 'locale' );
break;
}
}
}
if ( !$contentObject )
//.........这里部分代码省略.........
示例15: checkRelationActions
function checkRelationActions($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage)
{
$http = eZHTTPTool::instance();
if ($module->isCurrentAction('BrowseForObjects')) {
$objectID = $object->attribute('id');
$assignedNodes = $object->attribute('assigned_nodes');
$assignedNodesIDs = array();
foreach ($assignedNodes as $node) {
$assignedNodesIDs = $node->attribute('node_id');
}
unset($assignedNodes);
eZContentBrowse::browse(array('action_name' => 'AddRelatedObject', 'description_template' => 'design:content/browse_related.tpl', 'content' => array('object_id' => $objectID, 'object_version' => $editVersion, 'object_language' => $editLanguage), 'keys' => array('class' => $class->attribute('id'), 'class_id' => $class->attribute('identifier'), 'classgroup' => $class->attribute('ingroup_id_list'), 'section' => $object->attribute('section_id')), 'ignore_nodes_select' => $assignedNodesIDs, 'from_page' => $module->redirectionURI('content', 'edit', array($objectID, $editVersion, $editLanguage, $fromLanguage))), $module);
return eZModule::HOOK_STATUS_CANCEL_RUN;
}
if ($module->isCurrentAction('UploadFileRelation')) {
$objectID = $object->attribute('id');
$section = eZSection::fetch($object->attribute('section_id'));
$navigationPart = false;
if ($section) {
$navigationPart = $section->attribute('navigation_part_identifier');
}
$location = false;
if ($module->hasActionParameter('UploadRelationLocation')) {
$location = $module->actionParameter('UploadRelationLocation');
}
// We only do direct uploading if we have the uploaded HTTP file
// if not we need to go to the content/upload page.
if (eZHTTPFile::canFetch('UploadRelationFile')) {
$upload = new eZContentUpload();
if ($upload->handleUpload($result, 'UploadRelationFile', $location, false)) {
$relatedObjectID = $result['contentobject_id'];
if ($relatedObjectID) {
$db = eZDB::instance();
$db->begin();
$object->addContentObjectRelation($relatedObjectID, $editVersion);
$db->commit();
}
}
} else {
eZContentUpload::upload(array('action_name' => 'RelatedObjectUpload', 'description_template' => 'design:content/upload_related.tpl', 'navigation_part_identifier' => $navigationPart, 'content' => array('object_id' => $objectID, 'object_version' => $editVersion, 'object_language' => $editLanguage), 'keys' => array('class' => $class->attribute('id'), 'class_id' => $class->attribute('identifier'), 'classgroup' => $class->attribute('ingroup_id_list'), 'section' => $object->attribute('section_id')), 'result_action_name' => 'UploadedFileRelation', 'ui_context' => 'edit', 'result_module' => array('content', 'edit', array($objectID, $editVersion, $editLanguage, $fromLanguage))), $module);
return eZModule::HOOK_STATUS_CANCEL_RUN;
}
}
if ($module->isCurrentAction('DeleteRelation')) {
$objectID = $object->attribute('id');
if ($http->hasPostVariable('DeleteRelationIDArray')) {
$relationObjectIDs = $http->postVariable('DeleteRelationIDArray');
} else {
$relationObjectIDs = array();
}
$db = eZDB::instance();
$db->begin();
foreach ($relationObjectIDs as $relationObjectID) {
$object->removeContentObjectRelation($relationObjectID, $editVersion);
}
$db->commit();
}
if ($module->isCurrentAction('NewObject')) {
if ($http->hasPostVariable('ClassID')) {
if ($http->hasPostVariable('SectionID')) {
$sectionID = $http->postVariable('SectionID');
} else {
$sectionID = 0;
/* Will be changed later */
}
$contentClassID = $http->postVariable('ClassID');
$class = eZContentClass::fetch($contentClassID);
$db = eZDB::instance();
$db->begin();
$relatedContentObject = $class->instantiate(false, $sectionID);
$db->commit();
$newObjectID = $relatedContentObject->attribute('id');
$relatedContentVersion = $relatedContentObject->attribute('current');
if ($relatedContentObject->attribute('can_edit')) {
$db = eZDB::instance();
$db->begin();
$assignmentHandler = new eZContentObjectAssignmentHandler($relatedContentObject, $relatedContentVersion);
$sectionID = (int) $assignmentHandler->setupAssignments(array('group-name' => 'RelationAssignmentSettings', 'default-variable-name' => 'DefaultAssignment', 'specific-variable-name' => 'ClassSpecificAssignment', 'section-id-wanted' => true, 'fallback-node-id' => $object->attribute('main_node_id')));
$http->setSessionVariable('ParentObject', array($object->attribute('id'), $editVersion, $editLanguage));
$http->setSessionVariable('NewObjectID', $newObjectID);
/* Change section ID to the same one as the main node placement */
$db->query("UPDATE ezcontentobject SET section_id = {$sectionID} WHERE id = {$newObjectID}");
$db->commit();
$module->redirectToView('edit', array($relatedContentObject->attribute('id'), $relatedContentObject->attribute('current_version'), false));
} else {
$db = eZDB::instance();
$db->begin();
$relatedContentObject->purge();
$db->commit();
}
return;
}
}
}