Example #1
0
 /**
  * Стартуем
  * @param $content
  * @return void
  */
 public function run(&$content)
 {
     //Путь к файлу
     $__path = $this->file;
     //Счетчик времени
     $time = Boot::mktime();
     //Оборачиваем все в функцию
     $view = function ($params, $content) use($__path) {
         //Извлекаем переменные
         if (!empty($params)) {
             extract((array) $params);
         }
         //Запускаем отладчик
         ob_start();
         //Подключаем файл
         require $__path;
         //Выполняем сценарий
         $html = ob_get_contents();
         ob_end_clean();
         //Возвращаем данные
         return $html;
     };
     //Выполняем функцию
     $html = $view((array) Boot_Controller::getInstance()->view, $content);
     //Debug
     Boot::getInstance()->debug("  Rendered " . str_replace(APPLICATION_PATH . "/", "", $__path) . " (" . Boot::check_time($time) . "ms)");
     echo $html;
 }
Example #2
0
File: boot.php Project: pnixx/boot
 /**
  * Завершение работы скрипта
  */
 public function end()
 {
     //Выводим время работы
     Boot::getInstance()->debug("  Completed (" . Boot::check_time($this->_time_start) . "ms)");
 }
Example #3
0
File: cache.php Project: pnixx/boot
 /**
  * @param $key
  */
 public function _delete($key)
 {
     //Запоминаем время начала
     $time = Boot::mktime();
     try {
         //Очищаем данные
         $this->m->delete($this->prefix . $key);
         //Debug
         Boot::getInstance()->debug("  Cache (" . Boot::check_time($time) . "ms) DELETE " . $this->prefix . $key);
     } catch (Exception $e) {
         $this->error($e->getMessage());
     }
 }
Example #4
0
 /**
  * SQL query
  * @param	$query
  * @return postgres
  */
 public function query($query)
 {
     //Запоминаем время начала
     $time = Boot::mktime();
     //Делаем запрос
     $this->result = @pg_query($this->_connect, $query) or $this->error($query);
     //Debug
     Boot::getInstance()->debug("  SQL (" . Boot::check_time($time) . "ms) " . $query);
     //Return
     return $this;
 }
Example #5
0
File: view.php Project: pnixx/boot
 /**
  * Рендирит шаблон
  * @param string $file Путь к файлу от каталога /application/views без расширения
  * @param array  $params
  * @throws Boot_Exception
  */
 private function _render($file, $params = [])
 {
     //Строим полный путь
     $__path = null;
     //Проверяем наличие шаблона
     $paths = explode(PATH_SEPARATOR, get_include_path());
     foreach ($paths as $p) {
         if (file_exists(realpath($p) . '/' . $file . '.phtml')) {
             $__path = realpath($p) . '/' . $file . '.phtml';
             break;
         }
     }
     //Если не нашли шаблон
     if ($__path == null) {
         throw new Boot_Exception('View "' . $file . '.phtml" not exist');
     }
     //Счетчик времени
     $time = Boot::mktime();
     //Оборачиваем все в функцию
     $view = function ($params) use($__path) {
         //Извлекаем переменные
         if (!empty($params)) {
             extract((array) $params);
         }
         //Запускаем отладчик
         ob_start();
         //Подключаем файл
         require $__path;
         //Выполняем сценарий
         $html = ob_get_contents();
         ob_end_clean();
         //Возвращаем данные
         return $html;
     };
     //Выполняем функцию
     $html = $view($params);
     //Debug
     Boot::getInstance()->debug("  Rendered " . str_replace(APPLICATION_PATH . "/", "", $__path) . " (" . Boot::check_time($time) . "ms)");
     //Возвращаем результат
     return $html;
 }