Esempio n. 1
0
 /**
  * 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:
         $sm = $this->getServiceLocator();
         $cache = is_object($sm) && $sm->has('CacheManager') ? $sm->get('CacheManager')->getCache('searchspecs') : false;
         // Determine full configuration file path:
         $fullpath = Reader::getBaseConfigPath($filename);
         $local = Reader::getLocalConfigPath($filename);
         // Generate cache key:
         $key = $filename . '-' . filemtime($fullpath);
         if (!empty($local)) {
             $key .= '-local-' . filemtime($local);
         }
         $key = md5($key);
         // Generate data if not found in cache:
         if (!$cache || !($results = $cache->getItem($key))) {
             $results = Yaml::load(file_get_contents($fullpath));
             if (!empty($local)) {
                 $localResults = Yaml::load(file_get_contents($local));
                 foreach ($localResults as $key => $value) {
                     $results[$key] = $value;
                 }
             }
             if ($cache) {
                 $cache->setItem($key, $results);
             }
         }
         $this->searchSpecs[$filename] = $results;
     }
     return $this->searchSpecs[$filename];
 }
Esempio n. 2
0
 /**
  * Configuration management
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function configAction()
 {
     $view = $this->createViewModel();
     $view->baseConfigPath = ConfigReader::getBaseConfigPath('');
     $conf = ConfigReader::getConfig();
     $view->showInstallLink = isset($conf->System->autoConfigure) && $conf->System->autoConfigure;
     return $view;
 }
Esempio n. 3
0
 /**
  * Display repair instructions for ILS problems.
  *
  * @return mixed
  */
 public function fixilsAction()
 {
     // Process incoming parameter -- user may have selected a new driver:
     $newDriver = $this->params()->fromPost('driver');
     if (!empty($newDriver)) {
         $configPath = ConfigReader::getLocalConfigPath('config.ini', null, true);
         $writer = new ConfigWriter($configPath);
         $writer->set('Catalog', 'driver', $newDriver);
         if (!$writer->save()) {
             return $this->forwardTo('Install', 'fixbasicconfig');
         }
         // Copy configuration, if applicable:
         $ilsIni = ConfigReader::getBaseConfigPath($newDriver . '.ini');
         $localIlsIni = ConfigReader::getLocalConfigPath("{$newDriver}.ini", null, true);
         if (file_exists($ilsIni) && !file_exists($localIlsIni)) {
             if (!copy($ilsIni, $localIlsIni)) {
                 return $this->forwardTo('Install', 'fixbasicconfig');
             }
         }
         return $this->redirect()->toRoute('install-home');
     }
     // If we got this far, check whether we have an error with a real driver
     // or if we need to warn the user that they have selected a fake driver:
     $config = ConfigReader::getConfig();
     $view = $this->createViewModel();
     if (in_array($config->Catalog->driver, array('Sample', 'Demo'))) {
         $view->demo = true;
         // Get a list of available drivers:
         $dir = opendir(APPLICATION_PATH . '/module/VuFind/src/VuFind/ILS/Driver');
         $drivers = array();
         $blacklist = array('Sample.php', 'Demo.php', 'DriverInterface.php', 'AbstractBase.php', 'PluginManager.php', 'PluginFactory.php');
         while ($line = readdir($dir)) {
             if (stristr($line, '.php') && !in_array($line, $blacklist)) {
                 $drivers[] = str_replace('.php', '', $line);
             }
         }
         closedir($dir);
         sort($drivers);
         $view->drivers = $drivers;
     } else {
         $view->configPath = ConfigReader::getLocalConfigPath("{$config->Catalog->driver}.ini", null, true);
     }
     return $view;
 }
Esempio n. 4
0
 /**
  * Upgrade the configuration files.
  *
  * @return mixed
  */
 public function fixconfigAction()
 {
     $upgrader = new \VuFind\Config\Upgrade($this->cookie->oldVersion, $this->cookie->newVersion, $this->cookie->sourceDir . '/web/conf', dirname(ConfigReader::getBaseConfigPath('config.ini')), dirname(ConfigReader::getLocalConfigPath('config.ini', null, true)));
     try {
         $upgrader->run();
         $this->cookie->warnings = $upgrader->getWarnings();
         $this->cookie->configOkay = true;
         return $this->forwardTo('Upgrade', 'Home');
     } catch (\Exception $e) {
         $extra = is_a($e, 'VuFind\\Exception\\FileAccess') ? '  Check file permissions.' : '';
         $this->flashMessenger()->setNamespace('error')->addMessage('Config upgrade failed: ' . $e->getMessage() . $extra);
         return $this->forwardTo('Upgrade', 'Error');
     }
 }