@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | use PSFS\base\types\helpers\GeneratorHelper; |
14 | 14 | use PSFS\base\types\helpers\Inspector; |
15 | 15 | |
16 | -defined('CSS_SRI_FILENAME') or define('CSS_SRI_FILENAME', CACHE_DIR . DIRECTORY_SEPARATOR . 'css.sri.json'); |
|
17 | -defined('JS_SRI_FILENAME') or define('JS_SRI_FILENAME', CACHE_DIR . DIRECTORY_SEPARATOR . 'js.sri.json'); |
|
16 | +defined('CSS_SRI_FILENAME') or define('CSS_SRI_FILENAME', CACHE_DIR.DIRECTORY_SEPARATOR.'css.sri.json'); |
|
17 | +defined('JS_SRI_FILENAME') or define('JS_SRI_FILENAME', CACHE_DIR.DIRECTORY_SEPARATOR.'js.sri.json'); |
|
18 | 18 | /** |
19 | 19 | * Class AssetsParser |
20 | 20 | * @package PSFS\base\extension |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | /** @var Cache $cache */ |
67 | 67 | $cache = Cache::getInstance(); |
68 | 68 | $this->sri = $cache->getDataFromFile($this->sriFilename, Cache::JSON, true); |
69 | - if(empty($this->sri)) { |
|
69 | + if (empty($this->sri)) { |
|
70 | 70 | $this->sri = []; |
71 | 71 | } |
72 | 72 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function __construct($type = 'js') |
80 | 80 | { |
81 | 81 | $this->type = $type; |
82 | - $this->path = WEB_DIR . DIRECTORY_SEPARATOR; |
|
82 | + $this->path = WEB_DIR.DIRECTORY_SEPARATOR; |
|
83 | 83 | $this->domains = Template::getDomains(true); |
84 | 84 | $this->cdnPath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl()); |
85 | 85 | } |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function addFile($filename) |
94 | 94 | { |
95 | - if (file_exists($this->path . $filename) && preg_match('/\.' . $this->type . '$/i', $filename)) { |
|
95 | + if (file_exists($this->path.$filename) && preg_match('/\.'.$this->type.'$/i', $filename)) { |
|
96 | 96 | $this->files[] = $filename; |
97 | 97 | } elseif (!empty($this->domains)) { |
98 | 98 | foreach ($this->domains as $domain => $paths) { |
99 | 99 | $domainFilename = str_replace($domain, $paths["public"], $filename); |
100 | - if (file_exists($domainFilename) && preg_match('/\.' . $this->type . '$/i', $domainFilename)) { |
|
100 | + if (file_exists($domainFilename) && preg_match('/\.'.$this->type.'$/i', $domainFilename)) { |
|
101 | 101 | $this->files[] = $domainFilename; |
102 | 102 | } |
103 | 103 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | public function setHash($hash) |
115 | 115 | { |
116 | 116 | $cache = Config::getParam('cache.var', ''); |
117 | - $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache; |
|
117 | + $this->hash = $hash.(strlen($cache) ? '.' : '').$cache; |
|
118 | 118 | return $this; |
119 | 119 | } |
120 | 120 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $sourceFile = explode("?", $sourceFile); |
178 | 178 | $sourceFile = $sourceFile[0]; |
179 | 179 | } |
180 | - $orig = realpath(dirname($filenamePath) . DIRECTORY_SEPARATOR . $sourceFile); |
|
180 | + $orig = realpath(dirname($filenamePath).DIRECTORY_SEPARATOR.$sourceFile); |
|
181 | 181 | return $orig; |
182 | 182 | } |
183 | 183 | |
@@ -194,15 +194,15 @@ discard block |
||
194 | 194 | if (preg_match_all('#url\((.*?)\)#', $line, $urls, PREG_SET_ORDER)) { |
195 | 195 | foreach ($urls as $source) { |
196 | 196 | $orig = self::calculateResourcePathname($filenamePath, $source); |
197 | - if(!empty($orig)) { |
|
197 | + if (!empty($orig)) { |
|
198 | 198 | $orig_part = preg_split("/Public/i", $orig); |
199 | - $dest = WEB_DIR . $orig_part[1]; |
|
199 | + $dest = WEB_DIR.$orig_part[1]; |
|
200 | 200 | GeneratorHelper::createDir(dirname($dest)); |
201 | 201 | if (@copy($orig, $dest) === false) { |
202 | - throw new ConfigException("Can't copy " . $orig . " to " . $dest); |
|
202 | + throw new ConfigException("Can't copy ".$orig." to ".$dest); |
|
203 | 203 | } |
204 | - } else { |
|
205 | - Logger::log($filenamePath . ' has an empty origin with the url ' . $source, LOG_WARNING); |
|
204 | + }else { |
|
205 | + Logger::log($filenamePath.' has an empty origin with the url '.$source, LOG_WARNING); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | } |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | * @throws \PSFS\base\exception\GeneratorException |
216 | 216 | */ |
217 | 217 | protected function getSriHash($hash, $type = 'js') { |
218 | - if(array_key_exists($hash, $this->sri)) { |
|
218 | + if (array_key_exists($hash, $this->sri)) { |
|
219 | 219 | $sriHash = $this->sri[$hash]; |
220 | - } else { |
|
221 | - Inspector::stats('[SRITrait] Generating SRI for ' . $hash, Inspector::SCOPE_DEBUG); |
|
222 | - $filename = WEB_DIR . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $hash . '.' . $type; |
|
220 | + }else { |
|
221 | + Inspector::stats('[SRITrait] Generating SRI for '.$hash, Inspector::SCOPE_DEBUG); |
|
222 | + $filename = WEB_DIR.DIRECTORY_SEPARATOR.$type.DIRECTORY_SEPARATOR.$hash.'.'.$type; |
|
223 | 223 | $sriHash = base64_encode(hash("sha384", file_get_contents($filename), true)); |
224 | 224 | $this->sri[$hash] = $sriHash; |
225 | 225 | Cache::getInstance()->storeData($this->sriFilename, $this->sri, Cache::JSON, true); |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | protected function compileCss($basePath, $hash) |
31 | 31 | { |
32 | 32 | $debug = Config::getParam('debug'); |
33 | - $base = $basePath . "css" . DIRECTORY_SEPARATOR; |
|
34 | - if ($debug || !file_exists($base . $hash . ".css")) { |
|
33 | + $base = $basePath."css".DIRECTORY_SEPARATOR; |
|
34 | + if ($debug || !file_exists($base.$hash.".css")) { |
|
35 | 35 | $data = ''; |
36 | 36 | if (0 < count($this->files)) { |
37 | 37 | $minifier = new CSS(); |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | $data = $this->processCssLine($file, $base, $data, $hash); |
40 | 40 | } |
41 | 41 | } |
42 | - if($debug) { |
|
43 | - AssetsHelper::storeContents($base . $hash . ".css", $data); |
|
44 | - } else { |
|
42 | + if ($debug) { |
|
43 | + AssetsHelper::storeContents($base.$hash.".css", $data); |
|
44 | + }else { |
|
45 | 45 | $minifier = new CSS(); |
46 | 46 | $minifier->add($data); |
47 | 47 | ini_set('max_execution_time', -1); |
48 | 48 | ini_set('memory_limit', -1); |
49 | 49 | GeneratorHelper::createDir($base); |
50 | - $minifier->minify($base . $hash . ".css"); |
|
50 | + $minifier->minify($base.$hash.".css"); |
|
51 | 51 | } |
52 | 52 | unset($minifier); |
53 | 53 | } |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | if (file_exists($file)) { |
68 | 68 | $debug = Config::getParam('debug'); |
69 | 69 | $pathParts = explode("/", $file); |
70 | - $filePath = $this->hash . "_" . $pathParts[count($pathParts) - 1]; |
|
71 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file) || $debug) { |
|
70 | + $filePath = $this->hash."_".$pathParts[count($pathParts) - 1]; |
|
71 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file) || $debug) { |
|
72 | 72 | //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados |
73 | - if (file_exists($base . $hash . ".css") && @unlink($base . $hash . ".css") === false) { |
|
74 | - throw new ConfigException("Can't unlink file " . $base . $hash . ".css"); |
|
73 | + if (file_exists($base.$hash.".css") && @unlink($base.$hash.".css") === false) { |
|
74 | + throw new ConfigException("Can't unlink file ".$base.$hash.".css"); |
|
75 | 75 | } |
76 | 76 | $this->loopCssLines($file); |
77 | 77 | } |
78 | 78 | if ($debug) { |
79 | 79 | $data = file_get_contents($file); |
80 | - AssetsHelper::storeContents($base . $filePath, $data); |
|
81 | - } else { |
|
80 | + AssetsHelper::storeContents($base.$filePath, $data); |
|
81 | + }else { |
|
82 | 82 | $data .= file_get_contents($file); |
83 | 83 | } |
84 | - $this->compiledFiles[] = "/css/" . $filePath; |
|
84 | + $this->compiledFiles[] = "/css/".$filePath; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | return $data; |
@@ -113,25 +113,25 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function extractCssResources($source, $file) |
115 | 115 | { |
116 | - Inspector::stats('[CssTrait] Start collecting resources from ' . $file, Inspector::SCOPE_DEBUG); |
|
116 | + Inspector::stats('[CssTrait] Start collecting resources from '.$file, Inspector::SCOPE_DEBUG); |
|
117 | 117 | $sourceFile = AssetsHelper::extractSourceFilename($source); |
118 | - $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $sourceFile); |
|
118 | + $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$sourceFile); |
|
119 | 119 | $origPart = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig); |
120 | 120 | try { |
121 | 121 | if (count($source) > 1 && array_key_exists(1, $origPart)) { |
122 | - $dest = $this->path . $origPart[1]; |
|
122 | + $dest = $this->path.$origPart[1]; |
|
123 | 123 | GeneratorHelper::createDir(dirname($dest)); |
124 | 124 | if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) { |
125 | 125 | if (@copy($orig, $dest) === FALSE) { |
126 | - throw new \RuntimeException('Can\' copy ' . $dest . ''); |
|
126 | + throw new \RuntimeException('Can\' copy '.$dest.''); |
|
127 | 127 | } |
128 | 128 | Logger::log("$orig copiado a $dest", LOG_INFO); |
129 | 129 | } |
130 | 130 | } |
131 | - } catch (\Exception $e) { |
|
131 | + }catch (\Exception $e) { |
|
132 | 132 | Logger::log($e->getMessage(), LOG_ERR); |
133 | 133 | } |
134 | - Inspector::stats('[CssTrait] End collecting resources from ' . $file, Inspector::SCOPE_DEBUG); |
|
134 | + Inspector::stats('[CssTrait] End collecting resources from '.$file, Inspector::SCOPE_DEBUG); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | foreach ($compiledFiles as $file) { |
147 | 147 | echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>"; |
148 | 148 | } |
149 | - } else { |
|
150 | - echo "\t\t<link href='" . $baseUrl . "/css/" . $hash . ".css' rel='stylesheet' " . |
|
149 | + }else { |
|
150 | + echo "\t\t<link href='".$baseUrl."/css/".$hash.".css' rel='stylesheet' ". |
|
151 | 151 | //"crossorigin='anonymous' integrity='sha384-" . $sri . "'>"; |
152 | 152 | "media='screen, print'>"; |
153 | 153 | } |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | // TODO check more en locales |
45 | 45 | if (strtolower($locale) === 'en') { |
46 | 46 | $locale = 'en_GB'; |
47 | - } else { |
|
48 | - $locale = $locale . '_' . strtoupper($locale); |
|
47 | + }else { |
|
48 | + $locale = $locale.'_'.strtoupper($locale); |
|
49 | 49 | } |
50 | 50 | $defaultLocales = explode(',', Config::getParam('i18n.locales', '')); |
51 | 51 | if (!in_array($locale, array_merge($defaultLocales, self::$langs))) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $translations = array(); |
65 | 65 | if (file_exists($absoluteFileName)) { |
66 | 66 | @include($absoluteFileName); |
67 | - } else { |
|
67 | + }else { |
|
68 | 68 | Cache::getInstance()->storeData($absoluteFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
69 | 69 | } |
70 | 70 | |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | public static function setLocale($default = null) |
80 | 80 | { |
81 | 81 | $locale = self::extractLocale($default); |
82 | - Inspector::stats('[i18NHelper] Set locale to project [' . $locale . ']', Inspector::SCOPE_DEBUG); |
|
82 | + Inspector::stats('[i18NHelper] Set locale to project ['.$locale.']', Inspector::SCOPE_DEBUG); |
|
83 | 83 | // Load translations |
84 | - putenv("LC_ALL=" . $locale); |
|
84 | + putenv("LC_ALL=".$locale); |
|
85 | 85 | setlocale(LC_ALL, $locale); |
86 | 86 | // Load the locale path |
87 | - $localePath = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
88 | - Logger::log('Set locale dir ' . $localePath); |
|
87 | + $localePath = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
88 | + Logger::log('Set locale dir '.$localePath); |
|
89 | 89 | GeneratorHelper::createDir($localePath); |
90 | 90 | bindtextdomain('translations', $localePath); |
91 | 91 | textdomain('translations'); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | } elseif (is_object($data)) { |
107 | 107 | $properties = get_class_vars($data); |
108 | - if(is_array($properties)) { |
|
108 | + if (is_array($properties)) { |
|
109 | 109 | foreach (array_keys($properties) as $property) { |
110 | 110 | $data->$property = self::utf8Encode($data->$property); |
111 | 111 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ['i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'], |
153 | 153 | ['o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'], |
154 | 154 | ['u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'], |
155 | - ['n', 'N', 'c', 'C',], |
|
155 | + ['n', 'N', 'c', 'C', ], |
|
156 | 156 | ]; |
157 | 157 | |
158 | 158 | $text = filter_var($string, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); |
@@ -172,24 +172,24 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public static function findTranslations($path, $locale) |
174 | 174 | { |
175 | - $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
176 | - $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
175 | + $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
176 | + $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
177 | 177 | |
178 | 178 | $translations = array(); |
179 | 179 | if (file_exists($path)) { |
180 | 180 | $directory = dir($path); |
181 | 181 | while (false !== ($fileName = $directory->read())) { |
182 | 182 | GeneratorHelper::createDir($localePath); |
183 | - if (!file_exists($localePath . 'translations.po')) { |
|
184 | - file_put_contents($localePath . 'translations.po', ''); |
|
183 | + if (!file_exists($localePath.'translations.po')) { |
|
184 | + file_put_contents($localePath.'translations.po', ''); |
|
185 | 185 | } |
186 | - $inspectPath = realpath($path . DIRECTORY_SEPARATOR . $fileName); |
|
187 | - $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext " . |
|
188 | - $inspectPath . DIRECTORY_SEPARATOR . |
|
186 | + $inspectPath = realpath($path.DIRECTORY_SEPARATOR.$fileName); |
|
187 | + $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext ". |
|
188 | + $inspectPath.DIRECTORY_SEPARATOR. |
|
189 | 189 | "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$localePath}translations.po"; |
190 | - if (is_dir($path . DIRECTORY_SEPARATOR . $fileName) && preg_match('/^\./', $fileName) == 0) { |
|
191 | - $res = t('Revisando directorio: ') . $inspectPath; |
|
192 | - $res .= t('Comando ejecutado: ') . $cmdPhp; |
|
190 | + if (is_dir($path.DIRECTORY_SEPARATOR.$fileName) && preg_match('/^\./', $fileName) == 0) { |
|
191 | + $res = t('Revisando directorio: ').$inspectPath; |
|
192 | + $res .= t('Comando ejecutado: ').$cmdPhp; |
|
193 | 193 | $res .= shell_exec($cmdPhp); |
194 | 194 | usleep(10); |
195 | 195 | $translations[] = $res; |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | { |
36 | 36 | $html = '<style>*{margin: 0} body{background: rgb(36,36,36); padding: 5px;}</style>'; |
37 | 37 | $html .= '<pre style="padding: 10px; margin: 5px; display: block; background: rgb(41,41,41); color: white; border-radius: 5px;">'; |
38 | - if(is_null($var)) { |
|
39 | - if($varName) $html .= $varName . ' ==> <b>NULL</b>'; |
|
40 | - } else { |
|
41 | - $html .= print_r('(' . gettype($var) . ') ', TRUE); |
|
42 | - if($varName) $html .= $varName . ' ==> '; |
|
43 | - if("boolean" === gettype($var)) { |
|
38 | + if (is_null($var)) { |
|
39 | + if ($varName) $html .= $varName.' ==> <b>NULL</b>'; |
|
40 | + }else { |
|
41 | + $html .= print_r('('.gettype($var).') ', TRUE); |
|
42 | + if ($varName) $html .= $varName.' ==> '; |
|
43 | + if ("boolean" === gettype($var)) { |
|
44 | 44 | $html .= print_r($var ? "TRUE" : "FALSE", TRUE); |
45 | - } else if((is_array($var) && !empty($var)) || (!is_array($var)) || ($var === 0)) { |
|
45 | + }else if ((is_array($var) && !empty($var)) || (!is_array($var)) || ($var === 0)) { |
|
46 | 46 | $html .= print_r($var, TRUE); |
47 | - } else { |
|
47 | + }else { |
|
48 | 48 | $html .= 'empty'; |
49 | 49 | } |
50 | 50 | } |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | /* @var $file SplFileInfo */ |
80 | 80 | foreach ($finder as $file) { |
81 | 81 | $path = $file->getRealPath(); |
82 | - if(!in_array($path, $loaded_files)) { |
|
82 | + if (!in_array($path, $loaded_files)) { |
|
83 | 83 | $loaded_files[] = $path; |
84 | 84 | require_once($path); |
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | -if(!function_exists('t')) { |
|
89 | +if (!function_exists('t')) { |
|
90 | 90 | function t($message, $key = null, $reload = false) { |
91 | 91 | return CustomTranslateExtension::_($message, $key, $reload); |
92 | 92 | } |
@@ -36,10 +36,14 @@ discard block |
||
36 | 36 | $html = '<style>*{margin: 0} body{background: rgb(36,36,36); padding: 5px;}</style>'; |
37 | 37 | $html .= '<pre style="padding: 10px; margin: 5px; display: block; background: rgb(41,41,41); color: white; border-radius: 5px;">'; |
38 | 38 | if(is_null($var)) { |
39 | - if($varName) $html .= $varName . ' ==> <b>NULL</b>'; |
|
39 | + if($varName) { |
|
40 | + $html .= $varName . ' ==> <b>NULL</b>'; |
|
41 | + } |
|
40 | 42 | } else { |
41 | 43 | $html .= print_r('(' . gettype($var) . ') ', TRUE); |
42 | - if($varName) $html .= $varName . ' ==> '; |
|
44 | + if($varName) { |
|
45 | + $html .= $varName . ' ==> '; |
|
46 | + } |
|
43 | 47 | if("boolean" === gettype($var)) { |
44 | 48 | $html .= print_r($var ? "TRUE" : "FALSE", TRUE); |
45 | 49 | } else if((is_array($var) && !empty($var)) || (!is_array($var)) || ($var === 0)) { |
@@ -63,9 +67,10 @@ discard block |
||
63 | 67 | function getallheaders() |
64 | 68 | { |
65 | 69 | $headers = []; |
66 | - foreach ($_SERVER as $h => $v) |
|
67 | - if (preg_match('/HTTP_(.+)/', $h, $hp)) { |
|
70 | + foreach ($_SERVER as $h => $v) { |
|
71 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) { |
|
68 | 72 | $headers[$hp[1]] = $v; |
73 | + } |
|
69 | 74 | } |
70 | 75 | return $headers; |
71 | 76 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function getServer($key, $default = null) |
22 | 22 | { |
23 | 23 | $value = null; |
24 | - if(array_key_exists($key, $this->server)) { |
|
24 | + if (array_key_exists($key, $this->server)) { |
|
25 | 25 | $value = $this->server[$key]; |
26 | 26 | } |
27 | 27 | return $value ?: $default; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function getProtocol() |
62 | 62 | { |
63 | - if(Config::getParam('force.https', false)) { |
|
63 | + if (Config::getParam('force.https', false)) { |
|
64 | 64 | return 'https://'; |
65 | 65 | } |
66 | 66 | return ($this->getServer('HTTPS') || $this->getServer('https')) ? 'https://' : 'http://'; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | $platform = trim(Config::getInstance()->get('platform.name', 'PSFS')); |
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 t('Zona restringida'); |
39 | 39 | exit(); |
40 | 40 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $admin['class'] = 'primary'; |
77 | 77 | break; |
78 | 78 | } |
79 | - } else { |
|
79 | + }else { |
|
80 | 80 | $admin['class'] = 'primary'; |
81 | 81 | } |
82 | 82 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | $headers = []; |
90 | 90 | foreach ($this->getHeaders() as $key => $value) { |
91 | - $headers[] = $key . ': ' . $value; |
|
91 | + $headers[] = $key.': '.$value; |
|
92 | 92 | } |
93 | 93 | $headers[self::PSFS_TRACK_HEADER] = Logger::getUid(); |
94 | 94 | if (count($headers)) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | case Request::VERB_GET: |
119 | 119 | if (!empty($this->params)) { |
120 | 120 | $sep = !str_contains($this->getUrl(), '?') ? '?' : ''; |
121 | - $this->setUrl($this->getUrl() . $sep . http_build_query($this->getParams()), false); |
|
121 | + $this->setUrl($this->getUrl().$sep.http_build_query($this->getParams()), false); |
|
122 | 122 | } |
123 | 123 | break; |
124 | 124 | case Request::VERB_POST: |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | if ($this->isDebug() && is_resource($verbose)) { |
150 | 150 | $this->dumpVerboseLogs($verbose); |
151 | 151 | } |
152 | - Logger::log($this->getUrl() . ' response: ', LOG_DEBUG, is_array($this->getRawResult()) ? $this->getRawResult() : [$this->getRawResult()]); |
|
152 | + Logger::log($this->getUrl().' response: ', LOG_DEBUG, is_array($this->getRawResult()) ? $this->getRawResult() : [$this->getRawResult()]); |
|
153 | 153 | $this->info = array_merge($this->info, curl_getinfo($this->con)); |
154 | 154 | } |
155 | 155 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | && (preg_match('/^\/(admin|setup\-admin)/i', $route) || Config::getParam('restricted', false)) |
35 | 35 | ) { |
36 | 36 | if (!self::isTest() && |
37 | - null === Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true)) { |
|
37 | + null === Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true)) { |
|
38 | 38 | throw new AdminCredentialsException(); |
39 | 39 | } |
40 | 40 | if (!Security::getInstance()->checkAdmin()) { |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | $token = ''; |
55 | 55 | $length = strlen($timestamp); |
56 | 56 | for ($i = 0; $i < $length; $i++) { |
57 | - $token = substr($hash, $i, 1) . |
|
58 | - substr($timestamp, $i, 1) . |
|
57 | + $token = substr($hash, $i, 1). |
|
58 | + substr($timestamp, $i, 1). |
|
59 | 59 | $token; |
60 | 60 | } |
61 | 61 | return $token; |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | $charsLength = strlen(self::RAND_SEP) - 1; |
75 | 75 | $tsLength = strlen($timestamp); |
76 | 76 | $i = 0; |
77 | - $partCount = ceil($hashRest / 4); |
|
78 | - $part = substr($hash, $tsLength + $partCount * $i, $partCount); |
|
77 | + $partCount = ceil($hashRest/4); |
|
78 | + $part = substr($hash, $tsLength + $partCount*$i, $partCount); |
|
79 | 79 | while (false !== $part && strlen($part) > 0) { |
80 | - $mixedToken .= $part . |
|
81 | - substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1) . |
|
80 | + $mixedToken .= $part. |
|
81 | + substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1). |
|
82 | 82 | substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1); |
83 | - $part = substr($hash, $tsLength + $partCount * $i, $partCount); |
|
83 | + $part = substr($hash, $tsLength + $partCount*$i, $partCount); |
|
84 | 84 | $i++; |
85 | 85 | } |
86 | - return $mixedToken . $token; |
|
86 | + return $mixedToken.$token; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | private static function getTs($isOdd = null) |
94 | 94 | { |
95 | 95 | $timestamp = time(); |
96 | - $tsIsOdd = (bool)((int)substr($timestamp, -1) % 2); |
|
96 | + $tsIsOdd = (bool)((int)substr($timestamp, -1)%2); |
|
97 | 97 | if (false === $isOdd && !$tsIsOdd) { |
98 | 98 | $timestamp--; |
99 | 99 | } elseif (true === $isOdd && !$tsIsOdd) { |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | $timestamp = ''; |
130 | 130 | $part = strrev($part); |
131 | 131 | for ($i = 0, $ct = strlen($part); $i < $ct; $i++) { |
132 | - if ($i % 2 == 0) { |
|
132 | + if ($i%2 == 0) { |
|
133 | 133 | $timestamp .= substr($part, $i, 1); |
134 | - } else { |
|
134 | + }else { |
|
135 | 135 | $partToken .= substr($part, $i, 1); |
136 | 136 | } |
137 | 137 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | list($partToken, $timestamp) = self::extractTs(array_pop($parts)); |
149 | 149 | $token = null; |
150 | 150 | if ($timestamp > 0) { |
151 | - $token = $partToken . implode('', $parts); |
|
151 | + $token = $partToken.implode('', $parts); |
|
152 | 152 | } |
153 | 153 | return [$token, $timestamp]; |
154 | 154 | } |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | $objects = scandir($dir); |
24 | 24 | foreach ($objects as $object) { |
25 | 25 | if ($object != "." && $object != "..") { |
26 | - if (filetype($dir . "/" . $object) == "dir") { |
|
27 | - self::deleteDir($dir . "/" . $object); |
|
28 | - } else { |
|
29 | - unlink($dir . "/" . $object); |
|
26 | + if (filetype($dir."/".$object) == "dir") { |
|
27 | + self::deleteDir($dir."/".$object); |
|
28 | + }else { |
|
29 | + unlink($dir."/".$object); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | } |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | { |
43 | 43 | $rootDirs = array("css", "js", "media", "font"); |
44 | 44 | foreach ($rootDirs as $dir) { |
45 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
45 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
46 | 46 | try { |
47 | - self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
48 | - } catch (\Exception $e) { |
|
47 | + self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
48 | + }catch (\Exception $e) { |
|
49 | 49 | syslog(LOG_INFO, $e->getMessage()); |
50 | 50 | } |
51 | 51 | } |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public static function createDir($dir) |
61 | 61 | { |
62 | - if(!empty($dir)) { |
|
62 | + if (!empty($dir)) { |
|
63 | 63 | try { |
64 | 64 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
65 | - throw new \Exception(t('Can\'t create directory ') . $dir); |
|
65 | + throw new \Exception(t('Can\'t create directory ').$dir); |
|
66 | 66 | } |
67 | - } catch (\Exception $e) { |
|
67 | + }catch (\Exception $e) { |
|
68 | 68 | syslog(LOG_WARNING, $e->getMessage()); |
69 | 69 | if (!file_exists(dirname($dir))) { |
70 | - throw new GeneratorException($e->getMessage() . $dir); |
|
70 | + throw new GeneratorException($e->getMessage().$dir); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public static function getTemplatePath() |
81 | 81 | { |
82 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
82 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
83 | 83 | return realpath($path); |
84 | 84 | } |
85 | 85 | |
@@ -98,15 +98,15 @@ discard block |
||
98 | 98 | * @throws \ReflectionException |
99 | 99 | */ |
100 | 100 | public static function checkCustomNamespaceApi($namespace) { |
101 | - if(!empty($namespace)) { |
|
102 | - if(class_exists($namespace)) { |
|
101 | + if (!empty($namespace)) { |
|
102 | + if (class_exists($namespace)) { |
|
103 | 103 | $reflector = new \ReflectionClass($namespace); |
104 | - if(!$reflector->isSubclassOf(Api::class)) { |
|
104 | + if (!$reflector->isSubclassOf(Api::class)) { |
|
105 | 105 | throw new GeneratorException(t('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501); |
106 | - } elseif(!$reflector->isAbstract()) { |
|
106 | + } elseif (!$reflector->isAbstract()) { |
|
107 | 107 | throw new GeneratorException(t('La clase definida debe ser abstracta'), 501); |
108 | 108 | } |
109 | - } else { |
|
109 | + }else { |
|
110 | 110 | throw new GeneratorException(t('La clase definida para extender la API no existe'), 501); |
111 | 111 | } |
112 | 112 | } |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public static function createRoot($path = WEB_DIR, OutputInterface $output = null, $quiet = false) { |
122 | 122 | |
123 | - if(null === $output) { |
|
123 | + if (null === $output) { |
|
124 | 124 | $output = new ConsoleOutput(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | GeneratorHelper::createDir($path); |
128 | 128 | $paths = array("js", "css", "img", "media", "font"); |
129 | 129 | foreach ($paths as $htmlPath) { |
130 | - GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath); |
|
130 | + GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // Generates the root needed files |
@@ -137,26 +137,26 @@ discard block |
||
137 | 137 | 'crossdomain' => 'crossdomain.xml', |
138 | 138 | 'humans' => 'humans.txt', |
139 | 139 | 'robots' => 'robots.txt', |
140 | - 'docker' => '..' . DIRECTORY_SEPARATOR . 'docker-compose.yml', |
|
140 | + 'docker' => '..'.DIRECTORY_SEPARATOR.'docker-compose.yml', |
|
141 | 141 | ]; |
142 | 142 | $output->writeln('Start creating html files'); |
143 | 143 | foreach ($files as $templates => $filename) { |
144 | - $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig'); |
|
145 | - if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) { |
|
146 | - if(!$quiet) { |
|
147 | - $output->writeln('Can\t create the file ' . $filename); |
|
144 | + $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig'); |
|
145 | + if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) { |
|
146 | + if (!$quiet) { |
|
147 | + $output->writeln('Can\t create the file '.$filename); |
|
148 | 148 | } |
149 | - } else { |
|
150 | - if(!$quiet) { |
|
151 | - $output->writeln($filename . ' created successfully'); |
|
149 | + }else { |
|
150 | + if (!$quiet) { |
|
151 | + $output->writeln($filename.' created successfully'); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | 156 | //Export base locale translations |
157 | - if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) { |
|
158 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
159 | - self::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
157 | + if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) { |
|
158 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
159 | + self::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | { |
173 | 173 | if (file_exists($filenamePath)) { |
174 | 174 | $destfolder = basename($filenamePath); |
175 | - if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) { |
|
175 | + if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) { |
|
176 | 176 | if (is_dir($filenamePath)) { |
177 | - self::copyr($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
178 | - } else { |
|
179 | - if (@copy($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) { |
|
180 | - throw new ConfigException("Can't copy " . $filenamePath . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
177 | + self::copyr($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
178 | + }else { |
|
179 | + if (@copy($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) { |
|
180 | + throw new ConfigException("Can't copy ".$filenamePath." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | } |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | self::createDir($dst); |
196 | 196 | while (false !== ($file = readdir($dir))) { |
197 | 197 | if (($file != '.') && ($file != '..')) { |
198 | - if (is_dir($src . '/' . $file)) { |
|
199 | - self::copyr($src . '/' . $file, $dst . '/' . $file); |
|
200 | - } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) { |
|
201 | - throw new ConfigException("Can't copy " . $src . " to " . $dst); |
|
198 | + if (is_dir($src.'/'.$file)) { |
|
199 | + self::copyr($src.'/'.$file, $dst.'/'.$file); |
|
200 | + } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) { |
|
201 | + throw new ConfigException("Can't copy ".$src." to ".$dst); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |