@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | Logger::log('Configuration saved successful'); |
64 | 64 | Security::getInstance()->setFlash("callback_message", _("Usuario agregado correctamente")); |
65 | 65 | Security::getInstance()->setFlash("callback_route", Router::getInstance()->getRoute("admin", true)); |
66 | - } else { |
|
66 | + }else { |
|
67 | 67 | throw new ConfigException(_('Error al guardar los administradores, prueba a cambiar los permisos')); |
68 | 68 | } |
69 | 69 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | if ($this->isAdmin()) { |
101 | 101 | return $this->redirect('admin'); |
102 | - } else { |
|
102 | + }else { |
|
103 | 103 | return Admin::staticAdminLogon($route); |
104 | 104 | } |
105 | 105 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $cookies = array( |
132 | 132 | array( |
133 | 133 | "name" => Security::getInstance()->getHash(), |
134 | - "value" => base64_encode($form->getFieldValue("user") . ":" . $form->getFieldValue("pass")), |
|
134 | + "value" => base64_encode($form->getFieldValue("user").":".$form->getFieldValue("pass")), |
|
135 | 135 | "expire" => time() + 3600, |
136 | 136 | "http" => true, |
137 | 137 | ) |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | 'status_message' => _("Acceso permitido... redirigiendo!!"), |
143 | 143 | 'delay' => 1, |
144 | 144 | ); |
145 | - } else { |
|
145 | + }else { |
|
146 | 146 | $form->setError("user", _("El usuario no tiene acceso a la web")); |
147 | 147 | } |
148 | 148 | } |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public static function staticAdminLogon($route = null) |
50 | 50 | { |
51 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
51 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
52 | 52 | if ('login' !== Config::getInstance()->get('admin_login')) { |
53 | 53 | return AdminServices::getInstance()->setAdminHeaders(); |
54 | - } else { |
|
54 | + }else { |
|
55 | 55 | $form = new LoginForm(); |
56 | 56 | $form->setData(array("route" => $route)); |
57 | 57 | $form->build(); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | 'form' => $form, |
62 | 62 | )); |
63 | 63 | } |
64 | - } else { |
|
64 | + }else { |
|
65 | 65 | return UserController::showAdminManager(); |
66 | 66 | } |
67 | 67 | } |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use PSFS\base\config\Config; |
6 | 6 | use PSFS\base\config\LoginForm; |
7 | -use PSFS\base\Router; |
|
8 | 7 | use PSFS\base\Template; |
9 | 8 | use PSFS\base\types\AuthAdminController; |
10 | 9 | use PSFS\controller\UserController; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - Logger::log(get_class($this) . ' constructor invoked'); |
|
23 | + Logger::log(get_class($this).' constructor invoked'); |
|
24 | 24 | $this->init(); |
25 | 25 | } |
26 | 26 | |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | $calledClass = get_called_class(); |
91 | 91 | try { |
92 | 92 | $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
93 | - $setter = "set" . ucfirst($variable); |
|
93 | + $setter = "set".ucfirst($variable); |
|
94 | 94 | if (method_exists($calledClass, $setter)) { |
95 | 95 | $this->$setter($instance); |
96 | - } else { |
|
96 | + }else { |
|
97 | 97 | $this->$variable = $instance; |
98 | 98 | } |
99 | - } catch (\Exception $e) { |
|
100 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
99 | + }catch (\Exception $e) { |
|
100 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
101 | 101 | } |
102 | 102 | return $this; |
103 | 103 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | { |
110 | 110 | if (!$this->isLoaded()) { |
111 | 111 | $filename = sha1(get_class($this)); |
112 | - $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . ".json"; |
|
112 | + $cacheFilename = "reflections".DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.".json"; |
|
113 | 113 | /** @var \PSFS\base\Cache $cacheService */ |
114 | 114 | $cacheService = Cache::getInstance(); |
115 | 115 | /** @var \PSFS\base\config\Config $configService */ |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | $this->load($property, true, $class); |
125 | 125 | } |
126 | 126 | $this->setLoaded(); |
127 | - } else { |
|
128 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
127 | + }else { |
|
128 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |
@@ -121,9 +121,11 @@ |
||
121 | 121 | $cacheService->storeData($cacheFilename, $properties, $cache); |
122 | 122 | } |
123 | 123 | /** @var \ReflectionProperty $property */ |
124 | - if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) { |
|
124 | + if (!empty($properties) && is_array($properties)) { |
|
125 | + foreach ($properties as $property => $class) { |
|
125 | 126 | $this->load($property, true, $class); |
126 | 127 | } |
128 | + } |
|
127 | 129 | $this->setLoaded(); |
128 | 130 | } else { |
129 | 131 | Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
@@ -144,7 +144,7 @@ |
||
144 | 144 | * @param string $path |
145 | 145 | * @param $domains |
146 | 146 | * |
147 | - * @return mixed |
|
147 | + * @return string |
|
148 | 148 | */ |
149 | 149 | private static function extractPathname($path, $domains) |
150 | 150 | { |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | |
40 | 40 | $file_path = ""; |
41 | 41 | if (!file_exists($file_path)) { |
42 | - $file_path = BASE_DIR . $string; |
|
42 | + $file_path = BASE_DIR.$string; |
|
43 | 43 | } |
44 | 44 | $filename_path = AssetsParser::findDomainPath($string, $file_path); |
45 | 45 | |
46 | 46 | $file_path = self::processAsset($string, $name, $return, $filename_path); |
47 | - $return_path = (empty($name)) ? Request::getInstance()->getRootUrl() . '/' . $file_path : $name; |
|
47 | + $return_path = (empty($name)) ? Request::getInstance()->getRootUrl().'/'.$file_path : $name; |
|
48 | 48 | return ($return) ? $return_path : ''; |
49 | 49 | } |
50 | 50 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $router = Router::getInstance(); |
62 | 62 | try { |
63 | 63 | return $router->getRoute($path, $absolute, $params); |
64 | - } catch (\Exception $e) { |
|
64 | + }catch (\Exception $e) { |
|
65 | 65 | return $router->getRoute('', $absolute, $params); |
66 | 66 | } |
67 | 67 | } |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | private static function putResourceContent($name, $filename_path, $base, $file_path) |
188 | 188 | { |
189 | 189 | $data = file_get_contents($filename_path); |
190 | - if (!empty($name)) file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
|
191 | - else file_put_contents($base . $file_path, $data); |
|
190 | + if (!empty($name)) file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data); |
|
191 | + else file_put_contents($base.$file_path, $data); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | if (file_exists($filename_path)) { |
207 | 207 | list($base, $html_base, $file_path) = AssetsParser::calculateAssetPath($string, $name, $return, $filename_path); |
208 | 208 | //Creamos el directorio si no existe |
209 | - GeneratorHelper::createDir($base . $html_base); |
|
209 | + GeneratorHelper::createDir($base.$html_base); |
|
210 | 210 | //Si se ha modificado |
211 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($filename_path)) { |
|
211 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($filename_path)) { |
|
212 | 212 | if ($html_base == 'css') { |
213 | 213 | self::processCssLines($filename_path); |
214 | 214 | } |
@@ -187,8 +187,11 @@ |
||
187 | 187 | private static function putResourceContent($name, $filename_path, $base, $file_path) |
188 | 188 | { |
189 | 189 | $data = file_get_contents($filename_path); |
190 | - if (!empty($name)) file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
|
191 | - else file_put_contents($base . $file_path, $data); |
|
190 | + if (!empty($name)) { |
|
191 | + file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
|
192 | + } else { |
|
193 | + file_put_contents($base . $file_path, $data); |
|
194 | + } |
|
192 | 195 | } |
193 | 196 | |
194 | 197 | /** |
@@ -48,6 +48,9 @@ discard block |
||
48 | 48 | return $this; |
49 | 49 | } |
50 | 50 | |
51 | + /** |
|
52 | + * @param string|null $action |
|
53 | + */ |
|
51 | 54 | public function setAction($action) |
52 | 55 | { |
53 | 56 | $this->action = $action; |
@@ -562,7 +565,7 @@ discard block |
||
562 | 565 | } |
563 | 566 | |
564 | 567 | /** |
565 | - * @param $token_field |
|
568 | + * @param string $token_field |
|
566 | 569 | * @return bool |
567 | 570 | */ |
568 | 571 | protected function existsFormToken($token_field) |
@@ -594,7 +597,7 @@ discard block |
||
594 | 597 | /** |
595 | 598 | * Método que extrae el valor de un campo del formulario del modelo |
596 | 599 | * @param $field |
597 | - * @param $value |
|
600 | + * @param ObjectCollection $value |
|
598 | 601 | * @param $type |
599 | 602 | * @return mixed |
600 | 603 | */ |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | public function add($name, array $value = array()) |
70 | 70 | { |
71 | 71 | $this->fields[$name] = $value; |
72 | - $this->fields[$name]['name'] = $this->getName() . "[{$name}]"; |
|
73 | - $this->fields[$name]['id'] = $this->getName() . '_' . $name; |
|
72 | + $this->fields[$name]['name'] = $this->getName()."[{$name}]"; |
|
73 | + $this->fields[$name]['id'] = $this->getName().'_'.$name; |
|
74 | 74 | $this->fields[$name]['placeholder'] = (array_key_exists('placeholder', $value)) ? $value['placeholder'] : $name; |
75 | 75 | $this->fields[$name]['hasLabel'] = (array_key_exists('hasLabel', $value)) ? $value['hasLabel'] : true; |
76 | 76 | return $this; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | if ('' !== $hash_orig) { |
135 | 135 | $this->crfs = sha1($hash_orig); |
136 | - $this->add($this->getName() . '_token', array( |
|
136 | + $this->add($this->getName().'_token', array( |
|
137 | 137 | "type" => "hidden", |
138 | 138 | "value" => $this->crfs, |
139 | 139 | )); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | public function isValid() |
203 | 203 | { |
204 | 204 | $valid = true; |
205 | - $token_field = $this->getName() . '_token'; |
|
205 | + $token_field = $this->getName().'_token'; |
|
206 | 206 | //Controlamos CSRF token |
207 | 207 | if (!$this->existsFormToken($token_field)) { |
208 | 208 | $this->errors[$token_field] = _('Formulario no válido'); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $data = array(); |
275 | 275 | if (count($this->fields) > 0) { |
276 | 276 | foreach ($this->fields as $key => $field) { |
277 | - if (self::SEPARATOR !== $key && $key !== ($this->getName() . "_token")) { |
|
277 | + if (self::SEPARATOR !== $key && $key !== ($this->getName()."_token")) { |
|
278 | 278 | $data[$key] = (array_key_exists('value', $field)) ? $field["value"] : null; |
279 | 279 | } |
280 | 280 | } |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | $model = $this->getHydratedModel(); |
390 | 390 | $model->save(); |
391 | 391 | $save = true; |
392 | - Logger::getInstance()->infoLog(get_class($this->model) . " guardado con id " . $this->model->getPrimaryKey()); |
|
393 | - } catch (\Exception $e) { |
|
392 | + Logger::getInstance()->infoLog(get_class($this->model)." guardado con id ".$this->model->getPrimaryKey()); |
|
393 | + }catch (\Exception $e) { |
|
394 | 394 | Logger::getInstance()->errorLog($e->getMessage()); |
395 | 395 | throw new FormException($e->getMessage(), $e->getCode(), $e); |
396 | 396 | } |
@@ -409,10 +409,10 @@ discard block |
||
409 | 409 | if (null === $value) { |
410 | 410 | $isEmpty = true; |
411 | 411 | // Empty Array check |
412 | - } else if (is_array($value) && 0 === count($value)) { |
|
412 | + }else if (is_array($value) && 0 === count($value)) { |
|
413 | 413 | $isEmpty = true; |
414 | 414 | // Empty string check |
415 | - } else if (0 === strlen(preg_replace('/(\ |\r|\n)/m', '', $value))) { |
|
415 | + }else if (0 === strlen(preg_replace('/(\ |\r|\n)/m', '', $value))) { |
|
416 | 416 | $isEmpty = true; |
417 | 417 | } |
418 | 418 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | && array_key_exists($key, $field) |
440 | 440 | && !array_key_exists('error', $field[$key]) |
441 | 441 | && !empty($field["value"]) |
442 | - && preg_match('/' . $field['pattern'] . '/', $field['value']) === 0 |
|
442 | + && preg_match('/'.$field['pattern'].'/', $field['value']) === 0 |
|
443 | 443 | ) { |
444 | 444 | $this->setError($key, str_replace('%s', "<strong>{$key}</strong>", _("El campo %s no tiene un formato válido"))); |
445 | 445 | $field["error"] = $this->getError($key); |
@@ -461,10 +461,10 @@ discard block |
||
461 | 461 | if (array_key_exists($key, $data[$form_name])) { |
462 | 462 | if (preg_match("/id/i", $key) && ($data[$form_name][$key] === 0 || $data[$form_name][$key] === "%" || $data[$form_name][$key] === "")) { |
463 | 463 | $field["value"] = null; |
464 | - } else { |
|
464 | + }else { |
|
465 | 465 | $field["value"] = $data[$form_name][$key]; |
466 | 466 | } |
467 | - } else { |
|
467 | + }else { |
|
468 | 468 | unset($field["value"]); |
469 | 469 | } |
470 | 470 | return array($data, $field); |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | */ |
479 | 479 | private function hydrateModelField($key, $value) |
480 | 480 | { |
481 | - $setter = "set" . ucfirst($key); |
|
482 | - $getter = "get" . ucfirst($key); |
|
481 | + $setter = "set".ucfirst($key); |
|
482 | + $getter = "get".ucfirst($key); |
|
483 | 483 | if (method_exists($this->model, $setter)) { |
484 | 484 | if (method_exists($this->model, $getter)) { |
485 | 485 | $tmp = $this->model->$getter(); |
@@ -504,16 +504,16 @@ discard block |
||
504 | 504 | { |
505 | 505 | //Extraemos el dato del modelo relacionado si existe el getter |
506 | 506 | $method = null; |
507 | - if (array_key_exists('class_data', $field) && method_exists($val, "get" . $field["class_data"])) { |
|
508 | - $class_method = "get" . $field["class_data"]; |
|
507 | + if (array_key_exists('class_data', $field) && method_exists($val, "get".$field["class_data"])) { |
|
508 | + $class_method = "get".$field["class_data"]; |
|
509 | 509 | $class = $val->$class_method(); |
510 | - if (array_key_exists('class_id', $field) && method_exists($class, "get" . $field["class_id"])) { |
|
511 | - $method = "get" . $field["class_id"]; |
|
510 | + if (array_key_exists('class_id', $field) && method_exists($class, "get".$field["class_id"])) { |
|
511 | + $method = "get".$field["class_id"]; |
|
512 | 512 | $data[] = $class->$method(); |
513 | - } else { |
|
513 | + }else { |
|
514 | 514 | $data[] = $class->getPrimaryKey(); |
515 | 515 | } |
516 | - } else { |
|
516 | + }else { |
|
517 | 517 | $data[] = $val; |
518 | 518 | } |
519 | 519 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | private function extractModelFieldValue($key, $field) |
530 | 530 | { |
531 | 531 | //Extraemos el valor del campo del modelo |
532 | - $method = "get" . ucfirst($key); |
|
532 | + $method = "get".ucfirst($key); |
|
533 | 533 | $type = (array_key_exists('type', $field)) ? $field["type"] : "text"; |
534 | 534 | //Extraemos los campos del modelo |
535 | 535 | if (method_exists($this->model, $method)) { |
@@ -539,16 +539,16 @@ discard block |
||
539 | 539 | //Si es una relación múltiple |
540 | 540 | if ($value instanceof ObjectCollection) { |
541 | 541 | $field = $this->computeModelFieldValue($field, $value, $type); |
542 | - } else { //O una relación unitaria |
|
542 | + }else { //O una relación unitaria |
|
543 | 543 | if (method_exists($value, "__toString")) { |
544 | 544 | $field["value"] = $value; |
545 | 545 | } elseif ($value instanceof \DateTime) { |
546 | 546 | $field["value"] = $value->format("Y-m-d H:i:s"); |
547 | - } else { |
|
547 | + }else { |
|
548 | 548 | $field["value"] = $value->getPrimaryKey(); |
549 | 549 | } |
550 | 550 | } |
551 | - } else { |
|
551 | + }else { |
|
552 | 552 | $field["value"] = $value; |
553 | 553 | } |
554 | 554 | } |
@@ -212,7 +212,9 @@ |
||
212 | 212 | //Validamos los campos del formulario |
213 | 213 | if ($valid && count($this->fields) > 0) { |
214 | 214 | foreach ($this->fields as $key => &$field) { |
215 | - if ($key === $token_field || $key === self::SEPARATOR) continue; |
|
215 | + if ($key === $token_field || $key === self::SEPARATOR) { |
|
216 | + continue; |
|
217 | + } |
|
216 | 218 | list($field, $valid) = $this->checkFieldValidation($field, $key); |
217 | 219 | } |
218 | 220 | } |
@@ -8,7 +8,13 @@ |
||
8 | 8 | */ |
9 | 9 | interface ControllerInterface |
10 | 10 | { |
11 | + /** |
|
12 | + * @return string|null |
|
13 | + */ |
|
11 | 14 | public function render($template, array $vars = [], $cookies = []); |
12 | 15 | |
16 | + /** |
|
17 | + * @return void |
|
18 | + */ |
|
13 | 19 | public function response($response, $type = 'text/html'); |
14 | 20 | } |
@@ -4,7 +4,6 @@ |
||
4 | 4 | use PSFS\base\config\Config; |
5 | 5 | use PSFS\base\Security; |
6 | 6 | use PSFS\base\Service; |
7 | -use PSFS\controller\Admin; |
|
8 | 7 | use Symfony\Component\Finder\Finder; |
9 | 8 | |
10 | 9 | class AdminServices extends Service |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | $platform = trim(Config::getInstance()->get("platform_name")); |
36 | 36 | header('HTTP/1.1 401 Unauthorized'); |
37 | - header('WWW-Authenticate: Basic Realm="' . $platform . '"'); |
|
37 | + header('WWW-Authenticate: Basic Realm="'.$platform.'"'); |
|
38 | 38 | echo _("Zona restringida"); |
39 | 39 | exit(); |
40 | 40 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $admin['class'] = 'primary'; |
76 | 76 | break; |
77 | 77 | } |
78 | - } else { |
|
78 | + }else { |
|
79 | 79 | $admin["class"] = "primary"; |
80 | 80 | } |
81 | 81 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $logs = array(); |
93 | 93 | /** @var \SplFileInfo $file */ |
94 | 94 | foreach ($files as $file) { |
95 | - $size = $file->getSize() / 8 / 1024; |
|
95 | + $size = $file->getSize()/8/1024; |
|
96 | 96 | $time = date("c", $file->getMTime()); |
97 | 97 | $dateTime = new \DateTime($time); |
98 | 98 | if (!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $time = date("c", $file->getMTime()); |
129 | 129 | $dateTime = new \DateTime($time); |
130 | 130 | $monthOpen = $dateTime->format("m"); |
131 | - $content = file($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename()); |
|
131 | + $content = file($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename()); |
|
132 | 132 | krsort($content); |
133 | 133 | $detailLog = array(); |
134 | 134 | foreach ($content as &$line) { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | break; |
182 | 182 | } |
183 | 183 | |
184 | - } catch (\Exception $e) { |
|
184 | + }catch (\Exception $e) { |
|
185 | 185 | $detail = array( |
186 | 186 | "type" => "danger", |
187 | 187 | ); |
@@ -61,11 +61,13 @@ discard block |
||
61 | 61 | */ |
62 | 62 | private function parseAdmins(&$admins) |
63 | 63 | { |
64 | - if (!empty($admins)) foreach ($admins as &$admin) { |
|
64 | + if (!empty($admins)) { |
|
65 | + foreach ($admins as &$admin) { |
|
65 | 66 | if (isset($admin["profile"])) { |
66 | 67 | switch ($admin["profile"]) { |
67 | 68 | case Security::MANAGER_ID_TOKEN: |
68 | 69 | $admin['class'] = 'warning'; |
70 | + } |
|
69 | 71 | break; |
70 | 72 | case Security::ADMIN_ID_TOKEN: |
71 | 73 | $admin['class'] = 'info'; |
@@ -95,7 +97,9 @@ discard block |
||
95 | 97 | $size = $file->getSize() / 8 / 1024; |
96 | 98 | $time = date("c", $file->getMTime()); |
97 | 99 | $dateTime = new \DateTime($time); |
98 | - if (!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
|
100 | + if (!isset($logs[$dateTime->format("Y")])) { |
|
101 | + $logs[$dateTime->format("Y")] = array(); |
|
102 | + } |
|
99 | 103 | $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array( |
100 | 104 | "filename" => $file->getFilename(), |
101 | 105 | "size" => round($size, 3) |
@@ -136,7 +140,9 @@ discard block |
||
136 | 140 | $detailLog[] = array_merge(array( |
137 | 141 | "log" => $line, |
138 | 142 | ), $detail); |
139 | - if (count($detailLog) >= 1000) break; |
|
143 | + if (count($detailLog) >= 1000) { |
|
144 | + break; |
|
145 | + } |
|
140 | 146 | } |
141 | 147 | $log = $detailLog; |
142 | 148 | } |
@@ -160,7 +166,9 @@ discard block |
||
160 | 166 | |
161 | 167 | $detail = json_decode($match[0][0], TRUE); |
162 | 168 | } |
163 | - if (empty($detail)) $detail = array(); |
|
169 | + if (empty($detail)) { |
|
170 | + $detail = array(); |
|
171 | + } |
|
164 | 172 | preg_match_all('/\>\ (.*):/i', $line, $match); |
165 | 173 | |
166 | 174 | $type = (isset($match[1][0])) ? $match[1][0] : ''; |
@@ -360,7 +360,7 @@ |
||
360 | 360 | * Translator from php types to swagger types |
361 | 361 | * @param string $format |
362 | 362 | * |
363 | - * @return array |
|
363 | + * @return string[] |
|
364 | 364 | */ |
365 | 365 | public static function translateSwaggerFormats($format) |
366 | 366 | { |
@@ -2,7 +2,6 @@ |
||
2 | 2 | namespace PSFS\services; |
3 | 3 | |
4 | 4 | use Propel\Runtime\Map\ColumnMap; |
5 | -use Propel\Runtime\Map\TableMap; |
|
6 | 5 | use PSFS\base\config\Config; |
7 | 6 | use PSFS\base\Logger; |
8 | 7 | use PSFS\base\Request; |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | if (!preg_match('/^ROOT/i', $module) && $module == $requestModule) { |
44 | 44 | $modules = [ |
45 | 45 | 'name' => $module, |
46 | - 'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'), |
|
46 | + 'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'), |
|
47 | 47 | ]; |
48 | 48 | } |
49 | - } catch (\Exception $e) { |
|
49 | + }catch (\Exception $e) { |
|
50 | 50 | $modules[] = $e->getMessage(); |
51 | 51 | } |
52 | 52 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function extractApiEndpoints(array $module) |
66 | 66 | { |
67 | - $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
67 | + $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
68 | 68 | $module_name = $module['name']; |
69 | 69 | $endpoints = []; |
70 | 70 | if (file_exists($module_path)) { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | if (count($finder)) { |
74 | 74 | /** @var \SplFileInfo $file */ |
75 | 75 | foreach ($finder as $file) { |
76 | - $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
76 | + $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
77 | 77 | $info = $this->extractApiInfo($namespace, $module_name); |
78 | 78 | if (!empty($info)) { |
79 | 79 | $endpoints[$namespace] = $info; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if (NULL !== $mInfo) { |
103 | 103 | $info[] = $mInfo; |
104 | 104 | } |
105 | - } catch (\Exception $e) { |
|
105 | + }catch (\Exception $e) { |
|
106 | 106 | Logger::getInstance()->errorLog($e->getMessage()); |
107 | 107 | } |
108 | 108 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
316 | 316 | $payload = $this->extractDtoProperties($namespace); |
317 | 317 | } |
318 | - } catch (\Exception $e) { |
|
318 | + }catch (\Exception $e) { |
|
319 | 319 | Logger::getInstance()->errorLog($e->getMessage()); |
320 | 320 | } |
321 | 321 | |
@@ -354,18 +354,18 @@ discard block |
||
354 | 354 | unset($methodInfo['return']['objects']); |
355 | 355 | if (in_array($methodInfo['method'], ['POST', 'PUT'])) { |
356 | 356 | $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments); |
357 | - } elseif($method->getNumberOfParameters() > 0) { |
|
357 | + } elseif ($method->getNumberOfParameters() > 0) { |
|
358 | 358 | $methodInfo['parameters'] = []; |
359 | - foreach($method->getParameters() as $parameter) { |
|
359 | + foreach ($method->getParameters() as $parameter) { |
|
360 | 360 | $parameterName = $parameter->getName(); |
361 | 361 | $types = []; |
362 | 362 | preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types); |
363 | - if(count($types) > 1) { |
|
363 | + if (count($types) > 1) { |
|
364 | 364 | $methodInfo['parameters'][$parameterName] = $types[1][0]; |
365 | 365 | } |
366 | 366 | } |
367 | 367 | } |
368 | - } catch (\Exception $e) { |
|
368 | + }catch (\Exception $e) { |
|
369 | 369 | jpre($e->getMessage()); |
370 | 370 | Logger::getInstance()->errorLog($e->getMessage()); |
371 | 371 | } |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | private static function swaggerResponses() { |
462 | 462 | $codes = [200, 400, 404, 500]; |
463 | 463 | $responses = []; |
464 | - foreach($codes as $code) { |
|
465 | - switch($code) { |
|
464 | + foreach ($codes as $code) { |
|
465 | + switch ($code) { |
|
466 | 466 | default: |
467 | 467 | case 200: |
468 | 468 | $message = _('Successful response'); |
@@ -514,10 +514,10 @@ discard block |
||
514 | 514 | $formatted = [ |
515 | 515 | "swagger" => "2.0", |
516 | 516 | "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)), |
517 | - "basePath" => '/' . $module['name'] . '/api', |
|
517 | + "basePath" => '/'.$module['name'].'/api', |
|
518 | 518 | "schemes" => [Request::getInstance()->getServer('HTTPS') == 'on' ? "https" : "http"], |
519 | 519 | "info" => [ |
520 | - "title" => _('Documentación API módulo ') . $module['name'], |
|
520 | + "title" => _('Documentación API módulo ').$module['name'], |
|
521 | 521 | "version" => Config::getParam('api.version', '1.0'), |
522 | 522 | "contact" => [ |
523 | 523 | "name" => Config::getParam("author", "Fran López"), |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $endpoints = DocumentorService::getInstance()->extractApiEndpoints($module); |
530 | 530 | foreach ($endpoints as $model) { |
531 | 531 | foreach ($model as $endpoint) { |
532 | - if(!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
|
532 | + if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
|
533 | 533 | $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']); |
534 | 534 | $description = $endpoint['description']; |
535 | 535 | $method = strtolower($endpoint['method']); |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | 'responses' => self::swaggerResponses(), |
541 | 541 | 'parameters' => [], |
542 | 542 | ]; |
543 | - if(array_key_exists('parameters', $endpoint)) { |
|
544 | - foreach($endpoint['parameters'] as $parameter => $type) { |
|
543 | + if (array_key_exists('parameters', $endpoint)) { |
|
544 | + foreach ($endpoint['parameters'] as $parameter => $type) { |
|
545 | 545 | list($type, $format) = self::translateSwaggerFormats($type); |
546 | 546 | $paths[$url][$method]['parameters'][] = [ |
547 | 547 | 'in' => 'path', |
@@ -553,19 +553,19 @@ discard block |
||
553 | 553 | } |
554 | 554 | |
555 | 555 | } |
556 | - foreach($endpoint['objects'] as $name => $object) { |
|
557 | - if(class_exists($name)) { |
|
556 | + foreach ($endpoint['objects'] as $name => $object) { |
|
557 | + if (class_exists($name)) { |
|
558 | 558 | $class = GeneratorHelper::extractClassFromNamespace($name); |
559 | 559 | $classDefinition = [ |
560 | 560 | 'type' => 'object', |
561 | - '$ref' => '#/definitions/' . $class, |
|
561 | + '$ref' => '#/definitions/'.$class, |
|
562 | 562 | ]; |
563 | 563 | $paths[$url][$method]['responses'][200]['schema']['properties']['data'] = $classDefinition; |
564 | 564 | $dtos += self::extractSwaggerDefinition($class, $object); |
565 | - if(!isset($paths[$url][$method]['tags']) || !in_array($class, $paths[$url][$method]['tags'])) { |
|
565 | + if (!isset($paths[$url][$method]['tags']) || !in_array($class, $paths[$url][$method]['tags'])) { |
|
566 | 566 | $paths[$url][$method]['tags'][] = $class; |
567 | 567 | } |
568 | - if(array_key_exists('payload', $endpoint)) { |
|
568 | + if (array_key_exists('payload', $endpoint)) { |
|
569 | 569 | $paths[$url][$method]['parameters'][] = [ |
570 | 570 | 'in' => 'body', |
571 | 571 | 'name' => $class, |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | protected function extractDtoName($dto, $isArray = false) |
594 | 594 | { |
595 | 595 | $dto = explode('\\', $dto); |
596 | - $modelDto = array_pop($dto) . "Dto"; |
|
596 | + $modelDto = array_pop($dto)."Dto"; |
|
597 | 597 | if ($isArray) { |
598 | 598 | $modelDto .= "List"; |
599 | 599 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | )) |
38 | 38 | ->addButton('submit', _("Acceder como {{username}}")) |
39 | 39 | ->addButton("cancel", _("Cancelar"), "button", array( |
40 | - "onclick" => "javacript:location.href = \"" . Router::getInstance()->getRoute('') . "\";", |
|
40 | + "onclick" => "javacript:location.href = \"".Router::getInstance()->getRoute('')."\";", |
|
41 | 41 | "class" => "btn-link", |
42 | 42 | )); |
43 | 43 | } |