Ejemplo n.º 1
0
 function exportArticle(&$journal, &$issue, &$article, &$galley, $outputFile = null)
 {
     $this->import('EruditExportDom');
     $doc =& XMLCustomWriter::createDocument('article', '-//ERUDIT//Erudit Article DTD 3.0.0//EN', 'http://www.erudit.org/dtd/article/3.0.0/en/eruditarticle.dtd');
     $articleNode =& EruditExportDom::generateArticleDom($doc, $journal, $issue, $article, $galley);
     XMLCustomWriter::appendChild($doc, $articleNode);
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'wb')) === false) {
             return false;
         }
         fwrite($h, XMLCustomWriter::getXML($doc));
         fclose($h);
     } else {
         header("Content-Type: application/xml");
         header("Cache-Control: private");
         header("Content-Disposition: attachment; filename=\"erudit.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
Ejemplo n.º 2
0
 function &getMetadataPage($pageNum, &$errors)
 {
     import('xml.XMLCustomWriter');
     import('db.DBResultRange');
     $journal =& Request::getJournal();
     $journalId = $journal->getJournalId();
     $falseVar = false;
     if ($pageNum < 1) {
         return $falseVar;
     }
     $rangeInfo =& new DBResultRange(GOOGLE_SCHOLAR_ITEMS_PER_PAGE, $pageNum);
     $document =& XMLCustomWriter::createDocument('articles', 'articles.dtd');
     $articlesNode =& XMLCustomWriter::createElement($document, 'articles');
     XMLCustomWriter::appendChild($document, $articlesNode);
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $publishedArticles =& $publishedArticleDao->getPublishedArticlesByJournalId($journalId, $rangeInfo);
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $issueCache = array();
     while ($publishedArticle =& $publishedArticles->next()) {
         $articleNode =& XMLCustomWriter::createElement($document, 'article');
         XMLCustomWriter::appendChild($articlesNode, $articleNode);
         $frontNode =& XMLCustomWriter::createElement($document, 'front');
         XMLCustomWriter::appendChild($articleNode, $frontNode);
         $journalMetaNode =& XMLCustomWriter::createElement($document, 'journal-meta');
         XMLCustomWriter::appendChild($frontNode, $journalMetaNode);
         // Journal Metadata
         $journal =& Request::getJournal();
         XMLCustomWriter::createChildWithText($document, $journalMetaNode, 'journal-title', $journal->getJournalTitle(), true);
         XMLCustomWriter::createChildWithText($document, $journalMetaNode, 'abbrev-journal-title', $journal->getLocalizedSetting('initials'), false);
         $issn = $journal->getSetting('onlineIssn');
         if (empty($issn)) {
             array_push($errors, Locale::translate('plugins.gateways.googleScholar.errors.noIssn'));
             return $falseVar;
         }
         XMLCustomWriter::createChildWithText($document, $journalMetaNode, 'issn', $issn, false);
         $publisherNode =& XMLCustomWriter::createElement($document, 'publisher');
         $publisherName = $this->getSetting($journalId, 'publisher-name');
         if (empty($publisherName)) {
             array_push($errors, Locale::translate('plugins.gateways.googleScholar.errors.noPublisherName'));
             return $falseVar;
         }
         XMLCustomWriter::createChildWithText($document, $publisherNode, 'publisher-name', $publisherName, true);
         XMLCustomWriter::appendChild($journalMetaNode, $publisherNode);
         $articleMetaNode =& XMLCustomWriter::createElement($document, 'article-meta');
         XMLCustomWriter::appendChild($frontNode, $articleMetaNode);
         // Article Metadata
         $titleGroupNode =& XMLCustomWriter::createElement($document, 'title-group');
         XMLCustomWriter::appendChild($articleMetaNode, $titleGroupNode);
         $titles = $publishedArticle->getTitle(null);
         $primaryLocale = $journal->getPrimaryLocale();
         XMLCustomWriter::createChildWithText($document, $titleGroupNode, 'article-title', $titles[$primaryLocale], true);
         unset($titles[$primaryLocale]);
         foreach ($titles as $locale => $title) {
             XMLCustomWriter::createChildWithText($document, $titleGroupNode, 'trans-title', $title, false);
         }
         $contribGroupNode =& XMLCustomWriter::createElement($document, 'contrib-group');
         XMLCustomWriter::appendChild($articleMetaNode, $contribGroupNode);
         foreach ($publishedArticle->getAuthors() as $author) {
             $contribNode =& XMLCustomWriter::createElement($document, 'contrib');
             XMLCustomWriter::appendChild($contribGroupNode, $contribNode);
             XMLCustomWriter::setAttribute($contribNode, 'contrib-type', 'author');
             $nameNode =& XMLCustomWriter::createElement($document, 'name');
             XMLCustomWriter::appendChild($contribNode, $nameNode);
             // Opatan Inc.
             XMLCustomWriter::createChildWithText($document, $nameNode, 'surname', $author->getAuthorLastName(), true);
             // Given names in the form: FirstName MiddleName, where MiddleName is optional
             $name = $author->getAuthorFirstName();
             // Opatan Inc. : gets Localized author firstName
             if (($middleName = $author->getAuthorMiddleName()) != '') {
                 $name .= " {$middleName}";
             }
             // Opatan Inc.
             XMLCustomWriter::createChildWithText($document, $nameNode, 'given-names', $name, true);
         }
         $dateParts = getdate(strtotime($publishedArticle->getDatePublished()));
         $pubDateNode =& XMLCustomWriter::createElement($document, 'pub-date');
         XMLCustomWriter::appendChild($articleMetaNode, $pubDateNode);
         XMLCustomWriter::createChildWithText($document, $pubDateNode, 'day', $dateParts['mday']);
         XMLCustomWriter::createChildWithText($document, $pubDateNode, 'month', $dateParts['mon']);
         XMLCustomWriter::createChildWithText($document, $pubDateNode, 'year', $dateParts['year']);
         $issueId = $publishedArticle->getIssueId();
         if (!isset($issueCache[$issueId])) {
             $issueCache[$issueId] =& $issueDao->getIssueById($issueId);
         }
         $issue =& $issueCache[$issueId];
         XMLCustomWriter::createChildWithText($document, $articleMetaNode, 'volume', $issue->getVolume());
         XMLCustomWriter::createChildWithText($document, $articleMetaNode, 'issue', $issue->getNumber());
         $canonicalUriNode =& XMLCustomWriter::createElement($document, 'self-uri');
         XMLCustomWriter::setAttribute($canonicalUriNode, 'xlink:href', Request::url(null, 'article', 'viewArticle', array($publishedArticle->getArticleId())));
         XMLCustomWriter::appendChild($articleMetaNode, $canonicalUriNode);
         foreach ($publishedArticle->getGalleys() as $galley) {
             $galleyUriNode =& XMLCustomWriter::createElement($document, 'self-uri');
             if ($galley->isHTMLGalley()) {
                 XMLCustomWriter::setAttribute($galleyUriNode, 'xlink:href', Request::url(null, 'article', 'viewArticle', array($publishedArticle->getArticleId(), $galley->getGalleyId())));
             } else {
                 XMLCustomWriter::setAttribute($galleyUriNode, 'xlink:href', Request::url(null, 'article', 'viewFile', array($publishedArticle->getArticleId(), $galley->getGalleyId())));
             }
             XMLCustomWriter::appendChild($articleMetaNode, $galleyUriNode);
         }
         unset($issue);
     }
     return $document;
 }
Ejemplo n.º 3
0
 function &createChildWithText(&$doc, &$node, $name, $value, $appendIfEmpty = true)
 {
     $childNode = null;
     if ($appendIfEmpty || $value != '') {
         $childNode =& XMLCustomWriter::createElement($doc, $name);
         $textNode =& XMLCustomWriter::createTextNode($doc, $value);
         XMLCustomWriter::appendChild($childNode, $textNode);
         XMLCustomWriter::appendChild($node, $childNode);
     }
     return $childNode;
 }
Ejemplo n.º 4
0
 /**
  * Create a description text element.
  *
  * @param $workOrProduct string
  * @param $relationCode string One of the O4DOI_RELATION_* constants.
  * @param $ids array
  *
  * @return XMLNode|DOMImplementation
  */
 function &_relationElement($workOrProduct, $relationCode, $ids)
 {
     $relationElement =& XMLCustomWriter::createElement($this->getDoc(), "Related{$workOrProduct}");
     // Relation code (mandatory)
     XMLCustomWriter::createChildWithText($this->getDoc(), $relationElement, 'RelationCode', $relationCode);
     // Work/Product ID (mandatory)
     foreach ($ids as $idType => $id) {
         XMLCustomWriter::appendChild($relationElement, $this->_idElement($workOrProduct, $idType, $id));
     }
     return $relationElement;
 }
Ejemplo n.º 5
0
 /**
  * Create an XML element with a text node.
  *
  * FIXME: Move this to XMLCustomWriter? I leave the decision up to PKP...
  *
  * @param $name string
  * @param $value string
  * @param $attributes array An array with the attribute names as array
  *  keys and attribute values as array values.
  *
  * @return XMLNode|DOMImplementation
  */
 function &createElementWithText($name, $value, $attributes = array())
 {
     $element =& XMLCustomWriter::createElement($this->getDoc(), $name);
     $elementContent =& XMLCustomWriter::createTextNode($this->getDoc(), String::html2text($value));
     XMLCustomWriter::appendChild($element, $elementContent);
     foreach ($attributes as $attributeName => $attributeValue) {
         XMLCustomWriter::setAttribute($element, $attributeName, $attributeValue);
     }
     return $element;
 }
 function exportArticles(&$results, $outputFile = null)
 {
     $this->import('NativeExportDom');
     $doc =& XMLCustomWriter::createDocument('articles', NATIVE_DTD_ID, NATIVE_DTD_URL);
     $articlesNode =& XMLCustomWriter::createElement($doc, 'articles');
     XMLCustomWriter::appendChild($doc, $articlesNode);
     foreach ($results as $result) {
         $article =& $result['publishedArticle'];
         $section =& $result['section'];
         $issue =& $result['issue'];
         $journal =& $result['journal'];
         $articleNode =& NativeExportDom::generateArticleDom($doc, $journal, $issue, $section, $article);
         XMLCustomWriter::appendChild($articlesNode, $articleNode);
     }
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'w')) === false) {
             return false;
         }
         fwrite($h, XMLCustomWriter::getXML($doc));
         fclose($h);
     } else {
         header("Content-Type: application/xml");
         header("Cache-Control: private");
         header("Content-Disposition: attachment; filename=\"articles.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
Ejemplo n.º 7
0
 /**
  *  Create METS:metsHdr for export
  */
 function &createmetsHdr($doc)
 {
     $root =& XMLCustomWriter::createElement($doc, 'METS:metsHdr');
     XMLCustomWriter::setAttribute($root, 'CREATEDATE', date('c'));
     XMLCustomWriter::setAttribute($root, 'LASTMODDATE', date('c'));
     $agentNode =& XMLCustomWriter::createElement($doc, 'METS:agent');
     XMLCustomWriter::setAttribute($agentNode, 'ROLE', 'DISSEMINATOR');
     XMLCustomWriter::setAttribute($agentNode, 'TYPE', 'ORGANIZATION');
     $organization = Request::getUserVar('organization');
     if ($organization == '') {
         $siteDao =& DAORegistry::getDAO('SiteDAO');
         $site = $siteDao->getSite();
         $organization = $site->getLocalizedTitle();
     }
     XMLCustomWriter::createChildWithText($doc, $agentNode, 'METS:name', $organization, false);
     XMLCustomWriter::appendChild($root, $agentNode);
     $agentNode2 =& XMLCustomWriter::createElement($doc, 'METS:agent');
     XMLCustomWriter::setAttribute($agentNode2, 'ROLE', 'CREATOR');
     XMLCustomWriter::setAttribute($agentNode2, 'TYPE', 'OTHER');
     XMLCustomWriter::createChildWithText($doc, $agentNode2, 'METS:name', MetsExportDom::getCreatorString(), false);
     XMLCustomWriter::appendChild($root, $agentNode2);
     return $root;
 }
Ejemplo n.º 8
0
 function &generateArticleDom(&$doc, &$journal, &$issue, &$section, &$article)
 {
     // register the editor submission DAO for use later
     $editorSubmissionDao =& DAORegistry::getDAO('EditorSubmissionDAO');
     /* --- Article --- */
     $root =& XMLCustomWriter::createElement($doc, 'Article');
     /* --- Journal --- */
     $journalNode =& XMLCustomWriter::createElement($doc, 'Journal');
     XMLCustomWriter::appendChild($root, $journalNode);
     $publisherInstitution = $journal->getSetting('publisherInstitution');
     $publisherNode = XMLCustomWriter::createChildWithText($doc, $journalNode, 'PublisherName', $publisherInstitution);
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'JournalTitle', $journal->getLocalizedTitle());
     // check various ISSN fields to create the ISSN tag
     if ($journal->getSetting('printIssn') != '') {
         $ISSN = $journal->getSetting('printIssn');
     } elseif ($journal->getSetting('issn') != '') {
         $ISSN = $journal->getSetting('issn');
     } elseif ($journal->getSetting('onlineIssn') != '') {
         $ISSN = $journal->getSetting('onlineIssn');
     } else {
         $ISSN = '';
     }
     if ($ISSN != '') {
         XMLCustomWriter::createChildWithText($doc, $journalNode, 'Issn', $ISSN);
     }
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'Volume', $issue->getVolume());
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'Issue', $issue->getNumber(), false);
     $datePublished = $article->getDatePublished();
     if (!$datePublished) {
         $datePublished = $issue->getDatePublished();
     }
     if ($datePublished) {
         $pubDateNode =& PubMedExportDom::generatePubDateDom($doc, $datePublished, 'epublish');
         XMLCustomWriter::appendChild($journalNode, $pubDateNode);
     }
     /* --- Replaces --- */
     // this creates a blank replaces tag since OJS doesn't contain PMID metadata
     //		XMLCustomWriter::createChildWithText($doc, $root, 'Replaces', '');
     /* --- ArticleTitle / VernacularTitle --- */
     // there is some ambiguity between whether to use
     // article->getlanguage or journal->getlocale
     // PubMed requires english titles for ArticleTitle
     $language = $article->getLanguage();
     if ($language == 'en' || $language == '') {
         XMLCustomWriter::createChildWithText($doc, $root, 'ArticleTitle', $article->getLocalizedTitle());
     } else {
         XMLCustomWriter::createChildWithText($doc, $root, 'VernacularTitle', $article->getLocalizedTitle());
     }
     /* --- FirstPage / LastPage --- */
     // there is some ambiguity for online journals as to what
     // "page numbers" are; for example, some journals (eg. JMIR)
     // use the "e-location ID" as the "page numbers" in PubMed
     $pages = $article->getPages();
     if (preg_match("/([0-9]+)\\s*-\\s*([0-9]+)/i", $pages, $matches)) {
         // simple pagination (eg. "pp. 3-8")
         XMLCustomWriter::createChildWithText($doc, $root, 'FirstPage', $matches[1]);
         XMLCustomWriter::createChildWithText($doc, $root, 'LastPage', $matches[2]);
     } elseif (preg_match("/(e[0-9]+)\\s*-\\s*(e[0-9]+)/i", $pages, $matches)) {
         // e9 - e14, treated as page ranges
         XMLCustomWriter::createChildWithText($doc, $root, 'FirstPage', $matches[1]);
         XMLCustomWriter::createChildWithText($doc, $root, 'LastPage', $matches[2]);
     } elseif (preg_match("/(e[0-9]+)/i", $pages, $matches)) {
         // single elocation-id (eg. "e12")
         XMLCustomWriter::createChildWithText($doc, $root, 'FirstPage', $matches[1]);
         XMLCustomWriter::createChildWithText($doc, $root, 'LastPage', $matches[1]);
     } else {
         // we need to insert something, so use the best ID possible
         XMLCustomWriter::createChildWithText($doc, $root, 'FirstPage', $article->getBestArticleId($journal));
         XMLCustomWriter::createChildWithText($doc, $root, 'LastPage', $article->getBestArticleId($journal));
     }
     /* --- DOI --- */
     if ($doi = $article->getPubId('doi')) {
         $doiNode =& XMLCustomWriter::createChildWithText($doc, $root, 'ELocationID', $doi, false);
         XMLCustomWriter::setAttribute($doiNode, 'EIdType', 'doi');
     }
     /* --- Language --- */
     XMLCustomWriter::createChildWithText($doc, $root, 'Language', strtoupper($article->getLanguage()), false);
     /* --- AuthorList --- */
     $authorListNode =& XMLCustomWriter::createElement($doc, 'AuthorList');
     XMLCustomWriter::appendChild($root, $authorListNode);
     $authorIndex = 0;
     foreach ($article->getAuthors() as $author) {
         $authorNode =& PubMedExportDom::generateAuthorDom($doc, $author, $authorIndex++);
         XMLCustomWriter::appendChild($authorListNode, $authorNode);
     }
     /* --- ArticleIdList --- */
     // Pubmed will accept two types of article identifier: pii and doi
     // how this is handled is journal-specific, and will require either
     // configuration in the plugin, or an update to the core code.
     // this is also related to DOI-handling within OJS
     if ($article->getPubId('publisher-id')) {
         $articleIdListNode =& XMLCustomWriter::createElement($doc, 'ArticleIdList');
         XMLCustomWriter::appendChild($root, $articleIdListNode);
         $articleIdNode =& XMLCustomWriter::createChildWithText($doc, $articleIdListNode, 'ArticleId', $article->getPubId('publisher-id'));
         XMLCustomWriter::setAttribute($articleIdNode, 'IdType', 'pii');
     }
     /* --- History --- */
     $historyNode =& XMLCustomWriter::createElement($doc, 'History');
     XMLCustomWriter::appendChild($root, $historyNode);
     // date manuscript received for review
     $receivedNode =& PubMedExportDom::generatePubDateDom($doc, $article->getDateSubmitted(), 'received');
     XMLCustomWriter::appendChild($historyNode, $receivedNode);
     // accepted for publication
     $editordecisions = $editorSubmissionDao->getEditorDecisions($article->getId());
     // if there are multiple decisions, make sure we get the accepted date
     $editordecision = array_pop($editordecisions);
     while ($editordecision['decision'] != SUBMISSION_EDITOR_DECISION_ACCEPT && count($editordecisions) > 0) {
         $editordecision = array_pop($editordecisions);
     }
     if ($editordecision != '') {
         $acceptedNode =& PubMedExportDom::generatePubDateDom($doc, $editordecision['dateDecided'], 'accepted');
         XMLCustomWriter::appendChild($historyNode, $acceptedNode);
     }
     // article revised by publisher or author
     // check if there is a revised version; if so, generate a revised tag
     $revisedFileID = $article->getRevisedFileId();
     if (!empty($revisedFileID)) {
         $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
         $articleFile =& $articleFileDao->getArticleFile($revisedFileID);
         if ($articleFile) {
             $revisedNode =& PubMedExportDom::generatePubDateDom($doc, $articleFile->getDateModified(), 'revised');
             XMLCustomWriter::appendChild($historyNode, $revisedNode);
         }
     }
     /* --- Abstract --- */
     if ($article->getLocalizedAbstract()) {
         $abstractNode = XMLCustomWriter::createChildWithText($doc, $root, 'Abstract', strip_tags($article->getLocalizedAbstract()), false);
     }
     return $root;
 }
Ejemplo n.º 9
0
 /**
  * Construct a sitemap for a scheduled conference
  * @return XMLNode
  */
 function createSchedConfSitemap()
 {
     $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
     $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
     $conference =& Request::getConference();
     $conferenceId = $conference->getId();
     $schedConf = Request::getSchedConf();
     $doc =& XMLCustomWriter::createDocument();
     $root =& XMLCustomWriter::createElement($doc, 'urlset');
     XMLCustomWriter::setAttribute($root, 'xmlns', SITEMAP_XSD_URL);
     // Sched. Conf. home
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath())));
     // About page
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'about')));
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'about', 'submissions')));
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'about', 'siteMap')));
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'about', 'aboutThisPublishingSystem')));
     // Search
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'search')));
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'search', 'authors')));
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'search', 'titles')));
     // Conference Information
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'overview')));
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'trackPolicies')));
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'presentations')));
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'accommodation')));
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'location')));
     XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'organizingTeam')));
     // Individual Papers
     $publishedPapers =& $publishedPaperDao->getPublishedPapers($schedConf->getId());
     while ($paper =& $publishedPapers->next()) {
         // Abstract
         XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'paper', 'view', $paper->getId())));
         // Galley files
         $galleys = $galleyDao->getGalleysByPaper($paper->getId());
         foreach ($galleys as $galley) {
             XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'paper', 'view', array($paper->getId(), $galley->getId()))));
         }
     }
     XMLCustomWriter::appendChild($doc, $root);
     return $doc;
 }
Ejemplo n.º 10
0
 function &generatePaperDom(&$doc, &$conference, &$track, &$paper)
 {
     // register the editor submission DAO for use later
     //		$editorSubmissionDao =& DAORegistry::getDAO('EditorSubmissionDAO');
     /* --- MeetingAbstract --- */
     $root =& XMLCustomWriter::createElement($doc, 'MeetingAbstract');
     XMLCustomWriter::setAttribute($root, 'Status', 'Completed');
     /* --- DateCreated --- */
     $dateNode =& XMLCustomWriter::createElement($doc, 'DateCreated');
     XMLCustomWriter::appendChild($root, $dateNode);
     XMLCustomWriter::createChildWithText($doc, $dateNode, 'Year', date('Y'));
     XMLCustomWriter::createChildWithText($doc, $dateNode, 'Month', date('m'));
     XMLCustomWriter::createChildWithText($doc, $dateNode, 'Day', date('d'));
     /* --- Article/Paper --- */
     $articleNode =& XMLCustomWriter::createElement($doc, 'Article');
     XMLCustomWriter::setAttribute($articleNode, 'PubModel', 'Electronic');
     XMLCustomWriter::appendChild($root, $articleNode);
     /* --- Journal/Book --- */
     // FIXME: at the moment this is a null element required by NLM
     $journalNode =& XMLCustomWriter::createChildWithText($doc, $articleNode, 'Journal', null);
     $journalIssueNode =& XMLCustomWriter::createElement($doc, 'JournalIssue');
     XMLCustomWriter::setAttribute($journalIssueNode, 'CitedMedium', 'Internet');
     XMLCustomWriter::appendChild($journalNode, $journalIssueNode);
     $journalDateNode =& XMLCustomWriter::createElement($doc, 'PubDate');
     XMLCustomWriter::appendChild($journalIssueNode, $journalDateNode);
     XMLCustomWriter::createChildWithText($doc, $journalDateNode, 'MedlineDate', date('Y'));
     /* --- ArticleTitle --- */
     // NLM requires english titles for PaperTitle
     XMLCustomWriter::createChildWithText($doc, $articleNode, 'ArticleTitle', $paper->getLocalizedTitle());
     /* --- Pagination --- */
     // If there is no page number, then use abstract number
     $paginationNode =& XMLCustomWriter::createElement($doc, 'Pagination');
     XMLCustomWriter::appendChild($articleNode, $paginationNode);
     $pages = $paper->getPages();
     if (preg_match("/([0-9]+)\\s*-\\s*([0-9]+)/i", $pages, $matches)) {
         // simple pagination (eg. "pp. 3- 		8")
         XMLCustomWriter::createChildWithText($doc, $paginationNode, 'MedlinePgn', $matches[1] . '-' . $matches[2]);
     } elseif (preg_match("/(e[0-9]+)/i", $pages, $matches)) {
         // elocation-id (eg. "e12")
         XMLCustomWriter::createChildWithText($doc, $paginationNode, 'MedlinePgn', $matches[1]);
     } else {
         // we need to insert something, so use the best ID possible
         XMLCustomWriter::createChildWithText($doc, $paginationNode, 'MedlinePgn', $paper->getBestPaperId($conference));
     }
     /* --- Abstract --- */
     $abstractNode =& XMLCustomWriter::createElement($doc, 'Abstract');
     XMLCustomWriter::appendChild($articleNode, $abstractNode);
     XMLCustomWriter::createChildWithText($doc, $abstractNode, 'AbstractText', strip_tags($paper->getLocalizedAbstract()), false);
     /* --- Affiliation --- */
     $sponsor = $paper->getLocalizedSponsor();
     if ($sponsor != '') {
         XMLCustomWriter::createChildWithText($doc, $articleNode, 'Affiliation', $sponsor);
     }
     /* --- AuthorList --- */
     $authorListNode =& XMLCustomWriter::createElement($doc, 'AuthorList');
     XMLCustomWriter::setAttribute($authorListNode, 'CompleteYN', 'Y');
     XMLCustomWriter::appendChild($articleNode, $authorListNode);
     foreach ($paper->getAuthors() as $author) {
         $authorNode =& NLMExportDom::generateAuthorDom($doc, $author);
         XMLCustomWriter::appendChild($authorListNode, $authorNode);
     }
     /* --- Conference --- */
     $conferenceNode =& XMLCustomWriter::createElement($doc, 'Author');
     XMLCustomWriter::appendChild($authorListNode, $conferenceNode);
     XMLCustomWriter::createChildWithText($doc, $conferenceNode, 'CollectiveName', $conference->getConferenceTitle());
     // OtherInformation element goes here with location for current conference
     /* --- Language --- */
     XMLCustomWriter::createChildWithText($doc, $articleNode, 'Language', strtolower($paper->getLanguage()), false);
     /* --- MedlineJournalInfo--- */
     // FIXME: at the moment this is a null element required by NLM
     $journalInfoNode =& XMLCustomWriter::createChildWithText($doc, $root, 'MedlineJournalInfo', null);
     XMLCustomWriter::createChildWithText($doc, $journalInfoNode, 'MedlineTA', null);
     return $root;
 }
 /**
  * Export public identifiers of one or more issues.
  * @param $journal object
  * @param $issues array
  * @param $outputFile xml file containing the exported public identifiers
  */
 function exportPubIdsForIssues($journal, $issues, $outputFile = null)
 {
     $doc =& XMLCustomWriter::createDocument('pubIds', PID_DTD_URL, PID_DTD_URL);
     $pubIdsNode =& XMLCustomWriter::createElement($doc, 'pubIds');
     XMLCustomWriter::appendChild($doc, $pubIdsNode);
     foreach ($issues as $issue) {
         $this->generatePubId($doc, $pubIdsNode, $issue, $journal->getId());
         $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
         foreach ($publishedArticleDao->getPublishedArticles($issue->getId()) as $publishedArticle) {
             $this->generatePubId($doc, $pubIdsNode, $publishedArticle, $journal->getId());
             $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
             $galleys = $articleGalleyDao->getBySubmissionId($publishedArticle->getId());
             while ($galley = $galleys->next()) {
                 $this->generatePubId($doc, $pubIdsNode, $galley, $journal->getId());
             }
         }
     }
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'w')) === false) {
             return false;
         }
         fwrite($h, XMLCustomWriter::getXML($doc));
         fclose($h);
     } else {
         header("Content-Type: application/xml");
         header("Cache-Control: private");
         header("Content-Disposition: attachment; filename=\"pubIds.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
 /**
  * Generate the journal_article node (the heart of the file).
  * @param $doc XMLNode
  * @param $journal Journal
  * @param $issue Issue
  * @param $section Section
  * @param $article Article
  * @return XMLNode
  */
 function &generateJournalArticleDom(&$doc, &$journal, &$issue, &$section, &$article)
 {
     // Create the base node
     $journalArticleNode =& XMLCustomWriter::createElement($doc, 'journal_article');
     XMLCustomWriter::setAttribute($journalArticleNode, 'publication_type', 'full_text');
     /* Titles */
     $titlesNode =& XMLCustomWriter::createElement($doc, 'titles');
     XMLCustomWriter::createChildWithText($doc, $titlesNode, 'title', $article->getLocalizedTitle());
     XMLCustomWriter::appendChild($journalArticleNode, $titlesNode);
     $contributorsNode =& XMLCustomWriter::createElement($doc, 'contributors');
     /* AuthorList */
     $isFirst = true;
     foreach ($article->getAuthors() as $author) {
         $authorNode =& CrossRefExportDom::generateAuthorDom($doc, $author, $isFirst);
         $isFirst = false;
         XMLCustomWriter::appendChild($contributorsNode, $authorNode);
     }
     XMLCustomWriter::appendChild($journalArticleNode, $contributorsNode);
     /* publication date of issue */
     if ($issue->getDatePublished()) {
         $publicationDateNode =& CrossRefExportDom::generatePublisherDateDom($doc, $issue->getDatePublished());
         XMLCustomWriter::appendChild($journalArticleNode, $publicationDateNode);
     }
     /* publisher_item is the article pages */
     if ($article->getPages() != '') {
         $publisherItemNode =& XMLCustomWriter::createElement($doc, 'publisher_item');
         XMLCustomWriter::createChildWithText($doc, $publisherItemNode, 'item_number', $article->getPages());
         XMLCustomWriter::appendChild($journalArticleNode, $publisherItemNode);
     }
     return $journalArticleNode;
 }
Ejemplo n.º 13
0
 function &generateSuppFileDom(&$doc, &$journal, &$issue, &$article, &$suppFile)
 {
     $root =& XMLCustomWriter::createElement($doc, 'supplemental_file');
     NativeExportDom::generatePubId($doc, $root, $suppFile, $issue);
     // FIXME: These should be constants!
     switch ($suppFile->getType()) {
         case __('author.submit.suppFile.researchInstrument'):
             $suppFileType = 'research_instrument';
             break;
         case __('author.submit.suppFile.researchMaterials'):
             $suppFileType = 'research_materials';
             break;
         case __('author.submit.suppFile.researchResults'):
             $suppFileType = 'research_results';
             break;
         case __('author.submit.suppFile.transcripts'):
             $suppFileType = 'transcripts';
             break;
         case __('author.submit.suppFile.dataAnalysis'):
             $suppFileType = 'data_analysis';
             break;
         case __('author.submit.suppFile.dataSet'):
             $suppFileType = 'data_set';
             break;
         case __('author.submit.suppFile.sourceText'):
             $suppFileType = 'source_text';
             break;
         default:
             $suppFileType = 'other';
             break;
     }
     XMLCustomWriter::setAttribute($root, 'type', $suppFileType);
     XMLCustomWriter::setAttribute($root, 'public_id', $suppFile->getPubId('publisher-id'), false);
     XMLCustomWriter::setAttribute($root, 'language', $suppFile->getLanguage(), false);
     XMLCustomWriter::setAttribute($root, 'show_reviewers', $suppFile->getShowReviewers() ? 'true' : 'false');
     if (is_array($suppFile->getTitle(null))) {
         foreach ($suppFile->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($suppFile->getCreator(null))) {
         foreach ($suppFile->getCreator(null) as $locale => $creator) {
             $creatorNode =& XMLCustomWriter::createChildWithText($doc, $root, 'creator', $creator, false);
             if ($creatorNode) {
                 XMLCustomWriter::setAttribute($creatorNode, 'locale', $locale);
             }
             unset($creatorNode);
         }
     }
     if (is_array($suppFile->getSubject(null))) {
         foreach ($suppFile->getSubject(null) as $locale => $subject) {
             $subjectNode =& XMLCustomWriter::createChildWithText($doc, $root, 'subject', $subject, false);
             if ($subjectNode) {
                 XMLCustomWriter::setAttribute($subjectNode, 'locale', $locale);
             }
             unset($subjectNode);
         }
     }
     if ($suppFileType == 'other') {
         if (is_array($suppFile->getTypeOther(null))) {
             foreach ($suppFile->getTypeOther(null) as $locale => $typeOther) {
                 $typeOtherNode =& XMLCustomWriter::createChildWithText($doc, $root, 'type_other', $typeOther, false);
                 if ($typeOtherNode) {
                     XMLCustomWriter::setAttribute($typeOtherNode, 'locale', $locale);
                 }
                 unset($typeOtherNode);
             }
         }
     }
     if (is_array($suppFile->getDescription(null))) {
         foreach ($suppFile->getDescription(null) as $locale => $description) {
             $descriptionNode =& XMLCustomWriter::createChildWithText($doc, $root, 'description', $description, false);
             if ($descriptionNode) {
                 XMLCustomWriter::setAttribute($descriptionNode, 'locale', $locale);
             }
             unset($descriptionNode);
         }
     }
     if (is_array($suppFile->getPublisher(null))) {
         foreach ($suppFile->getPublisher(null) as $locale => $publisher) {
             $publisherNode =& XMLCustomWriter::createChildWithText($doc, $root, 'publisher', $publisher, false);
             if ($publisherNode) {
                 XMLCustomWriter::setAttribute($publisherNode, 'locale', $locale);
             }
             unset($publisherNode);
         }
     }
     if (is_array($suppFile->getSponsor(null))) {
         foreach ($suppFile->getSponsor(null) as $locale => $sponsor) {
             $sponsorNode =& XMLCustomWriter::createChildWithText($doc, $root, 'sponsor', $sponsor, false);
             if ($sponsorNode) {
                 XMLCustomWriter::setAttribute($sponsorNode, 'locale', $locale);
             }
             unset($sponsorNode);
         }
     }
     XMLCustomWriter::createChildWithText($doc, $root, 'date_created', NativeExportDom::formatDate($suppFile->getDateCreated()), false);
     if (is_array($suppFile->getSource(null))) {
         foreach ($suppFile->getSource(null) as $locale => $source) {
             $sourceNode =& XMLCustomWriter::createChildWithText($doc, $root, 'source', $source, false);
             if ($sourceNode) {
                 XMLCustomWriter::setAttribute($sourceNode, 'locale', $locale);
             }
             unset($sourceNode);
         }
     }
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($article->getId());
     $fileNode =& XMLCustomWriter::createElement($doc, 'file');
     XMLCustomWriter::appendChild($root, $fileNode);
     if ($suppFile->getRemoteURL()) {
         $remoteNode =& XMLCustomWriter::createElement($doc, 'remote');
         XMLCustomWriter::appendChild($fileNode, $remoteNode);
         XMLCustomWriter::setAttribute($remoteNode, 'src', $suppFile->getRemoteURL());
     } else {
         $embedNode =& XMLCustomWriter::createChildWithText($doc, $fileNode, 'embed', base64_encode($articleFileManager->readFile($suppFile->getFileId())));
         XMLCustomWriter::setAttribute($embedNode, 'filename', $suppFile->getOriginalFileName());
         XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64');
         XMLCustomWriter::setAttribute($embedNode, 'mime_type', $suppFile->getFileType());
     }
     return $root;
 }
Ejemplo n.º 14
0
 /**
  * Index rebuild cleanup: mark select options as clean.
  */
 function callbackFinish($hookName, $args)
 {
     $searchFormElementDao =& DAORegistry::getDAO('SearchFormElementDAO');
     $searchFormElements =& $searchFormElementDao->getSearchFormElements();
     while ($searchFormElement =& $searchFormElements->next()) {
         $searchFormElement->setIsClean(true);
         $searchFormElementDao->updateSearchFormElement($searchFormElement);
         unset($searchFormElement);
     }
     if ($this->isUsingSolr()) {
         import('lib.pkp.classes.xml.XMLCustomWriter');
         $doc =& XMLCustomWriter::createDocument('commit', SOLR_DTD_ID, SOLR_DTD_URL);
         $docNode =& XMLCustomWriter::createElement($doc, 'commit');
         XMLCustomWriter::appendChild($doc, $docNode);
         $this->solrQuery($doc);
         unset($doc);
         $doc =& XMLCustomWriter::createDocument('optimize', SOLR_DTD_ID, SOLR_DTD_URL);
         $docNode =& XMLCustomWriter::createElement($doc, 'optimize');
         XMLCustomWriter::appendChild($doc, $docNode);
         $this->solrQuery($doc);
         unset($doc);
     } else {
         $index =& $this->getIndex();
         $index->optimize();
     }
 }
Ejemplo n.º 15
0
 function exportPapers(&$results, $outputFile = null)
 {
     $this->import('NLMExportDom');
     $doc =& NLMExportDom::generateNLMDom();
     $paperSetNode =& NLMExportDom::generatePaperSetDom($doc);
     foreach ($results as $result) {
         $conference =& $result['conference'];
         $track =& $result['track'];
         $paper =& $result['publishedPaper'];
         $paperNode =& NLMExportDom::generatePaperDom($doc, $conference, $track, $paper);
         XMLCustomWriter::appendChild($paperSetNode, $paperNode);
     }
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'w')) === false) {
             return false;
         }
         fwrite($h, XMLCustomWriter::getXML($doc));
         fclose($h);
     } else {
         header("Content-Type: application/xml");
         header("Cache-Control: private");
         header("Content-Disposition: attachment; filename=\"nlm.xml\"");
         XMLCustomWriter::printXML($doc);
         //echo '<pre>'.htmlentities(preg_replace('/></', ">\n<", XMLCustomWriter::getXML($doc))).'</pre>';
     }
     return true;
 }
Ejemplo n.º 16
0
 /**
  * Generate the DOM tree for a given article.
  * @param $doc object DOM object
  * @param $journal object Journal
  * @param $issue object Issue
  * @param $section object Section
  * @param $article object Article
  */
 function &generateArticleDom(&$doc, &$journal, &$issue, &$section, &$article)
 {
     $root =& XMLCustomWriter::createElement($doc, 'record');
     /* --- Article Language --- */
     XMLCustomWriter::createChildWithText($doc, $root, 'language', DOAJExportDom::mapLang($article->getLanguage()), false);
     /* --- Publisher name (i.e. institution name) --- */
     XMLCustomWriter::createChildWithText($doc, $root, 'publisher', $journal->getSetting('publisherInstitution'), false);
     /* --- Journal's title --- */
     XMLCustomWriter::createChildWithText($doc, $root, 'journalTitle', $journal->getLocalizedTitle(), false);
     /* --- Identification Numbers --- */
     XMLCustomWriter::createChildWithText($doc, $root, 'issn', $journal->getSetting('printIssn'), false);
     XMLCustomWriter::createChildWithText($doc, $root, 'eissn', $journal->getSetting('onlineIssn'), false);
     /* --- Article's publication date, volume, issue, DOI --- */
     XMLCustomWriter::createChildWithText($doc, $root, 'publicationDate', DOAJExportDom::formatDate($issue->getDatePublished()), false);
     XMLCustomWriter::createChildWithText($doc, $root, 'volume', $issue->getVolume(), false);
     XMLCustomWriter::createChildWithText($doc, $root, 'issue', $issue->getNumber(), false);
     /** --- FirstPage / LastPage (from PubMed plugin)---
      * there is some ambiguity for online journals as to what
      * "page numbers" are; for example, some journals (eg. JMIR)
      * use the "e-location ID" as the "page numbers" in PubMed
      */
     $pages = $article->getPages();
     if (preg_match("/([0-9]+)\\s*-\\s*([0-9]+)/i", $pages, $matches)) {
         // simple pagination (eg. "pp. 3-8")
         XMLCustomWriter::createChildWithText($doc, $root, 'startPage', $matches[1]);
         XMLCustomWriter::createChildWithText($doc, $root, 'endPage', $matches[2]);
     } elseif (preg_match("/(e[0-9]+)/i", $pages, $matches)) {
         // elocation-id (eg. "e12")
         XMLCustomWriter::createChildWithText($doc, $root, 'startPage', $matches[1]);
         XMLCustomWriter::createChildWithText($doc, $root, 'endPage', $matches[1]);
     }
     XMLCustomWriter::createChildWithText($doc, $root, 'doi', $article->getPubId('doi'), false);
     /* --- Article's publication date, volume, issue, DOI --- */
     XMLCustomWriter::createChildWithText($doc, $root, 'publisherRecordId', $article->getPublishedArticleId(), false);
     XMLCustomWriter::createChildWithText($doc, $root, 'documentType', $article->getLocalizedType(), false);
     /* --- Article title --- */
     foreach ((array) $article->getTitle(null) as $locale => $title) {
         if (empty($title)) {
             continue;
         }
         $titleNode =& XMLCustomWriter::createChildWithText($doc, $root, 'title', $title);
         if (strlen($locale) == 5) {
             XMLCustomWriter::setAttribute($titleNode, 'language', DOAJExportDom::mapLang(String::substr($locale, 0, 2)));
         }
     }
     /* --- Authors and affiliations --- */
     $authors =& XMLCustomWriter::createElement($doc, 'authors');
     XMLCustomWriter::appendChild($root, $authors);
     $affilList = DOAJExportDom::generateAffiliationsList($article->getAuthors());
     foreach ($article->getAuthors() as $author) {
         $authorNode =& DOAJExportDom::generateAuthorDom($doc, $root, $issue, $article, $author, $affilList);
         XMLCustomWriter::appendChild($authors, $authorNode);
         unset($authorNode);
     }
     if (!empty($affilList[0])) {
         $affils =& XMLCustomWriter::createElement($doc, 'affiliationsList');
         XMLCustomWriter::appendChild($root, $affils);
         for ($i = 0; $i < count($affilList); $i++) {
             $affilNode =& XMLCustomWriter::createChildWithText($doc, $affils, 'affiliationName', $affilList[$i]);
             XMLCustomWriter::setAttribute($affilNode, 'affiliationId', $i);
             unset($affilNode);
         }
     }
     /* --- Abstract --- */
     foreach ((array) $article->getAbstract(null) as $locale => $abstract) {
         if (empty($abstract)) {
             continue;
         }
         $abstractNode =& XMLCustomWriter::createChildWithText($doc, $root, 'abstract', $abstract);
         if (strlen($locale) == 5) {
             XMLCustomWriter::setAttribute($abstractNode, 'language', DOAJExportDom::mapLang(String::substr($locale, 0, 2)));
         }
     }
     /* --- FullText URL --- */
     $fullTextUrl =& XMLCustomWriter::createChildWithText($doc, $root, 'fullTextUrl', Request::url(null, 'article', 'view', $article->getId()));
     XMLCustomWriter::setAttribute($fullTextUrl, 'format', 'html');
     /* --- Keywords --- */
     $keywords =& XMLCustomWriter::createElement($doc, 'keywords');
     XMLCustomWriter::appendChild($root, $keywords);
     $subjects = array_map('trim', explode(';', $article->getLocalizedSubject()));
     foreach ($subjects as $keyword) {
         XMLCustomWriter::createChildWithText($doc, $keywords, 'keyword', $keyword, false);
     }
     return $root;
 }
Ejemplo n.º 17
0
 function exportIssues(&$journal, &$issues, $outputFile = null)
 {
     $this->import('PubMedExportDom');
     $doc =& PubMedExportDom::generatePubMedDom();
     $articleSetNode =& PubMedExportDom::generateArticleSetDom($doc);
     $sectionDao = DAORegistry::getDAO('SectionDAO');
     $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
     foreach ($issues as $issue) {
         foreach ($sectionDao->getByIssueId($issue->getId()) as $section) {
             foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getId(), $issue->getId()) as $article) {
                 $articleNode = PubMedExportDom::generateArticleDom($doc, $journal, $issue, $section, $article);
                 XMLCustomWriter::appendChild($articleSetNode, $articleNode);
             }
         }
     }
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'w')) === false) {
             return false;
         }
         fwrite($h, XMLCustomWriter::getXML($doc));
         fclose($h);
     } else {
         header("Content-Type: application/xml");
         header("Cache-Control: private");
         header("Content-Disposition: attachment; filename=\"pubmed.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
Ejemplo n.º 18
0
 /**
  * Generate doi_data element - this is what assigns the DOI
  * @param $doc XMLNode
  * @param $DOI string
  * @param $url string
  * @param $galleys array
  */
 function &_generateDOIdataDom(&$doc, $DOI, $url, $galleys = null)
 {
     $request = Application::getRequest();
     $journal = $request->getJournal();
     $DOIdataNode =& XMLCustomWriter::createElement($doc, 'doi_data');
     XMLCustomWriter::createChildWithText($doc, $DOIdataNode, 'doi', $DOI);
     XMLCustomWriter::createChildWithText($doc, $DOIdataNode, 'resource', $url);
     /* article galleys */
     if ($galleys) {
         $collectionNode = XMLCustomWriter::createElement($doc, 'collection');
         XMLCustomWriter::setAttribute($collectionNode, 'property', 'text-mining');
         XMLCustomWriter::appendChild($DOIdataNode, $collectionNode);
         foreach ($galleys as $galley) {
             $itemNode = XMLCustomWriter::createElement($doc, 'item');
             XMLCustomWriter::appendChild($collectionNode, $itemNode);
             $resourceNode = XMLCustomWriter::createElement($doc, 'resource');
             XMLCustomWriter::appendChild($itemNode, $resourceNode);
             XMLCustomWriter::setAttribute($resourceNode, 'mime_type', $galley->getFileType());
             $urlNode = XMLCustomWriter::createTextNode($doc, $request->url(null, 'article', 'viewFile', array($galley->getArticleId(), $galley->getBestGalleyId($journal))));
             XMLCustomWriter::appendChild($resourceNode, $urlNode);
         }
     }
     return $DOIdataNode;
 }
Ejemplo n.º 19
0
 function &exportUsers(&$journal, &$users, $allowedRoles = null)
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $doc =& XMLCustomWriter::createDocument('users', USERS_DTD_ID, USERS_DTD_URL);
     $root =& XMLCustomWriter::createElement($doc, 'users');
     foreach ($users as $user) {
         $userNode =& XMLCustomWriter::createElement($doc, 'user');
         XMLCustomWriter::createChildWithText($doc, $userNode, 'username', $user->getUserName(), false);
         $passwordNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'password', $user->getPassword());
         XMLCustomWriter::setAttribute($passwordNode, 'encrypted', Config::getVar('security', 'encryption'));
         XMLCustomWriter::createChildWithText($doc, $userNode, 'salutation', $user->getSalutation(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'first_name', $user->getFirstName());
         XMLCustomWriter::createChildWithText($doc, $userNode, 'middle_name', $user->getMiddleName(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'last_name', $user->getLastName());
         XMLCustomWriter::createChildWithText($doc, $userNode, 'initials', $user->getInitials(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'gender', $user->getGender(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'email', $user->getEmail());
         XMLCustomWriter::createChildWithText($doc, $userNode, 'url', $user->getUrl(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'phone', $user->getPhone(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'fax', $user->getFax(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'mailing_address', $user->getMailingAddress(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'country', $user->getCountry(), false);
         if (is_array($user->getAffiliation(null))) {
             foreach ($user->getAffiliation(null) as $locale => $value) {
                 $affiliationNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'affiliation', $value, false);
                 if ($affiliationNode) {
                     XMLCustomWriter::setAttribute($affiliationNode, 'locale', $locale);
                 }
                 unset($affiliationNode);
             }
         }
         if (is_array($user->getSignature(null))) {
             foreach ($user->getSignature(null) as $locale => $value) {
                 $signatureNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'signature', $value, false);
                 if ($signatureNode) {
                     XMLCustomWriter::setAttribute($signatureNode, 'locale', $locale);
                 }
                 unset($signatureNode);
             }
         }
         $interestsNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'interests', $user->getInterests(), false);
         if ($interestsNode) {
             XMLCustomWriter::setAttribute($interestsNode, 'locale', $locale);
         }
         if (is_array($user->getGossip(null))) {
             foreach ($user->getGossip(null) as $locale => $value) {
                 $gossipNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'gossip', $value, false);
                 if ($gossipNode) {
                     XMLCustomWriter::setAttribute($gossipNode, 'locale', $locale);
                 }
                 unset($gossipNode);
             }
         }
         if (is_array($user->getBiography(null))) {
             foreach ($user->getBiography(null) as $locale => $value) {
                 $biographyNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'biography', $value, false);
                 if ($biographyNode) {
                     XMLCustomWriter::setAttribute($biographyNode, 'locale', $locale);
                 }
                 unset($biographyNode);
             }
         }
         XMLCustomWriter::createChildWithText($doc, $userNode, 'locales', join(':', $user->getLocales()), false);
         $roles =& $roleDao->getRolesByUserId($user->getId(), $journal->getId());
         foreach ($roles as $role) {
             $rolePath = $role->getRolePath();
             if ($allowedRoles !== null && !in_array($rolePath, $allowedRoles)) {
                 continue;
             }
             $roleNode =& XMLCustomWriter::createElement($doc, 'role');
             XMLCustomWriter::setAttribute($roleNode, 'type', $rolePath);
             XMLCustomWriter::appendChild($userNode, $roleNode);
             unset($roleNode);
         }
         XMLCustomWriter::appendChild($root, $userNode);
     }
     XMLCustomWriter::appendChild($doc, $root);
     return $doc;
 }
Ejemplo n.º 20
0
 function exportIssues(&$journal, &$issues, $outputFile = null)
 {
     $this->import('CrossRefExportDom');
     $doc =& CrossRefExportDom::generateCrossRefDom();
     $doiBatchNode =& CrossRefExportDom::generateDoiBatchDom($doc);
     $journal =& Request::getJournal();
     // Create Head Node and all parts inside it
     $head =& CrossRefExportDom::generateHeadDom($doc, $journal);
     // attach it to the root node
     XMLCustomWriter::appendChild($doiBatchNode, $head);
     $bodyNode =& XMLCustomWriter::createElement($doc, 'body');
     XMLCustomWriter::appendChild($doiBatchNode, $bodyNode);
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     foreach ($issues as $issue) {
         foreach ($sectionDao->getSectionsForIssue($issue->getId()) as $section) {
             foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getId(), $issue->getId()) as $article) {
                 // Create the metadata node
                 // this does not need to be repeated for every article
                 // but its allowed to be and its simpler to do so
                 $journalNode =& XMLCustomWriter::createElement($doc, 'journal');
                 $journalMetadataNode =& CrossRefExportDom::generateJournalMetadataDom($doc, $journal);
                 XMLCustomWriter::appendChild($journalNode, $journalMetadataNode);
                 $journalIssueNode =& CrossRefExportDom::generateJournalIssueDom($doc, $journal, $issue, $section, $article);
                 XMLCustomWriter::appendChild($journalNode, $journalIssueNode);
                 // Article node
                 $journalArticleNode =& CrossRefExportDom::generateJournalArticleDom($doc, $journal, $issue, $section, $article);
                 XMLCustomWriter::appendChild($journalNode, $journalArticleNode);
                 // DOI data node
                 $DOIdataNode =& CrossRefExportDom::generateDOIdataDom($doc, $article->getDOI(), Request::url(null, 'article', 'view', $article->getId()));
                 XMLCustomWriter::appendChild($journalArticleNode, $DOIdataNode);
                 XMLCustomWriter::appendChild($bodyNode, $journalNode);
             }
         }
     }
     // dump out results
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'w')) === false) {
             return false;
         }
         fwrite($h, XMLCustomWriter::getXML($doc));
         fclose($h);
     } else {
         header("Content-Type: application/xml");
         header("Cache-Control: private");
         header("Content-Disposition: attachment; filename=\"crossref.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
Ejemplo n.º 21
0
 function exportIssues(&$journal, &$issues)
 {
     $this->import('MetsExportDom');
     $doc =& XMLCustomWriter::createDocument('', null);
     $root =& XMLCustomWriter::createElement($doc, 'METS:mets');
     XMLCustomWriter::setAttribute($root, 'xmlns:METS', 'http://www.loc.gov/METS/');
     XMLCustomWriter::setAttribute($root, 'xmlns:xlink', 'http://www.w3.org/TR/xlink');
     XMLCustomWriter::setAttribute($root, 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     XMLCustomWriter::setAttribute($root, 'PROFILE', 'Australian METS Profile 1.0');
     XMLCustomWriter::setAttribute($root, 'TYPE', 'journal');
     XMLCustomWriter::setAttribute($root, 'OBJID', 'J-' . $journal->getJournalId());
     XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', 'http://www.loc.gov/METS/ http://www.loc.gov/mets/mets.xsd');
     $HeaderNode =& MetsExportDom::createmetsHdr($doc);
     XMLCustomWriter::appendChild($root, $HeaderNode);
     MetsExportDom::generateJournalDmdSecDom($doc, $root, $journal);
     $fileSec =& XMLCustomWriter::createElement($doc, 'METS:fileSec');
     $fileGrpOriginal =& XMLCustomWriter::createElement($doc, 'METS:fileGrp');
     XMLCustomWriter::setAttribute($fileGrpOriginal, 'USE', 'original');
     $fileGrpDerivative =& XMLCustomWriter::createElement($doc, 'METS:fileGrp');
     XMLCustomWriter::setAttribute($fileGrpDerivative, 'USE', 'derivative');
     foreach ($issues as $issue) {
         MetsExportDom::generateIssueDmdSecDom($doc, $root, $issue, $journal);
         MetsExportDom::generateIssueFileSecDom($doc, $fileGrpOriginal, $issue);
         MetsExportDom::generateIssueHtmlGalleyFileSecDom($doc, $fileGrpDerivative, $issue);
     }
     $amdSec =& MetsExportDom::createmetsamdSec($doc, $root, $journal);
     XMLCustomWriter::appendChild($root, $amdSec);
     XMLCustomWriter::appendChild($fileSec, $fileGrpOriginal);
     XMLCustomWriter::appendChild($fileSec, $fileGrpDerivative);
     XMLCustomWriter::appendChild($root, $fileSec);
     MetsExportDom::generateStructMap($doc, $root, $journal, $issues);
     XMLCustomWriter::appendChild($doc, $root);
     header("Content-Type: application/xml");
     header("Cache-Control: private");
     header("Content-Disposition: attachment; filename=\"" . $journal->getPath() . "-mets.xml\"");
     XMLCustomWriter::printXML($doc);
     return true;
 }
Ejemplo n.º 22
0
 /**
  * Construct the sitemap
  * @return XMLNode
  */
 function _createJournalSitemap()
 {
     $issueDao = DAORegistry::getDAO('IssueDAO');
     $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
     $galleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
     $journal = Request::getJournal();
     $journalId = $journal->getId();
     $doc = XMLCustomWriter::createDocument();
     $root = XMLCustomWriter::createElement($doc, 'urlset');
     XMLCustomWriter::setAttribute($root, 'xmlns', SITEMAP_XSD_URL);
     // Journal home
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'index', 'index')));
     // About page
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'about')));
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'about', 'editorialTeam')));
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'about', 'editorialPolicies')));
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'about', 'submissions')));
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'about', 'siteMap')));
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'about', 'aboutThisPublishingSystem')));
     // Search
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'search')));
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'search', 'authors')));
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'search', 'titles')));
     // Issues
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'issue', 'current')));
     XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'issue', 'archive')));
     $publishedIssues = $issueDao->getPublishedIssues($journalId);
     while ($issue = $publishedIssues->next()) {
         XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'issue', 'view', $issue->getId())));
         // Articles for issue
         $articles = $publishedArticleDao->getPublishedArticles($issue->getId());
         foreach ($articles as $article) {
             // Abstract
             XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'article', 'view', array($article->getBestArticleId()))));
             // Galley files
             $galleys = $galleyDao->getBySubmissionId($article->getId());
             while ($galley = $galleys->next()) {
                 XMLCustomWriter::appendChild($root, $this->_createUrlTree($doc, Request::url($journal->getPath(), 'article', 'view', array($article->getBestArticleId(), $galley->getId()))));
             }
         }
     }
     XMLCustomWriter::appendChild($doc, $root);
     return $doc;
 }
 /**
  * Export a journal's content
  * @param $journal object
  * @param $outputFile string
  */
 function exportJournal(&$journal, $outputFile = null)
 {
     $this->import('DOAJExportDom');
     $doc =& XMLCustomWriter::createDocument();
     $journalNode =& DOAJExportDom::generateJournalDom($doc, $journal);
     $journalNode->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $journalNode->setAttribute('xsi:noNamespaceSchemaLocation', DOAJ_XSD_URL);
     XMLCustomWriter::appendChild($doc, $journalNode);
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'wb')) === false) {
             return false;
         }
         fwrite($h, XMLCustomWriter::getXML($doc));
         fclose($h);
     } else {
         header("Content-Type: application/xml");
         header("Cache-Control: private");
         header("Content-Disposition: attachment; filename=\"journal-" . $journal->getId() . ".xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
Ejemplo n.º 24
0
 /**
  * Datacite does not allow empty nodes. So we have to
  * check nodes before we add them.
  * @param $parentNode XmlNode|DOMElement
  * @param $child XmlNode|DOMElement
  */
 function _appendNonMandatoryChild(&$parentNode, &$child)
 {
     if (is_a($child, 'XMLNode')) {
         $childChildren = $child->getChildren();
         $childEmpty = empty($childChildren);
     } else {
         $childEmpty = !$child->hasChildNodes();
     }
     if ($childEmpty) {
         return;
     }
     XMLCustomWriter::appendChild($parentNode, $child);
 }
Ejemplo n.º 25
0
 function exportSchedConfs(&$conference, &$schedConfIdArray)
 {
     $this->import('MetsExportDom');
     $schedConfDAO =& DAORegistry::getDAO('SchedConfDAO');
     $doc =& XMLCustomWriter::createDocument();
     $root =& XMLCustomWriter::createElement($doc, 'METS:mets');
     XMLCustomWriter::setAttribute($root, 'xmlns:METS', 'http://www.loc.gov/METS/');
     XMLCustomWriter::setAttribute($root, 'xmlns:xlink', 'http://www.w3.org/TR/xlink');
     XMLCustomWriter::setAttribute($root, 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     XMLCustomWriter::setAttribute($root, 'PROFILE', 'Australian METS Profile 1.0');
     XMLCustomWriter::setAttribute($root, 'TYPE', 'conference');
     XMLCustomWriter::setAttribute($root, 'OBJID', 'C-' . $conference->getId());
     XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', 'http://www.loc.gov/METS/ http://www.loc.gov/mets/mets.xsd');
     $headerNode =& MetsExportDom::createmetsHdr($doc);
     XMLCustomWriter::appendChild($root, $headerNode);
     MetsExportDom::generateConfDmdSecDom($doc, $root, $conference);
     $fileSec =& XMLCustomWriter::createElement($doc, 'METS:fileSec');
     $fileGrp =& XMLCustomWriter::createElement($doc, 'METS:fileGrp');
     XMLCustomWriter::setAttribute($fileGrp, 'USE', 'original');
     $i = 0;
     while ($i < sizeof($schedConfIdArray)) {
         $schedConf =& $schedConfDAO->getSchedConf($schedConfIdArray[$i]);
         MetsExportDom::generateSchedConfDmdSecDom($doc, $root, $conference, $schedConf);
         MetsExportDom::generateSchedConfFileSecDom($doc, $fileGrp, $conference, $schedConf);
         $i++;
     }
     $amdSec =& MetsExportDom::createmetsamdSec($doc, $root, $conference);
     XMLCustomWriter::appendChild($root, $amdSec);
     XMLCustomWriter::appendChild($fileSec, $fileGrp);
     XMLCustomWriter::appendChild($root, $fileSec);
     MetsExportDom::generateConfstructMapWithSchedConfsIdArray($doc, $root, $conference, $schedConfIdArray);
     XMLCustomWriter::appendChild($doc, $root);
     header("Content-Type: application/xml");
     header("Cache-Control: private");
     header("Content-Disposition: attachment; filename=\"" . $conference->getPath() . "-mets.xml\"");
     XMLCustomWriter::printXML($doc);
     return true;
 }
Ejemplo n.º 26
0
 function exportPapers(&$results, $outputFile = null)
 {
     $this->import('NativeExportDom');
     $doc =& XMLCustomWriter::createDocument('papers', NATIVE_DTD_ID, NATIVE_DTD_URL);
     $papersNode =& XMLCustomWriter::createElement($doc, 'papers');
     XMLCustomWriter::appendChild($doc, $papersNode);
     foreach ($results as $result) {
         $paper =& $result['publishedPaper'];
         $track =& $result['track'];
         $conference =& $result['conference'];
         $schedConf =& $result['schedConf'];
         $paperNode =& NativeExportDom::generatePaperDom($doc, $schedConf, $track, $paper);
         XMLCustomWriter::appendChild($papersNode, $paperNode);
     }
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'w')) === false) {
             return false;
         }
         fwrite($h, XMLCustomWriter::getXML($doc));
         fclose($h);
     } else {
         header("Content-Type: application/xml");
         header("Cache-Control: private");
         header("Content-Disposition: attachment; filename=\"papers.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
 /**
  * Recursively join the document hierarchy into a single document.
  * @param $documentHierarchy
  * @return array an array of joined nodes
  */
 function &_joinNodes(&$documentHierarchy)
 {
     // Get the root node of the hierarchy.
     $root = $documentHierarchy['@branch'];
     unset($documentHierarchy['@branch']);
     // Add the sub-hierarchies to the root element.
     foreach ($documentHierarchy as $subHierarchy) {
         // Is this a leaf node?
         if (isset($subHierarchy['@leaves'])) {
             // Make sure that there's no rubbish in this node.
             assert(count($subHierarchy) == 1);
             foreach ($subHierarchy['@leaves'] as $leafNode) {
                 XMLCustomWriter::appendChild($root, $leafNode);
             }
         } else {
             // This is a branch node.
             $subNode =& $this->_joinNodes($subHierarchy);
             XMLCustomWriter::appendChild($root, $subNode);
         }
     }
     // Return the node list.
     return $root;
 }
Ejemplo n.º 28
0
 /**
  * Add the metadata XML of a single article to an
  * XML article list.
  *
  * @param $articleDoc DOMDocument
  * @param $article PublishedArticle
  * @param $journal Journal
  * @param $markToDelete boolean If true the returned XML
  *  will only contain a deletion marker.
  */
 function _addArticleXml(&$articleDoc, &$article, &$journal, $markToDelete = false)
 {
     assert(is_a($article, 'Article'));
     // Get the root node of the list.
     assert(is_a($articleDoc, 'DOMDocument'));
     $articleList =& $articleDoc->documentElement;
     // Create a new article node.
     $articleNode =& XMLCustomWriter::createElement($articleDoc, 'article');
     // Add ID information.
     XMLCustomWriter::setAttribute($articleNode, 'id', $article->getId());
     XMLCustomWriter::setAttribute($articleNode, 'sectionId', $article->getSectionId());
     XMLCustomWriter::setAttribute($articleNode, 'journalId', $article->getJournalId());
     XMLCustomWriter::setAttribute($articleNode, 'instId', $this->_instId);
     // Set the load action.
     $loadAction = $markToDelete ? 'delete' : 'replace';
     XMLCustomWriter::setAttribute($articleNode, 'loadAction', $loadAction);
     XMLCustomWriter::appendChild($articleList, $articleNode);
     // The XML for an article marked to be deleted contains no metadata.
     if ($markToDelete) {
         return;
     }
     assert(is_a($article, 'PublishedArticle'));
     // Add authors.
     $authors = $article->getAuthors();
     if (!empty($authors)) {
         $authorList =& XMLCustomWriter::createElement($articleDoc, 'authorList');
         foreach ($authors as $author) {
             /* @var $author Author */
             XMLCustomWriter::createChildWithText($articleDoc, $authorList, 'author', $author->getFullName(true));
         }
         XMLCustomWriter::appendChild($articleNode, $authorList);
     }
     // We need the request to retrieve locales and build URLs.
     $request = PKPApplication::getRequest();
     // Get all supported locales.
     $site = $request->getSite();
     $supportedLocales = $site->getSupportedLocales() + array_keys($journal->getSupportedLocaleNames());
     assert(!empty($supportedLocales));
     // Add titles.
     $titleList =& XMLCustomWriter::createElement($articleDoc, 'titleList');
     // Titles are used for sorting, we therefore need
     // them in all supported locales.
     assert(!empty($supportedLocales));
     foreach ($supportedLocales as $locale) {
         $localizedTitle = $article->getLocalizedTitle($locale);
         if (!is_null($localizedTitle)) {
             // Add the localized title.
             $titleNode =& XMLCustomWriter::createChildWithText($articleDoc, $titleList, 'title', $localizedTitle);
             XMLCustomWriter::setAttribute($titleNode, 'locale', $locale);
             // If the title does not exist in the given locale
             // then use the localized title for sorting only.
             $title = $article->getTitle($locale);
             $sortOnly = empty($title) ? 'true' : 'false';
             XMLCustomWriter::setAttribute($titleNode, 'sortOnly', $sortOnly);
         }
     }
     XMLCustomWriter::appendChild($articleNode, $titleList);
     // Add abstracts.
     $abstracts = $article->getAbstract(null);
     // return all locales
     if (!empty($abstracts)) {
         $abstractList =& XMLCustomWriter::createElement($articleDoc, 'abstractList');
         foreach ($abstracts as $locale => $abstract) {
             $abstractNode =& XMLCustomWriter::createChildWithText($articleDoc, $abstractList, 'abstract', $abstract);
             XMLCustomWriter::setAttribute($abstractNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $abstractList);
     }
     // Add discipline.
     $disciplines = $article->getDiscipline(null);
     // return all locales
     if (!empty($disciplines)) {
         $disciplineList =& XMLCustomWriter::createElement($articleDoc, 'disciplineList');
         foreach ($disciplines as $locale => $discipline) {
             $disciplineNode =& XMLCustomWriter::createChildWithText($articleDoc, $disciplineList, 'discipline', $discipline);
             XMLCustomWriter::setAttribute($disciplineNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $disciplineList);
     }
     // Add subjects and subject classes.
     $subjectClasses = $article->getSubjectClass(null);
     $subjects = $article->getSubject(null);
     if (!empty($subjectClasses) || !empty($subjects)) {
         $subjectList =& XMLCustomWriter::createElement($articleDoc, 'subjectList');
         if (!is_array($subjectClasses)) {
             $subjectClasses = array();
         }
         if (!is_array($subjects)) {
             $subjects = array();
         }
         $locales = array_unique(array_merge(array_keys($subjectClasses), array_keys($subjects)));
         foreach ($locales as $locale) {
             $subject = '';
             if (isset($subjectClasses[$locale])) {
                 $subject .= $subjectClasses[$locale];
             }
             if (isset($subjects[$locale])) {
                 if (!empty($subject)) {
                     $subject .= ' ';
                 }
                 $subject .= $subjects[$locale];
             }
             $subjectNode =& XMLCustomWriter::createChildWithText($articleDoc, $subjectList, 'subject', $subject);
             XMLCustomWriter::setAttribute($subjectNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $subjectList);
     }
     // Add type.
     $types = $article->getType(null);
     // return all locales
     if (!empty($types)) {
         $typeList =& XMLCustomWriter::createElement($articleDoc, 'typeList');
         foreach ($types as $locale => $type) {
             $typeNode =& XMLCustomWriter::createChildWithText($articleDoc, $typeList, 'type', $type);
             XMLCustomWriter::setAttribute($typeNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $typeList);
     }
     // Add coverage.
     $coverageGeo = $article->getCoverageGeo(null);
     $coverageChron = $article->getCoverageChron(null);
     $coverageSample = $article->getCoverageSample(null);
     if (!empty($coverageGeo) || !empty($coverageChron) || !empty($coverageSample)) {
         $coverageList =& XMLCustomWriter::createElement($articleDoc, 'coverageList');
         if (!is_array($coverageGeo)) {
             $coverageGeo = array();
         }
         if (!is_array($coverageChron)) {
             $coverageChron = array();
         }
         if (!is_array($coverageSample)) {
             $coverageSample = array();
         }
         $locales = array_unique(array_merge(array_keys($coverageGeo), array_keys($coverageChron), array_keys($coverageSample)));
         foreach ($locales as $locale) {
             $coverage = '';
             if (isset($coverageGeo[$locale])) {
                 $coverage .= $coverageGeo[$locale];
             }
             if (isset($coverageChron[$locale])) {
                 if (!empty($coverage)) {
                     $coverage .= '; ';
                 }
                 $coverage .= $coverageChron[$locale];
             }
             if (isset($coverageSample[$locale])) {
                 if (!empty($coverage)) {
                     $coverage .= '; ';
                 }
                 $coverage .= $coverageSample[$locale];
             }
             $coverageNode =& XMLCustomWriter::createChildWithText($articleDoc, $coverageList, 'coverage', $coverage);
             XMLCustomWriter::setAttribute($coverageNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $coverageList);
     }
     // Add journal titles.
     $journalTitleList =& XMLCustomWriter::createElement($articleDoc, 'journalTitleList');
     // Journal titles are used for sorting, we therefore need
     // them in all supported locales.
     foreach ($supportedLocales as $locale) {
         $localizedTitle = $journal->getName($locale);
         $sortOnly = false;
         if (is_null($localizedTitle)) {
             // If the title does not exist in the given locale
             // then use the localized title for sorting only.
             $journalTitle = $journal->getLocalizedName();
             $sortOnly = true;
         } else {
             $journalTitle = $localizedTitle;
         }
         $journalTitleNode =& XMLCustomWriter::createChildWithText($articleDoc, $journalTitleList, 'journalTitle', $journalTitle);
         XMLCustomWriter::setAttribute($journalTitleNode, 'locale', $locale);
         $sortOnly = $sortOnly ? 'true' : 'false';
         XMLCustomWriter::setAttribute($journalTitleNode, 'sortOnly', $sortOnly);
     }
     XMLCustomWriter::appendChild($articleNode, $journalTitleList);
     // Add publication dates.
     $publicationDate = $article->getDatePublished();
     if (!empty($publicationDate)) {
         // Transform and store article publication date.
         $publicationDate = $this->_convertDate($publicationDate);
         $dateNode =& XMLCustomWriter::createChildWithText($articleDoc, $articleNode, 'publicationDate', $publicationDate);
     }
     $issueId = $article->getIssueId();
     if (is_numeric($issueId)) {
         $issueDao = DAORegistry::getDAO('IssueDAO');
         /* @var $issueDao IssueDAO */
         $issue = $issueDao->getById($issueId);
         if (is_a($issue, 'Issue')) {
             $issuePublicationDate = $issue->getDatePublished();
             if (!empty($issuePublicationDate)) {
                 // Transform and store issue publication date.
                 $issuePublicationDate = $this->_convertDate($issuePublicationDate);
                 $dateNode =& XMLCustomWriter::createChildWithText($articleDoc, $articleNode, 'issuePublicationDate', $issuePublicationDate);
             }
         }
     }
     // We need the router to build file URLs.
     $router = $request->getRouter();
     /* @var $router PageRouter */
     // Add galley files
     $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
     $galleys = $articleGalleyDao->getBySubmissionId($article->getId());
     $galleyList = null;
     while ($galley = $galleys->next()) {
         /* @var $galley ArticleGalley */
         $locale = $galley->getLocale();
         $galleyUrl = $router->url($request, $journal->getPath(), 'article', 'download', array(intval($article->getId()), intval($galley->getId())));
         if (!empty($locale) && !empty($galleyUrl)) {
             if (is_null($galleyList)) {
                 $galleyList =& XMLCustomWriter::createElement($articleDoc, 'galleyList');
             }
             $galleyNode =& XMLCustomWriter::createElement($articleDoc, 'galley');
             XMLCustomWriter::setAttribute($galleyNode, 'locale', $locale);
             XMLCustomWriter::setAttribute($galleyNode, 'fileName', $galleyUrl);
             XMLCustomWriter::appendChild($galleyList, $galleyNode);
         }
     }
     // Wrap the galley XML as CDATA.
     if (!is_null($galleyList)) {
         if (is_callable(array($articleDoc, 'saveXml'))) {
             $galleyXml = $articleDoc->saveXml($galleyList);
         } else {
             $galleyXml = $galleyList->toXml();
         }
         $galleyOuterNode =& XMLCustomWriter::createElement($articleDoc, 'galley-xml');
         if (is_callable(array($articleDoc, 'createCDATASection'))) {
             $cdataNode = $articleDoc->createCDATASection($galleyXml);
         } else {
             $cdataNode = new XMLNode();
             $cdataNode->setValue('<![CDATA[' . $galleyXml . ']]>');
         }
         XMLCustomWriter::appendChild($galleyOuterNode, $cdataNode);
         XMLCustomWriter::appendChild($articleNode, $galleyOuterNode);
     }
 }
Ejemplo n.º 29
0
 function &generateArticleDom(&$doc, &$journal, &$issue, &$article, &$galley)
 {
     $unavailableString = Locale::translate('plugins.importexport.erudit.unavailable');
     $root =& XMLCustomWriter::createElement($doc, 'article');
     XMLCustomWriter::setAttribute($root, 'idprop', $journal->getJournalId() . '-' . $issue->getIssueId() . '-' . $article->getArticleId() . '-' . $galley->getGalleyId(), false);
     XMLCustomWriter::setAttribute($root, 'arttype', 'article');
     $lang = $article->getLanguage();
     XMLCustomWriter::setAttribute($root, 'lang', isset($lang) ? $lang : 'en');
     XMLCustomWriter::setAttribute($root, 'processing', 'cart');
     /* --- admin --- */
     $adminNode =& XMLCustomWriter::createElement($doc, 'admin');
     XMLCustomWriter::appendChild($root, $adminNode);
     /* --- articleinfo --- */
     $articleInfoNode =& XMLCustomWriter::createElement($doc, 'articleinfo');
     XMLCustomWriter::appendChild($adminNode, $articleInfoNode);
     // The first public ID should be a full URL to the article.
     $urlIdNode =& XMLCustomWriter::createChildWithText($doc, $articleInfoNode, 'idpublic', Request::url($journal->getPath(), 'article', 'view', array($article->getArticleId(), $galley->getGalleyId())));
     XMLCustomWriter::setAttribute($urlIdNode, 'scheme', 'sici');
     /* --- journal --- */
     $journalNode =& XMLCustomWriter::createElement($doc, 'journal');
     XMLCustomWriter::appendChild($adminNode, $journalNode);
     XMLCustomWriter::setAttribute($journalNode, 'id', 'ojs-' . $journal->getPath());
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'jtitle', $journal->getJournalTitle());
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'jshorttitle', $journal->getLocalizedSetting('initials'), false);
     if (!($printIssn = $journal->getSetting('printIssn'))) {
         $printIssn = $unavailableString;
     }
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'idissn', $printIssn);
     if (!($onlineIssn = $journal->getSetting('onlineIssn'))) {
         $onlineIssn = $unavailableString;
     }
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'iddigissn', $onlineIssn);
     /* --- issue --- */
     $issueNode =& XMLCustomWriter::createElement($doc, 'issue');
     XMLCustomWriter::appendChild($adminNode, $issueNode);
     XMLCustomWriter::setAttribute($issueNode, 'id', 'ojs-' . $issue->getBestIssueId());
     XMLCustomWriter::createChildWithText($doc, $issueNode, 'volume', $issue->getVolume(), false);
     XMLCustomWriter::createChildWithText($doc, $issueNode, 'issueno', $issue->getNumber(), false);
     $pubNode =& XMLCustomWriter::createElement($doc, 'pub');
     XMLCustomWriter::appendChild($issueNode, $pubNode);
     XMLCustomWriter::createChildWithText($doc, $pubNode, 'year', $issue->getYear());
     $digPubNode =& XMLCustomWriter::createElement($doc, 'digpub');
     XMLCustomWriter::appendChild($issueNode, $digPubNode);
     XMLCustomWriter::createChildWithText($doc, $digPubNode, 'date', EruditExportDom::formatDate($issue->getDatePublished()));
     /* --- Publisher & DTD --- */
     $publisherInstitution =& $journal->getSetting('publisherInstitution');
     $publisherNode =& XMLCustomWriter::createElement($doc, 'publisher');
     XMLCustomWriter::setAttribute($publisherNode, 'id', 'ojs-' . $journal->getJournalId() . '-' . $issue->getIssueId() . '-' . $article->getArticleId());
     XMLCustomWriter::appendChild($adminNode, $publisherNode);
     $publisherInstitution = $unavailableString;
     if (empty($publisherInstitution)) {
         $publisherInstitution = $unavailableString;
     }
     XMLCustomWriter::createChildWithText($doc, $publisherNode, 'orgname', $publisherInstitution);
     $digprodNode =& XMLCustomWriter::createElement($doc, 'digprod');
     XMLCustomWriter::createChildWithText($doc, $digprodNode, 'orgname', $publisherInstitution);
     XMLCustomWriter::setAttribute($digprodNode, 'id', 'ojs-prod-' . $journal->getJournalId() . '-' . $issue->getIssueId() . '-' . $article->getArticleId());
     XMLCustomWriter::appendChild($adminNode, $digprodNode);
     $digdistNode =& XMLCustomWriter::createElement($doc, 'digdist');
     XMLCustomWriter::createChildWithText($doc, $digdistNode, 'orgname', $publisherInstitution);
     XMLCustomWriter::setAttribute($digdistNode, 'id', 'ojs-dist-' . $journal->getJournalId() . '-' . $issue->getIssueId() . '-' . $article->getArticleId());
     XMLCustomWriter::appendChild($adminNode, $digdistNode);
     $dtdNode =& XMLCustomWriter::createElement($doc, 'dtd');
     XMLCustomWriter::appendChild($adminNode, $dtdNode);
     XMLCustomWriter::setAttribute($dtdNode, 'name', 'Erudit Article');
     XMLCustomWriter::setAttribute($dtdNode, 'version', '3.0.0');
     /* --- copyright --- */
     $copyright = $journal->getLocalizedSetting('copyrightNotice');
     XMLCustomWriter::createChildWithText($doc, $adminNode, 'copyright', empty($copyright) ? $unavailableString : $copyright);
     /* --- frontmatter --- */
     $frontMatterNode =& XMLCustomWriter::createElement($doc, 'frontmatter');
     XMLCustomWriter::appendChild($root, $frontMatterNode);
     $titleGroupNode =& XMLCustomWriter::createElement($doc, 'titlegr');
     XMLCustomWriter::appendChild($frontMatterNode, $titleGroupNode);
     XMLCustomWriter::createChildWithText($doc, $titleGroupNode, 'title', strip_tags($article->getArticleTitle()));
     /* --- authorgr --- */
     $authorGroupNode =& XMLCustomWriter::createElement($doc, 'authorgr');
     XMLCustomWriter::appendChild($frontMatterNode, $authorGroupNode);
     $authorNum = 1;
     foreach ($article->getAuthors() as $author) {
         $authorNode =& XMLCustomWriter::createElement($doc, 'author');
         XMLCustomWriter::appendChild($authorGroupNode, $authorNode);
         XMLCustomWriter::setAttribute($authorNode, 'id', 'ojs-' . $journal->getJournalId() . '-' . $issue->getIssueId() . '-' . $article->getArticleId() . '-' . $galley->getGalleyId() . '-' . $authorNum);
         $persNameNode =& XMLCustomWriter::createElement($doc, 'persname');
         XMLCustomWriter::appendChild($authorNode, $persNameNode);
         // Opatan Inc.
         foreach ((array) $author->getFirstName(null) as $locale => $firstName) {
             $firstName = strip_tags($firstName);
             $firstNameNode =& XMLCustomWriter::createElement($doc, 'firstname');
             XMLCustomWriter::setAttribute($firstNameNode, 'lang', $locale);
             XMLCustomWriter::appendChild($persNameNode, $firstNameNode);
             XMLCustomWriter::createChildWithText($doc, $firstNameNode, 'blocktext', $firstName);
             unset($firstNameNode);
         }
         // Opatan Inc.
         foreach ((array) $author->getMiddleName(null) as $locale => $middleName) {
             $middleName = strip_tags($middleName);
             $middleNameNode =& XMLCustomWriter::createElement($doc, 'middlename');
             XMLCustomWriter::setAttribute($middleNameNode, 'lang', $locale);
             XMLCustomWriter::appendChild($persNameNode, $middleNameNode);
             XMLCustomWriter::createChildWithText($doc, $middleNameNode, 'blocktext', $middleName);
             unset($middleNameNode);
         }
         // Opatan Inc.
         foreach ((array) $author->getLastName(null) as $locale => $lastName) {
             $lastName = strip_tags($lastName);
             $lastNameNode =& XMLCustomWriter::createElement($doc, 'familyname');
             XMLCustomWriter::setAttribute($lastNameNode, 'lang', $locale);
             XMLCustomWriter::appendChild($persNameNode, $lastNameNode);
             XMLCustomWriter::createChildWithText($doc, $lastNameNode, 'blocktext', $lastName);
             unset($lastNameNode);
         }
         // Opatan Inc.
         foreach ((array) $author->getAffiliation(null) as $locale => $affiliation) {
             $affiliation = strip_tags($affiliation);
             $affiliationNode =& XMLCustomWriter::createElement($doc, 'affiliation');
             XMLCustomWriter::setAttribute($affiliationNode, 'lang', $locale);
             XMLCustomWriter::appendChild($authorNode, $affiliationNode);
             XMLCustomWriter::createChildWithText($doc, $affiliationNode, 'blocktext', $affiliation, false);
         }
         $authorNum++;
     }
     /* --- abstract and keywords --- */
     foreach ((array) $article->getAbstract(null) as $locale => $abstract) {
         $abstract = strip_tags($abstract);
         $abstractNode =& XMLCustomWriter::createElement($doc, 'abstract');
         XMLCustomWriter::setAttribute($abstractNode, 'lang', $locale);
         XMLCustomWriter::appendChild($frontMatterNode, $abstractNode);
         XMLCustomWriter::createChildWithText($doc, $abstractNode, 'blocktext', $abstract);
         unset($abstractNode);
     }
     if ($keywords = $article->getArticleSubject()) {
         $keywordGroupNode =& XMLCustomWriter::createElement($doc, 'keywordgr');
         XMLCustomWriter::setAttribute($keywordGroupNode, 'lang', ($language = $article->getLanguage()) ? $language : 'en');
         foreach (explode(';', $keywords) as $keyword) {
             XMLCustomWriter::createChildWithText($doc, $keywordGroupNode, 'keyword', trim($keyword), false);
         }
         XMLCustomWriter::appendChild($frontMatterNode, $keywordGroupNode);
     }
     /* --- body --- */
     $bodyNode =& XMLCustomWriter::createElement($doc, 'body');
     XMLCustomWriter::appendChild($root, $bodyNode);
     import('file.ArticleFileManager');
     $articleFileManager =& new ArticleFileManager($article->getArticleId());
     $file =& $articleFileManager->getFile($galley->getFileId());
     $parser =& SearchFileParser::fromFile($file);
     if (isset($parser)) {
         if ($parser->open()) {
             // File supports text indexing.
             $textNode =& XMLCustomWriter::createElement($doc, 'text');
             XMLCustomWriter::appendChild($bodyNode, $textNode);
             while (($line = $parser->read()) !== false) {
                 $line = trim($line);
                 if ($line != '') {
                     XMLCustomWriter::createChildWithText($doc, $textNode, 'blocktext', $line, false);
                 }
             }
             $parser->close();
         }
     }
     return $root;
 }
Ejemplo n.º 30
0
 /**
  * Export the selected email templates as XML
  * @param $args array
  * @@param $request PKPRequest
  */
 function exportEmails($args, $request)
 {
     $this->validate();
     import('lib.pkp.classes.xml.XMLCustomWriter');
     $selectedEmailKeys = (array) $request->getUserVar('tplId');
     if (empty($selectedEmailKeys)) {
         $request->redirect(null, null, 'emails');
     }
     $journal = Request::getJournal();
     $doc = XMLCustomWriter::createDocument();
     $emailTexts = XMLCustomWriter::createElement($doc, 'email_texts');
     $emailTexts->setAttribute('locale', AppLocale::getLocale());
     $emailTexts->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $emailTemplateDao = DAORegistry::getDAO('EmailTemplateDAO');
     $emailTemplates = $emailTemplateDao->getEmailTemplates(AppLocale::getLocale(), $journal->getId());
     foreach ($emailTemplates as $emailTemplate) {
         $emailKey = $emailTemplate->getData('emailKey');
         if (!in_array($emailKey, $selectedEmailKeys)) {
             continue;
         }
         $subject = $emailTemplate->getData('subject');
         $body = $emailTemplate->getData('body');
         $emailTextNode = XMLCustomWriter::createElement($doc, 'email_text');
         XMLCustomWriter::setAttribute($emailTextNode, 'key', $emailKey);
         //append subject node
         $subjectNode = XMLCustomWriter::createChildWithText($doc, $emailTextNode, 'subject', $subject, false);
         XMLCustomWriter::appendChild($emailTextNode, $subjectNode);
         //append body node
         $bodyNode = XMLCustomWriter::createChildWithText($doc, $emailTextNode, 'body', $body, false);
         XMLCustomWriter::appendChild($emailTextNode, $bodyNode);
         //append email_text node
         XMLCustomWriter::appendChild($emailTexts, $emailTextNode);
     }
     XMLCustomWriter::appendChild($doc, $emailTexts);
     header("Content-Type: application/xml");
     header("Cache-Control: private");
     header("Content-Disposition: attachment; filename=\"email-templates-" . date('Y-m-d-H-i-s') . ".xml\"");
     XMLCustomWriter::printXML($doc);
 }