@@ -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 | ]; |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | if ($module === $requestModule && 0 === stripos($module, 'ROOT')) { |
| 56 | 56 | $modules = [ |
| 57 | 57 | 'name' => $module, |
| 58 | - 'path' => dirname($info['template'] . DIRECTORY_SEPARATOR . '..'), |
|
| 58 | + 'path' => dirname($info['template'].DIRECTORY_SEPARATOR.'..'), |
|
| 59 | 59 | ]; |
| 60 | 60 | } |
| 61 | - } catch (\Exception $e) { |
|
| 61 | + }catch (\Exception $e) { |
|
| 62 | 62 | $modules[] = $e->getMessage(); |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function extractApiEndpoints(array $module) |
| 78 | 78 | { |
| 79 | - $modulePath = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
| 79 | + $modulePath = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
| 80 | 80 | $moduleName = $module['name']; |
| 81 | 81 | $endpoints = []; |
| 82 | 82 | if (file_exists($modulePath)) { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | if (count($finder)) { |
| 86 | 86 | /** @var \SplFileInfo $file */ |
| 87 | 87 | foreach ($finder as $file) { |
| 88 | - $namespace = "\\{$moduleName}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
| 88 | + $namespace = "\\{$moduleName}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
| 89 | 89 | $info = $this->extractApiInfo($namespace, $moduleName); |
| 90 | 90 | if (!empty($info)) { |
| 91 | 91 | $endpoints[$namespace] = $info; |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | if (Router::exists($namespace) && !I18nHelper::checkI18Class($namespace)) { |
| 109 | 109 | $reflection = new \ReflectionClass($namespace); |
| 110 | 110 | $visible = InjectorHelper::checkIsVisible($reflection->getDocComment()); |
| 111 | - if($visible) { |
|
| 111 | + if ($visible) { |
|
| 112 | 112 | foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { |
| 113 | 113 | try { |
| 114 | 114 | $mInfo = $this->extractMethodInfo($namespace, $method, $reflection, $module); |
| 115 | 115 | if (NULL !== $mInfo) { |
| 116 | 116 | $info[] = $mInfo; |
| 117 | 117 | } |
| 118 | - } catch (\Exception $e) { |
|
| 118 | + }catch (\Exception $e) { |
|
| 119 | 119 | Logger::log($e->getMessage(), LOG_ERR); |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | $payload = $this->extractModelFields($namespace); |
| 249 | 249 | $reflector = new \ReflectionClass($namespace); |
| 250 | 250 | $shortName = $reflector->getShortName(); |
| 251 | - } else { |
|
| 251 | + }else { |
|
| 252 | 252 | $namespace = $model; |
| 253 | 253 | $shortName = $model; |
| 254 | 254 | } |
@@ -337,13 +337,13 @@ discard block |
||
| 337 | 337 | "required" => $field->isNotNull(), |
| 338 | 338 | 'format' => $format, |
| 339 | 339 | ]; |
| 340 | - if(count($field->getValueSet())) { |
|
| 340 | + if (count($field->getValueSet())) { |
|
| 341 | 341 | $info['enum'] = array_values($field->getValueSet()); |
| 342 | 342 | } |
| 343 | - if(null !== $field->getDefaultValue()) { |
|
| 343 | + if (null !== $field->getDefaultValue()) { |
|
| 344 | 344 | $info['default'] = $field->getDefaultValue(); |
| 345 | 345 | } |
| 346 | - switch(Config::getParam('api.field.type', TableMap::TYPE_PHPNAME)) { |
|
| 346 | + switch (Config::getParam('api.field.type', TableMap::TYPE_PHPNAME)) { |
|
| 347 | 347 | case 'UpperCamelCase': |
| 348 | 348 | case TableMap::TYPE_PHPNAME: |
| 349 | 349 | $payload[$field->getPhpName()] = $info; |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
| 366 | 366 | $payload = $this->extractDtoProperties($namespace); |
| 367 | 367 | } |
| 368 | - } catch (\Exception $e) { |
|
| 368 | + }catch (\Exception $e) { |
|
| 369 | 369 | Logger::log($e->getMessage(), LOG_ERR); |
| 370 | 370 | } |
| 371 | 371 | |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | $return = $this->extractReturn($modelNamespace, $docComments); |
| 397 | 397 | $url = array_pop($route); |
| 398 | 398 | $methodInfo = [ |
| 399 | - 'url' => str_replace('/' . $module . '/api', '', $url), |
|
| 399 | + 'url' => str_replace('/'.$module.'/api', '', $url), |
|
| 400 | 400 | 'method' => $info['http'], |
| 401 | 401 | 'description' => $info['label'], |
| 402 | 402 | 'return' => $return, |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | $this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments); |
| 408 | 408 | $this->setQueryParams($method, $methodInfo); |
| 409 | 409 | $this->setRequestHeaders($reflection, $methodInfo); |
| 410 | - } catch (\Exception $e) { |
|
| 410 | + }catch (\Exception $e) { |
|
| 411 | 411 | Logger::log($e->getMessage(), LOG_ERR); |
| 412 | 412 | } |
| 413 | 413 | } |
@@ -476,10 +476,10 @@ discard block |
||
| 476 | 476 | $formatted = [ |
| 477 | 477 | "swagger" => "2.0", |
| 478 | 478 | "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)), |
| 479 | - "basePath" => '/' . $module['name'] . '/api', |
|
| 479 | + "basePath" => '/'.$module['name'].'/api', |
|
| 480 | 480 | "schemes" => [Request::getInstance()->getServer('HTTPS') === 'on' ? 'https' : 'http'], |
| 481 | 481 | "info" => [ |
| 482 | - "title" => t('Documentación API módulo ') . $module['name'], |
|
| 482 | + "title" => t('Documentación API módulo ').$module['name'], |
|
| 483 | 483 | "version" => Config::getParam('api.version', '1.0.0'), |
| 484 | 484 | "contact" => [ |
| 485 | 485 | "name" => Config::getParam("author", "Fran López"), |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | foreach ($endpoints as $model) { |
| 493 | 493 | foreach ($model as $endpoint) { |
| 494 | 494 | if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
| 495 | - $url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']); |
|
| 495 | + $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']); |
|
| 496 | 496 | $description = $endpoint['description']; |
| 497 | 497 | $method = strtolower($endpoint['method']); |
| 498 | 498 | $paths[$url][$method] = [ |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | protected function extractDtoName($dto, $isArray = false) |
| 554 | 554 | { |
| 555 | 555 | $dto = explode('\\', $dto); |
| 556 | - $modelDto = array_pop($dto) . "Dto"; |
|
| 556 | + $modelDto = array_pop($dto)."Dto"; |
|
| 557 | 557 | if ($isArray) { |
| 558 | 558 | $modelDto .= "List"; |
| 559 | 559 | } |
@@ -603,10 +603,10 @@ discard block |
||
| 603 | 603 | { |
| 604 | 604 | |
| 605 | 605 | $methodInfo['headers'] = []; |
| 606 | - foreach($reflection->getProperties() as $property) { |
|
| 606 | + foreach ($reflection->getProperties() as $property) { |
|
| 607 | 607 | $doc = $property->getDocComment(); |
| 608 | 608 | preg_match('/@header\ (.*)\n/i', $doc, $headers); |
| 609 | - if(count($headers)) { |
|
| 609 | + if (count($headers)) { |
|
| 610 | 610 | $header = [ |
| 611 | 611 | "name" => $headers[1], |
| 612 | 612 | "in" => "header", |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | foreach ($method->getParameters() as $parameter) { |
| 652 | 652 | $parameterName = $parameter->getName(); |
| 653 | 653 | $types = []; |
| 654 | - preg_match_all('/\@param\ (.*)\ \$' . $parameterName . '$/im', $docComments, $types); |
|
| 654 | + preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types); |
|
| 655 | 655 | if (count($types) > 1 && count($types[1]) > 0) { |
| 656 | 656 | $methodInfo['parameters'][$parameterName] = $types[1][0]; |
| 657 | 657 | } |
@@ -673,21 +673,21 @@ discard block |
||
| 673 | 673 | $modelDto['objects'][$dtoName][$param] = [ |
| 674 | 674 | 'type' => 'array', |
| 675 | 675 | 'items' => [ |
| 676 | - '$ref' => '#/definitions/' . $info['type'], |
|
| 676 | + '$ref' => '#/definitions/'.$info['type'], |
|
| 677 | 677 | ] |
| 678 | 678 | ]; |
| 679 | - } else { |
|
| 679 | + }else { |
|
| 680 | 680 | $modelDto['objects'][$dtoName][$param] = [ |
| 681 | 681 | 'type' => 'object', |
| 682 | - '$ref' => '#/definitions/' . $info['type'], |
|
| 682 | + '$ref' => '#/definitions/'.$info['type'], |
|
| 683 | 683 | ]; |
| 684 | 684 | } |
| 685 | 685 | $modelDto['objects'][$info['class']] = $info['properties']; |
| 686 | 686 | $paramDto = $this->checkDtoAttributes($info['properties'], $info['properties'], $info['class']); |
| 687 | - if(array_key_exists('objects', $paramDto)) { |
|
| 687 | + if (array_key_exists('objects', $paramDto)) { |
|
| 688 | 688 | $modelDto['objects'] = array_merge($modelDto['objects'], $paramDto['objects']); |
| 689 | 689 | } |
| 690 | - } else { |
|
| 690 | + }else { |
|
| 691 | 691 | $modelDto['objects'][$dtoName][$param] = $info; |
| 692 | 692 | } |
| 693 | 693 | } |
@@ -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]; |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function init() |
| 77 | 77 | { |
| 78 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE); |
|
| 78 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE); |
|
| 79 | 79 | if (empty($this->routing) || Config::getInstance()->getDebugMode()) { |
| 80 | 80 | $this->debugLoad(); |
| 81 | - } else { |
|
| 82 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE); |
|
| 81 | + }else { |
|
| 82 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE); |
|
| 83 | 83 | } |
| 84 | 84 | $this->checkExternalModules(false); |
| 85 | 85 | $this->setLoaded(); |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $not_found_route = Config::getParam('route.404'); |
| 120 | - if(null !== $not_found_route) { |
|
| 120 | + if (null !== $not_found_route) { |
|
| 121 | 121 | Request::getInstance()->redirect($this->getRoute($not_found_route, true)); |
| 122 | - } else { |
|
| 122 | + }else { |
|
| 123 | 123 | return $template->render('error.html.twig', array( |
| 124 | 124 | 'exception' => $e, |
| 125 | 125 | 'trace' => $e->getTraceAsString(), |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | try { |
| 171 | 171 | //Search action and execute |
| 172 | 172 | $this->searchAction($route); |
| 173 | - } catch (AccessDeniedException $e) { |
|
| 174 | - Logger::log(_('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
| 173 | + }catch (AccessDeniedException $e) { |
|
| 174 | + Logger::log(_('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
| 175 | 175 | return Admin::staticAdminLogon($route); |
| 176 | - } catch (RouterException $r) { |
|
| 176 | + }catch (RouterException $r) { |
|
| 177 | 177 | Logger::log($r->getMessage(), LOG_WARNING); |
| 178 | - } catch (\Exception $e) { |
|
| 178 | + }catch (\Exception $e) { |
|
| 179 | 179 | Logger::log($e->getMessage(), LOG_ERR); |
| 180 | 180 | throw $e; |
| 181 | 181 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | protected function searchAction($route) |
| 194 | 194 | { |
| 195 | - Logger::log('Searching action to execute: ' . $route, LOG_INFO); |
|
| 195 | + Logger::log('Searching action to execute: '.$route, LOG_INFO); |
|
| 196 | 196 | //Revisamos si tenemos la ruta registrada |
| 197 | 197 | $parts = parse_url($route); |
| 198 | 198 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -207,12 +207,12 @@ discard block |
||
| 207 | 207 | /** @var $class \PSFS\base\types\Controller */ |
| 208 | 208 | $class = RouterHelper::getClassToCall($action); |
| 209 | 209 | try { |
| 210 | - if($this->checkRequirements($action, $get)) { |
|
| 210 | + if ($this->checkRequirements($action, $get)) { |
|
| 211 | 211 | $this->executeCachedRoute($route, $action, $class, $get); |
| 212 | - } else { |
|
| 212 | + }else { |
|
| 213 | 213 | throw new RouterException(_('La ruta no es válida'), 400); |
| 214 | 214 | } |
| 215 | - } catch (\Exception $e) { |
|
| 215 | + }catch (\Exception $e) { |
|
| 216 | 216 | Logger::log($e->getMessage(), LOG_ERR); |
| 217 | 217 | throw $e; |
| 218 | 218 | } |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | * @return bool |
| 228 | 228 | */ |
| 229 | 229 | private function checkRequirements(array $action, $params = []) { |
| 230 | - if(!empty($params) && !empty($action['requirements'])) { |
|
| 230 | + if (!empty($params) && !empty($action['requirements'])) { |
|
| 231 | 231 | $checked = 0; |
| 232 | - foreach(array_keys($params) as $key) { |
|
| 233 | - if(in_array($key, $action['requirements'], true)) { |
|
| 232 | + foreach (array_keys($params) as $key) { |
|
| 233 | + if (in_array($key, $action['requirements'], true)) { |
|
| 234 | 234 | $checked++; |
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | $valid = count($action['requirements']) === $checked; |
| 238 | - } else { |
|
| 238 | + }else { |
|
| 239 | 239 | $valid = true; |
| 240 | 240 | } |
| 241 | 241 | return $valid; |
@@ -285,14 +285,14 @@ discard block |
||
| 285 | 285 | $this->checkExternalModules(); |
| 286 | 286 | if (file_exists($modulesPath)) { |
| 287 | 287 | $modules = $this->finder->directories()->in($modulesPath)->depth(0); |
| 288 | - if($modules->hasResults()) { |
|
| 288 | + if ($modules->hasResults()) { |
|
| 289 | 289 | foreach ($modules->getIterator() as $modulePath) { |
| 290 | 290 | $module = $modulePath->getBasename(); |
| 291 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
| 291 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
| 295 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | $home_params = NULL; |
| 309 | 309 | foreach ($this->routing as $pattern => $params) { |
| 310 | 310 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
| 311 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
| 311 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
| 312 | 312 | $home_params = $params; |
| 313 | 313 | } |
| 314 | 314 | unset($method); |
@@ -330,14 +330,14 @@ discard block |
||
| 330 | 330 | private function inspectDir($origen, $namespace = 'PSFS', $routing = []) |
| 331 | 331 | { |
| 332 | 332 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name('*.php'); |
| 333 | - if($files->hasResults()) { |
|
| 333 | + if ($files->hasResults()) { |
|
| 334 | 334 | foreach ($files->getIterator() as $file) { |
| 335 | - if($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) { |
|
| 336 | - $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
| 337 | - } else { |
|
| 335 | + if ($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) { |
|
| 336 | + $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
| 337 | + }else { |
|
| 338 | 338 | $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname())); |
| 339 | 339 | } |
| 340 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
| 340 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | $this->finder = new Finder(); |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | private function addRouting($namespace, &$routing, $module = 'PSFS') |
| 367 | 367 | { |
| 368 | 368 | if (self::exists($namespace)) { |
| 369 | - if(I18nHelper::checkI18Class($namespace)) { |
|
| 369 | + if (I18nHelper::checkI18Class($namespace)) { |
|
| 370 | 370 | return $routing; |
| 371 | 371 | } |
| 372 | 372 | $reflection = new \ReflectionClass($namespace); |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | if (!$this->domains) { |
| 409 | 409 | $this->domains = []; |
| 410 | 410 | } |
| 411 | - $domain = '@' . $class->getConstant('DOMAIN') . '/'; |
|
| 411 | + $domain = '@'.$class->getConstant('DOMAIN').'/'; |
|
| 412 | 412 | if (!array_key_exists($domain, $this->domains)) { |
| 413 | 413 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
| 414 | 414 | } |
@@ -424,11 +424,11 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | public function simpatize() |
| 426 | 426 | { |
| 427 | - $translationFileName = 'translations' . DIRECTORY_SEPARATOR . 'routes_translations.php'; |
|
| 428 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
| 427 | + $translationFileName = 'translations'.DIRECTORY_SEPARATOR.'routes_translations.php'; |
|
| 428 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
| 429 | 429 | $this->generateSlugs($absoluteTranslationFileName); |
| 430 | 430 | GeneratorHelper::createDir(CONFIG_DIR); |
| 431 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
| 431 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
| 432 | 432 | |
| 433 | 433 | return $this; |
| 434 | 434 | } |
@@ -444,18 +444,18 @@ discard block |
||
| 444 | 444 | public function getRoute($slug = '', $absolute = FALSE, array $params = []) |
| 445 | 445 | { |
| 446 | 446 | if ('' === $slug) { |
| 447 | - return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
| 447 | + return $absolute ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
| 448 | 448 | } |
| 449 | 449 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
| 450 | 450 | throw new RouterException(_('No existe la ruta especificada')); |
| 451 | 451 | } |
| 452 | - $url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
| 452 | + $url = $absolute ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
| 453 | 453 | if (!empty($params)) { |
| 454 | 454 | foreach ($params as $key => $value) { |
| 455 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
| 455 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
| 456 | 456 | } |
| 457 | 457 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
| 458 | - $url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default']; |
|
| 458 | + $url = $absolute ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default']; |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -492,15 +492,15 @@ discard block |
||
| 492 | 492 | * @param string $method |
| 493 | 493 | */ |
| 494 | 494 | private function checkPreActions($class, $method) { |
| 495 | - $preAction = 'pre' . ucfirst($method); |
|
| 496 | - if(method_exists($class, $preAction)) { |
|
| 495 | + $preAction = 'pre'.ucfirst($method); |
|
| 496 | + if (method_exists($class, $preAction)) { |
|
| 497 | 497 | Logger::log(_('Pre action invoked')); |
| 498 | 498 | try { |
| 499 | - if(false === call_user_func_array([$class, $preAction])) { |
|
| 499 | + if (false === call_user_func_array([$class, $preAction])) { |
|
| 500 | 500 | Logger::log(_('Pre action failed'), LOG_ERR, [error_get_last()]); |
| 501 | 501 | error_clear_last(); |
| 502 | 502 | } |
| 503 | - } catch (\Exception $e) { |
|
| 503 | + }catch (\Exception $e) { |
|
| 504 | 504 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
| 505 | 505 | } |
| 506 | 506 | } |
@@ -516,16 +516,16 @@ discard block |
||
| 516 | 516 | */ |
| 517 | 517 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
| 518 | 518 | { |
| 519 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
| 519 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
| 520 | 520 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
| 521 | 521 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
| 522 | 522 | $cache = Cache::needCache(); |
| 523 | 523 | $execute = TRUE; |
| 524 | 524 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
| 525 | 525 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
| 526 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
| 526 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
| 527 | 527 | if (NULL !== $cachedData) { |
| 528 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
| 528 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
| 529 | 529 | Template::getInstance()->renderCache($cachedData, $headers); |
| 530 | 530 | $execute = FALSE; |
| 531 | 531 | } |
@@ -568,11 +568,11 @@ discard block |
||
| 568 | 568 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath) |
| 569 | 569 | { |
| 570 | 570 | $extModule = $modulePath->getBasename(); |
| 571 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
| 572 | - if(file_exists($moduleAutoloader)) { |
|
| 571 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
| 572 | + if (file_exists($moduleAutoloader)) { |
|
| 573 | 573 | include_once $moduleAutoloader; |
| 574 | 574 | if ($hydrateRoute) { |
| 575 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing); |
|
| 575 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing); |
|
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | 578 | } |
@@ -586,16 +586,16 @@ discard block |
||
| 586 | 586 | { |
| 587 | 587 | try { |
| 588 | 588 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
| 589 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
| 590 | - if(file_exists($externalModulePath)) { |
|
| 589 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
| 590 | + if (file_exists($externalModulePath)) { |
|
| 591 | 591 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
| 592 | - if($externalModule->hasResults()) { |
|
| 592 | + if ($externalModule->hasResults()) { |
|
| 593 | 593 | foreach ($externalModule->getIterator() as $modulePath) { |
| 594 | 594 | $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath); |
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | - } catch (\Exception $e) { |
|
| 598 | + }catch (\Exception $e) { |
|
| 599 | 599 | Logger::log($e->getMessage(), LOG_WARNING); |
| 600 | 600 | $module = null; |
| 601 | 601 | } |
@@ -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 |