ArticleHandler::view PHP Метод

view() публичный Метод

View Article. (Either article landing page or galley view.)
public view ( $args, $request )
$args array
$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');
        $galley = $galleyDao->getByBestGalleyId($galleyId, $article->getId());
        if ($galley && $galley->getRemoteURL()) {
            $request->redirectUrl($galley->getRemoteURL());
        }
        // Copyright and license info
        $templateMgr->assign(array('copyright' => $journal->getLocalizedSetting('copyrightNotice'), 'copyrightHolder' => $journal->getLocalizedSetting('copyrightHolder'), 'copyrightYear' => $journal->getSetting('copyrightYear')));
        if ($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);
        // Citation formats
        $citationPlugins = PluginRegistry::loadCategory('citationFormats');
        uasort($citationPlugins, create_function('$a, $b', 'return strcmp($a->getDisplayName(), $b->getDisplayName());'));
        $templateMgr->assign('citationPlugins', $citationPlugins);
        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('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);
            }
            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));
            }
        }
    }