@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | && (preg_match('/^\/(admin|setup\-admin)/i', $route) || Config::getParam('restricted', false)) |
| 35 | 35 | ) { |
| 36 | 36 | if (!self::isTest() && |
| 37 | - null === Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true)) { |
|
| 37 | + null === Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true)) { |
|
| 38 | 38 | throw new AdminCredentialsException(); |
| 39 | 39 | } |
| 40 | 40 | if (!Security::getInstance()->checkAdmin()) { |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | $token = ''; |
| 55 | 55 | $length = strlen($timestamp); |
| 56 | 56 | for ($i = 0; $i < $length; $i++) { |
| 57 | - $token = substr($hash, $i, 1) . |
|
| 58 | - substr($timestamp, $i, 1) . |
|
| 57 | + $token = substr($hash, $i, 1). |
|
| 58 | + substr($timestamp, $i, 1). |
|
| 59 | 59 | $token; |
| 60 | 60 | } |
| 61 | 61 | return $token; |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | $charsLength = strlen(self::RAND_SEP) - 1; |
| 75 | 75 | $tsLength = strlen($timestamp); |
| 76 | 76 | $i = 0; |
| 77 | - $partCount = ceil($hashRest / 4); |
|
| 78 | - $part = substr($hash, $tsLength + $partCount * $i, $partCount); |
|
| 77 | + $partCount = ceil($hashRest/4); |
|
| 78 | + $part = substr($hash, $tsLength + $partCount*$i, $partCount); |
|
| 79 | 79 | while (false !== $part && strlen($part) > 0) { |
| 80 | - $mixedToken .= $part . |
|
| 81 | - substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1) . |
|
| 80 | + $mixedToken .= $part. |
|
| 81 | + substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1). |
|
| 82 | 82 | substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1); |
| 83 | - $part = substr($hash, $tsLength + $partCount * $i, $partCount); |
|
| 83 | + $part = substr($hash, $tsLength + $partCount*$i, $partCount); |
|
| 84 | 84 | $i++; |
| 85 | 85 | } |
| 86 | - return $mixedToken . $token; |
|
| 86 | + return $mixedToken.$token; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | private static function getTs(bool $isOdd = null): int |
| 94 | 94 | { |
| 95 | 95 | $timestamp = time(); |
| 96 | - $tsIsOdd = (bool)((int)substr($timestamp, -1) % 2); |
|
| 96 | + $tsIsOdd = (bool)((int)substr($timestamp, -1)%2); |
|
| 97 | 97 | if (false === $isOdd && !$tsIsOdd) { |
| 98 | 98 | $timestamp--; |
| 99 | 99 | } elseif (true === $isOdd && !$tsIsOdd) { |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | $timestamp = ''; |
| 130 | 130 | $part = strrev($part); |
| 131 | 131 | for ($i = 0, $ct = strlen($part); $i < $ct; $i++) { |
| 132 | - if ($i % 2 == 0) { |
|
| 132 | + if ($i%2 == 0) { |
|
| 133 | 133 | $timestamp .= substr($part, $i, 1); |
| 134 | - } else { |
|
| 134 | + }else { |
|
| 135 | 135 | $partToken .= substr($part, $i, 1); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | list($partToken, $timestamp) = self::extractTs(array_pop($parts)); |
| 149 | 149 | $token = null; |
| 150 | 150 | if ($timestamp > 0) { |
| 151 | - $token = $partToken . implode('', $parts); |
|
| 151 | + $token = $partToken.implode('', $parts); |
|
| 152 | 152 | } |
| 153 | 153 | return [$token, $timestamp]; |
| 154 | 154 | } |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | */ |
| 97 | 97 | public static function extractFromDoc(string $needle, string $comments, string $default = null): ?string |
| 98 | 98 | { |
| 99 | - preg_match('/@' . $needle . '\ (.*)(\n|\r)/im', $comments, $matches); |
|
| 99 | + preg_match('/@'.$needle.'\ (.*)(\n|\r)/im', $comments, $matches); |
|
| 100 | 100 | return (count($matches) > 0) ? $matches[1] : $default; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -24,10 +24,10 @@ |
||
| 24 | 24 | $now = new DateTime(); |
| 25 | 25 | $now->setTimezone(new DateTimeZone(Config::getParam('project.timezone', 'Europe/Madrid'))); |
| 26 | 26 | $config = Config::getInstance()->dumpConfig(); |
| 27 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $config[self::CACHE_VAR_TAG] . '.file.cache')) { |
|
| 28 | - unlink(CACHE_DIR . DIRECTORY_SEPARATOR . $config[self::CACHE_VAR_TAG] . '.file.cache'); |
|
| 27 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$config[self::CACHE_VAR_TAG].'.file.cache')) { |
|
| 28 | + unlink(CACHE_DIR.DIRECTORY_SEPARATOR.$config[self::CACHE_VAR_TAG].'.file.cache'); |
|
| 29 | 29 | } |
| 30 | - $config[self::CACHE_VAR_TAG] = 'v' . $now->format('Ymd.His'); |
|
| 30 | + $config[self::CACHE_VAR_TAG] = 'v'.$now->format('Ymd.His'); |
|
| 31 | 31 | Config::save($config); |
| 32 | 32 | return $config[self::CACHE_VAR_TAG]; |
| 33 | 33 | } |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | // TODO check more en locales |
| 47 | 47 | if (strtolower($locale) === 'en') { |
| 48 | 48 | $locale = 'en_GB'; |
| 49 | - } else { |
|
| 50 | - $locale = $locale . '_' . strtoupper($locale); |
|
| 49 | + }else { |
|
| 50 | + $locale = $locale.'_'.strtoupper($locale); |
|
| 51 | 51 | } |
| 52 | 52 | $defaultLocales = explode(',', Config::getParam('i18n.locales', '')); |
| 53 | 53 | if (!in_array($locale, array_merge($defaultLocales, self::$langs))) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $translations = array(); |
| 67 | 67 | if (file_exists($absoluteFileName)) { |
| 68 | 68 | @include($absoluteFileName); |
| 69 | - } else { |
|
| 69 | + }else { |
|
| 70 | 70 | Cache::getInstance()->storeData($absoluteFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | public static function setLocale(string $default = null, string $customKey = null, bool $force = false): void |
| 84 | 84 | { |
| 85 | 85 | $locale = $force ? $default : self::extractLocale($default); |
| 86 | - Inspector::stats('[i18NHelper] Set locale to project [' . $locale . ']', Inspector::SCOPE_DEBUG); |
|
| 86 | + Inspector::stats('[i18NHelper] Set locale to project ['.$locale.']', Inspector::SCOPE_DEBUG); |
|
| 87 | 87 | // Load translations |
| 88 | - putenv("LC_ALL=" . $locale); |
|
| 88 | + putenv("LC_ALL=".$locale); |
|
| 89 | 89 | setlocale(LC_ALL, $locale); |
| 90 | 90 | // Load the locale path |
| 91 | - $localePath = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
| 92 | - Logger::log('Set locale dir ' . $localePath); |
|
| 91 | + $localePath = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
| 92 | + Logger::log('Set locale dir '.$localePath); |
|
| 93 | 93 | GeneratorHelper::createDir($localePath); |
| 94 | 94 | bindtextdomain('translations', $localePath); |
| 95 | 95 | textdomain('translations'); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | ['i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'], |
| 156 | 156 | ['o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'], |
| 157 | 157 | ['u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'], |
| 158 | - ['n', 'N', 'c', 'C',], |
|
| 158 | + ['n', 'N', 'c', 'C', ], |
|
| 159 | 159 | ]; |
| 160 | 160 | |
| 161 | 161 | $text = htmlspecialchars($string); |
@@ -175,24 +175,24 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public static function findTranslations(string $path, string $locale): array |
| 177 | 177 | { |
| 178 | - $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 179 | - $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
| 178 | + $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 179 | + $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
| 180 | 180 | |
| 181 | 181 | $translations = array(); |
| 182 | 182 | if (file_exists($path)) { |
| 183 | 183 | $directory = dir($path); |
| 184 | 184 | while (false !== ($fileName = $directory->read())) { |
| 185 | 185 | GeneratorHelper::createDir($localePath); |
| 186 | - if (!file_exists($localePath . 'translations.po')) { |
|
| 187 | - file_put_contents($localePath . 'translations.po', ''); |
|
| 186 | + if (!file_exists($localePath.'translations.po')) { |
|
| 187 | + file_put_contents($localePath.'translations.po', ''); |
|
| 188 | 188 | } |
| 189 | - $inspectPath = realpath($path . DIRECTORY_SEPARATOR . $fileName); |
|
| 190 | - $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext " . |
|
| 191 | - $inspectPath . DIRECTORY_SEPARATOR . |
|
| 189 | + $inspectPath = realpath($path.DIRECTORY_SEPARATOR.$fileName); |
|
| 190 | + $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext ". |
|
| 191 | + $inspectPath.DIRECTORY_SEPARATOR. |
|
| 192 | 192 | "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$localePath}translations.po"; |
| 193 | - if (is_dir($path . DIRECTORY_SEPARATOR . $fileName) && preg_match('/^\./', $fileName) == 0) { |
|
| 194 | - $res = t('Revisando directorio: ') . $inspectPath; |
|
| 195 | - $res .= t('Comando ejecutado: ') . $cmdPhp; |
|
| 193 | + if (is_dir($path.DIRECTORY_SEPARATOR.$fileName) && preg_match('/^\./', $fileName) == 0) { |
|
| 194 | + $res = t('Revisando directorio: ').$inspectPath; |
|
| 195 | + $res .= t('Comando ejecutado: ').$cmdPhp; |
|
| 196 | 196 | $res .= shell_exec($cmdPhp); |
| 197 | 197 | usleep(10); |
| 198 | 198 | $translations[] = $res; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | 'required' => $isRequired, |
| 44 | 44 | 'description' => $label, |
| 45 | 45 | ]; |
| 46 | - } else { |
|
| 46 | + }else { |
|
| 47 | 47 | $instance = new ReflectionClass($instanceType); |
| 48 | 48 | $variables[$property->getName()] = [ |
| 49 | 49 | 'is_array' => $isArray, |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public static function constructInjectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
| 161 | 161 | { |
| 162 | - Logger::log('Create inyectable instance for ' . $classNameSpace); |
|
| 162 | + Logger::log('Create inyectable instance for '.$classNameSpace); |
|
| 163 | 163 | $reflector = new ReflectionClass($calledClass); |
| 164 | 164 | $property = $reflector->getProperty($variable); |
| 165 | 165 | $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace; |
| 166 | 166 | if (true === $singleton && method_exists($varInstanceType, 'getInstance')) { |
| 167 | 167 | $instance = $varInstanceType::getInstance(); |
| 168 | - } else { |
|
| 168 | + }else { |
|
| 169 | 169 | $instance = new $varInstanceType(); |
| 170 | 170 | } |
| 171 | 171 | return $instance; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | public static function getClassProperties($class) |
| 180 | 180 | { |
| 181 | 181 | $properties = []; |
| 182 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
| 182 | + Logger::log('Extracting annotations properties from class '.$class); |
|
| 183 | 183 | $selfReflector = new ReflectionClass($class); |
| 184 | 184 | if (false !== $selfReflector->getParentClass()) { |
| 185 | 185 | $properties = self::getClassProperties($selfReflector->getParentClass()->getName()); |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | { |
| 53 | 53 | return [ |
| 54 | 54 | 'ts' => round($stats['ts'] - $timestamp, 4), |
| 55 | - 'mem' => round(($stats['mem'] - $mem) / 1024 / 1024, 4), |
|
| 55 | + 'mem' => round(($stats['mem'] - $mem)/1024/1024, 4), |
|
| 56 | 56 | 'files' => $stats['files'] - $files, |
| 57 | 57 | 'name' => $stats['name'], |
| 58 | 58 | ]; |
@@ -66,26 +66,26 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return string[] |
| 68 | 68 | */ |
| 69 | - public static function calculateAssetPath(string $string, string|null $name = null, bool $return = true, string $filenamePath = ''): array |
|
| 69 | + public static function calculateAssetPath(string $string, string | null $name = null, bool $return = true, string $filenamePath = ''): array |
|
| 70 | 70 | { |
| 71 | 71 | $path = explode("/", $string); |
| 72 | 72 | $originalFilename = end($path); |
| 73 | - $base = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 73 | + $base = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 74 | 74 | $debug = Config::getParam('debug'); |
| 75 | 75 | $cache = Config::getParam('cache.var'); |
| 76 | - $cache = $cache ? '.' . $cache : ''; |
|
| 76 | + $cache = $cache ? '.'.$cache : ''; |
|
| 77 | 77 | $finfo = finfo_open(FILEINFO_MIME_TYPE); // devuelve el tipo mime de su extensión |
| 78 | 78 | $mime = finfo_file($finfo, $filenamePath); |
| 79 | 79 | $extension = explode(".", $string); |
| 80 | 80 | $extension = end($extension); |
| 81 | - $file = "/" . substr(md5($string), 0, 8) . "." . $extension; |
|
| 81 | + $file = "/".substr(md5($string), 0, 8).".".$extension; |
|
| 82 | 82 | $htmlBase = ''; |
| 83 | 83 | finfo_close($finfo); |
| 84 | 84 | if (preg_match('/\.css$/i', $string)) { |
| 85 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.css"; |
|
| 85 | + $file = "/".substr(md5($string), 0, 8)."$cache.css"; |
|
| 86 | 86 | $htmlBase = "css"; |
| 87 | 87 | } elseif (preg_match('/\.js$/i', $string)) { |
| 88 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.js"; |
|
| 88 | + $file = "/".substr(md5($string), 0, 8)."$cache.js"; |
|
| 89 | 89 | $htmlBase = "js"; |
| 90 | 90 | } elseif (preg_match("/image/i", $mime)) { |
| 91 | 91 | $htmlBase = "img"; |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | $file = $name; |
| 100 | 100 | } |
| 101 | 101 | if ($debug) { |
| 102 | - $file = str_replace("." . $extension, "_" . $originalFilename, $file); |
|
| 102 | + $file = str_replace(".".$extension, "_".$originalFilename, $file); |
|
| 103 | 103 | } |
| 104 | - $filePath = $htmlBase . $file; |
|
| 104 | + $filePath = $htmlBase.$file; |
|
| 105 | 105 | |
| 106 | 106 | return array($base, $htmlBase, $filePath); |
| 107 | 107 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | { |
| 117 | 117 | GeneratorHelper::createDir(dirname($path)); |
| 118 | 118 | if ("" !== $content && false === file_put_contents($path, $content)) { |
| 119 | - throw new ConfigException(t('No se tienen permisos para escribir en ' . $path)); |
|
| 119 | + throw new ConfigException(t('No se tienen permisos para escribir en '.$path)); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -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 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 | } |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | //Generating the templates translations |
| 45 | 45 | $translations = $this->tpl->regenerateTemplates(); |
| 46 | 46 | |
| 47 | - $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 48 | - $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
| 47 | + $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 48 | + $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
| 49 | 49 | |
| 50 | 50 | //xgettext localizations |
| 51 | 51 | $translations = array_merge($translations, I18nHelper::findTranslations(SOURCE_DIR, $locale)); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $translations = array_merge($translations, I18nHelper::findTranslations(CACHE_DIR, $locale)); |
| 54 | 54 | |
| 55 | 55 | $translations[] = "msgfmt {$localePath}translations.po -o {$localePath}translations.mo"; |
| 56 | - $translations[] = shell_exec('export PATH=\$PATH:/opt/local/bin:/bin:/sbin; msgfmt ' . $localePath . 'translations.po -o ' . $localePath . 'translations.mo'); |
|
| 56 | + $translations[] = shell_exec('export PATH=\$PATH:/opt/local/bin:/bin:/sbin; msgfmt '.$localePath.'translations.po -o '.$localePath.'translations.mo'); |
|
| 57 | 57 | return $this->render('translations.html.twig', array( |
| 58 | 58 | 'translations' => $translations, |
| 59 | 59 | )); |