68 protected static $_cache = array(
'type' => FALSE,
'time' => FALSE,
'group' => FALSE);
83 public static function select($view, $template = FALSE)
88 if ($template !== FALSE) {
89 self::$_template = $template;
98 public static function template($template)
100 self::$_template = $template;
112 public static function response($response, $template = FALSE)
114 if ($response ==
'view') {
115 self::$_template = NULL;
117 self::$_response = $response;
121 if ($template !== FALSE) {
122 self::$_template = $template;
133 self::$_path = $path .
'/';
143 if (self::$_response)
144 return self::$_path . self::$_view .
'.' . self::$_response .
'.phtml';
146 return self::$_path . self::$_view .
'.phtml';
154 public static function get($atribute)
156 return self::${
"_$atribute"};
168 public static function cache($time, $type=
'view', $group=
'kumbia.view')
170 if ($time === FALSE) {
171 self::$_cache[
'type'] = FALSE;
174 self::$_cache[
'type'] = $type;
175 self::$_cache[
'time'] = $time;
176 self::$_cache[
'group'] = $group;
178 if (PRODUCTION && $type ===
'view') {
192 return self::$_content !== NULL;
200 public static function render($controller)
202 if (!self::$_view && !self::$_template)
203 return ob_end_flush();
206 self::$_controller = $controller;
209 extract(get_object_vars($controller), EXTR_OVERWRITE);
212 if (($__view = self::$_view) && self::$_content === NULL) {
214 self::$_content = ob_get_clean();
219 $__file =
APP_PATH .
'views/' . self::getPath();
221 if (!is_file($__file) && $scaffold) {
222 $__file =
APP_PATH .
"views/_shared/scaffolds/$scaffold/$__view.phtml";
226 if (!include $__file)
227 throw new KumbiaException(
'Vista "' . self::getPath() .
'" no encontrada',
'no_view');
230 if (PRODUCTION && self::$_cache[
'type'] ==
'view') {
235 if (!self::$_template) {
240 self::$_content = ob_get_clean();
245 if ($__template = self::$_template) {
249 if (!include
APP_PATH .
"views/_shared/templates/$__template.phtml")
253 if (PRODUCTION && self::$_cache[
'type'] ==
'template') {
257 return ob_end_flush();
260 echo self::$_content;
269 if (isset($_SESSION[
'KUMBIA.CONTENT'])) {
270 echo $_SESSION[
'KUMBIA.CONTENT'];
271 unset($_SESSION[
'KUMBIA.CONTENT']);
273 echo self::$_content;
286 public static function partial($partial, $__time=FALSE, $params=NULL, $group =
'kumbia.partials')
288 if (PRODUCTION && $__time && !
Cache::driver()->start($__time, $partial, $group)) {
293 $__file =
APP_PATH .
"views/_shared/partials/$partial.phtml";
295 if (!is_file($__file)) {
297 $__file =
CORE_PATH .
"views/partials/$partial.phtml";
301 if (is_string($params)) {
306 extract($params, EXTR_OVERWRITE);
310 if (!include $__file) {
311 throw new KumbiaException(
'Vista Parcial "' . $__file .
'" no se encontro');
315 if (PRODUCTION && $__time) {
330 $path =
"extensions/helpers/$helper.php";
333 if (!is_file($file)) {
348 public static function getVar($var = NULL)
350 if(!$var)
return get_object_vars(self::$_controller);
352 return isset(self::$_controller->$var) ? self::$_controller->$var : NULL;
364 function h($s, $charset = APP_CHARSET)
366 return htmlspecialchars($s, ENT_QUOTES, $charset);
377 function eh($s, $charset = APP_CHARSET)
379 echo htmlspecialchars($s, ENT_QUOTES, $charset);