16 import(
'lib.pkp.plugins.importexport.native.filter.NativeExportFilter');
26 parent::__construct($filterGroup);
36 return 'plugins.importexport.doaj.filter.DOAJXmlFilter';
49 $doc =
new DOMDocument(
'1.0',
'utf-8');
50 $doc->preserveWhiteSpace =
false;
51 $doc->formatOutput =
true;
53 $context = $deployment->getContext();
54 $plugin = $deployment->getPlugin();
55 $cache = $plugin->getCache();
59 $doc->appendChild($rootNode);
61 foreach($pubObjects as $pubObject) {
62 $publication = $pubObject->getCurrentPublication();
63 $issueId = $publication->getData(
'issueId');
64 if ($cache->isCached(
'issues', $issueId)) {
65 $issue = $cache->get(
'issues', $issueId);
68 $issue = $issueDao->getById($issueId, $context->getId());
69 if ($issue) $cache->add($issue,
null);
73 $recordNode = $doc->createElement(
'record');
74 $rootNode->appendChild($recordNode);
77 if (!empty($language)) $recordNode->appendChild($node = $doc->createElement(
'language', $language));
79 $publisher = $context->getData(
'publisherInstitution');
80 if (!empty($publisher)) $recordNode->appendChild($node = $doc->createElement(
'publisher', htmlspecialchars($publisher, ENT_COMPAT,
'UTF-8')));
82 $journalTitle = $context->getName($context->getPrimaryLocale());
83 $recordNode->appendChild($node = $doc->createElement(
'journalTitle', htmlspecialchars($journalTitle, ENT_COMPAT,
'UTF-8')));
85 $issn = $context->getData(
'printIssn');
86 if (!empty($issn)) $recordNode->appendChild($node = $doc->createElement(
'issn', $issn));
87 $eissn = $context->getData(
'onlineIssn');
88 if (!empty($eissn)) $recordNode->appendChild($node = $doc->createElement(
'eissn', $eissn));
90 if ($publication->getData(
'datePublished')) {
91 $recordNode->appendChild($node = $doc->createElement(
'publicationDate', $this->formatDate($publication->getData(
'datePublished'))));
93 $recordNode->appendChild($node = $doc->createElement(
'publicationDate', $this->formatDate($issue->getDatePublished())));
95 $volume = $issue->getVolume();
96 if (!empty($volume) && $issue->getShowVolume()) $recordNode->appendChild($node = $doc->createElement(
'volume', htmlspecialchars($volume, ENT_COMPAT,
'UTF-8')));
97 $issueNumber = $issue->getNumber();
98 if (!empty($issueNumber) && $issue->getShowNumber()) $recordNode->appendChild($node = $doc->createElement(
'issue', htmlspecialchars($issueNumber, ENT_COMPAT,
'UTF-8')));
104 $startPage = $publication->getStartingPage();
105 $endPage = $publication->getEndingPage();
106 if (isset($startPage) && $startPage !==
"") {
107 $recordNode->appendChild($node = $doc->createElement(
'startPage', htmlspecialchars($startPage, ENT_COMPAT,
'UTF-8')));
108 $recordNode->appendChild($node = $doc->createElement(
'endPage', htmlspecialchars($endPage, ENT_COMPAT,
'UTF-8')));
111 $doi = $publication->getStoredPubId(
'doi');
112 if (!empty($doi)) $recordNode->appendChild($node = $doc->createElement(
'doi', htmlspecialchars($doi, ENT_COMPAT,
'UTF-8')));
114 $recordNode->appendChild($node = $doc->createElement(
'publisherRecordId', htmlspecialchars($publication->getId(), ENT_COMPAT,
'UTF-8')));
116 $type = $publication->getLocalizedData(
'type', $publication->getData(
'locale'));
117 if (!empty($type)) $recordNode->appendChild($node = $doc->createElement(
'documentType', htmlspecialchars($type, ENT_COMPAT,
'UTF-8')));
119 $articleTitles = (array) $publication->getData(
'title');
120 if (array_key_exists($publication->getData(
'locale'), $articleTitles)) {
121 $titleInArticleLocale = $articleTitles[$publication->getData(
'locale')];
122 unset($articleTitles[$publication->getData(
'locale')]);
123 $articleTitles = array_merge(array($publication->getData(
'locale') => $titleInArticleLocale), $articleTitles);
125 foreach ($articleTitles as $locale => $title) {
126 if (!empty($title)) {
127 $recordNode->appendChild($node = $doc->createElement(
'title', htmlspecialchars($title, ENT_COMPAT,
'UTF-8')));
132 $authorsNode = $doc->createElement(
'authors');
133 $recordNode->appendChild($authorsNode);
135 foreach ((array) $publication->getData(
'authors') as $author) {
136 $authorsNode->appendChild($this->
createAuthorNode($doc, $publication, $author, $affilList));
138 if (!empty($affilList[0])) {
139 $affilsNode = $doc->createElement(
'affiliationsList');
140 $recordNode->appendChild($affilsNode);
141 for ($i = 0; $i < count($affilList); $i++) {
142 $affilsNode->appendChild($node = $doc->createElement(
'affiliationName', htmlspecialchars($affilList[$i], ENT_COMPAT,
'UTF-8')));
143 $node->setAttribute(
'affiliationId', $i);
147 $articleAbstracts = (array) $publication->getData(
'abstract');
148 if (array_key_exists($publication->getData(
'locale'), $articleAbstracts)) {
149 $abstractInArticleLocale = $articleAbstracts[$publication->getData(
'locale')];
150 unset($articleAbstracts[$publication->getData(
'locale')]);
151 $articleAbstracts = array_merge(array($publication->getData(
'locale') => $abstractInArticleLocale), $articleAbstracts);
153 foreach ($articleAbstracts as $locale => $abstract) {
154 if (!empty($abstract)) {
155 $recordNode->appendChild($node = $doc->createElement(
'abstract', htmlspecialchars(
PKPString::html2text($abstract), ENT_COMPAT,
'UTF-8')));
161 $recordNode->appendChild($node = $doc->createElement(
'fullTextUrl', htmlspecialchars($request->url(
null,
'article',
'view', $pubObject->getId()), ENT_COMPAT,
'UTF-8')));
162 $node->setAttribute(
'format',
'html');
166 $articleKeywords = $dao->getKeywords($publication->getId(), $supportedLocales);
167 if (array_key_exists($publication->getData(
'locale'), $articleKeywords)) {
168 $keywordsInArticleLocale = $articleKeywords[$publication->getData(
'locale')];
169 unset($articleKeywords[$publication->getData(
'locale')]);
170 $articleKeywords = array_merge(array($publication->getData(
'locale') => $keywordsInArticleLocale), $articleKeywords);
172 foreach ($articleKeywords as $locale => $keywords) {
173 $keywordsNode = $doc->createElement(
'keywords');
175 $recordNode->appendChild($keywordsNode);
176 foreach ($keywords as $keyword) {
177 if (!empty($keyword)) $keywordsNode->appendChild($node = $doc->createElement(
'keyword', htmlspecialchars($keyword, ENT_COMPAT,
'UTF-8')));
191 $rootNode = $doc->createElement($deployment->getRootElementName());
192 $rootNode->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xsi',
'http://www.w3.org/2001/XMLSchema-instance');
193 $rootNode->setAttribute(
'xsi:noNamespaceSchemaLocation', $deployment->getXmlSchemaLocation());
207 $authorNode = $doc->createElement(
'author');
208 $authorNode->appendChild($node = $doc->createElement(
'name', htmlspecialchars($author->getFullName(
false), ENT_COMPAT,
'UTF-8')));
209 if(in_array($author->getAffiliation($publication->getData(
'locale')), $affilList) && !empty($affilList[0])) {
210 $authorNode->appendChild($node = $doc->createElement(
'affiliationId', htmlspecialchars(current(array_keys($affilList, $author->getAffiliation($publication->getData(
'locale')))), ENT_COMPAT,
'UTF-8')));
212 if ($orcid = $author->getData(
'orcid')) {
213 $authorNode->appendChild($doc->createElement(
'orcid_id'))->appendChild($doc->createTextNode($orcid));
225 $affilList = array();
226 foreach ($authors as $author) {
227 if(!in_array($author->getAffiliation($publication->getData(
'locale')), $affilList)) {
228 $affilList[] = $author->getAffiliation($publication->getData(
'locale')) ;
240 if ($date ==
'')
return null;
241 return date(
'Y-m-d', strtotime($date));