/**
  * Return search specs
  *
  * @param string $filename config file name
  *
  * @return array
  */
 public function get($filename)
 {
     // Load data if it is not already in the object's cache:
     if (!isset($this->searchSpecs[$filename])) {
         // Connect to searchspecs cache:
         $cache = null !== $this->cacheManager ? $this->cacheManager->getCache('searchspecs') : false;
         // Determine full configuration file path:
         $fullpath = Locator::getBaseConfigPath($filename);
         $local = Locator::getLocalConfigPath($filename);
         // Generate cache key:
         $cacheKey = $filename . '-' . (file_exists($fullpath) ? filemtime($fullpath) : 0);
         if (!empty($local)) {
             $cacheKey .= '-local-' . filemtime($local);
         }
         $cacheKey = md5($cacheKey);
         // Generate data if not found in cache:
         if ($cache === false || !($results = $cache->getItem($cacheKey))) {
             $results = file_exists($fullpath) ? Yaml::parse(file_get_contents($fullpath)) : [];
             if (!empty($local)) {
                 $localResults = Yaml::parse(file_get_contents($local));
                 foreach ($localResults as $key => $value) {
                     $results[$key] = $value;
                 }
             }
             if ($cache !== false) {
                 $cache->setItem($cacheKey, $results);
             }
         }
         $this->searchSpecs[$filename] = $results;
     }
     return $this->searchSpecs[$filename];
 }
Beispiel #2
0
 /**
  * Constructor.
  *
  * Add file cache for record descriptions loaded from external sources.
  *
  * @param Config $config       Main VuFind configuration
  * @param Config $searchConfig Search configuration
  */
 public function __construct(Config $config, Config $searchConfig)
 {
     $cacheBase = $this->getCacheDir();
     foreach (['feed', 'description'] as $cache) {
         $this->createFileCache($cache, $cacheBase . $cache . 's');
     }
     return parent::__construct($config, $searchConfig);
 }
Beispiel #3
0
 /**
  * Constructor.
  *
  * Add file cache for record descriptions loaded from external sources.
  *
  * @param Config $config       Main VuFind configuration
  * @param Config $searchConfig Search configuration
  */
 public function __construct(Config $config, Config $searchConfig)
 {
     parent::__construct($config, $searchConfig);
     $cacheBase = $this->getCacheDir();
     $ids = ['feed', 'description', 'organisation-info', 'stylesheet'];
     foreach ($ids as $cache) {
         $this->createFileCache($cache, $cacheBase . $cache . 's');
     }
 }
 /**
  * Given core and local filenames, retrieve the searchspecs data.
  *
  * @param string $defaultFile Full path to file containing default YAML
  * @param string $customFile  Full path to file containing local customizations
  * (may be null if no local file exists).
  *
  * @return array
  */
 protected function getFromPaths($defaultFile, $customFile = null)
 {
     // Connect to searchspecs cache:
     $cache = null !== $this->cacheManager ? $this->cacheManager->getCache('searchspecs') : false;
     // Generate cache key:
     $cacheKey = basename($defaultFile) . '-' . (file_exists($defaultFile) ? filemtime($defaultFile) : 0);
     if (!empty($customFile)) {
         $cacheKey .= '-local-' . filemtime($customFile);
     }
     $cacheKey = md5($cacheKey);
     // Generate data if not found in cache:
     if ($cache === false || !($results = $cache->getItem($cacheKey))) {
         $results = $this->parseYaml($customFile, $defaultFile);
         if ($cache !== false) {
             $cache->setItem($cacheKey, $results);
         }
     }
     return $results;
 }
Beispiel #5
0
 /**
  * Initialize the driver.
  *
  * Validate configuration and perform all resource-intensive tasks needed to
  * make the driver active.
  *
  * @throws ILSException
  * @return void
  */
 public function init()
 {
     // Validate config
     $required = ['host', 'bib', 'useradm', 'admlib', 'dlfport', 'available_statuses'];
     foreach ($required as $current) {
         if (!isset($this->config['Catalog'][$current])) {
             throw new ILSException("Missing Catalog/{$current} config setting.");
         }
     }
     if (!isset($this->config['sublibadm'])) {
         throw new ILSException('Missing sublibadm config setting.');
     }
     // Process config
     $this->host = $this->config['Catalog']['host'];
     $this->bib = explode(',', $this->config['Catalog']['bib']);
     $this->useradm = $this->config['Catalog']['useradm'];
     $this->admlib = $this->config['Catalog']['admlib'];
     if (isset($this->config['Catalog']['wwwuser']) && isset($this->config['Catalog']['wwwpasswd'])) {
         $this->wwwuser = $this->config['Catalog']['wwwuser'];
         $this->wwwpasswd = $this->config['Catalog']['wwwpasswd'];
         $this->xserver_enabled = true;
         $this->xport = isset($this->config['Catalog']['xport']) ? $this->config['Catalog']['xport'] : 80;
     } else {
         $this->xserver_enabled = false;
     }
     $this->dlfport = $this->config['Catalog']['dlfport'];
     $this->sublibadm = $this->config['sublibadm'];
     if (isset($this->config['duedates'])) {
         $this->duedates = $this->config['duedates'];
     }
     $this->available_statuses = explode(',', $this->config['Catalog']['available_statuses']);
     $this->quick_availability = isset($this->config['Catalog']['quick_availability']) ? $this->config['Catalog']['quick_availability'] : false;
     $this->debug_enabled = isset($this->config['Catalog']['debug']) ? $this->config['Catalog']['debug'] : false;
     if (isset($this->config['util']['tab40']) && isset($this->config['util']['tab15']) && isset($this->config['util']['tab_sub_library'])) {
         if (isset($this->config['Cache']['type']) && null !== $this->cacheManager) {
             $cache = $this->cacheManager->getCache($this->config['Cache']['type']);
             $this->translator = $cache->getItem('alephTranslator');
         }
         if ($this->translator == false) {
             $this->translator = new AlephTranslator($this->config);
             if (isset($cache)) {
                 $cache->setItem('alephTranslator', $this->translator);
             }
         }
     }
     if (isset($this->config['Catalog']['preferred_pick_up_locations'])) {
         $this->preferredPickUpLocations = explode(',', $this->config['Catalog']['preferred_pick_up_locations']);
     }
     if (isset($this->config['Catalog']['default_patron_id'])) {
         $this->defaultPatronId = $this->config['Catalog']['default_patron_id'];
     }
 }
Beispiel #6
0
 /**
  * Initialize the driver.
  *
  * Validate configuration and perform all resource-intensive tasks needed to
  * make the driver active.
  *
  * @throws ILSException
  * @return void
  */
 public function init()
 {
     // Validate config
     $required = array('host', 'bib', 'useradm', 'admlib', 'dlfport', 'available_statuses');
     foreach ($required as $current) {
         if (!isset($this->config['Catalog'][$current])) {
             throw new ILSException("Missing Catalog/{$current} config setting.");
         }
     }
     if (!isset($this->config['sublibadm'])) {
         throw new ILSException('Missing sublibadm config setting.');
     }
     $lang = $this->translator->getTranslator()->getLocale();
     $this->alephWebService->init($this->config['Catalog'], $lang);
     $this->bib = explode(',', $this->config['Catalog']['bib']);
     $this->useradm = $this->config['Catalog']['useradm'];
     $this->admlib = $this->config['Catalog']['admlib'];
     $this->sublibadm = $this->config['sublibadm'];
     if (isset($this->config['duedates'])) {
         $this->duedates = $this->config['duedates'];
     }
     $this->available_statuses = explode(',', $this->config['Catalog']['available_statuses']);
     $this->quick_availability = isset($this->config['Catalog']['quick_availability']) ? $this->config['Catalog']['quick_availability'] : false;
     if (isset($this->config['util']['tab40']) && isset($this->config['util']['tab15']) && isset($this->config['util']['tab_sub_library'])) {
         if (isset($this->config['Cache']['type']) && null !== $this->cacheManager) {
             $cache = $this->cacheManager->getCache($this->config['Cache']['type']);
             $this->alephTranslator = $cache->getItem('alephTranslator');
         }
         if ($this->alephTranslator == false) {
             $this->alephTranslator = new AlephFileTranslator($this->config);
             if (isset($cache)) {
                 $cache->setItem('alephTranslator', $this->alephTranslator);
             }
         }
     } else {
         $this->alephTranslator = new AlephFixedTranslator();
     }
     if (isset($this->config['Catalog']['preferred_pick_up_locations'])) {
         $this->preferredPickUpLocations = explode(',', $this->config['Catalog']['preferred_pick_up_locations']);
     }
     if (isset($this->config['Catalog']['default_patron'])) {
         $this->defaultPatronId = $this->config['Catalog']['default_patron'];
     }
     $idResolverType = 'fixed';
     if (isset($this->config['IdResolver']['type'])) {
         $idResolverType = $this->config['IdResolver']['type'];
     }
     if ($idResolverType == 'fixed') {
         $this->idResolver = new FixedIdResolver();
     } else {
         if ($idResolverType == 'solr') {
             $this->idResolver = new SolrIdResolver($this->searchService, $this->config);
         } else {
             if ($idResolverType == 'xserver') {
                 $this->idResolver = new XServerIdResolver($this->alephWebService, $this->config);
             } else {
                 throw new ILSException('Unsupported Catalog[IdResolver][type]:' . $idResolverType . ', valid values are fixed, solr and xserver.');
             }
         }
     }
     if (isset($this->config['ILL']['hidden_statuses'])) {
         $this->IllHiddenStatuses = explode(',', $this->config['ILL']['hidden_statuses']);
     }
     if (isset($this->config['ILL']['default_ill_unit'])) {
         $this->defaultIllUnit = $this->config['ILL']['default_ill_unit'];
     }
     if (isset($this->config['ILL']['default_pickup_location'])) {
         $this->defaultIllPickupPlocation = $this->config['ILL']['default_pickup_location'];
     }
     if (isset($this->config['holdings']['default_required_date'])) {
         $this->defaultRequiredDate = $this->config['holdings']['default_required_date'];
     } else {
         $this->defaultRequiredDate = "0:1:0";
     }
 }