@@ -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 | { |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public static function getClassToCall($action) |
| 23 | 23 | { |
| 24 | 24 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
| 25 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
| 25 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
| 26 | 26 | $class = method_exists($actionClass, "getInstance") ? $actionClass::getInstance() : new $actionClass; |
| 27 | 27 | return $class; |
| 28 | 28 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $expr = preg_quote($expr, '/'); |
| 109 | 109 | $expr = str_replace('###', '(.*)', $expr); |
| 110 | 110 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
| 111 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
| 111 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
| 112 | 112 | return $matched; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
| 121 | 121 | { |
| 122 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
| 123 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
| 122 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
| 123 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
| 124 | 124 | $tpl_path = "templates"; |
| 125 | 125 | $public_path = "public"; |
| 126 | 126 | $model_path = "models"; |
@@ -130,13 +130,13 @@ discard block |
||
| 130 | 130 | $model_path = ucfirst($model_path); |
| 131 | 131 | } |
| 132 | 132 | if ($class->hasConstant("TPL")) { |
| 133 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
| 133 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
| 134 | 134 | } |
| 135 | 135 | return [ |
| 136 | 136 | 'base' => $path, |
| 137 | - 'template' => $path . $tpl_path, |
|
| 138 | - 'model' => $path . $model_path, |
|
| 139 | - 'public' => $path . $public_path, |
|
| 137 | + 'template' => $path.$tpl_path, |
|
| 138 | + 'model' => $path.$model_path, |
|
| 139 | + 'public' => $path.$public_path, |
|
| 140 | 140 | ]; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | foreach ($parameters as $param) { |
| 161 | 161 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
| 162 | 162 | $params[$param->getName()] = $param->getDefaultValue(); |
| 163 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
| 164 | - } elseif(!$param->isOptional()) { |
|
| 163 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
| 164 | + } elseif (!$param->isOptional()) { |
|
| 165 | 165 | $requirements[] = $param->getName(); |
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | - } else { |
|
| 168 | + }else { |
|
| 169 | 169 | $default = $regex; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $default = str_replace('{__DOMAIN__}', $module, $default); |
| 248 | 248 | $httpMethod = self::extractReflectionHttpMethod($docComments); |
| 249 | 249 | $label = self::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
| 250 | - $route = $httpMethod . "#|#" . $regex; |
|
| 250 | + $route = $httpMethod."#|#".$regex; |
|
| 251 | 251 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
| 252 | 252 | $info = [ |
| 253 | 253 | 'method' => $method->getName(), |
@@ -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]; |
@@ -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 | { |
@@ -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 | /** |