本文整理匯總了PHP中eZContentClassAttribute::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZContentClassAttribute::create方法的具體用法?PHP eZContentClassAttribute::create怎麽用?PHP eZContentClassAttribute::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZContentClassAttribute
的用法示例。
在下文中一共展示了eZContentClassAttribute::create方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAttributeIsTranslatable
/**
* #15898: Cannot translate a user content object
* Make sure datatype translation flag is honored.
*
* @link http://issues.ez.no/15898
*/
public function testAttributeIsTranslatable()
{
$stringAttribute = eZContentClassAttribute::create(0, 'ezstring');
$this->assertEquals(1, $stringAttribute->attribute('can_translate'), 'ezstring class attribute should have been translatable by default');
$stringAttribute = eZContentClassAttribute::create(0, 'ezuser');
$this->assertEquals(0, $stringAttribute->attribute('can_translate'), 'ezuser class attribute should NOT have been translatable by default');
}
示例2: add
/**
* Adds new content class attribute to initialized class.
*
* @param string $name
* @param string $identifier
* @param string $type
* @return eZContentClassAttribute
*/
public function add($name = 'Test attribute', $identifer = 'test_attribute', $type = 'ezstring')
{
$classAttribute = eZContentClassAttribute::create($this->id, $type, array(), $this->language);
$classAttribute->setName($name, $this->language);
$dataType = $classAttribute->dataType();
$dataType->initializeClassAttribute($classAttribute);
$classAttribute->setAttribute('identifier', $identifer);
$classAttribute->store();
return $classAttribute;
}
示例3: testMultipleCallsToCalculatedPrice
/**
* Test scenario for issue #13712: Multiprice datatype shows wrong price after multiple calls in template
*
* Test Outline
* ------------
* 1. Create a euro currency
* 2. Create a VAT type of 10 %
* 3. Create a content class with an attribute of the datatype ezmultiprice
* 4. Create a content object of this content class and set a custom price ex. VAT with the VAT type of 10% that we created
* 5. Subsequently retrieve the attribute 'inc_vat_price_list'
*
* @result: the returned eZMultiPriceData instances differ on each call, their values are increased each time with VAT
* @expected: the returned eZMultiPriceData instances are equal
* @link http://issues.ez.no/13712
* @group issue_13712
*/
public function testMultipleCallsToCalculatedPrice()
{
$currencyCode = 'EUR';
// create currency
$currencyParams = array('code' => $currencyCode, 'symbol' => false, 'locale' => 'eng-GB', 'custom_rate_value' => 0, 'rate_factor' => 1);
$currency = eZCurrencyData::create($currencyCode, '€', 'eng-GB', 0, 0, 1);
$currency->store();
$currencyID = $currency->attribute('id');
$this->assertInternalType('integer', $currencyID);
// create VAT type
$row = array('name' => 'Test', 'percentage' => 10.0);
$vatType = new eZVatType($row);
$vatType->store();
$vatTypeID = $vatType->attribute('id');
$this->assertInternalType('integer', $vatTypeID);
$class = eZContentClass::create(false, array('name' => 'eZMultiPrice::testMultipleCallsToCalculatedPrice', 'identifier' => 'ezmultiprice_test'));
$class->store();
$classID = $class->attribute('id');
$this->assertInternalType('integer', $classID);
$attributes = $class->fetchAttributes();
// add class attributes
$newAttribute = eZContentClassAttribute::create($classID, 'ezmultiprice', array('name' => 'Test', 'identifier' => 'test'));
$dataType = $newAttribute->dataType();
$dataType->initializeClassAttribute($newAttribute);
$newAttribute->setAttribute(eZMultiPriceType::DEFAULT_CURRENCY_CODE_FIELD, $currencyCode);
$newAttribute->setAttribute(eZMultiPriceType::VAT_ID_FIELD, $vatTypeID);
$newAttribute->store();
$attributes[] = $newAttribute;
$class->storeDefined($attributes);
$contentObject = $class->instantiate();
$version = $contentObject->currentVersion();
$dataMap = $version->dataMap();
$multiPrice = $dataMap['test']->content();
$multiPrice->setAttribute('selected_vat_type', $vatTypeID);
$multiPrice->setAttribute('is_vat_included', eZMultiPriceType::EXCLUDED_VAT);
$multiPrice->setCustomPrice($currencyCode, 100);
$multiPrice->updateAutoPriceList();
$dataMap['test']->setContent($multiPrice);
$dataMap['test']->setAttribute('data_text', $vatTypeID . ',' . eZMultiPriceType::EXCLUDED_VAT);
$dataMap['test']->store();
// test values
$firstIncVatPriceList = $multiPrice->attribute('inc_vat_price_list');
$this->assertArrayHasKey('EUR', $firstIncVatPriceList);
$firstCallValue = $firstIncVatPriceList['EUR']->attribute('value');
$secondIncVatPriceList = $multiPrice->attribute('inc_vat_price_list');
$this->assertArrayHasKey('EUR', $secondIncVatPriceList);
$secondCallValue = $secondIncVatPriceList['EUR']->attribute('value');
$this->assertEquals($firstCallValue, $secondCallValue);
$thirdIncVatPriceList = $multiPrice->attribute('inc_vat_price_list');
$this->assertArrayHasKey('EUR', $thirdIncVatPriceList);
$thirdCallValue = $thirdIncVatPriceList['EUR']->attribute('value');
$this->assertEquals($firstCallValue, $thirdCallValue);
}
示例4: 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 {
//.........這裏部分代碼省略.........
示例5: addClassAttributes
function addClassAttributes( $params )
{
$classInfo = $params['class'];
$attributesInfo = $params['attributes'];
$classID = isset( $classInfo['id'] ) ? $classInfo['id'] : false;
if( $classID )
{
$class = eZContentClass::fetch( $classID );
}
else
{
if( isset( $classInfo['identifier'] ) )
{
$class = eZSiteInstaller::classByIdentifier( $classInfo );
}
else
{
$this->reportError( "neither 'id' nor 'identifier' is set for content class" ,
'eZSiteInstaller::addClassAttribute' );
}
}
if( !is_object( $class ) )
{
$this->reportError( "Can't fetch content class" ,
'eZSiteInstaller::addClassAttribute' );
return;
}
$classID = $class->attribute( 'id' );
foreach( $attributesInfo as $attributeInfo )
{
$classAttributeIdentifier = $attributeInfo['identifier'];
$classAttributeName = $attributeInfo['name'];
$datatype = $attributeInfo['data_type_string'];
$defaultValue = isset( $attributeInfo['default_value'] ) ? $attributeInfo['default_value'] : false;
$canTranslate = isset( $attributeInfo['can_translate'] ) ? $attributeInfo['can_translate'] : 1;
$isRequired = isset( $attributeInfo['is_required'] ) ? $attributeInfo['is_required'] : 0;
$isSearchable = isset( $attributeInfo['is_searchable'] ) ? $attributeInfo['is_searchable'] : 0;
$attrContent = isset( $attributeInfo['content'] ) ? $attributeInfo['content'] : false;
$attrCreateInfo = array( 'identifier' => $classAttributeIdentifier,
'name' => $classAttributeName,
'can_translate' => $canTranslate,
'is_required' => $isRequired,
'is_searchable' => $isSearchable );
$newAttribute = eZContentClassAttribute::create( $classID, $datatype, $attrCreateInfo );
$dataType = $newAttribute->dataType();
$dataType->initializeClassAttribute( $newAttribute );
// not all datatype can have 'default_value'. do check here.
if( $defaultValue !== false )
{
switch( $datatype )
{
case 'ezboolean':
{
$newAttribute->setAttribute( 'data_int3', $defaultValue );
}
break;
default:
break;
}
}
if( $attrContent )
$newAttribute->setContent( $attrContent );
// store attribute, update placement, etc...
$attributes = $class->fetchAttributes();
$attributes[] = $newAttribute;
// remove temporary version
if ( $newAttribute->attribute( 'id' ) !== null )
{
$newAttribute->remove();
}
$newAttribute->setAttribute( 'version', eZContentClass::VERSION_STATUS_DEFINED );
$newAttribute->setAttribute( 'placement', count( $attributes ) );
$class->adjustAttributePlacements( $attributes );
foreach( $attributes as $attribute )
{
$attribute->storeDefined();
}
// update objects
$classAttributeID = $newAttribute->attribute( 'id' );
$objects = eZContentObject::fetchSameClassList( $classID );
foreach( $objects as $object )
{
$contentobjectID = $object->attribute( 'id' );
$objectVersions = $object->versions();
foreach( $objectVersions as $objectVersion )
{
//.........這裏部分代碼省略.........
示例6: array
} else {
$unorderedParameters['ScheduledScriptID'] = 0;
$class->storeVersioned($attributes, eZContentClass::VERSION_STATUS_DEFINED);
}
$db->commit();
$http->removeSessionVariable('ClassCanStoreTicket');
ezpEvent::getInstance()->notify('content/class/cache', array($ClassID));
return $Module->redirectToView('view', array($ClassID), $unorderedParameters);
}
}
// Store changes
if ($canStore) {
$class->store($attributes);
}
if ($http->hasPostVariable('NewButton')) {
$newAttribute = eZContentClassAttribute::create($ClassID, $cur_datatype, array(), $EditLanguage);
$attrcnt = count($attributes) + 1;
$newAttribute->setName(ezpI18n::tr('kernel/class/edit', 'new attribute') . $attrcnt, $EditLanguage);
$dataType = $newAttribute->dataType();
$dataType->initializeClassAttribute($newAttribute);
$newAttribute->store();
$attributes[] = $newAttribute;
$lastChangedID = $newAttribute->attribute('id');
} else {
if ($http->hasPostVariable('MoveUp')) {
$attribute = eZContentClassAttribute::fetch($http->postVariable('MoveUp'), true, eZContentClass::VERSION_STATUS_TEMPORARY, array('contentclass_id', 'version', 'placement'));
$attribute->move(false);
$Module->redirectTo($Module->functionURI('edit') . '/' . $ClassID . '/(language)/' . $EditLanguage);
return;
} else {
if ($http->hasPostVariable('MoveDown')) {
示例7: addClassAttribute
function addClassAttribute($class, $params)
{
$classID = $class->attribute('id');
$classAttributeIdentifier = $params['identifier'];
$classAttributeNameList = $params['name_list'];
$datatype = $params['data_type_string'];
$defaultValue = isset($params['default_value']) ? $params['default_value'] : false;
$canTranslate = isset($params['can_translate']) ? $params['can_translate'] : 0;
$isRequired = isset($params['is_required']) ? $params['is_required'] : 0;
$isSearchable = isset($params['is_searchable']) ? $params['is_searchable'] : 0;
$isCollector = isset($params['is_information_collector']) ? $params['is_information_collector'] : false;
$attrContent = isset($params['content']) ? $params['content'] : false;
$attrCreateInfo = array('identifier' => $classAttributeIdentifier, 'serialized_name_list' => $classAttributeNameList->serializeNames(), 'can_translate' => $canTranslate, 'is_required' => $isRequired, 'is_searchable' => $isSearchable, 'is_information_collector' => $isCollector);
$newAttribute = eZContentClassAttribute::create($classID, $datatype, $attrCreateInfo);
$dataType = $newAttribute->dataType();
if (!$dataType) {
$this->writeMessage("\t\tUnknown datatype: '{$datatype}'", 'error');
return false;
}
$dataType->initializeClassAttribute($newAttribute);
$newAttribute->store();
$dataType->unserializeContentClassAttribute($newAttribute, $params['attribute-node'], $params['datatype-parameter']);
$newAttribute->sync();
if ($attrContent) {
$newAttribute->setContent($attrContent);
}
// store attribute, update placement, etc...
$attributes = $class->fetchAttributes();
$attributes[] = $newAttribute;
// remove temporary version
if ($newAttribute->attribute('id') !== null) {
$newAttribute->remove();
}
$newAttribute->setAttribute('version', eZContentClass::VERSION_STATUS_DEFINED);
$placement = $params['placement'] ? intval($params['placement']) : count($attributes);
$newAttribute->setAttribute('placement', $placement);
$this->adjustAttributesPlacement = true;
$newAttribute->storeDefined();
$classAttributeID = $newAttribute->attribute('id');
return $classAttributeID;
}
示例8: addAttribute
protected function addAttribute($originalAttribute)
{
$class = $this->currentClass;
$localeAttributes = $class->fetchAttributes();
$placement = count($localeAttributes);
$allowedTypes = eZDataType::allowedTypes();
if (!$class->fetchAttributeByIdentifier($originalAttribute->Identifier) && in_array($originalAttribute->DataTypeString, $allowedTypes)) {
/** @var eZContentClassAttribute $localeAttribute */
$localeAttribute = eZContentClassAttribute::create($class->attribute('id'), $originalAttribute->DataTypeString, array('version' => eZContentClass::VERSION_STATUS_TEMPORARY, 'identifier' => $originalAttribute->Identifier, 'serialized_name_list' => $originalAttribute->SerializedNameList, 'serialized_description_list' => $originalAttribute->SerializedDescriptionList, 'category' => $originalAttribute->Category, 'serialized_data_text' => $originalAttribute->SerializedDataText, 'is_required' => $originalAttribute->IsRequired, 'is_searchable' => $originalAttribute->IsSearchable, 'is_information_collector' => $originalAttribute->IsInformationCollector, 'can_translate' => $originalAttribute->CanTranslate, 'placement' => ++$placement), $this->EditLanguage);
foreach ($this->fields as $localeIdentifier => $remoteProperty) {
$localeAttribute->setAttribute($localeIdentifier, $originalAttribute->{$remoteProperty});
}
$localeAttribute->store();
return $localeAttribute;
}
return false;
}
示例9: addAttributeToClass
static function addAttributeToClass($contentClass, $newAttributeXPath)
{
$classID = $contentClass->attribute("id");
// extracting from the xml, it's gross, but it's better than from an assoc array
$xmlValues = array("identifier" => trim($newAttributeXPath->query("//newattribute/identifier")->item(0)->nodeValue), "display_name" => trim($newAttributeXPath->query("//newattribute/displayname")->item(0)->nodeValue), "description" => trim($newAttributeXPath->query("//newattribute/description")->item(0)->nodeValue), "language" => trim($newAttributeXPath->query("//newattribute/language")->item(0)->nodeValue), "can_translate" => trim($newAttributeXPath->query("//newattribute/can_translate")->item(0)->nodeValue), "is_required" => trim($newAttributeXPath->query("//newattribute/is_required")->item(0)->nodeValue), "is_searchable" => trim($newAttributeXPath->query("//newattribute/is_searchable")->item(0)->nodeValue), "is_information_collector" => trim($newAttributeXPath->query("//newattribute/is_information_collector")->item(0)->nodeValue), "datatypestring" => trim($newAttributeXPath->query("//newattribute/datatypestring")->item(0)->nodeValue), "content" => trim($newAttributeXPath->query("//newattribute/content")->item(0)->nodeValue));
// create new attribute
$attributeCreationInfo = array("identifier" => $xmlValues["identifier"], "serialized_name_list" => serialize(array($xmlValues["language"] => $xmlValues["display_name"], "always-available" => $xmlValues["language"])), "description" => $xmlValues["description"], "can_translate" => $xmlValues["can_translate"], "is_required" => $xmlValues["is_required"], "is_searchable" => $xmlValues["is_searchable"], "is_information_collector" => $xmlValues["is_information_collector"]);
$newAttribute = eZContentClassAttribute::create($classID, $xmlValues["datatypestring"], $attributeCreationInfo);
$dataType = $newAttribute->dataType();
if (!$dataType) {
throw new Exception("Unknown datatype: [ " . $datatype . " ]");
}
$dataType->initializeClassAttribute($newAttribute);
$newAttribute->store();
AttributeFunctions::updateParameters($newAttribute, $newAttributeXPath);
$newAttribute->sync();
$content = $xmlValues["content"];
if ("eep-no-content" != $content) {
$newAttribute->setContent($content);
}
// store attribute, update placement, etc...
$allAttributesList = $contentClass->fetchAttributes();
$allAttributesList[] = $newAttribute;
// remove temporary version
if ($newAttribute->attribute("id") !== null) {
$newAttribute->remove();
}
$newAttribute->setAttribute("version", eZContentClass::VERSION_STATUS_DEFINED);
$newAttribute->setAttribute("placement", count($allAttributesList));
$contentClass->adjustAttributePlacements($allAttributesList);
foreach ($allAttributesList as $attribute) {
$attribute->storeDefined();
}
$classAttributeID = $newAttribute->attribute("id");
echo "\n\nAttribute with ID " . $classAttributeID . " added\n\n";
return $classAttributeID;
}
示例10: addClassAttributes
public static function addClassAttributes($class_identifier, $attributesInfo)
{
if (isset($class_identifier)) {
$class = eZContentClass::fetchByIdentifier($class_identifier);
}
if (!is_object($class)) {
return;
}
$classID = $class->attribute('id');
foreach ($attributesInfo as $attributeInfo) {
$classAttributeIdentifier = $attributeInfo['identifier'];
$classAttributeName = $attributeInfo['name'];
$datatype = $attributeInfo['data_type_string'];
$defaultValue = isset($attributeInfo['default_value']) ? $attributeInfo['default_value'] : false;
$canTranslate = isset($attributeInfo['can_translate']) ? $attributeInfo['can_translate'] : 1;
$isRequired = isset($attributeInfo['is_required']) ? $attributeInfo['is_required'] : 0;
$isSearchable = isset($attributeInfo['is_searchable']) ? $attributeInfo['is_searchable'] : 1;
$attrContent = isset($attributeInfo['content']) ? $attributeInfo['content'] : false;
$attrCreateInfo = array('identifier' => $classAttributeIdentifier, 'name' => $classAttributeName, 'can_translate' => $canTranslate, 'is_required' => $isRequired, 'is_searchable' => $isSearchable);
$newAttribute = eZContentClassAttribute::create($classID, $datatype, $attrCreateInfo);
$dataType = $newAttribute->dataType();
$dataType->initializeClassAttribute($newAttribute);
// not all datatype can have 'default_value'. do check here.
if ($defaultValue !== false) {
switch ($datatype) {
case 'ezboolean':
$newAttribute->setAttribute('data_int3', $defaultValue);
break;
default:
break;
}
}
if ($attrContent) {
$newAttribute->setContent($attrContent);
}
// store attribute, update placement, etc...
$attributes = $class->fetchAttributes();
$attributes[] = $newAttribute;
// remove temporary version
if ($newAttribute->attribute('id') !== null) {
$newAttribute->remove();
}
$newAttribute->setAttribute('version', eZContentClass::VERSION_STATUS_DEFINED);
$newAttribute->setAttribute('placement', count($attributes));
$class->adjustAttributePlacements($attributes);
foreach ($attributes as $attribute) {
$attribute->storeDefined();
}
// update objects
$classAttributeID = $newAttribute->attribute('id');
$count = eZContentObject::fetchSameClassListCount($class->ID);
$output = new ezcConsoleOutput();
$bar = new ezcConsoleProgressbar($output, (int) $count);
$offset = 0;
$limit = 50;
while (true) {
if ($offset > $count) {
break;
}
$objects = eZContentObject::fetchSameClassList($classID, true, $offset, $limit);
foreach ($objects as $object) {
$contentobjectID = $object->attribute('id');
$objectVersions = $object->versions();
foreach ($objectVersions as $objectVersion) {
$translations = $objectVersion->translations(false);
$version = $objectVersion->attribute('version');
foreach ($translations as $translation) {
$objectAttribute = eZContentObjectAttribute::create($classAttributeID, $contentobjectID, $version);
$objectAttribute->setAttribute('language_code', $translation);
$objectAttribute->initialize();
$objectAttribute->store();
$objectAttribute->postInitialize();
}
}
$bar->advance();
}
eZContentObject::clearCache();
$offset += $limit;
}
$bar->finish();
}
}