/**
  * Initialize the template manager.
  */
 function initialize()
 {
     $locale = AppLocale::getLocale();
     $application = PKPApplication::getApplication();
     $router = $this->_request->getRouter();
     assert(is_a($router, 'PKPRouter'));
     $currentContext = $this->_request->getContext();
     $this->assign(array('defaultCharset' => Config::getVar('i18n', 'client_charset'), 'basePath' => $this->_request->getBasePath(), 'baseUrl' => $this->_request->getBaseUrl(), 'requiresFormRequest' => $this->_request->isPost(), 'currentUrl' => $this->_request->getCompleteUrl(), 'dateFormatTrunc' => Config::getVar('general', 'date_format_trunc'), 'dateFormatShort' => Config::getVar('general', 'date_format_short'), 'dateFormatLong' => Config::getVar('general', 'date_format_long'), 'datetimeFormatShort' => Config::getVar('general', 'datetime_format_short'), 'datetimeFormatLong' => Config::getVar('general', 'datetime_format_long'), 'timeFormat' => Config::getVar('general', 'time_format'), 'currentContext' => $currentContext, 'currentLocale' => $locale, 'pageTitle' => $application->getNameKey(), 'applicationName' => __($application->getNameKey())));
     if (is_a($router, 'PKPPageRouter')) {
         $this->assign(array('requestedPage' => $router->getRequestedPage($this->_request), 'requestedOp' => $router->getRequestedOp($this->_request)));
         // Register the jQuery script
         $min = Config::getVar('general', 'enable_minified') ? '.min' : '';
         if (Config::getVar('general', 'enable_cdn')) {
             $jquery = '//ajax.googleapis.com/ajax/libs/jquery/' . CDN_JQUERY_VERSION . '/jquery' . $min . '.js';
             $jqueryUI = '//ajax.googleapis.com/ajax/libs/jqueryui/' . CDN_JQUERY_UI_VERSION . '/jquery-ui' . $min . '.js';
         } else {
             $jquery = $this->_request->getBaseUrl() . '/lib/pkp/lib/components/jquery/jquery' . $min . '.js';
             $jqueryUI = $this->_request->getBaseUrl() . '/lib/pkp/lib/components/jquery-ui/jquery-ui' . $min . '.js';
         }
         $this->addJavaScript('jquery', $jquery, array('priority' => STYLE_SEQUENCE_CORE, 'contexts' => 'backend'));
         $this->addJavaScript('jqueryUI', $jqueryUI, array('priority' => STYLE_SEQUENCE_CORE, 'contexts' => 'backend'));
         // Register the pkp-lib JS library
         $this->registerJSLibraryData();
         $this->registerJSLibrary();
         // Load Noto Sans font from Google Font CDN
         // To load extended latin or other character sets, see:
         // https://www.google.com/fonts#UsePlace:use/Collection:Noto+Sans
         if (Config::getVar('general', 'enable_cdn')) {
             $this->addStyleSheet('pkpLibNotoSans', '//fonts.googleapis.com/css?family=Noto+Sans:400,400italic,700,700italic', array('priority' => STYLE_SEQUENCE_CORE, 'contexts' => 'backend'));
         }
         // Register the primary backend stylesheet
         if ($dispatcher = $this->_request->getDispatcher()) {
             $this->addStyleSheet('pkpLib', $dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'page.PageHandler', 'css'), array('priority' => STYLE_SEQUENCE_CORE, 'contexts' => 'backend'));
         }
         // Add reading language flag based on locale
         $this->assign('currentLocaleLangDir', AppLocale::getLocaleDirection($locale));
         // If there's a locale-specific stylesheet, add it.
         if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) {
             $this->addStyleSheet('pkpLibLocale', $this->_request->getBaseUrl() . '/' . $localeStyleSheet, array('contexts' => array('frontend', 'backend')));
         }
         // Register colour picker assets on the appearance page
         $this->addJavaScript('spectrum', $this->_request->getBaseUrl() . '/lib/pkp/js/lib/jquery/plugins/spectrum/spectrum.js', array('contexts' => array('backend-management-settings', 'backend-admin-settings', 'backend-admin-contexts')));
         $this->addStyleSheet('spectrum', $this->_request->getBaseUrl() . '/lib/pkp/js/lib/jquery/plugins/spectrum/spectrum.css', array('contexts' => array('backend-management-settings', 'backend-admin-settings', 'backend-admin-contexts')));
         // Register recaptcha on relevant pages
         if (Config::getVar('captcha', 'recaptcha') && Config::getVar('captcha', 'captcha_on_register')) {
             $this->addJavaScript('recaptcha', 'https://www.google.com/recaptcha/api.js', array('contexts' => array('frontend-user-register', 'frontend-user-registerUser')));
         }
         // Register meta tags
         if (Config::getVar('general', 'installed')) {
             if (($this->_request->getRequestedPage() == '' || $this->_request->getRequestedPage() == 'index') && $currentContext && $currentContext->getLocalizedSetting('searchDescription')) {
                 $this->addHeader('searchDescription', '<meta name="description" content="' . $currentContext->getLocalizedSetting('searchDescription') . '">');
             }
             $this->addHeader('generator', '<meta name="generator" content="' . __($application->getNameKey()) . ' ' . $application->getCurrentVersion()->getVersionString(false) . '">', array('contexts' => array('frontend', 'backend')));
             if ($currentContext) {
                 $customHeaders = $currentContext->getLocalizedSetting('customHeaders');
                 if (!empty($customHeaders)) {
                     $this->addHeader('customHeaders', $customHeaders);
                 }
             }
         }
         if ($currentContext && !$currentContext->getEnabled()) {
             $this->addHeader('noindex', '<meta name="robots" content="noindex,nofollow">', array('contexts' => array('frontend', 'backend')));
         }
     }
     // Register custom functions
     $this->register_modifier('translate', array('AppLocale', 'translate'));
     $this->register_modifier('strip_unsafe_html', array('PKPString', 'stripUnsafeHtml'));
     $this->register_modifier('String_substr', array('PKPString', 'substr'));
     $this->register_modifier('dateformatPHP2JQueryDatepicker', array('PKPString', 'dateformatPHP2JQueryDatepicker'));
     $this->register_modifier('to_array', array($this, 'smartyToArray'));
     $this->register_modifier('compare', array($this, 'smartyCompare'));
     $this->register_modifier('concat', array($this, 'smartyConcat'));
     $this->register_modifier('strtotime', array($this, 'smartyStrtotime'));
     $this->register_modifier('explode', array($this, 'smartyExplode'));
     $this->register_modifier('assign', array($this, 'smartyAssign'));
     $this->register_function('csrf', array($this, 'smartyCSRF'));
     $this->register_function('translate', array($this, 'smartyTranslate'));
     $this->register_function('null_link_action', array($this, 'smartyNullLinkAction'));
     $this->register_function('help', array($this, 'smartyHelp'));
     $this->register_function('flush', array($this, 'smartyFlush'));
     $this->register_function('call_hook', array($this, 'smartyCallHook'));
     $this->register_function('html_options_translate', array($this, 'smartyHtmlOptionsTranslate'));
     $this->register_block('iterate', array($this, 'smartyIterate'));
     $this->register_function('page_links', array($this, 'smartyPageLinks'));
     $this->register_function('page_info', array($this, 'smartyPageInfo'));
     $this->register_function('pluck_files', array($this, 'smartyPluckFiles'));
     // Modified vocabulary for creating forms
     $fbv = $this->getFBV();
     $this->register_block('fbvFormSection', array($fbv, 'smartyFBVFormSection'));
     $this->register_block('fbvFormArea', array($fbv, 'smartyFBVFormArea'));
     $this->register_function('fbvFormButtons', array($fbv, 'smartyFBVFormButtons'));
     $this->register_function('fbvElement', array($fbv, 'smartyFBVElement'));
     $this->assign('fbvStyles', $fbv->getStyles());
     $this->register_function('fieldLabel', array($fbv, 'smartyFieldLabel'));
     // register the resource name "core"
     $coreResource = new PKPTemplateResource($this->core_template_dir);
     $this->register_resource('core', array(array($coreResource, 'fetch'), array($coreResource, 'fetchTimestamp'), array($coreResource, 'getSecure'), array($coreResource, 'getTrusted')));
     $appResource = new PKPTemplateResource($this->app_template_dir);
     $this->register_resource('app', array(array($appResource, 'fetch'), array($appResource, 'fetchTimestamp'), array($appResource, 'getSecure'), array($appResource, 'getTrusted')));
     $this->register_function('url', array($this, 'smartyUrl'));
     // ajax load into a div or any element
     $this->register_function('load_url_in_el', array($this, 'smartyLoadUrlInEl'));
     $this->register_function('load_url_in_div', array($this, 'smartyLoadUrlInDiv'));
     // load stylesheets/scripts/headers from a given context
     $this->register_function('load_stylesheet', array($this, 'smartyLoadStylesheet'));
     $this->register_function('load_script', array($this, 'smartyLoadScript'));
     $this->register_function('load_header', array($this, 'smartyLoadHeader'));
     /**
      * Kludge to make sure no code that tries to connect to the
      * database is executed (e.g., when loading installer pages).
      */
     if (!defined('SESSION_DISABLE_INIT')) {
         $application = PKPApplication::getApplication();
         $this->assign(array('isUserLoggedIn' => Validation::isLoggedIn(), 'isUserLoggedInAs' => Validation::isLoggedInAs(), 'itemsPerPage' => Config::getVar('interface', 'items_per_page'), 'numPageLinks' => Config::getVar('interface', 'page_links')));
         $user = $this->_request->getUser();
         $hasSystemNotifications = false;
         if ($user) {
             $notificationDao = DAORegistry::getDAO('NotificationDAO');
             $notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL);
             if ($notifications->getCount() > 0) {
                 $this->assign('hasSystemNotifications', true);
             }
             // Assign the user name to be used in the sitenav
             $this->assign(array('loggedInUsername' => $user->getUserName(), 'initialHelpState' => (int) $user->getInlineHelp()));
         }
     }
     // Load enabled block plugins and setup active sidebar variables
     PluginRegistry::loadCategory('blocks', true);
     $sidebarHooks = HookRegistry::getHooks('Templates::Common::Sidebar');
     $this->assign(array('hasSidebar' => !empty($sidebarHooks)));
 }
 /**
  * Initialize the template manager.
  */
 function initialize()
 {
     // Retrieve the router
     $router = $this->_request->getRouter();
     assert(is_a($router, 'PKPRouter'));
     $this->assign('defaultCharset', Config::getVar('i18n', 'client_charset'));
     $this->assign('basePath', $this->_request->getBasePath());
     $this->assign('baseUrl', $this->_request->getBaseUrl());
     $this->assign('requiresFormRequest', $this->_request->isPost());
     if (is_a($router, 'PKPPageRouter')) {
         $this->assign('requestedPage', $router->getRequestedPage($this->_request));
     }
     $this->assign('currentUrl', $this->_request->getCompleteUrl());
     $this->assign('dateFormatTrunc', Config::getVar('general', 'date_format_trunc'));
     $this->assign('dateFormatShort', Config::getVar('general', 'date_format_short'));
     $this->assign('dateFormatLong', Config::getVar('general', 'date_format_long'));
     $this->assign('datetimeFormatShort', Config::getVar('general', 'datetime_format_short'));
     $this->assign('datetimeFormatLong', Config::getVar('general', 'datetime_format_long'));
     $this->assign('timeFormat', Config::getVar('general', 'time_format'));
     $this->assign('allowCDN', Config::getVar('general', 'enable_cdn'));
     $this->assign('useMinifiedJavaScript', Config::getVar('general', 'enable_minified'));
     $this->assign('toggleHelpOnText', __('help.toggleInlineHelpOn'));
     $this->assign('toggleHelpOffText', __('help.toggleInlineHelpOff'));
     $this->assign('currentContext', $this->_request->getContext());
     $locale = AppLocale::getLocale();
     $this->assign('currentLocale', $locale);
     // Add uncompilable styles
     $this->addStyleSheet($this->_request->getBaseUrl() . '/styles/lib.css', STYLE_SEQUENCE_CORE);
     $dispatcher = $this->_request->getDispatcher();
     if ($dispatcher) {
         $this->addStyleSheet($dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'page.PageHandler', 'css'), STYLE_SEQUENCE_CORE);
     }
     // If there's a locale-specific stylesheet, add it.
     if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) {
         $this->addStyleSheet($this->_request->getBaseUrl() . '/' . $localeStyleSheet);
     }
     $application = PKPApplication::getApplication();
     $this->assign('pageTitle', $application->getNameKey());
     $this->assign('applicationName', __($application->getNameKey()));
     $this->assign('exposedConstants', $application->getExposedConstants());
     $this->assign('jsLocaleKeys', $application->getJSLocaleKeys());
     // Register custom functions
     $this->register_modifier('translate', array('AppLocale', 'translate'));
     $this->register_modifier('strip_unsafe_html', array('String', 'stripUnsafeHtml'));
     $this->register_modifier('String_substr', array('String', 'substr'));
     $this->register_modifier('to_array', array($this, 'smartyToArray'));
     $this->register_modifier('compare', array($this, 'smartyCompare'));
     $this->register_modifier('concat', array($this, 'smartyConcat'));
     $this->register_modifier('escape', array($this, 'smartyEscape'));
     $this->register_modifier('strtotime', array($this, 'smartyStrtotime'));
     $this->register_modifier('explode', array($this, 'smartyExplode'));
     $this->register_modifier('assign', array($this, 'smartyAssign'));
     $this->register_function('translate', array($this, 'smartyTranslate'));
     $this->register_function('null_link_action', array($this, 'smartyNullLinkAction'));
     $this->register_function('flush', array($this, 'smartyFlush'));
     $this->register_function('call_hook', array($this, 'smartyCallHook'));
     $this->register_function('html_options_translate', array($this, 'smartyHtmlOptionsTranslate'));
     $this->register_block('iterate', array($this, 'smartyIterate'));
     $this->register_function('page_links', array($this, 'smartyPageLinks'));
     $this->register_function('page_info', array($this, 'smartyPageInfo'));
     $this->register_function('icon', array($this, 'smartyIcon'));
     $this->register_modifier('truncate', array($this, 'smartyTruncate'));
     // Modified vocabulary for creating forms
     $fbv = $this->getFBV();
     $this->register_block('fbvFormSection', array($fbv, 'smartyFBVFormSection'));
     $this->register_block('fbvFormArea', array($fbv, 'smartyFBVFormArea'));
     $this->register_function('fbvFormButtons', array($fbv, 'smartyFBVFormButtons'));
     $this->register_function('fbvElement', array($fbv, 'smartyFBVElement'));
     $this->assign('fbvStyles', $fbv->getStyles());
     $this->register_function('fieldLabel', array($fbv, 'smartyFieldLabel'));
     // register the resource name "core"
     $this->register_resource('core', array(array($this, 'smartyResourceCoreGetTemplate'), array($this, 'smartyResourceCoreGetTimestamp'), array($this, 'smartyResourceCoreGetSecure'), array($this, 'smartyResourceCoreGetTrusted')));
     $this->register_function('url', array($this, 'smartyUrl'));
     // ajax load into a div
     $this->register_function('load_url_in_div', array($this, 'smartyLoadUrlInDiv'));
     if (!defined('SESSION_DISABLE_INIT')) {
         /**
          * Kludge to make sure no code that tries to connect to
          * the database is executed (e.g., when loading
          * installer pages).
          */
         $this->assign('isUserLoggedIn', Validation::isLoggedIn());
         $this->assign('isUserLoggedInAs', Validation::isLoggedInAs());
         $application = PKPApplication::getApplication();
         $currentVersion = $application->getCurrentVersion();
         $this->assign('currentVersionString', $currentVersion->getVersionString(false));
         $this->assign('itemsPerPage', Config::getVar('interface', 'items_per_page'));
         $this->assign('numPageLinks', Config::getVar('interface', 'page_links'));
     }
     // Load enabled block plugins.
     PluginRegistry::loadCategory('blocks', true);
     if (!defined('SESSION_DISABLE_INIT')) {
         $user = $this->_request->getUser();
         $hasSystemNotifications = false;
         if ($user) {
             // Assign the user name to be used in the sitenav
             $this->assign('loggedInUsername', $user->getUserName());
             $notificationDao = DAORegistry::getDAO('NotificationDAO');
             $notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL);
             if ($notifications->getCount() > 0) {
                 $hasSystemNotifications = true;
             }
             $this->assign('initialHelpState', (int) $user->getInlineHelp());
         }
         $this->assign('hasSystemNotifications', $hasSystemNotifications);
     }
 }
Beispiel #3
0
 /**
  * @covers PKPLocale
  */
 public function testGetLocaleStylesheet()
 {
     self::assertNull(AppLocale::getLocaleStyleSheet('en_US'));
     self::assertEquals('pt.css', AppLocale::getLocaleStyleSheet('pt_BR'));
     self::assertNull(AppLocale::getLocaleStyleSheet('xx_XX'));
 }
 /**
  * Constructor.
  * Initialize template engine and assign basic template variables.
  * @param $request PKPRequest FIXME: is optional for backwards compatibility only - make mandatory
  */
 function PKPTemplateManager($request = null)
 {
     // FIXME: for backwards compatibility only - remove
     if (!isset($request)) {
         if (Config::getVar('debug', 'deprecation_warnings')) {
             trigger_error('Deprecated function call.');
         }
         $request =& Registry::get('request');
     }
     assert(is_a($request, 'PKPRequest'));
     // Retrieve the router
     $router =& $request->getRouter();
     assert(is_a($router, 'PKPRouter'));
     parent::Smarty();
     // Set up Smarty configuration
     $baseDir = Core::getBaseDir();
     $cachePath = CacheManager::getFileCachePath();
     // Set the default template dir (app's template dir)
     $this->app_template_dir = $baseDir . DIRECTORY_SEPARATOR . 'templates';
     // Set fallback template dir (core's template dir)
     $this->core_template_dir = $baseDir . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'templates';
     $this->template_dir = array($this->app_template_dir, $this->core_template_dir);
     $this->compile_dir = $cachePath . DIRECTORY_SEPARATOR . 't_compile';
     $this->config_dir = $cachePath . DIRECTORY_SEPARATOR . 't_config';
     $this->cache_dir = $cachePath . DIRECTORY_SEPARATOR . 't_cache';
     // Assign common variables
     $this->styleSheets = array();
     $this->assign_by_ref('stylesheets', $this->styleSheets);
     $this->cacheability = CACHEABILITY_NO_STORE;
     // Safe default
     $this->assign('defaultCharset', Config::getVar('i18n', 'client_charset'));
     $this->assign('baseUrl', $request->getBaseUrl());
     $this->assign('requiresFormRequest', $request->isPost());
     if (is_a($router, 'PKPPageRouter')) {
         $this->assign('requestedPage', $router->getRequestedPage($request));
     }
     $this->assign('currentUrl', $request->getCompleteUrl());
     $this->assign('dateFormatTrunc', Config::getVar('general', 'date_format_trunc'));
     $this->assign('dateFormatShort', Config::getVar('general', 'date_format_short'));
     $this->assign('dateFormatLong', Config::getVar('general', 'date_format_long'));
     $this->assign('datetimeFormatShort', Config::getVar('general', 'datetime_format_short'));
     $this->assign('datetimeFormatLong', Config::getVar('general', 'datetime_format_long'));
     $this->assign('timeFormat', Config::getVar('general', 'time_format'));
     $this->assign('allowCDN', Config::getVar('general', 'enable_cdn'));
     $locale = AppLocale::getLocale();
     $this->assign('currentLocale', $locale);
     // If there's a locale-specific stylesheet, add it.
     if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) {
         $this->addStyleSheet($request->getBaseUrl() . '/' . $localeStyleSheet);
     }
     $application =& PKPApplication::getApplication();
     $this->assign('pageTitle', $application->getNameKey());
     // Register custom functions
     $this->register_modifier('translate', array('AppLocale', 'translate'));
     $this->register_modifier('get_value', array(&$this, 'smartyGetValue'));
     $this->register_modifier('strip_unsafe_html', array('String', 'stripUnsafeHtml'));
     $this->register_modifier('String_substr', array('String', 'substr'));
     $this->register_modifier('to_array', array(&$this, 'smartyToArray'));
     $this->register_modifier('concat', array(&$this, 'smartyConcat'));
     $this->register_modifier('escape', array(&$this, 'smartyEscape'));
     $this->register_modifier('strtotime', array(&$this, 'smartyStrtotime'));
     $this->register_modifier('explode', array(&$this, 'smartyExplode'));
     $this->register_modifier('assign', array(&$this, 'smartyAssign'));
     $this->register_function('translate', array(&$this, 'smartyTranslate'));
     $this->register_function('flush', array(&$this, 'smartyFlush'));
     $this->register_function('call_hook', array(&$this, 'smartyCallHook'));
     $this->register_function('html_options_translate', array(&$this, 'smartyHtmlOptionsTranslate'));
     $this->register_block('iterate', array(&$this, 'smartyIterate'));
     $this->register_function('call_progress_function', array(&$this, 'smartyCallProgressFunction'));
     $this->register_function('page_links', array(&$this, 'smartyPageLinks'));
     $this->register_function('page_info', array(&$this, 'smartyPageInfo'));
     $this->register_function('get_help_id', array(&$this, 'smartyGetHelpId'));
     $this->register_function('icon', array(&$this, 'smartyIcon'));
     $this->register_function('help_topic', array(&$this, 'smartyHelpTopic'));
     $this->register_function('sort_heading', array(&$this, 'smartySortHeading'));
     $this->register_function('sort_search', array(&$this, 'smartySortSearch'));
     $this->register_function('get_debug_info', array(&$this, 'smartyGetDebugInfo'));
     $this->register_function('assign_mailto', array(&$this, 'smartyAssignMailto'));
     $this->register_function('display_template', array(&$this, 'smartyDisplayTemplate'));
     $this->register_modifier('truncate', array(&$this, 'smartyTruncate'));
     // JS UI components
     $this->register_function('load_div', array(&$this, 'smartyLoadUrlInDiv'));
     $this->register_function('modal', array(&$this, 'smartyModal'));
     $this->register_function('confirm', array(&$this, 'smartyConfirm'));
     $this->register_function('ajax_upload', array(&$this, 'smartyAjaxUpload'));
     $this->register_function('init_tabs', array(&$this, 'smartyInitTabs'));
     // register the resource name "core"
     $this->register_resource("core", array(array(&$this, 'smartyResourceCoreGetTemplate'), array(&$this, 'smartyResourceCoreGetTimestamp'), array(&$this, 'smartyResourceCoreGetSecure'), array(&$this, 'smartyResourceCoreGetTrusted')));
     $this->register_function('url', array(&$this, 'smartyUrl'));
     // ajax load into a div
     $this->register_function('load_url_in_div', array(&$this, 'smartyLoadUrlInDiv'));
     if (!defined('SESSION_DISABLE_INIT')) {
         /**
          * Kludge to make sure no code that tries to connect to
          * the database is executed (e.g., when loading
          * installer pages).
          */
         $this->assign('isUserLoggedIn', Validation::isLoggedIn());
         $versionDAO =& DAORegistry::getDAO('VersionDAO');
         $currentVersion = $versionDAO->getCurrentVersion();
         $this->assign('currentVersionString', $currentVersion->getVersionString());
         $this->assign('itemsPerPage', Config::getVar('interface', 'items_per_page'));
         $this->assign('numPageLinks', Config::getVar('interface', 'page_links'));
     }
     $this->initialized = false;
 }
 /**
  * Initialize the template manager.
  */
 function initialize()
 {
     $locale = AppLocale::getLocale();
     $application = PKPApplication::getApplication();
     $router = $this->_request->getRouter();
     assert(is_a($router, 'PKPRouter'));
     $this->assign(array('defaultCharset' => Config::getVar('i18n', 'client_charset'), 'basePath' => $this->_request->getBasePath(), 'baseUrl' => $this->_request->getBaseUrl(), 'requiresFormRequest' => $this->_request->isPost(), 'currentUrl' => $this->_request->getCompleteUrl(), 'dateFormatTrunc' => Config::getVar('general', 'date_format_trunc'), 'dateFormatShort' => Config::getVar('general', 'date_format_short'), 'dateFormatLong' => Config::getVar('general', 'date_format_long'), 'datetimeFormatShort' => Config::getVar('general', 'datetime_format_short'), 'datetimeFormatLong' => Config::getVar('general', 'datetime_format_long'), 'timeFormat' => Config::getVar('general', 'time_format'), 'allowCDN' => Config::getVar('general', 'enable_cdn'), 'useMinifiedJavaScript' => Config::getVar('general', 'enable_minified'), 'currentContext' => $this->_request->getContext(), 'currentLocale' => $locale, 'pageTitle' => $application->getNameKey(), 'applicationName' => __($application->getNameKey()), 'exposedConstants' => $application->getExposedConstants(), 'jsLocaleKeys' => $application->getJSLocaleKeys()));
     if (is_a($router, 'PKPPageRouter')) {
         $this->assign(array('requestedPage' => $router->getRequestedPage($this->_request), 'requestedOp' => $router->getRequestedOp($this->_request)));
     }
     if ($dispatcher = $this->_request->getDispatcher()) {
         $this->addStyleSheet($dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'page.PageHandler', 'css'), STYLE_SEQUENCE_CORE, 'backend');
     }
     // If there's a locale-specific stylesheet, add it.
     if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) {
         $this->addStyleSheet($this->_request->getBaseUrl() . '/' . $localeStyleSheet, 'backend');
     }
     // Register custom functions
     $this->register_modifier('translate', array('AppLocale', 'translate'));
     $this->register_modifier('strip_unsafe_html', array('PKPString', 'stripUnsafeHtml'));
     $this->register_modifier('String_substr', array('PKPString', 'substr'));
     $this->register_modifier('to_array', array($this, 'smartyToArray'));
     $this->register_modifier('compare', array($this, 'smartyCompare'));
     $this->register_modifier('concat', array($this, 'smartyConcat'));
     $this->register_modifier('strtotime', array($this, 'smartyStrtotime'));
     $this->register_modifier('explode', array($this, 'smartyExplode'));
     $this->register_modifier('assign', array($this, 'smartyAssign'));
     $this->register_function('translate', array($this, 'smartyTranslate'));
     $this->register_function('null_link_action', array($this, 'smartyNullLinkAction'));
     $this->register_function('help', array($this, 'smartyHelp'));
     $this->register_function('flush', array($this, 'smartyFlush'));
     $this->register_function('call_hook', array($this, 'smartyCallHook'));
     $this->register_function('html_options_translate', array($this, 'smartyHtmlOptionsTranslate'));
     $this->register_block('iterate', array($this, 'smartyIterate'));
     $this->register_function('page_links', array($this, 'smartyPageLinks'));
     $this->register_function('page_info', array($this, 'smartyPageInfo'));
     $this->register_function('pluck_files', array($this, 'smartyPluckFiles'));
     // Modified vocabulary for creating forms
     $fbv = $this->getFBV();
     $this->register_block('fbvFormSection', array($fbv, 'smartyFBVFormSection'));
     $this->register_block('fbvFormArea', array($fbv, 'smartyFBVFormArea'));
     $this->register_function('fbvFormButtons', array($fbv, 'smartyFBVFormButtons'));
     $this->register_function('fbvElement', array($fbv, 'smartyFBVElement'));
     $this->assign('fbvStyles', $fbv->getStyles());
     $this->register_function('fieldLabel', array($fbv, 'smartyFieldLabel'));
     // register the resource name "core"
     $coreResource = new PKPTemplateResource($this->core_template_dir);
     $this->register_resource('core', array(array($coreResource, 'fetch'), array($coreResource, 'fetchTimestamp'), array($coreResource, 'getSecure'), array($coreResource, 'getTrusted')));
     $appResource = new PKPTemplateResource($this->app_template_dir);
     $this->register_resource('app', array(array($appResource, 'fetch'), array($appResource, 'fetchTimestamp'), array($appResource, 'getSecure'), array($appResource, 'getTrusted')));
     $this->register_function('url', array($this, 'smartyUrl'));
     // ajax load into a div or any element
     $this->register_function('load_url_in_el', array($this, 'smartyLoadUrlInEl'));
     $this->register_function('load_url_in_div', array($this, 'smartyLoadUrlInDiv'));
     // load stylesheets from a given context
     $this->register_function('load_stylesheet', array($this, 'smartyLoadStylesheet'));
     /**
      * Kludge to make sure no code that tries to connect to the
      * database is executed (e.g., when loading installer pages).
      */
     if (!defined('SESSION_DISABLE_INIT')) {
         $application = PKPApplication::getApplication();
         $currentVersion = $application->getCurrentVersion();
         $this->assign(array('isUserLoggedIn' => Validation::isLoggedIn(), 'isUserLoggedInAs' => Validation::isLoggedInAs(), 'currentVersionString' => $currentVersion->getVersionString(false), 'itemsPerPage' => Config::getVar('interface', 'items_per_page'), 'numPageLinks' => Config::getVar('interface', 'page_links')));
         $user = $this->_request->getUser();
         $hasSystemNotifications = false;
         if ($user) {
             $notificationDao = DAORegistry::getDAO('NotificationDAO');
             $notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL);
             if ($notifications->getCount() > 0) {
                 $this->assign('hasSystemNotifications', true);
             }
             // Assign the user name to be used in the sitenav
             $this->assign(array('loggedInUsername' => $user->getUserName(), 'initialHelpState' => (int) $user->getInlineHelp()));
         }
     }
     // Load enabled block plugins and setup active sidebar variables
     PluginRegistry::loadCategory('blocks', true);
     $leftSidebarHooks = HookRegistry::getHooks('Templates::Common::LeftSidebar');
     $this->assign(array('hasLeftSidebar' => !empty($leftSidebarHooks)));
 }