Пример #1
0
 protected function append($filename, $origfilename = null)
 {
     if (substr($filename, -5) == ".less") {
         $script = Cache::Pub($filename, ".css");
         if ($script->check()) {
             Logger::info("Compile less file {$filename}");
             $less = new Less();
             $less->setOriginalDir(dirname($origfilename));
             $less->compileFile($filename, $script->getFilename());
         }
         $filename = $script->getFilename();
     }
     parent::append($filename, $origfilename);
 }
Пример #2
0
 public function query($sql, $params = array())
 {
     Logger::Debug("Query {$sql} ", $params);
     $reponse = $this->pdo->prepare($sql);
     if ($reponse === false) {
         $error = $this->pdo->errorInfo();
         ErrorHandler::error(500, null, "Error in SQL statement {$error[0]} ({$error[1]}) {$error[2]} in\n{$sql}");
     }
     $reponse->setFetchMode(PDO::FETCH_NAMED);
     $result = $reponse->execute($params);
     if ($result === false) {
         $error = $reponse->errorInfo();
         ErrorHandler::error(500, null, "Sql error {$error[0]} ({$error[1]}) {$error[2]} in\n{$sql}");
     }
     return $reponse;
 }
Пример #3
0
 public function __construct($argv)
 {
     self::$instance = $this;
     while (ob_get_level()) {
         ob_end_clean();
     }
     $this->has_colors = posix_isatty(STDOUT);
     $this->args = $this->parseArguments($argv);
     $logger = Logger::getInstance();
     if (array_key_exists("v", $this->args)) {
         $logger->setLevel(Logger::DEBUG);
     }
     $this->commands = array();
     $this->options = array();
     $this->switches = array();
     $this->inputs = array();
     $this->addCommand("help", array($this, "printHelp"), "Help messages");
 }
Пример #4
0
 public function formatOut($type, $value)
 {
     if ($value === null) {
         return $value;
     }
     switch ($type) {
         case ModelField::TYPE_INT:
             return intval($value);
         case ModelField::TYPE_BOOL:
             return intval($value) != 0;
         case ModelField::TYPE_DATETIME:
             if ($value instanceof DateTime) {
                 return $value->getTimestamp();
             }
             try {
                 $value = new DateTime($value);
                 return $value->getTimestamp();
             } catch (Exception $e) {
                 Logger::Error("Date {$value} invalid: " . $e->getMessage());
                 return $value;
             }
     }
     return $value;
 }
Пример #5
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;
 }
Пример #6
0
 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;
 }
Пример #7
0
 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());
     }
 }
Пример #8
0
 public function errorHandler($errno, $errstr, $errfile, $errline)
 {
     if ($this->inerror) {
         Logger::critical("Already processing error (error_handler) {$errno}, {$errstr}, {$errfile}, {$errline}");
         return;
     }
     if (!(error_reporting() & $errno)) {
         return;
     }
     $this->addBacktrace($errfile, $errline);
     $this->send_error(500, null, "Error {$errno} {$errstr}", false);
 }
Пример #9
0
 public function update()
 {
     if (Cli::getOption("a")) {
         $cf_dir = "\"" . realpath(CF_DIR) . "\"";
     } else {
         $cf_dir = "ROOT_DIR . \"/" . System::relativePath(System::absPath(ROOT_DIR), System::absPath(CF_DIR)) . "\"";
     }
     Cli::pinfo(" * Create paths.php");
     Logger::Debug("CF dir is {$cf_dir}");
     Logger::Debug("ROOT dir is " . ROOT_DIR);
     $content = "<?php // DO NOT MODIFY THIS FILE, IT IS GENERATED BY setup update SCRIPT\n\n";
     $content .= "@define(\"ROOT_DIR\", \"" . ROOT_DIR . "\");\n";
     $content .= "@define(\"CF_DIR\", {$cf_dir});\n";
     file_put_contents(CONFIG_DIR . "/paths.php", $content);
 }