コード例 #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
ファイル: cf.php プロジェクト: davbfr/cf
 public static function dispatchAllReversed()
 {
     $results = array();
     $arguments = func_get_args();
     $method_name = array_shift($arguments);
     foreach (array_reverse(self::get_plugins()) as $plugin) {
         $class = self::get($plugin);
         if (method_exists($class, $method_name)) {
             Logger::debug("Dispatch " . $plugin . "::" . $method_name);
             $results[] = call_user_func_array(array($class, $method_name), $arguments);
         }
     }
     return $results;
 }
コード例 #3
0
ファイル: MongodbHelper.class.php プロジェクト: davbfr/cf
 public function current()
 {
     $data = $this->cursor->current();
     if ($data) {
         $data['_id'] = (string) $data['_id'];
     }
     if (count($this->fields) > 0) {
         $_data = $data;
         $data = array();
         foreach ($this->fields as $k => $v) {
             if (is_int($k)) {
                 $data[$v] = $_data[$v];
             } else {
                 $data[$k] = $_data[$v];
             }
         }
     }
     Logger::debug("fetch data", $data);
     return $data;
 }
コード例 #4
0
ファイル: Crud.class.php プロジェクト: davbfr/cf
 protected function update_item($r)
 {
     ErrorHandler::RaiseExceptionOnError();
     try {
         Input::ensureRequest($r, array("id"));
         $id = $r["id"];
         Logger::debug("Crud::update_item id:" . $id . " in table " . $this->model->getTableName());
         $post = $this->jsonpost();
         $this->fixValues($post);
         $item = $this->model->getById($id);
         $item->setValues($post);
         $item->save();
         Output::success(array("id" => $id));
     } catch (Exception $e) {
         Output::error($e->getMessage());
     }
 }