@@ -48,7 +48,7 @@ |
||
| 48 | 48 | $sViewName = $store->getViewName(); |
| 49 | 49 | $sNamespace = $store->getNamespace(); |
| 50 | 50 | // In this view renderer, the namespace must always be prepended to the view name. |
| 51 | - if(substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::') |
|
| 51 | + if (substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::') |
|
| 52 | 52 | { |
| 53 | 53 | $sViewName = $sNamespace . '::' . $sViewName; |
| 54 | 54 | } |
@@ -89,24 +89,24 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function addNamespaces(Config $xAppConfig, ?Config $xUserConfig = null) |
| 91 | 91 | { |
| 92 | - if(empty($aNamespaces = $xAppConfig->getOptionNames('views'))) |
|
| 92 | + if (empty($aNamespaces = $xAppConfig->getOptionNames('views'))) |
|
| 93 | 93 | { |
| 94 | 94 | return; |
| 95 | 95 | } |
| 96 | 96 | $sPackage = $xAppConfig->getOption('package', ''); |
| 97 | - foreach($aNamespaces as $sNamespace => $sOption) |
|
| 97 | + foreach ($aNamespaces as $sNamespace => $sOption) |
|
| 98 | 98 | { |
| 99 | 99 | // Save the namespace |
| 100 | 100 | $aNamespace = $xAppConfig->getOption($sOption); |
| 101 | 101 | $aNamespace['package'] = $sPackage; |
| 102 | - if(!isset($aNamespace['renderer'])) |
|
| 102 | + if (!isset($aNamespace['renderer'])) |
|
| 103 | 103 | { |
| 104 | 104 | $aNamespace['renderer'] = 'jaxon'; // 'jaxon' is the default renderer. |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // If the lib config has defined a template option, then its value must be |
| 108 | 108 | // read from the app config. |
| 109 | - if($xUserConfig !== null && isset($aNamespace['template']) && is_array($aNamespace['template'])) |
|
| 109 | + if ($xUserConfig !== null && isset($aNamespace['template']) && is_array($aNamespace['template'])) |
|
| 110 | 110 | { |
| 111 | 111 | $sTemplateOption = $xAppConfig->getOption($sOption . '.template.option'); |
| 112 | 112 | $sTemplateDefault = $xAppConfig->getOption($sOption . '.template.default'); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $aNamespaces = array_filter($this->aNamespaces, function($aNamespace) use($sId) { |
| 150 | 150 | return $aNamespace['renderer'] === $sId; |
| 151 | 151 | }); |
| 152 | - foreach($aNamespaces as $sNamespace => $aNamespace) |
|
| 152 | + foreach ($aNamespaces as $sNamespace => $aNamespace) |
|
| 153 | 153 | { |
| 154 | 154 | $xRenderer->addNamespace($sNamespace, $aNamespace['directory'], $aNamespace['extension']); |
| 155 | 155 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | public function getNamespaceRenderer(string $sNamespace): ?ViewInterface |
| 184 | 184 | { |
| 185 | - if(!isset($this->aNamespaces[$sNamespace])) |
|
| 185 | + if (!isset($this->aNamespaces[$sNamespace])) |
|
| 186 | 186 | { |
| 187 | 187 | return null; |
| 188 | 188 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | protected function store(): Store |
| 209 | 209 | { |
| 210 | - if(!$this->xStore) |
|
| 210 | + if (!$this->xStore) |
|
| 211 | 211 | { |
| 212 | 212 | $this->xStore = new Store(); |
| 213 | 213 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function shareValues(array $aValues): ViewRenderer |
| 253 | 253 | { |
| 254 | - foreach($aValues as $sName => $xValue) |
|
| 254 | + foreach ($aValues as $sName => $xValue) |
|
| 255 | 255 | { |
| 256 | 256 | $this->share($sName, $xValue); |
| 257 | 257 | } |
@@ -275,12 +275,12 @@ discard block |
||
| 275 | 275 | $sNamespace = $this->sDefaultNamespace; |
| 276 | 276 | // Get the namespace from the view name |
| 277 | 277 | $nSeparatorPosition = strrpos($sViewName, '::'); |
| 278 | - if($nSeparatorPosition !== false) |
|
| 278 | + if ($nSeparatorPosition !== false) |
|
| 279 | 279 | { |
| 280 | 280 | $sNamespace = substr($sViewName, 0, $nSeparatorPosition); |
| 281 | 281 | } |
| 282 | 282 | $xRenderer = $this->getNamespaceRenderer($sNamespace); |
| 283 | - if(!$xRenderer) |
|
| 283 | + if (!$xRenderer) |
|
| 284 | 284 | { |
| 285 | 285 | // Cannot render a view if there's no renderer corresponding to the namespace. |
| 286 | 286 | return null; |
@@ -43,8 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function confirm(string $sQuestion, string $sYesScript, string $sNoScript): string |
| 45 | 45 | { |
| 46 | - return empty($sNoScript) ? 'if(confirm(' . $sQuestion . ')){' . $sYesScript . ';}' : |
|
| 47 | - 'if(confirm(' . $sQuestion . ')){' . $sYesScript . ';}else{' . $sNoScript . ';}'; |
|
| 46 | + return empty($sNoScript) ? 'if(confirm(' . $sQuestion . ')){' . $sYesScript . ';}' : 'if(confirm(' . $sQuestion . ')){' . $sYesScript . ';}else{' . $sNoScript . ';}'; |
|
| 48 | 47 | } |
| 49 | 48 | |
| 50 | 49 | /** |
@@ -57,11 +56,11 @@ discard block |
||
| 57 | 56 | */ |
| 58 | 57 | private function alert(string $sMessage, string $sTitle): string |
| 59 | 58 | { |
| 60 | - if(!empty($sTitle)) |
|
| 59 | + if (!empty($sTitle)) |
|
| 61 | 60 | { |
| 62 | 61 | $sMessage = '<b>' . $sTitle . '</b><br/>' . $sMessage; |
| 63 | 62 | } |
| 64 | - if($this->returnCode()) |
|
| 63 | + if ($this->returnCode()) |
|
| 65 | 64 | { |
| 66 | 65 | return 'alert(' . $sMessage . ')'; |
| 67 | 66 | } |
@@ -136,18 +136,18 @@ |
||
| 136 | 136 | $aOptions = $this->getOptionNames($sKeyPrefix); |
| 137 | 137 | $sSpaces = str_repeat(' ', $nSpaces); |
| 138 | 138 | $sScript = ''; |
| 139 | - foreach($aOptions as $sShortName => $sFullName) |
|
| 139 | + foreach ($aOptions as $sShortName => $sFullName) |
|
| 140 | 140 | { |
| 141 | 141 | $value = $this->xConfigManager->getOption($sFullName); |
| 142 | - if(is_string($value)) |
|
| 142 | + if (is_string($value)) |
|
| 143 | 143 | { |
| 144 | 144 | $value = "'$value'"; |
| 145 | 145 | } |
| 146 | - elseif(is_bool($value)) |
|
| 146 | + elseif (is_bool($value)) |
|
| 147 | 147 | { |
| 148 | 148 | $value = ($value ? 'true' : 'false'); |
| 149 | 149 | } |
| 150 | - elseif(!is_numeric($value)) |
|
| 150 | + elseif (!is_numeric($value)) |
|
| 151 | 151 | { |
| 152 | 152 | $value = json_encode($value); |
| 153 | 153 | } |
@@ -142,12 +142,10 @@ |
||
| 142 | 142 | if(is_string($value)) |
| 143 | 143 | { |
| 144 | 144 | $value = "'$value'"; |
| 145 | - } |
|
| 146 | - elseif(is_bool($value)) |
|
| 145 | + } elseif(is_bool($value)) |
|
| 147 | 146 | { |
| 148 | 147 | $value = ($value ? 'true' : 'false'); |
| 149 | - } |
|
| 150 | - elseif(!is_numeric($value)) |
|
| 148 | + } elseif(!is_numeric($value)) |
|
| 151 | 149 | { |
| 152 | 150 | $value = json_encode($value); |
| 153 | 151 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public static function getInstance(): Ajax |
| 85 | 85 | { |
| 86 | - if(self::$xInstance === null) |
|
| 86 | + if (self::$xInstance === null) |
|
| 87 | 87 | { |
| 88 | 88 | // First call: create and initialize the instances. |
| 89 | 89 | self::$xInstance = new Ajax(); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function config(string $sConfigFile = '', string $sConfigSection = ''): ConfigManager |
| 123 | 123 | { |
| 124 | - if(!empty(($sConfigFile = trim($sConfigFile)))) |
|
| 124 | + if (!empty(($sConfigFile = trim($sConfigFile)))) |
|
| 125 | 125 | { |
| 126 | 126 | $this->xConfigManager->load($sConfigFile, trim($sConfigSection)); |
| 127 | 127 | } |
@@ -33,24 +33,24 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function sendResponse() |
| 35 | 35 | { |
| 36 | - if(!$this->xConfigManager->getOption('core.response.send', false)) |
|
| 36 | + if (!$this->xConfigManager->getOption('core.response.send', false)) |
|
| 37 | 37 | { |
| 38 | 38 | return; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // Check to see if headers have already been sent out, in which case we can't do our job |
| 42 | - if(headers_sent($sFilename, $nLineNumber)) |
|
| 42 | + if (headers_sent($sFilename, $nLineNumber)) |
|
| 43 | 43 | { |
| 44 | 44 | throw new RequestException($this->xTranslator->trans('errors.output.already-sent', |
| 45 | 45 | ['location' => $sFilename . ':' . $nLineNumber]) . "\n" . |
| 46 | 46 | $this->xTranslator->trans('errors.output.advice')); |
| 47 | 47 | } |
| 48 | - if(empty($sContent = $this->xResponseManager->getOutput())) |
|
| 48 | + if (empty($sContent = $this->xResponseManager->getOutput())) |
|
| 49 | 49 | { |
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if($this->di()->getRequest()->getMethod() === 'GET') |
|
| 53 | + if ($this->di()->getRequest()->getMethod() === 'GET') |
|
| 54 | 54 | { |
| 55 | 55 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
| 56 | 56 | header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | print $sContent; |
| 63 | 63 | |
| 64 | - if($this->xConfigManager->getOption('core.process.exit', false)) |
|
| 64 | + if ($this->xConfigManager->getOption('core.process.exit', false)) |
|
| 65 | 65 | { |
| 66 | 66 | exit(); |
| 67 | 67 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | public function cl(string $sName) |
| 36 | 36 | { |
| 37 | 37 | $xCallableClass = $this->xCallableClassHelper->xCallableRegistry->getCallableObject($sName); |
| 38 | - if($xCallableClass === null) |
|
| 38 | + if ($xCallableClass === null) |
|
| 39 | 39 | { |
| 40 | 40 | return null; |
| 41 | 41 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function setup(string $sConfigFile) |
| 52 | 52 | { |
| 53 | - if(!file_exists($sConfigFile)) |
|
| 53 | + if (!file_exists($sConfigFile)) |
|
| 54 | 54 | { |
| 55 | 55 | $sMessage = $this->xTranslator->trans('errors.file.access', ['path' => $sConfigFile]); |
| 56 | 56 | throw new SetupException($sMessage); |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | $aOptions = $this->xConfigManager->read($sConfigFile); |
| 61 | 61 | $aLibOptions = $aOptions['lib'] ?? []; |
| 62 | 62 | $aAppOptions = $aOptions['app'] ?? []; |
| 63 | - if(!is_array($aLibOptions) || !is_array($aAppOptions)) |
|
| 63 | + if (!is_array($aLibOptions) || !is_array($aAppOptions)) |
|
| 64 | 64 | { |
| 65 | 65 | $sMessage = $this->xTranslator->trans('errors.file.content', ['path' => $sConfigFile]); |
| 66 | 66 | throw new SetupException($sMessage); |
| 67 | 67 | } |
| 68 | 68 | // The bootstrap set this to false. It needs to be changed. |
| 69 | - if(!isset($aLibOptions['core']['response']['send'])) |
|
| 69 | + if (!isset($aLibOptions['core']['response']['send'])) |
|
| 70 | 70 | { |
| 71 | 71 | $aLibOptions['core']['response']['send'] = true; |
| 72 | 72 | } |
@@ -177,8 +177,7 @@ |
||
| 177 | 177 | return $this->xContainer->get($sClass); |
| 178 | 178 | } |
| 179 | 179 | return $this->offsetGet($sClass); |
| 180 | - } |
|
| 181 | - catch(Exception|Throwable $e) |
|
| 180 | + } catch(Exception|Throwable $e) |
|
| 182 | 181 | { |
| 183 | 182 | $xTranslator = $this->g(Translator::class); |
| 184 | 183 | $sMessage = $xTranslator->trans('errors.class.container', ['name' => $sClass]); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function has(string $sClass): bool |
| 143 | 143 | { |
| 144 | - if($this->xContainer != null && $this->xContainer->has($sClass)) |
|
| 144 | + if ($this->xContainer != null && $this->xContainer->has($sClass)) |
|
| 145 | 145 | { |
| 146 | 146 | return true; |
| 147 | 147 | } |
@@ -172,13 +172,13 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | try |
| 174 | 174 | { |
| 175 | - if($this->xContainer != null && $this->xContainer->has($sClass)) |
|
| 175 | + if ($this->xContainer != null && $this->xContainer->has($sClass)) |
|
| 176 | 176 | { |
| 177 | 177 | return $this->xContainer->get($sClass); |
| 178 | 178 | } |
| 179 | 179 | return $this->offsetGet($sClass); |
| 180 | 180 | } |
| 181 | - catch(Exception|Throwable $e) |
|
| 181 | + catch (Exception | Throwable $e) |
|
| 182 | 182 | { |
| 183 | 183 | $xTranslator = $this->g(Translator::class); |
| 184 | 184 | $sMessage = $xTranslator->trans('errors.class.container', ['name' => $sClass]); |
@@ -238,22 +238,22 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | public function make($xClass) |
| 240 | 240 | { |
| 241 | - if(is_string($xClass)) |
|
| 241 | + if (is_string($xClass)) |
|
| 242 | 242 | { |
| 243 | 243 | $xClass = new ReflectionClass($xClass); // Create the reflection class instance |
| 244 | 244 | } |
| 245 | - if(!($xClass instanceof ReflectionClass)) |
|
| 245 | + if (!($xClass instanceof ReflectionClass)) |
|
| 246 | 246 | { |
| 247 | 247 | return null; |
| 248 | 248 | } |
| 249 | 249 | // Use the Reflection class to get the parameters of the constructor |
| 250 | - if(($constructor = $xClass->getConstructor()) === null) |
|
| 250 | + if (($constructor = $xClass->getConstructor()) === null) |
|
| 251 | 251 | { |
| 252 | 252 | return $xClass->newInstance(); |
| 253 | 253 | } |
| 254 | 254 | $parameters = $constructor->getParameters(); |
| 255 | 255 | $parameterInstances = []; |
| 256 | - foreach($parameters as $parameter) |
|
| 256 | + foreach ($parameters as $parameter) |
|
| 257 | 257 | { |
| 258 | 258 | // Get the parameter instance from the DI |
| 259 | 259 | $parameterInstances[] = $this->get($parameter->getType()); |