@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | foreach ($compiledFiles as $file) { |
| 24 | 24 | echo "\t\t<script type='text/javascript' src='{$file}'></script>\n"; |
| 25 | 25 | } |
| 26 | - } else { |
|
| 27 | - echo "\t\t<script type='text/javascript' src='" . $baseUrl . "/js/" . $hash . ".js'></script>\n"; |
|
| 26 | + }else { |
|
| 27 | + echo "\t\t<script type='text/javascript' src='".$baseUrl."/js/".$hash.".js'></script>\n"; |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | protected function putDebugJs($pathParts, $base, $file, $hash, array &$compiledFiles) |
| 41 | 41 | { |
| 42 | - $filePath = $hash . "_" . $pathParts[count($pathParts) - 1]; |
|
| 43 | - $compiledFiles[] = "/js/" . $filePath; |
|
| 42 | + $filePath = $hash."_".$pathParts[count($pathParts) - 1]; |
|
| 43 | + $compiledFiles[] = "/js/".$filePath; |
|
| 44 | 44 | $data = ""; |
| 45 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file)) { |
|
| 45 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file)) { |
|
| 46 | 46 | $data = file_get_contents($file); |
| 47 | - AssetsHelper::storeContents($base . $filePath, $data); |
|
| 47 | + AssetsHelper::storeContents($base.$filePath, $data); |
|
| 48 | 48 | } |
| 49 | 49 | return $data; |
| 50 | 50 | } |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | protected function compileJs(array $files, $basePath, $hash, array &$compiledFiles) |
| 62 | 62 | { |
| 63 | - $base = $basePath . "js" . DIRECTORY_SEPARATOR; |
|
| 63 | + $base = $basePath."js".DIRECTORY_SEPARATOR; |
|
| 64 | 64 | $debug = Config::getParam('debug'); |
| 65 | - if ($debug || !file_exists($base . $hash . ".js")) { |
|
| 65 | + if ($debug || !file_exists($base.$hash.".js")) { |
|
| 66 | 66 | $data = ''; |
| 67 | 67 | if (0 < count($files)) { |
| 68 | 68 | $minifier = new JS(); |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | if (file_exists($file)) { |
| 72 | 72 | if ($debug) { |
| 73 | 73 | $data = $this->putDebugJs($pathParts, $base, $file, $hash, $compiledFiles); |
| 74 | - } elseif (!file_exists($base . $hash . ".js")) { |
|
| 74 | + } elseif (!file_exists($base.$hash.".js")) { |
|
| 75 | 75 | $minifier->add($file); |
| 76 | 76 | //$data = $this->putProductionJs($base, $file, $data); |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | - if($debug) { |
|
| 81 | - AssetsHelper::storeContents($base . $hash . ".js", $data); |
|
| 82 | - } else { |
|
| 80 | + if ($debug) { |
|
| 81 | + AssetsHelper::storeContents($base.$hash.".js", $data); |
|
| 82 | + }else { |
|
| 83 | 83 | $this->dumpJs($hash, $base, $minifier); |
| 84 | 84 | } |
| 85 | 85 | unset($minifier); |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | ini_set('memory_limit', -1); |
| 101 | 101 | GeneratorHelper::createDir($base); |
| 102 | 102 | if (Config::getParam('assets.obfuscate', false)) { |
| 103 | - $minifier->gzip($base . $hash . ".js"); |
|
| 104 | - } else { |
|
| 105 | - $minifier->minify($base . $hash . ".js"); |
|
| 103 | + $minifier->gzip($base.$hash.".js"); |
|
| 104 | + }else { |
|
| 105 | + $minifier->minify($base.$hash.".js"); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | protected function compileCss($basePath, $hash) |
| 30 | 30 | { |
| 31 | 31 | $debug = Config::getParam('debug'); |
| 32 | - $base = $basePath . "css" . DIRECTORY_SEPARATOR; |
|
| 33 | - if ($debug || !file_exists($base . $hash . ".css")) { |
|
| 32 | + $base = $basePath."css".DIRECTORY_SEPARATOR; |
|
| 33 | + if ($debug || !file_exists($base.$hash.".css")) { |
|
| 34 | 34 | $data = ''; |
| 35 | 35 | if (0 < count($this->files)) { |
| 36 | 36 | $minifier = new CSS(); |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | $data = $this->processCssLine($file, $base, $data, $hash); |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | - if($debug) { |
|
| 42 | - AssetsHelper::storeContents($base . $hash . ".css", $data); |
|
| 43 | - } else { |
|
| 41 | + if ($debug) { |
|
| 42 | + AssetsHelper::storeContents($base.$hash.".css", $data); |
|
| 43 | + }else { |
|
| 44 | 44 | $minifier = new CSS(); |
| 45 | 45 | $minifier->add($data); |
| 46 | 46 | ini_set('max_execution_time', -1); |
| 47 | 47 | ini_set('memory_limit', -1); |
| 48 | 48 | GeneratorHelper::createDir($base); |
| 49 | - $minifier->minify($base . $hash . ".css"); |
|
| 49 | + $minifier->minify($base.$hash.".css"); |
|
| 50 | 50 | } |
| 51 | 51 | unset($minifier); |
| 52 | 52 | } |
@@ -66,21 +66,21 @@ discard block |
||
| 66 | 66 | if (file_exists($file)) { |
| 67 | 67 | $debug = Config::getParam('debug'); |
| 68 | 68 | $pathParts = explode("/", $file); |
| 69 | - $filePath = $this->hash . "_" . $pathParts[count($pathParts) - 1]; |
|
| 70 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file) || $debug) { |
|
| 69 | + $filePath = $this->hash."_".$pathParts[count($pathParts) - 1]; |
|
| 70 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file) || $debug) { |
|
| 71 | 71 | //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados |
| 72 | - if (file_exists($base . $hash . ".css") && @unlink($base . $hash . ".css") === false) { |
|
| 73 | - throw new ConfigException("Can't unlink file " . $base . $hash . ".css"); |
|
| 72 | + if (file_exists($base.$hash.".css") && @unlink($base.$hash.".css") === false) { |
|
| 73 | + throw new ConfigException("Can't unlink file ".$base.$hash.".css"); |
|
| 74 | 74 | } |
| 75 | 75 | $this->loopCssLines($file); |
| 76 | 76 | } |
| 77 | 77 | if ($debug) { |
| 78 | 78 | $data = file_get_contents($file); |
| 79 | - AssetsHelper::storeContents($base . $filePath, $data); |
|
| 80 | - } else { |
|
| 79 | + AssetsHelper::storeContents($base.$filePath, $data); |
|
| 80 | + }else { |
|
| 81 | 81 | $data .= file_get_contents($file); |
| 82 | 82 | } |
| 83 | - $this->compiledFiles[] = "/css/" . $filePath; |
|
| 83 | + $this->compiledFiles[] = "/css/".$filePath; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $data; |
@@ -113,20 +113,20 @@ discard block |
||
| 113 | 113 | protected function extractCssResources($source, $file) |
| 114 | 114 | { |
| 115 | 115 | $sourceFile = AssetsHelper::extractSourceFilename($source); |
| 116 | - $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $sourceFile); |
|
| 116 | + $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$sourceFile); |
|
| 117 | 117 | $origPart = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig); |
| 118 | 118 | try { |
| 119 | 119 | if (count($source) > 1 && array_key_exists(1, $origPart)) { |
| 120 | - $dest = $this->path . $origPart[1]; |
|
| 120 | + $dest = $this->path.$origPart[1]; |
|
| 121 | 121 | GeneratorHelper::createDir(dirname($dest)); |
| 122 | 122 | if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) { |
| 123 | 123 | if (@copy($orig, $dest) === FALSE) { |
| 124 | - throw new \RuntimeException('Can\' copy ' . $dest . ''); |
|
| 124 | + throw new \RuntimeException('Can\' copy '.$dest.''); |
|
| 125 | 125 | } |
| 126 | 126 | Logger::log("$orig copiado a $dest", LOG_INFO); |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | - } catch (\Exception $e) { |
|
| 129 | + }catch (\Exception $e) { |
|
| 130 | 130 | Logger::log($e->getMessage(), LOG_ERR); |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | foreach ($compiledFiles as $file) { |
| 143 | 143 | echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>"; |
| 144 | 144 | } |
| 145 | - } else { |
|
| 146 | - echo "\t\t<link href='" . $baseUrl . "/css/" . $hash . ".css' rel='stylesheet'>"; |
|
| 145 | + }else { |
|
| 146 | + echo "\t\t<link href='".$baseUrl."/css/".$hash.".css' rel='stylesheet'>"; |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | public function __construct($type = 'js') |
| 52 | 52 | { |
| 53 | 53 | $this->type = $type; |
| 54 | - $this->path = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 54 | + $this->path = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 55 | 55 | $this->domains = Template::getDomains(true); |
| 56 | 56 | $this->cdnPath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl()); |
| 57 | 57 | } |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function addFile($filename) |
| 66 | 66 | { |
| 67 | - if (file_exists($this->path . $filename) && preg_match('/\.' . $this->type . '$/i', $filename)) { |
|
| 67 | + if (file_exists($this->path.$filename) && preg_match('/\.'.$this->type.'$/i', $filename)) { |
|
| 68 | 68 | $this->files[] = $filename; |
| 69 | 69 | } elseif (!empty($this->domains)) { |
| 70 | 70 | foreach ($this->domains as $domain => $paths) { |
| 71 | 71 | $domainFilename = str_replace($domain, $paths["public"], $filename); |
| 72 | - if (file_exists($domainFilename) && preg_match('/\.' . $this->type . '$/i', $domainFilename)) { |
|
| 72 | + if (file_exists($domainFilename) && preg_match('/\.'.$this->type.'$/i', $domainFilename)) { |
|
| 73 | 73 | $this->files[] = $domainFilename; |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | public function setHash($hash) |
| 87 | 87 | { |
| 88 | 88 | $cache = Config::getParam('cache.var', ''); |
| 89 | - $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache; |
|
| 89 | + $this->hash = $hash.(strlen($cache) ? '.' : '').$cache; |
|
| 90 | 90 | return $this; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function getAdmins() |
| 66 | 66 | { |
| 67 | - return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true); |
|
| 67 | + return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | if (!empty($user) && !empty($admins[$user])) { |
| 91 | 91 | $auth = $admins[$user]['hash']; |
| 92 | - $this->authorized = ($auth === sha1($user . $pass)); |
|
| 92 | + $this->authorized = ($auth === sha1($user.$pass)); |
|
| 93 | 93 | if ($this->authorized) { |
| 94 | 94 | $this->updateAdmin($user, $admins[$user]['profile']); |
| 95 | 95 | ResponseHelper::setCookieHeaders([ |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | ]); |
| 103 | 103 | $this->setSessionKey(self::LOGGED_USER_TOKEN, base64_encode("{$user}:{$pass}")); |
| 104 | 104 | } |
| 105 | - } else { |
|
| 105 | + }else { |
|
| 106 | 106 | $this->admin = null; |
| 107 | 107 | $this->setSessionKey(self::ADMIN_ID_TOKEN, null); |
| 108 | 108 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function hasSessionKey($key) { |
| 33 | 33 | $exists = false; |
| 34 | - if(array_key_exists($key, $this->session)) { |
|
| 34 | + if (array_key_exists($key, $this->session)) { |
|
| 35 | 35 | $exists = true; |
| 36 | 36 | } |
| 37 | 37 | return $exists; |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | session_start(); |
| 57 | 57 | } |
| 58 | 58 | // Fix for phpunits |
| 59 | - if(!isset($_SESSION)) { |
|
| 59 | + if (!isset($_SESSION)) { |
|
| 60 | 60 | $_SESSION = []; |
| 61 | 61 | } |
| 62 | 62 | $this->session = null === $_SESSION ? [] : $_SESSION; |
@@ -86,11 +86,11 @@ |
||
| 86 | 86 | public static function save($user) |
| 87 | 87 | { |
| 88 | 88 | $saved = true; |
| 89 | - $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 90 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
| 89 | + $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 90 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
| 91 | 91 | $admins[$user['username']]['profile'] = $user['profile']; |
| 92 | 92 | |
| 93 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true); |
|
| 93 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true); |
|
| 94 | 94 | return $saved; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -69,21 +69,21 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | $path = explode("/", $string); |
| 71 | 71 | $originalFilename = end($path); |
| 72 | - $base = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 72 | + $base = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 73 | 73 | $debug = Config::getParam('debug'); |
| 74 | 74 | $cache = Config::getParam('cache.var'); |
| 75 | - $cache = $cache ? '.' . $cache : ''; |
|
| 75 | + $cache = $cache ? '.'.$cache : ''; |
|
| 76 | 76 | $finfo = finfo_open(FILEINFO_MIME_TYPE); // devuelve el tipo mime de su extensión |
| 77 | 77 | $mime = finfo_file($finfo, $filenamePath); |
| 78 | 78 | $extension = explode(".", $string); |
| 79 | 79 | $extension = end($extension); |
| 80 | - $file = "/" . substr(md5($string), 0, 8) . "." . $extension; |
|
| 80 | + $file = "/".substr(md5($string), 0, 8).".".$extension; |
|
| 81 | 81 | finfo_close($finfo); |
| 82 | 82 | if (preg_match('/\.css$/i', $string)) { |
| 83 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.css"; |
|
| 83 | + $file = "/".substr(md5($string), 0, 8)."$cache.css"; |
|
| 84 | 84 | $htmlBase = "css"; |
| 85 | 85 | } elseif (preg_match('/\.js$/i', $string)) { |
| 86 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.js"; |
|
| 86 | + $file = "/".substr(md5($string), 0, 8)."$cache.js"; |
|
| 87 | 87 | $htmlBase = "js"; |
| 88 | 88 | } elseif (preg_match("/image/i", $mime)) { |
| 89 | 89 | $htmlBase = "img"; |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | $file = $name; |
| 99 | 99 | } |
| 100 | 100 | if ($debug) { |
| 101 | - $file = str_replace("." . $extension, "_" . $originalFilename, $file); |
|
| 101 | + $file = str_replace(".".$extension, "_".$originalFilename, $file); |
|
| 102 | 102 | } |
| 103 | - $filePath = $htmlBase . $file; |
|
| 103 | + $filePath = $htmlBase.$file; |
|
| 104 | 104 | |
| 105 | 105 | return array($base, $htmlBase, $filePath); |
| 106 | 106 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | GeneratorHelper::createDir(dirname($path)); |
| 117 | 117 | if ("" !== $content && false === file_put_contents($path, $content)) { |
| 118 | - throw new ConfigException(t('No se tienen permisos para escribir en ' . $path)); |
|
| 118 | + throw new ConfigException(t('No se tienen permisos para escribir en '.$path)); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | */ |
| 70 | 70 | public function swaggerUi($domain) |
| 71 | 71 | { |
| 72 | - if(!Router::getInstance()->domainExists($domain)) { |
|
| 72 | + if (!Router::getInstance()->domainExists($domain)) { |
|
| 73 | 73 | throw new RouterException('Domains is empty'); |
| 74 | 74 | } |
| 75 | 75 | return $this->render('swagger.html.twig', [ |
@@ -38,9 +38,9 @@ |
||
| 38 | 38 | if (self::isTest()) { |
| 39 | 39 | throw new UserAuthException(); |
| 40 | 40 | } |
| 41 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 41 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 42 | 42 | return AdminServices::getInstance()->setAdminHeaders(); |
| 43 | - } else { |
|
| 43 | + }else { |
|
| 44 | 44 | return UserController::showAdminManager(); |
| 45 | 45 | } |
| 46 | 46 | } |