function &generateArticleDom(&$doc, &$journal, &$issue, &$section, &$article) { $root =& XMLCustomWriter::createElement($doc, 'article'); XMLCustomWriter::setAttribute($root, 'locale', $article->getLocale()); XMLCustomWriter::setAttribute($root, 'public_id', $article->getPubId('publisher-id'), false); XMLCustomWriter::setAttribute($root, 'language', $article->getLanguage(), false); NativeExportDom::generatePubId($doc, $root, $article, $issue); /* --- Titles and Abstracts --- */ if (is_array($article->getTitle(null))) { foreach ($article->getTitle(null) as $locale => $title) { $titleNode =& XMLCustomWriter::createChildWithText($doc, $root, 'title', $title, false); if ($titleNode) { XMLCustomWriter::setAttribute($titleNode, 'locale', $locale); } unset($titleNode); } } if (is_array($article->getAbstract(null))) { foreach ($article->getAbstract(null) as $locale => $abstract) { $abstractNode =& XMLCustomWriter::createChildWithText($doc, $root, 'abstract', $abstract, false); if ($abstractNode) { XMLCustomWriter::setAttribute($abstractNode, 'locale', $locale); } unset($abstractNode); } } /* --- Indexing --- */ $indexingNode =& XMLCustomWriter::createElement($doc, 'indexing'); $isIndexingNecessary = false; if (is_array($article->getDiscipline(null))) { foreach ($article->getDiscipline(null) as $locale => $discipline) { $disciplineNode =& XMLCustomWriter::createChildWithText($doc, $indexingNode, 'discipline', $discipline, false); if ($disciplineNode) { XMLCustomWriter::setAttribute($disciplineNode, 'locale', $locale); $isIndexingNecessary = true; } unset($disciplineNode); } } if (is_array($article->getType(null))) { foreach ($article->getType(null) as $locale => $type) { $typeNode =& XMLCustomWriter::createChildWithText($doc, $indexingNode, 'type', $type, false); if ($typeNode) { XMLCustomWriter::setAttribute($typeNode, 'locale', $locale); $isIndexingNecessary = true; } unset($typeNode); } } if (is_array($article->getSubject(null))) { foreach ($article->getSubject(null) as $locale => $subject) { $subjectNode =& XMLCustomWriter::createChildWithText($doc, $indexingNode, 'subject', $subject, false); if ($subjectNode) { XMLCustomWriter::setAttribute($subjectNode, 'locale', $locale); $isIndexingNecessary = true; } unset($subjectNode); } } if (is_array($article->getSubjectClass(null))) { foreach ($article->getSubjectClass(null) as $locale => $subjectClass) { $subjectClassNode =& XMLCustomWriter::createChildWithText($doc, $indexingNode, 'subject_class', $subjectClass, false); if ($subjectClassNode) { XMLCustomWriter::setAttribute($subjectClassNode, 'locale', $locale); $isIndexingNecessary = true; } unset($subjectClassNode); } } $coverageNode =& XMLCustomWriter::createElement($doc, 'coverage'); $isCoverageNecessary = false; if (is_array($article->getCoverageGeo(null))) { foreach ($article->getCoverageGeo(null) as $locale => $geographical) { $geographicalNode =& XMLCustomWriter::createChildWithText($doc, $coverageNode, 'geographical', $geographical, false); if ($geographicalNode) { XMLCustomWriter::setAttribute($geographicalNode, 'locale', $locale); $isCoverageNecessary = true; } unset($geographicalNode); } } if (is_array($article->getCoverageChron(null))) { foreach ($article->getCoverageChron(null) as $locale => $chronological) { $chronologicalNode =& XMLCustomWriter::createChildWithText($doc, $coverageNode, 'chronological', $chronological, false); if ($chronologicalNode) { XMLCustomWriter::setAttribute($chronologicalNode, 'locale', $locale); $isCoverageNecessary = true; } unset($chronologicalNode); } } if (is_array($article->getCoverageSample(null))) { foreach ($article->getCoverageSample(null) as $locale => $sample) { $sampleNode =& XMLCustomWriter::createChildWithText($doc, $coverageNode, 'sample', $sample, false); if ($sampleNode) { XMLCustomWriter::setAttribute($sampleNode, 'locale', $locale); $isCoverageNecessary = true; } unset($sampleNode); } } if ($isCoverageNecessary) { XMLCustomWriter::appendChild($indexingNode, $coverageNode); $isIndexingNecessary = true; } if ($isIndexingNecessary) { XMLCustomWriter::appendChild($root, $indexingNode); } /* --- */ /* --- Authors --- */ foreach ($article->getAuthors() as $author) { $authorNode =& NativeExportDom::generateAuthorDom($doc, $journal, $issue, $article, $author); XMLCustomWriter::appendChild($root, $authorNode); unset($authorNode); } /* --- */ if (is_array($article->getShowCoverPage(null))) { foreach (array_keys($article->getShowCoverPage(null)) as $locale) { if ($article->getShowCoverPage($locale)) { $coverNode =& XMLCustomWriter::createElement($doc, 'cover'); XMLCustomWriter::appendChild($root, $coverNode); XMLCustomWriter::setAttribute($coverNode, 'locale', $locale); XMLCustomWriter::createChildWithText($doc, $coverNode, 'altText', $issue->getCoverPageDescription($locale), false); $coverFile = $article->getFileName($locale); if ($coverFile != '') { $imageNode =& XMLCustomWriter::createElement($doc, 'image'); XMLCustomWriter::appendChild($coverNode, $imageNode); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPagePath = $publicFileManager->getJournalFilesPath($journal->getId()) . '/'; $coverPagePath .= $coverFile; $embedNode =& XMLCustomWriter::createChildWithText($doc, $imageNode, 'embed', base64_encode($publicFileManager->readFile($coverPagePath))); XMLCustomWriter::setAttribute($embedNode, 'filename', $article->getOriginalFileName($locale)); XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64'); XMLCustomWriter::setAttribute($embedNode, 'mime_type', String::mime_content_type($coverPagePath)); } unset($coverNode); } } } XMLCustomWriter::createChildWithText($doc, $root, 'pages', $article->getPages(), false); // NOTE that this is a required field for import, but it's // possible here to generate nonconforming XML via export b/c // of the potentially missing date_published node. This is due // to legacy data issues WRT an earlier lack of ability to // define article pub dates. Some legacy data will be missing // this date. XMLCustomWriter::createChildWithText($doc, $root, 'date_published', NativeExportDom::formatDate($article->getDatePublished()), false); if ($article->getAccessStatus() == ARTICLE_ACCESS_OPEN) { $accessNode =& XMLCustomWriter::createElement($doc, 'open_access'); XMLCustomWriter::appendChild($root, $accessNode); } /* --- Permissions --- */ $permissionsNode =& XMLCustomWriter::createElement($doc, 'permissions'); XMLCustomWriter::appendChild($root, $permissionsNode); XMLCustomWriter::createChildWithText($doc, $permissionsNode, 'license_url', $article->getLicenseURL(), false); foreach ($article->getCopyrightHolder(null) as $locale => $copyrightHolder) { $copyrightHolderNode =& XMLCustomWriter::createChildWithText($doc, $permissionsNode, 'copyright_holder', $copyrightHolder, false); if ($copyrightHolderNode) { XMLCustomWriter::setAttribute($copyrightHolderNode, 'locale', $locale); } unset($copyrightHolderNode); } XMLCustomWriter::createChildWithText($doc, $permissionsNode, 'copyright_year', $article->getCopyrightYear(), false); /* --- */ /* --- Galleys --- */ foreach ($article->getGalleys() as $galley) { $galleyNode =& NativeExportDom::generateGalleyDom($doc, $journal, $issue, $article, $galley); if ($galleyNode !== null) { XMLCustomWriter::appendChild($root, $galleyNode); } unset($galleyNode); } /* --- Supplementary Files --- */ foreach ($article->getSuppFiles() as $suppFile) { $suppNode =& NativeExportDom::generateSuppFileDom($doc, $journal, $issue, $article, $suppFile); if ($suppNode !== null) { XMLCustomWriter::appendChild($root, $suppNode); } unset($suppNode); } return $root; }
function &generateArticleDom(&$doc, &$journal, &$issue, &$section, &$article) { $root =& XMLCustomWriter::createElement($doc, 'article'); if ($doi = $article->getDOI()) { $idNode =& XMLCustomWriter::createChildWithText($doc, $root, 'id', $doi); XMLCustomWriter::setAttribute($idNode, 'type', 'doi'); } /* --- Titles and Abstracts --- */ if (is_array($article->getTitle(null))) { foreach ($article->getTitle(null) as $locale => $title) { $titleNode =& XMLCustomWriter::createChildWithText($doc, $root, 'title', $title, false); if ($titleNode) { XMLCustomWriter::setAttribute($titleNode, 'locale', $locale); } unset($titleNode); } } if (is_array($article->getAbstract(null))) { foreach ($article->getAbstract(null) as $locale => $abstract) { $abstractNode =& XMLCustomWriter::createChildWithText($doc, $root, 'abstract', $abstract, false); if ($abstractNode) { XMLCustomWriter::setAttribute($abstractNode, 'locale', $locale); } unset($abstractNode); } } /* --- Indexing --- */ $indexingNode =& XMLCustomWriter::createElement($doc, 'indexing'); $isIndexingNecessary = false; if (is_array($article->getDiscipline(null))) { foreach ($article->getDiscipline(null) as $locale => $discipline) { $disciplineNode =& XMLCustomWriter::createChildWithText($doc, $indexingNode, 'discipline', $discipline, false); if ($disciplineNode) { XMLCustomWriter::setAttribute($disciplineNode, 'locale', $locale); $isIndexingNecessary = true; } unset($disciplineNode); } } if (is_array($article->getType(null))) { foreach ($article->getType(null) as $locale => $type) { $typeNode =& XMLCustomWriter::createChildWithText($doc, $indexingNode, 'type', $type, false); if ($typeNode) { XMLCustomWriter::setAttribute($typeNode, 'locale', $locale); $isIndexingNecessary = true; } unset($typeNode); } } if (is_array($article->getSubject(null))) { foreach ($article->getSubject(null) as $locale => $subject) { $subjectNode =& XMLCustomWriter::createChildWithText($doc, $indexingNode, 'subject', $subject, false); if ($subjectNode) { XMLCustomWriter::setAttribute($subjectNode, 'locale', $locale); $isIndexingNecessary = true; } unset($subjectNode); } } if (is_array($article->getSubjectClass(null))) { foreach ($article->getSubjectClass(null) as $locale => $subjectClass) { $subjectClassNode =& XMLCustomWriter::createChildWithText($doc, $indexingNode, 'subject_class', $subjectClass, false); if ($subjectClassNode) { XMLCustomWriter::setAttribute($subjectClassNode, 'locale', $locale); $isIndexingNecessary = true; } unset($subjectClassNode); } } $coverageNode =& XMLCustomWriter::createElement($doc, 'coverage'); $isCoverageNecessary = false; if (is_array($article->getCoverageGeo(null))) { foreach ($article->getCoverageGeo(null) as $locale => $geographical) { $geographicalNode =& XMLCustomWriter::createChildWithText($doc, $coverageNode, 'geographical', $geographical, false); if ($geographicalNode) { XMLCustomWriter::setAttribute($geographicalNode, 'locale', $locale); $isCoverageNecessary = true; } unset($geographicalNode); } } if (is_array($article->getCoverageChron(null))) { foreach ($article->getCoverageChron(null) as $locale => $chronological) { $chronologicalNode =& XMLCustomWriter::createChildWithText($doc, $coverageNode, 'chronological', $chronological, false); if ($chronologicalNode) { XMLCustomWriter::setAttribute($chronologicalNode, 'locale', $locale); $isCoverageNecessary = true; } unset($chronologicalNode); } } if (is_array($article->getCoverageSample(null))) { foreach ($article->getCoverageSample(null) as $locale => $sample) { $sampleNode =& XMLCustomWriter::createChildWithText($doc, $coverageNode, 'sample', $sample, false); if ($sampleNode) { XMLCustomWriter::setAttribute($sampleNode, 'locale', $locale); $isCoverageNecessary = true; } unset($sampleNode); } } if ($isCoverageNecessary) { XMLCustomWriter::appendChild($indexingNode, $coverageNode); $isIndexingNecessary = true; } if ($isIndexingNecessary) { XMLCustomWriter::appendChild($root, $indexingNode); } /* --- */ /* --- Authors --- */ foreach ($article->getAuthors() as $author) { $authorNode =& NativeExportDom::generateAuthorDom($doc, $journal, $issue, $article, $author); XMLCustomWriter::appendChild($root, $authorNode); unset($authorNode); } /* --- */ if (is_array($article->getShowCoverPage(null))) { foreach (array_keys($article->getShowCoverPage(null)) as $locale) { if ($article->getShowCoverPage($locale)) { $coverNode =& XMLCustomWriter::createElement($doc, 'cover'); XMLCustomWriter::appendChild($root, $coverNode); XMLCustomWriter::setAttribute($coverNode, 'locale', $locale); XMLCustomWriter::createChildWithText($doc, $coverNode, 'altText', $issue->getCoverPageDescription($locale), false); $coverFile = $article->getFileName($locale); if ($coverFile != '') { $imageNode =& XMLCustomWriter::createElement($doc, 'image'); XMLCustomWriter::appendChild($coverNode, $imageNode); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPagePath = $publicFileManager->getJournalFilesPath($journal->getId()) . '/'; $coverPagePath .= $coverFile; $embedNode =& XMLCustomWriter::createChildWithText($doc, $imageNode, 'embed', base64_encode($publicFileManager->readFile($coverPagePath))); XMLCustomWriter::setAttribute($embedNode, 'filename', $article->getOriginalFileName($locale)); XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64'); XMLCustomWriter::setAttribute($embedNode, 'mime_type', String::mime_content_type($coverPagePath)); } unset($coverNode); } } } XMLCustomWriter::createChildWithText($doc, $root, 'pages', $article->getPages(), false); XMLCustomWriter::createChildWithText($doc, $root, 'date_published', NativeExportDom::formatDate($article->getDatePublished()), false); if ($article->getAccessStatus() == ARTICLE_ACCESS_OPEN) { $accessNode =& XMLCustomWriter::createElement($doc, 'open_access'); XMLCustomWriter::appendChild($root, $accessNode); } /* --- */ /* --- Galleys --- */ foreach ($article->getGalleys() as $galley) { $galleyNode =& NativeExportDom::generateGalleyDom($doc, $journal, $issue, $article, $galley); if ($galleyNode !== null) { XMLCustomWriter::appendChild($root, $galleyNode); } unset($galleyNode); } /* --- Supplementary Files --- */ foreach ($article->getSuppFiles() as $suppFile) { $suppNode =& NativeExportDom::generateSuppFileDom($doc, $journal, $issue, $article, $suppFile); if ($suppNode !== null) { XMLCustomWriter::appendChild($root, $suppNode); } unset($suppNode); } return $root; }