16 import(
'lib.pkp.plugins.importexport.native.filter.NativeExportFilter');
25 parent::__construct($filterGroup);
35 return 'lib.pkp.plugins.importexport.native.filter.PKPPublicationNativeXmlFilter';
48 $doc =
new DOMDocument(
'1.0');
49 $doc->preserveWhiteSpace =
false;
50 $doc->formatOutput =
true;
53 $doc->appendChild($rootNode);
54 $rootNode->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xsi',
'http://www.w3.org/2001/XMLSchema-instance');
55 $rootNode->setAttribute(
'xsi:schemaLocation', $deployment->getNamespace() .
' ' . $deployment->getSchemaFilename());
71 $context = $deployment->getContext();
74 $entityNode = $doc->createElementNS($deployment->getNamespace(),
'publication');
78 $entityNode->setAttribute(
'locale', $entity->getData(
'locale'));
79 $entityNode->setAttribute(
'version', $entity->getData(
'version') ?: 1);
80 $entityNode->setAttribute(
'status', $entity->getData(
'status'));
81 if ($primaryContactId = $entity->getData(
'primaryContactId')) $entityNode->setAttribute(
'primary_contact_id', $primaryContactId);
82 $entityNode->setAttribute(
'url_path', $entity->getData(
'urlPath'));
84 $isPublished = $entity->getData(
'status') === STATUS_PUBLISHED;
85 $isPublished ? $entityNode->setAttribute(
'seq', (
int) $entity->getData(
'seq')) : $entityNode->setAttribute(
'seq',
'0');
87 $entityLanguages = $entity->getData(
'languages');
88 if ($entityLanguages) {
89 $entityNode->setAttribute(
'language', $entityLanguages);
92 if ($datePublished = $entity->getData(
'datePublished')) {
93 $entityNode->setAttribute(
'date_published', strftime(
'%Y-%m-%d', strtotime($datePublished)));
113 $entityNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'id', $entity->getId()));
114 $node->setAttribute(
'type',
'internal');
115 $node->setAttribute(
'advice',
'ignore');
118 if ($pubId = $entity->getStoredPubId(
'publisher-id')) {
119 $entityNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'id', htmlspecialchars($pubId, ENT_COMPAT,
'UTF-8')));
120 $node->setAttribute(
'type',
'public');
121 $node->setAttribute(
'advice',
'update');
126 foreach ($pubIdPlugins as $pubIdPlugin) {
140 $pubId = $entity->getStoredPubId($pubIdPlugin->getPubIdType());
143 $entityNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'id', htmlspecialchars($pubId, ENT_COMPAT,
'UTF-8')));
144 $node->setAttribute(
'type', $pubIdPlugin->getPubIdType());
145 $node->setAttribute(
'advice',
'update');
168 if ($entity->getData(
'licenseUrl')) {
169 $entityNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'licenseUrl', htmlspecialchars($entity->getData(
'licenseUrl'))));
172 $this->
createLocalizedNodes($doc, $entityNode,
'copyrightHolder', $entity->getData(
'copyrightHolder'));
174 if ($entity->getData(
'copyrightYear')) {
175 $entityNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'copyrightYear', intval($entity->getData(
'copyrightYear'))));
182 foreach ($controlledVocabulariesMapping as $controlledVocabulariesNodeName => $mappings) {
184 $getFunction = $mappings[1];
185 $controlledVocabularyNodeName = $mappings[2];
186 $controlledVocabulary = $dao->$getFunction($entity->getId(), $supportedLocales);
187 $this->
addControlledVocabulary($doc, $entityNode, $controlledVocabulariesNodeName, $controlledVocabularyNodeName, $controlledVocabulary);
199 function addControlledVocabulary($doc, $entityNode, $controlledVocabulariesNodeName, $controlledVocabularyNodeName, $controlledVocabulary) {
201 $locales = array_keys($controlledVocabulary);
202 foreach ($locales as $locale) {
203 if (!empty($controlledVocabulary[$locale])) {
204 $controlledVocabulariesNode = $doc->createElementNS($deployment->getNamespace(), $controlledVocabulariesNodeName);
205 $controlledVocabulariesNode->setAttribute(
'locale', $locale);
206 foreach ($controlledVocabulary[$locale] as $controlledVocabularyItem) {
207 $controlledVocabulariesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), $controlledVocabularyNodeName, htmlspecialchars($controlledVocabularyItem, ENT_COMPAT,
'UTF-8')));
210 $entityNode->appendChild($controlledVocabulariesNode);
223 $nativeExportFilters = $filterDao->getObjectsByGroup(
'author=>native-xml');
224 assert(count($nativeExportFilters)==1);
225 $exportFilter = array_shift($nativeExportFilters);
228 $authors = $entity->getData(
'authors');
229 $authorsDoc = $exportFilter->execute($authors);
230 if ($authorsDoc->documentElement instanceof DOMElement) {
231 $clone = $doc->importNode($authorsDoc->documentElement,
true);
232 $entityNode->appendChild($clone);
244 $nativeExportFilters = $filterDao->getObjectsByGroup($this->getRepresentationExportFilterGroupName());
245 assert(count($nativeExportFilters)==1);
246 $exportFilter = array_shift($nativeExportFilters);
250 $representations = $representationDao->getByPublicationId($entity->getId());
251 while ($representation = $representations->next()) {
252 $representationDoc = $exportFilter->execute($representation);
253 $clone = $doc->importNode($representationDoc->documentElement,
true);
254 $entityNode->appendChild($clone);
264 'keywords' => array(
'SubmissionKeywordDAO',
'getKeywords',
'keyword'),
265 'agencies' => array(
'SubmissionAgencyDAO',
'getAgencies',
'agency'),
266 'disciplines' => array(
'SubmissionDisciplineDAO',
'getDisciplines',
'discipline'),
267 'subjects' => array(
'SubmissionSubjectDAO',
'getSubjects',
'subject'),