| @@ -6,49 +6,49 @@ | ||
| 6 | 6 | */ | 
| 7 | 7 | class Session | 
| 8 | 8 |  { | 
| 9 | - /** | |
| 10 | - * Permite obtener una entrada desde la variable $_SESSION | |
| 11 | - * de acuerdo a su clave $key | |
| 12 | - * @param string $key | |
| 13 | - * @return mixed | |
| 14 | - */ | |
| 15 | - public static function get(string $key) | |
| 16 | -	{ | |
| 17 | -		if (empty($_SESSION[$key])) { | |
| 18 | - return null; | |
| 19 | - } | |
| 9 | + /** | |
| 10 | + * Permite obtener una entrada desde la variable $_SESSION | |
| 11 | + * de acuerdo a su clave $key | |
| 12 | + * @param string $key | |
| 13 | + * @return mixed | |
| 14 | + */ | |
| 15 | + public static function get(string $key) | |
| 16 | +    { | |
| 17 | +        if (empty($_SESSION[$key])) { | |
| 18 | + return null; | |
| 19 | + } | |
| 20 | 20 | |
| 21 | - return $_SESSION[$key]; | |
| 22 | - } | |
| 21 | + return $_SESSION[$key]; | |
| 22 | + } | |
| 23 | 23 | |
| 24 | - /** | |
| 25 | - * Permite crear una entrada en la variable $_SESSION | |
| 26 | - * de acuerdo a su clave $key | |
| 27 | - * @param string $key | |
| 28 | - * @param mixed $value | |
| 29 | - * @return void | |
| 30 | - */ | |
| 31 | - public static function set(string $key, $value) | |
| 32 | -	{ | |
| 33 | - $_SESSION[$key] = $value; | |
| 34 | - } | |
| 24 | + /** | |
| 25 | + * Permite crear una entrada en la variable $_SESSION | |
| 26 | + * de acuerdo a su clave $key | |
| 27 | + * @param string $key | |
| 28 | + * @param mixed $value | |
| 29 | + * @return void | |
| 30 | + */ | |
| 31 | + public static function set(string $key, $value) | |
| 32 | +    { | |
| 33 | + $_SESSION[$key] = $value; | |
| 34 | + } | |
| 35 | 35 | |
| 36 | - /** | |
| 37 | - * Permite eliminar una entrada en la variable $_SESSION | |
| 38 | - * de acuerdo a su clave $key | |
| 39 | - * @param string $key | |
| 40 | - * @return void | |
| 41 | - */ | |
| 42 | - public static function delete(string $key) | |
| 43 | -	{ | |
| 44 | - unset($_SESSION[$key]); | |
| 45 | - } | |
| 36 | + /** | |
| 37 | + * Permite eliminar una entrada en la variable $_SESSION | |
| 38 | + * de acuerdo a su clave $key | |
| 39 | + * @param string $key | |
| 40 | + * @return void | |
| 41 | + */ | |
| 42 | + public static function delete(string $key) | |
| 43 | +    { | |
| 44 | + unset($_SESSION[$key]); | |
| 45 | + } | |
| 46 | 46 | |
| 47 | - /** | |
| 48 | - * Permite cerrar la sesión | |
| 49 | - */ | |
| 50 | - public static function destroy() | |
| 51 | -	{ | |
| 52 | - session_destroy(); | |
| 53 | - } | |
| 47 | + /** | |
| 48 | + * Permite cerrar la sesión | |
| 49 | + */ | |
| 50 | + public static function destroy() | |
| 51 | +    { | |
| 52 | + session_destroy(); | |
| 53 | + } | |
| 54 | 54 | } | 
| @@ -4,6 +4,6 @@ | ||
| 4 | 4 |  define('DATABASE_USER', "nelson");  | 
| 5 | 5 |  define('DATABASE_PASSWORD', "secret");  | 
| 6 | 6 |  define('DATABASE_PARAMETERS', [ | 
| 7 | - PDO::ATTR_PERSISTENT => true, | |
| 7 | + PDO::ATTR_PERSISTENT => true, | |
| 8 | 8 | PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, | 
| 9 | 9 | ]); | 
| 10 | 10 | \ No newline at end of file | 
| @@ -4,14 +4,14 @@ | ||
| 4 | 4 | |
| 5 | 5 | function signin() | 
| 6 | 6 |  { | 
| 7 | -	Session::set("is_logged_in", true); | |
| 8 | -	Session::set("flash", "Bienvenido!"); | |
| 9 | -	redirect_to(""); | |
| 7 | +    Session::set("is_logged_in", true); | |
| 8 | +    Session::set("flash", "Bienvenido!"); | |
| 9 | +    redirect_to(""); | |
| 10 | 10 | } | 
| 11 | 11 | |
| 12 | 12 | function signout() | 
| 13 | 13 |  { | 
| 14 | - Session::destroy(); | |
| 15 | -	redirect_to(""); | |
| 14 | + Session::destroy(); | |
| 15 | +    redirect_to(""); | |
| 16 | 16 | } | 
| 17 | 17 | |
| @@ -2,10 +2,10 @@ | ||
| 2 | 2 | |
| 3 | 3 | function index() | 
| 4 | 4 |  { | 
| 5 | -	load_view("default/index"); | |
| 5 | +    load_view("default/index"); | |
| 6 | 6 | } | 
| 7 | 7 | |
| 8 | 8 | function redirigir() | 
| 9 | 9 |  { | 
| 10 | -	redirect_to("page/show"); | |
| 10 | +    redirect_to("page/show"); | |
| 11 | 11 | } | 
| 12 | 12 | \ No newline at end of file | 
| @@ -6,22 +6,22 @@ | ||
| 6 | 6 | |
| 7 | 7 | function page_initializer() | 
| 8 | 8 |  { | 
| 9 | -	if (Session::get("is_logged_in") !== true) { | |
| 10 | - //ir a la pagina inicial | |
| 11 | -		Session::set("flash", "Debe iniciar sesión para acceder al recurso *<i>page</i>*"); | |
| 12 | -		redirect_to(""); | |
| 13 | - } | |
| 9 | +    if (Session::get("is_logged_in") !== true) { | |
| 10 | + //ir a la pagina inicial | |
| 11 | +        Session::set("flash", "Debe iniciar sesión para acceder al recurso *<i>page</i>*"); | |
| 12 | +        redirect_to(""); | |
| 13 | + } | |
| 14 | 14 | } | 
| 15 | 15 | |
| 16 | 16 | function show($slug) | 
| 17 | 17 |  { | 
| 18 | -	$users = Db::findAll("SELECT * FROM Usuario"); | |
| 19 | -	load_view("page/show", ['users' => $users, 'slug' => $slug]); | |
| 18 | +    $users = Db::findAll("SELECT * FROM Usuario"); | |
| 19 | +    load_view("page/show", ['users' => $users, 'slug' => $slug]); | |
| 20 | 20 | } | 
| 21 | 21 | |
| 22 | 22 | function edit() | 
| 23 | 23 |  { | 
| 24 | -	$users = Db::findAll("SELECT * FROM Usuario"); | |
| 25 | -	load_view("page/edit", ['users' => $users]); | |
| 24 | +    $users = Db::findAll("SELECT * FROM Usuario"); | |
| 25 | +    load_view("page/edit", ['users' => $users]); | |
| 26 | 26 | } | 
| 27 | 27 | |
| @@ -2,147 +2,147 @@ | ||
| 2 | 2 | |
| 3 | 3 | function javascript_include_tag($src) | 
| 4 | 4 |  { | 
| 5 | - return "<script type='text/javascript' src='" . PUBLIC_PATH . "js/$src.js'></script>\r\n"; | |
| 5 | + return "<script type='text/javascript' src='" . PUBLIC_PATH . "js/$src.js'></script>\r\n"; | |
| 6 | 6 | } | 
| 7 | 7 | |
| 8 | 8 | function stylesheet_link($src = '') | 
| 9 | 9 |  { | 
| 10 | - return "<link rel='stylesheet' type='text/css' href='" . PUBLIC_PATH . "css/$src.css'/>\r\n"; | |
| 10 | + return "<link rel='stylesheet' type='text/css' href='" . PUBLIC_PATH . "css/$src.css'/>\r\n"; | |
| 11 | 11 | } | 
| 12 | 12 | |
| 13 | 13 | function link_to($action, $text, $attributes = '') | 
| 14 | 14 |  { | 
| 15 | - return "<a href='" . PUBLIC_PATH . "$action' $attributes>$text</a>"; | |
| 15 | + return "<a href='" . PUBLIC_PATH . "$action' $attributes>$text</a>"; | |
| 16 | 16 | } | 
| 17 | 17 | |
| 18 | 18 | function img_tag($img, $attributes = '') | 
| 19 | 19 |  { | 
| 20 | - return "<img src='" . PUBLIC_PATH . "img/$img' $attributes />\r\n"; | |
| 20 | + return "<img src='" . PUBLIC_PATH . "img/$img' $attributes />\r\n"; | |
| 21 | 21 | } | 
| 22 | 22 | |
| 23 | 23 | function form_tag($action, $attributes = '') | 
| 24 | 24 |  { | 
| 25 | - return "<form action='" . PUBLIC_PATH . "$action' $attributes>\r\n"; | |
| 25 | + return "<form action='" . PUBLIC_PATH . "$action' $attributes>\r\n"; | |
| 26 | 26 | } | 
| 27 | 27 | |
| 28 | 28 | function end_form_tag() | 
| 29 | 29 |  { | 
| 30 | - return "</form>\r\n"; | |
| 30 | + return "</form>\r\n"; | |
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | 33 | function submit_tag($caption, $attributes = '') | 
| 34 | 34 |  { | 
| 35 | - return "<input type='submit' value='$caption' $attributes />\r\n"; | |
| 35 | + return "<input type='submit' value='$caption' $attributes />\r\n"; | |
| 36 | 36 | } | 
| 37 | 37 | |
| 38 | 38 | function button_tag($caption, $type = 'button', $attributes = '') | 
| 39 | 39 |  { | 
| 40 | - return "<button type='$type' $attributes>$caption</button>\r\n"; | |
| 40 | + return "<button type='$type' $attributes>$caption</button>\r\n"; | |
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | 43 | function get_field_name_and_id($name) | 
| 44 | 44 |  { | 
| 45 | - $id = ""; | |
| 46 | -	if (strpos($name, ".") !== 0) { | |
| 47 | -		$items = explode(".", $name); | |
| 48 | -		$id = " id='{$items[0]}_{$items[1]}' "; | |
| 49 | - $name = $items[0] . "[" . $items[1] . "]"; | |
| 50 | - } | |
| 51 | - return [$id, $name]; | |
| 45 | + $id = ""; | |
| 46 | +    if (strpos($name, ".") !== 0) { | |
| 47 | +        $items = explode(".", $name); | |
| 48 | +        $id = " id='{$items[0]}_{$items[1]}' "; | |
| 49 | + $name = $items[0] . "[" . $items[1] . "]"; | |
| 50 | + } | |
| 51 | + return [$id, $name]; | |
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | 54 | function text_field_tag($name, $value = '', $attributes = '') | 
| 55 | 55 |  { | 
| 56 | - list($id, $name) = get_field_name_and_id($name); | |
| 56 | + list($id, $name) = get_field_name_and_id($name); | |
| 57 | 57 | |
| 58 | - return "<input type='text' name='$name' $id value='$value' $attributes />\r\n"; | |
| 58 | + return "<input type='text' name='$name' $id value='$value' $attributes />\r\n"; | |
| 59 | 59 | } | 
| 60 | 60 | |
| 61 | 61 | function password_field_tag($name, $value = '', $attributes = '') | 
| 62 | 62 |  { | 
| 63 | - list($id, $name) = get_field_name_and_id($name); | |
| 63 | + list($id, $name) = get_field_name_and_id($name); | |
| 64 | 64 | |
| 65 | - return "<input type='password' name='$name' $id value='$value' $attributes />\r\n"; | |
| 65 | + return "<input type='password' name='$name' $id value='$value' $attributes />\r\n"; | |
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 | function text_area_tag($name, $value = '', $attributes = '') | 
| 69 | 69 |  { | 
| 70 | - list($id, $name) = get_field_name_and_id($name); | |
| 70 | + list($id, $name) = get_field_name_and_id($name); | |
| 71 | 71 | |
| 72 | - return "<textarea name='$name' $id $attributes>$value</textarea>\r\n"; | |
| 72 | + return "<textarea name='$name' $id $attributes>$value</textarea>\r\n"; | |
| 73 | 73 | } | 
| 74 | 74 | |
| 75 | 75 | function hidden_field_tag($name, $value = '', $attributes = '') | 
| 76 | 76 |  { | 
| 77 | - list($id, $name) = get_field_name_and_id($name); | |
| 77 | + list($id, $name) = get_field_name_and_id($name); | |
| 78 | 78 | |
| 79 | - return "<input type='hidden' name='$name' $id value='$value' $attributes />\r\n"; | |
| 79 | + return "<input type='hidden' name='$name' $id value='$value' $attributes />\r\n"; | |
| 80 | 80 | } | 
| 81 | 81 | |
| 82 | 82 | function check_box_tag($name, $value, $checked = false, $attributes = '') | 
| 83 | 83 |  { | 
| 84 | - list($id, $name) = get_field_name_and_id($name); | |
| 85 | - $checked = $checked == true ? ' checked ' : ''; | |
| 86 | - return "<input type='checkbox' $id name='$name' $checked $attributes value='$value'/>\r\n"; | |
| 84 | + list($id, $name) = get_field_name_and_id($name); | |
| 85 | + $checked = $checked == true ? ' checked ' : ''; | |
| 86 | + return "<input type='checkbox' $id name='$name' $checked $attributes value='$value'/>\r\n"; | |
| 87 | 87 | } | 
| 88 | 88 | |
| 89 | 89 | function radio_button_tag($name, $value, $checked = false, $attributes = '') | 
| 90 | 90 |  { | 
| 91 | - list($id, $name) = get_field_name_and_id($name); | |
| 92 | - $checked = $checked == true ? ' checked ' : ''; | |
| 93 | - return "<input type='radio' $id name='$name' $checked $attributes value='$value'/>\r\n"; | |
| 91 | + list($id, $name) = get_field_name_and_id($name); | |
| 92 | + $checked = $checked == true ? ' checked ' : ''; | |
| 93 | + return "<input type='radio' $id name='$name' $checked $attributes value='$value'/>\r\n"; | |
| 94 | 94 | } | 
| 95 | 95 | |
| 96 | 96 | function label_tag($field, $caption, $attributes = '') | 
| 97 | 97 |  { | 
| 98 | - return "<label for='$field' $attributes>$caption</label>\r\n"; | |
| 98 | + return "<label for='$field' $attributes>$caption</label>\r\n"; | |
| 99 | 99 | } | 
| 100 | 100 | |
| 101 | 101 | function select_tag($name = '', $options, $include_blank = false, $attributes = '') | 
| 102 | 102 |  { | 
| 103 | - list($id, $name) = get_field_name_and_id($name); | |
| 103 | + list($id, $name) = get_field_name_and_id($name); | |
| 104 | 104 | |
| 105 | - $code = ""; | |
| 106 | -	if ($include_blank != false) { | |
| 107 | - $code = "<option value=''>$include_blank</option>\r\n"; | |
| 108 | - } | |
| 105 | + $code = ""; | |
| 106 | +    if ($include_blank != false) { | |
| 107 | + $code = "<option value=''>$include_blank</option>\r\n"; | |
| 108 | + } | |
| 109 | 109 | |
| 110 | - return "<select $id name='$name' $attributes>\r\n$code$options</select>\r\n"; | |
| 110 | + return "<select $id name='$name' $attributes>\r\n$code$options</select>\r\n"; | |
| 111 | 111 | } | 
| 112 | 112 | |
| 113 | 113 | function options_for_dbselect($data, $show, $value, $selected = '') | 
| 114 | 114 |  { | 
| 115 | - $code = ""; | |
| 116 | -	foreach ($data as $item) { | |
| 117 | - $selected_tag = ""; | |
| 118 | -		if ($selected == $item[$value]) { | |
| 119 | - $selected_tag = " selected='selected' "; | |
| 120 | - } | |
| 121 | -		$code .= "<option value='{$item[$value]}' $selected_tag>{$item[$show]}</option>\r\n"; | |
| 122 | - } | |
| 123 | - return $code; | |
| 115 | + $code = ""; | |
| 116 | +    foreach ($data as $item) { | |
| 117 | + $selected_tag = ""; | |
| 118 | +        if ($selected == $item[$value]) { | |
| 119 | + $selected_tag = " selected='selected' "; | |
| 120 | + } | |
| 121 | +        $code .= "<option value='{$item[$value]}' $selected_tag>{$item[$show]}</option>\r\n"; | |
| 122 | + } | |
| 123 | + return $code; | |
| 124 | 124 | } | 
| 125 | 125 | |
| 126 | 126 | function options_for_select($data, $selected = '') | 
| 127 | 127 |  { | 
| 128 | - $code = ""; | |
| 129 | -	foreach ($data as $key => $value) { | |
| 130 | - $selected_tag = ""; | |
| 131 | -		if ($selected == $value) { | |
| 132 | - $selected_tag = " selected='selected' "; | |
| 133 | - } | |
| 134 | - $code .= "<option value='$key' $selected_tag>$value</option>\r\n"; | |
| 135 | - } | |
| 136 | - return $code; | |
| 128 | + $code = ""; | |
| 129 | +    foreach ($data as $key => $value) { | |
| 130 | + $selected_tag = ""; | |
| 131 | +        if ($selected == $value) { | |
| 132 | + $selected_tag = " selected='selected' "; | |
| 133 | + } | |
| 134 | + $code .= "<option value='$key' $selected_tag>$value</option>\r\n"; | |
| 135 | + } | |
| 136 | + return $code; | |
| 137 | 137 | } | 
| 138 | 138 | |
| 139 | 139 | function js_redirect_to($action, $seconds = 0.01) | 
| 140 | 140 |  { | 
| 141 | - $seconds *= 1000; | |
| 142 | -	return "<script type=\"text/javascript\">setTimeout('window.location=\"?/$action\"', $seconds)</script>"; | |
| 141 | + $seconds *= 1000; | |
| 142 | +    return "<script type=\"text/javascript\">setTimeout('window.location=\"?/$action\"', $seconds)</script>"; | |
| 143 | 143 | } | 
| 144 | 144 | |
| 145 | 145 | function button_to_action($caption, $action, $attributes = '') | 
| 146 | 146 |  { | 
| 147 | - return "<button type='button' $attributes onclick='window.location=\"" . PUBLIC_PATH . "$action\"'>$caption</button>"; | |
| 147 | + return "<button type='button' $attributes onclick='window.location=\"" . PUBLIC_PATH . "$action\"'>$caption</button>"; | |
| 148 | 148 | } | 
| @@ -2,46 +2,46 @@ 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 | - } | |
| 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 | + } | |
| 13 | 13 | } | 
| 14 | 14 | |
| 15 | 15 | function load_lib(string $lib) | 
| 16 | 16 |  { | 
| 17 | - load_file($lib, ".php", PIN_PATH . 'libs' . DS, "Librería"); | |
| 17 | + load_file($lib, ".php", PIN_PATH . 'libs' . DS, "Librería"); | |
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | 20 | function load_config(string $config) | 
| 21 | 21 |  { | 
| 22 | - load_file($config, ".php", PIN_PATH . 'config' . DS, "Configuración"); | |
| 22 | + load_file($config, ".php", PIN_PATH . 'config' . DS, "Configuración"); | |
| 23 | 23 | } | 
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | function load_helper(string $helper) | 
| 27 | 27 |  { | 
| 28 | - load_file($helper, ".php", PIN_PATH . 'helpers' . DS, "Helper"); | |
| 28 | + load_file($helper, ".php", PIN_PATH . 'helpers' . DS, "Helper"); | |
| 29 | 29 | } | 
| 30 | 30 | |
| 31 | 31 | function load_view(string $view, array $parameters = null) | 
| 32 | 32 |  { | 
| 33 | - load_file($view, ".phtml", PIN_PATH . 'views' . DS, "Vista", $parameters); | |
| 33 | + load_file($view, ".phtml", PIN_PATH . 'views' . DS, "Vista", $parameters); | |
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | 36 | function load_partial(string $partial, array $parameters = null) | 
| 37 | 37 |  { | 
| 38 | - load_file($partial, ".phtml", PIN_PATH . 'partials' . DS, "Parcial", $parameters); | |
| 38 | + load_file($partial, ".phtml", PIN_PATH . 'partials' . DS, "Parcial", $parameters); | |
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | 41 | function redirect_to(string $url) | 
| 42 | 42 |  { | 
| 43 | - $url = PUBLIC_PATH . $url; | |
| 44 | -	header("Location: $url", true, 301); | |
| 43 | + $url = PUBLIC_PATH . $url; | |
| 44 | +    header("Location: $url", true, 301); | |
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | 47 | |
| @@ -50,56 +50,56 @@ discard block | ||
| 50 | 50 | |
| 51 | 51 | function handle_error($level, $message, $file, $line) | 
| 52 | 52 |  { | 
| 53 | -	if (error_reporting() !== 0) { | |
| 54 | - throw new \ErrorException($message, 0, $level, $file, $line); | |
| 55 | - } | |
| 53 | +    if (error_reporting() !== 0) { | |
| 54 | + throw new \ErrorException($message, 0, $level, $file, $line); | |
| 55 | + } | |
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | 58 | function handle_exception($exception) | 
| 59 | 59 |  { | 
| 60 | - $code = $exception->getCode(); | |
| 61 | -	if ($code != 404) { | |
| 62 | - $code = 500; | |
| 63 | - } | |
| 64 | - http_response_code($code); | |
| 65 | - | |
| 66 | -	if (error_reporting() !== 0) { | |
| 67 | -		load_partial("templates/header"); | |
| 68 | - echo "<h1>Fatal error</h1>"; | |
| 69 | - echo "<p>Uncaught exception: '" . get_class($exception) . "'</p>"; | |
| 70 | - echo "<p>Message: '" . $exception->getMessage() . "'</p>"; | |
| 71 | - echo "<p>Stack trace:<pre>" . $exception->getTraceAsString() . "</pre></p>"; | |
| 72 | - echo "<p>Thrown in '" . $exception->getFile() . "' on line " . $exception->getLine() . "</p>"; | |
| 73 | -		load_partial("templates/footer"); | |
| 74 | - } | |
| 60 | + $code = $exception->getCode(); | |
| 61 | +    if ($code != 404) { | |
| 62 | + $code = 500; | |
| 63 | + } | |
| 64 | + http_response_code($code); | |
| 65 | + | |
| 66 | +    if (error_reporting() !== 0) { | |
| 67 | +        load_partial("templates/header"); | |
| 68 | + echo "<h1>Fatal error</h1>"; | |
| 69 | + echo "<p>Uncaught exception: '" . get_class($exception) . "'</p>"; | |
| 70 | + echo "<p>Message: '" . $exception->getMessage() . "'</p>"; | |
| 71 | + echo "<p>Stack trace:<pre>" . $exception->getTraceAsString() . "</pre></p>"; | |
| 72 | + echo "<p>Thrown in '" . $exception->getFile() . "' on line " . $exception->getLine() . "</p>"; | |
| 73 | +        load_partial("templates/footer"); | |
| 74 | + } | |
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | function load_page_from_url($url) | 
| 79 | 79 |  { | 
| 80 | -	$content = explode('/', $url); | |
| 81 | - //quitar el elemento inicial vacio | |
| 82 | - array_shift($content); | |
| 83 | - | |
| 84 | - $page = !empty($content[0]) ? trim($content[0]) : 'default'; | |
| 85 | - array_shift($content); | |
| 86 | - | |
| 87 | -	if (file_exists(PIN_PATH . 'pages' . DS . $page . '.php')) { | |
| 88 | - require PIN_PATH . 'pages' . DS . $page . '.php'; | |
| 89 | -	} else { | |
| 90 | -		throw (new Exception("La página <b>$page</b> no existe!")); | |
| 91 | - } | |
| 92 | - | |
| 93 | - $function_to_be_load = !empty($content[0]) ? trim($content[0]) : 'index'; | |
| 94 | - array_shift($content); | |
| 95 | - | |
| 96 | -	if (function_exists("page_initializer")) { | |
| 97 | -		call_user_func("page_initializer"); | |
| 98 | - } | |
| 99 | - | |
| 100 | -	if (function_exists($function_to_be_load)) { | |
| 101 | - call_user_func($function_to_be_load, $content); | |
| 102 | -	} else { | |
| 103 | -		throw (new Exception("La función <b>$function_to_be_load</b> no existe en la página <b>$page</b>!")); | |
| 104 | - } | |
| 80 | +    $content = explode('/', $url); | |
| 81 | + //quitar el elemento inicial vacio | |
| 82 | + array_shift($content); | |
| 83 | + | |
| 84 | + $page = !empty($content[0]) ? trim($content[0]) : 'default'; | |
| 85 | + array_shift($content); | |
| 86 | + | |
| 87 | +    if (file_exists(PIN_PATH . 'pages' . DS . $page . '.php')) { | |
| 88 | + require PIN_PATH . 'pages' . DS . $page . '.php'; | |
| 89 | +    } else { | |
| 90 | +        throw (new Exception("La página <b>$page</b> no existe!")); | |
| 91 | + } | |
| 92 | + | |
| 93 | + $function_to_be_load = !empty($content[0]) ? trim($content[0]) : 'index'; | |
| 94 | + array_shift($content); | |
| 95 | + | |
| 96 | +    if (function_exists("page_initializer")) { | |
| 97 | +        call_user_func("page_initializer"); | |
| 98 | + } | |
| 99 | + | |
| 100 | +    if (function_exists($function_to_be_load)) { | |
| 101 | + call_user_func($function_to_be_load, $content); | |
| 102 | +    } else { | |
| 103 | +        throw (new Exception("La función <b>$function_to_be_load</b> no existe en la página <b>$page</b>!")); | |
| 104 | + } | |
| 105 | 105 | } |