Exemplo n.º 1
0
 /**
  * Método que muestra el contenido de una vista
  */
 public static function content()
 {
     //Verifico si hay mensajes
     if (MkcMessage::has()) {
         MkcMessage::output();
     }
     parent::content();
 }
Exemplo n.º 2
0
 /**
  * Genera la vista
  *
  * @param Controller $controller
  */
 protected static function generate(Controller $controller)
 {
     // Registra la autocarga de helpers
     spl_autoload_register('kumbia_autoload_helper', true, true);
     // Mapea los atributos del controller en el scope
     extract(get_object_vars($controller), EXTR_OVERWRITE);
     // carga la vista si tiene view y no esta cacheada
     if (self::$_view && self::$_content === NULL) {
         // Carga el contenido del buffer de salida
         self::$_content = ob_get_clean();
         // Renderizar vista
         ob_start();
         // carga la vista
         if (!(include self::getView())) {
             throw new KumbiaException('Vista "' . self::getPath() . '" no encontrada', 'no_view');
         }
         // si esta en produccion y se cachea la vista
         self::saveCache('view');
         // Verifica si hay template
         if (!self::$_template) {
             ob_end_flush();
             return;
         }
         self::$_content = ob_get_clean();
     }
     // Renderizar template
     if ($__template = self::$_template) {
         ob_start();
         // carga el template
         if (!(include APP_PATH . "views/_shared/templates/{$__template}.phtml")) {
             throw new KumbiaException("Template {$__template} no encontrado");
         }
         // si esta en produccion y se cachea template
         self::saveCache('template');
         return ob_end_flush();
     }
     echo self::$_content;
 }
Exemplo n.º 3
0
 /**
  * Renderiza la vista
  *
  * @param Controller $controller
  */
 public static function render($controller)
 {
     if (!self::$_view && !self::$_template) {
         return ob_end_flush();
     }
     // Guarda el controlador
     self::$_controller = $controller;
     // Mapea los atributos del controller en el scope
     extract(get_object_vars($controller), EXTR_OVERWRITE);
     // carga la vista si tiene view y no esta cacheada
     if (self::$_view && self::$_content === NULL) {
         // Carga el contenido del buffer de salida
         self::$_content = ob_get_clean();
         // Renderizar vista
         ob_start();
         // carga la vista
         if (!(include self::getView())) {
             throw new KumbiaException('Vista "' . self::getPath() . '" no encontrada', 'no_view');
         }
         // si esta en produccion y se cachea la vista
         if (PRODUCTION && self::$_cache['type'] == 'view') {
             Cache::driver()->save(ob_get_contents(), self::$_cache['time'], Router::get('route'), self::$_cache['group']);
         }
         // Verifica si hay template
         if (!self::$_template) {
             ob_end_flush();
             return;
         }
         self::$_content = ob_get_clean();
     }
     // Renderizar template
     if ($__template = self::$_template) {
         ob_start();
         // carga el template
         if (!(include APP_PATH . "views/_shared/templates/{$__template}.phtml")) {
             throw new KumbiaException("Template {$__template} no encontrado");
         }
         // si esta en produccion y se cachea template
         if (PRODUCTION && self::$_cache['type'] == 'template') {
             Cache::driver()->save(ob_get_contents(), self::$_cache['time'], Router::get('route'), self::$_cache['group']);
         }
         return ob_end_flush();
     }
     echo self::$_content;
 }
Exemplo n.º 4
0
 /**
  * Renderiza la vista
  *
  * @param Controller $controller
  * @param string $url url a renderizar
  */
 public static function render($controller, $_url)
 {
     if (!self::$_view && !self::$_template) {
         return ob_end_flush();
     }
     // Mapea los atributos del controller en el scope
     extract(get_object_vars($controller), EXTR_OVERWRITE);
     // inicia contenido con valor nulo
     self::$_content = NULL;
     // si se encuentra en produccion
     if (PRODUCTION) {
         // si se cachea vista
         if (self::$_cache['type'] == 'view') {
             // el contenido permanece nulo si no hay nada cacheado o la cache expiro
             self::$_content = Cache::driver()->get($_url, self::$_cache['group']);
         }
     }
     // carga la vista si no esta en produccion o se usa scaffold o no hay contenido cargado
     if (!PRODUCTION || $scaffold || !self::$_content) {
         // Carga el contenido del buffer de salida
         self::$_content = ob_get_clean();
         // Renderizar vista
         if ($view = self::$_view) {
             ob_start();
             $file = APP_PATH . 'views/' . self::getPath();
             if (!is_file($file) && $scaffold) {
                 $file = APP_PATH . "views/_shared/scaffolds/{$scaffold}/{$view}.phtml";
             }
             // carga la vista
             if (!(include $file)) {
                 throw new KumbiaException('Vista "' . self::getPath() . '" no encontrada');
             }
             // si esta en produccion y se cachea la vista
             if (PRODUCTION && self::$_cache['type'] == 'view') {
                 Cache::driver()->save(ob_get_contents(), self::$_cache['time'], $_url, self::$_cache['group']);
             }
             // Verifica si hay template
             if (!self::$_template) {
                 ob_end_flush();
                 return;
             }
             self::$_content = ob_get_clean();
         }
     } else {
         ob_clean();
     }
     // Renderizar template
     if ($template = self::$_template) {
         ob_start();
         // carga el template
         if (!(include APP_PATH . "views/_shared/templates/{$template}.phtml")) {
             throw new KumbiaException("Template {$template} no encontrado");
         }
         // si esta en produccion y se cachea template
         if (PRODUCTION && self::$_cache['type'] == 'template') {
             Cache::driver()->save(ob_get_contents(), self::$_cache['time'], $_url, "kumbia.templates");
         }
         return ob_end_flush();
     }
     echo self::$_content;
 }
Exemplo n.º 5
0
 /**
  * Método que muestra el contenido de una vista
  */
 public static function content()
 {
     Flash::output();
     parent::content();
 }