/** * Test that saving a content class in DEFINED version status * correctly manipulate associated class groups * * @link http://issues.ez.no/16197 */ public function testContentClassStillInGroupAfterEdition() { $class = eZContentClass::fetch( $this->class->id ); // This is logic contained in kernel/class/edit.php foreach ( eZContentClassClassGroup::fetchGroupList( $class->attribute( 'id' ), eZContentClass::VERSION_STATUS_DEFINED ) as $classGroup ) { eZContentClassClassGroup::create( $class->attribute( 'id' ), eZContentClass::VERSION_STATUS_TEMPORARY, $classGroup->attribute( 'group_id' ), $classGroup->attribute( 'group_name' ) ) ->store(); } $attributes = $class->fetchAttributes(); $class->setAttribute( 'version', eZContentClass::VERSION_STATUS_TEMPORARY ); $class->NameList->setHasDirtyData(); foreach ( $attributes as $attribute ) { $attribute->setAttribute( 'version', eZContentClass::VERSION_STATUS_TEMPORARY ); if ( $dataType = $attribute->dataType() ) $dataType->initializeClassAttribute( $attribute ); } $class->store( $attributes ); $db = eZDB::instance(); $db->begin(); $class->storeVersioned( $attributes, eZContentClass::VERSION_STATUS_DEFINED ); $db->commit(); $this->assertTrue( eZContentClassClassGroup::classInGroup( $class->attribute( 'id' ), eZContentClass::VERSION_STATUS_DEFINED, 1 ) ); }
static function remove($classID) { $contentClass = eZContentClass::fetch($classID); if ($contentClass == null or !$contentClass->isRemovable()) { return false; } // Remove all objects $contentObjects = eZContentObject::fetchSameClassList($classID); foreach ($contentObjects as $contentObject) { eZContentObjectOperations::remove($contentObject->attribute('id')); } if (count($contentObjects) == 0) { eZContentObject::expireAllViewCache(); } eZContentClassClassGroup::removeClassMembers($classID, 0); eZContentClassClassGroup::removeClassMembers($classID, 1); // Fetch real version and remove it $contentClass->remove(true); // Fetch temp version and remove it $tempDeleteClass = eZContentClass::fetch($classID, true, 1); if ($tempDeleteClass != null) { $tempDeleteClass->remove(true, 1); } return true; }
static function removeGroup( $classID, $classVersion, $selectedGroup ) { $class = eZContentClass::fetch( $classID, true, eZContentClass::VERSION_STATUS_DEFINED ); if ( !$class ) return false; $groups = $class->attribute( 'ingroup_list' ); foreach ( array_keys( $groups ) as $key ) { if ( in_array( $groups[$key]->attribute( 'group_id' ), $selectedGroup ) ) { unset( $groups[$key] ); } } if ( count( $groups ) == 0 ) { return false; } else { foreach( $selectedGroup as $group_id ) { eZContentClassClassGroup::removeGroup( $classID, $classVersion, $group_id ); } } return true; }
/** * Initialize ezpClass object * * @param string $name * @param string $identifier * @param string $contentObjectName * @param int $creatorID * @param string $language * @param int $groupID * @param string $groupName */ public function __construct($name = 'Test class', $identifier = 'test_class', $contentObjectName = '<test_attribute>', $creatorID = 14, $language = 'eng-GB', $groupID = 1, $groupName = 'Content') { if (eZContentLanguage::fetchByLocale($language) === false) { $topPriorityLanguage = eZContentLanguage::topPriorityLanguage(); if ($topPriorityLanguage) { $language = $topPriorityLanguage->attribute('locale'); } } $this->language = $language; $this->class = eZContentClass::create($creatorID, array(), $this->language); $this->class->setName($name, $this->language); $this->class->setAttribute('contentobject_name', $contentObjectName); $this->class->setAttribute('identifier', $identifier); $this->class->store(); $languageID = eZContentLanguage::idByLocale($this->language); $this->class->setAlwaysAvailableLanguageID($languageID); $this->classGroup = eZContentClassClassGroup::create($this->id, $this->version, $groupID, $groupName); $this->classGroup->store(); }
public static function getGroupedClasses() { /** @var ContainerInterface $container */ $container = ezpKernel::instance()->getServiceContainer(); $params = $container->getParameter('kaliop_class_select'); $classInclude = $classExclude = $groupInclude = $groupExclude = false; $cgparams = array(); if (!empty($params['classes']['include'])) { $classInclude = true; $cgparams = $params['classes']['include']; } elseif (!empty($params['classes']['exclude'])) { $classExclude = true; $cgparams = $params['classes']['exclude']; } elseif (!empty($params['class_groups']['include'])) { $groupInclude = true; $cgparams = $params['class_groups']['include']; } elseif (!empty($params['class_groups']['exclude'])) { $groupExclude = true; $cgparams = $params['class_groups']['exclude']; } $groups = eZContentClassGroup::fetchList(false, true); $return = array(); $count = 0; foreach ($groups as $group) { if ($groupInclude and (in_array($group->attribute('id'), $cgparams) or in_array($group->attribute('name'), $cgparams)) or !$groupInclude and $groupExclude and (!in_array($group->attribute('id'), $cgparams) or !in_array($group->attribute('name'), $cgparams)) or !$groupInclude and !$groupExclude) { $array = array('name' => $group->attribute('name'), 'classes' => array()); $count++; $classes = eZContentClassClassGroup::fetchClassList(0, $group->attribute('id'), true); foreach ($classes as $class) { if ($classInclude and (in_array($class->attribute('id'), $cgparams) or in_array($class->attribute('identifier'), $cgparams)) or !$classInclude and $classExclude and (!in_array($class->attribute('id'), $cgparams) or !in_array($class->attribute('identifier'), $cgparams)) or !$classInclude and !$classExclude) { $array['classes'][] = array('identifier' => $class->attribute('identifier'), 'name' => $class->attribute('name')); $count++; } } $return[] = $array; } } return array('result' => array('groups' => $return, 'total' => $count)); }
/** * Stores the current class as a modified version, updates the contentobject_name * attribute and recreates the class group entries. * * @note It will remove classes in the previous and specified version before storing. * * @param array $attributes array of attributes * @param int $version version status * @since Version 4.3 */ public function storeVersioned($attributes, $version) { $previousVersion = $this->attribute('version'); $db = eZDB::instance(); $db->begin(); // Before removing anything from the attributes, load attribute information // which might otherwise not accessible when recreating them below. // See issue #18164 foreach ($attributes as $attribute) { $attribute->content(); } $this->removeAttributes(false, $version); $this->removeAttributes(false, $previousVersion); $this->remove(false); $this->setVersion($version, $attributes); $this->setAttribute("modifier_id", eZUser::currentUser()->attribute("contentobject_id")); $this->setAttribute("modified", time()); $this->adjustAttributePlacements($attributes); foreach ($attributes as $attribute) { $attribute->storeVersioned($version); } // Set contentobject_name to something sensible if it is missing if (count($attributes) > 0 && trim($this->attribute('contentobject_name')) == '') { $this->setAttribute('contentobject_name', '<' . $attributes[0]->attribute('identifier') . '>'); } // Recreate class member entries eZContentClassClassGroup::removeClassMembers($this->ID, $version); foreach (eZContentClassClassGroup::fetchGroupList($this->ID, $previousVersion) as $classgroup) { $classgroup->setAttribute('contentclass_version', $version); $classgroup->store(); } eZContentClassClassGroup::removeClassMembers($this->ID, $previousVersion); eZExpiryHandler::registerShutdownFunction(); $handler = eZExpiryHandler::instance(); $time = time(); $handler->setTimestamp('user-class-cache', $time); $handler->setTimestamp('class-identifier-cache', $time); $handler->setTimestamp('sort-key-cache', $time); $handler->store(); eZContentCacheManager::clearAllContentCache(); $this->setAttribute('serialized_name_list', $this->NameList->serializeNames()); $this->setAttribute('serialized_description_list', $this->DescriptionList->serializeNames()); eZPersistentObject::store(); $this->NameList->store($this); $db->commit(); }
function appendClass($class, $version = false) { if ($class instanceof eZContentClass) { $classID = $class->attribute('id'); $version = $class->attribute('version'); } else { $classID = $class; } $classGroupLink = eZContentClassClassGroup::create($classID, $version, $this->attribute('id'), $this->attribute('name')); $classGroupLink->store(); return $classGroupLink; }
$deletedClassName .= " '" . $className . "'"; $deleteClassIDList[] = $classID; $groupClassesInfo[] = array('class_name' => $className, 'object_count' => $classObject->objectCount()); } } if ($deletedClassName == '') { $deletedClassName = ezpI18n::tr('kernel/class', '(no classes)'); } $deleteResult[] = array('groupName' => $GroupName, 'deletedClassName' => $deletedClassName); $groupsInfo[] = array('group_name' => $GroupName, 'class_list' => $groupClassesInfo); } } if ($http->hasPostVariable("ConfirmButton")) { foreach ($deleteIDArray as $deleteID) { eZContentClassGroup::removeSelected($deleteID); eZContentClassClassGroup::removeGroupMembers($deleteID); foreach ($deleteClassIDList as $deleteClassID) { $deleteClass = eZContentClass::fetch($deleteClassID); if ($deleteClass) { $deleteClass->remove(true); } $deleteClass = eZContentClass::fetch($deleteClassID, true, eZContentClass::VERSION_STATUS_TEMPORARY); if ($deleteClass) { $deleteClass->remove(true); } } } $Module->redirectTo('/class/grouplist/'); } if ($http->hasPostVariable("CancelButton")) { $Module->redirectTo('/class/grouplist/');
if (isset($Params["GroupID"])) { $GroupID = $Params["GroupID"]; } $class = eZContentClass::fetch($ClassID); $ClassName = $class->attribute('name'); $classObjects = eZContentObject::fetchSameClassList($ClassID); $ClassObjectsCount = count($classObjects); if ($ClassObjectsCount == 0) { $ClassObjectsCount .= " object"; } else { $ClassObjectsCount .= " objects"; } $http = eZHTTPTool::instance(); if ($http->hasPostVariable("ConfirmButton")) { $class->remove(true); eZContentClassClassGroup::removeClassMembers($ClassID, 0); ezpEvent::getInstance()->notify('content/class/cache', array($ClassID)); $Module->redirectTo('/class/classlist/' . $GroupID); } if ($http->hasPostVariable("CancelButton")) { $Module->redirectTo('/class/classlist/' . $GroupID); } $Module->setTitle("Deletion of class " . $ClassID); $tpl = eZTemplate::factory(); $tpl->setVariable("module", $Module); $tpl->setVariable("GroupID", $GroupID); $tpl->setVariable("ClassID", $ClassID); $tpl->setVariable("ClassName", $ClassName); $tpl->setVariable("ClassObjectsCount", $ClassObjectsCount); $Result = array(); $Result['content'] = $tpl->fetch("design:class/delete.tpl");
$Module->setTitle( ezpI18n::tr( 'kernel/class', 'Class list of group' ) . ' ' . $GroupID ); $tpl = eZTemplate::factory(); $user = eZUser::currentUser(); foreach( $TemplateData as $tpldata ) { $tplname = $tpldata["name"]; $groupInfo = eZContentClassGroup::fetch( $GroupID ); if( !$groupInfo ) { return $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' ); } $list = eZContentClassClassGroup::fetchClassList( 0, $GroupID, $asObject = true ); $groupModifier = eZContentObject::fetch( $groupInfo->attribute( 'modifier_id') ); $tpl->setVariable( $tplname, $list ); $tpl->setVariable( "class_count", count( $list ) ); $tpl->setVariable( "GroupID", $GroupID ); $tpl->setVariable( "group", $groupInfo ); $tpl->setVariable( "group_modifier", $groupModifier ); } $group = eZContentClassGroup::fetch( $GroupID ); $groupName = $group->attribute( 'name' ); $tpl->setVariable( "module", $Module ); $Result = array();
static function classInGroup($contentclassID, $contentclassVersion, $groupID) { $rows = eZPersistentObject::fetchObjectList(eZContentClassClassGroup::definition(), null, array('group_id' => $groupID, "contentclass_id" => $contentclassID, "contentclass_version" => $contentclassVersion), null, null, false); return count($rows) > 0; }
protected function syncGroups() { $remote = $this->getRemote(); if ($remote === null) { throw new Exception("Classe remota non trovata"); } $this->syncAllGroups($remote); $locale = $this->currentClass; /** @var eZContentClassClassGroup[] $localGroups */ $localGroups = $locale->fetchGroupList(); //$localGroupsNames = array(); //$remoteGroupsNames = array(); foreach ($localGroups as $group) { /** @var eZContentClassGroup $classGroup */ $classGroup = eZContentClassGroup::fetchByName($group->attribute('group_name')); if ($classGroup) { eZContentClassClassGroup::removeGroup($this->currentClass->attribute('id'), $this->currentClass->attribute('version'), $classGroup->attribute('id')); } } foreach ($remote->InGroups as $group) { /** @var eZContentClassGroup $classGroup */ $classGroup = eZContentClassGroup::fetchByName($group->GroupName); if ($classGroup) { $ingroup = eZContentClassClassGroup::create($this->currentClass->attribute('id'), $this->currentClass->attribute('version'), $classGroup->attribute('id'), $classGroup->attribute('name')); $ingroup->store(); } } //$groups = $this->currentClass->attribute( 'ingroup_list' ); //if ( count( $groups ) == 0 ) //{ // //@todo //} }
private function createClass($displayName, $classIdentifier, $groupIdentifier, $groupId) { $adminUserObject = eZUser::fetchByName("admin"); $adminUserObject->loginCurrent(); $adminUserId = $adminUserObject->attribute('contentobject_id'); $language = eZContentLanguage::topPriorityLanguage(); $editLanguage = $language->attribute('locale'); $class = eZContentClass::create($adminUserId, array(), $editLanguage); // this is the display name, ez automatically creates the content-class-identifier from it $class->setName($displayName, $editLanguage); $class->setAttribute("identifier", $classIdentifier); // default naming for objects - content classes should update this value once they have attributes added $class->setAttribute('contentobject_name', 'eep-created-content-class'); $class->store(); $editLanguageID = eZContentLanguage::idByLocale($editLanguage); $class->setAlwaysAvailableLanguageID($editLanguageID); $ClassID = $class->attribute('id'); $ClassVersion = $class->attribute('version'); $ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $groupId, $groupIdentifier); $ingroup->store(); // clean up the content class status $class->storeDefined(array()); $adminUserObject->logoutCurrent(); }
static function fetchUserGroupClassNames() { // Get names of user classes $userClassNames = array(); $userClasses = eZUser::fetchUserClassList(false, array('identifier')); foreach ($userClasses as $class) { $userClassNames[] = $class['identifier']; } // Get names of all allowed content-classes for the Users subtree $contentIni = eZINI::instance("content.ini"); $userGroupClassNames = array(); if ($contentIni->hasVariable('ClassGroupIDs', 'Users') and is_numeric($usersClassGroupID = $contentIni->variable('ClassGroupIDs', 'Users')) and count($usersClassList = eZContentClassClassGroup::fetchClassList(eZContentClass::VERSION_STATUS_DEFINED, $usersClassGroupID)) > 0) { foreach ($usersClassList as $userClass) { $userGroupClassNames[] = $userClass->attribute('identifier'); } } // Get names of user-group classes $groupClassNames = array_diff($userGroupClassNames, $userClassNames); return $groupClassNames; }
} // Find out the group where class is created or edited from. if ($http->hasSessionVariable('FromGroupID')) { $fromGroupID = $http->sessionVariable('FromGroupID'); } else { $fromGroupID = false; } $ClassID = $class->attribute('id'); $ClassVersion = $class->attribute('version'); $validation = array('processed' => false, 'groups' => array(), 'attributes' => array(), 'class_errors' => array()); $unvalidatedAttributes = array(); if ($http->hasPostVariable('DiscardButton')) { $http->removeSessionVariable('ClassCanStoreTicket'); $class->setVersion(eZContentClass::VERSION_STATUS_TEMPORARY); $class->remove(true, eZContentClass::VERSION_STATUS_TEMPORARY); eZContentClassClassGroup::removeClassMembers($ClassID, eZContentClass::VERSION_STATUS_TEMPORARY); if ($fromGroupID === false) { $Module->redirectToView('grouplist'); } else { $Module->redirectTo($Module->functionURI('classlist') . '/' . $fromGroupID . '/'); } return; } if ($http->hasPostVariable('AddGroupButton') && $http->hasPostVariable('ContentClass_group')) { eZClassFunctions::addGroup($ClassID, $ClassVersion, $http->postVariable('ContentClass_group')); $lastChangedID = 'group'; } if ($http->hasPostVariable('RemoveGroupButton') && $http->hasPostVariable('group_id_checked')) { if (!eZClassFunctions::removeGroup($ClassID, $ClassVersion, $http->postVariable('group_id_checked'))) { $validation['groups'][] = array('text' => ezpI18n::tr('kernel/class', 'You have to have at least one group that the class belongs to!')); $validation['processed'] = true;
if ($http->hasPostVariable("DiscardButton")) { $Module->redirectTo($Module->functionURI("grouplist")); return; } if ($http->hasPostVariable("StoreButton")) { if ($http->hasPostVariable("Group_name")) { $name = $http->postVariable("Group_name"); } $classgroup->setAttribute("name", $name); // Set new modification date $date_time = time(); $classgroup->setAttribute("modified", $date_time); $user = eZUser::currentUser(); $user_id = $user->attribute("contentobject_id"); $classgroup->setAttribute("modifier_id", $user_id); $classgroup->store(); eZContentClassClassGroup::update(null, $GroupID, $name); $Module->redirectToView('classlist', array($classgroup->attribute('id'))); return; } $Module->setTitle("Edit class group " . $classgroup->attribute("name")); // Template handling $tpl = eZTemplate::factory(); $res = eZTemplateDesignResource::instance(); $res->setKeys(array(array("classgroup", $classgroup->attribute("id")))); $tpl->setVariable("http", $http); $tpl->setVariable("module", $Module); $tpl->setVariable("classgroup", $classgroup); $Result = array(); $Result['content'] = $tpl->fetch("design:class/groupedit.tpl"); $Result['path'] = array(array('url' => '/class/grouplist/', 'text' => ezpI18n::tr('kernel/class', 'Class groups')), array('url' => false, 'text' => $classgroup->attribute('name')));
private function renamegroup($groupIdentifier, $newGroupIdentifier) { $groupObject = eZContentClassGroup::fetchByName($groupIdentifier, true); if ($groupObject == null) { echo "Invalid group identifier\n"; return; } $date_time = time(); $groupObject->setAttribute("modified", $date_time); $groupObject->setAttribute("modifier_id", false); $groupObject->setAttribute("name", $newGroupIdentifier); $groupObject->store(); eZContentClassClassGroup::update(null, $groupObject->ID, $newGroupIdentifier); echo "Successfully renamed group {$groupIdentifier} to {$newGroupIdentifier}\n"; }
static function classDOMTree($class) { if (!$class) { $retValue = false; return $retValue; } $dom = new DOMDocument('1.0', 'utf-8'); $classNode = $dom->createElement('content-class'); $dom->appendChild($classNode); $serializedNameListNode = $dom->createElement('serialized-name-list'); $serializedNameListNode->appendChild($dom->createTextNode($class->attribute('serialized_name_list'))); $classNode->appendChild($serializedNameListNode); $identifierNode = $dom->createElement('identifier'); $identifierNode->appendChild($dom->createTextNode($class->attribute('identifier'))); $classNode->appendChild($identifierNode); $serializedDescriptionListNode = $dom->createElement('serialized-description-list'); $serializedDescriptionListNode->appendChild($dom->createTextNode($class->attribute('serialized_description_list'))); $classNode->appendChild($serializedDescriptionListNode); $remoteIDNode = $dom->createElement('remote-id'); $remoteIDNode->appendChild($dom->createTextNode($class->attribute('remote_id'))); $classNode->appendChild($remoteIDNode); $objectNamePatternNode = $dom->createElement('object-name-pattern'); $objectNamePatternNode->appendChild($dom->createTextNode($class->attribute('contentobject_name'))); $classNode->appendChild($objectNamePatternNode); $urlAliasPatternNode = $dom->createElement('url-alias-pattern'); $urlAliasPatternNode->appendChild($dom->createTextNode($class->attribute('url_alias_name'))); $classNode->appendChild($urlAliasPatternNode); $isContainer = $class->attribute('is_container') ? 'true' : 'false'; $classNode->setAttribute('is-container', $isContainer); $classNode->setAttribute('always-available', $class->attribute('always_available') ? 'true' : 'false'); $classNode->setAttribute('sort-field', eZContentObjectTreeNode::sortFieldName($class->attribute('sort_field'))); $classNode->setAttribute('sort-order', $class->attribute('sort_order')); // Remote data start $remoteNode = $dom->createElement('remote'); $classNode->appendChild($remoteNode); $ini = eZINI::instance(); $siteName = $ini->variable('SiteSettings', 'SiteURL'); $classURL = 'http://' . $siteName . '/class/view/' . $class->attribute('id'); $siteURL = 'http://' . $siteName . '/'; $siteUrlNode = $dom->createElement('site-url'); $siteUrlNode->appendChild($dom->createTextNode($siteURL)); $remoteNode->appendChild($siteUrlNode); $urlNode = $dom->createElement('url'); $urlNode->appendChild($dom->createTextNode($classURL)); $remoteNode->appendChild($urlNode); $classGroupsNode = $dom->createElement('groups'); $classGroupList = eZContentClassClassGroup::fetchGroupList($class->attribute('id'), $class->attribute('version')); foreach ($classGroupList as $classGroupLink) { $classGroup = eZContentClassGroup::fetch($classGroupLink->attribute('group_id')); if ($classGroup) { unset($groupNode); $groupNode = $dom->createElement('group'); $groupNode->setAttribute('id', $classGroup->attribute('id')); $groupNode->setAttribute('name', $classGroup->attribute('name')); $classGroupsNode->appendChild($groupNode); } } $remoteNode->appendChild($classGroupsNode); $idNode = $dom->createElement('id'); $idNode->appendChild($dom->createTextNode($class->attribute('id'))); $remoteNode->appendChild($idNode); $createdNode = $dom->createElement('created'); $createdNode->appendChild($dom->createTextNode($class->attribute('created'))); $remoteNode->appendChild($createdNode); $modifiedNode = $dom->createElement('modified'); $modifiedNode->appendChild($dom->createTextNode($class->attribute('modified'))); $remoteNode->appendChild($modifiedNode); $creatorNode = $dom->createElement('creator'); $remoteNode->appendChild($creatorNode); $creatorIDNode = $dom->createElement('user-id'); $creatorIDNode->appendChild($dom->createTextNode($class->attribute('creator_id'))); $creatorNode->appendChild($creatorIDNode); $creator = $class->attribute('creator'); if ($creator) { $creatorLoginNode = $dom->createElement('user-login'); $creatorLoginNode->appendChild($dom->createTextNode($creator->attribute('login'))); $creatorNode->appendChild($creatorLoginNode); } $modifierNode = $dom->createElement('modifier'); $remoteNode->appendChild($modifierNode); $modifierIDNode = $dom->createElement('user-id'); $modifierIDNode->appendChild($dom->createTextNode($class->attribute('modifier_id'))); $modifierNode->appendChild($modifierIDNode); $modifier = $class->attribute('modifier'); if ($modifier) { $modifierLoginNode = $dom->createElement('user-login'); $modifierLoginNode->appendChild($dom->createTextNode($modifier->attribute('login'))); $modifierNode->appendChild($modifierLoginNode); } // Remote data end $attributesNode = $dom->createElementNS('http://ezpublish/contentclassattribute', 'ezcontentclass-attribute:attributes'); $classNode->appendChild($attributesNode); $attributes = $class->fetchAttributes(); foreach ($attributes as $attribute) { $attributeNode = $dom->createElement('attribute'); $attributeNode->setAttribute('datatype', $attribute->attribute('data_type_string')); $required = $attribute->attribute('is_required') ? 'true' : 'false'; $attributeNode->setAttribute('required', $required); $searchable = $attribute->attribute('is_searchable') ? 'true' : 'false'; $attributeNode->setAttribute('searchable', $searchable); $informationCollector = $attribute->attribute('is_information_collector') ? 'true' : 'false'; $attributeNode->setAttribute('information-collector', $informationCollector); $translatable = $attribute->attribute('can_translate') ? 'true' : 'false'; $attributeNode->setAttribute('translatable', $translatable); $attributeRemoteNode = $dom->createElement('remote'); $attributeNode->appendChild($attributeRemoteNode); $attributeIDNode = $dom->createElement('id'); $attributeIDNode->appendChild($dom->createTextNode($attribute->attribute('id'))); $attributeRemoteNode->appendChild($attributeIDNode); $attributeSerializedNameListNode = $dom->createElement('serialized-name-list'); $attributeSerializedNameListNode->appendChild($dom->createTextNode($attribute->attribute('serialized_name_list'))); $attributeNode->appendChild($attributeSerializedNameListNode); $attributeIdentifierNode = $dom->createElement('identifier'); $attributeIdentifierNode->appendChild($dom->createTextNode($attribute->attribute('identifier'))); $attributeNode->appendChild($attributeIdentifierNode); $attributeSerializedDescriptionListNode = $dom->createElement('serialized-description-list'); $attributeSerializedDescriptionListNode->appendChild($dom->createTextNode($attribute->attribute('serialized_description_list'))); $attributeNode->appendChild($attributeSerializedDescriptionListNode); $attributeCategoryNode = $dom->createElement('category'); $attributeCategoryNode->appendChild($dom->createTextNode($attribute->attribute('category'))); $attributeNode->appendChild($attributeCategoryNode); $attributeSerializedDataTextNode = $dom->createElement('serialized-data-text'); $attributeSerializedDataTextNode->appendChild($dom->createTextNode($attribute->attribute('serialized_data_text'))); $attributeNode->appendChild($attributeSerializedDataTextNode); $attributePlacementNode = $dom->createElement('placement'); $attributePlacementNode->appendChild($dom->createTextNode($attribute->attribute('placement'))); $attributeNode->appendChild($attributePlacementNode); $attributeParametersNode = $dom->createElement('datatype-parameters'); $attributeNode->appendChild($attributeParametersNode); $dataType = $attribute->dataType(); if (is_object($dataType)) { $dataType->serializeContentClassAttribute($attribute, $attributeNode, $attributeParametersNode); } $attributesNode->appendChild($attributeNode); } eZDebug::writeDebug($dom->saveXML(), 'content class package XML'); return $classNode; }
// $Module = $Params['Module']; $ClassID = null; if (isset($Params["ClassID"])) { $ClassID = $Params["ClassID"]; } $class = eZContentClass::fetch($ClassID, true, 0); if (!$class) { return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE); } $classCopy = clone $class; $classCopy->initializeCopy($class); $classCopy->setAttribute('version', eZContentClass::VERSION_STATUS_MODIFIED); $classCopy->store(); $mainGroupID = false; $classGroups = eZContentClassClassGroup::fetchGroupList($class->attribute('id'), $class->attribute('version')); for ($i = 0; $i < count($classGroups); ++$i) { $classGroup =& $classGroups[$i]; $classGroup->setAttribute('contentclass_id', $classCopy->attribute('id')); $classGroup->setAttribute('contentclass_version', $classCopy->attribute('version')); $classGroup->store(); if ($mainGroupID === false) { $mainGroupID = $classGroup->attribute('group_id'); } } $classAttributeCopies = array(); $classAttributes = $class->fetchAttributes(); foreach (array_keys($classAttributes) as $classAttributeKey) { $classAttribute =& $classAttributes[$classAttributeKey]; $classAttributeCopy = clone $classAttribute; if ($datatype = $classAttributeCopy->dataType()) {