@@ -34,7 +34,7 @@ |
||
34 | 34 | */ |
35 | 35 | public static function dropInstance() { |
36 | 36 | $class = get_called_class(); |
37 | - if(isset(self::$instance[$class])) { |
|
37 | + if (isset(self::$instance[$class])) { |
|
38 | 38 | self::$instance[$class] = null; |
39 | 39 | } |
40 | 40 | } |
@@ -212,7 +212,9 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function redirect($url = null) |
214 | 214 | { |
215 | - if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
|
215 | + if (null === $url) { |
|
216 | + $url = $this->getServer('HTTP_ORIGIN'); |
|
217 | + } |
|
216 | 218 | ob_start(); |
217 | 219 | header('Location: ' . $url); |
218 | 220 | ob_end_clean(); |
@@ -259,7 +261,9 @@ discard block |
||
259 | 261 | $host = $this->getServerName(); |
260 | 262 | $protocol = $protocol ? $this->getProtocol() : ''; |
261 | 263 | $url = ''; |
262 | - if (!empty($host) && !empty($protocol)) $url = $protocol . $host; |
|
264 | + if (!empty($host) && !empty($protocol)) { |
|
265 | + $url = $protocol . $host; |
|
266 | + } |
|
263 | 267 | if (!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
264 | 268 | $url .= ':' . $this->getServer('SERVER_PORT'); |
265 | 269 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Método que verifica si existe una cabecera concreta |
57 | - * @param $header |
|
57 | + * @param string $header |
|
58 | 58 | * |
59 | 59 | * @return boolean |
60 | 60 | */ |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @param string $queryParams |
177 | 177 | * |
178 | - * @return mixed |
|
178 | + * @return string |
|
179 | 179 | */ |
180 | 180 | public function getQuery($queryParams) |
181 | 181 | { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $this->data = $_REQUEST or []; |
28 | 28 | $this->query = $_GET or []; |
29 | 29 | $contentType = $this->getHeader('Accept'); |
30 | - if(null === $contentType) { |
|
30 | + if (null === $contentType) { |
|
31 | 31 | $contentType = $this->getServer('Accept') ?: 'text/html'; |
32 | 32 | } |
33 | 33 | if (preg_match('/application\/json/i', $contentType)) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public static function header($name, $default = null) |
119 | 119 | { |
120 | - return self::getInstance()->getHeader($name, $default); |
|
120 | + return self::getInstance()->getHeader($name, $default); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | { |
221 | 221 | if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
222 | 222 | ob_start(); |
223 | - header('Location: ' . $url); |
|
223 | + header('Location: '.$url); |
|
224 | 224 | ob_end_clean(); |
225 | 225 | Security::getInstance()->updateSession(); |
226 | 226 | exit(_("Redireccionando...")); |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | $host = $this->getServerName(); |
266 | 266 | $protocol = $protocol ? $this->getProtocol() : ''; |
267 | 267 | $url = ''; |
268 | - if (!empty($host) && !empty($protocol)) $url = $protocol . $host; |
|
268 | + if (!empty($host) && !empty($protocol)) $url = $protocol.$host; |
|
269 | 269 | if (!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
270 | - $url .= ':' . $this->getServer('SERVER_PORT'); |
|
270 | + $url .= ':'.$this->getServer('SERVER_PORT'); |
|
271 | 271 | } |
272 | 272 | return $url; |
273 | 273 | } |
@@ -69,16 +69,16 @@ |
||
69 | 69 | if (!Request::getInstance()->isFile()) { |
70 | 70 | return $this->router->execute($this->actualUri); |
71 | 71 | } |
72 | - } else { |
|
72 | + }else { |
|
73 | 73 | return ConfigController::getInstance()->config(); |
74 | 74 | } |
75 | - } catch (AdminCredentialsException $a) { |
|
75 | + }catch (AdminCredentialsException $a) { |
|
76 | 76 | return UserController::showAdminManager(); |
77 | - } catch (SecurityException $s) { |
|
77 | + }catch (SecurityException $s) { |
|
78 | 78 | return $this->security->notAuthorized($this->actualUri); |
79 | - } catch (RouterException $r) { |
|
79 | + }catch (RouterException $r) { |
|
80 | 80 | return $this->router->httpNotFound($r); |
81 | - } catch (\Exception $e) { |
|
81 | + }catch (\Exception $e) { |
|
82 | 82 | return $this->dumpException($e); |
83 | 83 | } |
84 | 84 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | class FileHelper { |
9 | 9 | /** |
10 | - * @param mixed $data |
|
10 | + * @param string $data |
|
11 | 11 | * @param string $path |
12 | 12 | * @return int |
13 | 13 | */ |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @param string $path |
20 | - * @return mixed|bool |
|
20 | + * @return string|false |
|
21 | 21 | */ |
22 | 22 | public static function readFile($path) { |
23 | 23 | $data = false; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public static function readFile($path) { |
23 | 23 | $data = false; |
24 | - if(file_exists($path)) { |
|
24 | + if (file_exists($path)) { |
|
25 | 25 | $data = file_get_contents($path); |
26 | 26 | } |
27 | 27 | return $data; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return string |
35 | 35 | */ |
36 | 36 | public static function generateHashFilename($verb, $slug, array $query = []) { |
37 | - return sha1($verb . " " . $slug . " " . http_build_query($query)); |
|
37 | + return sha1($verb." ".$slug." ".http_build_query($query)); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public static function generateCachePath(array $action, array $query = []) { |
46 | 46 | $class = GeneratorHelper::extractClassFromNamespace($action['class']); |
47 | 47 | $filename = self::generateHashFilename($action["http"], $action["slug"], $query); |
48 | - $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2); |
|
49 | - return $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR; |
|
48 | + $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2); |
|
49 | + return $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -202,7 +202,7 @@ |
||
202 | 202 | |
203 | 203 | /** |
204 | 204 | * Método que fuerza la descarga de un fichero |
205 | - * @param $data |
|
205 | + * @param string $data |
|
206 | 206 | * @param string $content |
207 | 207 | * @param string $filename |
208 | 208 | * @return mixed |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $this->setStatusCode(Template::STATUS_OK); |
121 | 121 | break; |
122 | 122 | default: |
123 | - $this->setStatusCode('HTTP/1.0 ' . $status ?: 200); |
|
123 | + $this->setStatusCode('HTTP/1.0 '.$status ?: 200); |
|
124 | 124 | break; |
125 | 125 | } |
126 | 126 | return $this; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
139 | 139 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
140 | 140 | ResponseHelper::setCookieHeaders($cookies); |
141 | - header('Content-type: ' . $contentType); |
|
141 | + header('Content-type: '.$contentType); |
|
142 | 142 | |
143 | 143 | } |
144 | 144 | |
@@ -154,15 +154,15 @@ discard block |
||
154 | 154 | Logger::log('Start output response'); |
155 | 155 | ob_start(); |
156 | 156 | $this->setReponseHeaders($contentType, $cookies); |
157 | - header('Content-length: ' . strlen($output)); |
|
157 | + header('Content-length: '.strlen($output)); |
|
158 | 158 | |
159 | 159 | $needCache = Cache::needCache(); |
160 | 160 | if (false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) { |
161 | 161 | $cache = Cache::getInstance(); |
162 | 162 | Logger::log('Saving output response into cache'); |
163 | 163 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
164 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
165 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", headers_list(), Cache::JSON); |
|
164 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
165 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", headers_list(), Cache::JSON); |
|
166 | 166 | } |
167 | 167 | echo $output; |
168 | 168 | |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | Logger::log('Close template render'); |
181 | 181 | $uri = Request::requestUri(); |
182 | 182 | Security::getInstance()->setSessionKey("lastRequest", array( |
183 | - "url" => Request::getInstance()->getRootUrl() . $uri, |
|
183 | + "url" => Request::getInstance()->getRootUrl().$uri, |
|
184 | 184 | "ts" => microtime(true), |
185 | 185 | )); |
186 | 186 | Security::getInstance()->updateSession(); |
187 | - Logger::log('End request: ' . $uri, LOG_INFO); |
|
187 | + Logger::log('End request: '.$uri, LOG_INFO); |
|
188 | 188 | exit; |
189 | 189 | } |
190 | 190 | |
@@ -222,17 +222,17 @@ discard block |
||
222 | 222 | ///////////////////////////////////////////////////////////// |
223 | 223 | // Date in the past sets the value to already have been expired. |
224 | 224 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
225 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
225 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
226 | 226 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
227 | 227 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
228 | 228 | header("Pragma: no-cache"); |
229 | 229 | header("Expires: 0"); |
230 | 230 | header('Content-Transfer-Encoding: binary'); |
231 | - header("Content-type: " . $content); |
|
232 | - header("Content-length: " . strlen($data)); |
|
233 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
231 | + header("Content-type: ".$content); |
|
232 | + header("Content-length: ".strlen($data)); |
|
233 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
234 | 234 | header("Access-Control-Expose-Headers: Filename"); |
235 | - header("Filename: " . $filename); |
|
235 | + header("Filename: ".$filename); |
|
236 | 236 | echo $data; |
237 | 237 | ob_flush(); |
238 | 238 | ob_end_clean(); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $download = $this->getRequest()->get('download') ?: false; |
34 | 34 | |
35 | 35 | $module = $this->srv->getModules($domain); |
36 | - if(empty($module)) { |
|
36 | + if (empty($module)) { |
|
37 | 37 | return Router::getInstance()->httpNotFound(null, true); |
38 | 38 | } |
39 | 39 | switch (strtolower($type)) { |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | ini_restore('max_execution_time'); |
54 | 54 | ini_restore('memory_limit'); |
55 | 55 | |
56 | - if($download && $type === ApiController::SWAGGER_DOC) { |
|
56 | + if ($download && $type === ApiController::SWAGGER_DOC) { |
|
57 | 57 | return $this->download(\GuzzleHttp\json_encode($doc), 'application/json', 'swagger.json'); |
58 | - } elseif($type === ApiController::HTML_DOC) { |
|
58 | + } elseif ($type === ApiController::HTML_DOC) { |
|
59 | 59 | return $this->render('documentation.html.twig', ["data" => json_encode($doc)]); |
60 | - } else { |
|
60 | + }else { |
|
61 | 61 | return $this->json($doc, 200); |
62 | 62 | } |
63 | 63 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $dump = ''; |
112 | 112 | try { |
113 | 113 | $dump = $this->tpl->render($tpl, $vars); |
114 | - } catch (\Exception $e) { |
|
114 | + }catch (\Exception $e) { |
|
115 | 115 | Logger::log($e->getMessage(), LOG_ERR); |
116 | 116 | } |
117 | 117 | return $dump; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | public function regenerateTemplates() |
139 | 139 | { |
140 | 140 | $this->generateTemplatesCache(); |
141 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true); |
|
141 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true); |
|
142 | 142 | $translations = []; |
143 | 143 | if (is_array($domains)) { |
144 | 144 | $translations = $this->parsePathTranslations($domains); |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | // force compilation |
161 | 161 | if ($file->isFile()) { |
162 | 162 | try { |
163 | - $this->tpl->load(str_replace($tplDir . '/', '', $file)); |
|
164 | - } catch (\Exception $e) { |
|
163 | + $this->tpl->load(str_replace($tplDir.'/', '', $file)); |
|
164 | + }catch (\Exception $e) { |
|
165 | 165 | Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]); |
166 | 166 | } |
167 | 167 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | 'existsFlash' => TemplateFunctions::EXISTS_FLASH_FUNCTION, |
222 | 222 | 'getFlash' => TemplateFunctions::GET_FLASH_FUNCTION, |
223 | 223 | ]; |
224 | - foreach($functions as $name => $function) { |
|
224 | + foreach ($functions as $name => $function) { |
|
225 | 225 | $this->addTemplateFunction($name, $function); |
226 | 226 | } |
227 | 227 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | private function loadDomains() |
242 | 242 | { |
243 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
243 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
244 | 244 | if (null !== $domains) { |
245 | 245 | foreach ($domains as $domain => $paths) { |
246 | 246 | $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain)); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | { |
256 | 256 | $loader = new \Twig_Loader_Filesystem(GeneratorHelper::getTemplatePath()); |
257 | 257 | $this->tpl = new \Twig_Environment($loader, array( |
258 | - 'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig', |
|
258 | + 'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig', |
|
259 | 259 | 'debug' => (bool)$this->debug, |
260 | 260 | 'auto_reload' => Config::getParam('twig.autoreload', TRUE), |
261 | 261 | )); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $translations = array(); |
25 | 25 | if (file_exists($absoluteTranslationFileName)) { |
26 | 26 | @include($absoluteTranslationFileName); |
27 | - } else { |
|
27 | + }else { |
|
28 | 28 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
29 | 29 | } |
30 | 30 | |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public static function setLocale() { |
38 | 38 | $locale = Config::getParam("default.language", 'es_ES'); |
39 | - Logger::log('Set locale to project [' . $locale . ']'); |
|
39 | + Logger::log('Set locale to project ['.$locale.']'); |
|
40 | 40 | // Load translations |
41 | - putenv("LC_ALL=" . $locale); |
|
41 | + putenv("LC_ALL=".$locale); |
|
42 | 42 | setlocale(LC_ALL, $locale); |
43 | 43 | // Load the locale path |
44 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
45 | - Logger::log('Set locale dir ' . $locale_path); |
|
44 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
45 | + Logger::log('Set locale dir '.$locale_path); |
|
46 | 46 | GeneratorHelper::createDir($locale_path); |
47 | 47 | bindtextdomain('translations', $locale_path); |
48 | 48 | textdomain('translations'); |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | * @return string |
55 | 55 | */ |
56 | 56 | public static function utf8Encode($data) { |
57 | - if(is_array($data)) { |
|
58 | - foreach($data as $key => &$field) { |
|
57 | + if (is_array($data)) { |
|
58 | + foreach ($data as $key => &$field) { |
|
59 | 59 | $field = self::utf8Encode($field); |
60 | 60 | } |
61 | - } elseif(is_object($data)) { |
|
61 | + } elseif (is_object($data)) { |
|
62 | 62 | $properties = get_class_vars($data); |
63 | - foreach($properties as $property => $value) { |
|
63 | + foreach ($properties as $property => $value) { |
|
64 | 64 | $data->$property = self::utf8Encode($data->$property); |
65 | 65 | } |
66 | 66 | |
67 | - } elseif(is_string($data)) { |
|
67 | + } elseif (is_string($data)) { |
|
68 | 68 | $data = utf8_encode($data); |
69 | 69 | } |
70 | 70 | return $data; |
@@ -19,12 +19,12 @@ |
||
19 | 19 | */ |
20 | 20 | public function json($response, $statusCode = 200) |
21 | 21 | { |
22 | - if(Config::getParam('json.encodeUTF8', false)) { |
|
22 | + if (Config::getParam('json.encodeUTF8', false)) { |
|
23 | 23 | $response = I18nHelper::utf8Encode($response); |
24 | 24 | } |
25 | 25 | $data = json_encode($response, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); |
26 | - if(Config::getParam('angular.protection', false)) { |
|
27 | - $data = ")]}',\n" . $data; |
|
26 | + if (Config::getParam('angular.protection', false)) { |
|
27 | + $data = ")]}',\n".$data; |
|
28 | 28 | } |
29 | 29 | $this->setStatus($statusCode); |
30 | 30 | return $this->output($data, "application/json"); |