@@ -202,7 +202,7 @@ |
||
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | 204 | * Método que fuerza la descarga de un fichero |
| 205 | - * @param $data |
|
| 205 | + * @param string $data |
|
| 206 | 206 | * @param string $content |
| 207 | 207 | * @param string $filename |
| 208 | 208 | * @return mixed |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $this->setStatusCode(Template::STATUS_OK); |
| 121 | 121 | break; |
| 122 | 122 | default: |
| 123 | - $this->setStatusCode('HTTP/1.0 ' . $status ?: 200); |
|
| 123 | + $this->setStatusCode('HTTP/1.0 '.$status ?: 200); |
|
| 124 | 124 | break; |
| 125 | 125 | } |
| 126 | 126 | return $this; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
| 139 | 139 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
| 140 | 140 | ResponseHelper::setCookieHeaders($cookies); |
| 141 | - header('Content-type: ' . $contentType); |
|
| 141 | + header('Content-type: '.$contentType); |
|
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
@@ -154,15 +154,15 @@ discard block |
||
| 154 | 154 | Logger::log('Start output response'); |
| 155 | 155 | ob_start(); |
| 156 | 156 | $this->setReponseHeaders($contentType, $cookies); |
| 157 | - header('Content-length: ' . strlen($output)); |
|
| 157 | + header('Content-length: '.strlen($output)); |
|
| 158 | 158 | |
| 159 | 159 | $needCache = Cache::needCache(); |
| 160 | 160 | $cache = Cache::getInstance(); |
| 161 | 161 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
| 162 | 162 | if (false !== $needCache && $this->getStatusCode() === Template::STATUS_OK && null !== $cacheDataName) { |
| 163 | 163 | Logger::log('Saving output response into cache'); |
| 164 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
| 165 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", headers_list(), Cache::JSON); |
|
| 164 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
| 165 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", headers_list(), Cache::JSON); |
|
| 166 | 166 | } elseif (Request::getInstance()->getMethod() !== 'GET') { |
| 167 | 167 | $cache->flushCache(); |
| 168 | 168 | } |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | Logger::log('Close template render'); |
| 183 | 183 | $uri = Request::requestUri(); |
| 184 | 184 | Security::getInstance()->setSessionKey("lastRequest", array( |
| 185 | - "url" => Request::getInstance()->getRootUrl() . $uri, |
|
| 185 | + "url" => Request::getInstance()->getRootUrl().$uri, |
|
| 186 | 186 | "ts" => microtime(true), |
| 187 | 187 | )); |
| 188 | 188 | Security::getInstance()->updateSession(); |
| 189 | - Logger::log('End request: ' . $uri, LOG_INFO); |
|
| 189 | + Logger::log('End request: '.$uri, LOG_INFO); |
|
| 190 | 190 | exit; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -224,17 +224,17 @@ discard block |
||
| 224 | 224 | ///////////////////////////////////////////////////////////// |
| 225 | 225 | // Date in the past sets the value to already have been expired. |
| 226 | 226 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
| 227 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 227 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
| 228 | 228 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
| 229 | 229 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
| 230 | 230 | header("Pragma: no-cache"); |
| 231 | 231 | header("Expires: 0"); |
| 232 | 232 | header('Content-Transfer-Encoding: binary'); |
| 233 | - header("Content-type: " . $content); |
|
| 234 | - header("Content-length: " . strlen($data)); |
|
| 235 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 233 | + header("Content-type: ".$content); |
|
| 234 | + header("Content-length: ".strlen($data)); |
|
| 235 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 236 | 236 | header("Access-Control-Expose-Headers: Filename"); |
| 237 | - header("Filename: " . $filename); |
|
| 237 | + header("Filename: ".$filename); |
|
| 238 | 238 | echo $data; |
| 239 | 239 | ob_flush(); |
| 240 | 240 | ob_end_clean(); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $download = $this->getRequest()->get('download') ?: false; |
| 34 | 34 | |
| 35 | 35 | $module = $this->srv->getModules($domain); |
| 36 | - if(empty($module)) { |
|
| 36 | + if (empty($module)) { |
|
| 37 | 37 | return Router::getInstance()->httpNotFound(null, true); |
| 38 | 38 | } |
| 39 | 39 | switch (strtolower($type)) { |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | ini_restore('max_execution_time'); |
| 54 | 54 | ini_restore('memory_limit'); |
| 55 | 55 | |
| 56 | - if($download && $type === ApiController::SWAGGER_DOC) { |
|
| 56 | + if ($download && $type === ApiController::SWAGGER_DOC) { |
|
| 57 | 57 | return $this->download(\GuzzleHttp\json_encode($doc), 'application/json', 'swagger.json'); |
| 58 | - } elseif($type === ApiController::HTML_DOC) { |
|
| 58 | + } elseif ($type === ApiController::HTML_DOC) { |
|
| 59 | 59 | return $this->render('documentation.html.twig', ["data" => json_encode($doc)]); |
| 60 | - } else { |
|
| 60 | + }else { |
|
| 61 | 61 | return $this->json($doc, 200); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $dump = ''; |
| 112 | 112 | try { |
| 113 | 113 | $dump = $this->tpl->render($tpl, $vars); |
| 114 | - } catch (\Exception $e) { |
|
| 114 | + }catch (\Exception $e) { |
|
| 115 | 115 | Logger::log($e->getMessage(), LOG_ERR); |
| 116 | 116 | } |
| 117 | 117 | return $dump; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | public function regenerateTemplates() |
| 139 | 139 | { |
| 140 | 140 | $this->generateTemplatesCache(); |
| 141 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true); |
|
| 141 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true); |
|
| 142 | 142 | $translations = []; |
| 143 | 143 | if (is_array($domains)) { |
| 144 | 144 | $translations = $this->parsePathTranslations($domains); |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | // force compilation |
| 161 | 161 | if ($file->isFile()) { |
| 162 | 162 | try { |
| 163 | - $this->tpl->load(str_replace($tplDir . '/', '', $file)); |
|
| 164 | - } catch (\Exception $e) { |
|
| 163 | + $this->tpl->load(str_replace($tplDir.'/', '', $file)); |
|
| 164 | + }catch (\Exception $e) { |
|
| 165 | 165 | Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]); |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | 'existsFlash' => TemplateFunctions::EXISTS_FLASH_FUNCTION, |
| 222 | 222 | 'getFlash' => TemplateFunctions::GET_FLASH_FUNCTION, |
| 223 | 223 | ]; |
| 224 | - foreach($functions as $name => $function) { |
|
| 224 | + foreach ($functions as $name => $function) { |
|
| 225 | 225 | $this->addTemplateFunction($name, $function); |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | private function loadDomains() |
| 242 | 242 | { |
| 243 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
| 243 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
| 244 | 244 | if (null !== $domains) { |
| 245 | 245 | foreach ($domains as $domain => $paths) { |
| 246 | 246 | $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain)); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | { |
| 256 | 256 | $loader = new \Twig_Loader_Filesystem(GeneratorHelper::getTemplatePath()); |
| 257 | 257 | $this->tpl = new \Twig_Environment($loader, array( |
| 258 | - 'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig', |
|
| 258 | + 'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig', |
|
| 259 | 259 | 'debug' => (bool)$this->debug, |
| 260 | 260 | 'auto_reload' => Config::getParam('twig.autoreload', TRUE), |
| 261 | 261 | )); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function __construct($type = 'js') |
| 34 | 34 | { |
| 35 | 35 | $this->type = $type; |
| 36 | - $this->path = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 36 | + $this->path = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 37 | 37 | $this->domains = Template::getDomains(true); |
| 38 | 38 | $this->debug = Config::getInstance()->getDebugMode(); |
| 39 | 39 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $source_file = explode("?", $source_file); |
| 56 | 56 | $source_file = $source_file[0]; |
| 57 | 57 | } |
| 58 | - $orig = realpath(dirname($filename_path) . DIRECTORY_SEPARATOR . $source_file); |
|
| 58 | + $orig = realpath(dirname($filename_path).DIRECTORY_SEPARATOR.$source_file); |
|
| 59 | 59 | return $orig; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function addFile($filename) |
| 70 | 70 | { |
| 71 | - if (file_exists($this->path . $filename) && preg_match('/\.' . $this->type . '$/i', $filename)) { |
|
| 71 | + if (file_exists($this->path.$filename) && preg_match('/\.'.$this->type.'$/i', $filename)) { |
|
| 72 | 72 | $this->files[] = $filename; |
| 73 | 73 | } elseif (!empty($this->domains)) { |
| 74 | 74 | foreach ($this->domains as $domain => $paths) { |
| 75 | 75 | $domain_filename = str_replace($domain, $paths["public"], $filename); |
| 76 | - if (file_exists($domain_filename) && preg_match('/\.' . $this->type . '$/i', $domain_filename)) { |
|
| 76 | + if (file_exists($domain_filename) && preg_match('/\.'.$this->type.'$/i', $domain_filename)) { |
|
| 77 | 77 | $this->files[] = $domain_filename; |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | public function setHash($hash) |
| 91 | 91 | { |
| 92 | 92 | $cache = Config::getParam('cache.var', ''); |
| 93 | - $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache; |
|
| 93 | + $this->hash = $hash.(strlen($cache) ? '.' : '').$cache; |
|
| 94 | 94 | return $this; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | protected function compileCss() |
| 126 | 126 | { |
| 127 | - $base = $this->path . "css" . DIRECTORY_SEPARATOR; |
|
| 128 | - if ($this->debug || !file_exists($base . $this->hash . ".css")) { |
|
| 127 | + $base = $this->path."css".DIRECTORY_SEPARATOR; |
|
| 128 | + if ($this->debug || !file_exists($base.$this->hash.".css")) { |
|
| 129 | 129 | $data = ''; |
| 130 | 130 | if (0 < count($this->files)) { |
| 131 | 131 | $minifier = new CSS(); |
@@ -133,15 +133,15 @@ discard block |
||
| 133 | 133 | $data = $this->processCssLine($file, $base, $data); |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | - if($this->debug) { |
|
| 137 | - $this->storeContents($base . $this->hash . ".css", $data); |
|
| 138 | - } else { |
|
| 136 | + if ($this->debug) { |
|
| 137 | + $this->storeContents($base.$this->hash.".css", $data); |
|
| 138 | + }else { |
|
| 139 | 139 | $minifier = new CSS(); |
| 140 | 140 | $minifier->add($data); |
| 141 | 141 | ini_set('max_execution_time', -1); |
| 142 | 142 | ini_set('memory_limit', -1); |
| 143 | 143 | GeneratorHelper::createDir($base); |
| 144 | - $minifier->minify($base . $this->hash . ".css"); |
|
| 144 | + $minifier->minify($base.$this->hash.".css"); |
|
| 145 | 145 | unset($cssMinifier); |
| 146 | 146 | ini_restore('memory_limit'); |
| 147 | 147 | ini_restore('max_execution_time'); |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function compileJs() |
| 159 | 159 | { |
| 160 | - $base = $this->path . "js" . DIRECTORY_SEPARATOR; |
|
| 161 | - if ($this->debug || !file_exists($base . $this->hash . ".js")) { |
|
| 160 | + $base = $this->path."js".DIRECTORY_SEPARATOR; |
|
| 161 | + if ($this->debug || !file_exists($base.$this->hash.".js")) { |
|
| 162 | 162 | $data = ''; |
| 163 | 163 | if (0 < count($this->files)) { |
| 164 | 164 | $minifier = new JS(); |
@@ -167,19 +167,19 @@ discard block |
||
| 167 | 167 | if (file_exists($file)) { |
| 168 | 168 | if ($this->debug) { |
| 169 | 169 | $data = $this->putDebugJs($path_parts, $base, $file); |
| 170 | - } elseif (!file_exists($base . $this->hash . ".js")) { |
|
| 170 | + } elseif (!file_exists($base.$this->hash.".js")) { |
|
| 171 | 171 | $minifier->add($file); |
| 172 | 172 | //$data = $this->putProductionJs($base, $file, $data); |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | - if($this->debug) { |
|
| 177 | - $this->storeContents($base . $this->hash . ".js", $data); |
|
| 178 | - } else { |
|
| 176 | + if ($this->debug) { |
|
| 177 | + $this->storeContents($base.$this->hash.".js", $data); |
|
| 178 | + }else { |
|
| 179 | 179 | ini_set('max_execution_time', -1); |
| 180 | 180 | ini_set('memory_limit', -1); |
| 181 | 181 | GeneratorHelper::createDir($base); |
| 182 | - $minifier->minify($base . $this->hash . ".js"); |
|
| 182 | + $minifier->minify($base.$this->hash.".js"); |
|
| 183 | 183 | ini_restore('memory_limit'); |
| 184 | 184 | ini_restore('max_execution_time'); |
| 185 | 185 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | GeneratorHelper::createDir(dirname($path)); |
| 201 | 201 | if ("" !== $content && false === file_put_contents($path, $content)) { |
| 202 | - throw new ConfigException(_('No se tienen permisos para escribir en ' . $path)); |
|
| 202 | + throw new ConfigException(_('No se tienen permisos para escribir en '.$path)); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | foreach ($this->compiled_files as $file) { |
| 229 | 229 | echo "\t\t<script type='text/javascript' src='{$file}'></script>\n"; |
| 230 | 230 | } |
| 231 | - } else { |
|
| 232 | - echo "\t\t<script type='text/javascript' src='/js/" . $this->hash . ".js'></script>\n"; |
|
| 231 | + }else { |
|
| 232 | + echo "\t\t<script type='text/javascript' src='/js/".$this->hash.".js'></script>\n"; |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | foreach ($this->compiled_files as $file) { |
| 243 | 243 | echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>"; |
| 244 | 244 | } |
| 245 | - } else { |
|
| 246 | - echo "\t\t<link href='/css/" . $this->hash . ".css' rel='stylesheet'>"; |
|
| 245 | + }else { |
|
| 246 | + echo "\t\t<link href='/css/".$this->hash.".css' rel='stylesheet'>"; |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
@@ -254,20 +254,20 @@ discard block |
||
| 254 | 254 | protected function extractCssResources($source, $file) |
| 255 | 255 | { |
| 256 | 256 | $source_file = $this->extractSourceFilename($source); |
| 257 | - $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $source_file); |
|
| 257 | + $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$source_file); |
|
| 258 | 258 | $orig_part = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig); |
| 259 | 259 | try { |
| 260 | 260 | if (count($source) > 1 && array_key_exists(1, $orig_part)) { |
| 261 | - $dest = $this->path . $orig_part[1]; |
|
| 261 | + $dest = $this->path.$orig_part[1]; |
|
| 262 | 262 | GeneratorHelper::createDir(dirname($dest)); |
| 263 | 263 | if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) { |
| 264 | 264 | if (@copy($orig, $dest) === FALSE) { |
| 265 | - throw new \RuntimeException('Can\' copy ' . $dest . ''); |
|
| 265 | + throw new \RuntimeException('Can\' copy '.$dest.''); |
|
| 266 | 266 | } |
| 267 | 267 | Logger::log("$orig copiado a $dest", LOG_INFO); |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | - } catch (\Exception $e) { |
|
| 270 | + }catch (\Exception $e) { |
|
| 271 | 271 | Logger::log($e->getMessage(), LOG_ERR); |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -284,21 +284,21 @@ discard block |
||
| 284 | 284 | { |
| 285 | 285 | if (file_exists($file)) { |
| 286 | 286 | $path_parts = explode("/", $file); |
| 287 | - $file_path = $this->hash . "_" . $path_parts[count($path_parts) - 1]; |
|
| 288 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($file) || $this->debug) { |
|
| 287 | + $file_path = $this->hash."_".$path_parts[count($path_parts) - 1]; |
|
| 288 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($file) || $this->debug) { |
|
| 289 | 289 | //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados |
| 290 | - if (file_exists($base . $this->hash . ".css") && @unlink($base . $this->hash . ".css") === false) { |
|
| 291 | - throw new ConfigException("Can't unlink file " . $base . $this->hash . ".css"); |
|
| 290 | + if (file_exists($base.$this->hash.".css") && @unlink($base.$this->hash.".css") === false) { |
|
| 291 | + throw new ConfigException("Can't unlink file ".$base.$this->hash.".css"); |
|
| 292 | 292 | } |
| 293 | 293 | $this->loopCssLines($file); |
| 294 | 294 | } |
| 295 | 295 | if ($this->debug) { |
| 296 | 296 | $data = file_get_contents($file); |
| 297 | - $this->storeContents($base . $file_path, $data); |
|
| 298 | - } else { |
|
| 297 | + $this->storeContents($base.$file_path, $data); |
|
| 298 | + }else { |
|
| 299 | 299 | $data .= file_get_contents($file); |
| 300 | 300 | } |
| 301 | - $this->compiled_files[] = "/css/" . $file_path; |
|
| 301 | + $this->compiled_files[] = "/css/".$file_path; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | return $data; |
@@ -313,12 +313,12 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | protected function putDebugJs($path_parts, $base, $file) |
| 315 | 315 | { |
| 316 | - $file_path = $this->hash . "_" . $path_parts[count($path_parts) - 1]; |
|
| 317 | - $this->compiled_files[] = "/js/" . $file_path; |
|
| 316 | + $file_path = $this->hash."_".$path_parts[count($path_parts) - 1]; |
|
| 317 | + $this->compiled_files[] = "/js/".$file_path; |
|
| 318 | 318 | $data = ""; |
| 319 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($file)) { |
|
| 319 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($file)) { |
|
| 320 | 320 | $data = file_get_contents($file); |
| 321 | - $this->storeContents($base . $file_path, $data); |
|
| 321 | + $this->storeContents($base.$file_path, $data); |
|
| 322 | 322 | } |
| 323 | 323 | return $data; |
| 324 | 324 | } |
@@ -360,60 +360,60 @@ discard block |
||
| 360 | 360 | { |
| 361 | 361 | $ppath = explode("/", $string); |
| 362 | 362 | $original_filename = $ppath[count($ppath) - 1]; |
| 363 | - $base = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 363 | + $base = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 364 | 364 | $file = ""; |
| 365 | 365 | $html_base = ""; |
| 366 | 366 | $debug = Config::getInstance()->getDebugMode(); |
| 367 | 367 | $cache = Config::getInstance()->get('cache.var'); |
| 368 | - $cache = $cache ? '.' . $cache : ''; |
|
| 368 | + $cache = $cache ? '.'.$cache : ''; |
|
| 369 | 369 | $finfo = finfo_open(FILEINFO_MIME_TYPE); // devuelve el tipo mime de su extensión |
| 370 | 370 | $mime = finfo_file($finfo, $filename_path); |
| 371 | 371 | finfo_close($finfo); |
| 372 | 372 | if (preg_match('/\.css$/i', $string)) { |
| 373 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.css"; |
|
| 373 | + $file = "/".substr(md5($string), 0, 8)."$cache.css"; |
|
| 374 | 374 | $html_base = "css"; |
| 375 | 375 | if ($debug) { |
| 376 | - $file = str_replace(".css", "_" . $original_filename, $file); |
|
| 376 | + $file = str_replace(".css", "_".$original_filename, $file); |
|
| 377 | 377 | } |
| 378 | 378 | } elseif (preg_match('/\.js$/i', $string)) { |
| 379 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.js"; |
|
| 379 | + $file = "/".substr(md5($string), 0, 8)."$cache.js"; |
|
| 380 | 380 | $html_base = "js"; |
| 381 | 381 | if ($debug) { |
| 382 | - $file = str_replace(".js", "_" . $original_filename, $file); |
|
| 382 | + $file = str_replace(".js", "_".$original_filename, $file); |
|
| 383 | 383 | } |
| 384 | 384 | } elseif (preg_match("/image/i", $mime)) { |
| 385 | 385 | $ext = explode(".", $string); |
| 386 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 386 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 387 | 387 | $html_base = "img"; |
| 388 | 388 | if ($debug) { |
| 389 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 389 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 390 | 390 | } |
| 391 | 391 | } elseif (preg_match("/(doc|pdf)/i", $mime)) { |
| 392 | 392 | $ext = explode(".", $string); |
| 393 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 393 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 394 | 394 | $html_base = "docs"; |
| 395 | 395 | if ($debug) { |
| 396 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 396 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 397 | 397 | } |
| 398 | 398 | } elseif (preg_match("/(video|audio|ogg)/i", $mime)) { |
| 399 | 399 | $ext = explode(".", $string); |
| 400 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 400 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 401 | 401 | $html_base = "media"; |
| 402 | 402 | if ($debug) { |
| 403 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 403 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 404 | 404 | } |
| 405 | 405 | } elseif (preg_match("/(text|html)/i", $mime)) { |
| 406 | 406 | $ext = explode(".", $string); |
| 407 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 407 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 408 | 408 | $html_base = "templates"; |
| 409 | 409 | if ($debug) { |
| 410 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 410 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 411 | 411 | } |
| 412 | 412 | } elseif (!$return && !is_null($name)) { |
| 413 | 413 | $html_base = ''; |
| 414 | 414 | $file = $name; |
| 415 | 415 | } |
| 416 | - $file_path = $html_base . $file; |
|
| 416 | + $file_path = $html_base.$file; |
|
| 417 | 417 | |
| 418 | 418 | return array($base, $html_base, $file_path); |
| 419 | 419 | } |
@@ -432,10 +432,10 @@ discard block |
||
| 432 | 432 | foreach ($urls as $source) { |
| 433 | 433 | $orig = self::calculateResourcePathname($filename_path, $source); |
| 434 | 434 | $orig_part = preg_split("/Public/i", $orig); |
| 435 | - $dest = WEB_DIR . $orig_part[1]; |
|
| 435 | + $dest = WEB_DIR.$orig_part[1]; |
|
| 436 | 436 | GeneratorHelper::createDir(dirname($dest)); |
| 437 | 437 | if (@copy($orig, $dest) === false) { |
| 438 | - throw new ConfigException("Can't copy " . $orig . " to " . $dest); |
|
| 438 | + throw new ConfigException("Can't copy ".$orig." to ".$dest); |
|
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | } |
@@ -160,7 +160,7 @@ |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | - * @param $field |
|
| 163 | + * @param string $field |
|
| 164 | 164 | * @param bool $required |
| 165 | 165 | * @return Field |
| 166 | 166 | */ |
@@ -31,19 +31,19 @@ discard block |
||
| 31 | 31 | $behaviors = $tableMap->getBehaviors(); |
| 32 | 32 | foreach ($map::getFieldNames() as $field) { |
| 33 | 33 | $fDto = self::parseFormField($domain, $tableMap, $field, $behaviors); |
| 34 | - if(null !== $fDto) { |
|
| 34 | + if (null !== $fDto) { |
|
| 35 | 35 | $form->addField($fDto); |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if(array_key_exists('i18n', $behaviors)) { |
|
| 40 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
| 41 | - if(null !== $relateI18n) { |
|
| 39 | + if (array_key_exists('i18n', $behaviors)) { |
|
| 40 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
| 41 | + if (null !== $relateI18n) { |
|
| 42 | 42 | $i18NTableMap = $relateI18n->getLocalTable(); |
| 43 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
| 44 | - if(!$form->fieldExists($columnMap->getPhpName())) { |
|
| 43 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
| 44 | + if (!$form->fieldExists($columnMap->getPhpName())) { |
|
| 45 | 45 | $fDto = self::parseFormField($domain, $i18NTableMap, $columnMap->getPhpName(), $i18NTableMap->getBehaviors()); |
| 46 | - if(null !== $fDto) { |
|
| 46 | + if (null !== $fDto) { |
|
| 47 | 47 | $fDto->pk = false; |
| 48 | 48 | $form->addField($fDto); |
| 49 | 49 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $fDto->entity = $relatedModel; |
| 73 | 73 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
| 74 | 74 | $fDto->relatedField = $relatedField->getPhpName(); |
| 75 | - $fDto->url = Router::getInstance()->getRoute(strtolower($domain) . '-api-' . $relatedModel); |
|
| 75 | + $fDto->url = Router::getInstance()->getRoute(strtolower($domain).'-api-'.$relatedModel); |
|
| 76 | 76 | return $fDto; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $column = null; |
| 181 | 181 | try { |
| 182 | 182 | $column = $tableMap->getColumnByPhpName($field); |
| 183 | - } catch (\Exception $e) { |
|
| 183 | + }catch (\Exception $e) { |
|
| 184 | 184 | Logger::log($e->getMessage(), LOG_WARNING); |
| 185 | 185 | //foreach($tableMap->getRelations() as $relation) { |
| 186 | 186 | // $column = self::checkFieldExists($relation->getLocalTable(), $field); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @param ModelCriteria $query |
| 195 | 195 | * @param mixed $value |
| 196 | 196 | */ |
| 197 | - private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) |
|
| 197 | + private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null) |
|
| 198 | 198 | { |
| 199 | 199 | $tableField = $column->getFullyQualifiedName(); |
| 200 | 200 | if (preg_match('/^<=/', $value)) { |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
| 211 | 211 | $text = preg_replace('/(\'|\")/', '', $value); |
| 212 | 212 | $text = preg_replace('/\ /', '%', $text); |
| 213 | - $query->add($tableField, '%' . $text . '%', Criteria::LIKE); |
|
| 214 | - } else { |
|
| 213 | + $query->add($tableField, '%'.$text.'%', Criteria::LIKE); |
|
| 214 | + }else { |
|
| 215 | 215 | $query->add($tableField, $value, Criteria::EQUAL); |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -222,35 +222,35 @@ discard block |
||
| 222 | 222 | * @param array $extraColumns |
| 223 | 223 | * @param mixed $value |
| 224 | 224 | */ |
| 225 | - public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null) |
|
| 225 | + public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null) |
|
| 226 | 226 | { |
| 227 | 227 | $exp = 'CONCAT('; |
| 228 | 228 | $sep = ''; |
| 229 | 229 | foreach ($tableMap->getColumns() as $column) { |
| 230 | 230 | if ($column->isText()) { |
| 231 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
| 231 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
| 232 | 232 | $sep = ', " ", '; |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | - foreach($tableMap->getRelations() as $relation) { |
|
| 236 | - if(preg_match('/I18n$/i', $relation->getName())) { |
|
| 235 | + foreach ($tableMap->getRelations() as $relation) { |
|
| 236 | + if (preg_match('/I18n$/i', $relation->getName())) { |
|
| 237 | 237 | $localeTableMap = $relation->getLocalTable(); |
| 238 | 238 | foreach ($localeTableMap->getColumns() as $column) { |
| 239 | 239 | if ($column->isText()) { |
| 240 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
| 240 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
| 241 | 241 | $sep = ', " ", '; |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | foreach ($extraColumns as $extra => $name) { |
| 247 | - $exp .= $sep . $extra; |
|
| 247 | + $exp .= $sep.$extra; |
|
| 248 | 248 | $sep = ', " ", '; |
| 249 | 249 | } |
| 250 | 250 | $exp .= ")"; |
| 251 | 251 | $text = preg_replace('/(\'|\")/', '', $value); |
| 252 | 252 | $text = preg_replace('/\ /', '%', $text); |
| 253 | - $query->where($exp . Criteria::LIKE . '"%' . $text . '%"'); |
|
| 253 | + $query->where($exp.Criteria::LIKE.'"%'.$text.'%"'); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @param string $field |
| 261 | 261 | * @param mixed $value |
| 262 | 262 | */ |
| 263 | - public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null) |
|
| 263 | + public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null) |
|
| 264 | 264 | { |
| 265 | 265 | if ($column = self::checkFieldExists($tableMap, $field)) { |
| 266 | 266 | self::addQueryFilter($column, $query, $value); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | public static function extractQuery($modelNameNamespace, ConnectionInterface $con = null) |
| 277 | 277 | { |
| 278 | - $queryReflector = new \ReflectionClass($modelNameNamespace . "Query"); |
|
| 278 | + $queryReflector = new \ReflectionClass($modelNameNamespace."Query"); |
|
| 279 | 279 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
| 280 | 280 | $query = $queryReflector->getMethod('create')->invoke($con); |
| 281 | 281 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | } elseif ($mappedColumn->isText()) { |
| 305 | 305 | if ($mappedColumn->getSize() > 100) { |
| 306 | 306 | $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required); |
| 307 | - } else { |
|
| 307 | + }else { |
|
| 308 | 308 | $fDto = self::generateStringField($field, $required); |
| 309 | 309 | } |
| 310 | 310 | } elseif ($mappedColumn->getType() === PropelTypes::BOOLEAN) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Method that extract the Api name |
| 42 | - * @return mixed |
|
| 42 | + * @return string |
|
| 43 | 43 | */ |
| 44 | 44 | public function getApi() |
| 45 | 45 | { |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Method that extract the Domain name |
| 53 | - * @return mixed |
|
| 53 | + * @return string |
|
| 54 | 54 | */ |
| 55 | 55 | public function getDomain() |
| 56 | 56 | { |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @param ModelCriteria $query |
| 95 | 95 | */ |
| 96 | - protected function joinTables(ModelCriteria &$query) |
|
| 96 | + protected function joinTables(ModelCriteria & $query) |
|
| 97 | 97 | { |
| 98 | 98 | //TODO for specific implementations |
| 99 | 99 | } |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | private function findPk(ModelCriteria $query, $pk) { |
| 108 | 108 | $pks = explode(Api::API_PK_SEPARATOR, urldecode($pk)); |
| 109 | - if(count($pks) == 1) { |
|
| 109 | + if (count($pks) == 1) { |
|
| 110 | 110 | return $query->findPk($pks[0]); |
| 111 | - } else { |
|
| 111 | + }else { |
|
| 112 | 112 | $i = 0; |
| 113 | - foreach($this->getPkDbName() as $key => $phpName) { |
|
| 113 | + foreach ($this->getPkDbName() as $key => $phpName) { |
|
| 114 | 114 | $query->filterBy($phpName, $pks[$i]); |
| 115 | 115 | $i++; |
| 116 | - if($i >= count($pks)) break; |
|
| 116 | + if ($i >= count($pks)) break; |
|
| 117 | 117 | } |
| 118 | 118 | return $query->findOne(); |
| 119 | 119 | } |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | try { |
| 141 | 141 | $query = $this->prepareQuery(); |
| 142 | 142 | $this->model = $this->findPk($query, $pk); |
| 143 | - } catch (\Exception $e) { |
|
| 144 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 143 | + }catch (\Exception $e) { |
|
| 144 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | /** |
| 163 | 163 | * @param ModelCriteria $query |
| 164 | 164 | */ |
| 165 | - private function checkReturnFields(ModelCriteria &$query) |
|
| 165 | + private function checkReturnFields(ModelCriteria & $query) |
|
| 166 | 166 | { |
| 167 | 167 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
| 168 | 168 | if (null !== $returnFields) { |
@@ -113,7 +113,9 @@ |
||
| 113 | 113 | foreach($this->getPkDbName() as $key => $phpName) { |
| 114 | 114 | $query->filterBy($phpName, $pks[$i]); |
| 115 | 115 | $i++; |
| 116 | - if($i >= count($pks)) break; |
|
| 116 | + if($i >= count($pks)) { |
|
| 117 | + break; |
|
| 118 | + } |
|
| 117 | 119 | } |
| 118 | 120 | return $query->findOne(); |
| 119 | 121 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | return ($aOrder < $bOrder) ? -1 : 1; |
| 49 | 49 | }); |
| 50 | 50 | $array['actions'] = []; |
| 51 | - foreach($this->actions as $action) { |
|
| 51 | + foreach ($this->actions as $action) { |
|
| 52 | 52 | $array['actions'][] = $action->__toArray(); |
| 53 | 53 | } |
| 54 | 54 | return $array; |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | header("Access-Control-Allow-Credentials: true"); |
| 45 | 45 | header("Access-Control-Allow-Origin: *"); |
| 46 | 46 | header("Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS"); |
| 47 | - header("Access-Control-Allow-Headers: " . implode(', ', self::getCorsHeaders())); |
|
| 47 | + header("Access-Control-Allow-Headers: ".implode(', ', self::getCorsHeaders())); |
|
| 48 | 48 | } |
| 49 | 49 | if (Request::getInstance()->getMethod() == 'OPTIONS') { |
| 50 | 50 | Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests', LOG_DEBUG); |
@@ -39,8 +39,8 @@ |
||
| 39 | 39 | "domain" => $this->getDomain(), |
| 40 | 40 | "listLabel" => Api::API_LIST_NAME_FIELD, |
| 41 | 41 | 'modelId' => Api::API_MODEL_KEY_FIELD, |
| 42 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
| 43 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
| 42 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
| 43 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
| 44 | 44 | ), [], ''); |
| 45 | 45 | } |
| 46 | 46 | |