public static function loadConfig() { $conf = Config::getInstance(); $memcache = new MemCache(); if (array_key_exists("JCONFIG_FILE", $memcache)) { $conf->setData($memcache["JCONFIG_FILE"]); Logger::debug("Config loaded from cache"); foreach ($conf->get("plugins", array()) as $plugin) { Plugins::add($plugin); } } else { $cache = Cache::Priv(self::config, ".php"); if ($cache->check()) { if (file_exists(ROOT_DIR . "/composer.json")) { $conf->append(ROOT_DIR . "/composer.json", false, "composer"); } if (file_exists(CONFIG_DIR . "/config.json")) { $conf->append(CONFIG_DIR . "/config.json"); } if (file_exists(CONFIG_DIR . "/config.local.json")) { $conf->append(CONFIG_DIR . "/config.local.json"); } foreach (glob(CONFIG_DIR . "/*.json") as $file) { $bn = basename($file); if (substr($bn, 0, 7) != "config.") { $conf->append($file, false, substr($bn, 0, strlen($bn) - 5)); } } if (DEBUG && file_exists(CONFIG_DIR . "/config.debug.json")) { $conf->append(CONFIG_DIR . "/config.debug.json"); } $confsave = $conf->getData(); foreach ($conf->get("plugins", array()) as $plugin) { Plugins::add($plugin); } foreach (array_reverse(Plugins::findAll(self::config)) as $dirname) { if (file_exists($dirname . "/config.json")) { $conf->append($dirname . "/config.json"); } foreach (glob($dirname . "/*.json") as $file) { $bn = basename($file); if (substr($bn, 0, 7) != "config.") { $conf->append($file, false, substr($bn, 0, strlen($bn) - 5)); } } } Plugins::dispatchAllReversed("config", $conf); $conf->merge($confsave); ArrayWriter::toFile($conf->getData(), $cache->getFilename()); } else { $conf->setData(ArrayWriter::fromFile($cache->getFilename())); foreach ($conf->get("plugins", array()) as $plugin) { Plugins::add($plugin); } } $memcache["JCONFIG_FILE"] = $conf->getData(); } }
public function getStylesheets() { $res = $this->getResourcesByExt(".css"); $output = Cache::Pub($this->tag . ".css"); if (!MINIFY_JSCSS) { $output->delete(); return array_map(array($this, "web"), $res); } if ($output->check()) { $out = $output->openWrite(); foreach ($res as $item) { fwrite($out, $this->minifyStylesheet($item) . "\n"); } fclose($out); } return array($this->web($output->getFilename())); }
public function testMakeCacheName() { Cache::MakeCacheName("name", CACHE_DIR, 0); }