classes/template/TemplateManager.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00017 // $Id$
00018 
00019 
00020 import('search.PaperSearch');
00021 import('file.PublicFileManager');
00022 import('template.PKPTemplateManager');
00023 
00024 class TemplateManager extends PKPTemplateManager {
00029    function TemplateManager() {
00030       parent::PKPTemplateManager();
00031 
00032       if (!defined('SESSION_DISABLE_INIT')) {
00039          $conference =& Request::getConference();
00040          $schedConf =& Request::getSchedConf();
00041          $site =& Request::getSite();
00042          $this->assign('siteTitle', $site->getLocalizedTitle());
00043 
00044          $siteFilesDir = Request::getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath();
00045          $this->assign('sitePublicFilesDir', $siteFilesDir);
00046 
00047          $this->assign('homeContext', array('conference' => 'index', 'schedConf' => 'index'));
00048 
00049          $siteStyleFilename = PublicFileManager::getSiteFilesPath() . '/' . $site->getSiteStyleFilename();
00050          if (file_exists($siteStyleFilename)) $this->addStyleSheet(Request::getBaseUrl() . '/' . $siteStyleFilename);
00051 
00052          if (isset($conference)) {
00053             $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00054             $archivedSchedConfsExist = $schedConfDao->archivedSchedConfsExist($conference->getId());
00055             $currentSchedConfsExist = $schedConfDao->currentSchedConfsExist($conference->getId());
00056             $this->assign('archivedSchedConfsExist', $archivedSchedConfsExist);
00057             $this->assign('currentSchedConfsExist', $currentSchedConfsExist);
00058 
00059             $this->assign_by_ref('currentConference', $conference);
00060             $conferenceTitle = $conference->getConferenceTitle();
00061 
00062             $this->assign('numPageLinks', $conference->getSetting('numPageLinks'));
00063             $this->assign('itemsPerPage', $conference->getSetting('itemsPerPage'));
00064 
00065             // Load and apply theme plugin, if chosen
00066             $themePluginPath = $conference->getSetting('conferenceTheme');
00067 
00068             if (!empty($themePluginPath)) {
00069                // Load and activate the theme
00070                $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath);
00071                if ($themePlugin) $themePlugin->activate($this);
00072             }
00073 
00074             // Assign additional navigation bar items
00075             $navMenuItems =& $conference->getLocalizedSetting('navItems');
00076             $this->assign_by_ref('navMenuItems', $navMenuItems);
00077 
00078             $this->assign('publicFilesDir', Request::getBaseUrl() . '/' . PublicFileManager::getConferenceFilesPath($conference->getId()));
00079             $this->assign('displayPageHeaderTitle', $conference->getPageHeaderTitle());
00080             $this->assign('displayPageHeaderLogo', $conference->getPageHeaderLogo());
00081             $this->assign('displayPageHeaderTitleAltText', $conference->getLocalizedSetting('pageHeaderTitleImageAltText'));
00082             $this->assign('displayPageHeaderLogoAltText', $conference->getLocalizedSetting('pageHeaderLogoImageAltText'));
00083             $this->assign('displayFavicon', $conference->getLocalizedFavicon());
00084             $this->assign('faviconDir', Request::getBaseUrl() . '/' . PublicFileManager::getConferenceFilesPath($conference->getId()));
00085             $this->assign('alternatePageHeader', $conference->getLocalizedSetting('conferencePageHeader'));
00086             $this->assign('metaSearchDescription', $conference->getLocalizedSetting('searchDescription'));
00087             $this->assign('metaSearchKeywords', $conference->getLocalizedSetting('searchKeywords'));
00088             $this->assign('metaCustomHeaders', $conference->getLocalizedSetting('customHeaders'));
00089             $this->assign('enableAnnouncements', $conference->getSetting('enableAnnouncements'));
00090 
00091             $this->assign('pageFooter', $conference->getLocalizedSetting('conferencePageFooter'));
00092             $this->assign('displayCreativeCommons', $conference->getSetting('postCreativeCommons'));
00093 
00094             if (isset($schedConf)) {
00095 
00096                // This will be needed if inheriting public conference files from the scheduled conference.
00097                $this->assign('publicSchedConfFilesDir', Request::getBaseUrl() . '/' . PublicFileManager::getSchedConfFilesPath($schedConf->getId()));
00098                $this->assign('primaryLocale', $conference->getSetting('primaryLocale'));
00099                $this->assign('alternateLocales', $conference->getPrimaryLocale());
00100 
00101                $this->assign_by_ref('currentSchedConf', $schedConf);
00102 
00103                // Assign common sched conf vars:
00104                $currentTime = time();
00105                $submissionsCloseDate = $schedConf->getSetting('submissionsCloseDate');
00106                $this->assign('submissionsCloseDate', $submissionsCloseDate);
00107                $this->assign('schedConfPostTimeline', $schedConf->getSetting('postTimeline'));
00108                $this->assign('schedConfPostOverview', $schedConf->getSetting('postOverview'));
00109                $this->assign('schedConfPostTrackPolicies', $schedConf->getSetting('postTrackPolicies'));
00110                $this->assign('schedConfPostPresentations', $schedConf->getSetting('postPresentations'));
00111                $this->assign('schedConfPostAccommodation', $schedConf->getSetting('postAccommodation'));
00112                $this->assign('schedConfPostSupporters', $schedConf->getSetting('postSupporters'));
00113                $this->assign('schedConfPostPayment', $schedConf->getSetting('postPayment'));
00114 
00115                // CFP displayed
00116                $showCFPDate = $schedConf->getSetting('showCFPDate');
00117                $postCFP = $schedConf->getSetting('postCFP');
00118                if ($postCFP && $showCFPDate && $submissionsCloseDate && $currentTime > $showCFPDate && $currentTime < $submissionsCloseDate) {
00119                   $this->assign('schedConfShowCFP', true);
00120                }
00121 
00122                // Schedule displayed
00123                $postScheduleDate = $schedConf->getSetting('postScheduleDate');
00124                if ($postScheduleDate && $currentTime > $postScheduleDate && $schedConf->getSetting('postSchedule')) {
00125                   $this->assign('schedConfPostSchedule', true);
00126                }
00127 
00128                // Program
00129                if ($schedConf->getSetting('postProgram') && ($schedConf->getSetting('program') || $schedConf->getSetting('programFile'))) {
00130                   $this->assign('schedConfShowProgram', true);
00131                }
00132 
00133                // Submissions open
00134                $submissionsOpenDate = $schedConf->getSetting('submissionsOpenDate');
00135                $postSubmission = $schedConf->getSetting('postProposalSubmission');
00136                $this->assign('submissionsOpenDate', $submissionsOpenDate);
00137 
00138                import('payment.ocs.OCSPaymentManager');
00139                $paymentManager =& OCSPaymentManager::getManager();
00140                $this->assign('schedConfPaymentsEnabled', $paymentManager->isConfigured());
00141 
00142             }
00143 
00144             // Assign conference stylesheet and footer
00145             $conferenceStyleSheet = $conference->getSetting('conferenceStyleSheet');
00146             if ($conferenceStyleSheet) {
00147                $this->addStyleSheet(Request::getBaseUrl() .
00148                '/' . PublicFileManager::getConferenceFilesPath($conference->getId()) .
00149                '/' . $conferenceStyleSheet['uploadName']);
00150             }
00151 
00152             // Assign scheduled conference stylesheet and footer (after conference stylesheet!)
00153             if($schedConf) {
00154                $schedConfStyleSheet = $schedConf->getSetting('schedConfStyleSheet');
00155                if ($schedConfStyleSheet) {
00156                   $this->addStyleSheet(Request::getBaseUrl() .
00157                   '/' . PublicFileManager::getSchedConfFilesPath($schedConf->getId()) .
00158                   '/' . $schedConfStyleSheet['uploadName']);
00159                }
00160             }
00161          } else { // Not within conference context
00162             // Add the site-wide logo, if set for this locale or the primary locale
00163             $displayPageHeaderTitle = $site->getLocalizedPageHeaderTitle();
00164             $this->assign('displayPageHeaderTitle', $displayPageHeaderTitle);
00165             if (isset($displayPageHeaderTitle['altText'])) $this->assign('displayPageHeaderTitleAltText', $displayPageHeaderTitle['altText']);
00166             $this->assign('publicFilesDir', Request::getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath());
00167          }
00168       }
00169    }
00170 
00180    function smartyGetHelpId($params, &$smarty) {
00181       import('help.Help');
00182       $help =& Help::getHelp();
00183       if (isset($params) && !empty($params)) {
00184          if (isset($params['key'])) {
00185             $key = $params['key'];
00186             unset($params['key']);
00187             $translatedKey = $help->translate($key);
00188          } else {
00189             $translatedKey = $help->translate('');
00190          }
00191 
00192          if ($params['url'] == "true") {
00193             return Request::url(null, null, 'help', 'view', explode('/', $translatedKey));
00194          } else {
00195             return $translatedKey;
00196          }
00197       }
00198    }
00199 
00208    function smartyHelpTopic($params, &$smarty) {
00209       import('help.Help');
00210       $help =& Help::getHelp();
00211       if (isset($params) && !empty($params)) {
00212          $translatedKey = isset($params['key']) ? $help->translate($params['key']) : $help->translate('');
00213          $link = Request::url(null, null, 'help', 'view', explode('/', $translatedKey));
00214          $text = isset($params['text']) ? $params['text'] : '';
00215          return "<a href=\"$link\">$text</a>";
00216       }
00217    }
00218 
00229    function smartyPageLinks($params, &$smarty) {
00230       $iterator = $params['iterator'];
00231       $name = $params['name'];
00232       if (isset($params['anchor'])) {
00233          $anchor = $params['anchor'];
00234          unset($params['anchor']);
00235       } else {
00236          $anchor = null;
00237       }
00238       if (isset($params['all_extra'])) {
00239          $allExtra = ' ' . $params['all_extra'];
00240          unset($params['all_extra']);
00241       } else {
00242          $allExtra = '';
00243       }
00244 
00245       unset($params['iterator']);
00246       unset($params['name']);
00247 
00248       $numPageLinks = $smarty->get_template_vars('numPageLinks');
00249       if (!is_numeric($numPageLinks)) $numPageLinks=10;
00250 
00251       $page = $iterator->getPage();
00252       $pageCount = $iterator->getPageCount();
00253       $itemTotal = $iterator->getCount();
00254 
00255       $pageBase = max($page - floor($numPageLinks / 2), 1);
00256       $paramName = $name . 'Page';
00257 
00258       if ($pageCount<=1) return '';
00259 
00260       $value = '';
00261 
00262       if ($page>1) {
00263          $params[$paramName] = 1;
00264          $value .= '<a href="' . Request::url(null, null, null, null, Request::getRequestedArgs(), $params, $anchor, true) . '"' . $allExtra . '>&lt;&lt;</a>&nbsp;';
00265          $params[$paramName] = $page - 1;
00266          $value .= '<a href="' . Request::url(null, null, null, null, Request::getRequestedArgs(), $params, $anchor, true) . '"' . $allExtra . '>&lt;</a>&nbsp;';
00267       }
00268 
00269       for ($i=$pageBase; $i<min($pageBase+$numPageLinks, $pageCount+1); $i++) {
00270          if ($i == $page) {
00271             $value .= "<strong>$i</strong>&nbsp;";
00272          } else {
00273             $params[$paramName] = $i;
00274             $value .= '<a href="' . Request::url(null, null, null, null, Request::getRequestedArgs(), $params, $anchor, true) . '"' . $allExtra . '>' . $i . '</a>&nbsp;';
00275          }
00276       }
00277       if ($page < $pageCount) {
00278          $params[$paramName] = $page + 1;
00279          $value .= '<a href="' . Request::url(null, null, null, null, Request::getRequestedArgs(), $params, $anchor, true) . '"' . $allExtra . '>&gt;</a>&nbsp;';
00280          $params[$paramName] = $pageCount;
00281          $value .= '<a href="' . Request::url(null, null, null, null, Request::getRequestedArgs(), $params, $anchor, true) . '"' . $allExtra . '>&gt;&gt;</a>&nbsp;';
00282       }
00283 
00284       return $value;
00285    }
00286 }
00287 
00288 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7