| @@ -7,19 +7,19 @@ | ||
| 7 | 7 | */ | 
| 8 | 8 | class Config | 
| 9 | 9 |  { | 
| 10 | - private static $_db_config = [ | |
| 11 | - 'dsn' => "mysql:host=127.0.0.1;dbname=app;charset=utf8", | |
| 12 | - 'user' => "nelson", | |
| 13 | - 'password' => "s3cret", | |
| 14 | - 'parameters' => [ | |
| 15 | - PDO::ATTR_PERSISTENT => true, | |
| 16 | - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, | |
| 17 | - ] | |
| 18 | - ]; | |
| 10 | + private static $_db_config = [ | |
| 11 | + 'dsn' => "mysql:host=127.0.0.1;dbname=app;charset=utf8", | |
| 12 | + 'user' => "nelson", | |
| 13 | + 'password' => "s3cret", | |
| 14 | + 'parameters' => [ | |
| 15 | + PDO::ATTR_PERSISTENT => true, | |
| 16 | + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, | |
| 17 | + ] | |
| 18 | + ]; | |
| 19 | 19 | |
| 20 | - public static function getDbConfig() | |
| 21 | -	{ | |
| 22 | - return self::$_db_config; | |
| 23 | - } | |
| 20 | + public static function getDbConfig() | |
| 21 | +    { | |
| 22 | + return self::$_db_config; | |
| 23 | + } | |
| 24 | 24 | |
| 25 | 25 | } | 
| 26 | 26 | \ No newline at end of file | 
| @@ -8,49 +8,49 @@ | ||
| 8 | 8 | */ | 
| 9 | 9 | class Session | 
| 10 | 10 |  { | 
| 11 | - /** | |
| 12 | - * Permite obtener una entrada desde la variable $_SESSION | |
| 13 | - * de acuerdo a su clave $key | |
| 14 | - * @param $key | |
| 15 | - * @return mixed | |
| 16 | - */ | |
| 17 | - public static function get($key) | |
| 18 | -	{ | |
| 19 | -		if (empty($_SESSION[$key])) { | |
| 20 | - return null; | |
| 21 | - } | |
| 11 | + /** | |
| 12 | + * Permite obtener una entrada desde la variable $_SESSION | |
| 13 | + * de acuerdo a su clave $key | |
| 14 | + * @param $key | |
| 15 | + * @return mixed | |
| 16 | + */ | |
| 17 | + public static function get($key) | |
| 18 | +    { | |
| 19 | +        if (empty($_SESSION[$key])) { | |
| 20 | + return null; | |
| 21 | + } | |
| 22 | 22 | |
| 23 | - return $_SESSION[$key]; | |
| 24 | - } | |
| 23 | + return $_SESSION[$key]; | |
| 24 | + } | |
| 25 | 25 | |
| 26 | - /** | |
| 27 | - * Permite crear una entrada en la variable $_SESSION | |
| 28 | - * de acuerdo a su clave $key | |
| 29 | - * @param $key | |
| 30 | - * @param mixed $value | |
| 31 | - * @return void | |
| 32 | - */ | |
| 33 | - public static function set($key, $value) | |
| 34 | -	{ | |
| 35 | - $_SESSION[$key] = $value; | |
| 36 | - } | |
| 26 | + /** | |
| 27 | + * Permite crear una entrada en la variable $_SESSION | |
| 28 | + * de acuerdo a su clave $key | |
| 29 | + * @param $key | |
| 30 | + * @param mixed $value | |
| 31 | + * @return void | |
| 32 | + */ | |
| 33 | + public static function set($key, $value) | |
| 34 | +    { | |
| 35 | + $_SESSION[$key] = $value; | |
| 36 | + } | |
| 37 | 37 | |
| 38 | - /** | |
| 39 | - * Permite eliminar una entrada en la variable $_SESSION | |
| 40 | - * de acuerdo a su clave $key | |
| 41 | - * @param $key | |
| 42 | - * @return void | |
| 43 | - */ | |
| 44 | - public static function delete($key) | |
| 45 | -	{ | |
| 46 | - unset($_SESSION[$key]); | |
| 47 | - } | |
| 38 | + /** | |
| 39 | + * Permite eliminar una entrada en la variable $_SESSION | |
| 40 | + * de acuerdo a su clave $key | |
| 41 | + * @param $key | |
| 42 | + * @return void | |
| 43 | + */ | |
| 44 | + public static function delete($key) | |
| 45 | +    { | |
| 46 | + unset($_SESSION[$key]); | |
| 47 | + } | |
| 48 | 48 | |
| 49 | - /** | |
| 50 | - * Permite cerrar la sesión | |
| 51 | - */ | |
| 52 | - public static function destroy() | |
| 53 | -	{ | |
| 54 | - session_destroy(); | |
| 55 | - } | |
| 49 | + /** | |
| 50 | + * Permite cerrar la sesión | |
| 51 | + */ | |
| 52 | + public static function destroy() | |
| 53 | +    { | |
| 54 | + session_destroy(); | |
| 55 | + } | |
| 56 | 56 | } | 
| @@ -7,62 +7,62 @@ | ||
| 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 array | |
| 17 | - */ | |
| 18 | - private $_properties = []; | |
| 15 | + /** | |
| 16 | + * @var array | |
| 17 | + */ | |
| 18 | + private $_properties = []; | |
| 19 | 19 | |
| 20 | - /** | |
| 21 | - * Método mágico para setear propiedades | |
| 22 | - * @param string $prop | |
| 23 | - * @param mixed $value | |
| 24 | - */ | |
| 25 | - public function __set($prop, $value) | |
| 26 | -	{ | |
| 27 | - $this->_properties[$prop] = $value; | |
| 28 | - } | |
| 20 | + /** | |
| 21 | + * Método mágico para setear propiedades | |
| 22 | + * @param string $prop | |
| 23 | + * @param mixed $value | |
| 24 | + */ | |
| 25 | + public function __set($prop, $value) | |
| 26 | +    { | |
| 27 | + $this->_properties[$prop] = $value; | |
| 28 | + } | |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - /** | |
| 32 | - * Método mágico para obtener propiedades | |
| 33 | - * @param string $prop | |
| 34 | - * @return mixed|null | |
| 35 | - */ | |
| 36 | - public function __get($prop) | |
| 37 | -	{ | |
| 38 | - return isset($this->_properties[$prop]) ? $this->_properties[$prop] : null; | |
| 39 | - } | |
| 31 | + /** | |
| 32 | + * Método mágico para obtener propiedades | |
| 33 | + * @param string $prop | |
| 34 | + * @return mixed|null | |
| 35 | + */ | |
| 36 | + public function __get($prop) | |
| 37 | +    { | |
| 38 | + return isset($this->_properties[$prop]) ? $this->_properties[$prop] : null; | |
| 39 | + } | |
| 40 | 40 | |
| 41 | - /** | |
| 42 | - * Permite setear el template manualmente | |
| 43 | - * @param string $template | |
| 44 | - */ | |
| 45 | - public function setTemplate($template) | |
| 46 | -	{ | |
| 47 | - $this->_template = $template; | |
| 48 | - } | |
| 41 | + /** | |
| 42 | + * Permite setear el template manualmente | |
| 43 | + * @param string $template | |
| 44 | + */ | |
| 45 | + public function setTemplate($template) | |
| 46 | +    { | |
| 47 | + $this->_template = $template; | |
| 48 | + } | |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** | |
| 52 | - * Permite renderizar una vista dentro de la plantilla | |
| 53 | - * @param string $view | |
| 54 | - */ | |
| 55 | - public function render($view) | |
| 56 | -	{ | |
| 57 | - $template_file = PIN_PATH . 'templates' . DS . $this->_template . '.phtml'; | |
| 51 | + /** | |
| 52 | + * Permite renderizar una vista dentro de la plantilla | |
| 53 | + * @param string $view | |
| 54 | + */ | |
| 55 | + public function render($view) | |
| 56 | +    { | |
| 57 | + $template_file = PIN_PATH . 'templates' . DS . $this->_template . '.phtml'; | |
| 58 | 58 | |
| 59 | - ob_start(); | |
| 60 | - load_view($view, $this->_properties); | |
| 61 | - $yield = ob_get_clean(); | |
| 62 | -		if (file_exists($template_file)) { | |
| 63 | - include $template_file; | |
| 64 | -		} else { | |
| 65 | -			throw new Exception("Archivo de template no encontrado $template_file", 1); | |
| 66 | - } | |
| 67 | - } | |
| 59 | + ob_start(); | |
| 60 | + load_view($view, $this->_properties); | |
| 61 | + $yield = ob_get_clean(); | |
| 62 | +        if (file_exists($template_file)) { | |
| 63 | + include $template_file; | |
| 64 | +        } else { | |
| 65 | +            throw new Exception("Archivo de template no encontrado $template_file", 1); | |
| 66 | + } | |
| 67 | + } | |
| 68 | 68 | } | 
| 69 | 69 | \ No newline at end of file | 
| @@ -6,7 +6,7 @@ discard block | ||
| 6 | 6 | * @return string | 
| 7 | 7 | */ | 
| 8 | 8 |  function javascript_include_tag($src){ | 
| 9 | - return "<script type='text/javascript' src='".PUBLIC_PATH."js/$src.js'></script>\r\n"; | |
| 9 | + return "<script type='text/javascript' src='".PUBLIC_PATH."js/$src.js'></script>\r\n"; | |
| 10 | 10 | } | 
| 11 | 11 | |
| 12 | 12 | /** | 
| @@ -15,7 +15,7 @@ discard block | ||
| 15 | 15 | * @return string | 
| 16 | 16 | */ | 
| 17 | 17 |  function stylesheet_link($src=''){ | 
| 18 | - return "<link rel='stylesheet' type='text/css' href='".PUBLIC_PATH."css/$src.css'/>\r\n"; | |
| 18 | + return "<link rel='stylesheet' type='text/css' href='".PUBLIC_PATH."css/$src.css'/>\r\n"; | |
| 19 | 19 | } | 
| 20 | 20 | |
| 21 | 21 | /** | 
| @@ -26,7 +26,7 @@ discard block | ||
| 26 | 26 | * @return string | 
| 27 | 27 | */ | 
| 28 | 28 |  function link_to($action, $text, $attributes=''){ | 
| 29 | - return "<a href='".PUBLIC_PATH."$action' $attributes>$text</a>"; | |
| 29 | + return "<a href='".PUBLIC_PATH."$action' $attributes>$text</a>"; | |
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | 32 | /** | 
| @@ -36,7 +36,7 @@ discard block | ||
| 36 | 36 | * @return string | 
| 37 | 37 | */ | 
| 38 | 38 |  function img_tag($img, $attributes=''){ | 
| 39 | - return "<img src='".PUBLIC_PATH."img/$img' $attributes />\r\n"; | |
| 39 | + return "<img src='".PUBLIC_PATH."img/$img' $attributes />\r\n"; | |
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | 42 | /** | 
| @@ -46,7 +46,7 @@ discard block | ||
| 46 | 46 | * @return string | 
| 47 | 47 | */ | 
| 48 | 48 |  function form_tag($action, $attributes=''){ | 
| 49 | - return "<form action='".PUBLIC_PATH."$action' $attributes>\r\n"; | |
| 49 | + return "<form action='".PUBLIC_PATH."$action' $attributes>\r\n"; | |
| 50 | 50 | } | 
| 51 | 51 | |
| 52 | 52 | /** | 
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 | * @return string | 
| 55 | 55 | */ | 
| 56 | 56 |  function end_form_tag(){ | 
| 57 | - return "</form>\r\n"; | |
| 57 | + return "</form>\r\n"; | |
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | 60 | /** | 
| @@ -64,7 +64,7 @@ discard block | ||
| 64 | 64 | * @return string | 
| 65 | 65 | */ | 
| 66 | 66 |  function submit_tag($caption, $attributes=''){ | 
| 67 | - return "<input type='submit' value='$caption' $attributes />\r\n"; | |
| 67 | + return "<input type='submit' value='$caption' $attributes />\r\n"; | |
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | 70 | /** | 
| @@ -75,7 +75,7 @@ discard block | ||
| 75 | 75 | * @return string | 
| 76 | 76 | */ | 
| 77 | 77 |  function button_tag($caption, $type='button', $attributes=''){ | 
| 78 | - return "<button type='$type' $attributes>$caption</button>\r\n"; | |
| 78 | + return "<button type='$type' $attributes>$caption</button>\r\n"; | |
| 79 | 79 | } | 
| 80 | 80 | |
| 81 | 81 | /** | 
| @@ -85,13 +85,13 @@ discard block | ||
| 85 | 85 | */ | 
| 86 | 86 | function get_field_name_and_id($name) | 
| 87 | 87 |  { | 
| 88 | - $id=""; | |
| 89 | -	if (strpos($name, ".") != false) { | |
| 90 | -		$items = explode(".", $name); | |
| 91 | -		$id=" id='{$items[0]}_{$items[1]}' "; | |
| 92 | - $name = $items[0]."[".$items[1]."]"; | |
| 93 | - } | |
| 94 | - return [$id, $name]; | |
| 88 | + $id=""; | |
| 89 | +    if (strpos($name, ".") != false) { | |
| 90 | +        $items = explode(".", $name); | |
| 91 | +        $id=" id='{$items[0]}_{$items[1]}' "; | |
| 92 | + $name = $items[0]."[".$items[1]."]"; | |
| 93 | + } | |
| 94 | + return [$id, $name]; | |
| 95 | 95 | } | 
| 96 | 96 | |
| 97 | 97 | /** | 
| @@ -102,9 +102,9 @@ discard block | ||
| 102 | 102 | * @return string | 
| 103 | 103 | */ | 
| 104 | 104 |  function text_field_tag($name, $value='', $attributes=''){ | 
| 105 | - list($id, $name) = get_field_name_and_id($name); | |
| 105 | + list($id, $name) = get_field_name_and_id($name); | |
| 106 | 106 | |
| 107 | - return "<input type='text' name='$name' $id value='$value' $attributes />\r\n"; | |
| 107 | + return "<input type='text' name='$name' $id value='$value' $attributes />\r\n"; | |
| 108 | 108 | } | 
| 109 | 109 | |
| 110 | 110 | /** | 
| @@ -115,9 +115,9 @@ discard block | ||
| 115 | 115 | * @return string | 
| 116 | 116 | */ | 
| 117 | 117 |  function password_field_tag($name, $value='', $attributes=''){ | 
| 118 | - list($id, $name) = get_field_name_and_id($name); | |
| 118 | + list($id, $name) = get_field_name_and_id($name); | |
| 119 | 119 | |
| 120 | - return "<input type='password' name='$name' $id value='$value' $attributes />\r\n"; | |
| 120 | + return "<input type='password' name='$name' $id value='$value' $attributes />\r\n"; | |
| 121 | 121 | } | 
| 122 | 122 | |
| 123 | 123 | /** | 
| @@ -128,9 +128,9 @@ discard block | ||
| 128 | 128 | * @return string | 
| 129 | 129 | */ | 
| 130 | 130 |  function text_area_tag($name, $value='', $attributes=''){ | 
| 131 | - list($id, $name) = get_field_name_and_id($name); | |
| 131 | + list($id, $name) = get_field_name_and_id($name); | |
| 132 | 132 | |
| 133 | - return "<textarea name='$name' $id $attributes>$value</textarea>\r\n"; | |
| 133 | + return "<textarea name='$name' $id $attributes>$value</textarea>\r\n"; | |
| 134 | 134 | } | 
| 135 | 135 | |
| 136 | 136 | /** | 
| @@ -141,9 +141,9 @@ discard block | ||
| 141 | 141 | * @return string | 
| 142 | 142 | */ | 
| 143 | 143 |  function hidden_field_tag($name, $value='', $attributes=''){ | 
| 144 | - list($id, $name) = get_field_name_and_id($name); | |
| 144 | + list($id, $name) = get_field_name_and_id($name); | |
| 145 | 145 | |
| 146 | - return "<input type='hidden' name='$name' $id value='$value' $attributes />\r\n"; | |
| 146 | + return "<input type='hidden' name='$name' $id value='$value' $attributes />\r\n"; | |
| 147 | 147 | } | 
| 148 | 148 | |
| 149 | 149 | /** | 
| @@ -156,9 +156,9 @@ discard block | ||
| 156 | 156 | * @return string | 
| 157 | 157 | */ | 
| 158 | 158 |  function check_box_tag($name, $value, $text, $checked=false, $attributes=''){ | 
| 159 | - list($id, $name) = get_field_name_and_id($name); | |
| 160 | - $checked = $checked == true ? ' checked ' : ''; | |
| 161 | - return "<input type='checkbox' $id name='$name' $checked $attributes value='$value'/>\r\n"; | |
| 159 | + list($id, $name) = get_field_name_and_id($name); | |
| 160 | + $checked = $checked == true ? ' checked ' : ''; | |
| 161 | + return "<input type='checkbox' $id name='$name' $checked $attributes value='$value'/>\r\n"; | |
| 162 | 162 | } | 
| 163 | 163 | |
| 164 | 164 | /** | 
| @@ -170,9 +170,9 @@ discard block | ||
| 170 | 170 | * @return string | 
| 171 | 171 | */ | 
| 172 | 172 |  function radio_button_tag($name, $value, $checked=false, $attributes=''){ | 
| 173 | - list($id, $name) = get_field_name_and_id($name); | |
| 174 | - $checked = $checked == true ? ' checked ' : ''; | |
| 175 | - return "<input type='radio' $id name='$name' $checked $attributes value='$value'/>\r\n"; | |
| 173 | + list($id, $name) = get_field_name_and_id($name); | |
| 174 | + $checked = $checked == true ? ' checked ' : ''; | |
| 175 | + return "<input type='radio' $id name='$name' $checked $attributes value='$value'/>\r\n"; | |
| 176 | 176 | } | 
| 177 | 177 | |
| 178 | 178 | /** | 
| @@ -195,14 +195,14 @@ discard block | ||
| 195 | 195 | * @return string | 
| 196 | 196 | */ | 
| 197 | 197 |  function select_tag($name, $options='', $include_blank=false, $attributes=''){ | 
| 198 | - list($id, $name) = get_field_name_and_id($name); | |
| 198 | + list($id, $name) = get_field_name_and_id($name); | |
| 199 | 199 | |
| 200 | - $code = ""; | |
| 201 | -	if ($include_blank != false) { | |
| 202 | - $code="<option value=''>$include_blank</option>\r\n"; | |
| 203 | - } | |
| 200 | + $code = ""; | |
| 201 | +    if ($include_blank != false) { | |
| 202 | + $code="<option value=''>$include_blank</option>\r\n"; | |
| 203 | + } | |
| 204 | 204 | |
| 205 | - return "<select $id name='$name' $attributes>\r\n$code$options</select>\r\n"; | |
| 205 | + return "<select $id name='$name' $attributes>\r\n$code$options</select>\r\n"; | |
| 206 | 206 | |
| 207 | 207 | } | 
| 208 | 208 | |
| @@ -216,15 +216,15 @@ discard block | ||
| 216 | 216 | */ | 
| 217 | 217 | function options_for_dbselect($data, $show, $value, $selected='') | 
| 218 | 218 |  { | 
| 219 | - $code=""; | |
| 220 | -	foreach($data as $item) { | |
| 221 | - $selected_tag=""; | |
| 222 | -		if ($selected == $item[$value]){ | |
| 223 | - $selected_tag = " selected='selected' "; | |
| 224 | - } | |
| 225 | -		$code.="<option value='{$item[$value]}' $selected_tag>{$item[$show]}</option>\r\n"; | |
| 226 | - } | |
| 227 | - return $code; | |
| 219 | + $code=""; | |
| 220 | +    foreach($data as $item) { | |
| 221 | + $selected_tag=""; | |
| 222 | +        if ($selected == $item[$value]){ | |
| 223 | + $selected_tag = " selected='selected' "; | |
| 224 | + } | |
| 225 | +        $code.="<option value='{$item[$value]}' $selected_tag>{$item[$show]}</option>\r\n"; | |
| 226 | + } | |
| 227 | + return $code; | |
| 228 | 228 | } | 
| 229 | 229 | |
| 230 | 230 | /** | 
| @@ -235,15 +235,15 @@ discard block | ||
| 235 | 235 | */ | 
| 236 | 236 | function options_for_select($data, $selected='') | 
| 237 | 237 |  { | 
| 238 | - $code=""; | |
| 239 | -	foreach($data as $key => $value) { | |
| 240 | - $selected_tag=""; | |
| 241 | -		if ($selected == $value){ | |
| 242 | - $selected_tag = " selected='selected' "; | |
| 243 | - } | |
| 244 | - $code.="<option value='$key' $selected_tag>$value</option>\r\n"; | |
| 245 | - } | |
| 246 | - return $code; | |
| 238 | + $code=""; | |
| 239 | +    foreach($data as $key => $value) { | |
| 240 | + $selected_tag=""; | |
| 241 | +        if ($selected == $value){ | |
| 242 | + $selected_tag = " selected='selected' "; | |
| 243 | + } | |
| 244 | + $code.="<option value='$key' $selected_tag>$value</option>\r\n"; | |
| 245 | + } | |
| 246 | + return $code; | |
| 247 | 247 | } | 
| 248 | 248 | |
| 249 | 249 | /** | 
| @@ -253,8 +253,8 @@ discard block | ||
| 253 | 253 | * @return string | 
| 254 | 254 | */ | 
| 255 | 255 |  function js_redirect_to($action, $seconds = 0.01){ | 
| 256 | - $seconds*=1000; | |
| 257 | -	return "<script type=\"text/javascript\">setTimeout('window.location=\"?/$action\"', $seconds)</script>"; | |
| 256 | + $seconds*=1000; | |
| 257 | +    return "<script type=\"text/javascript\">setTimeout('window.location=\"?/$action\"', $seconds)</script>"; | |
| 258 | 258 | } | 
| 259 | 259 | |
| 260 | 260 | /** | 
| @@ -265,5 +265,5 @@ discard block | ||
| 265 | 265 | * @return string | 
| 266 | 266 | */ | 
| 267 | 267 |  function button_to_action($caption, $action, $attributes=''){ | 
| 268 | - return "<button type='button' $attributes onclick='window.location=\"".PUBLIC_PATH."$action\"'>$caption</button>"; | |
| 268 | + return "<button type='button' $attributes onclick='window.location=\"".PUBLIC_PATH."$action\"'>$caption</button>"; | |
| 269 | 269 | } | 
| @@ -2,15 +2,15 @@ | ||
| 2 | 2 | |
| 3 | 3 | function signin() | 
| 4 | 4 |  { | 
| 5 | -	Session::set("is_logged_in", true); | |
| 6 | -	Session::set("flash", "Bienvenido!"); | |
| 7 | -	return redirect_to(""); | |
| 5 | +    Session::set("is_logged_in", true); | |
| 6 | +    Session::set("flash", "Bienvenido!"); | |
| 7 | +    return redirect_to(""); | |
| 8 | 8 | } | 
| 9 | 9 | |
| 10 | 10 | function signout() | 
| 11 | 11 |  { | 
| 12 | - Session::destroy(); | |
| 13 | -	Session::set("flash", "Adios!"); | |
| 14 | -	return redirect_to(""); | |
| 12 | + Session::destroy(); | |
| 13 | +    Session::set("flash", "Adios!"); | |
| 14 | +    return redirect_to(""); | |
| 15 | 15 | } | 
| 16 | 16 | |
| @@ -2,12 +2,12 @@ | ||
| 2 | 2 | |
| 3 | 3 | function index() | 
| 4 | 4 |  { | 
| 5 | - $template = new Template(); | |
| 6 | - $template->saludo = "Saludo interno"; | |
| 7 | -	$template->render("default/index"); | |
| 5 | + $template = new Template(); | |
| 6 | + $template->saludo = "Saludo interno"; | |
| 7 | +    $template->render("default/index"); | |
| 8 | 8 | } | 
| 9 | 9 | |
| 10 | 10 | function redirigir() | 
| 11 | 11 |  { | 
| 12 | -	return redirect_to("page/show"); | |
| 12 | +    return redirect_to("page/show"); | |
| 13 | 13 | } | 
| @@ -3,31 +3,31 @@ | ||
| 3 | 3 | |
| 4 | 4 | function page_initializer() | 
| 5 | 5 |  { | 
| 6 | -	if (Session::get("is_logged_in") !== true) { | |
| 7 | - //ir a la pagina inicial | |
| 8 | -		Session::set("flash", "Debe iniciar sesión para acceder al recurso *<i>page</i>*"); | |
| 9 | -		return redirect_to(""); | |
| 10 | - } | |
| 6 | +    if (Session::get("is_logged_in") !== true) { | |
| 7 | + //ir a la pagina inicial | |
| 8 | +        Session::set("flash", "Debe iniciar sesión para acceder al recurso *<i>page</i>*"); | |
| 9 | +        return redirect_to(""); | |
| 10 | + } | |
| 11 | 11 | } | 
| 12 | 12 | |
| 13 | 13 | function show($slug = '') | 
| 14 | 14 |  { | 
| 15 | - $template = new Template(); | |
| 16 | - $template->slug = $slug; | |
| 17 | -	$template->render("page/show"); | |
| 15 | + $template = new Template(); | |
| 16 | + $template->slug = $slug; | |
| 17 | +    $template->render("page/show"); | |
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | 20 | function edit() | 
| 21 | 21 |  { | 
| 22 | - $template = new Template(); | |
| 23 | -	$template->render("page/edit");	 | |
| 22 | + $template = new Template(); | |
| 23 | +    $template->render("page/edit");	 | |
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | 26 | function update() | 
| 27 | 27 |  { | 
| 28 | - $template = new Template(); | |
| 29 | -	Session::set("flash", "Página actualizada correctamente"); | |
| 30 | -	$template->render("page/edit");	 | |
| 28 | + $template = new Template(); | |
| 29 | +    Session::set("flash", "Página actualizada correctamente"); | |
| 30 | +    $template->render("page/edit");	 | |
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | 33 | |
| @@ -2,58 +2,58 @@ discard block | ||
| 2 | 2 | |
| 3 | 3 | function load_file($file, $extension, $base_dir, $classification, $parameters = null) | 
| 4 | 4 |  { | 
| 5 | -	if (isset($parameters) && is_array($parameters)) { | |
| 6 | - extract($parameters); | |
| 7 | - } | |
| 8 | -	if (file_exists($base_dir . $file . $extension)) {	 | |
| 9 | - require $base_dir . $file . $extension; | |
| 10 | -	} else { | |
| 11 | -		throw (new Exception("$classification <b>$file</b> no existe!")); | |
| 12 | - return; | |
| 13 | - } | |
| 5 | +    if (isset($parameters) && is_array($parameters)) { | |
| 6 | + extract($parameters); | |
| 7 | + } | |
| 8 | +    if (file_exists($base_dir . $file . $extension)) {	 | |
| 9 | + require $base_dir . $file . $extension; | |
| 10 | +    } else { | |
| 11 | +        throw (new Exception("$classification <b>$file</b> no existe!")); | |
| 12 | + return; | |
| 13 | + } | |
| 14 | 14 | } | 
| 15 | 15 | |
| 16 | 16 | function load_lib($lib) | 
| 17 | 17 |  { | 
| 18 | - load_file($lib, ".php", PIN_PATH . 'libs' . DS, "Librería"); | |
| 18 | + load_file($lib, ".php", PIN_PATH . 'libs' . DS, "Librería"); | |
| 19 | 19 | } | 
| 20 | 20 | |
| 21 | 21 | function load_config($config) | 
| 22 | 22 |  { | 
| 23 | - load_file($config, ".php", PIN_PATH . 'config' . DS, "Configuración"); | |
| 23 | + load_file($config, ".php", PIN_PATH . 'config' . DS, "Configuración"); | |
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | function load_helper($helper) | 
| 28 | 28 |  { | 
| 29 | - load_file($helper, ".php", PIN_PATH . 'helpers' . DS, "Helper"); | |
| 29 | + load_file($helper, ".php", PIN_PATH . 'helpers' . DS, "Helper"); | |
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | 32 | function load_view($view, array $parameters = null) | 
| 33 | 33 |  { | 
| 34 | - load_file($view, ".phtml", PIN_PATH . 'views' . DS, "Vista", $parameters); | |
| 34 | + load_file($view, ".phtml", PIN_PATH . 'views' . DS, "Vista", $parameters); | |
| 35 | 35 | } | 
| 36 | 36 | |
| 37 | 37 | function load_partial($partial, array $parameters = null) | 
| 38 | 38 |  { | 
| 39 | - load_file($partial, ".phtml", PIN_PATH . 'partials'. DS , "Parcial", $parameters); | |
| 39 | + load_file($partial, ".phtml", PIN_PATH . 'partials'. DS , "Parcial", $parameters); | |
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | 42 | function redirect_to($url) | 
| 43 | 43 |  { | 
| 44 | - $url = PUBLIC_PATH . $url; | |
| 45 | -	header("Location: $url", 301); | |
| 44 | + $url = PUBLIC_PATH . $url; | |
| 45 | +    header("Location: $url", 301); | |
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | 48 | //implementar autoloader para clases | 
| 49 | 49 |  spl_autoload_register(function($className){ | 
| 50 | - $file = PIN_PATH . 'libs' . DS . strtolower($className) . '.php'; | |
| 51 | -	if (file_exists($file)) { | |
| 52 | - require_once $file; | |
| 53 | - return; | |
| 54 | -	} else { | |
| 55 | -		throw new Exception("$className no existe en $file", 1);		 | |
| 56 | - } | |
| 50 | + $file = PIN_PATH . 'libs' . DS . strtolower($className) . '.php'; | |
| 51 | +    if (file_exists($file)) { | |
| 52 | + require_once $file; | |
| 53 | + return; | |
| 54 | +    } else { | |
| 55 | +        throw new Exception("$className no existe en $file", 1);		 | |
| 56 | + } | |
| 57 | 57 | }); | 
| 58 | 58 | |
| 59 | 59 | |
| @@ -77,7 +77,7 @@ discard block | ||
| 77 | 77 | |
| 78 | 78 |      if (error_reporting() !== 0) { | 
| 79 | 79 | |
| 80 | - echo "<h1>Fatal error</h1>"; | |
| 80 | + echo "<h1>Fatal error</h1>"; | |
| 81 | 81 | echo "<p>Uncaught exception: '" . get_class($exception) . "'</p>"; | 
| 82 | 82 | echo "<p>Message: '" . $exception->getMessage() . "'</p>"; | 
| 83 | 83 | echo "<p>Stack trace:<pre>" . $exception->getTraceAsString() . "</pre></p>"; | 
| @@ -89,32 +89,32 @@ discard block | ||
| 89 | 89 | |
| 90 | 90 | function load_page_from_url($url) | 
| 91 | 91 |  { | 
| 92 | -	$content = explode('/', $url); | |
| 92 | +    $content = explode('/', $url); | |
| 93 | 93 | //quitar el elemento inicial vacio | 
| 94 | 94 | array_shift($content); | 
| 95 | 95 | |
| 96 | - $page = !empty($content[0]) ? trim($content[0]) : 'default'; | |
| 97 | - array_shift($content); | |
| 96 | + $page = !empty($content[0]) ? trim($content[0]) : 'default'; | |
| 97 | + array_shift($content); | |
| 98 | 98 | |
| 99 | -	if (file_exists(PIN_PATH . 'pages' . DS . $page . '.php')) { | |
| 100 | - require PIN_PATH . 'pages' . DS . $page . '.php'; | |
| 101 | -	} else { | |
| 102 | -		throw (new Exception("La página <b>$page</b> no existe!")); | |
| 103 | - return; | |
| 104 | - } | |
| 99 | +    if (file_exists(PIN_PATH . 'pages' . DS . $page . '.php')) { | |
| 100 | + require PIN_PATH . 'pages' . DS . $page . '.php'; | |
| 101 | +    } else { | |
| 102 | +        throw (new Exception("La página <b>$page</b> no existe!")); | |
| 103 | + return; | |
| 104 | + } | |
| 105 | 105 | |
| 106 | - $function_to_be_load = !empty($content[0]) ? trim($content[0]) : 'index'; | |
| 107 | - array_shift($content); | |
| 106 | + $function_to_be_load = !empty($content[0]) ? trim($content[0]) : 'index'; | |
| 107 | + array_shift($content); | |
| 108 | 108 | |
| 109 | -	if (function_exists("page_initializer")) { | |
| 110 | -		call_user_func("page_initializer"); | |
| 111 | - } | |
| 109 | +    if (function_exists("page_initializer")) { | |
| 110 | +        call_user_func("page_initializer"); | |
| 111 | + } | |
| 112 | 112 | |
| 113 | -	if (function_exists($function_to_be_load)) { | |
| 114 | - call_user_func_array($function_to_be_load, $content); | |
| 115 | -	} else { | |
| 116 | -		throw (new Exception("La función <b>$function_to_be_load</b> no existe en la página <b>$page</b>!")); | |
| 117 | - return; | |
| 118 | - } | |
| 113 | +    if (function_exists($function_to_be_load)) { | |
| 114 | + call_user_func_array($function_to_be_load, $content); | |
| 115 | +    } else { | |
| 116 | +        throw (new Exception("La función <b>$function_to_be_load</b> no existe en la página <b>$page</b>!")); | |
| 117 | + return; | |
| 118 | + } | |
| 119 | 119 | |
| 120 | 120 | } | 
| 121 | 121 | \ No newline at end of file |