/** * Constructor. * * @access public */ public function __construct() { parent::__construct(); $this->cart = Cart_Model::getInstance(); }
/** * Constructor * * @param string $local Local directory for cache and compile * * @access public */ public function UInterface($local = '') { global $configArray; if (!$local) { $local = $configArray['Site']['local']; } $this->_vufindTheme = $configArray['Site']['theme']; // Use mobile theme for mobile devices (if enabled in config.ini) if (isset($configArray['Site']['mobile_theme'])) { // If the user is overriding the UI setting, store that: if (isset($_GET['ui'])) { $_COOKIE['ui'] = $_GET['ui']; setcookie('ui', $_GET['ui'], null, '/'); } else { if (!isset($_COOKIE['ui'])) { // If we don't already have a UI setting, detect if we're on a // mobile device and store the result in a cookie so we don't waste // time doing the detection routine on every page: $_COOKIE['ui'] = mobile_device_detect() ? 'mobile' : 'standard'; setcookie('ui', $_COOKIE['ui'], null, '/'); } } // If we're mobile, override the standard theme with the mobile one: if ($_COOKIE['ui'] == 'mobile') { $this->_vufindTheme = $configArray['Site']['mobile_theme']; } } // Check to see if multiple themes were requested; if so, build an array, // otherwise, store a single string. $themeArray = explode(',', $this->_vufindTheme); if (count($themeArray) > 1) { $this->template_dir = array(); foreach ($themeArray as $currentTheme) { $currentTheme = trim($currentTheme); $this->template_dir[] = "{$local}/interface/themes/{$currentTheme}"; } } else { $this->template_dir = "{$local}/interface/themes/{$this->_vufindTheme}"; } // Create an MD5 hash of the theme name -- this will ensure that it's a // writeable directory name (since some config.ini settings may include // problem characters like commas or whitespace). $md5 = md5($this->_vufindTheme); $this->compile_dir = "{$local}/interface/compile/{$md5}"; if (!is_dir($this->compile_dir)) { mkdir($this->compile_dir); } $this->cache_dir = "{$local}/interface/cache/{$md5}"; if (!is_dir($this->cache_dir)) { mkdir($this->cache_dir); } $this->plugins_dir = array('plugins', "{$local}/interface/plugins"); $this->caching = false; $this->debug = true; $this->compile_check = true; unset($local); $this->register_function('translate', 'translate'); $this->register_function('char', 'char'); $this->assign('site', $configArray['Site']); $this->assign('path', $configArray['Site']['path']); $this->assign('url', $configArray['Site']['url']); $this->assign('fullPath', isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false); $this->assign('supportEmail', $configArray['Site']['email']); $searchObject = SearchObjectFactory::initSearchObject(); $this->assign('basicSearchTypes', is_object($searchObject) ? $searchObject->getBasicTypes() : array()); $this->assign('autocomplete', is_object($searchObject) ? $searchObject->getAutocompleteStatus() : false); $this->assign('retainFiltersByDefault', $searchObject->getRetainFilterByDefaultSetting()); if (isset($configArray['Site']['showBookBag'])) { $this->assign('bookBag', $configArray['Site']['showBookBag'] ? Cart_Model::getInstance() : false); } if (isset($configArray['OpenURL']) && isset($configArray['OpenURL']['url'])) { // Trim off any parameters (for legacy compatibility -- default config // used to include extraneous parameters): list($base) = explode('?', $configArray['OpenURL']['url']); } else { $base = false; } $this->assign('openUrlBase', empty($base) ? false : $base); // Other OpenURL settings: $this->assign('openUrlWindow', empty($configArray['OpenURL']['window_settings']) ? false : $configArray['OpenURL']['window_settings']); $this->assign('openUrlGraphic', empty($configArray['OpenURL']['graphic']) ? false : $configArray['OpenURL']['graphic']); $this->assign('openUrlGraphicWidth', empty($configArray['OpenURL']['graphic_width']) ? false : $configArray['OpenURL']['graphic_width']); $this->assign('openUrlGraphicHeight', empty($configArray['OpenURL']['graphic_height']) ? false : $configArray['OpenURL']['graphic_height']); if (isset($configArray['OpenURL']['embed']) && !empty($configArray['OpenURL']['embed'])) { include_once 'sys/Counter.php'; $this->assign('openUrlEmbed', true); $this->assign('openUrlCounter', new Counter()); } $this->assign('currentTab', 'Search'); $this->assign('authMethod', $configArray['Authentication']['method']); if (isset($configArray['Authentication']['libraryCard']) && !$configArray['Authentication']['libraryCard']) { $this->assign('libraryCard', false); } else { $this->assign('libraryCard', true); } $this->assign('sidebarOnLeft', !isset($configArray['Site']['sidebarOnLeft']) ? false : $configArray['Site']['sidebarOnLeft']); $piwikUrl = isset($configArray['Piwik']['url']) ? $configArray['Piwik']['url'] : false; if ($piwikUrl && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $piwikUrl = preg_replace('/^http:/', 'https:', $piwikUrl); } $this->assign('piwikUrl', $piwikUrl); $this->assign('piwikSiteId', !isset($configArray['Piwik']['site_id']) ? false : $configArray['Piwik']['site_id']); // Create prefilter list $prefilters = getExtraConfigArray('prefilters'); if (isset($prefilters['Prefilters'])) { $filters = array(); foreach ($prefilters['Prefilters'] as $key => $filter) { $filters[$key] = $filter; } $this->assign('prefilterList', $filters); } if (isset($_REQUEST['prefiltered'])) { $this->assign('activePrefilter', $_REQUEST['prefiltered']); } $metalib = getExtraConfigArray('MetaLib'); if (!empty($metalib)) { $this->assign('metalibEnabled', isset($metalib['General']['enabled']) ? $metalib['General']['enabled'] : true); } $pci = getExtraConfigArray('PCI'); if (!empty($pci)) { $this->assign('pciEnabled', isset($pci['General']['enabled']) ? $pci['General']['enabled'] : true); } $rssFeeds = getExtraConfigArray('rss'); if (isset($rssFeeds)) { $this->assign('rssFeeds', $rssFeeds); } $catalog = ConnectionManager::connectToCatalog(); $this->assign("offlineMode", $catalog->getOfflineMode()); $hideLogin = isset($configArray['Authentication']['hideLogin']) ? $configArray['Authentication']['hideLogin'] : false; $this->assign("hideLogin", $hideLogin ? true : $catalog->loginIsHidden()); if (isset($configArray['Site']['development']) && $configArray['Site']['development']) { $this->assign('developmentSite', true); } if (isset($configArray['Site']['dualResultsEnabled']) && $configArray['Site']['dualResultsEnabled']) { $this->assign('dualResultsEnabled', true); } // Resolve enabled context-help ids $contextHelp = array(); if (isset($configArray['ContextHelp'])) { foreach ($configArray['ContextHelp'] as $key => $val) { if ((bool) $val) { $contextHelp[] = $key; } } } $this->assign('contextHelp', $contextHelp); // Set Advanced Search start year and scale // The default values: $advSearchYearScale = array(0, 900, 1800, 1910); $yearScale = !isset($configArray['Site']['advSearchYearScale']) ? false : $configArray['Site']['advSearchYearScale']; if (isset($yearScale)) { $scaleArray = explode(',', $yearScale); $i = count($scaleArray); // Do we have more values or just the starting year if ($i > 1) { $j = 0; if ($i <= 4) { while ($j < $i) { $advSearchYearScale[$j] = (int) $scaleArray[$j]; $j++; } } else { while ($j < 4) { $advSearchYearScale[$j] = (int) $scaleArray[$j]; $j++; } } } else { // Only the starting year is set $advSearchYearScale[0] = (int) $yearScale; } } $this->assign('advSearchYearScale', $advSearchYearScale); }