@@ -21,11 +21,11 @@ |
||
21 | 21 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
22 | 22 | |
23 | 23 | // filepath |
24 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
24 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
25 | 25 | if (!file_exists($abs_path)) { |
26 | - pre('→ ' . $class); |
|
27 | - pre('→ ' . $path); |
|
28 | - pre('→ ' . $abs_path); |
|
26 | + pre('→ '.$class); |
|
27 | + pre('→ '.$path); |
|
28 | + pre('→ '.$abs_path); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | // require the file |
@@ -38,8 +38,8 @@ |
||
38 | 38 | //Generating the templates translations |
39 | 39 | $translations = $this->tpl->regenerateTemplates(); |
40 | 40 | |
41 | - $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
42 | - $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
41 | + $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
42 | + $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
43 | 43 | |
44 | 44 | //xgettext localizations |
45 | 45 | $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale)); |
@@ -35,7 +35,9 @@ |
||
35 | 35 | public function getTranslations($locale) |
36 | 36 | { |
37 | 37 | //Default locale |
38 | - if (null === $locale) $locale = $this->config->get("default.language", 'es_ES'); |
|
38 | + if (null === $locale) { |
|
39 | + $locale = $this->config->get("default.language", 'es_ES'); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | //Generating the templates translations |
41 | 43 | $translations = $this->tpl->regenerateTemplates(); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | unset($_SERVER["PHP_AUTH_USER"]); |
39 | 39 | unset($_SERVER["PHP_AUTH_PW"]); |
40 | 40 | header_remove("Authorization"); |
41 | - } else { |
|
41 | + }else { |
|
42 | 42 | header('Authorization:'); |
43 | 43 | } |
44 | 44 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | Logger::log('Adding debug headers to render response'); |
67 | 67 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
68 | 68 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
69 | - header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
70 | - header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
71 | - header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
69 | + header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
70 | + header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
71 | + header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return $vars; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * Método que extrae los parámetros de una función |
142 | 142 | * |
143 | - * @param array $sr |
|
143 | + * @param string[] $sr |
|
144 | 144 | * @param \ReflectionMethod $method |
145 | 145 | * |
146 | 146 | * @return array |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param string $docComments |
209 | 209 | * |
210 | - * @return bool |
|
210 | + * @return string |
|
211 | 211 | */ |
212 | 212 | public static function extractReflectionCacheability($docComments) |
213 | 213 | { |
@@ -59,8 +59,10 @@ |
||
59 | 59 | $_route = explode("/", $url['path']); |
60 | 60 | $_pattern = explode("/", $pattern); |
61 | 61 | $get = array(); |
62 | - if (!empty($_pattern)) foreach ($_pattern as $index => $component) { |
|
62 | + if (!empty($_pattern)) { |
|
63 | + foreach ($_pattern as $index => $component) { |
|
63 | 64 | $_get = array(); |
65 | + } |
|
64 | 66 | preg_match_all('/^\{(.*)\}$/i', $component, $_get); |
65 | 67 | if (!empty($_get[1]) && isset($_route[$index])) { |
66 | 68 | $get[array_pop($_get[1])] = $_route[$index]; |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | public static function getClassToCall(array $action) |
20 | 20 | { |
21 | 21 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
22 | - $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class']; |
|
22 | + $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class']; |
|
23 | 23 | $reflectionClass = new \ReflectionClass($actionClass); |
24 | - if($reflectionClass->hasMethod('getInstance')) { |
|
24 | + if ($reflectionClass->hasMethod('getInstance')) { |
|
25 | 25 | $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']); |
26 | - } else { |
|
26 | + }else { |
|
27 | 27 | $class = new $actionClass; |
28 | 28 | } |
29 | 29 | return $class; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $expr = preg_quote($expr, '/'); |
111 | 111 | $expr = str_replace('###', '(.*)', $expr); |
112 | 112 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
113 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
113 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
114 | 114 | return $matched; |
115 | 115 | } |
116 | 116 | |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
123 | 123 | { |
124 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
125 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
124 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
125 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
126 | 126 | $tpl_path = "templates"; |
127 | 127 | $public_path = "public"; |
128 | 128 | $model_path = "models"; |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | $model_path = ucfirst($model_path); |
133 | 133 | } |
134 | 134 | if ($class->hasConstant("TPL")) { |
135 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
135 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
136 | 136 | } |
137 | 137 | return [ |
138 | 138 | 'base' => $path, |
139 | - 'template' => $path . $tpl_path, |
|
140 | - 'model' => $path . $model_path, |
|
141 | - 'public' => $path . $public_path, |
|
139 | + 'template' => $path.$tpl_path, |
|
140 | + 'model' => $path.$model_path, |
|
141 | + 'public' => $path.$public_path, |
|
142 | 142 | ]; |
143 | 143 | } |
144 | 144 | |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | foreach ($parameters as $param) { |
163 | 163 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
164 | 164 | $params[$param->getName()] = $param->getDefaultValue(); |
165 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
166 | - } elseif(!$param->isOptional()) { |
|
165 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
166 | + } elseif (!$param->isOptional()) { |
|
167 | 167 | $requirements[] = $param->getName(); |
168 | 168 | } |
169 | 169 | } |
170 | - } else { |
|
170 | + }else { |
|
171 | 171 | $default = $regex; |
172 | 172 | } |
173 | 173 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $default = str_replace('{__DOMAIN__}', $module, $default); |
250 | 250 | $httpMethod = self::extractReflectionHttpMethod($docComments); |
251 | 251 | $label = self::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
252 | - $route = $httpMethod . "#|#" . $regex; |
|
252 | + $route = $httpMethod."#|#".$regex; |
|
253 | 253 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
254 | 254 | $info = [ |
255 | 255 | 'method' => $method->getName(), |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * @route /admin/config/params |
23 | 23 | * @label Parámetros de configuración de PSGS |
24 | 24 | * @visible false |
25 | - * @return mixed |
|
25 | + * @return string|null |
|
26 | 26 | */ |
27 | 27 | public function getConfigParams() |
28 | 28 | { |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | foreach ($domains as $domain => $routes) { |
32 | 32 | $pDomain = str_replace('@', '', $domain); |
33 | 33 | $pDomain = str_replace('/', '', $pDomain); |
34 | - $response[] = strtolower($pDomain) . '.api.secret'; |
|
34 | + $response[] = strtolower($pDomain).'.api.secret'; |
|
35 | 35 | } |
36 | 36 | return $this->json($response); |
37 | 37 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function config() |
47 | 47 | { |
48 | - Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri()); |
|
48 | + Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri()); |
|
49 | 49 | /* @var $form \PSFS\base\config\ConfigForm */ |
50 | 50 | $form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig()); |
51 | 51 | $form->build(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | Security::getInstance()->setFlash("callback_message", _("Configuración actualizada correctamente")); |
84 | 84 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true)); |
85 | - } else { |
|
85 | + }else { |
|
86 | 86 | throw new \HttpException(_('Error al guardar la configuración, prueba a cambiar los permisos'), 403); |
87 | 87 | } |
88 | 88 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | * @route /admin/routes/show |
31 | 31 | * @label Servicio de rutas del sistema |
32 | 32 | * @visible false |
33 | - * @return mixed |
|
33 | + * @return string|null |
|
34 | 34 | */ |
35 | 35 | public function getRouting() |
36 | 36 | { |
@@ -55,7 +55,7 @@ |
||
55 | 55 | $router->simpatize(); |
56 | 56 | Security::getInstance()->setFlash("callback_message", _("Rutas generadas correctamente")); |
57 | 57 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true)); |
58 | - } catch (\Exception $e) { |
|
58 | + }catch (\Exception $e) { |
|
59 | 59 | Logger::log($e->getMessage(), LOG_ERR); |
60 | 60 | Security::getInstance()->setFlash("callback_message", _("Algo no ha salido bien, revisa los logs")); |
61 | 61 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true)); |
@@ -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; |
@@ -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 | { |
@@ -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 | /** |
@@ -39,13 +39,13 @@ 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 | 47 | $base_path = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl()); |
48 | - $return_path = (empty($name)) ? $base_path . '/' . $file_path : $name; |
|
48 | + $return_path = (empty($name)) ? $base_path.'/'.$file_path : $name; |
|
49 | 49 | return ($return) ? $return_path : ''; |
50 | 50 | } |
51 | 51 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $router = Router::getInstance(); |
63 | 63 | try { |
64 | 64 | return $router->getRoute($path, $absolute, $params); |
65 | - } catch (\Exception $e) { |
|
65 | + }catch (\Exception $e) { |
|
66 | 66 | return $router->getRoute('', $absolute, $params); |
67 | 67 | } |
68 | 68 | } |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | private static function putResourceContent($name, $filename_path, $base, $file_path) |
200 | 200 | { |
201 | 201 | $data = file_get_contents($filename_path); |
202 | - if (!empty($name)) file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
|
203 | - else file_put_contents($base . $file_path, $data); |
|
202 | + if (!empty($name)) file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data); |
|
203 | + else file_put_contents($base.$file_path, $data); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | if (file_exists($filename_path)) { |
219 | 219 | list($base, $html_base, $file_path) = AssetsParser::calculateAssetPath($string, $name, $return, $filename_path); |
220 | 220 | //Creamos el directorio si no existe |
221 | - GeneratorHelper::createDir($base . $html_base); |
|
221 | + GeneratorHelper::createDir($base.$html_base); |
|
222 | 222 | //Si se ha modificado |
223 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($filename_path)) { |
|
223 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($filename_path)) { |
|
224 | 224 | if ($html_base == 'css') { |
225 | 225 | self::processCssLines($filename_path); |
226 | 226 | } |