コード例 #1
0
ファイル: Profiles.php プロジェクト: mdouchin/jelix
 protected static function loadProfiles()
 {
     $file = App::configPath('profiles.ini.php');
     $tempFile = App::tempPath('profiles.cache.php');
     if (!file_exists($tempFile) || filemtime($file) > filemtime($tempFile)) {
         $compiler = new \jProfilesCompiler($file);
         self::$_profiles = $compiler->compile();
         \Jelix\IniFile\Util::write(self::$_profiles, $tempFile);
     } else {
         self::$_profiles = parse_ini_file($tempFile, true);
     }
 }
コード例 #2
0
ファイル: Config.php プロジェクト: mdouchin/jelix
 /**
  * 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
ファイル: Compiler.php プロジェクト: jelix/jelix
 /**
  * Identical to read(), but also stores the result in a temporary file
  * @return object an object which contains configuration values
  */
 public function readAndCache()
 {
     $config = $this->read(false);
     $tempPath = App::tempPath();
     \jFile::createDir($tempPath, $config->chmodDir);
     $filename = $tempPath . str_replace('/', '~', $this->configFileName);
     if (BYTECODE_CACHE_EXISTS) {
         $filename .= '.conf.php';
         if ($f = @fopen($filename, 'wb')) {
             fwrite($f, '<?php $config = ' . var_export(get_object_vars($config), true) . ";\n?>");
             fclose($f);
             chmod($filename, $config->chmodFile);
         } else {
             throw new Exception('Error while writing configuration cache file -- ' . $filename);
         }
     } else {
         IniFileMgr::write(get_object_vars($config), $filename . '.resultini.php', ";<?php die('');?>\n", '', $config->chmodFile);
     }
     return $config;
 }
コード例 #4
0
ファイル: jPrefManager.php プロジェクト: mdouchin/jelix
 protected static function _getPrefFile()
 {
     return \Jelix\IniFile\Util::read(jApp::configPath(self::$_pref_config_file));
 }