@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * Reglas definidas en Rules.php |
| 28 | 28 | * |
| 29 | 29 | * @var array CONSTANTE con las reglas permitidas |
| 30 | - */ |
|
| 30 | + */ |
|
| 31 | 31 | const RULES = [ |
| 32 | 32 | 'none', # Sin ninguna regla |
| 33 | 33 | 'letters', # Sólamente letras |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * Colección de rutas existentes |
| 44 | 44 | * |
| 45 | 45 | * @var array |
| 46 | - */ |
|
| 46 | + */ |
|
| 47 | 47 | private $routerCollection = array( |
| 48 | 48 | '/controller' => 'home', # controlador por defecto |
| 49 | 49 | '/method' => null, # método por defecto |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * Colección de reglas para cada ruta existente |
| 55 | 55 | * |
| 56 | 56 | * @var array |
| 57 | - */ |
|
| 57 | + */ |
|
| 58 | 58 | private $routerCollectionRules = array( |
| 59 | 59 | '/controller' => 'letters', |
| 60 | 60 | '/method' => 'none', |
@@ -65,19 +65,19 @@ discard block |
||
| 65 | 65 | * Petición real estructurada |
| 66 | 66 | * |
| 67 | 67 | * @var array |
| 68 | - */ |
|
| 68 | + */ |
|
| 69 | 69 | private $real_request = array(); |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * Uri requerida por el cliente final |
| 73 | 73 | * |
| 74 | 74 | * @var string |
| 75 | - */ |
|
| 75 | + */ |
|
| 76 | 76 | private $requestUri; |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * __construct() |
| 80 | - */ |
|
| 80 | + */ |
|
| 81 | 81 | public function __construct() { |
| 82 | 82 | global $http; |
| 83 | 83 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @throws \RuntimeException si la regla no existe |
| 98 | 98 | * @return void |
| 99 | - */ |
|
| 99 | + */ |
|
| 100 | 100 | final private function setCollectionRule(string $index, string $rule) { |
| 101 | 101 | # Verificar si la regla existe |
| 102 | 102 | if (!in_array($rule, self::RULES)) { |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Verifica las peticiones por defecto |
| 111 | - */ |
|
| 111 | + */ |
|
| 112 | 112 | final private function checkRequests() { |
| 113 | 113 | # Verificar si existe peticiones |
| 114 | 114 | if (null !== $this->requestUri) { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $rule : Nombre de la regla, por defecto es ninguna "none" |
| 129 | 129 | * |
| 130 | 130 | * @throws \RuntimeException si no puede definirse la ruta |
| 131 | - */ |
|
| 131 | + */ |
|
| 132 | 132 | final public function setRoute(string $index, string $rule = 'none') { |
| 133 | 133 | # Nombres de rutas no permitidos |
| 134 | 134 | if (in_array($index, ['/controller', '/method', '/id'])) { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | /** |
| 110 | 110 | * Verifica las peticiones por defecto |
| 111 | 111 | */ |
| 112 | - final private function checkRequests() { |
|
| 112 | + final private function checkRequests() { |
|
| 113 | 113 | # Verificar si existe peticiones |
| 114 | 114 | if (null !== $this->requestUri) { |
| 115 | 115 | $this->real_request = explode('/', $this->requestUri); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @throws \RuntimeException si no puede definirse la ruta |
| 131 | 131 | */ |
| 132 | - final public function setRoute(string $index, string $rule = 'none') { |
|
| 132 | + final public function setRoute(string $index, string $rule = 'none') { |
|
| 133 | 133 | # Nombres de rutas no permitidos |
| 134 | 134 | if (in_array($index, ['/controller', '/method', '/id'])) { |
| 135 | 135 | throw new \RuntimeException('No puede definirse ' . $index . ' como índice en la ruta.'); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $rules = new Rules; |
| 167 | 167 | |
| 168 | 168 | # Retornar ruta con la regla definida aplicada |
| 169 | - if(method_exists($rules, $this->routerCollectionRules[$index])) { |
|
| 169 | + if (method_exists($rules, $this->routerCollectionRules[$index])) { |
|
| 170 | 170 | return $rules->{$this->routerCollectionRules[$index]}($ruta); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | final public function getId(bool $with_rules = false) { |
| 207 | 207 | $id = $this->routerCollection['/id']; |
| 208 | - if($with_rules && (!is_numeric($id) || $id <= 0)) { |
|
| 208 | + if ($with_rules && (!is_numeric($id) || $id <= 0)) { |
|
| 209 | 209 | return null; |
| 210 | 210 | } |
| 211 | 211 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @return void |
| 221 | 221 | */ |
| 222 | - final private function loadController() { |
|
| 222 | + final private function loadController() { |
|
| 223 | 223 | # Definir controlador |
| 224 | 224 | if (null != ($controller = $this->getController())) { |
| 225 | 225 | $controller = $controller . 'Controller'; |
@@ -258,15 +258,15 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @return void |
| 260 | 260 | */ |
| 261 | - final public function executeController() { |
|
| 261 | + final public function executeController() { |
|
| 262 | 262 | global $config; |
| 263 | 263 | |
| 264 | - if($config['build']['production']) { |
|
| 264 | + if ($config['build']['production']) { |
|
| 265 | 265 | try { |
| 266 | 266 | $this->loadController(); |
| 267 | - } catch(\Throwable $e) { |
|
| 267 | + } catch (\Throwable $e) { |
|
| 268 | 268 | $this->productionError(); |
| 269 | - } catch(\Exception $e) { |
|
| 269 | + } catch (\Exception $e) { |
|
| 270 | 270 | $this->productionError(); |
| 271 | 271 | } |
| 272 | 272 | } else { |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public static function loadTemplate(array $content, int $template) : string { |
| 48 | 48 | # Verificar que existe la plantilla |
| 49 | - if(!array_key_exists($template,self::TEMPLATES)) { |
|
| 49 | + if (!array_key_exists($template, self::TEMPLATES)) { |
|
| 50 | 50 | throw new \RuntimeException('La plantilla seleccionada no se encuentra.'); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | $tpl = Files::read_file(self::TEMPLATES_ROUTE . self::TEMPLATES[$template]); |
| 55 | 55 | |
| 56 | 56 | # Reempalzar contenido |
| 57 | - foreach($content as $index => $html) { |
|
| 58 | - $tpl = str_replace($index,$html,$tpl); |
|
| 57 | + foreach ($content as $index => $html) { |
|
| 58 | + $tpl = str_replace($index, $html, $tpl); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return $tpl; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $https['ssl']['verify_peer_name'] = false; |
| 91 | 91 | |
| 92 | 92 | # Verificar si están llenos los campos |
| 93 | - if(!$config['build']['production'] && Functions::emp($config['mailer']['host'])) { |
|
| 93 | + if (!$config['build']['production'] && Functions::emp($config['mailer']['host'])) { |
|
| 94 | 94 | throw new \RuntimeException('Los datos de mailer, en Ocrend.ini.yml están vacíos.'); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | # El mensaje |
| 107 | 107 | $message = new \Swift_Message(); |
| 108 | - $message->setSubject(array_key_exists('{{title}}',$content) ? $content['{{title}}'] : $config['build']['name']); |
|
| 109 | - $message->setBody(self::loadTemplate($content,$template), 'text/html'); |
|
| 110 | - $message->setFrom([ $config['mailer']['user'] => $config['build']['name']]); |
|
| 108 | + $message->setSubject(array_key_exists('{{title}}', $content) ? $content['{{title}}'] : $config['build']['name']); |
|
| 109 | + $message->setBody(self::loadTemplate($content, $template), 'text/html'); |
|
| 110 | + $message->setFrom([$config['mailer']['user'] => $config['build']['name']]); |
|
| 111 | 111 | $message->setTo($dest); |
| 112 | 112 | |
| 113 | 113 | # Adjuntos |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @param string $file_name: Nombre del archivo, da igual si es solo el nombre o la ruta con el nombre |
| 86 | 86 | * |
| 87 | 87 | * @return mixed string con la extensión, devuelve un string '' si no existe información alguna acerca de la extensión |
| 88 | - */ |
|
| 88 | + */ |
|
| 89 | 89 | public static function get_file_ext(string $file_name) { |
| 90 | 90 | return pathinfo($file_name, PATHINFO_EXTENSION); |
| 91 | 91 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param string $file_name: Nombre del archivo, da igual si es solo el nombre o la ruta con el nombre |
| 97 | 97 | * |
| 98 | 98 | * @return bool true si es una imagen, false si no lo es |
| 99 | - */ |
|
| 99 | + */ |
|
| 100 | 100 | public static function is_image(string $file_name) : bool { |
| 101 | 101 | return (bool) in_array(self::get_file_ext($file_name), ['jpg', 'png', 'jpeg', 'gif', 'JPG', 'PNG', 'JPEG', 'GIF']); |
| 102 | 102 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @return int con el tamaño del fichero |
| 110 | 110 | */ |
| 111 | 111 | public static function file_size(string $file) : int { |
| 112 | - return (int) round(filesize($file)*0.0009765625, 1); |
|
| 112 | + return (int) round(filesize($file)*0.0009765625, 1); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | * @param string $file: path del fichero |
| 119 | 119 | * |
| 120 | 120 | * @return string con la fecha del fichero en el formato d-m-y h:i:s |
| 121 | - */ |
|
| 121 | + */ |
|
| 122 | 122 | public static function date_file(string $file) : string { |
| 123 | - return date('d-m-Y h:i:s', filemtime($file)); |
|
| 123 | + return date('d-m-Y h:i:s', filemtime($file)); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @param string $types: tipos de archivos a buscar, por defecto '' significa todos, se puede pasar por ejemplo 'jpg' |
| 131 | 131 | * |
| 132 | 132 | * @return array con las rutas de todos los ficheros encontrados, un array vacío si no encontró ficheros |
| 133 | - */ |
|
| 133 | + */ |
|
| 134 | 134 | public static function get_files_in_dir(string $dir, string $types = '') : array { |
| 135 | 135 | $array = array(); |
| 136 | 136 | if (is_dir($dir)) { |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param int $permisos: Permisos del directorio a crear, por defecto es 0655 |
| 149 | 149 | * |
| 150 | 150 | * @return bool con true si fue creado con éxito, false si el directorio ya existía o hubo algún error |
| 151 | - */ |
|
| 151 | + */ |
|
| 152 | 152 | public static function create_dir(string $dir, int $permisos = 0655) : bool { |
| 153 | 153 | if(is_dir($dir)) { |
| 154 | 154 | return false; |
@@ -245,10 +245,10 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | - * Se obtiene de Twig_Extension y sirve para que cada función esté disponible como etiqueta en twig |
|
| 249 | - * |
|
| 250 | - * @return array con todas las funciones con sus respectivos nombres de acceso en plantillas twig |
|
| 251 | - */ |
|
| 248 | + * Se obtiene de Twig_Extension y sirve para que cada función esté disponible como etiqueta en twig |
|
| 249 | + * |
|
| 250 | + * @return array con todas las funciones con sus respectivos nombres de acceso en plantillas twig |
|
| 251 | + */ |
|
| 252 | 252 | public function getFunctions() : array { |
| 253 | 253 | return array( |
| 254 | 254 | new \Twig_Function('images_in_dir', array($this, 'images_in_dir')), |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
| 264 | - * Identificador único para la extensión de twig |
|
| 265 | - * |
|
| 266 | - * @return string con el nombre de la extensión |
|
| 267 | - */ |
|
| 264 | + * Identificador único para la extensión de twig |
|
| 265 | + * |
|
| 266 | + * @return string con el nombre de la extensión |
|
| 267 | + */ |
|
| 268 | 268 | public function getName() : string { |
| 269 | 269 | return 'ocrend_framework_helper_files'; |
| 270 | 270 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @return int catidad de bytes escritos en el archivo |
| 46 | 46 | */ |
| 47 | 47 | public static function write_file(string $dir, string $content) : int { |
| 48 | - $f = new \SplFileObject($dir,'w'); |
|
| 48 | + $f = new \SplFileObject($dir, 'w'); |
|
| 49 | 49 | return (int) $f->fwrite($content); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @return int : catidad de bytes escritos en el archivo |
| 59 | 59 | */ |
| 60 | 60 | public static function write_in_file(string $dir, string $content) : int { |
| 61 | - $f = new \SplFileObject($dir,'a+'); |
|
| 61 | + $f = new \SplFileObject($dir, 'a+'); |
|
| 62 | 62 | return (int) $f->fwrite("\n\r" . $content); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | * @return bool con true si fue creado con éxito, false si el directorio ya existía o hubo algún error |
| 151 | 151 | */ |
| 152 | 152 | public static function create_dir(string $dir, int $permisos = 0655) : bool { |
| 153 | - if(is_dir($dir)) { |
|
| 153 | + if (is_dir($dir)) { |
|
| 154 | 154 | return false; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - return (bool) mkdir($dir,$permisos,true); |
|
| 157 | + return (bool) mkdir($dir, $permisos, true); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -226,19 +226,19 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @return void |
| 228 | 228 | */ |
| 229 | - public static function move_from_dir(string $old_dir, string $new_dir, bool $only_images = false, bool $delete_old = false) { |
|
| 229 | + public static function move_from_dir(string $old_dir, string $new_dir, bool $only_images = false, bool $delete_old = false) { |
|
| 230 | 230 | self::create_dir($new_dir); |
| 231 | 231 | |
| 232 | - foreach(glob($old_dir . ($only_images ? '{*.jpg,*.gif,*.png,*.gif,*.jpeg,*.JPG,*.GIF,*.PNG,*.JPEG}' : '*'),GLOB_BRACE) as $file) { |
|
| 233 | - if(file_exists($file)) { |
|
| 232 | + foreach (glob($old_dir . ($only_images ? '{*.jpg,*.gif,*.png,*.gif,*.jpeg,*.JPG,*.GIF,*.PNG,*.JPEG}' : '*'), GLOB_BRACE) as $file) { |
|
| 233 | + if (file_exists($file)) { |
|
| 234 | 234 | unlink($file); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $name = explode('/',$file); |
|
| 237 | + $name = explode('/', $file); |
|
| 238 | 238 | $name = end($name); |
| 239 | - copy($file,$new_dir . $name); |
|
| 239 | + copy($file, $new_dir . $name); |
|
| 240 | 240 | |
| 241 | - if($delete_old) { |
|
| 241 | + if ($delete_old) { |
|
| 242 | 242 | unlink($file); |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @param int $max: Valor a comparar |
| 28 | 28 | * |
| 29 | 29 | * @return bool con el resultado de la comparación |
| 30 | - */ |
|
| 30 | + */ |
|
| 31 | 31 | private static function check_str_to_time(int $index, array $detail, int $max) : bool { |
| 32 | 32 | return !array_key_exists($index,$detail) || !is_numeric($detail[$index]) || intval($detail[$index]) < $max; |
| 33 | 33 | } |
@@ -38,19 +38,19 @@ discard block |
||
| 38 | 38 | * @param array $detail: Arreglo |
| 39 | 39 | * |
| 40 | 40 | * @return bool |
| 41 | - */ |
|
| 41 | + */ |
|
| 42 | 42 | private static function check_time(array $detail) : bool { |
| 43 | 43 | return self::check_str_to_time(0,$detail,1) || self::check_str_to_time(1,$detail,1) || intval($detail[1]) > 12 || self::check_str_to_time(2,$detail,1970); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * Redirecciona a una URL |
|
| 48 | - * |
|
| 49 | - * @param string $url: Sitio a donde redireccionará, si no se pasa, por defecto |
|
| 50 | - * se redirecciona a la URL principal del sitio |
|
| 51 | - * |
|
| 52 | - * @return void |
|
| 53 | - */ |
|
| 47 | + * Redirecciona a una URL |
|
| 48 | + * |
|
| 49 | + * @param string $url: Sitio a donde redireccionará, si no se pasa, por defecto |
|
| 50 | + * se redirecciona a la URL principal del sitio |
|
| 51 | + * |
|
| 52 | + * @return void |
|
| 53 | + */ |
|
| 54 | 54 | public static function redir($url = null) { |
| 55 | 55 | global $config; |
| 56 | 56 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $email: El email del usuario a extraer el gravatar |
| 92 | 92 | * @param int $size: El tamaño del gravatar |
| 93 | 93 | * @return string con la URl |
| 94 | - */ |
|
| 94 | + */ |
|
| 95 | 95 | public static function get_gravatar(string $email, int $size = 35) : string { |
| 96 | 96 | return 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . (int) abs($size) . '?d=robohash'; |
| 97 | 97 | } |
@@ -108,30 +108,30 @@ discard block |
||
| 108 | 108 | return (null === $var || empty(trim(str_replace(' ','',$var)))); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - //------------------------------------------------ |
|
| 111 | + //------------------------------------------------ |
|
| 112 | 112 | |
| 113 | - /** |
|
| 113 | + /** |
|
| 114 | 114 | * Aanaliza que TODOS los elementos de un arreglo estén llenos, útil para analizar por ejemplo que todos los elementos de un formulario esté llenos |
| 115 | 115 | * pasando como parámetro $_POST |
| 116 | 116 | * |
| 117 | 117 | * @param array $array, arreglo a analizar |
| 118 | 118 | * |
| 119 | 119 | * @return bool con true si están todos llenos, false si al menos uno está vacío |
| 120 | - */ |
|
| 121 | - public static function all_full(array $array) : bool { |
|
| 122 | - foreach($array as $e) { |
|
| 123 | - if(self::emp($e) and $e != '0') { |
|
| 124 | - return false; |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - return true; |
|
| 128 | - } |
|
| 120 | + */ |
|
| 121 | + public static function all_full(array $array) : bool { |
|
| 122 | + foreach($array as $e) { |
|
| 123 | + if(self::emp($e) and $e != '0') { |
|
| 124 | + return false; |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + return true; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * Alias de Empty() pero soporta más de un parámetro (infinitos) |
| 132 | 132 | * |
| 133 | 133 | * @return bool con true si al menos uno está vacío, false si todos están llenos |
| 134 | - */ |
|
| 134 | + */ |
|
| 135 | 135 | public static function e() : bool { |
| 136 | 136 | for ($i = 0, $nargs = func_num_args(); $i < $nargs; $i++) { |
| 137 | 137 | if(self::emp(func_get_arg($i)) && func_get_arg($i) != '0') { |
@@ -150,40 +150,40 @@ discard block |
||
| 150 | 150 | * @param int $time: Tiempo, por defecto es time() (igual que en date()) |
| 151 | 151 | * |
| 152 | 152 | * @return string con la fecha en formato humano (y en español) |
| 153 | - */ |
|
| 153 | + */ |
|
| 154 | 154 | public static function fecha(string $format, int $time = 0) : string { |
| 155 | 155 | $date = date($format,$time == 0 ? time() : $time); |
| 156 | 156 | $cambios = array( |
| 157 | - 'Monday'=> 'Lunes', |
|
| 158 | - 'Tuesday'=> 'Martes', |
|
| 159 | - 'Wednesday'=> 'Miércoles', |
|
| 160 | - 'Thursday'=> 'Jueves', |
|
| 161 | - 'Friday'=> 'Viernes', |
|
| 162 | - 'Saturday'=> 'Sábado', |
|
| 163 | - 'Sunday'=> 'Domingo', |
|
| 164 | - 'January'=> 'Enero', |
|
| 165 | - 'February'=> 'Febrero', |
|
| 166 | - 'March'=> 'Marzo', |
|
| 167 | - 'April'=> 'Abril', |
|
| 168 | - 'May'=> 'Mayo', |
|
| 169 | - 'June'=> 'Junio', |
|
| 170 | - 'July'=> 'Julio', |
|
| 171 | - 'August'=> 'Agosto', |
|
| 172 | - 'September'=> 'Septiembre', |
|
| 173 | - 'October'=> 'Octubre', |
|
| 174 | - 'November'=> 'Noviembre', |
|
| 175 | - 'December'=> 'Diciembre', |
|
| 176 | - 'Mon'=> 'Lun', |
|
| 177 | - 'Tue'=> 'Mar', |
|
| 178 | - 'Wed'=> 'Mie', |
|
| 179 | - 'Thu'=> 'Jue', |
|
| 180 | - 'Fri'=> 'Vie', |
|
| 181 | - 'Sat'=> 'Sab', |
|
| 182 | - 'Sun'=> 'Dom', |
|
| 183 | - 'Jan'=> 'Ene', |
|
| 184 | - 'Aug'=> 'Ago', |
|
| 185 | - 'Apr'=> 'Abr', |
|
| 186 | - 'Dec'=> 'Dic' |
|
| 157 | + 'Monday'=> 'Lunes', |
|
| 158 | + 'Tuesday'=> 'Martes', |
|
| 159 | + 'Wednesday'=> 'Miércoles', |
|
| 160 | + 'Thursday'=> 'Jueves', |
|
| 161 | + 'Friday'=> 'Viernes', |
|
| 162 | + 'Saturday'=> 'Sábado', |
|
| 163 | + 'Sunday'=> 'Domingo', |
|
| 164 | + 'January'=> 'Enero', |
|
| 165 | + 'February'=> 'Febrero', |
|
| 166 | + 'March'=> 'Marzo', |
|
| 167 | + 'April'=> 'Abril', |
|
| 168 | + 'May'=> 'Mayo', |
|
| 169 | + 'June'=> 'Junio', |
|
| 170 | + 'July'=> 'Julio', |
|
| 171 | + 'August'=> 'Agosto', |
|
| 172 | + 'September'=> 'Septiembre', |
|
| 173 | + 'October'=> 'Octubre', |
|
| 174 | + 'November'=> 'Noviembre', |
|
| 175 | + 'December'=> 'Diciembre', |
|
| 176 | + 'Mon'=> 'Lun', |
|
| 177 | + 'Tue'=> 'Mar', |
|
| 178 | + 'Wed'=> 'Mie', |
|
| 179 | + 'Thu'=> 'Jue', |
|
| 180 | + 'Fri'=> 'Vie', |
|
| 181 | + 'Sat'=> 'Sab', |
|
| 182 | + 'Sun'=> 'Dom', |
|
| 183 | + 'Jan'=> 'Ene', |
|
| 184 | + 'Aug'=> 'Ago', |
|
| 185 | + 'Apr'=> 'Abr', |
|
| 186 | + 'Dec'=> 'Dic' |
|
| 187 | 187 | ); |
| 188 | 188 | return str_replace(array_keys($cambios), array_values($cambios), $date); |
| 189 | 189 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * Se adapta a la configuración del dominio en general. |
| 194 | 194 | * |
| 195 | 195 | * @return string <base href="ruta" /> |
| 196 | - */ |
|
| 196 | + */ |
|
| 197 | 197 | public static function base_assets() : string { |
| 198 | 198 | global $config, $http; |
| 199 | 199 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param int $anio: Año (1975 a 2xxx) |
| 232 | 232 | * |
| 233 | 233 | * @return string con el número del día |
| 234 | - */ |
|
| 234 | + */ |
|
| 235 | 235 | public static function last_day_month(int $mes, int $anio) : string { |
| 236 | 236 | return date('d', (mktime(0,0,0,$mes + 1, 1, $anio) - 1)); |
| 237 | 237 | } |
@@ -290,19 +290,19 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | # Arreglo de condiciones y subcondiciones |
| 292 | 292 | $fecha = array( |
| 293 | - 1 => date('d/m/Y', time()), |
|
| 294 | - 2 => date('d/m/Y', time() - (60*60*24)), |
|
| 295 | - 3 => array( |
|
| 296 | - 'Mon' => $hoy[0], |
|
| 297 | - 'Tue' => intval($hoy[0]) - 1, |
|
| 298 | - 'Wed' => intval($hoy[0]) - 2, |
|
| 299 | - 'Thu' => intval($hoy[0]) - 3, |
|
| 300 | - 'Fri' => intval($hoy[0]) - 4, |
|
| 301 | - 'Sat' => intval($hoy[0]) - 5, |
|
| 302 | - 'Sun' => intval($hoy[0]) - 6 |
|
| 303 | - ), |
|
| 304 | - 4 => '01/'. self::cero_izq($hoy[1]) .'/' . $hoy[2], |
|
| 305 | - 5 => '01/01/' . $hoy[2] |
|
| 293 | + 1 => date('d/m/Y', time()), |
|
| 294 | + 2 => date('d/m/Y', time() - (60*60*24)), |
|
| 295 | + 3 => array( |
|
| 296 | + 'Mon' => $hoy[0], |
|
| 297 | + 'Tue' => intval($hoy[0]) - 1, |
|
| 298 | + 'Wed' => intval($hoy[0]) - 2, |
|
| 299 | + 'Thu' => intval($hoy[0]) - 3, |
|
| 300 | + 'Fri' => intval($hoy[0]) - 4, |
|
| 301 | + 'Sat' => intval($hoy[0]) - 5, |
|
| 302 | + 'Sun' => intval($hoy[0]) - 6 |
|
| 303 | + ), |
|
| 304 | + 4 => '01/'. self::cero_izq($hoy[1]) .'/' . $hoy[2], |
|
| 305 | + 5 => '01/01/' . $hoy[2] |
|
| 306 | 306 | ); |
| 307 | 307 | |
| 308 | 308 | if($desde == 3) { |
@@ -347,22 +347,22 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | public function getFunctions() : array { |
| 349 | 349 | return array( |
| 350 | - new \Twig_Function('percent', array($this, 'percent')), |
|
| 351 | - new \Twig_Function('convert', array($this, 'convert')), |
|
| 352 | - new \Twig_Function('get_gravatar', array($this, 'get_gravatar')), |
|
| 353 | - new \Twig_Function('emp', array($this, 'emp')), |
|
| 354 | - new \Twig_Function('e_dynamic', array($this, 'e')), |
|
| 355 | - new \Twig_Function('all_full', array($this, 'all_full')), |
|
| 356 | - new \Twig_Function('fecha', array($this, 'fecha')), |
|
| 357 | - new \Twig_Function('base_assets', array($this, 'base_assets')), |
|
| 358 | - new \Twig_Function('timestamp', array($this, 'timestamp')), |
|
| 359 | - new \Twig_Function('desde_date', array($this, 'desde_date')), |
|
| 360 | - new \Twig_Function('cero_izq', array($this, 'cero_izq')), |
|
| 361 | - new \Twig_Function('last_day_month', array($this, 'last_day_month')), |
|
| 362 | - new \Twig_Function('str_to_time', array($this, 'str_to_time')), |
|
| 363 | - new \Twig_Function('desde_date', array($this, 'desde_date')) |
|
| 350 | + new \Twig_Function('percent', array($this, 'percent')), |
|
| 351 | + new \Twig_Function('convert', array($this, 'convert')), |
|
| 352 | + new \Twig_Function('get_gravatar', array($this, 'get_gravatar')), |
|
| 353 | + new \Twig_Function('emp', array($this, 'emp')), |
|
| 354 | + new \Twig_Function('e_dynamic', array($this, 'e')), |
|
| 355 | + new \Twig_Function('all_full', array($this, 'all_full')), |
|
| 356 | + new \Twig_Function('fecha', array($this, 'fecha')), |
|
| 357 | + new \Twig_Function('base_assets', array($this, 'base_assets')), |
|
| 358 | + new \Twig_Function('timestamp', array($this, 'timestamp')), |
|
| 359 | + new \Twig_Function('desde_date', array($this, 'desde_date')), |
|
| 360 | + new \Twig_Function('cero_izq', array($this, 'cero_izq')), |
|
| 361 | + new \Twig_Function('last_day_month', array($this, 'last_day_month')), |
|
| 362 | + new \Twig_Function('str_to_time', array($this, 'str_to_time')), |
|
| 363 | + new \Twig_Function('desde_date', array($this, 'desde_date')) |
|
| 364 | 364 | ); |
| 365 | - } |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | 367 | /** |
| 368 | 368 | * Identificador único para la extensión de twig |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @return bool con el resultado de la comparación |
| 30 | 30 | */ |
| 31 | 31 | private static function check_str_to_time(int $index, array $detail, int $max) : bool { |
| 32 | - return !array_key_exists($index,$detail) || !is_numeric($detail[$index]) || intval($detail[$index]) < $max; |
|
| 32 | + return !array_key_exists($index, $detail) || !is_numeric($detail[$index]) || intval($detail[$index]) < $max; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | 42 | private static function check_time(array $detail) : bool { |
| 43 | - return self::check_str_to_time(0,$detail,1) || self::check_str_to_time(1,$detail,1) || intval($detail[1]) > 12 || self::check_str_to_time(2,$detail,1970); |
|
| 43 | + return self::check_str_to_time(0, $detail, 1) || self::check_str_to_time(1, $detail, 1) || intval($detail[1]) > 12 || self::check_str_to_time(2, $detail, 1970); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return void |
| 53 | 53 | */ |
| 54 | - public static function redir($url = null) { |
|
| 54 | + public static function redir($url = null) { |
|
| 55 | 55 | global $config; |
| 56 | 56 | |
| 57 | 57 | if (null == $url) { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @return bool con true si está vacío, false si no, un espacio en blanco cuenta como vacío |
| 106 | 106 | */ |
| 107 | 107 | public static function emp($var) : bool { |
| 108 | - return (null === $var || empty(trim(str_replace(' ','',$var)))); |
|
| 108 | + return (null === $var || empty(trim(str_replace(' ', '', $var)))); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | //------------------------------------------------ |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | * @return bool con true si están todos llenos, false si al menos uno está vacío |
| 120 | 120 | */ |
| 121 | 121 | public static function all_full(array $array) : bool { |
| 122 | - foreach($array as $e) { |
|
| 123 | - if(self::emp($e) and $e != '0') { |
|
| 122 | + foreach ($array as $e) { |
|
| 123 | + if (self::emp($e) and $e != '0') { |
|
| 124 | 124 | return false; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public static function e() : bool { |
| 136 | 136 | for ($i = 0, $nargs = func_num_args(); $i < $nargs; $i++) { |
| 137 | - if(self::emp(func_get_arg($i)) && func_get_arg($i) != '0') { |
|
| 137 | + if (self::emp(func_get_arg($i)) && func_get_arg($i) != '0') { |
|
| 138 | 138 | return true; |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @return string con la fecha en formato humano (y en español) |
| 153 | 153 | */ |
| 154 | 154 | public static function fecha(string $format, int $time = 0) : string { |
| 155 | - $date = date($format,$time == 0 ? time() : $time); |
|
| 155 | + $date = date($format, $time == 0 ? time() : $time); |
|
| 156 | 156 | $cambios = array( |
| 157 | 157 | 'Monday'=> 'Lunes', |
| 158 | 158 | 'Tuesday'=> 'Martes', |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | # Revisar protocolo |
| 201 | 201 | $https = 'http://'; |
| 202 | - if($config['router']['ssl']) { |
|
| 202 | + if ($config['router']['ssl']) { |
|
| 203 | 203 | # Revisar el protocolo |
| 204 | - if(true == $http->server->get('HTTPS') |
|
| 204 | + if (true == $http->server->get('HTTPS') |
|
| 205 | 205 | || $http->server->get('HTTPS') == 'on' |
| 206 | 206 | || $http->server->get('HTTPS') == 1) { |
| 207 | 207 | $https = 'https://'; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | # Revisar el path |
| 212 | 212 | $path = $config['router']['path']; |
| 213 | - if('/' != substr($path, -1)) { |
|
| 213 | + if ('/' != substr($path, -1)) { |
|
| 214 | 214 | $path .= '/'; |
| 215 | 215 | } |
| 216 | 216 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @return string con el número del día |
| 234 | 234 | */ |
| 235 | 235 | public static function last_day_month(int $mes, int $anio) : string { |
| 236 | - return date('d', (mktime(0,0,0,$mes + 1, 1, $anio) - 1)); |
|
| 236 | + return date('d', (mktime(0, 0, 0, $mes + 1, 1, $anio) - 1)); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -256,10 +256,10 @@ discard block |
||
| 256 | 256 | * @return int|null con el timestamp |
| 257 | 257 | */ |
| 258 | 258 | public static function str_to_time($fecha, string $hora = '00:00:00') { |
| 259 | - $detail = explode('/',$fecha ?? ''); |
|
| 259 | + $detail = explode('/', $fecha ?? ''); |
|
| 260 | 260 | |
| 261 | 261 | // Formato de día incorrecto, mes y año incorrectos |
| 262 | - if(self::check_time($detail)) { |
|
| 262 | + if (self::check_time($detail)) { |
|
| 263 | 263 | return null; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | */ |
| 286 | 286 | public static function desde_date(int $desde) { |
| 287 | 287 | # Obtener esta fecha |
| 288 | - $hoy = date('d/m/Y/D',time()); |
|
| 289 | - $hoy = explode('/',$hoy); |
|
| 288 | + $hoy = date('d/m/Y/D', time()); |
|
| 289 | + $hoy = explode('/', $hoy); |
|
| 290 | 290 | |
| 291 | 291 | # Arreglo de condiciones y subcondiciones |
| 292 | 292 | $fecha = array( |
@@ -301,21 +301,21 @@ discard block |
||
| 301 | 301 | 'Sat' => intval($hoy[0]) - 5, |
| 302 | 302 | 'Sun' => intval($hoy[0]) - 6 |
| 303 | 303 | ), |
| 304 | - 4 => '01/'. self::cero_izq($hoy[1]) .'/' . $hoy[2], |
|
| 304 | + 4 => '01/' . self::cero_izq($hoy[1]) . '/' . $hoy[2], |
|
| 305 | 305 | 5 => '01/01/' . $hoy[2] |
| 306 | 306 | ); |
| 307 | 307 | |
| 308 | - if($desde == 3) { |
|
| 308 | + if ($desde == 3) { |
|
| 309 | 309 | # Dia actual |
| 310 | 310 | $dia = $fecha[3][$hoy[3]]; |
| 311 | 311 | |
| 312 | 312 | # Mes anterior y posiblemente, año también. |
| 313 | - if($dia == 0) { |
|
| 313 | + if ($dia == 0) { |
|
| 314 | 314 | # Restante de la fecha |
| 315 | - $real_fecha = self::last_day_month($hoy[1],$hoy[2]) .'/'. self::cero_izq($hoy[1] - 1) .'/'; |
|
| 315 | + $real_fecha = self::last_day_month($hoy[1], $hoy[2]) . '/' . self::cero_izq($hoy[1] - 1) . '/'; |
|
| 316 | 316 | |
| 317 | 317 | # Verificamos si estamos en enero |
| 318 | - if($hoy[1] == 1) { |
|
| 318 | + if ($hoy[1] == 1) { |
|
| 319 | 319 | return $real_fecha . ($hoy[2] - 1); |
| 320 | 320 | } |
| 321 | 321 | |
@@ -323,8 +323,8 @@ discard block |
||
| 323 | 323 | return $real_fecha . $hoy[2]; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - return self::cero_izq($dia) .'/'. self::cero_izq($hoy[1]) .'/' . $hoy[2]; |
|
| 327 | - } else if(array_key_exists($desde,$fecha)) { |
|
| 326 | + return self::cero_izq($dia) . '/' . self::cero_izq($hoy[1]) . '/' . $hoy[2]; |
|
| 327 | + } else if (array_key_exists($desde, $fecha)) { |
|
| 328 | 328 | return $fecha[$desde]; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @param int|null $to: Tiempo en segundo hasta donde se desea contar, si no se pasa por defecto es el tiempo actual |
| 27 | 27 | * |
| 28 | 28 | * @return string con la forma: hace 20 segundos, hace 1 minuto, hace 2 horas, hace 4 días, hace 1 semana, hace 3 meses, hace 1 año ... |
| 29 | - */ |
|
| 29 | + */ |
|
| 30 | 30 | public static function amigable_time(int $from, $to = null) : string { |
| 31 | 31 | $intervalos = ['segundo', 'minuto', 'hora', 'día', 'semana', 'mes', 'año']; |
| 32 | 32 | $duraciones = ['60','60','24','7','4.35','12']; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @example Strings::chash('$2a$10$87b2b603324793cc37f8dOPFTnHRY0lviq5filK5cN4aMCQDJcC9G','123456'); //return true |
| 63 | 63 | * |
| 64 | 64 | * @return bool true si $s2 contiene la misma llave que $hash, por tanto el contenido de $hash es $s2, de lo contrario false |
| 65 | - */ |
|
| 65 | + */ |
|
| 66 | 66 | public static function chash(string $hash, string $s2) : bool { |
| 67 | 67 | return $hash == crypt($s2, substr($hash, 0, 29)); |
| 68 | 68 | } |
@@ -177,12 +177,12 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | - * Remueve todos los espacios en blanco de un string |
|
| 181 | - * |
|
| 182 | - * @param string $s: Cadena de texto a convertir |
|
| 183 | - * |
|
| 184 | - * @return string del texto sin espacios |
|
| 185 | - */ |
|
| 180 | + * Remueve todos los espacios en blanco de un string |
|
| 181 | + * |
|
| 182 | + * @param string $s: Cadena de texto a convertir |
|
| 183 | + * |
|
| 184 | + * @return string del texto sin espacios |
|
| 185 | + */ |
|
| 186 | 186 | public static function remove_spaces(string $s) : string { |
| 187 | 187 | return trim(str_replace(' ', '', $s)); |
| 188 | 188 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param string $s: Cadena de texto a verificar |
| 194 | 194 | * |
| 195 | 195 | * @return bool, verdadero si es alfanumerica, falso si no |
| 196 | - */ |
|
| 196 | + */ |
|
| 197 | 197 | public static function alphanumeric(string $s) : bool { |
| 198 | 198 | return ctype_alnum(self::remove_spaces($s)); |
| 199 | 199 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @param string $s: Cadena de texto a verificar |
| 206 | 206 | * |
| 207 | 207 | * @return bool, verdadero si sólamente tiene letras, falso si no |
| 208 | - */ |
|
| 208 | + */ |
|
| 209 | 209 | public static function only_letters(string $s) : bool { |
| 210 | 210 | return ctype_alpha(self::remove_spaces($s)); |
| 211 | 211 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param string $url: Cadena de texto a convertir |
| 230 | 230 | * |
| 231 | 231 | * @return string Cadena de texto con formato de url amigable |
| 232 | - */ |
|
| 232 | + */ |
|
| 233 | 233 | public static function url_amigable(string $url) : string { |
| 234 | 234 | $url = str_replace(['á', 'é', 'í', 'ó', 'ú', 'ñ'], ['a', 'e', 'i', 'o', 'u', 'n'], $url); |
| 235 | 235 | $url = str_replace([' ', '&', '\r\n', '\n', '+', '%'], '-', $url); |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | * Identificador único para la extensión de twig |
| 370 | 370 | * |
| 371 | 371 | * @return string Nombre de la extensión |
| 372 | - */ |
|
| 372 | + */ |
|
| 373 | 373 | public function getName() : string { |
| 374 | 374 | return 'ocrend_framework_helper_strings'; |
| 375 | 375 | } |
@@ -29,25 +29,25 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public static function amigable_time(int $from, $to = null) : string { |
| 31 | 31 | $intervalos = ['segundo', 'minuto', 'hora', 'día', 'semana', 'mes', 'año']; |
| 32 | - $duraciones = ['60','60','24','7','4.35','12']; |
|
| 32 | + $duraciones = ['60', '60', '24', '7', '4.35', '12']; |
|
| 33 | 33 | $to = $to ?? time(); |
| 34 | 34 | |
| 35 | 35 | $diferencia = $from - $to; |
| 36 | 36 | $tiempo = 'Dentro de'; |
| 37 | - if($to > $from) { |
|
| 37 | + if ($to > $from) { |
|
| 38 | 38 | $diferencia = $to - $from; |
| 39 | 39 | $tiempo = 'Hace'; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - for($j = 0; $diferencia >= $duraciones[$j] && $j < sizeof($duraciones) - 1 ; $j++) { |
|
| 42 | + for ($j = 0; $diferencia >= $duraciones[$j] && $j < sizeof($duraciones) - 1; $j++) { |
|
| 43 | 43 | $diferencia /= $duraciones[$j]; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $diferencia = round($diferencia); |
| 47 | 47 | |
| 48 | - if($diferencia != 1) { |
|
| 49 | - $intervalos[5].= 'e'; //MESES |
|
| 50 | - $intervalos[$j].= 's'; |
|
| 48 | + if ($diferencia != 1) { |
|
| 49 | + $intervalos[5] .= 'e'; //MESES |
|
| 50 | + $intervalos[$j] .= 's'; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | return $tiempo . ' ' . $diferencia . ' ' . $intervalos[$j]; |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | * @return string : Texto desencriptado |
| 103 | 103 | */ |
| 104 | 104 | public static function ocrend_decode(string $str, string $key) : string { |
| 105 | - $data = base64_decode($str ); |
|
| 106 | - $___s___ = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)); |
|
| 105 | + $data = base64_decode($str); |
|
| 106 | + $___s___ = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)); |
|
| 107 | 107 | return rtrim( |
| 108 | 108 | mcrypt_decrypt( |
| 109 | 109 | MCRYPT_RIJNDAEL_128, |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | */ |
| 139 | 139 | public static function date_difference(string $ini, string $fin) : int { |
| 140 | - $ini_i = explode('-',str_replace('/','-',$ini)); |
|
| 141 | - $fin_i = explode('-',str_replace('/','-',$fin)); |
|
| 142 | - return (int) floor((mktime(0, 0, 0, $fin_i[1], $fin_i[0], $fin_i[2]) - mktime(0, 0, 0, $ini_i[1], $ini_i[0], $ini_i[2])) / 86400); |
|
| 140 | + $ini_i = explode('-', str_replace('/', '-', $ini)); |
|
| 141 | + $fin_i = explode('-', str_replace('/', '-', $fin)); |
|
| 142 | + return (int) floor((mktime(0, 0, 0, $fin_i[1], $fin_i[0], $fin_i[2]) - mktime(0, 0, 0, $ini_i[1], $ini_i[0], $ini_i[2]))/86400); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | */ |
| 164 | 164 | public static function days_of_month() : int { |
| 165 | - return cal_days_in_month(CAL_GREGORIAN, (int) date('m',time()), (int) date('Y',time())); |
|
| 165 | + return cal_days_in_month(CAL_GREGORIAN, (int) date('m', time()), (int) date('Y', time())); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @return int Cantidad de palabras |
| 336 | 336 | */ |
| 337 | 337 | public static function count_words(string $s) : int { |
| 338 | - return (int) str_word_count($s,0,'0..9_'); |
|
| 338 | + return (int) str_word_count($s, 0, '0..9_'); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -25,57 +25,57 @@ |
||
| 25 | 25 | abstract class Controllers { |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * Obtiene el objeto del template |
|
| 29 | - * |
|
| 30 | - * @var \Twig_Environment |
|
| 31 | - */ |
|
| 28 | + * Obtiene el objeto del template |
|
| 29 | + * |
|
| 30 | + * @var \Twig_Environment |
|
| 31 | + */ |
|
| 32 | 32 | protected $template; |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * Verifica si está definida la ruta /id como un integer >= 1 |
|
| 36 | - * |
|
| 37 | - * @var bool |
|
| 38 | - */ |
|
| 35 | + * Verifica si está definida la ruta /id como un integer >= 1 |
|
| 36 | + * |
|
| 37 | + * @var bool |
|
| 38 | + */ |
|
| 39 | 39 | protected $isset_id = false; |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * Tiene el valor de la ruta /método |
|
| 43 | - * |
|
| 44 | - * @var string|null |
|
| 45 | - */ |
|
| 42 | + * Tiene el valor de la ruta /método |
|
| 43 | + * |
|
| 44 | + * @var string|null |
|
| 45 | + */ |
|
| 46 | 46 | protected $method; |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * Arreglo con la información del usuario conectado actualmente. |
|
| 50 | - * |
|
| 51 | - * @var array |
|
| 52 | - */ |
|
| 49 | + * Arreglo con la información del usuario conectado actualmente. |
|
| 50 | + * |
|
| 51 | + * @var array |
|
| 52 | + */ |
|
| 53 | 53 | protected $user = array(); |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | - * Contiene información sobre el estado del usuario, si está o no conectado. |
|
| 57 | - * |
|
| 58 | - * @var bool |
|
| 59 | - */ |
|
| 56 | + * Contiene información sobre el estado del usuario, si está o no conectado. |
|
| 57 | + * |
|
| 58 | + * @var bool |
|
| 59 | + */ |
|
| 60 | 60 | private $is_logged = false; |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * Parámetros de configuración para el controlador con la forma: |
|
| 64 | - * 'parmáetro' => (bool) valor |
|
| 65 | - * |
|
| 66 | - * @var array |
|
| 67 | - */ |
|
| 63 | + * Parámetros de configuración para el controlador con la forma: |
|
| 64 | + * 'parmáetro' => (bool) valor |
|
| 65 | + * |
|
| 66 | + * @var array |
|
| 67 | + */ |
|
| 68 | 68 | private $controllerConfig; |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Configuración inicial de cualquier controlador |
|
| 72 | - * |
|
| 73 | - * @param IRouter $router: Instancia de un Router |
|
| 74 | - * @param array $configController: Arreglo de configuración con la forma |
|
| 75 | - * 'users_logged' => bool, # Configura el controlador para solo ser visto por usuarios logeados |
|
| 76 | - * 'users_not_logged' => bool, # Configura el controlador para solo ser visto por !(usuarios logeados) |
|
| 77 | - * |
|
| 78 | - */ |
|
| 71 | + * Configuración inicial de cualquier controlador |
|
| 72 | + * |
|
| 73 | + * @param IRouter $router: Instancia de un Router |
|
| 74 | + * @param array $configController: Arreglo de configuración con la forma |
|
| 75 | + * 'users_logged' => bool, # Configura el controlador para solo ser visto por usuarios logeados |
|
| 76 | + * 'users_not_logged' => bool, # Configura el controlador para solo ser visto por !(usuarios logeados) |
|
| 77 | + * |
|
| 78 | + */ |
|
| 79 | 79 | protected function __construct(IRouter $router, $configController = []) { |
| 80 | 80 | global $config, $http, $session, $cookie; |
| 81 | 81 | |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | $this->template->addExtension(new Helper\Functions); |
| 120 | 120 | |
| 121 | 121 | # Debug disponible en twig |
| 122 | - if(!$config['build']['production']) { |
|
| 122 | + if (!$config['build']['production']) { |
|
| 123 | 123 | $this->template->addExtension(new \Twig_Extension_Debug()); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -48,12 +48,12 @@ |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | # Arrancar |
| 51 | -if($config['build']['production']) { |
|
| 51 | +if ($config['build']['production']) { |
|
| 52 | 52 | try { |
| 53 | 53 | ___loadApi(); |
| 54 | - } catch(\Throwable $e) { |
|
| 54 | + } catch (\Throwable $e) { |
|
| 55 | 55 | ___catchApi(); |
| 56 | - } catch(\Exception $e) { |
|
| 56 | + } catch (\Exception $e) { |
|
| 57 | 57 | ___catchApi(); |
| 58 | 58 | } |
| 59 | 59 | } else { |