_setupIssueTemplate() public method

Given an issue, set up the template with all the required variables for frontend/objects/issue_toc.tpl to function properly (i.e. current issue and view issue).
public _setupIssueTemplate ( $request, $issue, $showToc = false )
$issue object The issue to display
$showToc boolean iff false and a custom cover page exists, the cover page will be displayed. Otherwise table of contents will be displayed.
Ejemplo n.º 1
0
 /**
  * If no journal is selected, display list of journals.
  * Otherwise, display the index page for the selected journal.
  * @param $args array
  * @param $request Request
  */
 function index($args, $request)
 {
     $this->validate(null, $request);
     $journal = $request->getJournal();
     if (!$journal) {
         $journal = $this->getTargetContext($request, $journalsCount);
         if ($journal) {
             // There's a target context but no journal in the current request. Redirect.
             $request->redirect($journal->getPath());
         }
         if ($journalsCount === 0 && Validation::isSiteAdmin()) {
             // No contexts created, and this is the admin.
             $request->redirect(null, 'admin', 'contexts');
         }
     }
     $router = $request->getRouter();
     $templateMgr = TemplateManager::getManager($request);
     $journalDao = DAORegistry::getDAO('JournalDAO');
     $this->setupTemplate($request);
     if ($journal) {
         // Assign header and content for home page
         $templateMgr->assign('additionalHomeContent', $journal->getLocalizedSetting('additionalHomeContent'));
         $templateMgr->assign('homepageImage', $journal->getLocalizedSetting('homepageImage'));
         $templateMgr->assign('homepageImageAltText', $journal->getLocalizedSetting('homepageImageAltText'));
         $templateMgr->assign('journalDescription', $journal->getLocalizedSetting('description'));
         $displayCurrentIssue = $journal->getSetting('displayCurrentIssue');
         $issueDao = DAORegistry::getDAO('IssueDAO');
         $issue = $issueDao->getCurrent($journal->getId(), true);
         if ($displayCurrentIssue && isset($issue)) {
             import('pages.issue.IssueHandler');
             // The current issue TOC/cover page should be displayed below the custom home page.
             IssueHandler::_setupIssueTemplate($request, $issue);
         }
         $enableAnnouncements = $journal->getSetting('enableAnnouncements');
         if ($enableAnnouncements) {
             $enableAnnouncementsHomepage = $journal->getSetting('enableAnnouncementsHomepage');
             if ($enableAnnouncementsHomepage) {
                 $numAnnouncementsHomepage = $journal->getSetting('numAnnouncementsHomepage');
                 $announcementDao = DAORegistry::getDAO('AnnouncementDAO');
                 $announcements =& $announcementDao->getNumAnnouncementsNotExpiredByAssocId(ASSOC_TYPE_JOURNAL, $journal->getId(), $numAnnouncementsHomepage);
                 $templateMgr->assign('announcements', $announcements);
                 $templateMgr->assign('enableAnnouncementsHomepage', $enableAnnouncementsHomepage);
             }
         }
         // Include any social media items that are configured for the context itself.
         $socialMediaDao = DAORegistry::getDAO('SocialMediaDAO');
         $socialMedia =& $socialMediaDao->getEnabledForContextByContextId($journal->getId());
         $blocks = array();
         while ($media = $socialMedia->next()) {
             $media->replaceCodeVars();
             $blocks[] = $media->getCode();
         }
         $templateMgr->assign('socialMediaBlocks', $blocks);
         $templateMgr->display('frontend/pages/indexJournal.tpl');
     } else {
         $site = $request->getSite();
         if ($site->getRedirect() && ($journal = $journalDao->getById($site->getRedirect())) != null) {
             $request->redirect($journal->getPath());
         }
         $templateMgr->assign('intro', $site->getLocalizedIntro());
         $templateMgr->assign('journalFilesPath', $request->getBaseUrl() . '/' . Config::getVar('files', 'public_files_dir') . '/journals/');
         // If we're using paging, fetch the parameters
         $usePaging = $site->getSetting('usePaging');
         if ($usePaging) {
             $rangeInfo = $this->getRangeInfo($request, 'journals');
         } else {
             $rangeInfo = null;
         }
         $templateMgr->assign('usePaging', $usePaging);
         $journals = $journalDao->getAll(true, $rangeInfo);
         $templateMgr->assign('journals', $journals);
         $templateMgr->assign('site', $site);
         $templateMgr->setCacheability(CACHEABILITY_PUBLIC);
         $templateMgr->display('frontend/pages/indexSite.tpl');
     }
 }
Ejemplo n.º 2
0
 /**
  * If no journal is selected, display list of journals.
  * Otherwise, display the index page for the selected journal.
  * @param $args array
  * @param $request Request
  */
 function index($args, &$request)
 {
     $this->validate();
     $this->setupTemplate();
     $router =& $request->getRouter();
     $templateMgr =& TemplateManager::getManager();
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     $journalPath = $router->getRequestedContextPath($request);
     $templateMgr->assign('helpTopicId', 'user.home');
     $journal =& $router->getContext($request);
     if ($journal) {
         // Assign header and content for home page
         $templateMgr->assign('displayPageHeaderTitle', $journal->getLocalizedPageHeaderTitle(true));
         $templateMgr->assign('displayPageHeaderLogo', $journal->getLocalizedPageHeaderLogo(true));
         $templateMgr->assign('displayPageHeaderTitleAltText', $journal->getLocalizedSetting('homeHeaderTitleImageAltText'));
         $templateMgr->assign('displayPageHeaderLogoAltText', $journal->getLocalizedSetting('homeHeaderLogoImageAltText'));
         $templateMgr->assign('additionalHomeContent', $journal->getLocalizedSetting('additionalHomeContent'));
         $templateMgr->assign('homepageImage', $journal->getLocalizedSetting('homepageImage'));
         $templateMgr->assign('homepageImageAltText', $journal->getLocalizedSetting('homepageImageAltText'));
         $templateMgr->assign('journalDescription', $journal->getLocalizedSetting('description'));
         $displayCurrentIssue = $journal->getSetting('displayCurrentIssue');
         $issueDao =& DAORegistry::getDAO('IssueDAO');
         $issue =& $issueDao->getCurrentIssue($journal->getId(), true);
         if ($displayCurrentIssue && isset($issue)) {
             import('pages.issue.IssueHandler');
             // The current issue TOC/cover page should be displayed below the custom home page.
             IssueHandler::_setupIssueTemplate($request, $issue);
         }
         // Display creative commons logo/licence if enabled
         $templateMgr->assign('displayCreativeCommons', $journal->getSetting('includeCreativeCommons'));
         $enableAnnouncements = $journal->getSetting('enableAnnouncements');
         if ($enableAnnouncements) {
             $enableAnnouncementsHomepage = $journal->getSetting('enableAnnouncementsHomepage');
             if ($enableAnnouncementsHomepage) {
                 $numAnnouncementsHomepage = $journal->getSetting('numAnnouncementsHomepage');
                 $announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
                 $announcements =& $announcementDao->getNumAnnouncementsNotExpiredByAssocId(ASSOC_TYPE_JOURNAL, $journal->getId(), $numAnnouncementsHomepage);
                 $templateMgr->assign('announcements', $announcements);
                 $templateMgr->assign('enableAnnouncementsHomepage', $enableAnnouncementsHomepage);
             }
         }
         $templateMgr->display('index/journal.tpl');
     } else {
         $site =& Request::getSite();
         if ($site->getRedirect() && ($journal = $journalDao->getJournal($site->getRedirect())) != null) {
             $request->redirect($journal->getPath());
         }
         $templateMgr->assign('intro', $site->getLocalizedIntro());
         $templateMgr->assign('journalFilesPath', $request->getBaseUrl() . '/' . Config::getVar('files', 'public_files_dir') . '/journals/');
         // If we're using paging, fetch the parameters
         $usePaging = $site->getSetting('usePaging');
         if ($usePaging) {
             $rangeInfo =& Handler::getRangeInfo('journals');
         } else {
             $rangeInfo = null;
         }
         $templateMgr->assign('usePaging', $usePaging);
         // Fetch the alpha list parameters
         $searchInitial = Request::getUserVar('searchInitial');
         $templateMgr->assign('searchInitial', $searchInitial);
         $templateMgr->assign('useAlphalist', $site->getSetting('useAlphalist'));
         $journals =& $journalDao->getJournals(true, $rangeInfo, $searchInitial ? JOURNAL_FIELD_TITLE : JOURNAL_FIELD_SEQUENCE, $searchInitial ? JOURNAL_FIELD_TITLE : null, $searchInitial ? 'startsWith' : null, $searchInitial);
         $templateMgr->assign_by_ref('journals', $journals);
         $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList')));
         $templateMgr->setCacheability(CACHEABILITY_PUBLIC);
         $templateMgr->display('index/site.tpl');
     }
 }