Open Preprint Systems  3.3.0
TemplateManager.inc.php
1 <?php
2 
18 import('classes.search.ArticleSearch');
19 import('classes.file.PublicFileManager');
20 import('lib.pkp.classes.template.PKPTemplateManager');
21 
27  function initialize($request) {
28  parent::initialize($request);
29 
30  if (!defined('SESSION_DISABLE_INIT')) {
37  $context = $request->getContext();
38  $site = $request->getSite();
39 
40  $publicFileManager = new PublicFileManager();
41  $siteFilesDir = $request->getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath();
42  $this->assign('sitePublicFilesDir', $siteFilesDir);
43  $this->assign('publicFilesDir', $siteFilesDir); // May be overridden by journal
44 
45  if ($site->getData('styleSheet')) {
46  $this->addStyleSheet(
47  'siteStylesheet',
48  $request->getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath() . '/' . $site->getData('styleSheet')['uploadName'],
49  ['priority' => STYLE_SEQUENCE_LATE]
50  );
51  }
52 
53  // Pass app-specific details to template
54  $this->assign([
55  'brandImage' => 'templates/images/ops_brand.png',
56  'packageKey' => 'common.software',
57  ]);
58 
59  // Get a count of unread tasks.
60  if ($user = $request->getUser()) {
61  $notificationDao = DAORegistry::getDAO('NotificationDAO');
62  // Exclude certain tasks, defined in the notifications grid handler
63  import('lib.pkp.controllers.grid.notifications.TaskNotificationsGridHandler');
64  $this->assign('unreadNotificationCount', $notificationDao->getNotificationCount(false, $user->getId(), null, NOTIFICATION_LEVEL_TASK));
65  }
66  if (isset($context)) {
67 
68  $this->assign([
69  'currentJournal' => $context,
70  'siteTitle' => $context->getLocalizedName(),
71  'publicFilesDir' => $request->getBaseUrl() . '/' . $publicFileManager->getContextFilesPath($context->getId()),
72  'primaryLocale' => $context->getPrimaryLocale(),
73  'supportedLocales' => $context->getSupportedLocaleNames(),
74  'displayPageHeaderTitle' => $context->getLocalizedPageHeaderTitle(),
75  'displayPageHeaderLogo' => $context->getLocalizedPageHeaderLogo(),
76  'displayPageHeaderLogoAltText' => $context->getLocalizedData('pageHeaderLogoImageAltText'),
77  'numPageLinks' => $context->getData('numPageLinks'),
78  'itemsPerPage' => $context->getData('itemsPerPage'),
79  'enableAnnouncements' => $context->getData('enableAnnouncements'),
80  'disableUserReg' => $context->getData('disableUserReg'),
81  ]);
82 
83  // Get a link to the settings page for the current context.
84  // This allows us to reduce template duplication by using this
85  // variable in templates/common/header.tpl, instead of
86  // reproducing a lot of OMP/OJS-specific logic there.
87  $dispatcher = $request->getDispatcher();
88  $this->assign([
89  'contextSettingsUrl' => $dispatcher->url($request, ROUTE_PAGE, null, 'management', 'settings', 'context'),
90  'pageFooter' => $context->getLocalizedData('pageFooter')
91  ]);
92  } else {
93  // Check if registration is open for any contexts
94  $contextDao = Application::getContextDAO();
95  $contexts = $contextDao->getAll(true)->toArray();
96  $contextsForRegistration = [];
97  foreach($contexts as $context) {
98  if (!$context->getData('disableUserReg')) {
99  $contextsForRegistration[] = $context;
100  }
101  }
102 
103  $this->assign([
104  'contexts' => $contextsForRegistration,
105  'disableUserReg' => empty($contextsForRegistration),
106  'displayPageHeaderTitle' => $site->getLocalizedPageHeaderTitle(),
107  'displayPageHeaderLogo' => $site->getLocalizedData('pageHeaderTitleImage'),
108  'siteTitle' => $site->getLocalizedTitle(),
109  'primaryLocale' => $site->getPrimaryLocale(),
110  'supportedLocales' => $site->getSupportedLocaleNames(),
111  'pageFooter' => $site->getLocalizedData('pageFooter'),
112  ]);
113  }
114  }
115  }
116 }
117 
118 
PKPTemplateManager\addStyleSheet
addStyleSheet($name, $style, $args=[])
Definition: PKPTemplateManager.inc.php:455
Application\getContextDAO
static getContextDAO()
Definition: Application.inc.php:127
PKPTemplateManager
Definition: PKPTemplateManager.inc.php:50
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
PublicFileManager
Wrapper class for uploading files to a site/journal's public directory.
Definition: PublicFileManager.inc.php:18
TemplateManager\initialize
initialize($request)
Definition: TemplateManager.inc.php:27
TemplateManager
Class for accessing the underlying template engine. Currently integrated with Smarty (from http://sma...
Definition: TemplateManager.inc.php:22