Пример #1
0
 protected function readConfigFiles($configFile, $additionalOptions)
 {
     $configPath = App::configPath();
     // this is the defaultconfig file of JELIX itself
     $config = IniFileMgr::read(__DIR__ . '/defaultconfig.ini.php', true);
     // read the main configuration of the app
     $mcf = App::mainConfigFile();
     if ($mcf) {
         IniFileMgr::readAndMergeObject($mcf, $config);
     }
     $this->commonConfig = clone $config;
     // read the local configuration of the app
     if (file_exists($configPath . 'localconfig.ini.php')) {
         IniFileMgr::readAndMergeObject($configPath . 'localconfig.ini.php', $config);
     }
     // read the configuration specific to the entry point
     if ($configFile != '' && $configPath . $configFile != $mcf) {
         if (!file_exists($configPath . $configFile)) {
             throw new Exception("Configuration file is missing -- {$configFile}", 5);
         }
         if (false === IniFileMgr::readAndMergeObject($configPath . $configFile, $config)) {
             throw new Exception("Syntax error in the configuration file -- {$configFile}", 6);
         }
     }
     if ($additionalOptions) {
         IniFileMgr::mergeIniObjectContents($config, $additionalOptions);
     }
     return $config;
 }
Пример #2
0
 /**
  * load and read the configuration of the application
  * The combination of all configuration files (the given file
  * and the mainconfig.ini.php) is stored
  * in a single temporary file. So it calls the jConfigCompiler
  * class if needed
  * @param string $configFile the config file name
  * @return object it contains all configuration options
  * @see Jelix\Core\Config\Compiler
  */
 public static function load($configFile)
 {
     $config = array();
     $file = App::tempPath() . str_replace('/', '~', $configFile);
     if (BYTECODE_CACHE_EXISTS) {
         $file .= '.conf.php';
     } else {
         $file .= '.resultini.php';
     }
     self::$fromCache = true;
     if (!file_exists($file)) {
         // no cache, let's compile
         self::$fromCache = false;
     } else {
         $t = filemtime($file);
         $dc = App::mainConfigFile();
         $lc = App::configPath('localconfig.ini.php');
         if (file_exists($dc) && filemtime($dc) > $t || filemtime(App::appConfigPath($configFile)) > $t || file_exists($lc) && filemtime($lc) > $t) {
             // one of the config files have been modified: let's compile
             self::$fromCache = false;
         } else {
             // let's read the cache file
             if (BYTECODE_CACHE_EXISTS) {
                 include $file;
                 $config = (object) $config;
             } else {
                 $config = \Jelix\IniFile\Util::read($file, true);
             }
             // we check all directories to see if it has been modified
             if ($config->compilation['checkCacheFiletime']) {
                 foreach ($config->_allBasePath as $path) {
                     if (!file_exists($path) || filemtime($path) > $t) {
                         self::$fromCache = false;
                         break;
                     }
                 }
             }
         }
     }
     if (!self::$fromCache) {
         $compiler = new Config\Compiler($configFile);
         return $compiler->readAndCache();
     } else {
         return $config;
     }
 }
Пример #3
0
 protected static function _getPrefFile()
 {
     return \Jelix\IniFile\Util::read(jApp::configPath(self::$_pref_config_file));
 }