/** * Prepare and direct the home page where it needs to go * * @return mixed */ public function homeAction() { // Process login request, if necessary: if ($this->params()->fromPost('processLogin')) { try { $this->getAuthManager()->login($this->getRequest()); } catch (AuthException $e) { $this->flashMessenger()->setNamespace('error')->addMessage($e->getMessage()); } } // Not logged in? Force user to log in: if (!$this->getAuthManager()->isLoggedIn()) { return $this->forwardTo('MyResearch', 'Login'); } // Logged in? Forward user to followup action (if set) or default action // (if no followup provided): $followup = $this->followup()->retrieve(); if (isset($followup->url)) { $url = $followup->url; unset($followup->url); return $this->redirect()->toUrl($url); } $config = ConfigReader::getConfig(); $page = isset($configArray->Site->defaultAccountPage) ? $configArray->Site->defaultAccountPage : 'Favorites'; return $this->forwardTo('MyResearch', $page); }
/** * Shared OAI logic. * * @param string $serverClass Class to load for handling OAI requests. * * @return \Zend\Http\Response */ protected function handleOAI($serverClass) { // Check if the OAI Server is enabled before continuing $config = ConfigReader::getConfig(); $response = $this->getResponse(); if (!isset($config->OAI)) { $response->setStatusCode(404); $response->setContent('OAI Server Not Configured.'); return $response; } // Collect relevant parameters for OAI server: $url = explode('?', $this->getServerUrl()); $baseURL = $url[0]; // Build OAI response or die trying: try { $server = new $serverClass($this->getSearchManager(), $baseURL, $this->getRequest()->getQuery()->toArray()); $xml = $server->getResponse(); } catch (\Exception $e) { $response->setStatusCode(500); $response->setContent($e->getMessage()); return $response; } // Return response: $headers = $response->getHeaders(); $headers->addHeaderLine('Content-type', 'text/xml'); $response->setContent($xml); return $response; }
/** * Constructor * * @param \Zend\Mail\Transport\TransportInterface $transport Mail transport * object (we'll build our own if none is provided). * @param \Zend\Config\Config $config VuFind configuration * object (we'll auto-load if none is provided). */ public function __construct($transport = null, $config = null) { if (!is_null($transport)) { $this->setTransport($transport); } $this->config = is_null($config) ? ConfigReader::getConfig() : $config; }
/** * getSuggestions * * This returns an array of suggestions based on current request parameters. * This logic is present in the factory class so that it can be easily shared * by multiple AJAX handlers. * * @param \Zend\Stdlib\Parameters $request The user request * @param string $typeParam Request parameter containing search * type * @param string $queryParam Request parameter containing query * string * * @return array */ public function getSuggestions($request, $typeParam = 'type', $queryParam = 'q') { // Process incoming parameters: $type = $request->get($typeParam, ''); $query = $request->get($queryParam, ''); // get Autocomplete_Type config $searcher = $request->get('searcher', 'Solr'); $options = $this->getServiceLocator()->get('SearchManager')->setSearchClassId($searcher)->getOptionsInstance(); $config = ConfigReader::getConfig($options->getSearchIni()); $types = isset($config->Autocomplete_Types) ? $config->Autocomplete_Types->toArray() : array(); // Figure out which handler to use: if (!empty($type) && isset($types[$type])) { $module = $types[$type]; } else { if (isset($config->Autocomplete->default_handler)) { $module = $config->Autocomplete->default_handler; } else { $module = false; } } // Get suggestions: if ($module) { if (strpos($module, ':') === false) { $module .= ':'; // force colon to avoid warning in explode below } list($name, $params) = explode(':', $module, 2); $handler = $this->get($name); $handler->setConfig($params); } return isset($handler) && is_object($handler) ? array_values($handler->getSuggestions($query)) : array(); }
/** * Constructor */ public function __construct() { parent::__construct('http://www.worldcat.org/webservices/catalog/search/sru'); $config = ConfigReader::getConfig(); $this->wskey = isset($config->WorldCat->apiKey) ? $config->WorldCat->apiKey : null; $this->limitCodes = isset($config->WorldCat->LimitCodes) ? $config->WorldCat->LimitCodes : null; }
/** * Connect to the index. * * @param string $type Index type to connect to (null for standard Solr). * @param string $core Index core to use (null for default). * @param string $url Connection URL for index (null for config.ini default). * * @return object */ public static function connectToIndex($type = null, $core = null, $url = null) { $configArray = ConfigReader::getConfig(); // Load config.ini settings for missing parameters: if ($type == null) { $type = 'Solr'; } if ($url == null) { // Load appropriate default server URL based on index type: $url = $type == 'SolrStats' && isset($configArray->Statistics->solr) ? $configArray->Statistics->solr : $configArray->Index->url; } // Set appropriate default core if necessary: if (empty($core) && $type == 'Solr') { $core = isset($configArray->Index->default_core) ? $configArray->Index->default_core : "biblio"; } // Construct the object appropriately based on the $core setting: $class = 'VuFind\\Connection\\' . $type; if (empty($core)) { $index = new $class($url); } else { $index = new $class($url, $core); } // Set the service locator: $index->setServiceLocator(self::$serviceLocator); // Set the logger: $index->setLogger(self::$serviceLocator->get('Logger')); return $index; }
/** * Do the actual work of loading the notes. * * @param string $isbn ISBN of book to find notes for * * @return array */ public function __invoke($isbn) { // We can't proceed without an ISBN: if (empty($isbn)) { return array(); } $this->config = ConfigReader::getConfig(); $this->isbn = new ISBN($isbn); $results = array(); // Fetch from provider if (isset($this->config->Content->authorNotes)) { $providers = explode(',', $this->config->Content->authorNotes); foreach ($providers as $provider) { $parts = explode(':', trim($provider)); $provider = strtolower($parts[0]); $func = 'load' . ucwords($provider); $key = $parts[1]; try { $results[$provider] = method_exists($this, $func) ? $this->{$func}($key) : false; // If the current provider had no valid notes, store nothing: if (empty($results[$provider])) { unset($results[$provider]); } } catch (\Exception $e) { // Ignore exceptions: unset($results[$provider]); } } } return $results; }
/** * Constructor * * @return void */ public function __construct() { $this->searchIni = $this->facetsIni = 'WorldCat'; parent::__construct(); // Load the configuration file: $searchSettings = ConfigReader::getConfig($this->searchIni); // Search handler setup: $this->defaultHandler = 'srw.kw'; if (isset($searchSettings->Basic_Searches)) { foreach ($searchSettings->Basic_Searches as $key => $value) { $this->basicHandlers[$key] = $value; } } if (isset($searchSettings->Advanced_Searches)) { foreach ($searchSettings->Advanced_Searches as $key => $value) { $this->advancedHandlers[$key] = $value; } } // Load sort preferences: if (isset($searchSettings->Sorting)) { foreach ($searchSettings->Sorting as $key => $value) { $this->sortOptions[$key] = $value; } } if (isset($searchSettings->General->default_sort)) { $this->defaultSort = $searchSettings->General->default_sort; } if (isset($searchSettings->DefaultSortingByType) && count($searchSettings->DefaultSortingByType) > 0) { foreach ($searchSettings->DefaultSortingByType as $key => $val) { $this->defaultSortByHandler[$key] = $val; } } }
/** * Determines what elements are displayed on the home page based on whether * the user is logged in. * * @return mixed */ public function homeAction() { $config = ConfigReader::getConfig(); $loggedInModule = isset($config->Site->defaultLoggedInModule) ? $config->Site->defaultLoggedInModule : 'MyResearch'; $loggedOutModule = isset($config->Site->defaultModule) ? $config->Site->defaultModule : 'Search'; $module = $this->getUser() ? $loggedInModule : $loggedOutModule; return $this->forwardTo($module, 'Home'); }
/** * Constructor */ public function __construct() { // Call standard record controller initialization: parent::__construct(); // Load default tab setting: $config = ConfigReader::getConfig(); $this->defaultTab = isset($config->Site->defaultRecordTab) ? $config->Site->defaultRecordTab : 'Holdings'; }
/** * Apply proxy prefix to URL (if configured). * * @param string $url The raw URL to adjust * * @return string */ public function __invoke($url) { $config = ConfigReader::getConfig(); if (isset($config->EZproxy->host)) { $url = $config->EZproxy->host . '/login?qurl=' . urlencode($url); } return $url; }
/** * Constructor. Create a new search result scroller. */ public function __construct() { // Is this functionality enabled in config.ini? $config = ConfigReader::getConfig(); $this->enabled = isset($config->Record->next_prev_navigation) && $config->Record->next_prev_navigation; // Set up session namespace for the class. $this->data = new SessionContainer('ResultScroller'); }
/** * Get the name of the folder for storing statistics. * * @return string */ protected function getFolder() { if (null === $this->folder) { $configs = ConfigReader::getConfig(); $this->folder = $configs->Statistics->file; } return $this->folder; }
/** * Constructor * * @return void */ public function __construct() { $this->searchIni = $this->facetsIni = 'Summon'; parent::__construct(); // Load facet preferences: $facetSettings = ConfigReader::getConfig($this->facetsIni); if (isset($facetSettings->Advanced_Settings->translated_facets) && count($facetSettings->Advanced_Facet_Settings->translated_facets) > 0) { $list = $facetSettings->Advanced_Facet_Settings->translated_facets; foreach ($list as $c) { $this->translatedFacets[] = $c; } } if (isset($facetSettings->Advanced_Facet_Settings->special_facets)) { $this->specialAdvancedFacets = $facetSettings->Advanced_Facet_Settings->special_facets; } // Load the search configuration file: $searchSettings = ConfigReader::getConfig($this->searchIni); // Set up highlighting preference if (isset($searchSettings->General->highlighting)) { $this->highlight = $searchSettings->General->highlighting; } // Set up spelling preference if (isset($searchSettings->Spelling->enabled)) { $this->spellcheck = $searchSettings->Spelling->enabled; } // Load search preferences: if (isset($searchSettings->General->retain_filters_by_default)) { $this->retainFiltersByDefault = $searchSettings->General->retain_filters_by_default; } if (isset($searchSettings->General->result_limit)) { $this->resultLimit = $searchSettings->General->result_limit; } // Search handler setup: if (isset($searchSettings->Basic_Searches)) { foreach ($searchSettings->Basic_Searches as $key => $value) { $this->basicHandlers[$key] = $value; } } if (isset($searchSettings->Advanced_Searches)) { foreach ($searchSettings->Advanced_Searches as $key => $value) { $this->advancedHandlers[$key] = $value; } } // Load sort preferences: if (isset($searchSettings->Sorting)) { foreach ($searchSettings->Sorting as $key => $value) { $this->sortOptions[$key] = $value; } } if (isset($searchSettings->General->default_sort)) { $this->defaultSort = $searchSettings->General->default_sort; } if (isset($searchSettings->DefaultSortingByType) && count($searchSettings->DefaultSortingByType) > 0) { foreach ($searchSettings->DefaultSortingByType as $key => $val) { $this->defaultSortByHandler[$key] = $val; } } }
/** * Get the cover loader object * * @return Loader */ protected function getLoader() { // Construct object for loading cover images if it does not already exist: if (!$this->loader) { $this->loader = new Loader(ConfigReader::getConfig(), $this->getServiceLocator()->get('CacheManager')->getCacheDir()); $this->loader->setLogger($this->getServiceLocator()->get('Logger')); } return $this->loader; }
/** * Get the WorldCat ID from the config file. * * @return string */ protected function getWorldCatId() { static $wcId = null; if (is_null($wcId)) { $config = ConfigReader::getConfig(); $wcId = isset($config->WorldCat->id) ? $config->WorldCat->id : false; } return $wcId; }
/** * Accepts $keysToHash, a list of array keys, and $keyValueArray, a keyed array * * @param array $keysToHash A list of keys to hash * @param array $keyValueArray A keyed array * * @return sting A hash_hmac string using md5 */ public static function generate($keysToHash, $keyValueArray) { $config = ConfigReader::getConfig(); $str = ''; foreach ($keysToHash as $key) { $value = isset($keyValueArray[$key]) ? $keyValueArray[$key] : ''; $str .= $key . '=' . $value . '|'; } return hash_hmac('md5', $str, $config->Security->HMACkey); }
/** * Constructor */ public function __construct() { $this->config = ConfigReader::getConfig(); $this->disabledFacets = array(); foreach ($this->config->Browse as $key => $setting) { if ($setting == false) { $this->disabledFacets[] = $key; } } }
/** * Constructor * * @param \Zend\Config\Config $config Configuration to use (set to null to load * default configuration using ConfigReader class). */ public function __construct($config = null) { if (is_null($config)) { $config = ConfigReader::getConfig(); } // Set Display Date Format $this->displayDateFormat = isset($config->Site->displayDateFormat) ? $config->Site->displayDateFormat : "m-d-Y"; // Set Display Date Format $this->displayTimeFormat = isset($config->Site->displayTimeFormat) ? $config->Site->displayTimeFormat : "H:i"; }
/** * Constructor. */ public function __construct() { // Turn on highlighting as needed: $searchSettings = ConfigReader::getConfig('Summon'); $this->highlight = !isset($searchSettings->General->highlighting) ? false : $searchSettings->General->highlighting; // Set up resource source to allow tagging/saving/etc. $this->resourceSource = 'Summon'; // Make sure we read appropriate config file: $this->recordIni = 'Summon'; }
/** * Constructor * * @param \VuFind\Auth\Manager $account Auth manager object * @param ILSConnection $ils A catalog connection */ public function __construct(\VuFind\Auth\Manager $account, ILSConnection $ils) { $this->account = $account; $this->config = ConfigReader::getConfig(); if (isset($this->config->Record->hide_holdings)) { foreach ($this->config->Record->hide_holdings as $current) { $this->hideHoldings[] = $current; } } $this->catalog = $ils; }
/** * setConfig * * Store the configuration of the recommendation module. * * TopFacets:[ini section]:[ini name] * Display facets listed in the specified section of the specified ini file; * if [ini name] is left out, it defaults to "facets." * * @param string $settings Settings from searches.ini. * * @return void */ public function setConfig($settings) { $settings = explode(':', $settings); $mainSection = empty($settings[0]) ? 'ResultsTop' : $settings[0]; $iniName = isset($settings[1]) ? $settings[1] : 'facets'; // Load the desired facet information: $config = ConfigReader::getConfig($iniName); $this->facets = isset($config->{$mainSection}) ? $config->{$mainSection}->toArray() : array(); // Load other relevant settings: $this->baseSettings = array('rows' => $config->Results_Settings->top_rows, 'cols' => $config->Results_Settings->top_cols); }
/** * Get configuration (load automatically if not previously set). Throw an * exception if the configuration is invalid. * * @throws AuthException * @return \Zend\Config\Config */ public function getConfig() { // Load configuration if not already present: if (is_null($this->config)) { $this->setConfig(ConfigReader::getConfig()); } // Validate configuration if not already validated: if (!$this->configValidated) { $this->validateConfig(); } return $this->config; }
/** * Get a connection to the Summon API. * * @return SummonConnection */ public function getSummonConnection() { static $conn = false; if (!$conn) { $config = ConfigReader::getConfig(); $id = isset($config->Summon->apiId) ? $config->Summon->apiId : null; $key = isset($config->Summon->apiKey) ? $config->Summon->apiKey : null; $conn = new SummonConnection($id, $key); $conn->setLogger($this->getServiceLocator()->get('Logger')); } return $conn; }
/** * Gathers data for the view of the AlphaBrowser and does some initialization * * @return \Zend\View\Model\ViewModel */ public function homeAction() { $config = ConfigReader::getConfig(); // Load browse types from config file, or use defaults if unavailable: if (isset($config->AlphaBrowse_Types) && !empty($config->AlphaBrowse_Types)) { $types = array(); foreach ($config->AlphaBrowse_Types as $key => $value) { $types[$key] = $value; } } else { $types = array('topic' => 'By Topic', 'author' => 'By Author', 'title' => 'By Title', 'lcc' => 'By Call Number'); } // Connect to Solr: $db = ConnectionManager::connectToIndex(); // Process incoming parameters: $source = $this->params()->fromQuery('source', false); $from = $this->params()->fromQuery('from', false); $page = intval($this->params()->fromQuery('page', 0)); $limit = isset($config->AlphaBrowse->page_size) ? $config->AlphaBrowse->page_size : 20; // Create view model: $view = $this->createViewModel(); // If required parameters are present, load results: if ($source && $from !== false) { // Load Solr data or die trying: try { $result = $db->alphabeticBrowse($source, $from, $page, $limit); // No results? Try the previous page just in case we've gone past // the end of the list.... if ($result['Browse']['totalCount'] == 0) { $page--; $result = $db->alphabeticBrowse($source, $from, $page, $limit); } } catch (SolrException $e) { if ($e->isMissingBrowseIndex()) { throw new \Exception("Alphabetic Browse index missing. See " . "http://vufind.org/wiki/alphabetical_heading_browse for " . "details on generating the index."); } throw $e; } // Only display next/previous page links when applicable: if ($result['Browse']['totalCount'] > $limit) { $view->nextpage = $page + 1; } if ($result['Browse']['offset'] + $result['Browse']['startRow'] > 1) { $view->prevpage = $page - 1; } $view->result = $result; } $view->alphaBrowseTypes = $types; $view->from = $from; $view->source = $source; return $view; }
/** * Helper to allow easily configurable page layout -- given a broad class * name, return appropriate CSS classes to lay out the page according to * the current configuration file settings. * * @param string $class Type of class to return ('mainbody' or 'sidebar') * * @return string CSS classes to apply */ public function __invoke($class) { $config = ConfigReader::getConfig(); $left = !isset($config->Site->sidebarOnLeft) ? false : $config->Site->sidebarOnLeft; switch ($class) { case 'mainbody': return $left ? 'span-18 push-5 last' : 'span-18'; case 'sidebar': return $left ? 'span-5 pull-18 sidebarOnLeft' : 'span-5 last'; default: return ''; } }
/** * Constructor */ public function __construct() { $config = ConfigReader::getConfig(); if (isset($config->Site->showBookBag)) { $this->active = (bool) $config->Site->showBookBag; } if (isset($config->Site->bookBagMaxSize)) { $this->maxSize = $config->Site->bookBagMaxSize; } $this->items = array(); // Initialize contents $this->init(); }
/** * setConfig * * Store the configuration of the recommendation module. * * @param string $settings Settings from searches.ini. * * @return void */ public function setConfig($settings) { // Save the basic parameters: $this->settings = $settings; // Parse the additional settings: $settings = explode(':', $settings); $mainSection = empty($settings[0]) ? 'Results' : $settings[0]; $checkboxSection = isset($settings[1]) ? $settings[1] : false; $iniName = isset($settings[2]) ? $settings[2] : 'facets'; // Load the desired facet information... $config = ConfigReader::getConfig($iniName); // All standard facets to display: $this->facets = isset($config->{$mainSection}) ? $config->{$mainSection}->toArray() : array(); }
/** * Constructor */ public function __construct() { // Read Config file $config = ConfigReader::getConfig(); $this->baseUrl = $config->Site->url; $this->resultUrl = $this->baseUrl . '/Record/'; $this->config = ConfigReader::getConfig('sitemap'); $this->frequency = $this->config->Sitemap->frequency; $this->countPerPage = $this->config->Sitemap->countPerPage; $this->fileStart = $this->config->Sitemap->fileLocation . "/" . $this->config->Sitemap->fileName; if (isset($this->config->SitemapIndex->indexFileName)) { $this->indexFile = $this->config->Sitemap->fileLocation . "/" . $this->config->SitemapIndex->indexFileName . ".xml"; } }
/** * Uses the user language to determine which Help template to use * Uses the English template as a back-up * * @return mixed */ public function homeAction() { $config = ConfigReader::getConfig(); $this->layout()->setTemplate('layout/help'); // Sanitize the topic name to include only alphanumeric characters // or underscores. $safe_topic = preg_replace('/[^\\w]/', '', $this->params()->fromQuery('topic')); // Construct two possible template names -- the help screen in the // current selected language and help in English (most likely to exist). // The code will attempt to display the most appropriate existing help screen $language = $this->getServiceLocator()->has('Translator') ? $this->getServiceLocator()->get('Translator')->getLocale() : 'en'; $tpl_lang = 'HelpTranslations/' . $language . '/' . $safe_topic . '.phtml'; $tpl_en = 'HelpTranslations/en/' . $safe_topic . '.phtml'; // Best case -- help is available in the user's chosen language return $this->createViewModel(array('tpl_lang' => $tpl_lang, 'tpl_en' => $tpl_en)); }