@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | try { |
| 31 | 31 | $reflectionClass = new \ReflectionClass($this); |
| 32 | 32 | $properties = $reflectionClass->getProperties(\ReflectionProperty::IS_PUBLIC); |
| 33 | - if(count($properties) > 0) { |
|
| 33 | + if (count($properties) > 0) { |
|
| 34 | 34 | /** @var \ReflectionProperty $property */ |
| 35 | - foreach($properties as $property) { |
|
| 35 | + foreach ($properties as $property) { |
|
| 36 | 36 | $dto[$property->getName()] = $property->getValue($this); |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | - } catch(\Exception $e) { |
|
| 40 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 39 | + }catch (\Exception $e) { |
|
| 40 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 41 | 41 | } |
| 42 | 42 | return $dto; |
| 43 | 43 | } |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function fromArray(array $object = array()) |
| 59 | 59 | { |
| 60 | - if(count($object) > 0) { |
|
| 61 | - foreach($object as $key => $value) { |
|
| 62 | - if(property_exists($this, $key)) { |
|
| 60 | + if (count($object) > 0) { |
|
| 61 | + foreach ($object as $key => $value) { |
|
| 62 | + if (property_exists($this, $key)) { |
|
| 63 | 63 | $this->$key = $value; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -33,10 +33,10 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | private static function __init($instance) { |
| 35 | 35 | $loaded = false; |
| 36 | - if(method_exists($instance, 'isLoaded')) { |
|
| 36 | + if (method_exists($instance, 'isLoaded')) { |
|
| 37 | 37 | $loaded = $instance->isLoaded(); |
| 38 | 38 | } |
| 39 | - if(false === $loaded && method_exists($instance, "init")) { |
|
| 39 | + if (false === $loaded && method_exists($instance, "init")) { |
|
| 40 | 40 | $instance->init(); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public static function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
| 56 | 56 | { |
| 57 | - Logger::log('Create inyectable instance for ' . $classNameSpace); |
|
| 57 | + Logger::log('Create inyectable instance for '.$classNameSpace); |
|
| 58 | 58 | $reflector = new \ReflectionClass($calledClass); |
| 59 | 59 | $property = $reflector->getProperty($variable); |
| 60 | 60 | $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace; |
| 61 | 61 | if (true === $singleton && method_exists($varInstanceType, "getInstance")) { |
| 62 | 62 | $instance = $varInstanceType::getInstance(); |
| 63 | - } else { |
|
| 63 | + }else { |
|
| 64 | 64 | $instance = new $varInstanceType(); |
| 65 | 65 | } |
| 66 | 66 | return $instance; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | public static function getClassProperties($class) |
| 75 | 75 | { |
| 76 | 76 | $properties = []; |
| 77 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
| 77 | + Logger::log('Extracting annotations properties from class '.$class); |
|
| 78 | 78 | $selfReflector = new \ReflectionClass($class); |
| 79 | 79 | if (false !== $selfReflector->getParentClass()) { |
| 80 | 80 | $properties = self::getClassProperties($selfReflector->getParentClass()->getName()); |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | && (preg_match('/^\/(admin|setup\-admin)/i', $route) || NULL !== Config::getInstance()->get('restricted')) |
| 24 | 24 | ) { |
| 25 | 25 | |
| 26 | - if(!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 26 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 27 | 27 | //Si no hay fichero de usuarios redirigimos directamente al gestor |
| 28 | 28 | return UserController::getInstance()->adminers(); |
| 29 | 29 | } |
@@ -131,7 +131,7 @@ |
||
| 131 | 131 | if (null !== $function && $this->hasExpiredCache($path, $expires)) { |
| 132 | 132 | $data = call_user_func($function); |
| 133 | 133 | $this->storeData($path, $data, $transform); |
| 134 | - } else { |
|
| 134 | + }else { |
|
| 135 | 135 | $data = $this->getDataFromFile($path, $transform); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | $translations = array(); |
| 22 | 22 | if (file_exists($absoluteTranslationFileName)) { |
| 23 | 23 | @include($absoluteTranslationFileName); |
| 24 | - } else { |
|
| 24 | + }else { |
|
| 25 | 25 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | use PSFS\base\Singleton; |
| 17 | 17 | use PSFS\controller\ConfigController; |
| 18 | 18 | |
| 19 | -require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php"; |
|
| 19 | +require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php"; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Class Dispatcher |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | private function setLocale() |
| 78 | 78 | { |
| 79 | 79 | $this->locale = $this->config->get("default_language"); |
| 80 | - Logger::log('Set locale to project [' . $this->locale . ']'); |
|
| 80 | + Logger::log('Set locale to project ['.$this->locale.']'); |
|
| 81 | 81 | // Load translations |
| 82 | - putenv("LC_ALL=" . $this->locale); |
|
| 82 | + putenv("LC_ALL=".$this->locale); |
|
| 83 | 83 | setlocale(LC_ALL, $this->locale); |
| 84 | 84 | // Load the locale path |
| 85 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
| 86 | - Logger::log('Set locale dir ' . $locale_path); |
|
| 85 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
| 86 | + Logger::log('Set locale dir '.$locale_path); |
|
| 87 | 87 | Config::createDir($locale_path); |
| 88 | 88 | bindtextdomain('translations', $locale_path); |
| 89 | 89 | textdomain('translations'); |
@@ -104,18 +104,18 @@ discard block |
||
| 104 | 104 | if (!$this->parser->isFile()) { |
| 105 | 105 | return $this->router->execute($this->actualUri); |
| 106 | 106 | } |
| 107 | - } else { |
|
| 107 | + }else { |
|
| 108 | 108 | return ConfigController::getInstance()->config(); |
| 109 | 109 | } |
| 110 | - } catch (ConfigException $c) { |
|
| 110 | + }catch (ConfigException $c) { |
|
| 111 | 111 | return $this->dumpException($c); |
| 112 | - } catch (SecurityException $s) { |
|
| 112 | + }catch (SecurityException $s) { |
|
| 113 | 113 | return $this->security->notAuthorized($this->actualUri); |
| 114 | - } catch (UserAuthException $u) { |
|
| 114 | + }catch (UserAuthException $u) { |
|
| 115 | 115 | Request::getInstance()->redirect($this->router->getRoute($this->config->get('home_action'))); |
| 116 | - } catch (RouterException $r) { |
|
| 116 | + }catch (RouterException $r) { |
|
| 117 | 117 | return $this->router->httpNotFound($r); |
| 118 | - } catch (\Exception $e) { |
|
| 118 | + }catch (\Exception $e) { |
|
| 119 | 119 | return $this->dumpException($e); |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $use /= 1024; |
| 158 | 158 | break; |
| 159 | 159 | case "MBytes": |
| 160 | - $use /= (1024 * 1024); |
|
| 160 | + $use /= (1024*1024); |
|
| 161 | 161 | break; |
| 162 | 162 | case "Bytes": |
| 163 | 163 | default: |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | if ($this->config->getDebugMode()) { |
| 184 | 184 | Logger::log('Added handlers for errors'); |
| 185 | 185 | //Warning & Notice handler |
| 186 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
| 186 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
| 187 | 187 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline]); |
| 188 | 188 | throw new \Exception($errstr, 500); |
| 189 | 189 | }); |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | Logger::log('Initialicing stats (mem + ts)'); |
| 199 | 199 | if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) { |
| 200 | 200 | $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT']; |
| 201 | - } else { |
|
| 201 | + }else { |
|
| 202 | 202 | $this->ts = $this->parser->getTs(); |
| 203 | 203 | } |
| 204 | 204 | $this->mem = memory_get_usage(); |
@@ -7,10 +7,7 @@ |
||
| 7 | 7 | use PSFS\base\extension\AssetsTokenParser; |
| 8 | 8 | use PSFS\base\extension\TemplateFunctions; |
| 9 | 9 | use PSFS\base\types\helpers\ResponseHelper; |
| 10 | -use PSFS\base\types\helpers\SecurityHelper; |
|
| 11 | -use PSFS\base\types\helpers\TemplateHelper; |
|
| 12 | 10 | use PSFS\base\types\SingletonTrait; |
| 13 | -use PSFS\Dispatcher; |
|
| 14 | 11 | |
| 15 | 12 | |
| 16 | 13 | class Template |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | ResponseHelper::setStatusHeader($this->status_code); |
| 131 | 131 | ResponseHelper::setAuthHeaders($this->public_zone); |
| 132 | 132 | ResponseHelper::setCookieHeaders($cookies); |
| 133 | - header('Content-type: ' . $contentType); |
|
| 133 | + header('Content-type: '.$contentType); |
|
| 134 | 134 | |
| 135 | 135 | } |
| 136 | 136 | |
@@ -146,14 +146,14 @@ discard block |
||
| 146 | 146 | Logger::log('Start output response'); |
| 147 | 147 | ob_start(); |
| 148 | 148 | $this->setReponseHeaders($contentType, $cookies); |
| 149 | - header('Content-length: ' . strlen($output)); |
|
| 149 | + header('Content-length: '.strlen($output)); |
|
| 150 | 150 | |
| 151 | 151 | $cache = Cache::needCache(); |
| 152 | 152 | if (false !== $cache && $this->status_code === Template::STATUS_OK && $this->debug === false) { |
| 153 | 153 | Logger::log('Saving output response into cache'); |
| 154 | 154 | $cacheName = $this->cache->getRequestCacheHash(); |
| 155 | - $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $cacheName, $output); |
|
| 156 | - $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $cacheName . ".headers", headers_list(), Cache::JSON); |
|
| 155 | + $this->cache->storeData("json".DIRECTORY_SEPARATOR.$cacheName, $output); |
|
| 156 | + $this->cache->storeData("json".DIRECTORY_SEPARATOR.$cacheName.".headers", headers_list(), Cache::JSON); |
|
| 157 | 157 | } |
| 158 | 158 | echo $output; |
| 159 | 159 | |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | Logger::log('Close template render'); |
| 172 | 172 | Security::getInstance()->setSessionKey("lastRequest", array( |
| 173 | - "url" => Request::getInstance()->getRootUrl() . Request::requestUri(), |
|
| 173 | + "url" => Request::getInstance()->getRootUrl().Request::requestUri(), |
|
| 174 | 174 | "ts" => microtime(true), |
| 175 | 175 | )); |
| 176 | 176 | Security::getInstance()->updateSession(); |
| 177 | - Logger::log('End request: ' . Request::requestUri(), LOG_INFO); |
|
| 177 | + Logger::log('End request: '.Request::requestUri(), LOG_INFO); |
|
| 178 | 178 | exit; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $dump = ''; |
| 224 | 224 | try { |
| 225 | 225 | $dump = $this->tpl->render($tpl, $vars); |
| 226 | - } catch (\Exception $e) { |
|
| 226 | + }catch (\Exception $e) { |
|
| 227 | 227 | Logger::log($e->getMessage(), LOG_ERR); |
| 228 | 228 | } |
| 229 | 229 | return $dump; |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | public function regenerateTemplates() |
| 338 | 338 | { |
| 339 | 339 | $this->generateTemplatesCache(); |
| 340 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true); |
|
| 340 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true); |
|
| 341 | 341 | $translations = []; |
| 342 | 342 | if (is_array($domains)) { |
| 343 | 343 | $translations = $this->parsePathTranslations($domains); |
@@ -359,8 +359,8 @@ discard block |
||
| 359 | 359 | // force compilation |
| 360 | 360 | if ($file->isFile()) { |
| 361 | 361 | try { |
| 362 | - $this->tpl->load(str_replace($tplDir . '/', '', $file)); |
|
| 363 | - } catch (\Exception $e) { |
|
| 362 | + $this->tpl->load(str_replace($tplDir.'/', '', $file)); |
|
| 363 | + }catch (\Exception $e) { |
|
| 364 | 364 | Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]); |
| 365 | 365 | } |
| 366 | 366 | } |
@@ -434,9 +434,9 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | private function loadDomains() |
| 436 | 436 | { |
| 437 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
| 438 | - if(null !== $domains) { |
|
| 439 | - foreach($domains as $domain => $paths) { |
|
| 437 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
| 438 | + if (null !== $domains) { |
|
| 439 | + foreach ($domains as $domain => $paths) { |
|
| 440 | 440 | $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain)); |
| 441 | 441 | } |
| 442 | 442 | } |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | $this->cache = Cache::getInstance(); |
| 452 | 452 | $loader = new \Twig_Loader_Filesystem(Config::getInstance()->getTemplatePath()); |
| 453 | 453 | $this->tpl = new \Twig_Environment($loader, array( |
| 454 | - 'cache' => Config::getInstance()->getCachePath() . DIRECTORY_SEPARATOR . 'twig', |
|
| 454 | + 'cache' => Config::getInstance()->getCachePath().DIRECTORY_SEPARATOR.'twig', |
|
| 455 | 455 | 'debug' => (bool)$this->debug, |
| 456 | 456 | 'auto_reload' => Config::getParam('twig.auto_reload', TRUE), |
| 457 | 457 | )); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | unset($_SERVER["PHP_AUTH_USER"]); |
| 39 | 39 | unset($_SERVER["PHP_AUTH_PW"]); |
| 40 | 40 | header_remove("Authorization"); |
| 41 | - } else { |
|
| 41 | + }else { |
|
| 42 | 42 | header('Authorization:'); |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | Logger::log('Adding debug headers to render response'); |
| 67 | 67 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
| 68 | 68 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
| 69 | - header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
| 70 | - header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
| 71 | - header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
| 69 | + header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
| 70 | + header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
| 71 | + header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | return $vars; |