Ejemplo n.º 1
0
 /**
  * Get the compiled CSS
  * @param $args array
  * @param $request PKPRequest
  */
 function css($args, $request)
 {
     header('Content-Type: text/css');
     $stylesheetName = $request->getUserVar('name');
     switch ($stylesheetName) {
         case '':
         case null:
             $cacheDirectory = CacheManager::getFileCachePath();
             $compiledStylesheetFile = $cacheDirectory . '/compiled.css';
             if (!file_exists($compiledStylesheetFile)) {
                 // Generate the stylesheet file
                 require_once 'lib/pkp/lib/vendor/oyejorge/less.php/lessc.inc.php';
                 $less = new Less_Parser(array('relativeUrls' => false));
                 $less->parseFile('styles/index.less');
                 $compiledStyles = str_replace('{$baseUrl}', $request->getBaseUrl(true), $less->getCss());
                 // Allow plugins to intervene in stylesheet compilation
                 HookRegistry::call('PageHandler::compileCss', array($request, $less, &$compiledStylesheetFile, &$compiledStyles));
                 if (file_put_contents($compiledStylesheetFile, $compiledStyles) === false) {
                     // If the stylesheet cache can't be written, log the error and
                     // output the compiled styles directly without caching.
                     error_log("Unable to write \"{$compiledStylesheetFile}\".");
                     echo $compiledStyles;
                     return;
                 }
             }
             // Allow plugins to intervene in stylesheet display
             HookRegistry::call('PageHandler::displayCoreCss', array($request, &$compiledStylesheetFile));
             // Display the styles
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($compiledStylesheetFile)) . ' GMT');
             header('Content-Length: ' . filesize($compiledStylesheetFile));
             readfile($compiledStylesheetFile);
             break;
         default:
             // Allow plugins to intervene
             $result = null;
             $lastModified = null;
             TemplateManager::getManager($request);
             // Trigger loading of the themes plugins
             if (!HookRegistry::call('PageHandler::displayCss', array($request, &$stylesheetName, &$result, &$lastModified))) {
                 if ($lastModified) {
                     header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastModified) . ' GMT');
                 }
                 header('Content-Length: ' . strlen($result));
                 echo $result;
             }
     }
 }
Ejemplo n.º 2
0
 /**
  * Constructor.
  * Initialize template engine and assign basic template variables.
  * @param $request PKPRequest
  */
 function PKPTemplateManager($request)
 {
     assert(is_a($request, 'PKPRequest'));
     $this->_request = $request;
     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';
     $this->_cacheability = CACHEABILITY_NO_STORE;
     // Safe default
     // Are we using implicit authentication?
     $this->assign('implicitAuth', Config::getVar('security', 'implicit_auth'));
 }
Ejemplo n.º 3
0
 /**
  * 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->javaScripts = array();
     $this->cacheability = CACHEABILITY_NO_STORE;
     // Safe default
     $this->assign('defaultCharset', Config::getVar('i18n', 'client_charset'));
     $this->assign('basePath', $request->getBasePath());
     $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'));
     $this->assign('useMinifiedJavaScript', Config::getVar('general', 'enable_minified'));
     $locale = Locale::getLocale();
     $this->assign('currentLocale', $locale);
     // If there's a locale-specific stylesheet, add it.
     if (($localeStyleSheet = Locale::getLocaleStyleSheet($locale)) != null) {
         $this->addStyleSheet($request->getBaseUrl() . '/' . $localeStyleSheet);
     }
     $application =& PKPApplication::getApplication();
     $this->assign('pageTitle', $application->getNameKey());
     // Register custom functions
     $this->register_modifier('translate', array('Locale', '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('modal', array(&$this, 'smartyModal'));
     $this->register_function('confirm', array(&$this, 'smartyConfirm'));
     $this->register_function('confirm_submit', array(&$this, 'smartyConfirmSubmit'));
     $this->register_function('init_tabs', array(&$this, 'smartyInitTabs'));
     $this->register_function('modal_title', array(&$this, 'smartyModalTitle'));
     // 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());
         $application =& PKPApplication::getApplication();
         $currentVersion =& $application->getCurrentVersion();
         $this->assign('currentVersionString', $currentVersion->getVersionString());
         $this->assign('itemsPerPage', Config::getVar('interface', 'items_per_page'));
         $this->assign('numPageLinks', Config::getVar('interface', 'page_links'));
         $user =& $request->getUser();
         if ($user) {
             $notificationDao =& DAORegistry::getDAO('NotificationDAO');
             $notifications =& $notificationDao->getNotificationsByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL);
             $notificationsArray =& $notifications->toArray();
             unset($notifications);
             foreach ($notificationsArray as $notification) {
                 $notificationDao->deleteNotificationById($notification->getId());
             }
             $this->assign('systemNotifications', $notificationsArray);
         }
     }
     $this->initialized = false;
 }
Ejemplo n.º 4
0
 /**
  * Get the HTML contents for this block.
  * @param $templateMgr object
  * @return $string
  */
 function getContents(&$templateMgr)
 {
     $journal =& Request::getJournal();
     if (!$journal) {
         return '';
     }
     $journalId = $journal->getId();
     $plugin =& $this->getExternalFeedPlugin();
     if (!$plugin->getEnabled()) {
         return '';
     }
     $requestedPage = Request::getRequestedPage();
     $externalFeedDao =& DAORegistry::getDAO('ExternalFeedDAO');
     $plugin->import('simplepie.SimplePie');
     $feeds =& $externalFeedDao->getExternalFeedsByJournalId($journal->getId());
     while ($currentFeed =& $feeds->next()) {
         $displayBlock = $currentFeed->getDisplayBlock();
         if ($displayBlock == EXTERNAL_FEED_DISPLAY_BLOCK_NONE || $displayBlock == EXTERNAL_FEED_DISPLAY_BLOCK_HOMEPAGE && !empty($requestedPage) && $requestedPage != 'index') {
             continue;
         }
         $feed =& new SimplePie();
         $feed->set_feed_url($currentFeed->getUrl());
         $feed->enable_order_by_date(false);
         $feed->set_cache_location(CacheManager::getFileCachePath());
         $feed->init();
         if ($currentFeed->getLimitItems()) {
             $recentItems = $currentFeed->getRecentItems();
         } else {
             $recentItems = 0;
         }
         $externalFeeds[] = array('title' => $currentFeed->getLocalizedTitle(), 'items' => $feed->get_items(0, $recentItems));
     }
     if (!isset($externalFeeds)) {
         return '';
     }
     $templateMgr->assign_by_ref('externalFeeds', $externalFeeds);
     return parent::getContents($templateMgr);
 }
Ejemplo n.º 5
0
 /**
  * Display external feed content on journal homepage.
  * @param $hookName string
  * @param $args array
  */
 function displayHomepage($hookName, $args)
 {
     $request = $this->getRequest();
     $journal = $request->getJournal();
     $journalId = $journal ? $journal->getId() : 0;
     if ($this->getEnabled()) {
         $requestedPage = $request->getRequestedPage();
         if (empty($requestedPage) || $requestedPage == 'index') {
             $externalFeedDao = DAORegistry::getDAO('ExternalFeedDAO');
             $this->import('simplepie.SimplePie');
             $feeds =& $externalFeedDao->getExternalFeedsByJournalId($journal->getId());
             $output = '<div id="externalFeedsHome">';
             while ($currentFeed = $feeds->next()) {
                 if (!$currentFeed->getDisplayHomepage()) {
                     continue;
                 }
                 $feed = new SimplePie();
                 $feed->set_feed_url($currentFeed->getUrl());
                 $feed->enable_order_by_date(false);
                 $feed->set_cache_location(CacheManager::getFileCachePath());
                 $feed->init();
                 if ($currentFeed->getLimitItems()) {
                     $recentItems = $currentFeed->getRecentItems();
                 } else {
                     $recentItems = 0;
                 }
                 $output .= '<h3>' . $currentFeed->getLocalizedTitle() . '</h3>';
                 $output .= '<table class="externalFeeds">';
                 $output .= '<tr>';
                 $output .= '<td colspan="2" class="headseparator">&nbsp;</td>';
                 $output .= '</tr>';
                 $separator = '';
                 foreach ($feed->get_items(0, $recentItems) as $item) {
                     $output .= $separator;
                     $output .= '<tr class="title">';
                     $output .= '<td colspan="2" class="title">';
                     $output .= '<h4>' . $item->get_title() . '</h4>';
                     $output .= '</td>';
                     $output .= '</tr>';
                     $output .= '<tr class="description">';
                     $output .= '<td colspan="2" class="description">';
                     $output .= $item->get_description();
                     $output .= '</td>';
                     $output .= '</tr>';
                     $output .= '<tr class="details">';
                     $output .= '<td class="posted">';
                     $output .= AppLocale::Translate('plugins.generic.externalFeed.posted') . ': ' . date('Y-m-d', strtotime($item->get_date()));
                     $output .= '</td>';
                     $output .= '<td class="more">';
                     $output .= '<a href="' . $item->get_permalink() . '" target="_blank">' . AppLocale::Translate('plugins.generic.externalFeed.more') . '</a>';
                     $output .= '</td>';
                     $output .= '</tr>';
                     $separator = '<tr><td colspan="2" class="separator">&nbsp;</td></tr>';
                 }
                 $output .= '<tr><td colspan="2" class="endseparator">&nbsp;</td></tr>';
                 $output .= '</table>';
             }
             $output .= '</div>';
             $templateManager =& $args[0];
             $additionalHomeContent = $templateManager->get_template_vars('additionalHomeContent');
             $templateManager->assign('additionalHomeContent', $additionalHomeContent . "\n\n" . $output);
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * Configure the caching directory for database results
  * NOTE: This is implemented as a GLOBAL setting and cannot
  * be set on a per-connection basis.
  */
 function setCacheDir()
 {
     static $cacheDir;
     if (!isset($cacheDir)) {
         global $ADODB_CACHE_DIR;
         $cacheDir = CacheManager::getFileCachePath() . '/_db';
         $ADODB_CACHE_DIR = $cacheDir;
     }
 }
Ejemplo n.º 7
0
 /**
  * Clear all compiled CSS files
  */
 public function clearCssCache()
 {
     $cacheDirectory = CacheManager::getFileCachePath();
     $files = scandir($cacheDirectory);
     array_map('unlink', glob(CacheManager::getFileCachePath() . DIRECTORY_SEPARATOR . '*.' . CSS_FILENAME_SUFFIX));
 }
 /**
  * Called as a callback upon stylesheet compilation.
  * Used to inject this theme's styles.
  */
 function _displayCssCallback($hookName, $args)
 {
     $request = $args[0];
     $stylesheetName = $args[1];
     $result =& $args[2];
     $lastModified =& $args[3];
     // Ensure the callback is for this plugin before intervening
     if ($stylesheetName != $this->getName()) {
         return false;
     }
     if ($this->getLessStylesheet()) {
         $cacheDirectory = CacheManager::getFileCachePath();
         $cacheFilename = $this->getStyleCacheFilename();
         $lessFile = $this->getPluginPath() . '/' . $this->getLessStylesheet();
         $compiledStylesheetFile = $cacheDirectory . '/' . $cacheFilename;
         if ($cacheFilename === null || !file_exists($compiledStylesheetFile)) {
             // Need to recompile, so flag last modified.
             $lastModified = time();
             // Compile this theme's styles
             require_once 'lib/pkp/lib/vendor/oyejorge/less.php/lessc.inc.php';
             $less = new Less_Parser(array('relativeUrls' => false));
             $less->parseFile($lessFile);
             $compiledStyles = str_replace('{$baseUrl}', $request->getBaseUrl(), $less->getCss());
             // Give other plugins the chance to intervene
             HookRegistry::call('ThemePlugin::compileCss', array($request, $less, &$compiledStylesheetFile, &$compiledStyles));
             if ($cacheFilename === null || file_put_contents($compiledStylesheetFile, $compiledStyles) === false) {
                 // If the stylesheet cache can't be written, log the error and
                 // output the compiled styles directly without caching.
                 error_log("Unable to write \"{$compiledStylesheetFile}\".");
                 $result .= $compiledStyles;
                 return false;
             }
         } else {
             // We were able to fall back on a previously compiled file. Set lastModified.
             $cacheLastModified = filemtime($compiledStylesheetFile);
             $lastModified = $lastModified === null ? $cacheLastModified : min($lastModified, $cacheLastModified);
         }
         // Add the compiled styles to the rest
         $result .= "\n" . file_get_contents($compiledStylesheetFile);
     }
     return false;
 }
Ejemplo n.º 9
0
 /**
  * Output PDF generated from the XML/XSL/FO source to browser
  * This function performs any necessary filtering, like image URL replacement.
  * @return string
  */
 function viewFileContents()
 {
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     $pdfFileName = CacheManager::getFileCachePath() . DIRECTORY_SEPARATOR . 'fc-xsltGalley-' . str_replace($fileManager->parseFileExtension($this->getFileName()), 'pdf', $this->getFileName());
     // if file does not exist or is outdated, regenerate it from FO
     if (!$fileManager->fileExists($pdfFileName) || filemtime($pdfFileName) < filemtime($this->getFilePath())) {
         // render XML into XSL-FO
         $cache =& $this->_getXSLTCache($this->getFileName() . '-' . $this->getId());
         $contents = $cache->getContents();
         if ($contents == "") {
             return false;
         }
         // if for some reason the XSLT failed, show original file
         // Replace image references
         $images =& $this->getImageFiles();
         if ($images !== null) {
             // TODO: this should "smart replace" the file path ($this->getFilePath()) in the XSL-FO
             // in lieu of requiring XSL parameters, and transparently for FO that are hardcoded
             foreach ($images as $image) {
                 $contents = preg_replace('/src\\s*=\\s*"([^"]*)' . preg_quote($image->getOriginalFileName()) . '([^"]*)"/i', 'src="${1}' . dirname($this->getFilePath()) . DIRECTORY_SEPARATOR . $image->getFileName() . '$2"', $contents);
             }
         }
         // Replace supplementary file references
         $this->suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
         $suppFiles = $this->suppFileDao->getSuppFilesByArticle($this->getArticleId());
         if ($suppFiles) {
             $journal =& Request::getJournal();
             foreach ($suppFiles as $supp) {
                 $suppUrl = Request::url(null, 'article', 'downloadSuppFile', array($this->getArticleId(), $supp->getBestSuppFileId($journal)));
                 $contents = preg_replace('/external-destination\\s*=\\s*"([^"]*)' . preg_quote($supp->getOriginalFileName()) . '([^"]*)"/i', 'external-destination="' . $suppUrl . '"', $contents);
             }
         }
         // create temporary FO file and write the contents
         import('classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $tempFoName = $temporaryFileManager->filesDir . $this->getFileName() . '-' . $this->getId() . '.fo';
         $temporaryFileManager->writeFile($tempFoName, $contents);
         // perform %fo and %pdf replacements for fully-qualified shell command
         $journal =& Request::getJournal();
         $xmlGalleyPlugin =& PluginRegistry::getPlugin('generic', $this->parentPluginName);
         $fopCommand = str_replace(array('%fo', '%pdf'), array($tempFoName, $pdfFileName), $xmlGalleyPlugin->getSetting($journal->getId(), 'externalFOP'));
         // check for safe mode and escape the shell command
         if (!ini_get('safe_mode')) {
             $fopCommand = escapeshellcmd($fopCommand);
         }
         // run the shell command and get the results
         exec($fopCommand . ' 2>&1', $contents, $status);
         // if there is an error, spit out the shell results to aid debugging
         if ($status != false) {
             if ($contents != '') {
                 echo implode("\n", $contents);
                 $cache->flush();
                 // clear the XSL cache in case it's a FO error
                 return true;
             } else {
                 return false;
             }
         }
         // clear the temporary FO file
         $fileManager->deleteFile($tempFoName);
     }
     // use FileManager to send file to browser
     $fileManager->downloadFile($pdfFileName, $this->getFileType(), true);
     return true;
 }
Ejemplo n.º 10
0
 /**
  * Get the path to the index storage
  * @return string
  */
 function getIndexPath()
 {
     return CacheManager::getFileCachePath() . DIRECTORY_SEPARATOR . 'recordsIndex';
 }
Ejemplo n.º 11
0
 * importing class files.
 */
function normalizeMockEnvironment($mockEnv)
{
    if (substr($mockEnv, 0, 1) != '/') {
        $mockEnv = getcwd() . '/' . $mockEnv;
    }
    if (!is_dir($mockEnv)) {
        $mockEnv = dirname($mockEnv);
    }
    $mockEnv = realpath($mockEnv);
    // Test whether this is a valid directory.
    if (is_dir($mockEnv)) {
        return $mockEnv;
    } else {
        // Make sure that we do not try to
        // identify a mock env again but mark
        // it as "not found".
        return false;
    }
}
// Set up minimal PKP application environment
require_once './lib/pkp/includes/bootstrap.inc.php';
// Make sure ADOdb doesn't "clean up" our /tmp folder.
$ADODB_CACHE_DIR = CacheManager::getFileCachePath() . DIRECTORY_SEPARATOR . '_db';
// Remove the PKP error handler so that PHPUnit
// can set it's own error handler and catch errors for us.
restore_error_handler();
error_reporting(E_ALL & ~E_STRICT);
// Show errors in the UI
ini_set('display_errors', true);
Ejemplo n.º 12
0
 /**
  * Constructor.
  * Initialize template engine and assign basic template variables.
  */
 function TemplateManager()
 {
     parent::Smarty();
     import('file.PublicFileManager');
     import('cache.CacheManager');
     // Set up Smarty configuration
     $baseDir = Core::getBaseDir();
     $cachePath = CacheManager::getFileCachePath();
     $this->template_dir = $baseDir . DIRECTORY_SEPARATOR . 'templates';
     $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('pageTitle', 'common.openJournalSystems');
     $this->assign('requestedPage', Request::getRequestedPage());
     $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'));
     // Are we using implicit authentication?
     $this->assign('implicitAuth', Config::getVar('security', 'implicit_auth'));
     $locale = Locale::getLocale();
     $this->assign('currentLocale', $locale);
     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());
         $journal =& Request::getJournal();
         $site =& Request::getSite();
         $versionDAO =& DAORegistry::getDAO('VersionDAO');
         $currentVersion = $versionDAO->getCurrentVersion();
         $this->assign('currentVersionString', $currentVersion->getVersionString());
         $siteFilesDir = Request::getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath();
         $this->assign('sitePublicFilesDir', $siteFilesDir);
         $this->assign('publicFilesDir', $siteFilesDir);
         // May be overridden by journal
         $siteStyleFilename = PublicFileManager::getSiteFilesPath() . '/' . $site->getSiteStyleFilename();
         if (file_exists($siteStyleFilename)) {
             $this->addStyleSheet(Request::getBaseUrl() . '/' . $siteStyleFilename);
         }
         if (isset($journal)) {
             $this->assign_by_ref('currentJournal', $journal);
             $journalTitle = $journal->getJournalTitle();
             $this->assign('siteTitle', $journalTitle);
             $this->assign('publicFilesDir', Request::getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getJournalId()));
             $this->assign('primaryLocale', $journal->getPrimaryLocale());
             $this->assign('alternateLocales', $journal->getSetting('alternateLocales'));
             // Assign additional navigation bar items
             $navMenuItems =& $journal->getLocalizedSetting('navItems');
             $this->assign_by_ref('navMenuItems', $navMenuItems);
             // Assign journal page header
             $this->assign('displayPageHeaderTitle', $journal->getJournalPageHeaderTitle());
             $this->assign('displayPageHeaderLogo', $journal->getJournalPageHeaderLogo());
             $this->assign('alternatePageHeader', $journal->getLocalizedSetting('journalPageHeader'));
             $this->assign('metaSearchDescription', $journal->getLocalizedSetting('searchDescription'));
             $this->assign('metaSearchKeywords', $journal->getLocalizedSetting('searchKeywords'));
             $this->assign('metaCustomHeaders', $journal->getLocalizedSetting('customHeaders'));
             $this->assign('numPageLinks', $journal->getSetting('numPageLinks'));
             $this->assign('itemsPerPage', $journal->getSetting('itemsPerPage'));
             $this->assign('enableAnnouncements', $journal->getSetting('enableAnnouncements'));
             // Load and apply theme plugin, if chosen
             $themePluginPath = $journal->getSetting('journalTheme');
             if (!empty($themePluginPath)) {
                 // Load and activate the theme
                 $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath);
                 if ($themePlugin) {
                     $themePlugin->activate($this);
                 }
             }
             // Assign stylesheets and footer
             $journalStyleSheet = $journal->getSetting('journalStyleSheet');
             if ($journalStyleSheet) {
                 $this->addStyleSheet(Request::getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getJournalId()) . '/' . $journalStyleSheet['uploadName']);
             }
             import('payment.ojs.OJSPaymentManager');
             $paymentManager =& OJSPaymentManager::getManager();
             $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured());
             $this->assign('pageFooter', $journal->getLocalizedSetting('journalPageFooter'));
         } else {
             // Add the site-wide logo, if set for this locale or the primary locale
             $this->assign('displayPageHeaderTitle', $site->getSitePageHeaderTitle());
             $this->assign('siteTitle', $site->getSiteTitle());
             $this->assign('itemsPerPage', Config::getVar('interface', 'items_per_page'));
             $this->assign('numPageLinks', Config::getVar('interface', 'page_links'));
         }
         if (!$site->getJournalRedirect()) {
             $this->assign('hasOtherJournals', true);
         }
     }
     // If there's a locale-specific stylesheet, add it.
     if (($localeStyleSheet = Locale::getLocaleStyleSheet($locale)) != null) {
         $this->addStyleSheet(Request::getBaseUrl() . '/' . $localeStyleSheet);
     }
     // Register custom functions
     $this->register_modifier('translate', array('Locale', '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('escape', array(&$this, 'smartyEscape'));
     $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('get_debug_info', array(&$this, 'smartyGetDebugInfo'));
     $this->register_function('assign_mailto', array(&$this, 'smartyAssignMailto'));
     $this->register_function('display_template', array(&$this, 'smartyDisplayTemplate'));
     $this->register_function('url', array(&$this, 'smartyUrl'));
     $this->initialized = false;
 }