@@ -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 | } |
@@ -118,8 +118,7 @@ |
||
118 | 118 | try |
119 | 119 | { |
120 | 120 | $this->val($sReflectionClass, new ReflectionClass($sClassName)); |
121 | - } |
|
122 | - catch(ReflectionException $e) |
|
121 | + } catch(ReflectionException $e) |
|
123 | 122 | { |
124 | 123 | $xTranslator = $this->g(Translator::class); |
125 | 124 | $sMessage = $xTranslator->trans('errors.class.invalid', ['name' => $sClassName]); |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | private function getCallableObjectOptions(array $aConfigOptions, array $aAnnotationOptions): array |
37 | 37 | { |
38 | 38 | $aOptions = []; |
39 | - foreach($aConfigOptions as $sNames => $aFunctionOptions) |
|
39 | + foreach ($aConfigOptions as $sNames => $aFunctionOptions) |
|
40 | 40 | { |
41 | 41 | $aFunctionNames = explode(',', $sNames); // Names are in comma-separated list. |
42 | - foreach($aFunctionNames as $sFunctionName) |
|
42 | + foreach ($aFunctionNames as $sFunctionName) |
|
43 | 43 | { |
44 | 44 | $aOptions[$sFunctionName] = array_merge($aOptions[$sFunctionName] ?? [], $aFunctionOptions); |
45 | 45 | } |
46 | 46 | } |
47 | - foreach($aAnnotationOptions as $sFunctionName => $aFunctionOptions) |
|
47 | + foreach ($aAnnotationOptions as $sFunctionName => $aFunctionOptions) |
|
48 | 48 | { |
49 | 49 | $aOptions[$sFunctionName] = array_merge($aOptions[$sFunctionName] ?? [], $aFunctionOptions); |
50 | 50 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $aMethods = $xCallableObject->getPublicMethods($aProtectedMethods); |
67 | 67 | $aProperties = $xCallableObject->getProperties(); |
68 | 68 | [$bExcluded, $aAnnotationOptions, $aAnnotationProtected] = $xAnnotationReader->getAttributes($sClassName, $aMethods, $aProperties); |
69 | - if($bExcluded) |
|
69 | + if ($bExcluded) |
|
70 | 70 | { |
71 | 71 | $xCallableObject->configure('excluded', true); |
72 | 72 | return; |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | // Functions options |
79 | 79 | $aCallableOptions = []; |
80 | 80 | $aOptions = $this->getCallableObjectOptions($aOptions['functions'], $aAnnotationOptions); |
81 | - foreach($aOptions as $sFunctionName => $aFunctionOptions) |
|
81 | + foreach ($aOptions as $sFunctionName => $aFunctionOptions) |
|
82 | 82 | { |
83 | - foreach($aFunctionOptions as $sOptionName => $xOptionValue) |
|
83 | + foreach ($aFunctionOptions as $sOptionName => $xOptionValue) |
|
84 | 84 | { |
85 | - if(substr($sOptionName, 0, 2) !== '__') |
|
85 | + if (substr($sOptionName, 0, 2) !== '__') |
|
86 | 86 | { |
87 | 87 | // Options for javascript code. |
88 | 88 | $aCallableOptions[$sFunctionName][$sOptionName] = $xOptionValue; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $sReflectionClass = $sClassName . '_ReflectionClass'; |
112 | 112 | |
113 | 113 | // Make sure the registered class exists |
114 | - if(isset($aOptions['include'])) |
|
114 | + if (isset($aOptions['include'])) |
|
115 | 115 | { |
116 | 116 | require_once($aOptions['include']); |
117 | 117 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $this->val($sReflectionClass, new ReflectionClass($sClassName)); |
122 | 122 | } |
123 | - catch(ReflectionException $e) |
|
123 | + catch (ReflectionException $e) |
|
124 | 124 | { |
125 | 125 | $xTranslator = $this->g(Translator::class); |
126 | 126 | $sMessage = $xTranslator->trans('errors.class.invalid', ['name' => $sClassName]); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $this->set($sClassName, function($c) use($sClassName, $sReflectionClass) { |
147 | 147 | $xRegisteredObject = $this->make($c->g($sReflectionClass)); |
148 | 148 | // Initialize the object |
149 | - if($xRegisteredObject instanceof CallableClass) |
|
149 | + if ($xRegisteredObject instanceof CallableClass) |
|
150 | 150 | { |
151 | 151 | // Set the protected attributes of the object |
152 | 152 | $cSetter = function($c, $sClassName) { |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | // Run the callback for class initialisation |
161 | 161 | $aCallbacks = $c->g(CallbackManager::class)->getInitCallbacks(); |
162 | - foreach($aCallbacks as $xCallback) |
|
162 | + foreach ($aCallbacks as $xCallback) |
|
163 | 163 | { |
164 | 164 | call_user_func($xCallback, $xRegisteredObject); |
165 | 165 | } |