Example #1
0
 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);
     }
 }
Example #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;
     }
 }
Example #3
0
 /**
  * @return boolean true if the application is installed.
  */
 public static function isAppInstalled()
 {
     return file_exists(App::configPath('installer.ini.php'));
 }