16 import(
'plugins.importexport.crossref.filter.IssueCrossrefXmlFilter');
25 parent::__construct($filterGroup);
35 return 'plugins.importexport.crossref.filter.ArticleCrossrefXmlFilter';
47 $journalNode = parent::createJournalNode($doc, $pubObject);
48 assert(is_a($pubObject,
'Submission'));
61 $context = $deployment->getContext();
62 $cache = $deployment->getCache();
63 assert(is_a($submission,
'Submission'));
64 $issueId = $submission->getCurrentPublication()->getData(
'issueId');
65 if ($cache->isCached(
'issues', $issueId)) {
66 $issue = $cache->get(
'issues', $issueId);
69 $issue = $issueDao->getById($issueId, $context->getId());
70 if ($issue) $cache->add($issue,
null);
72 $journalIssueNode = parent::createJournalIssueNode($doc, $issue);
73 return $journalIssueNode;
84 $context = $deployment->getContext();
87 $publication = $submission->getCurrentPublication();
88 $locale = $publication->getData(
'locale');
91 $issue = $deployment->getIssue();
93 $journalArticleNode = $doc->createElementNS($deployment->getNamespace(),
'journal_article');
94 $journalArticleNode->setAttribute(
'publication_type',
'full_text');
95 $journalArticleNode->setAttribute(
'metadata_distribution_opts',
'any');
99 $titlesNode = $doc->createElementNS($deployment->getNamespace(),
'titles');
100 $titlesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'title', htmlspecialchars($publication->getData(
'title', $locale), ENT_COMPAT,
'UTF-8')));
101 if ($subtitle = $publication->getData(
'subtitle', $locale)) $titlesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'subtitle', htmlspecialchars($subtitle, ENT_COMPAT,
'UTF-8')));
102 $journalArticleNode->appendChild($titlesNode);
105 $contributorsNode = $doc->createElementNS($deployment->getNamespace(),
'contributors');
106 $authors = $publication->getData(
'authors');
108 foreach ($authors as $author) {
109 $personNameNode = $doc->createElementNS($deployment->getNamespace(),
'person_name');
110 $personNameNode->setAttribute(
'contributor_role',
'author');
113 $personNameNode->setAttribute(
'sequence',
'first');
115 $personNameNode->setAttribute(
'sequence',
'additional');
118 $familyNames = $author->getFamilyName(
null);
119 $givenNames = $author->getGivenName(
null);
122 if (isset($familyNames[$locale]) && isset($givenNames[$locale])) {
124 $personNameNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'given_name', htmlspecialchars(ucfirst($givenNames[$locale]), ENT_COMPAT,
'UTF-8')));
125 $personNameNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'surname', htmlspecialchars(ucfirst($familyNames[$locale]), ENT_COMPAT,
'UTF-8')));
128 foreach($familyNames as $otherLocal => $familyName) {
129 if ($otherLocal != $locale && isset($familyName) && !empty($familyName)) {
131 $altNameNode = $doc->createElementNS($deployment->getNamespace(),
'alt-name');
132 $personNameNode->appendChild($altNameNode);
137 $nameNode = $doc->createElementNS($deployment->getNamespace(),
'name');
140 $nameNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'surname', htmlspecialchars(ucfirst($familyName), ENT_COMPAT,
'UTF-8')));
141 if (isset($givenNames[$otherLocal]) && !empty($givenNames[$otherLocal])) {
142 $nameNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'given_name', htmlspecialchars(ucfirst($givenNames[$otherLocal]), ENT_COMPAT,
'UTF-8')));
145 $altNameNode->appendChild($nameNode);
150 $personNameNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'surname', htmlspecialchars(ucfirst($author->getFullName(
false)), ENT_COMPAT,
'UTF-8')));
153 if ($author->getData(
'orcid')) {
154 $personNameNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'ORCID', $author->getData(
'orcid')));
157 $contributorsNode->appendChild($personNameNode);
160 $journalArticleNode->appendChild($contributorsNode);
163 if ($abstract = $publication->getData(
'abstract', $locale)) {
164 $abstractNode = $doc->createElementNS($deployment->getJATSNamespace(),
'jats:abstract');
165 $abstractNode->appendChild($node = $doc->createElementNS($deployment->getJATSNamespace(),
'jats:p', htmlspecialchars(html_entity_decode(strip_tags($abstract), ENT_COMPAT,
'UTF-8'), ENT_COMPAT,
'UTF-8')));
166 $journalArticleNode->appendChild($abstractNode);
170 if ($datePublished = $publication->getData(
'datePublished')) {
176 $pages = $publication->getPageArray();
177 if (!empty($pages)) {
178 $firstRange = array_shift($pages);
179 $firstPage = array_shift($firstRange);
180 if (count($firstRange)) {
182 $lastPage = array_shift($firstRange);
188 if ((!empty($firstPage) || $firstPage ===
"0") && !preg_match(
'/[^[:alnum:]]/', $firstPage) && !preg_match(
'/[^[:alnum:]]/', $lastPage)) {
189 $pagesNode = $doc->createElementNS($deployment->getNamespace(),
'pages');
190 $pagesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'first_page', $firstPage));
191 if ($lastPage !=
'') {
192 $pagesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'last_page', $lastPage));
195 foreach ($pages as $range) {
196 $otherPages .= ($otherPages ?
',' :
'').implode(
'-', $range);
198 if ($otherPages !=
'') {
199 $pagesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'other_pages', $otherPages));
201 $journalArticleNode->appendChild($pagesNode);
206 if ($publication->getData(
'licenseUrl')) {
207 $licenseNode = $doc->createElementNS($deployment->getAINamespace(),
'ai:program');
208 $licenseNode->setAttribute(
'name',
'AccessIndicators');
209 $licenseNode->appendChild($node = $doc->createElementNS($deployment->getAINamespace(),
'ai:license_ref', htmlspecialchars($publication->getData(
'licenseUrl'), ENT_COMPAT,
'UTF-8')));
210 $journalArticleNode->appendChild($licenseNode);
214 $doiDataNode = $this->
createDOIDataNode($doc, $publication->getStoredPubId(
'doi'), $request->url($context->getPath(),
'article',
'view', $submission->getBestId(),
null,
null,
true));
216 $galleys = $publication->getData(
'galleys');
218 $submissionGalleys = $pdfGalleys = $remoteGalleys = array();
220 $pdfGalleyInArticleLocale =
null;
222 $componentGalleys = array();
224 foreach ($galleys as $galley) {
226 if (!$galley->getRemoteURL()) {
227 $galleyFile = $galley->getFile();
229 $genre = $genreDao->getById($galleyFile->getGenreId());
230 if ($genre->getSupplementary()) {
231 if ($galley->getStoredPubid(
'doi')) {
233 $componentGalleys[] = $galley;
236 $submissionGalleys[] = $galley;
237 if ($galley->isPdfGalley()) {
238 $pdfGalleys[] = $galley;
239 if (!$pdfGalleyInArticleLocale && $galley->getLocale() == $locale) {
240 $pdfGalleyInArticleLocale = $galley;
246 $remoteGalleys[] = $galley;
250 $asCrawledGalleys = array();
251 if ($pdfGalleyInArticleLocale) {
252 $asCrawledGalleys = array($pdfGalleyInArticleLocale);
253 } elseif (!empty($pdfGalleys)) {
254 $asCrawledGalleys = array($pdfGalleys[0]);
256 $asCrawledGalleys = $submissionGalleys;
261 $submissionGalleys = array_merge($submissionGalleys, $remoteGalleys);
263 $journalArticleNode->appendChild($doiDataNode);
266 if (!empty($componentGalleys)) {
270 return $journalArticleNode;
282 $context = $deployment->getContext();
285 if (empty($galleys)) {
286 $crawlerBasedCollectionNode = $doc->createElementNS($deployment->getNamespace(),
'collection');
287 $crawlerBasedCollectionNode->setAttribute(
'property',
'crawler-based');
288 $doiDataNode->appendChild($crawlerBasedCollectionNode);
290 foreach ($galleys as $galley) {
291 $resourceURL = $request->url($context->getPath(),
'article',
'download', array($submission->getBestId(), $galley->getBestGalleyId()),
null,
null,
true);
293 $crawlerBasedCollectionNode = $doc->createElementNS($deployment->getNamespace(),
'collection');
294 $crawlerBasedCollectionNode->setAttribute(
'property',
'crawler-based');
295 $iParadigmsItemNode = $doc->createElementNS($deployment->getNamespace(),
'item');
296 $iParadigmsItemNode->setAttribute(
'crawler',
'iParadigms');
297 $iParadigmsItemNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'resource', $resourceURL));
298 $crawlerBasedCollectionNode->appendChild($iParadigmsItemNode);
299 $doiDataNode->appendChild($crawlerBasedCollectionNode);
312 $context = $deployment->getContext();
316 $textMiningCollectionNode = $doc->createElementNS($deployment->getNamespace(),
'collection');
317 $textMiningCollectionNode->setAttribute(
'property',
'text-mining');
318 foreach ($galleys as $galley) {
319 $resourceURL = $request->url($context->getPath(),
'article',
'download', array($submission->getBestId(), $galley->getBestGalleyId()),
null,
null,
true);
321 $textMiningItemNode = $doc->createElementNS($deployment->getNamespace(),
'item');
322 $resourceNode = $doc->createElementNS($deployment->getNamespace(),
'resource', $resourceURL);
323 if (!$galley->getRemoteURL()) $resourceNode->setAttribute(
'mime_type', $galley->getFileType());
324 $textMiningItemNode->appendChild($resourceNode);
325 $textMiningCollectionNode->appendChild($textMiningItemNode);
327 $doiDataNode->appendChild($textMiningCollectionNode);
339 $context = $deployment->getContext();
343 $componentListNode =$doc->createElementNS($deployment->getNamespace(),
'component_list');
345 foreach($componentGalleys as $componentGalley) {
346 $componentFile = $componentGalley->getFile();
347 $componentNode = $doc->createElementNS($deployment->getNamespace(),
'component');
348 $componentNode->setAttribute(
'parent_relation',
'isPartOf');
350 $componentFileTitle = $componentFile->getName($componentGalley->getLocale());
351 if (!empty($componentFileTitle)) {
352 $titlesNode = $doc->createElementNS($deployment->getNamespace(),
'titles');
353 $titlesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'title', htmlspecialchars($componentFileTitle, ENT_COMPAT,
'UTF-8')));
354 $componentNode->appendChild($titlesNode);
357 $resourceURL = $request->url($context->getPath(),
'article',
'download', array($submission->getBestId(), $componentGalley->getBestGalleyId()),
null,
null,
true);
358 $componentNode->appendChild($this->
createDOIDataNode($doc, $componentGalley->getStoredPubId(
'doi'), $resourceURL));
359 $componentListNode->appendChild($componentNode);
361 return $componentListNode;