예제 #1
0
파일: Core.plugin.php 프로젝트: davbfr/cf
 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();
     }
 }
예제 #2
0
 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()));
 }
예제 #3
0
파일: Cache.test.php 프로젝트: davbfr/cf
 public function testMakeCacheName()
 {
     Cache::MakeCacheName("name", CACHE_DIR, 0);
 }