@@ -45,10 +45,10 @@ discard block |
||
| 45 | 45 | if (!headers_sent()) { |
| 46 | 46 | // TODO include this headers in Template class output method |
| 47 | 47 | header('Access-Control-Allow-Credentials: true'); |
| 48 | - header('Access-Control-Allow-Origin: ' . Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
| 48 | + header('Access-Control-Allow-Origin: '.Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
| 49 | 49 | header('Vary: Origin'); |
| 50 | 50 | header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS'); |
| 51 | - header('Access-Control-Allow-Headers: ' . implode(', ', self::getCorsHeaders())); |
|
| 51 | + header('Access-Control-Allow-Headers: '.implode(', ', self::getCorsHeaders())); |
|
| 52 | 52 | } |
| 53 | 53 | if (Request::getInstance()->getMethod() === Request::VERB_OPTIONS) { |
| 54 | 54 | Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests', LOG_DEBUG); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | return $ip; |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | - } else { |
|
| 81 | + }else { |
|
| 82 | 82 | if (self::validateIpAddress($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 83 | 83 | return $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 84 | 84 | } |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | protected function hydrateBulkRequest() { |
| 97 | 97 | $class = new \ReflectionClass($this->getModelNamespace()); |
| 98 | 98 | $this->list = []; |
| 99 | - foreach($this->data as $item) { |
|
| 100 | - if(is_array($item)) { |
|
| 101 | - if(count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
| 99 | + foreach ($this->data as $item) { |
|
| 100 | + if (is_array($item)) { |
|
| 101 | + if (count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
| 102 | 102 | /** @var ActiveRecordInterface $model */ |
| 103 | 103 | $model = $class->newInstance(); |
| 104 | 104 | $this->hydrateModelFromRequest($model, $item); |
| 105 | 105 | $this->list[] = $model; |
| 106 | - } else { |
|
| 107 | - Logger::log(t('Max items per bulk insert raised'), LOG_WARNING, count($this->data) . t('items')); |
|
| 106 | + }else { |
|
| 107 | + Logger::log(t('Max items per bulk insert raised'), LOG_WARNING, count($this->data).t('items')); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | protected function saveBulk() { |
| 117 | 117 | $tablemap = $this->getTableMap(); |
| 118 | - foreach($this->list as &$model) { |
|
| 118 | + foreach ($this->list as &$model) { |
|
| 119 | 119 | $con = Propel::getWriteConnection($tablemap::DATABASE_NAME); |
| 120 | 120 | try { |
| 121 | 121 | $model->save($con); |
| 122 | 122 | $con->commit(); |
| 123 | - } catch(\Exception $e) { |
|
| 123 | + }catch (\Exception $e) { |
|
| 124 | 124 | Logger::log($e->getMessage(), LOG_ERR, $model->toArray()); |
| 125 | 125 | $con->rollBack(); |
| 126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | protected function exportList() { |
| 134 | 134 | $list = []; |
| 135 | 135 | /** @var ActiveRecordInterface $item */ |
| 136 | - foreach($this->list as $item) { |
|
| 136 | + foreach ($this->list as $item) { |
|
| 137 | 137 | $list[] = $item->toArray(); |
| 138 | 138 | } |
| 139 | 139 | return $list; |
@@ -157,18 +157,18 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function findPk(ModelCriteria $query, $primaryKey) { |
| 159 | 159 | $pks = explode(Api::API_PK_SEPARATOR, urldecode($primaryKey)); |
| 160 | - if(count($pks) === 1 && !empty($pks[0])) { |
|
| 160 | + if (count($pks) === 1 && !empty($pks[0])) { |
|
| 161 | 161 | $query->filterByPrimaryKey($pks[0]); |
| 162 | - } else { |
|
| 162 | + }else { |
|
| 163 | 163 | $item = 0; |
| 164 | - foreach($this->getPkDbName() as $phpName) { |
|
| 164 | + foreach ($this->getPkDbName() as $phpName) { |
|
| 165 | 165 | try { |
| 166 | 166 | $query->filterBy($phpName, $pks[$item]); |
| 167 | 167 | $item++; |
| 168 | - if($item >= count($pks)) { |
|
| 168 | + if ($item >= count($pks)) { |
|
| 169 | 169 | break; |
| 170 | 170 | } |
| 171 | - } catch(\Exception $e) { |
|
| 171 | + }catch (\Exception $e) { |
|
| 172 | 172 | Logger::log($e->getMessage(), LOG_DEBUG); |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | try { |
| 199 | 199 | $query = $this->prepareQuery(); |
| 200 | 200 | $this->model = $this->findPk($query, $primaryKey); |
| 201 | - } catch (\Exception $e) { |
|
| 202 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 201 | + }catch (\Exception $e) { |
|
| 202 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $platform = trim(Config::getInstance()->get('platform.name')); |
| 35 | 35 | header('HTTP/1.1 401 Unauthorized'); |
| 36 | - header('WWW-Authenticate: Basic Realm="' . $platform . '"'); |
|
| 36 | + header('WWW-Authenticate: Basic Realm="'.$platform.'"'); |
|
| 37 | 37 | echo t('Zona restringida'); |
| 38 | 38 | exit(); |
| 39 | 39 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $admin['class'] = 'primary'; |
| 76 | 76 | break; |
| 77 | 77 | } |
| 78 | - } else { |
|
| 78 | + }else { |
|
| 79 | 79 | $admin['class'] = 'primary'; |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $logs = array(); |
| 94 | 94 | /** @var \SplFileInfo $file */ |
| 95 | 95 | foreach ($files as $file) { |
| 96 | - $size = $file->getSize() / 8 / 1024; |
|
| 96 | + $size = $file->getSize()/8/1024; |
|
| 97 | 97 | $time = date('c', $file->getMTime()); |
| 98 | 98 | $dateTime = new \DateTime($time); |
| 99 | 99 | if (!isset($logs[$dateTime->format('Y')])) { |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $files->files()->in(LOG_DIR)->name($selectedLog); |
| 123 | 123 | $file = $match = null; |
| 124 | 124 | $log = array(); |
| 125 | - foreach($files as $item) { |
|
| 125 | + foreach ($files as $item) { |
|
| 126 | 126 | $file = $item; |
| 127 | 127 | $match = $item; |
| 128 | 128 | break; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $time = date('c', $file->getMTime()); |
| 133 | 133 | $dateTime = new \DateTime($time); |
| 134 | 134 | $monthOpen = $dateTime->format('m'); |
| 135 | - $content = file($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename()); |
|
| 135 | + $content = file($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename()); |
|
| 136 | 136 | krsort($content); |
| 137 | 137 | $detailLog = array(); |
| 138 | 138 | foreach ($content as &$line) { |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | break; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - } catch (\Exception $e) { |
|
| 193 | + }catch (\Exception $e) { |
|
| 194 | 194 | $detail = [ |
| 195 | 195 | 'type' => 'danger', |
| 196 | 196 | ]; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public function __construct($type = 'js') |
| 36 | 36 | { |
| 37 | 37 | $this->type = $type; |
| 38 | - $this->path = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 38 | + $this->path = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 39 | 39 | $this->domains = Template::getDomains(true); |
| 40 | 40 | $this->debug = Config::getParam('debug'); |
| 41 | 41 | $this->cdnPath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl()); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $source_file = explode("?", $source_file); |
| 59 | 59 | $source_file = $source_file[0]; |
| 60 | 60 | } |
| 61 | - $orig = realpath(dirname($filename_path) . DIRECTORY_SEPARATOR . $source_file); |
|
| 61 | + $orig = realpath(dirname($filename_path).DIRECTORY_SEPARATOR.$source_file); |
|
| 62 | 62 | return $orig; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -71,12 +71,12 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function addFile($filename) |
| 73 | 73 | { |
| 74 | - if (file_exists($this->path . $filename) && preg_match('/\.' . $this->type . '$/i', $filename)) { |
|
| 74 | + if (file_exists($this->path.$filename) && preg_match('/\.'.$this->type.'$/i', $filename)) { |
|
| 75 | 75 | $this->files[] = $filename; |
| 76 | 76 | } elseif (!empty($this->domains)) { |
| 77 | 77 | foreach ($this->domains as $domain => $paths) { |
| 78 | 78 | $domain_filename = str_replace($domain, $paths["public"], $filename); |
| 79 | - if (file_exists($domain_filename) && preg_match('/\.' . $this->type . '$/i', $domain_filename)) { |
|
| 79 | + if (file_exists($domain_filename) && preg_match('/\.'.$this->type.'$/i', $domain_filename)) { |
|
| 80 | 80 | $this->files[] = $domain_filename; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | public function setHash($hash) |
| 94 | 94 | { |
| 95 | 95 | $cache = Config::getParam('cache.var', ''); |
| 96 | - $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache; |
|
| 96 | + $this->hash = $hash.(strlen($cache) ? '.' : '').$cache; |
|
| 97 | 97 | return $this; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | protected function compileCss() |
| 129 | 129 | { |
| 130 | - $base = $this->path . "css" . DIRECTORY_SEPARATOR; |
|
| 131 | - if ($this->debug || !file_exists($base . $this->hash . ".css")) { |
|
| 130 | + $base = $this->path."css".DIRECTORY_SEPARATOR; |
|
| 131 | + if ($this->debug || !file_exists($base.$this->hash.".css")) { |
|
| 132 | 132 | $data = ''; |
| 133 | 133 | if (0 < count($this->files)) { |
| 134 | 134 | $minifier = new CSS(); |
@@ -136,15 +136,15 @@ discard block |
||
| 136 | 136 | $data = $this->processCssLine($file, $base, $data); |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | - if($this->debug) { |
|
| 140 | - $this->storeContents($base . $this->hash . ".css", $data); |
|
| 141 | - } else { |
|
| 139 | + if ($this->debug) { |
|
| 140 | + $this->storeContents($base.$this->hash.".css", $data); |
|
| 141 | + }else { |
|
| 142 | 142 | $minifier = new CSS(); |
| 143 | 143 | $minifier->add($data); |
| 144 | 144 | ini_set('max_execution_time', -1); |
| 145 | 145 | ini_set('memory_limit', -1); |
| 146 | 146 | GeneratorHelper::createDir($base); |
| 147 | - $minifier->minify($base . $this->hash . ".css"); |
|
| 147 | + $minifier->minify($base.$this->hash.".css"); |
|
| 148 | 148 | ini_restore('memory_limit'); |
| 149 | 149 | ini_restore('max_execution_time'); |
| 150 | 150 | } |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | protected function compileJs() |
| 162 | 162 | { |
| 163 | - $base = $this->path . "js" . DIRECTORY_SEPARATOR; |
|
| 164 | - if ($this->debug || !file_exists($base . $this->hash . ".js")) { |
|
| 163 | + $base = $this->path."js".DIRECTORY_SEPARATOR; |
|
| 164 | + if ($this->debug || !file_exists($base.$this->hash.".js")) { |
|
| 165 | 165 | $data = ''; |
| 166 | 166 | if (0 < count($this->files)) { |
| 167 | 167 | $minifier = new JS(); |
@@ -170,19 +170,19 @@ discard block |
||
| 170 | 170 | if (file_exists($file)) { |
| 171 | 171 | if ($this->debug) { |
| 172 | 172 | $data = $this->putDebugJs($path_parts, $base, $file); |
| 173 | - } elseif (!file_exists($base . $this->hash . ".js")) { |
|
| 173 | + } elseif (!file_exists($base.$this->hash.".js")) { |
|
| 174 | 174 | $minifier->add($file); |
| 175 | 175 | //$data = $this->putProductionJs($base, $file, $data); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | - if($this->debug) { |
|
| 180 | - $this->storeContents($base . $this->hash . ".js", $data); |
|
| 181 | - } else { |
|
| 179 | + if ($this->debug) { |
|
| 180 | + $this->storeContents($base.$this->hash.".js", $data); |
|
| 181 | + }else { |
|
| 182 | 182 | ini_set('max_execution_time', -1); |
| 183 | 183 | ini_set('memory_limit', -1); |
| 184 | 184 | GeneratorHelper::createDir($base); |
| 185 | - $minifier->minify($base . $this->hash . ".js"); |
|
| 185 | + $minifier->minify($base.$this->hash.".js"); |
|
| 186 | 186 | ini_restore('memory_limit'); |
| 187 | 187 | ini_restore('max_execution_time'); |
| 188 | 188 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | GeneratorHelper::createDir(dirname($path)); |
| 204 | 204 | if ("" !== $content && false === file_put_contents($path, $content)) { |
| 205 | - throw new ConfigException(_('No se tienen permisos para escribir en ' . $path)); |
|
| 205 | + throw new ConfigException(_('No se tienen permisos para escribir en '.$path)); |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | foreach ($this->compiled_files as $file) { |
| 232 | 232 | echo "\t\t<script type='text/javascript' src='{$file}'></script>\n"; |
| 233 | 233 | } |
| 234 | - } else { |
|
| 234 | + }else { |
|
| 235 | 235 | $basePath = $this->cdnPath ?: ''; |
| 236 | - echo "\t\t<script type='text/javascript' src='" . $basePath . "/js/" . $this->hash . ".js'></script>\n"; |
|
| 236 | + echo "\t\t<script type='text/javascript' src='".$basePath."/js/".$this->hash.".js'></script>\n"; |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | foreach ($this->compiled_files as $file) { |
| 247 | 247 | echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>"; |
| 248 | 248 | } |
| 249 | - } else { |
|
| 249 | + }else { |
|
| 250 | 250 | $basePath = $this->cdnPath ?: ''; |
| 251 | - echo "\t\t<link href='" . $basePath . "/css/" . $this->hash . ".css' rel='stylesheet'>"; |
|
| 251 | + echo "\t\t<link href='".$basePath."/css/".$this->hash.".css' rel='stylesheet'>"; |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
@@ -259,20 +259,20 @@ discard block |
||
| 259 | 259 | protected function extractCssResources($source, $file) |
| 260 | 260 | { |
| 261 | 261 | $source_file = $this->extractSourceFilename($source); |
| 262 | - $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $source_file); |
|
| 262 | + $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$source_file); |
|
| 263 | 263 | $orig_part = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig); |
| 264 | 264 | try { |
| 265 | 265 | if (count($source) > 1 && array_key_exists(1, $orig_part)) { |
| 266 | - $dest = $this->path . $orig_part[1]; |
|
| 266 | + $dest = $this->path.$orig_part[1]; |
|
| 267 | 267 | GeneratorHelper::createDir(dirname($dest)); |
| 268 | 268 | if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) { |
| 269 | 269 | if (@copy($orig, $dest) === FALSE) { |
| 270 | - throw new \RuntimeException('Can\' copy ' . $dest . ''); |
|
| 270 | + throw new \RuntimeException('Can\' copy '.$dest.''); |
|
| 271 | 271 | } |
| 272 | 272 | Logger::log("$orig copiado a $dest", LOG_INFO); |
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | - } catch (\Exception $e) { |
|
| 275 | + }catch (\Exception $e) { |
|
| 276 | 276 | Logger::log($e->getMessage(), LOG_ERR); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -289,21 +289,21 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | if (file_exists($file)) { |
| 291 | 291 | $path_parts = explode("/", $file); |
| 292 | - $file_path = $this->hash . "_" . $path_parts[count($path_parts) - 1]; |
|
| 293 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($file) || $this->debug) { |
|
| 292 | + $file_path = $this->hash."_".$path_parts[count($path_parts) - 1]; |
|
| 293 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($file) || $this->debug) { |
|
| 294 | 294 | //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados |
| 295 | - if (file_exists($base . $this->hash . ".css") && @unlink($base . $this->hash . ".css") === false) { |
|
| 296 | - throw new ConfigException("Can't unlink file " . $base . $this->hash . ".css"); |
|
| 295 | + if (file_exists($base.$this->hash.".css") && @unlink($base.$this->hash.".css") === false) { |
|
| 296 | + throw new ConfigException("Can't unlink file ".$base.$this->hash.".css"); |
|
| 297 | 297 | } |
| 298 | 298 | $this->loopCssLines($file); |
| 299 | 299 | } |
| 300 | 300 | if ($this->debug) { |
| 301 | 301 | $data = file_get_contents($file); |
| 302 | - $this->storeContents($base . $file_path, $data); |
|
| 303 | - } else { |
|
| 302 | + $this->storeContents($base.$file_path, $data); |
|
| 303 | + }else { |
|
| 304 | 304 | $data .= file_get_contents($file); |
| 305 | 305 | } |
| 306 | - $this->compiled_files[] = "/css/" . $file_path; |
|
| 306 | + $this->compiled_files[] = "/css/".$file_path; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | return $data; |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | protected function putDebugJs($path_parts, $base, $file) |
| 320 | 320 | { |
| 321 | - $file_path = $this->hash . "_" . $path_parts[count($path_parts) - 1]; |
|
| 322 | - $this->compiled_files[] = "/js/" . $file_path; |
|
| 321 | + $file_path = $this->hash."_".$path_parts[count($path_parts) - 1]; |
|
| 322 | + $this->compiled_files[] = "/js/".$file_path; |
|
| 323 | 323 | $data = ""; |
| 324 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($file)) { |
|
| 324 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($file)) { |
|
| 325 | 325 | $data = file_get_contents($file); |
| 326 | - $this->storeContents($base . $file_path, $data); |
|
| 326 | + $this->storeContents($base.$file_path, $data); |
|
| 327 | 327 | } |
| 328 | 328 | return $data; |
| 329 | 329 | } |
@@ -365,60 +365,60 @@ discard block |
||
| 365 | 365 | { |
| 366 | 366 | $ppath = explode("/", $string); |
| 367 | 367 | $original_filename = $ppath[count($ppath) - 1]; |
| 368 | - $base = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 368 | + $base = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 369 | 369 | $file = ""; |
| 370 | 370 | $html_base = ""; |
| 371 | 371 | $debug = Config::getInstance()->getDebugMode(); |
| 372 | 372 | $cache = Config::getInstance()->get('cache.var'); |
| 373 | - $cache = $cache ? '.' . $cache : ''; |
|
| 373 | + $cache = $cache ? '.'.$cache : ''; |
|
| 374 | 374 | $finfo = finfo_open(FILEINFO_MIME_TYPE); // devuelve el tipo mime de su extensión |
| 375 | 375 | $mime = finfo_file($finfo, $filename_path); |
| 376 | 376 | finfo_close($finfo); |
| 377 | 377 | if (preg_match('/\.css$/i', $string)) { |
| 378 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.css"; |
|
| 378 | + $file = "/".substr(md5($string), 0, 8)."$cache.css"; |
|
| 379 | 379 | $html_base = "css"; |
| 380 | 380 | if ($debug) { |
| 381 | - $file = str_replace(".css", "_" . $original_filename, $file); |
|
| 381 | + $file = str_replace(".css", "_".$original_filename, $file); |
|
| 382 | 382 | } |
| 383 | 383 | } elseif (preg_match('/\.js$/i', $string)) { |
| 384 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.js"; |
|
| 384 | + $file = "/".substr(md5($string), 0, 8)."$cache.js"; |
|
| 385 | 385 | $html_base = "js"; |
| 386 | 386 | if ($debug) { |
| 387 | - $file = str_replace(".js", "_" . $original_filename, $file); |
|
| 387 | + $file = str_replace(".js", "_".$original_filename, $file); |
|
| 388 | 388 | } |
| 389 | 389 | } elseif (preg_match("/image/i", $mime)) { |
| 390 | 390 | $ext = explode(".", $string); |
| 391 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 391 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 392 | 392 | $html_base = "img"; |
| 393 | 393 | if ($debug) { |
| 394 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 394 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 395 | 395 | } |
| 396 | 396 | } elseif (preg_match("/(doc|pdf)/i", $mime)) { |
| 397 | 397 | $ext = explode(".", $string); |
| 398 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 398 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 399 | 399 | $html_base = "docs"; |
| 400 | 400 | if ($debug) { |
| 401 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 401 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 402 | 402 | } |
| 403 | 403 | } elseif (preg_match("/(video|audio|ogg)/i", $mime)) { |
| 404 | 404 | $ext = explode(".", $string); |
| 405 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 405 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 406 | 406 | $html_base = "media"; |
| 407 | 407 | if ($debug) { |
| 408 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 408 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 409 | 409 | } |
| 410 | 410 | } elseif (preg_match("/(text|html)/i", $mime)) { |
| 411 | 411 | $ext = explode(".", $string); |
| 412 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 412 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 413 | 413 | $html_base = "templates"; |
| 414 | 414 | if ($debug) { |
| 415 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 415 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 416 | 416 | } |
| 417 | 417 | } elseif (!$return && !is_null($name)) { |
| 418 | 418 | $html_base = ''; |
| 419 | 419 | $file = $name; |
| 420 | 420 | } |
| 421 | - $file_path = $html_base . $file; |
|
| 421 | + $file_path = $html_base.$file; |
|
| 422 | 422 | |
| 423 | 423 | return array($base, $html_base, $file_path); |
| 424 | 424 | } |
@@ -436,15 +436,15 @@ discard block |
||
| 436 | 436 | if (preg_match_all('#url\((.*?)\)#', $line, $urls, PREG_SET_ORDER)) { |
| 437 | 437 | foreach ($urls as $source) { |
| 438 | 438 | $orig = self::calculateResourcePathname($filename_path, $source); |
| 439 | - if(!empty($orig)) { |
|
| 439 | + if (!empty($orig)) { |
|
| 440 | 440 | $orig_part = preg_split("/Public/i", $orig); |
| 441 | - $dest = WEB_DIR . $orig_part[1]; |
|
| 441 | + $dest = WEB_DIR.$orig_part[1]; |
|
| 442 | 442 | GeneratorHelper::createDir(dirname($dest)); |
| 443 | 443 | if (@copy($orig, $dest) === false) { |
| 444 | - throw new ConfigException("Can't copy " . $orig . " to " . $dest); |
|
| 444 | + throw new ConfigException("Can't copy ".$orig." to ".$dest); |
|
| 445 | 445 | } |
| 446 | - } else { |
|
| 447 | - Logger::log($filename_path . ' has an empty origin with the url ' . $source, LOG_WARNING); |
|
| 446 | + }else { |
|
| 447 | + Logger::log($filename_path.' has an empty origin with the url '.$source, LOG_WARNING); |
|
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -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 |