@@ -127,9 +127,8 @@ discard block |
||
127 | 127 | */ |
128 | 128 | private function updatePagesCount(): Paginator |
129 | 129 | { |
130 | - $this->nPagesCount = ($this->nItemsPerPage === 0 ? 0 : |
|
131 | - (int)ceil($this->nItemsCount / $this->nItemsPerPage)); |
|
132 | - if($this->nPageNumber > $this->nPagesCount) |
|
130 | + $this->nPagesCount = ($this->nItemsPerPage === 0 ? 0 : (int) ceil($this->nItemsCount / $this->nItemsPerPage)); |
|
131 | + if ($this->nPageNumber > $this->nPagesCount) |
|
133 | 132 | { |
134 | 133 | $this->nPageNumber = $this->nPagesCount; |
135 | 134 | } |
@@ -183,8 +182,7 @@ discard block |
||
183 | 182 | protected function getPrevPage(): Page |
184 | 183 | { |
185 | 184 | return $this->nPageNumber <= 1 ? |
186 | - new Page('disabled', $this->sPreviousText, 0) : |
|
187 | - new Page('enabled', $this->sPreviousText, $this->nPageNumber - 1); |
|
185 | + new Page('disabled', $this->sPreviousText, 0) : new Page('enabled', $this->sPreviousText, $this->nPageNumber - 1); |
|
188 | 186 | } |
189 | 187 | |
190 | 188 | /** |
@@ -195,8 +193,7 @@ discard block |
||
195 | 193 | protected function getNextPage(): Page |
196 | 194 | { |
197 | 195 | return $this->nPageNumber >= $this->nPagesCount ? |
198 | - new Page('disabled', $this->sNextText, 0) : |
|
199 | - new Page('enabled', $this->sNextText, $this->nPageNumber + 1); |
|
196 | + new Page('disabled', $this->sNextText, 0) : new Page('enabled', $this->sNextText, $this->nPageNumber + 1); |
|
200 | 197 | } |
201 | 198 | |
202 | 199 | /** |
@@ -208,7 +205,7 @@ discard block |
||
208 | 205 | */ |
209 | 206 | protected function getPage(int $nNumber): Page |
210 | 207 | { |
211 | - if($nNumber < 1) |
|
208 | + if ($nNumber < 1) |
|
212 | 209 | { |
213 | 210 | return new Page('disabled', $this->sEllipsysText, 0); |
214 | 211 | } |
@@ -227,9 +224,9 @@ discard block |
||
227 | 224 | { |
228 | 225 | $aPageNumbers = []; |
229 | 226 | |
230 | - if($this->nPagesCount <= $this->nMaxPages) |
|
227 | + if ($this->nPagesCount <= $this->nMaxPages) |
|
231 | 228 | { |
232 | - for($i = 0; $i < $this->nPagesCount; $i++) |
|
229 | + for ($i = 0; $i < $this->nPagesCount; $i++) |
|
233 | 230 | { |
234 | 231 | $aPageNumbers[] = $i + 1; |
235 | 232 | } |
@@ -238,11 +235,11 @@ discard block |
||
238 | 235 | } |
239 | 236 | |
240 | 237 | // Determine the sliding range, centered around the current page. |
241 | - $nNumAdjacents = (int)floor(($this->nMaxPages - 4) / 2); |
|
238 | + $nNumAdjacents = (int) floor(($this->nMaxPages - 4) / 2); |
|
242 | 239 | |
243 | 240 | $nSlidingStart = 1; |
244 | 241 | $nSlidingEndOffset = $nNumAdjacents + 3 - $this->nPageNumber; |
245 | - if($nSlidingEndOffset < 0) |
|
242 | + if ($nSlidingEndOffset < 0) |
|
246 | 243 | { |
247 | 244 | $nSlidingStart = $this->nPageNumber - $nNumAdjacents; |
248 | 245 | $nSlidingEndOffset = 0; |
@@ -250,23 +247,23 @@ discard block |
||
250 | 247 | |
251 | 248 | $nSlidingEnd = $this->nPagesCount; |
252 | 249 | $nSlidingStartOffset = $this->nPageNumber + $nNumAdjacents + 2 - $this->nPagesCount; |
253 | - if($nSlidingStartOffset < 0) |
|
250 | + if ($nSlidingStartOffset < 0) |
|
254 | 251 | { |
255 | 252 | $nSlidingEnd = $this->nPageNumber + $nNumAdjacents; |
256 | 253 | $nSlidingStartOffset = 0; |
257 | 254 | } |
258 | 255 | |
259 | 256 | // Build the list of page numbers. |
260 | - if($nSlidingStart > 1) |
|
257 | + if ($nSlidingStart > 1) |
|
261 | 258 | { |
262 | 259 | $aPageNumbers[] = 1; |
263 | 260 | $aPageNumbers[] = 0; // Ellipsys; |
264 | 261 | } |
265 | - for($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
262 | + for ($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
266 | 263 | { |
267 | 264 | $aPageNumbers[] = $i; |
268 | 265 | } |
269 | - if($nSlidingEnd < $this->nPagesCount) |
|
266 | + if ($nSlidingEnd < $this->nPagesCount) |
|
270 | 267 | { |
271 | 268 | $aPageNumbers[] = 0; // Ellipsys; |
272 | 269 | $aPageNumbers[] = $this->nPagesCount; |
@@ -282,7 +279,7 @@ discard block |
||
282 | 279 | */ |
283 | 280 | public function pages(): array |
284 | 281 | { |
285 | - if($this->nPagesCount < 2) |
|
282 | + if ($this->nPagesCount < 2) |
|
286 | 283 | { |
287 | 284 | return []; |
288 | 285 | } |
@@ -333,14 +330,14 @@ discard block |
||
333 | 330 | */ |
334 | 331 | public function render(JsExpr $xCall, string $sWrapperId = '') |
335 | 332 | { |
336 | - if(($xFunc = $xCall->func()) === null) |
|
333 | + if (($xFunc = $xCall->func()) === null) |
|
337 | 334 | { |
338 | 335 | return; |
339 | 336 | } |
340 | 337 | |
341 | 338 | $sHtml = ''; |
342 | 339 | $aPages = $this->pages(); |
343 | - if(count($aPages) > 0) |
|
340 | + if (count($aPages) > 0) |
|
344 | 341 | { |
345 | 342 | $xRenderer = $this->xPlugin->renderer(); |
346 | 343 | $aPages = array_map(function($xPage) use($xRenderer) { |
@@ -359,7 +356,7 @@ discard block |
||
359 | 356 | } |
360 | 357 | // The HTML code must always be displayed, even if it is empty. |
361 | 358 | $aParams = $this->showLinks($sHtml, trim($sWrapperId)); |
362 | - if($sHtml !== '') |
|
359 | + if ($sHtml !== '') |
|
363 | 360 | { |
364 | 361 | // Set click handlers on the pagination links |
365 | 362 | $aParams['func'] = $xFunc->withPage()->jsonSerialize(); |
@@ -377,7 +374,7 @@ discard block |
||
377 | 374 | */ |
378 | 375 | private function showLinks(string $sHtml, string $sWrapperId): array |
379 | 376 | { |
380 | - if(is_a($this->xPlugin->response(), Response::class)) |
|
377 | + if (is_a($this->xPlugin->response(), Response::class)) |
|
381 | 378 | { |
382 | 379 | /** @var Response */ |
383 | 380 | $xResponse = $this->xPlugin->response(); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | $this->xFactory = $xFactory; |
48 | 48 | $this->xCallback = function(JsExpr $xJsExpr) { |
49 | 49 | // Add the newly created expression to the response |
50 | - $this->addCommand('script.exec', ['expr' => $xJsExpr]);; |
|
50 | + $this->addCommand('script.exec', ['expr' => $xJsExpr]); ; |
|
51 | 51 | }; |
52 | 52 | } |
53 | 53 |
@@ -75,7 +75,7 @@ |
||
75 | 75 | public function ajax(): ResponseInterface |
76 | 76 | { |
77 | 77 | $xPsrResponse = $this->xPsr17Factory->createResponse(200); |
78 | - if($this->xRequest->getMethod() === 'GET') |
|
78 | + if ($this->xRequest->getMethod() === 'GET') |
|
79 | 79 | { |
80 | 80 | $xPsrResponse = $xPsrResponse |
81 | 81 | ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT') |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | private function initDataBag() |
41 | 41 | { |
42 | - if($this->xDataBag !== null) |
|
42 | + if ($this->xDataBag !== null) |
|
43 | 43 | { |
44 | 44 | return; |
45 | 45 | } |
@@ -49,8 +49,7 @@ discard block |
||
49 | 49 | $aBody = $xRequest->getParsedBody(); |
50 | 50 | $aParams = $xRequest->getQueryParams(); |
51 | 51 | $aData = is_array($aBody) ? |
52 | - $this->readData($aBody['jxnbags'] ?? []) : |
|
53 | - $this->readData($aParams['jxnbags'] ?? []); |
|
52 | + $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []); |
|
54 | 53 | $this->xDataBag = new DataBag($this, $aData); |
55 | 54 | } |
56 | 55 | |
@@ -71,8 +70,7 @@ discard block |
||
71 | 70 | { |
72 | 71 | // Todo: clean input data. |
73 | 72 | return is_string($xData) ? |
74 | - (json_decode($xData, true) ?: []) : |
|
75 | - (is_array($xData) ? $xData : []); |
|
73 | + (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []); |
|
76 | 74 | } |
77 | 75 | |
78 | 76 | /** |
@@ -90,7 +88,7 @@ discard block |
||
90 | 88 | public function writeCommand() |
91 | 89 | { |
92 | 90 | $this->initDataBag(); |
93 | - if($this->xDataBag->touched()) |
|
91 | + if ($this->xDataBag->touched()) |
|
94 | 92 | { |
95 | 93 | $this->addCommand('databag.set', ['values' => $this->xDataBag]); |
96 | 94 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | { |
96 | 96 | $aArgs = func_get_args(); |
97 | 97 | array_shift($aArgs); |
98 | - $this->addCommand('script.call', ['func' => $this->str($sFunc),'args' => $aArgs]); |
|
98 | + $this->addCommand('script.call', ['func' => $this->str($sFunc), 'args' => $aArgs]); |
|
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | { |
136 | 136 | $xResponse = $this->newResponse(); |
137 | 137 | $fConfirm($xResponse); |
138 | - if($xResponse->nCommandCount > 0) |
|
138 | + if ($xResponse->nCommandCount > 0) |
|
139 | 139 | { |
140 | 140 | // The confirm command must be inserted before the commands to be confirmed. |
141 | 141 | $this->insertCommand('script.confirm', [ |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function str($xData): string |
85 | 85 | { |
86 | - return trim((string)$xData, " \t\n"); |
|
86 | + return trim((string) $xData, " \t\n"); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return void |
107 | 107 | */ |
108 | - public function addCommand(string $sName, array|JsonSerializable $aArgs = [], |
|
108 | + public function addCommand(string $sName, array | JsonSerializable $aArgs = [], |
|
109 | 109 | bool $bRemoveEmpty = false) |
110 | 110 | { |
111 | 111 | $this->nCommandCount++; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return void |
124 | 124 | */ |
125 | - public function insertCommand(string $sName, array|JsonSerializable $aArgs, |
|
125 | + public function insertCommand(string $sName, array | JsonSerializable $aArgs, |
|
126 | 126 | int $nBefore, bool $bRemoveEmpty = false) |
127 | 127 | { |
128 | 128 | $this->nCommandCount++; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return void |
139 | 139 | */ |
140 | - public function setOption(string $sName, string|array|JsonSerializable $xValue) |
|
140 | + public function setOption(string $sName, string | array | JsonSerializable $xValue) |
|
141 | 141 | { |
142 | 142 | $this->xManager->setOption($sName, $xValue); |
143 | 143 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | public function plugin(string $sName): ?AbstractResponsePlugin |
184 | 184 | { |
185 | 185 | $xResponsePlugin = $this->xPluginManager->getResponsePlugin($sName); |
186 | - if($xResponsePlugin !== null) |
|
186 | + if ($xResponsePlugin !== null) |
|
187 | 187 | { |
188 | 188 | $xResponsePlugin->setResponse($this); |
189 | 189 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return void |
79 | 79 | */ |
80 | - public function addCommand(string $sName, array|JsonSerializable $aArgs = [], |
|
80 | + public function addCommand(string $sName, array | JsonSerializable $aArgs = [], |
|
81 | 81 | bool $bRemoveEmpty = false) |
82 | 82 | { |
83 | 83 | parent::addCommand($sName, $aArgs, $bRemoveEmpty); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @return void |
96 | 96 | */ |
97 | - public function insertCommand(string $sName, array|JsonSerializable $aArgs, |
|
97 | + public function insertCommand(string $sName, array | JsonSerializable $aArgs, |
|
98 | 98 | int $nBefore, bool $bRemoveEmpty = false) |
99 | 99 | { |
100 | 100 | parent::insertCommand($sName, $aArgs, $nBefore, $bRemoveEmpty); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function str($xData): string |
105 | 105 | { |
106 | - return trim((string)$xData, " \t\n"); |
|
106 | + return trim((string) $xData, " \t\n"); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return array |
166 | 166 | */ |
167 | - private function getCommandArgs(array|JsonSerializable $aArgs, bool $bRemoveEmpty = false): array |
|
167 | + private function getCommandArgs(array | JsonSerializable $aArgs, bool $bRemoveEmpty = false): array |
|
168 | 168 | { |
169 | - if(!$bRemoveEmpty) |
|
169 | + if (!$bRemoveEmpty) |
|
170 | 170 | { |
171 | 171 | return $aArgs; |
172 | 172 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @return void |
186 | 186 | */ |
187 | - public function addCommand(string $sName, array|JsonSerializable $aArgs, |
|
187 | + public function addCommand(string $sName, array | JsonSerializable $aArgs, |
|
188 | 188 | bool $bRemoveEmpty = false) |
189 | 189 | { |
190 | 190 | $this->nLastCommandPos = count($this->aCommands); |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return void |
206 | 206 | */ |
207 | - public function insertCommand(string $sName, array|JsonSerializable $aArgs, |
|
207 | + public function insertCommand(string $sName, array | JsonSerializable $aArgs, |
|
208 | 208 | int $nBefore, bool $bRemoveEmpty = false) |
209 | 209 | { |
210 | 210 | $nInsertPosition = count($this->aCommands) - $nBefore; |
211 | - if($nInsertPosition < 0) |
|
211 | + if ($nInsertPosition < 0) |
|
212 | 212 | { |
213 | 213 | return; |
214 | 214 | } |
215 | 215 | // Move the commands after the insert position. |
216 | - for($nPos = count($this->aCommands); $nPos > $nInsertPosition; $nPos--) |
|
216 | + for ($nPos = count($this->aCommands); $nPos > $nInsertPosition; $nPos--) |
|
217 | 217 | { |
218 | 218 | $this->aCommands[$nPos] = $this->aCommands[$nPos - 1]; |
219 | 219 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function setComponent(array $aComponent) |
235 | 235 | { |
236 | - if($this->nLastCommandPos >= 0) |
|
236 | + if ($this->nLastCommandPos >= 0) |
|
237 | 237 | { |
238 | 238 | $this->aCommands[$this->nLastCommandPos]['component'] = $aComponent; |
239 | 239 | } |
@@ -247,12 +247,12 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return void |
249 | 249 | */ |
250 | - public function setOption(string $sName, string|array|JsonSerializable $xValue) |
|
250 | + public function setOption(string $sName, string | array | JsonSerializable $xValue) |
|
251 | 251 | { |
252 | - if($this->nLastCommandPos >= 0) |
|
252 | + if ($this->nLastCommandPos >= 0) |
|
253 | 253 | { |
254 | 254 | $aCommand = &$this->aCommands[$this->nLastCommandPos]; |
255 | - if(isset($aCommand['options'])) |
|
255 | + if (isset($aCommand['options'])) |
|
256 | 256 | { |
257 | 257 | $aCommand['options'][$this->str($sName)] = $xValue; |
258 | 258 | return; |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | */ |
341 | 341 | public function printDebug() |
342 | 342 | { |
343 | - foreach($this->aDebugMessages as $sMessage) |
|
343 | + foreach ($this->aDebugMessages as $sMessage) |
|
344 | 344 | { |
345 | 345 | $this->addCommand('script.debug', ['message' => $this->str($sMessage)]); |
346 | 346 | } |
@@ -354,8 +354,7 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public function getContentType(): string |
356 | 356 | { |
357 | - return empty($this->sCharacterEncoding) ? $this->getResponse()->getContentType() : |
|
358 | - $this->getResponse()->getContentType() . '; charset="' . $this->sCharacterEncoding . '"'; |
|
357 | + return empty($this->sCharacterEncoding) ? $this->getResponse()->getContentType() : $this->getResponse()->getContentType() . '; charset="' . $this->sCharacterEncoding . '"'; |
|
359 | 358 | } |
360 | 359 | |
361 | 360 | /** |
@@ -6,19 +6,19 @@ |
||
6 | 6 | jaxon.config.defaultMethod = "<?php echo $this->sDefaultMethod ?>"; |
7 | 7 | jaxon.config.responseType = "<?php echo $this->sResponseType ?>"; |
8 | 8 | |
9 | -<?php if($this->nResponseQueueSize > 0): ?> |
|
9 | +<?php if ($this->nResponseQueueSize > 0): ?> |
|
10 | 10 | jaxon.config.responseQueueSize = <?php echo $this->nResponseQueueSize ?>; |
11 | 11 | <?php endif ?> |
12 | 12 | |
13 | -<?php if(($this->bDebug)): ?> |
|
14 | -<?php if(($this->sDebugOutputID)): ?> |
|
13 | +<?php if (($this->bDebug)): ?> |
|
14 | +<?php if (($this->sDebugOutputID)): ?> |
|
15 | 15 | jaxon.debug.outputID = "<?php echo $this->sDebugOutputID ?>"; |
16 | 16 | <?php endif ?> |
17 | -<?php if(($this->bVerboseDebug)): ?> |
|
17 | +<?php if (($this->bVerboseDebug)): ?> |
|
18 | 18 | jaxon.debug.verbose.active = true; |
19 | 19 | <?php endif ?> |
20 | 20 | <?php endif ?> |
21 | 21 | |
22 | -<?php if(($this->sCsrfMetaName)): ?> |
|
22 | +<?php if (($this->sCsrfMetaName)): ?> |
|
23 | 23 | jaxon.setCsrf('<?php echo $this->sCsrfMetaName ?>'); |
24 | 24 | <?php endif ?> |