@@ -7,78 +7,78 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Template |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * @var string |
|
| 12 | - */ |
|
| 13 | - private $_template = 'default'; |
|
| 10 | + /** |
|
| 11 | + * @var string |
|
| 12 | + */ |
|
| 13 | + private $_template = 'default'; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - private $_title = ''; |
|
| 15 | + /** |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + private $_title = ''; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - private $_properties = []; |
|
| 20 | + /** |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + private $_properties = []; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Método para setear propiedades |
|
| 27 | - * @param string $prop |
|
| 28 | - * @param mixed $value |
|
| 29 | - */ |
|
| 30 | - public function set($prop, $value) |
|
| 31 | - { |
|
| 32 | - $this->_properties[$prop] = $value; |
|
| 33 | - } |
|
| 25 | + /** |
|
| 26 | + * Método para setear propiedades |
|
| 27 | + * @param string $prop |
|
| 28 | + * @param mixed $value |
|
| 29 | + */ |
|
| 30 | + public function set($prop, $value) |
|
| 31 | + { |
|
| 32 | + $this->_properties[$prop] = $value; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Método para obtener propiedades |
|
| 38 | - * @param string $prop |
|
| 39 | - * @return mixed|null |
|
| 40 | - */ |
|
| 41 | - public function get($prop) |
|
| 42 | - { |
|
| 43 | - return isset($this->_properties[$prop]) ? $this->_properties[$prop] : null; |
|
| 44 | - } |
|
| 36 | + /** |
|
| 37 | + * Método para obtener propiedades |
|
| 38 | + * @param string $prop |
|
| 39 | + * @return mixed|null |
|
| 40 | + */ |
|
| 41 | + public function get($prop) |
|
| 42 | + { |
|
| 43 | + return isset($this->_properties[$prop]) ? $this->_properties[$prop] : null; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Permite asignar el template manualmente |
|
| 48 | - * @param string $template |
|
| 49 | - */ |
|
| 50 | - public function setTemplate($template) |
|
| 51 | - { |
|
| 52 | - $this->_template = $template; |
|
| 53 | - } |
|
| 46 | + /** |
|
| 47 | + * Permite asignar el template manualmente |
|
| 48 | + * @param string $template |
|
| 49 | + */ |
|
| 50 | + public function setTemplate($template) |
|
| 51 | + { |
|
| 52 | + $this->_template = $template; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Permite asignar el title manualmente |
|
| 57 | - * @param string $title |
|
| 58 | - */ |
|
| 59 | - public function setTitle($title) |
|
| 60 | - { |
|
| 61 | - $this->_title = $title; |
|
| 62 | - } |
|
| 55 | + /** |
|
| 56 | + * Permite asignar el title manualmente |
|
| 57 | + * @param string $title |
|
| 58 | + */ |
|
| 59 | + public function setTitle($title) |
|
| 60 | + { |
|
| 61 | + $this->_title = $title; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Permite renderizar una vista dentro de la plantilla |
|
| 68 | - * @param string $view |
|
| 69 | - */ |
|
| 70 | - public function render($view) |
|
| 71 | - { |
|
| 72 | - $template_file = PIN_PATH . 'templates' . DS . $this->_template . '.phtml'; |
|
| 66 | + /** |
|
| 67 | + * Permite renderizar una vista dentro de la plantilla |
|
| 68 | + * @param string $view |
|
| 69 | + */ |
|
| 70 | + public function render($view) |
|
| 71 | + { |
|
| 72 | + $template_file = PIN_PATH . 'templates' . DS . $this->_template . '.phtml'; |
|
| 73 | 73 | |
| 74 | - ob_start(); |
|
| 75 | - load_view($view, $this->_properties); |
|
| 76 | - $yield = ob_get_clean(); |
|
| 77 | - if (file_exists($template_file)) { |
|
| 78 | - $title = $this->_title; |
|
| 79 | - include $template_file; |
|
| 80 | - } else { |
|
| 81 | - throw new Exception("Archivo de template no encontrado $template_file", 1); |
|
| 82 | - } |
|
| 83 | - } |
|
| 74 | + ob_start(); |
|
| 75 | + load_view($view, $this->_properties); |
|
| 76 | + $yield = ob_get_clean(); |
|
| 77 | + if (file_exists($template_file)) { |
|
| 78 | + $title = $this->_title; |
|
| 79 | + include $template_file; |
|
| 80 | + } else { |
|
| 81 | + throw new Exception("Archivo de template no encontrado $template_file", 1); |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | } |
| 85 | 85 | \ No newline at end of file |