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; }
function serialize($options, $contentNodeIDArray, $topNodeIDArray) { if ($options['node_assignment'] == 'main' && $this->attribute('main_node_id') != $this->attribute('node_id')) { return false; } if (!in_array($this->attribute('node_id'), array_keys($contentNodeIDArray))) { return false; } $dom = new DOMDocument('1.0', 'utf-8'); $nodeAssignmentNode = $dom->createElement('node-assignment'); if ($this->attribute('main_node_id') == $this->attribute('node_id')) { $nodeAssignmentNode->setAttribute('is-main-node', 1); } if (!in_array($this->attribute('node_id'), $topNodeIDArray)) { $parentNode = $this->attribute('parent'); $nodeAssignmentNode->setAttribute('parent-node-remote-id', $parentNode->attribute('remote_id')); } $nodeAssignmentNode->setAttribute('name', $this->attribute('name')); $nodeAssignmentNode->setAttribute('node-id', $this->attribute('node_id')); $nodeAssignmentNode->setAttribute('remote-id', $this->attribute('remote_id')); $nodeAssignmentNode->setAttribute('sort-field', eZContentObjectTreeNode::sortFieldName($this->attribute('sort_field'))); $nodeAssignmentNode->setAttribute('sort-order', $this->attribute('sort_order')); $nodeAssignmentNode->setAttribute('priority', $this->attribute('priority')); return $nodeAssignmentNode; }