@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | protected function getTmpAttribute($node = null) |
115 | 115 | { |
116 | 116 | $tmp = []; |
117 | - if(null !== $node) { |
|
117 | + if (null !== $node) { |
|
118 | 118 | $tmp = $node->getAttribute('value'); |
119 | 119 | if (!is_array($tmp)) { |
120 | 120 | $tmp = [$tmp]; |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | $tmp = []; |
137 | 137 | if (null === $node) { |
138 | 138 | $node = $value; |
139 | - } else { |
|
139 | + }else { |
|
140 | 140 | $tmp = $this->getTmpAttribute($node); |
141 | 141 | } |
142 | - if(null !== $node) { |
|
142 | + if (null !== $node) { |
|
143 | 143 | $tmp[] = $value->getAttribute('value'); |
144 | 144 | } |
145 | 145 | return [$tmp, $node]; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $dump = ''; |
115 | 115 | try { |
116 | 116 | $dump = $this->tpl->render($tpl, $vars); |
117 | - } catch (\Exception $e) { |
|
117 | + }catch (\Exception $e) { |
|
118 | 118 | Logger::log($e->getMessage(), LOG_ERR); |
119 | 119 | } |
120 | 120 | return $dump; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function regenerateTemplates() |
142 | 142 | { |
143 | 143 | $this->generateTemplatesCache(); |
144 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
144 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
145 | 145 | $translations = []; |
146 | 146 | if (is_array($domains)) { |
147 | 147 | $translations = $this->parsePathTranslations($domains); |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | // force compilation |
164 | 164 | if ($file->isFile()) { |
165 | 165 | try { |
166 | - $this->tpl->load(str_replace($tplDir . '/', '', $file)); |
|
167 | - } catch (\Exception $e) { |
|
166 | + $this->tpl->load(str_replace($tplDir.'/', '', $file)); |
|
167 | + }catch (\Exception $e) { |
|
168 | 168 | Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]); |
169 | 169 | } |
170 | 170 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | 'getFlash' => TemplateFunctions::GET_FLASH_FUNCTION, |
226 | 226 | 'getQuery' => TemplateFunctions::GET_QUERY_FUNCTION, |
227 | 227 | ]; |
228 | - foreach($functions as $name => $function) { |
|
228 | + foreach ($functions as $name => $function) { |
|
229 | 229 | $this->addTemplateFunction($name, $function); |
230 | 230 | } |
231 | 231 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | private function loadDomains() |
246 | 246 | { |
247 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
247 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
248 | 248 | if (null !== $domains) { |
249 | 249 | foreach ($domains as $domain => $paths) { |
250 | 250 | $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain)); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | { |
260 | 260 | $loader = new \Twig_Loader_Filesystem(GeneratorHelper::getTemplatePath()); |
261 | 261 | $this->tpl = new \Twig_Environment($loader, array( |
262 | - 'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig', |
|
262 | + 'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig', |
|
263 | 263 | 'debug' => (bool)$this->debug, |
264 | 264 | 'auto_reload' => Config::getParam('twig.autoreload', TRUE), |
265 | 265 | )); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | $routes = []; |
33 | 33 | foreach ($systemRoutes as $params) { |
34 | - if(isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) { |
|
34 | + if (isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) { |
|
35 | 35 | $module = strtoupper($params['module']); |
36 | 36 | $mode = $params['visible'] ? 'visible' : 'hidden'; |
37 | 37 | $routes[$module][$mode][] = [ |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | ]; |
42 | 42 | } |
43 | 43 | } |
44 | - foreach($routes as $module => &$route) { |
|
45 | - if(array_key_exists('visible', $route)) { |
|
44 | + foreach ($routes as $module => &$route) { |
|
45 | + if (array_key_exists('visible', $route)) { |
|
46 | 46 | uasort($route['visible'], '\PSFS\base\types\helpers\AdminHelper::sortByLabel'); |
47 | 47 | } |
48 | - if(array_key_exists('hidden', $route)) { |
|
48 | + if (array_key_exists('hidden', $route)) { |
|
49 | 49 | uasort($route['hidden'], '\PSFS\base\types\helpers\AdminHelper::sortByLabel'); |
50 | 50 | } |
51 | 51 | } |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function json($response, $statusCode = 200) |
25 | 25 | { |
26 | - if(Config::getParam('profiling.enable')) { |
|
27 | - if(is_array($response)) { |
|
26 | + if (Config::getParam('profiling.enable')) { |
|
27 | + if (is_array($response)) { |
|
28 | 28 | $response['profiling'] = Inspector::getStats(); |
29 | - } elseif($response instanceof JsonResponse) { |
|
29 | + } elseif ($response instanceof JsonResponse) { |
|
30 | 30 | $response = ProfilingJsonResponse::createFromPrevious($response, Inspector::getStats()); |
31 | 31 | } |
32 | 32 | } |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | $this->decodeJsonResponse($response); |
35 | 35 | |
36 | 36 | $mask = JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING; |
37 | - if(Config::getParam('output.json.strict_numbers')) { |
|
37 | + if (Config::getParam('output.json.strict_numbers')) { |
|
38 | 38 | $mask = JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING | JSON_NUMERIC_CHECK; |
39 | 39 | } |
40 | 40 | |
41 | 41 | $data = json_encode($response, $mask); |
42 | - if(Config::getParam('angular.protection', false)) { |
|
43 | - $data = ")]}',\n" . $data; |
|
42 | + if (Config::getParam('angular.protection', false)) { |
|
43 | + $data = ")]}',\n".$data; |
|
44 | 44 | } |
45 | 45 | $this->setStatus($statusCode); |
46 | 46 | ResponseHelper::setDebugHeaders([]); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function generateModule() |
36 | 36 | { |
37 | - Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri()); |
|
37 | + Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri()); |
|
38 | 38 | /* @var $form \PSFS\base\config\ConfigForm */ |
39 | 39 | $form = new ModuleForm(); |
40 | 40 | $form->build(); |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | $this->gen->createStructureModule($module, false, $type, $apiClass); |
66 | 66 | Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, t("Módulo %s generado correctamente"))); |
67 | 67 | // Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true)); |
68 | - } catch (\Exception $e) { |
|
69 | - Logger::log($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]"); |
|
68 | + }catch (\Exception $e) { |
|
69 | + Logger::log($e->getMessage()." [".$e->getFile().":".$e->getLine()."]"); |
|
70 | 70 | Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage())); |
71 | 71 | } |
72 | 72 | } |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | |
78 | 78 | public static function createRoot($path = WEB_DIR, OutputInterface $output = null) { |
79 | 79 | |
80 | - if(null === $output) { |
|
80 | + if (null === $output) { |
|
81 | 81 | $output = new ConsoleOutput(); |
82 | 82 | } |
83 | 83 | |
84 | 84 | GeneratorHelper::createDir($path); |
85 | 85 | $paths = array("js", "css", "img", "media", "font"); |
86 | 86 | foreach ($paths as $htmlPath) { |
87 | - GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath); |
|
87 | + GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | // Generates the root needed files |
@@ -96,18 +96,18 @@ discard block |
||
96 | 96 | 'robots' => 'robots.txt', |
97 | 97 | ]; |
98 | 98 | foreach ($files as $templates => $filename) { |
99 | - $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig'); |
|
100 | - if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) { |
|
101 | - $output->writeln('Can\t create the file ' . $filename); |
|
102 | - } else { |
|
103 | - $output->writeln($filename . ' created successfully'); |
|
99 | + $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig'); |
|
100 | + if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) { |
|
101 | + $output->writeln('Can\t create the file '.$filename); |
|
102 | + }else { |
|
103 | + $output->writeln($filename.' created successfully'); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | 107 | //Export base locale translations |
108 | - if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) { |
|
109 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
110 | - GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
108 | + if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) { |
|
109 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
110 | + GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | 114 | \ No newline at end of file |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function staticAdminLogon($route = null) |
40 | 40 | { |
41 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
41 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
42 | 42 | if ('login' !== Config::getParam('admin.login')) { |
43 | 43 | return AdminServices::getInstance()->setAdminHeaders(); |
44 | - } else { |
|
44 | + }else { |
|
45 | 45 | $form = new LoginForm(); |
46 | 46 | $form->setData(array("route" => $route)); |
47 | 47 | $form->build(); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | 'form' => $form, |
52 | 52 | )); |
53 | 53 | } |
54 | - } else { |
|
54 | + }else { |
|
55 | 55 | return UserController::showAdminManager(); |
56 | 56 | } |
57 | 57 | } |
@@ -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,10 +53,10 @@ 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(json_encode($doc), 'application/json', 'swagger.json'); |
58 | 58 | } |
59 | - if($type === ApiController::HTML_DOC) { |
|
59 | + if ($type === ApiController::HTML_DOC) { |
|
60 | 60 | return $this->render('documentation.html.twig', ["data" => json_encode($doc)]); |
61 | 61 | } |
62 | 62 | return $this->json($doc, 200); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $this->setStatusCode(Template::STATUS_OK); |
122 | 122 | break; |
123 | 123 | default: |
124 | - $this->setStatusCode('HTTP/1.0 ' .($status ?: 200)); |
|
124 | + $this->setStatusCode('HTTP/1.0 '.($status ?: 200)); |
|
125 | 125 | break; |
126 | 126 | } |
127 | 127 | return $this; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
140 | 140 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
141 | 141 | ResponseHelper::setCookieHeaders($cookies); |
142 | - header('Content-type: ' . $contentType); |
|
142 | + header('Content-type: '.$contentType); |
|
143 | 143 | |
144 | 144 | } |
145 | 145 | |
@@ -152,20 +152,20 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function output($output = '', $contentType = 'text/html', array $cookies = array()) |
154 | 154 | { |
155 | - if(!self::isTest()) { |
|
155 | + if (!self::isTest()) { |
|
156 | 156 | Logger::log('Start output response'); |
157 | 157 | ob_start(); |
158 | 158 | $this->setReponseHeaders($contentType, $cookies); |
159 | - header('Content-length: ' . strlen($output)); |
|
160 | - header('CRC: ' . crc32($output)); |
|
159 | + header('Content-length: '.strlen($output)); |
|
160 | + header('CRC: '.crc32($output)); |
|
161 | 161 | |
162 | 162 | $needCache = Cache::needCache(); |
163 | 163 | $cache = Cache::getInstance(); |
164 | 164 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
165 | 165 | if (null !== $cacheDataName && false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) { |
166 | 166 | Logger::log('Saving output response into cache'); |
167 | - $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
168 | - $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', headers_list(), Cache::JSON); |
|
167 | + $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
168 | + $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', headers_list(), Cache::JSON); |
|
169 | 169 | } elseif (Request::getInstance()->getMethod() !== 'GET') { |
170 | 170 | $cache->flushCache(); |
171 | 171 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | ob_end_clean(); |
176 | 176 | Logger::log('End output response'); |
177 | 177 | $this->closeRender(); |
178 | - } else { |
|
178 | + }else { |
|
179 | 179 | return $output; |
180 | 180 | } |
181 | 181 | } |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | Logger::log('Close template render'); |
189 | 189 | $uri = Request::requestUri(); |
190 | 190 | Security::getInstance()->setSessionKey('lastRequest', array( |
191 | - 'url' => Request::getInstance()->getRootUrl() . $uri, |
|
191 | + 'url' => Request::getInstance()->getRootUrl().$uri, |
|
192 | 192 | 'ts' => microtime(true), |
193 | 193 | )); |
194 | 194 | Security::getInstance()->updateSession(); |
195 | - Logger::log('End request: ' . $uri, LOG_INFO); |
|
195 | + Logger::log('End request: '.$uri, LOG_INFO); |
|
196 | 196 | exit; |
197 | 197 | } |
198 | 198 | |
@@ -230,17 +230,17 @@ discard block |
||
230 | 230 | ///////////////////////////////////////////////////////////// |
231 | 231 | // Date in the past sets the value to already have been expired. |
232 | 232 | header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); |
233 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
233 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
234 | 234 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
235 | 235 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
236 | 236 | header('Pragma: no-cache'); |
237 | 237 | header('Expires: 0'); |
238 | 238 | header('Content-Transfer-Encoding: binary'); |
239 | - header('Content-type: ' . $content); |
|
240 | - header('Content-length: ' . strlen($data)); |
|
241 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
239 | + header('Content-type: '.$content); |
|
240 | + header('Content-length: '.strlen($data)); |
|
241 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
242 | 242 | header('Access-Control-Expose-Headers: Filename'); |
243 | - header('Filename: ' . $filename); |
|
243 | + header('Filename: '.$filename); |
|
244 | 244 | echo $data; |
245 | 245 | ob_flush(); |
246 | 246 | ob_end_clean(); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | unset($_SERVER["PHP_AUTH_USER"]); |
41 | 41 | unset($_SERVER["PHP_AUTH_PW"]); |
42 | 42 | header_remove("Authorization"); |
43 | - } elseif(!self::isTest()) { |
|
43 | + } elseif (!self::isTest()) { |
|
44 | 44 | header('Authorization:'); |
45 | 45 | } |
46 | 46 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | Logger::log('Adding debug headers to render response'); |
69 | 69 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
70 | 70 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
71 | - header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
72 | - header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
73 | - header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
71 | + header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
72 | + header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
73 | + header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | return $vars; |