Example #1
0
 /**
  * Display the article metadata
  * @param $args array
  * @param $request Request
  */
 function metadata($args, &$request)
 {
     $router =& $request->getRouter();
     $this->setupTemplate($request);
     $articleId = isset($args[0]) ? $args[0] : 0;
     $galleyId = isset($args[1]) ? (int) $args[1] : 0;
     $this->validate($request, $articleId, $galleyId);
     $journal =& $router->getContext($request);
     $issue =& $this->issue;
     $article =& $this->article;
     $rtDao =& DAORegistry::getDAO('RTDAO');
     $journalRt =& $rtDao->getJournalRTByJournal($journal);
     if (!$journalRt || !$journalRt->getViewMetadata()) {
         $request->redirect(null, $router->getRequestedPage($request));
     }
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     $section =& $sectionDao->getSection($article->getSectionId(), $journal->getId(), true);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('articleId', $articleId);
     $templateMgr->assign('galleyId', $galleyId);
     $templateMgr->assign_by_ref('journalRt', $journalRt);
     $templateMgr->assign_by_ref('article', $article);
     $templateMgr->assign_by_ref('issue', $issue);
     $templateMgr->assign_by_ref('section', $section);
     $templateMgr->assign_by_ref('journalSettings', $journal->getSettings());
     // consider public identifiers
     $pubIdPlugins =& PluginRegistry::loadCategory('pubIds', true);
     $templateMgr->assign('pubIdPlugins', $pubIdPlugins);
     $templateMgr->assign('ccLicenseBadge', Application::getCCLicenseBadge($article->getLicenseURL()));
     $templateMgr->display('rt/metadata.tpl');
 }
 /**
  * @see OAIMetadataFormat#toXml
  * TODO:
  *  <copyright-holder>
  *  In Isabelle's mapping document:
  *   Article order in the issue's Table of Contents
  */
 function toXml(&$record, $format = null)
 {
     $article =& $record->getData('article');
     $journal =& $record->getData('journal');
     $section =& $record->getData('section');
     $issue =& $record->getData('issue');
     $galleys =& $record->getData('galleys');
     $articleId = $article->getId();
     // Cache issue ordering information.
     static $issueId;
     static $sectionSeq;
     if (!isset($issueId) || $issueId != $issue->getId()) {
         $sectionDao = DAORegistry::getDAO('SectionDAO');
         $issueId = $issue->getId();
         $sections = $sectionDao->getByIssueId($issueId);
         $sectionSeq = array();
         $i = 0;
         foreach ($sections as $thisSection) {
             $sectionSeq[$thisSection->getId()] = $i++;
         }
         unset($sections);
     }
     $abbreviation = $journal->getLocalizedSetting('abbreviation');
     $printIssn = $journal->getSetting('printIssn');
     $onlineIssn = $journal->getSetting('onlineIssn');
     $primaryLocale = $article->getLanguage() != '' ? $article->getLanguage() : $journal->getPrimaryLocale();
     $publisherInstitution = $journal->getSetting('publisherInstitution');
     $datePublished = $article->getDatePublished();
     if (!$datePublished) {
         $datePublished = $issue->getDatePublished();
     }
     if ($datePublished) {
         $datePublished = strtotime($datePublished);
     }
     $response = "<article\n" . "\txmlns=\"http://dtd.nlm.nih.gov/publishing/2.3\"\n" . "\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" . "\txmlns:mml=\"http://www.w3.org/1998/Math/MathML\"\n" . "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" . "\txsi:schemaLocation=\"http://dtd.nlm.nih.gov/publishing/2.3\n" . "\thttp://dtd.nlm.nih.gov/publishing/2.3/xsd/journalpublishing.xsd\"\n" . (($s = $section->getLocalizedIdentifyType()) != '' ? "\tarticle-type=\"" . htmlspecialchars(Core::cleanVar($s)) . "\"" : '') . "\txml:lang=\"" . strtoupper(substr($primaryLocale, 0, 2)) . "\">\n" . "\t<front>\n" . "\t\t<journal-meta>\n" . "\t\t\t<journal-id journal-id-type=\"other\">" . htmlspecialchars(Core::cleanVar(($s = Config::getVar('oai', 'nlm_journal_id')) != '' ? $s : $journal->getPath())) . "</journal-id>\n" . "\t\t\t<journal-title>" . htmlspecialchars(Core::cleanVar($journal->getLocalizedName())) . "</journal-title>\n";
     // Include translated journal titles
     foreach ($journal->getName(null) as $locale => $title) {
         if ($locale == $primaryLocale) {
             continue;
         }
         $response .= "\t\t\t<trans-title xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">" . htmlspecialchars(Core::cleanVar($title)) . "</trans-title>\n";
     }
     $response .= (!empty($onlineIssn) ? "\t\t\t<issn pub-type=\"epub\">" . htmlspecialchars(Core::cleanVar($onlineIssn)) . "</issn>" : '') . (!empty($printIssn) ? "\t\t\t<issn pub-type=\"ppub\">" . htmlspecialchars(Core::cleanVar($printIssn)) . "</issn>" : '') . ($publisherInstitution != '' ? "\t\t\t<publisher><publisher-name>" . htmlspecialchars(Core::cleanVar($publisherInstitution)) . "</publisher-name></publisher>\n" : '') . "\t\t</journal-meta>\n" . "\t\t<article-meta>\n" . "\t\t\t<article-id pub-id-type=\"other\">" . htmlspecialchars(Core::cleanVar($article->getBestArticleId())) . "</article-id>\n" . (($s = $article->getPubId('doi')) ? "\t\t\t<article-id pub-id-type=\"doi\">" . htmlspecialchars(Core::cleanVar($s)) . "</article-id>\n" : '') . "\t\t\t<article-categories><subj-group subj-group-type=\"heading\"><subject>" . htmlspecialchars(Core::cleanVar($section->getLocalizedTitle())) . "</subject></subj-group></article-categories>\n" . "\t\t\t<title-group>\n" . "\t\t\t\t<article-title>" . htmlspecialchars(Core::cleanVar(strip_tags($article->getLocalizedTitle()))) . "</article-title>\n";
     // Include translated journal titles
     foreach ($article->getTitle(null) as $locale => $title) {
         if ($locale == $primaryLocale) {
             continue;
         }
         $response .= "\t\t\t\t<trans-title xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">" . htmlspecialchars(Core::cleanVar(strip_tags($title))) . "</trans-title>\n";
     }
     $response .= "\t\t\t</title-group>\n" . "\t\t\t<contrib-group>\n";
     // Include authors
     foreach ($article->getAuthors() as $author) {
         $response .= "\t\t\t\t<contrib " . ($author->getPrimaryContact() ? 'corresp="yes" ' : '') . "contrib-type=\"author\">\n" . "\t\t\t\t\t<name name-style=\"western\">\n" . "\t\t\t\t\t\t<surname>" . htmlspecialchars(Core::cleanVar($author->getLastName())) . "</surname>\n" . "\t\t\t\t\t\t<given-names>" . htmlspecialchars(Core::cleanVar($author->getFirstName()) . (($s = $author->getMiddleName()) != '' ? " {$s}" : '')) . "</given-names>\n" . "\t\t\t\t\t</name>\n" . (($s = $author->getLocalizedAffiliation()) != '' ? "\t\t\t\t\t<aff>" . htmlspecialchars(Core::cleanVar($s)) . "</aff>\n" : '') . "\t\t\t\t\t<email>" . htmlspecialchars(Core::cleanVar($author->getEmail())) . "</email>\n" . (($s = $author->getUrl()) != '' ? "\t\t\t\t\t<uri>" . htmlspecialchars(Core::cleanVar($s)) . "</uri>\n" : '') . "\t\t\t\t</contrib>\n";
     }
     // Include editorships (optimized)
     $response .= $this->getEditorialInfo($journal->getId());
     $response .= "\t\t\t</contrib-group>\n";
     if ($datePublished) {
         $response .= "\t\t\t<pub-date pub-type=\"epub\">\n" . "\t\t\t\t<day>" . strftime('%d', $datePublished) . "</day>\n" . "\t\t\t\t<month>" . strftime('%m', $datePublished) . "</month>\n" . "\t\t\t\t<year>" . strftime('%Y', $datePublished) . "</year>\n" . "\t\t\t</pub-date>\n";
     }
     $response .= ($issue->getShowYear() ? "\t\t\t<pub-date pub-type=\"collection\"><year>" . htmlspecialchars(Core::cleanVar($issue->getYear())) . "</year></pub-date>\n" : '') . ($issue->getShowVolume() ? "\t\t\t<volume>" . htmlspecialchars(Core::cleanVar($issue->getVolume())) . "</volume>\n" : '') . ($issue->getShowNumber() ? "\t\t\t<issue seq=\"" . htmlspecialchars(Core::cleanVar($sectionSeq[$section->getId()] * 100 + $article->getSequence())) . "\">" . htmlspecialchars(Core::cleanVar($issue->getNumber())) . "</issue>\n" : '') . "\t\t\t<issue-id pub-id-type=\"other\">" . htmlspecialchars(Core::cleanVar($issue->getBestIssueId())) . "</issue-id>\n" . ($issue->getShowTitle() ? "\t\t\t<issue-title>" . htmlspecialchars(Core::cleanVar($issue->getLocalizedTitle())) . "</issue-title>\n" : '');
     // Include page info, if available and parseable.
     $matches = null;
     if (PKPString::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)$/', $article->getPages(), $matches)) {
         $matchedPage = htmlspecialchars(Core::cleanVar($matches[1]));
         $response .= "\t\t\t\t<fpage>{$matchedPage}</fpage><lpage>{$matchedPage}</lpage>\n";
         $pageCount = 1;
     } elseif (PKPString::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)[ ]?(-|–)[ ]?([Pp][Pp]?[.]?[ ]?)?(\\d+)$/', $article->getPages(), $matches)) {
         $matchedPageFrom = htmlspecialchars(Core::cleanVar($matches[1]));
         $matchedPageTo = htmlspecialchars(Core::cleanVar($matches[4]));
         $response .= "\t\t\t\t<fpage>{$matchedPageFrom}</fpage>\n" . "\t\t\t\t<lpage>{$matchedPageTo}</lpage>\n";
         $pageCount = $matchedPageTo - $matchedPageFrom + 1;
     }
     $response .= "\t\t\t<permissions>\n" . "\t\t\t\t<copyright-statement>" . htmlspecialchars(__('submission.copyrightStatement', array('copyrightYear' => $article->getCopyrightYear(), 'copyrightHolder' => $article->getLocalizedCopyrightHolder()))) . "</copyright-statement>\n" . ($datePublished ? "\t\t\t\t<copyright-year>" . $article->getCopyrightYear() . "</copyright-year>\n" : '') . "\t\t\t\t<license xlink:href=\"" . $article->getLicenseURL() . "\">\n" . (($s = Application::getCCLicenseBadge($article->getLicenseURL())) ? "\t\t\t\t\t<license-p>" . strip_tags($s) . "</license-p>\n" : '') . "\t\t\t\t</license>\n" . "\t\t\t</permissions>\n" . "\t\t\t<self-uri xlink:href=\"" . htmlspecialchars(Core::cleanVar(Request::url($journal->getPath(), 'article', 'view', $article->getBestArticleId()))) . "\" />\n";
     // Include galley links
     foreach ($article->getGalleys() as $galley) {
         $response .= "\t\t\t<self-uri content-type=\"" . htmlspecialchars(Core::cleanVar($galley->getFileType())) . "\" xlink:href=\"" . htmlspecialchars(Core::cleanVar(Request::url($journal->getPath(), 'article', 'view', array($article->getBestArticleId(), $galley->getId())))) . "\" />\n";
     }
     // Include abstract(s)
     $abstract = htmlspecialchars(Core::cleanVar(strip_tags($article->getLocalizedAbstract())));
     if (!empty($abstract)) {
         $abstract = "<p>{$abstract}</p>";
         // $abstract = '<p>' . PKPString::regexp_replace('/\n+/', '</p><p>', $abstract) . '</p>';
         $response .= "\t\t\t<abstract xml:lang=\"" . strtoupper(substr($primaryLocale, 0, 2)) . "\">{$abstract}</abstract>\n";
     }
     if (is_array($article->getAbstract(null))) {
         foreach ($article->getAbstract(null) as $locale => $abstract) {
             if ($locale == $primaryLocale || empty($abstract)) {
                 continue;
             }
             $abstract = htmlspecialchars(Core::cleanVar(strip_tags($abstract)));
             if (empty($abstract)) {
                 continue;
             }
             $abstract = "<p>{$abstract}</p>";
             //$abstract = '<p>' . PKPString::regexp_replace('/\n+/', '</p><p>', $abstract) . '</p>';
             $response .= "\t\t\t<abstract-trans xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">{$abstract}</abstract-trans>\n";
         }
     }
     $subjects = array();
     if (is_array($article->getSubject(null))) {
         foreach ($article->getSubject(null) as $locale => $subject) {
             $s = array_map('trim', explode(';', Core::cleanVar($subject)));
             if (!empty($s)) {
                 $subjects[$locale] = $s;
             }
         }
     }
     if (!empty($subjects)) {
         foreach ($subjects as $locale => $s) {
             $response .= "\t\t\t<kwd-group xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">\n";
             foreach ($s as $subject) {
                 $response .= "\t\t\t\t<kwd>" . htmlspecialchars($subject) . "</kwd>\n";
             }
             $response .= "\t\t\t</kwd-group>\n";
         }
     }
     $response .= (isset($pageCount) ? "\t\t\t<counts><page-count count=\"" . (int) $pageCount . "\" /></counts>\n" : '') . "\t\t</article-meta>\n" . "\t</front>\n";
     // Include body text (for search indexing only)
     import('classes.search.ArticleSearchIndex');
     $text = '';
     $galleys = $article->getGalleys();
     // Give precedence to HTML galleys, as they're quickest to parse
     usort($galleys, create_function('$a, $b', 'return $a->getFileType()==\'text/html\')?-1:1;'));
     // Determine any access limitations. If there are, do not
     // provide the full-text.
     import('classes.issue.IssueAction');
     $issueAction = new IssueAction();
     $subscriptionRequired = $issueAction->subscriptionRequired($issue);
     $isSubscribedDomain = $issueAction->subscribedDomain($journal, $issue->getId(), $article->getId());
     if (!$subscriptionRequired || $isSubscribedDomain) {
         foreach ($galleys as $galley) {
             $parser =& SearchFileParser::fromFile($galley);
             if ($parser && $parser->open()) {
                 while (($s = $parser->read()) !== false) {
                     $text .= $s;
                 }
                 $parser->close();
             }
             if ($galley->getFileType() == 'text/html') {
                 $text = strip_tags($text);
             }
             unset($galley);
             // Use the first parseable galley.
             if (!empty($text)) {
                 break;
             }
         }
     }
     if (!empty($text)) {
         $response .= "\t<body><p>" . htmlspecialchars(Core::cleanVar(Core::cleanVar($text))) . "</p></body>\n";
     }
     // Add NLM citation info
     $filterDao = DAORegistry::getDAO('FilterDAO');
     /* @var $filterDao FilterDAO */
     $nlmFilters = $filterDao->getObjectsByGroup('submission=>nlm23-article-xml');
     assert(count($nlmFilters) == 1);
     $nlmFilter = array_pop($nlmFilters);
     $nlmXmlDom = new DOMDocument();
     $nlmXmlDom->loadXML($nlmFilter->execute($article));
     $documentElement =& $nlmXmlDom->documentElement;
     // Work-around for hasChildNodes being stupid about whitespace.
     $hasChildren = false;
     if (isset($documentElement->childNodes)) {
         foreach ($documentElement->childNodes as $c) {
             if ($c->nodeType == XML_ELEMENT_NODE) {
                 $hasChildren = true;
             }
         }
     }
     // If there were any citations, include them.
     if ($hasChildren) {
         $innerXml = $nlmXmlDom->saveXML($documentElement);
         $response .= "<back>{$innerXml}</back>\n";
     }
     $response .= "</article>";
     return $response;
 }
Example #3
0
 /**
  * View Article. (Either article landing page or galley view.)
  * @param $args array
  * @param $request Request
  */
 function view($args, $request)
 {
     $articleId = array_shift($args);
     $galleyId = array_shift($args);
     $fileId = array_shift($args);
     $journal = $request->getJournal();
     $issue = $this->issue;
     $article = $this->article;
     $templateMgr = TemplateManager::getManager($request);
     $templateMgr->assign(array('issue' => $issue, 'article' => $article, 'fileId' => $fileId));
     $this->setupTemplate($request);
     if (!$this->userCanViewGalley($request, $articleId, $galleyId)) {
         fatalError('Cannot view galley.');
     }
     // Fetch and assign the section to the template
     $sectionDao = DAORegistry::getDAO('SectionDAO');
     $section = $sectionDao->getById($article->getSectionId(), $journal->getId(), true);
     $templateMgr->assign('section', $section);
     // Fetch and assign the galley to the template
     $galleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
     if ($journal->getSetting('enablePublicGalleyId')) {
         $galley = $galleyDao->getByBestGalleyId($galleyId, $article->getId());
     } else {
         $galley = $galleyDao->getById($galleyId, $article->getId());
     }
     if ($galley && $galley->getRemoteURL()) {
         $request->redirectUrl($galley->getRemoteURL());
     }
     $templateMgr->assign('galley', $galley);
     // Copyright and license info
     if ($journal->getSetting('includeCopyrightStatement') && $journal->getLocalizedSetting('copyrightNotice')) {
         $templateMgr->assign(array('copyright' => $journal->getLocalizedSetting('copyrightNotice'), 'copyrightHolder' => $journal->getLocalizedSetting('copyrightHolder'), 'copyrightYear' => $journal->getSetting('copyrightYear')));
     }
     if ($journal->getSetting('includeLicense') && $article->getLicenseURL()) {
         $templateMgr->assign(array('licenseUrl' => $article->getLicenseURL(), 'ccLicenseBadge' => Application::getCCLicenseBadge($article->getLicenseURL())));
     }
     // Keywords
     $submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO');
     $templateMgr->assign('keywords', $submissionKeywordDao->getKeywords($article->getId(), array(AppLocale::getLocale())));
     // Consider public identifiers
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
     $templateMgr->assign('pubIdPlugins', $pubIdPlugins);
     if (!$galley) {
         // No galley: Prepare the article landing page.
         // Get the subscription status if displaying the abstract;
         // if access is open, we can display links to the full text.
         import('classes.issue.IssueAction');
         // The issue may not exist, if this is an editorial user
         // and scheduling hasn't been completed yet for the article.
         $issueAction = new IssueAction();
         $subscriptionRequired = false;
         if ($issue) {
             $subscriptionRequired = $issueAction->subscriptionRequired($issue);
         }
         $subscribedUser = $issueAction->subscribedUser($journal, isset($issue) ? $issue->getId() : null, isset($article) ? $article->getId() : null);
         $subscribedDomain = $issueAction->subscribedDomain($journal, isset($issue) ? $issue->getId() : null, isset($article) ? $article->getId() : null);
         $templateMgr->assign('showGalleyLinks', !$subscriptionRequired || $journal->getSetting('showGalleyLinks'));
         $templateMgr->assign('hasAccess', !$subscriptionRequired || isset($article) && $article->getAccessStatus() == ARTICLE_ACCESS_OPEN || $subscribedUser || $subscribedDomain);
         import('classes.payment.ojs.OJSPaymentManager');
         $paymentManager = new OJSPaymentManager($request);
         if ($paymentManager->onlyPdfEnabled()) {
             $templateMgr->assign('restrictOnlyPdf', true);
         }
         if ($paymentManager->purchaseArticleEnabled()) {
             $templateMgr->assign('purchaseArticleEnabled', true);
         }
         // Article cover page.
         if (isset($article) && $article->getLocalizedFileName() && $article->getLocalizedShowCoverPage() && !$article->getLocalizedHideCoverPageAbstract()) {
             import('classes.file.PublicFileManager');
             $publicFileManager = new PublicFileManager();
             $templateMgr->assign(array('coverPagePath' => $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId()) . '/', 'coverPageFileName' => $article->getLocalizedFileName(), 'width' => $article->getLocalizedWidth(), 'height' => $article->getLocalizedHeight(), 'coverPageAltText' => $article->getLocalizedCoverPageAltText()));
         }
         if (!HookRegistry::call('ArticleHandler::view', array(&$request, &$issue, &$article))) {
             return $templateMgr->display('frontend/pages/article.tpl');
         }
     } else {
         // Galley: Prepare the galley file download.
         if (!HookRegistry::call('ArticleHandler::view::galley', array(&$request, &$issue, &$galley, &$article))) {
             $request->redirect(null, null, 'download', array($articleId, $galleyId));
         }
     }
 }
Example #4
0
 /**
  * View Article.
  * @param $args array
  * @param $request Request
  */
 function view($args, $request)
 {
     $articleId = isset($args[0]) ? $args[0] : 0;
     $galleyId = isset($args[1]) ? $args[1] : 0;
     $fileId = isset($args[2]) ? $args[2] : 0;
     if ($this->userCanViewGalley($request, $articleId, $galleyId)) {
         $journal = $this->journal;
         $issue = $this->issue;
         $article = $this->article;
         $this->setupTemplate($request);
         $sectionDao = DAORegistry::getDAO('SectionDAO');
         $section = $sectionDao->getById($article->getSectionId(), $journal->getId(), true);
         $galleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
         if ($journal->getSetting('enablePublicGalleyId')) {
             $galley = $galleyDao->getByBestGalleyId($galleyId, $article->getId());
         }
         if (!isset($galley)) {
             $galley = $galleyDao->getById($galleyId, $article->getId());
         }
         if (isset($galley)) {
             if ($galley->getRemoteURL()) {
                 $request->redirectUrl($galley->getRemoteURL());
             }
         }
         $templateMgr = TemplateManager::getManager($request);
         $templateMgr->addJavaScript('js/relatedItems.js');
         if (!$galley) {
             // Get the subscription status if displaying the abstract;
             // if access is open, we can display links to the full text.
             import('classes.issue.IssueAction');
             // The issue may not exist, if this is an editorial user
             // and scheduling hasn't been completed yet for the article.
             $issueAction = new IssueAction();
             if ($issue) {
                 $templateMgr->assign('subscriptionRequired', $issueAction->subscriptionRequired($issue));
             }
             $templateMgr->assign('subscribedUser', $issueAction->subscribedUser($journal, isset($issue) ? $issue->getId() : null, isset($article) ? $article->getId() : null));
             $templateMgr->assign('subscribedDomain', $issueAction->subscribedDomain($journal, isset($issue) ? $issue->getId() : null, isset($article) ? $article->getId() : null));
             $templateMgr->assign('showGalleyLinks', $journal->getSetting('showGalleyLinks'));
             import('classes.payment.ojs.OJSPaymentManager');
             $paymentManager = new OJSPaymentManager($request);
             if ($paymentManager->onlyPdfEnabled()) {
                 $templateMgr->assign('restrictOnlyPdf', true);
             }
             if ($paymentManager->purchaseArticleEnabled()) {
                 $templateMgr->assign('purchaseArticleEnabled', true);
             }
             // Article cover page.
             if (isset($article) && $article->getLocalizedFileName() && $article->getLocalizedShowCoverPage() && !$article->getLocalizedHideCoverPageAbstract()) {
                 import('classes.file.PublicFileManager');
                 $publicFileManager = new PublicFileManager();
                 $coverPagePath = $request->getBaseUrl() . '/';
                 $coverPagePath .= $publicFileManager->getJournalFilesPath($journal->getId()) . '/';
                 $templateMgr->assign('coverPagePath', $coverPagePath);
                 $templateMgr->assign('coverPageFileName', $article->getLocalizedFileName());
                 $templateMgr->assign('width', $article->getLocalizedWidth());
                 $templateMgr->assign('height', $article->getLocalizedHeight());
                 $templateMgr->assign('coverPageAltText', $article->getLocalizedCoverPageAltText());
             }
             // References list.
             // FIXME: We only display the edited raw citations right now. We also want
             // to allow for generated citations to be displayed here (including a way for
             // the reader to choose any of the installed citation styles for output), see #5938.
             $citationDao = DAORegistry::getDAO('CitationDAO');
             /* @var $citationDao CitationDAO */
             $citationFactory = $citationDao->getObjectsByAssocId(ASSOC_TYPE_ARTICLE, $article->getId());
             $templateMgr->assign('citationFactory', $citationFactory);
         }
         $templateMgr->assign('issue', $issue);
         $templateMgr->assign('article', $article);
         $templateMgr->assign('galley', $galley);
         $templateMgr->assign('section', $section);
         $templateMgr->assign('journal', $journal);
         $templateMgr->assign('articleId', $articleId);
         $templateMgr->assign('galleyId', $galleyId);
         $templateMgr->assign('fileId', $fileId);
         $templateMgr->assign('defineTermsContextId', isset($defineTermsContextId) ? $defineTermsContextId : null);
         $templateMgr->assign('ccLicenseBadge', Application::getCCLicenseBadge($article->getLicenseURL()));
         $templateMgr->assign('articleSearchByOptions', array('query' => 'search.allFields', 'authors' => 'search.author', 'title' => 'article.title', 'abstract' => 'search.abstract', 'indexTerms' => 'search.indexTerms', 'galleyFullText' => 'search.fullText'));
         // consider public identifiers
         $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
         $templateMgr->assign('pubIdPlugins', $pubIdPlugins);
         // load Article galley plugins
         PluginRegistry::loadCategory('viewableFiles', true);
         $templateMgr->display('article/article.tpl');
     }
 }
 /**
  * @see DOIExportDom::generate()
  */
 function &generate(&$object)
 {
     $falseVar = false;
     // Declare variables that will contain publication objects.
     $journal =& $this->getJournal();
     $issue = null;
     /* @var $issue Issue */
     $article = null;
     /* @var $article PublishedArticle */
     $galley = null;
     /* @var $galley ArticleGalley */
     $suppFile = null;
     /* @var $suppFile SuppFile */
     $articlesByIssue = null;
     $galleysByArticle = null;
     $suppFilesByArticle = null;
     // Retrieve required publication objects (depends on the object to be exported).
     $pubObjects =& $this->retrievePublicationObjects($object);
     extract($pubObjects);
     // Identify an object implementing an ArticleFile (if any).
     $articleFile = empty($suppFile) ? $galley : $suppFile;
     // Identify the object locale.
     $objectLocalePrecedence = $this->getObjectLocalePrecedence($article, $galley, $suppFile);
     // The publisher is required.
     $publisher = is_a($object, 'SuppFile') ? $object->getSuppFilePublisher() : null;
     if (empty($publisher)) {
         $publisher = $this->getPublisher($objectLocalePrecedence);
     }
     // The publication date is required.
     $publicationDate = is_a($article, 'PublishedArticle') ? $article->getDatePublished() : null;
     if (empty($publicationDate)) {
         $publicationDate = $issue->getDatePublished();
     }
     assert(!empty($publicationDate));
     // Create the XML document and its root element.
     $doc =& $this->getDoc();
     $rootElement =& $this->rootElement();
     XMLCustomWriter::appendChild($doc, $rootElement);
     // DOI (mandatory)
     if (($identifierElement =& $this->_identifierElement($object)) === false) {
         return false;
     }
     XMLCustomWriter::appendChild($rootElement, $identifierElement);
     // Creators (mandatory)
     XMLCustomWriter::appendChild($rootElement, $this->_creatorsElement($object, $objectLocalePrecedence, $publisher));
     // Title (mandatory)
     XMLCustomWriter::appendChild($rootElement, $this->_titlesElement($object, $objectLocalePrecedence));
     // Publisher (mandatory)
     XMLCustomWriter::createChildWithText($this->getDoc(), $rootElement, 'publisher', $publisher);
     // Publication Year (mandatory)
     XMLCustomWriter::createChildWithText($this->getDoc(), $rootElement, 'publicationYear', date('Y', strtotime($publicationDate)));
     // Subjects
     if (!empty($suppFile)) {
         $this->_appendNonMandatoryChild($rootElement, $this->_subjectsElement($suppFile, $objectLocalePrecedence));
     } elseif (!empty($article)) {
         $this->_appendNonMandatoryChild($rootElement, $this->_subjectsElement($article, $objectLocalePrecedence));
     }
     // Dates
     XMLCustomWriter::appendChild($rootElement, $this->_datesElement($issue, $article, $articleFile, $suppFile, $publicationDate));
     // Language
     XMLCustomWriter::createChildWithText($this->getDoc(), $rootElement, 'language', AppLocale::getIso1FromLocale($objectLocalePrecedence[0]));
     // Resource Type
     if (!is_a($object, 'SuppFile')) {
         $resourceTypeElement =& $this->_resourceTypeElement($object);
         XMLCustomWriter::appendChild($rootElement, $resourceTypeElement);
     }
     // Alternate Identifiers
     $this->_appendNonMandatoryChild($rootElement, $this->_alternateIdentifiersElement($object, $issue, $article, $articleFile));
     // Related Identifiers
     $this->_appendNonMandatoryChild($rootElement, $this->_relatedIdentifiersElement($object, $articlesByIssue, $galleysByArticle, $suppFilesByArticle, $issue, $article));
     // Sizes
     $sizesElement =& $this->_sizesElement($object, $article);
     if ($sizesElement) {
         XMLCustomWriter::appendChild($rootElement, $sizesElement);
     }
     // Formats
     if (!empty($articleFile)) {
         XMLCustomWriter::appendChild($rootElement, $this->_formatsElement($articleFile));
     }
     // Rights
     $rightsURL = $article ? $article->getLicenseURL() : $journal->getSetting('licenseURL');
     $rightsListElement =& XMLCustomWriter::createElement($this->getDoc(), 'rightsList');
     $rightsElement = $this->createElementWithText('rights', strip_tags(Application::getCCLicenseBadge($rightsURL)), array('rightsURI' => $rightsURL));
     XMLCustomWriter::appendChild($rightsListElement, $rightsElement);
     XMLCustomWriter::appendChild($rootElement, $rightsListElement);
     // Descriptions
     $descriptionsElement =& $this->_descriptionsElement($issue, $article, $suppFile, $objectLocalePrecedence, $articlesByIssue);
     if ($descriptionsElement) {
         XMLCustomWriter::appendChild($rootElement, $descriptionsElement);
     }
     return $doc;
 }
Example #6
0
 /**
  * @see Filter::process()
  * @param $pubObject Issue|PublishedArticle|ArticleGalley
  * @return DOMDocument
  */
 function &process(&$pubObject)
 {
     // Create the XML document
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->preserveWhiteSpace = false;
     $doc->formatOutput = true;
     $deployment = $this->getDeployment();
     $context = $deployment->getContext();
     $plugin = $deployment->getPlugin();
     $cache = $plugin->getCache();
     // Get all objects
     $issue = $article = $galley = $galleyFile = null;
     if (is_a($pubObject, 'Issue')) {
         $issue = $pubObject;
         if (!$cache->isCached('issues', $issue->getId())) {
             $cache->add($issue, null);
         }
     } elseif (is_a($pubObject, 'PublishedArticle')) {
         $article = $pubObject;
         if (!$cache->isCached('articles', $article->getId())) {
             $cache->add($article, null);
         }
     } elseif (is_a($pubObject, 'ArticleGalley')) {
         $galley = $pubObject;
         $galleyFile = $galley->getFile();
         $articleId = $galley->getSubmissionId();
         if ($cache->isCached('articles', $articleId)) {
             $article = $cache->get('articles', $articleId);
         } else {
             $articleDao = DAORegistry::getDAO('PublishedArticleDAO');
             /* @var $articleDao PublishedArticleDAO */
             $article = $articleDao->getPublishedArticleByArticleId($pubObject->getSubmissionId(), $context->getId());
             if ($article) {
                 $cache->add($article, null);
             }
         }
     }
     if (!$issue) {
         $issueId = $article->getIssueId();
         if ($cache->isCached('issues', $issueId)) {
             $issue = $cache->get('issues', $issueId);
         } else {
             $issueDao = DAORegistry::getDAO('IssueDAO');
             /* @var $issueDao IssueDAO */
             $issue = $issueDao->getById($issueId, $context->getId());
             if ($issue) {
                 $cache->add($issue, null);
             }
         }
     }
     // The publisher is required.
     // Use the journal title as DataCite recommends for now.
     $publisher = $this->getPrimaryTranslation($context->getName(null), $objectLocalePrecedence);
     assert(!empty($publisher));
     // The publication date is required.
     $publicationDate = isset($article) ? $article->getDatePublished() : null;
     if (empty($publicationDate)) {
         $publicationDate = $issue->getDatePublished();
     }
     assert(!empty($publicationDate));
     // Create the root node
     $rootNode = $this->createRootNode($doc);
     $doc->appendChild($rootNode);
     // Identify the object locale.
     $objectLocalePrecedence = $this->getObjectLocalePrecedence($context, $article, $galley);
     // DOI (mandatory)
     $doi = $pubObject->getStoredPubId('doi');
     if ($plugin->isTestMode($context)) {
         $doi = PKPString::regexp_replace('#^[^/]+/#', DATACITE_API_TESTPREFIX . '/', $doi);
     }
     $rootNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'identifier', htmlspecialchars($doi, ENT_COMPAT, 'UTF-8')));
     $node->setAttribute('identifierType', DATACITE_IDTYPE_DOI);
     // Creators (mandatory)
     $rootNode->appendChild($this->createCreatorsNode($doc, $issue, $article, $galley, $galleyFile, $publisher, $objectLocalePrecedence));
     // Title (mandatory)
     $rootNode->appendChild($this->createTitlesNode($doc, $issue, $article, $galley, $galleyFile, $objectLocalePrecedence));
     // Publisher (mandatory)
     $rootNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'publisher', htmlspecialchars($publisher, ENT_COMPAT, 'UTF-8')));
     // Publication Year (mandatory)
     $rootNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'publicationYear', date('Y', strtotime($publicationDate))));
     // Subjects
     $subject = null;
     if (!empty($galleyFile) && is_a($galleyFile, 'SupplementaryFile')) {
         $subject = $this->getPrimaryTranslation($galleyFile->getSubject(null), $objectLocalePrecedence);
     } elseif (!empty($article)) {
         $subject = $this->getPrimaryTranslation($article->getSubject(null), $objectLocalePrecedence);
     }
     if (!empty($subject)) {
         $subjectsNode = $doc->createElementNS($deployment->getNamespace(), 'subjects');
         $subjectsNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'subject', htmlspecialchars($subject, ENT_COMPAT, 'UTF-8')));
         $rootNode->appendChild($subjectsNode);
     }
     // Dates
     $rootNode->appendChild($this->createDatesNode($doc, $issue, $article, $galley, $galleyFile, $publicationDate));
     // Language
     $rootNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'language', AppLocale::getIso1FromLocale($objectLocalePrecedence[0])));
     // Resource Type
     $resourceTypeNode = $this->createResourceTypeNode($doc, $issue, $article, $galley, $galleyFile);
     if ($resourceTypeNode) {
         $rootNode->appendChild($resourceTypeNode);
     }
     // Alternate Identifiers
     $rootNode->appendChild($this->createAlternateIdentifiersNode($doc, $issue, $article, $galley));
     // Related Identifiers
     $relatedIdentifiersNode = $this->createRelatedIdentifiersNode($doc, $issue, $article, $galley);
     if ($relatedIdentifiersNode) {
         $rootNode->appendChild($relatedIdentifiersNode);
     }
     // Sizes
     $sizesNode = $this->createSizesNode($doc, $issue, $article, $galley, $galleyFile);
     if ($sizesNode) {
         $rootNode->appendChild($sizesNode);
     }
     // Formats
     if (!empty($galleyFile)) {
         $format = $galleyFile->getFileType();
         if (!empty($format)) {
             $formatsNode = $doc->createElementNS($deployment->getNamespace(), 'formats');
             $formatsNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'format', htmlspecialchars($format, ENT_COMPAT, 'UTF-8')));
             $rootNode->appendChild($formatsNode);
         }
     }
     // Rights
     $rightsURL = $article ? $article->getLicenseURL() : $context->getSetting('licenseURL');
     if (!empty($rightsURL)) {
         $rightsNode = $doc->createElementNS($deployment->getNamespace(), 'rightsList');
         $rightsNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'rights', htmlspecialchars(strip_tags(Application::getCCLicenseBadge($rightsURL)), ENT_COMPAT, 'UTF-8')));
         $node->setAttribute('rightsURI', $rightsURL);
         $rootNode->appendChild($rightsNode);
     }
     // Descriptions
     $descriptionsNode = $this->createDescriptionsNode($doc, $issue, $article, $galley, $galleyFile, $objectLocalePrecedence);
     if ($descriptionsNode) {
         $rootNode->appendChild($descriptionsNode);
     }
     return $doc;
 }
 /**
  * Set up the template
  * @param $request PKPRequest
  */
 function setupTemplate($request)
 {
     parent::setupTemplate();
     AppLocale::requireComponents(LOCALE_COMPONENT_PKP_READER, LOCALE_COMPONENT_PKP_SUBMISSION);
     if ($this->article) {
         $templateMgr =& TemplateManager::getManager($request);
         $templateMgr->assign('ccLicenseBadge', Application::getCCLicenseBadge($this->article->getLicenseURL()));
     }
 }
Example #8
0
 /**
  * Display a published monograph in the public catalog.
  * @param $args array
  * @param $request PKPRequest
  */
 function book($args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $publishedMonograph = $this->getAuthorizedContextObject(ASSOC_TYPE_PUBLISHED_MONOGRAPH);
     $this->setupTemplate($request, $publishedMonograph);
     AppLocale::requireComponents(LOCALE_COMPONENT_APP_SUBMISSION, LOCALE_COMPONENT_PKP_SUBMISSION);
     // submission.synopsis; submission.copyrightStatement
     $templateMgr->assign('publishedMonograph', $publishedMonograph);
     // Provide the publication formats to the template
     $publicationFormats = $publishedMonograph->getPublicationFormats(true);
     $availablePublicationFormats = array();
     foreach ($publicationFormats as $format) {
         if ($format->getIsAvailable()) {
             $availablePublicationFormats[] = $format;
         }
     }
     $templateMgr->assign('publicationFormats', $availablePublicationFormats);
     // Assign chapters (if they exist)
     $chapterDao = DAORegistry::getDAO('ChapterDAO');
     $chapters = $chapterDao->getChapters($publishedMonograph->getId());
     $templateMgr->assign('chapters', $chapters->toAssociativeArray());
     // Determine which pubId plugins are enabled.
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
     $enabledPubIdTypes = array();
     $metaCustomHeaders = '';
     foreach ((array) $pubIdPlugins as $plugin) {
         if ($plugin->getEnabled()) {
             $enabledPubIdTypes[] = $plugin->getPubIdType();
             // check to see if the format has a pubId set.  If not, generate one.
             foreach ($publicationFormats as $publicationFormat) {
                 if ($plugin->getPubIdType() == 'doi' && $publicationFormat->getStoredPubId('doi')) {
                     $pubId = strip_tags($publicationFormat->getStoredPubId('doi'));
                     $metaCustomHeaders .= '<meta name="DC.Identifier.DOI" content="' . $pubId . '"/><meta name="citation_doi" content="' . $pubId . '"/>';
                 }
             }
         }
     }
     $templateMgr->assign(array('enabledPubIdTypes' => $enabledPubIdTypes, 'metaCustomHeaders' => $metaCustomHeaders, 'licenseUrl' => $publishedMonograph->getLicenseURL(), 'ccLicenseBadge' => Application::getCCLicenseBadge($publishedMonograph->getLicenseURL())));
     // e-Commerce
     import('classes.payment.omp.OMPPaymentManager');
     $ompPaymentManager = new OMPPaymentManager($request);
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     if ($ompPaymentManager->isConfigured()) {
         $availableFiles = array_filter($submissionFileDao->getLatestRevisions($publishedMonograph->getId()), create_function('$a', 'return $a->getViewable() && $a->getDirectSalesPrice() !== null && $a->getAssocType() == ASSOC_TYPE_PUBLICATION_FORMAT;'));
         // Only pass files in pub formats that are also available
         $filteredAvailableFiles = array();
         foreach ($availableFiles as $file) {
             foreach ($availablePublicationFormats as $format) {
                 if ($file->getAssocId() == $format->getId()) {
                     $filteredAvailableFiles[] = $file;
                     break;
                 }
             }
         }
         // Expose variables to template
         $templateMgr->assign('availableFiles', $filteredAvailableFiles);
     }
     // Provide the currency to the template, if configured.
     $currencyDao = DAORegistry::getDAO('CurrencyDAO');
     $press = $request->getPress();
     if ($currency = $press->getSetting('currency')) {
         $templateMgr->assign('currency', $currencyDao->getCurrencyByAlphaCode($currency));
     }
     // Display
     $templateMgr->display('frontend/pages/book.tpl');
 }
 /**
  * Display a published monograph in the public catalog.
  * @param $args array
  * @param $request PKPRequest
  */
 function book($args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $this->setupTemplate($request);
     AppLocale::requireComponents(LOCALE_COMPONENT_APP_SUBMISSION, LOCALE_COMPONENT_PKP_SUBMISSION);
     // submission.synopsis; submission.copyrightStatement
     $publishedMonograph = $this->getAuthorizedContextObject(ASSOC_TYPE_PUBLISHED_MONOGRAPH);
     $templateMgr->assign('publishedMonograph', $publishedMonograph);
     // Get Social media blocks enabled for the catalog
     $socialMediaDao = DAORegistry::getDAO('SocialMediaDAO');
     $socialMedia = $socialMediaDao->getEnabledForContextByContextId($publishedMonograph->getContextId());
     $blocks = array();
     while ($media = $socialMedia->next()) {
         $media->replaceCodeVars($publishedMonograph);
         $blocks[] = $media->getCode();
     }
     $templateMgr->assign_by_ref('blocks', $blocks);
     // Assign chapters (if they exist)
     $chapterDao = DAORegistry::getDAO('ChapterDAO');
     $chapters = $chapterDao->getChapters($publishedMonograph->getId());
     $templateMgr->assign_by_ref('chapters', $chapters->toAssociativeArray());
     // Determine which pubId plugins are enabled.
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
     $enabledPubIdTypes = array();
     $metaCustomHeaders = '';
     foreach ((array) $pubIdPlugins as $plugin) {
         if ($plugin->getEnabled()) {
             $enabledPubIdTypes[] = $plugin->getPubIdType();
             // check to see if the format has a pubId set.  If not, generate one.
             $publicationFormats = $publishedMonograph->getPublicationFormats(true);
             foreach ($publicationFormats as $publicationFormat) {
                 if ($publicationFormat->getStoredPubId($plugin->getPubIdType()) == '') {
                     $plugin->getPubId($publicationFormat);
                 }
                 if ($plugin->getPubIdType() == 'doi') {
                     $pubId = strip_tags($publicationFormat->getStoredPubId('doi'));
                     $metaCustomHeaders .= '<meta name="DC.Identifier.DOI" content="' . $pubId . '"/><meta name="citation_doi" content="' . $pubId . '"/>';
                 }
             }
         }
     }
     $templateMgr->assign('enabledPubIdTypes', $enabledPubIdTypes);
     $templateMgr->assign('metaCustomHeaders', $metaCustomHeaders);
     $templateMgr->assign('ccLicenseBadge', Application::getCCLicenseBadge($publishedMonograph->getLicenseURL()));
     // e-Commerce
     import('classes.payment.omp.OMPPaymentManager');
     $ompPaymentManager = new OMPPaymentManager($request);
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     if ($ompPaymentManager->isConfigured()) {
         $availableFiles = array_filter($submissionFileDao->getLatestRevisions($publishedMonograph->getId()), create_function('$a', 'return $a->getViewable() && $a->getDirectSalesPrice() !== null && $a->getAssocType() == ASSOC_TYPE_PUBLICATION_FORMAT;'));
         $availableFilesByPublicationFormat = array();
         foreach ($availableFiles as $availableFile) {
             $availableFilesByPublicationFormat[$availableFile->getAssocId()][] = $availableFile;
         }
         // Determine whether or not to use the collapsed view.
         $useCollapsedView = true;
         foreach ($availableFilesByPublicationFormat as $representationId => $availableFiles) {
             if (count($availableFiles) > 1) {
                 $useCollapsedView = false;
                 break;
             }
         }
         // Expose variables to template
         $templateMgr->assign('availableFiles', $availableFilesByPublicationFormat);
         $templateMgr->assign('useCollapsedView', $useCollapsedView);
     }
     if ($seriesId = $publishedMonograph->getSeriesId()) {
         $seriesDao = DAORegistry::getDAO('SeriesDAO');
         $series = $seriesDao->getById($seriesId, $publishedMonograph->getContextId());
         $templateMgr->assign('series', $series);
     }
     // Display
     $templateMgr->display('catalog/book/book.tpl');
 }