Exemple #1
0
 /**
  * Отобразить шаблон
  *
  * @param $view Шаблон
  * @param array $data Данные шаблона
  */
 public function render($view, array $data = [])
 {
     $result = '';
     $viewObj = new View($this->parseViewPath($view), $data);
     if (!is_null($this->layout)) {
         $layoutObj = new View($this->parseViewPath($this->layout), ['content' => $viewObj->render()]);
         $result = $layoutObj->render();
     } else {
         $result = $viewObj->render();
     }
     $this->response->setContent($result)->setContentType()->send();
 }
 public function __construct()
 {
     $this->app = \Framework\App::getInstance();
     $this->view = \Framework\View::getInstance();
     $this->config = $this->app->getConfig();
     $this->input = \Framework\InputData::getInstance();
 }
 /**
  * @NoAction
  * @param string $layout
  * @param $model
  */
 public function renderCustomLayout(string $layout, $model = null)
 {
     if ($model === null) {
         $dummy = new DummyViewModel();
         View::initView($dummy, $layout);
     } else {
         View::initView($model, $layout);
     }
 }
 public function __construct()
 {
     $this->app = App::getInstance();
     $this->view = View::getInstance();
     $this->config = $this->app->getConfig();
     $this->input = InputData::getInstance();
     $this->session = $this->app->getSession();
     $this->db = new SimpleDB();
 }
 public function __construct()
 {
     $this->app = App::getInstance();
     $this->view = View::getInstance();
     $this->config = $this->app->getConfig();
     $this->input = InputData::getInstance();
     $this->db = new SimpleDatabase();
     $this->session = $this->app->getSession();
     $this->path = isset($this->config->app['default_path']) ? $this->config->app['default_path'] : null;
 }
 public function __construct()
 {
     $this->app = App::getInstance();
     $this->view = View::getInstance();
     $this->config = $this->app->getConfig();
     $this->input = InputData::getInstance();
     if (is_null($this->session)) {
         $this->session = new NativeSession('session');
     }
 }
Exemple #7
0
 public function create()
 {
     if ($this->post_count >= 2) {
         $new_user = load_model('Example');
         $new_user->name = $this->post['name'];
         $new_user->lastname = $this->post['lastname'];
         $new_user->datetime = time();
         if ($new_user->save() === true) {
             F\Core::redirect('home', 'main');
         }
     } else {
         F\View::add_template('create');
     }
 }
 public function dispatch()
 {
     try {
         $this->initController();
         View::$controllerName = $this->controllerName;
         View::$actionName = $this->actionName;
         call_user_func_array([$this->controller, $this->actionName], $this->requestParams);
     } catch (ApplicationException $e) {
         $_SESSION["errors"] = $e->getMessage();
         Helpers::redirect("error");
     } catch (\Exception $e) {
         Helpers::redirect("error");
     }
     unset($_SESSION["errors"]);
     $_SESSION["binding-errors"] = [];
 }
 public function displayError($error)
 {
     try {
         $view = View::getInstance();
         $view->display('errors.' . $error);
     } catch (\Exception $ex) {
         Common::headerStatus($error);
         echo '<h1>' . $error . '</h1>';
         exit;
     }
 }
Exemple #10
0
            $rain->assign(self::$variables);
            if (self::$configuration['start_with'] !== null) {
                $rain->draw(self::$configuration['start_with'], false);
            }
            // Recorremos el arreglo de plantillas y las vamos mostrando
            foreach (self::$templates as $template) {
                $rain->draw($template, false);
            }
            if (self::$configuration['end_with'] !== null) {
                $rain->draw(self::$configuration['end_with'], false);
            }
        } else {
            //TODO: Considerar idiomas
            if (count(self::$variables) >= 1) {
                echo json_encode(self::$variables);
            }
        }
    }
}
// class View();
/**
 * Excepción exclusiva del componente View
 * @access private
 */
class View_Exception extends \Exception
{
}
// class View_Exception();
// Iniciamos el componente.
View::init();
Exemple #11
0
 public function displayError($code)
 {
     try {
         $view = \Framework\View::getInstance();
         $view->display('errors.' . $code);
     } catch (\Exception $exc) {
         \Framework\Common::headerStatus($code);
         echo '<h1>' . $error . '</h1>';
         exit;
     }
 }
 public function displayError(\Exception $error)
 {
     $message = ['error' => $error->getMessage(), 'isLogged' => $this->_session->userid];
     try {
         $view = View::getInstance();
         $view->display('error', $message);
     } catch (\Exception $ex) {
         Common::headerStatus($error);
         echo '<h1>' . $error->getMessage() . '</h1>';
         exit;
     }
 }