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); } }
/** * 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; } }
/** * include a cache file which is the results of the compilation of multiple file sotred in multiple modules * @param array $aType * = array( * 'compilator class name', * 'relative path of the compilator class file to lib/jelix/', * 'foo.xml', // file name to compile (in each modules) * 'foo.php', //cache filename * ); * @return mixed arbitrary value from the cached */ public static function incAll($aType) { $returnedValue = null; $cachefile = App::tempPath('compiled/' . $aType[3]); if (isset(self::$_includedFiles[$cachefile])) { return $returnedValue; } $config = App::config(); $mustCompile = $config->compilation['force'] || !file_exists($cachefile); if (!$mustCompile && $config->compilation['checkCacheFiletime']) { $compiledate = filemtime($cachefile); foreach ($config->_modulesPathList as $module => $path) { $sourcefile = $path . $aType[2]; if (is_readable($sourcefile)) { if (filemtime($sourcefile) > $compiledate) { $mustCompile = true; break; } } } } if ($mustCompile) { if ($aType[1]) { require_once JELIX_LIB_PATH . $aType[1]; } $compiler = new $aType[0](); $compileok = true; foreach ($config->_modulesPathList as $module => $path) { $compileok = $compiler->compileItem($path . $aType[2], $module); if (!$compileok) { break; } } if ($compileok) { $compiler->endCompile($cachefile); // the require may load the file content from the // opcode cache if it is existing. // So we must invalidate the file. if (function_exists('opcache_invalidate')) { opcache_invalidate($cachefile, true); } else { if (function_exists('apc_delete_file')) { apc_delete_file($cachefile); } } $returnedValue = (require $cachefile); self::$_includedFiles[$cachefile] = true; } } else { $returnedValue = (require $cachefile); self::$_includedFiles[$cachefile] = true; } return $returnedValue; }