| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /inetpub/wwwroot/Topogeo/ojs/classes/template/ |
Upload File : |
<?php
/**
* @file classes/template/TemplateManager.inc.php
*
* Copyright (c) 2003-2012 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class TemplateManager
* @ingroup template
*
* @brief Class for accessing the underlying template engine.
* Currently integrated with Smarty (from http://smarty.php.net/).
*
*/
import('classes.search.ArticleSearch');
import('classes.file.PublicFileManager');
import('lib.pkp.classes.template.PKPTemplateManager');
class TemplateManager extends PKPTemplateManager {
/**
* Constructor.
* Initialize template engine and assign basic template variables.
* @param $request PKPRequest FIXME: is optional for backwards compatibility only - make mandatory
*/
function TemplateManager($request = null) {
// FIXME: for backwards compatibility only - remove
if (!isset($request)) {
// FIXME: Trigger a deprecation warning when enough instances of this
// call have been fixed to not clutter the error log.
$request =& Registry::get('request');
}
assert(is_a($request, 'PKPRequest'));
parent::PKPTemplateManager($request);
// Retrieve the router
$router =& $request->getRouter();
assert(is_a($router, 'PKPRouter'));
// Are we using implicit authentication?
$this->assign('implicitAuth', Config::getVar('security', 'implicit_auth'));
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).
*/
$journal =& $router->getContext($request);
$site =& $request->getSite();
$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);
$this->assign('homeContext', array());
if (isset($journal)) {
$this->assign_by_ref('currentJournal', $journal);
$journalTitle = $journal->getLocalizedTitle();
$this->assign('siteTitle', $journalTitle);
$this->assign('publicFilesDir', $request->getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getId()));
$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->getLocalizedPageHeaderTitle());
$this->assign('displayPageHeaderLogo', $journal->getLocalizedPageHeaderLogo());
$this->assign('displayPageHeaderTitleAltText', $journal->getLocalizedSetting('pageHeaderTitleImageAltText'));
$this->assign('displayPageHeaderLogoAltText', $journal->getLocalizedSetting('pageHeaderLogoImageAltText'));
$this->assign('displayFavicon', $journal->getLocalizedFavicon());
$this->assign('faviconDir', $request->getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getId()));
$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'));
$this->assign(
'hideRegisterLink',
!$journal->getSetting('allowRegReviewer') &&
!$journal->getSetting('allowRegReader') &&
!$journal->getSetting('allowRegAuthor')
);
// 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->getId()) . '/' . $journalStyleSheet['uploadName']);
}
import('classes.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
$displayPageHeaderTitle = $site->getLocalizedPageHeaderTitle();
$this->assign('displayPageHeaderTitle', $displayPageHeaderTitle);
if (isset($displayPageHeaderTitle['altText'])) $this->assign('displayPageHeaderTitleAltText', $displayPageHeaderTitle['altText']);
$this->assign('siteTitle', $site->getLocalizedTitle());
}
if (!$site->getRedirect()) {
$this->assign('hasOtherJournals', true);
}
// Add java script for notifications
$user =& $request->getUser();
if ($user) $this->addJavaScript('lib/pkp/js/jquery.pnotify.js');
}
}
/**
* Smarty usage: {get_help_id key="(dir)*.page.topic" url="boolean"}
*
* Custom Smarty function for retrieving help topic ids.
* Direct mapping of page topic key to a numerical value representing the associated help topic xml file
* @params $params array associative array, must contain "key" parameter for string to translate
* @params $smarty Smarty
* @return numerical help topic id
*/
function smartyGetHelpId($params, &$smarty) {
import('classes.help.Help');
$help =& Help::getHelp();
if (isset($params) && !empty($params)) {
if (isset($params['key'])) {
$key = $params['key'];
unset($params['key']);
$translatedKey = $help->translate($key);
} else {
$translatedKey = $help->translate('');
}
if ($params['url'] == "true") {
return Request::url(null, 'help', 'view', explode('/', $translatedKey));
} else {
return $translatedKey;
}
}
}
/**
* Smarty usage: {help_topic key="(dir)*.page.topic" text="foo"}
*
* Custom Smarty function for creating anchor tags
* @params $params array associative array
* @params $smarty Smarty
* @return anchor link to related help topic
*/
function smartyHelpTopic($params, &$smarty) {
import('classes.help.Help');
$help =& Help::getHelp();
if (isset($params) && !empty($params)) {
$translatedKey = isset($params['key']) ? $help->translate($params['key']) : $help->translate('');
$link = Request::url(null, 'help', 'view', explode('/', $translatedKey));
$text = isset($params['text']) ? $params['text'] : '';
return "<a href=\"$link\">$text</a>";
}
}
/**
* Display page links for a listing of items that has been
* divided onto multiple pages.
* Usage:
* {page_links
* name="nameMustMatchGetRangeInfoCall"
* iterator=$myIterator
* additional_param=myAdditionalParameterValue
* }
*/
function smartyPageLinks($params, &$smarty) {
$iterator = $params['iterator'];
$name = $params['name'];
if (isset($params['params']) && is_array($params['params'])) {
$extraParams = $params['params'];
unset($params['params']);
$params = array_merge($params, $extraParams);
}
if (isset($params['anchor'])) {
$anchor = $params['anchor'];
unset($params['anchor']);
} else {
$anchor = null;
}
if (isset($params['all_extra'])) {
$allExtra = ' ' . $params['all_extra'];
unset($params['all_extra']);
} else {
$allExtra = '';
}
unset($params['iterator']);
unset($params['name']);
$numPageLinks = $smarty->get_template_vars('numPageLinks');
if (!is_numeric($numPageLinks)) $numPageLinks=10;
$page = $iterator->getPage();
$pageCount = $iterator->getPageCount();
$itemTotal = $iterator->getCount();
$pageBase = max($page - floor($numPageLinks / 2), 1);
$paramName = $name . 'Page';
if ($pageCount<=1) return '';
$value = '';
if ($page>1) {
$params[$paramName] = 1;
$value .= '<a href="' . Request::url(null, null, null, Request::getRequestedArgs(), $params, $anchor, true) . '"' . $allExtra . '><<</a> ';
$params[$paramName] = $page - 1;
$value .= '<a href="' . Request::url(null, null, null, Request::getRequestedArgs(), $params, $anchor, true) . '"' . $allExtra . '><</a> ';
}
for ($i=$pageBase; $i<min($pageBase+$numPageLinks, $pageCount+1); $i++) {
if ($i == $page) {
$value .= "<strong>$i</strong> ";
} else {
$params[$paramName] = $i;
$value .= '<a href="' . Request::url(null, null, null, Request::getRequestedArgs(), $params, $anchor, true) . '"' . $allExtra . '>' . $i . '</a> ';
}
}
if ($page < $pageCount) {
$params[$paramName] = $page + 1;
$value .= '<a href="' . Request::url(null, null, null, Request::getRequestedArgs(), $params, $anchor, true) . '"' . $allExtra . '>></a> ';
$params[$paramName] = $pageCount;
$value .= '<a href="' . Request::url(null, null, null, Request::getRequestedArgs(), $params, $anchor, true) . '"' . $allExtra . '>>></a> ';
}
return $value;
}
}
?>