@@ -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 | } |
@@ -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 | } |
@@ -105,9 +105,9 @@ |
||
105 | 105 | */ |
106 | 106 | public function addParameters(array $aParameters): JsCall |
107 | 107 | { |
108 | - foreach($aParameters as $xParameter) |
|
108 | + foreach ($aParameters as $xParameter) |
|
109 | 109 | { |
110 | - if($xParameter instanceof JsCall) |
|
110 | + if ($xParameter instanceof JsCall) |
|
111 | 111 | { |
112 | 112 | $this->addParameter(Parameter::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}'); |
113 | 113 | } |
@@ -159,8 +159,7 @@ |
||
159 | 159 | if($xParameter instanceof JsCall) |
160 | 160 | { |
161 | 161 | $this->addParameter(Parameter::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}'); |
162 | - } |
|
163 | - else |
|
162 | + } else |
|
164 | 163 | { |
165 | 164 | $this->pushParameter(Parameter::make($xParameter)); |
166 | 165 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | protected function updateTotalPages(): Paginator |
147 | 147 | { |
148 | - $this->nTotalPages = ($this->nItemsPerPage === 0 ? 0 : (int)ceil($this->nTotalItems / $this->nItemsPerPage)); |
|
148 | + $this->nTotalPages = ($this->nItemsPerPage === 0 ? 0 : (int) ceil($this->nTotalItems / $this->nItemsPerPage)); |
|
149 | 149 | return $this; |
150 | 150 | } |
151 | 151 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | protected function getPrevLink(): array |
222 | 222 | { |
223 | - if($this->nCurrentPage <= 1) |
|
223 | + if ($this->nCurrentPage <= 1) |
|
224 | 224 | { |
225 | 225 | return ['disabled', $this->sPreviousText, '']; |
226 | 226 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | */ |
235 | 235 | protected function getNextLink(): array |
236 | 236 | { |
237 | - if($this->nCurrentPage >= $this->nTotalPages) |
|
237 | + if ($this->nCurrentPage >= $this->nTotalPages) |
|
238 | 238 | { |
239 | 239 | return ['disabled', $this->sNextText, '']; |
240 | 240 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | protected function getPageLink(int $nNumber): array |
252 | 252 | { |
253 | - if($nNumber < 1) |
|
253 | + if ($nNumber < 1) |
|
254 | 254 | { |
255 | 255 | return ['disabled', $this->sEllipsysText, '']; |
256 | 256 | } |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | { |
270 | 270 | $aPageNumbers = []; |
271 | 271 | |
272 | - if($this->nTotalPages <= $this->nMaxPages) |
|
272 | + if ($this->nTotalPages <= $this->nMaxPages) |
|
273 | 273 | { |
274 | - for($i = 0; $i < $this->nTotalPages; $i++) |
|
274 | + for ($i = 0; $i < $this->nTotalPages; $i++) |
|
275 | 275 | { |
276 | 276 | $aPageNumbers[] = $i + 1; |
277 | 277 | } |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | // Determine the sliding range, centered around the current page. |
283 | - $nNumAdjacents = (int)floor(($this->nMaxPages - 4) / 2); |
|
283 | + $nNumAdjacents = (int) floor(($this->nMaxPages - 4) / 2); |
|
284 | 284 | |
285 | 285 | $nSlidingStart = 1; |
286 | 286 | $nSlidingEndOffset = $nNumAdjacents + 3 - $this->nCurrentPage; |
287 | - if($nSlidingEndOffset < 0) |
|
287 | + if ($nSlidingEndOffset < 0) |
|
288 | 288 | { |
289 | 289 | $nSlidingStart = $this->nCurrentPage - $nNumAdjacents; |
290 | 290 | $nSlidingEndOffset = 0; |
@@ -292,23 +292,23 @@ discard block |
||
292 | 292 | |
293 | 293 | $nSlidingEnd = $this->nTotalPages; |
294 | 294 | $nSlidingStartOffset = $this->nCurrentPage + $nNumAdjacents + 2 - $this->nTotalPages; |
295 | - if($nSlidingStartOffset < 0) |
|
295 | + if ($nSlidingStartOffset < 0) |
|
296 | 296 | { |
297 | 297 | $nSlidingEnd = $this->nCurrentPage + $nNumAdjacents; |
298 | 298 | $nSlidingStartOffset = 0; |
299 | 299 | } |
300 | 300 | |
301 | 301 | // Build the list of page numbers. |
302 | - if($nSlidingStart > 1) |
|
302 | + if ($nSlidingStart > 1) |
|
303 | 303 | { |
304 | 304 | $aPageNumbers[] = 1; |
305 | 305 | $aPageNumbers[] = 0; // Ellipsys; |
306 | 306 | } |
307 | - for($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
307 | + for ($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
308 | 308 | { |
309 | 309 | $aPageNumbers[] = $i; |
310 | 310 | } |
311 | - if($nSlidingEnd < $this->nTotalPages) |
|
311 | + if ($nSlidingEnd < $this->nTotalPages) |
|
312 | 312 | { |
313 | 313 | $aPageNumbers[] = 0; // Ellipsys; |
314 | 314 | $aPageNumbers[] = $this->nTotalPages; |
@@ -341,13 +341,13 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function pages(): array |
343 | 343 | { |
344 | - if($this->nTotalPages < 2) |
|
344 | + if ($this->nTotalPages < 2) |
|
345 | 345 | { |
346 | 346 | return []; |
347 | 347 | } |
348 | 348 | |
349 | 349 | return array_map(function($aPage) { |
350 | - return (object)['type' => $aPage[0], 'text' => $aPage[1], 'call' => $aPage[2]]; |
|
350 | + return (object) ['type' => $aPage[0], 'text' => $aPage[1], 'call' => $aPage[2]]; |
|
351 | 351 | }, $this->links()); |
352 | 352 | } |
353 | 353 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function __toString() |
377 | 377 | { |
378 | - if($this->nTotalPages < 2) |
|
378 | + if ($this->nTotalPages < 2) |
|
379 | 379 | { |
380 | 380 | return ''; |
381 | 381 | } |