@@ -124,28 +124,28 @@ discard block |
||
124 | 124 | { |
125 | 125 | $bIsUsed = false; |
126 | 126 | $aInterfaces = class_implements($sClassName); |
127 | - if(in_array(CodeGeneratorInterface::class, $aInterfaces)) |
|
127 | + if (in_array(CodeGeneratorInterface::class, $aInterfaces)) |
|
128 | 128 | { |
129 | 129 | $this->xCodeGenerator->addCodeGenerator($sClassName, $nPriority); |
130 | 130 | $bIsUsed = true; |
131 | 131 | } |
132 | - if(in_array(CallableRegistryInterface::class, $aInterfaces)) |
|
132 | + if (in_array(CallableRegistryInterface::class, $aInterfaces)) |
|
133 | 133 | { |
134 | 134 | $this->aRegistryPlugins[$sPluginName] = $sClassName; |
135 | 135 | $bIsUsed = true; |
136 | 136 | } |
137 | - if(in_array(RequestHandlerInterface::class, $aInterfaces)) |
|
137 | + if (in_array(RequestHandlerInterface::class, $aInterfaces)) |
|
138 | 138 | { |
139 | 139 | $this->aRequestHandlers[$sPluginName] = $sClassName; |
140 | 140 | $bIsUsed = true; |
141 | 141 | } |
142 | - if(in_array(ResponsePluginInterface::class, $aInterfaces)) |
|
142 | + if (in_array(ResponsePluginInterface::class, $aInterfaces)) |
|
143 | 143 | { |
144 | 144 | $this->aResponsePlugins[$sPluginName] = $sClassName; |
145 | 145 | $bIsUsed = true; |
146 | 146 | } |
147 | 147 | |
148 | - if(!$bIsUsed) |
|
148 | + if (!$bIsUsed) |
|
149 | 149 | { |
150 | 150 | // The class is invalid. |
151 | 151 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | // Register the plugin in the DI container, if necessary |
156 | - if(!$this->di->has($sClassName)) |
|
156 | + if (!$this->di->has($sClassName)) |
|
157 | 157 | { |
158 | 158 | $this->di->auto($sClassName); |
159 | 159 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function registerCallable(string $sType, string $sCallable, $xOptions = []) |
188 | 188 | { |
189 | - if(isset($this->aRegistryPlugins[$sType]) && |
|
189 | + if (isset($this->aRegistryPlugins[$sType]) && |
|
190 | 190 | ($xPlugin = $this->di->g($this->aRegistryPlugins[$sType]))) |
191 | 191 | { |
192 | 192 | $xPlugin->register($sType, $sCallable, $xPlugin->checkOptions($sCallable, $xOptions)); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public function shallIncludeAssets(AbstractPlugin $xPlugin): bool |
72 | 72 | { |
73 | 73 | $sPluginOptionName = 'assets.include.' . $xPlugin->getName(); |
74 | - if($this->xConfigManager->hasOption($sPluginOptionName)) |
|
74 | + if ($this->xConfigManager->hasOption($sPluginOptionName)) |
|
75 | 75 | { |
76 | 76 | return $this->xConfigManager->getOption($sPluginOptionName); |
77 | 77 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $this->xConfigManager->getOption('js.lib.jq', "$sJsLibUri/libs/chibi/chibi$sJsExtension"), |
96 | 96 | "$sJsLibUri/jaxon.core$sJsExtension", |
97 | 97 | ]; |
98 | - if($this->xConfigManager->getOption('core.debug.on')) |
|
98 | + if ($this->xConfigManager->getOption('core.debug.on')) |
|
99 | 99 | { |
100 | 100 | $sLanguage = $this->xConfigManager->getOption('core.language'); |
101 | 101 | $aJsFiles[] = "$sJsLibUri/jaxon.debug$sJsExtension"; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getOptionVars(): array |
115 | 115 | { |
116 | - if(!$this->xConfigManager->hasOption('core.request.uri')) |
|
116 | + if (!$this->xConfigManager->hasOption('core.request.uri')) |
|
117 | 117 | { |
118 | 118 | $this->xConfigManager->setOption('core.request.uri', $this->xParameterReader->uri()); |
119 | 119 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | // Check config options |
147 | 147 | // - The js.app.export option must be set to true |
148 | 148 | // - The js.app.uri and js.app.dir options must be set to non null values |
149 | - if(!$this->xConfigManager->getOption('js.app.export', false) || |
|
149 | + if (!$this->xConfigManager->getOption('js.app.export', false) || |
|
150 | 150 | !$this->xConfigManager->getOption('js.app.uri') || |
151 | 151 | !$this->xConfigManager->getOption('js.app.dir')) |
152 | 152 | { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function createJsFiles(CodeGenerator $xCodeGenerator): string |
166 | 166 | { |
167 | - if(!$this->shallCreateJsFiles()) |
|
167 | + if (!$this->shallCreateJsFiles()) |
|
168 | 168 | { |
169 | 169 | return ''; |
170 | 170 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $sJsFileName = $this->xConfigManager->getOption('js.app.file') ?: $xCodeGenerator->getHash(); |
174 | 174 | $sJsDirectory = rtrim($this->xConfigManager->getOption('js.app.dir'), '\/') . DIRECTORY_SEPARATOR; |
175 | 175 | // - The js.app.dir must be writable |
176 | - if(!$sJsFileName || !is_dir($sJsDirectory) || !is_writable($sJsDirectory)) |
|
176 | + if (!$sJsFileName || !is_dir($sJsDirectory) || !is_writable($sJsDirectory)) |
|
177 | 177 | { |
178 | 178 | return ''; |
179 | 179 | } |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | $sJsFilePath = $sJsDirectory . $sJsFileName . '.js'; |
182 | 182 | $sJsMinFilePath = $sJsDirectory . $sJsFileName . '.min.js'; |
183 | 183 | $sJsFileUri = rtrim($this->xConfigManager->getOption('js.app.uri'), '/') . "/$sJsFileName"; |
184 | - if(!is_file($sJsFilePath) && !@file_put_contents($sJsFilePath, $xCodeGenerator->getJsScript())) |
|
184 | + if (!is_file($sJsFilePath) && !@file_put_contents($sJsFilePath, $xCodeGenerator->getJsScript())) |
|
185 | 185 | { |
186 | 186 | return ''; |
187 | 187 | } |
188 | - if(!$this->xConfigManager->getOption('js.app.minify', false)) |
|
188 | + if (!$this->xConfigManager->getOption('js.app.minify', false)) |
|
189 | 189 | { |
190 | 190 | return $sJsFileUri . '.js'; |
191 | 191 | } |
192 | - if(!is_file($sJsMinFilePath) && !$this->xMinifier->minify($sJsFilePath, $sJsMinFilePath)) |
|
192 | + if (!is_file($sJsMinFilePath) && !$this->xMinifier->minify($sJsFilePath, $sJsMinFilePath)) |
|
193 | 193 | { |
194 | 194 | // If the file cannot be minified, return the plain js file. |
195 | 195 | return $sJsFileUri . '.js'; |
@@ -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(); |
@@ -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 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php echo $this->sJsName ?> = function() { |
2 | 2 | return jaxon.request({ type: 'func', name: '<?php |
3 | 3 | echo $this->sName ?>' }, { parameters: arguments<?php |
4 | - foreach($this->aOptions as $sKey => $sValue): ?>, <?php |
|
4 | + foreach ($this->aOptions as $sKey => $sValue): ?>, <?php |
|
5 | 5 | echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> }); |
6 | 6 | }; |
@@ -6,20 +6,20 @@ |
||
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)): ?> |
|
13 | +<?php if (($this->bDebug)): ?> |
|
14 | 14 | jaxon.debug.active = true; |
15 | -<?php if(($this->sDebugOutputID)): ?> |
|
15 | +<?php if (($this->sDebugOutputID)): ?> |
|
16 | 16 | jaxon.debug.outputID = "<?php echo $this->sDebugOutputID ?>"; |
17 | 17 | <?php endif ?> |
18 | -<?php if(($this->bVerboseDebug)): ?> |
|
18 | +<?php if (($this->bVerboseDebug)): ?> |
|
19 | 19 | jaxon.debug.verbose.active = true; |
20 | 20 | <?php endif ?> |
21 | 21 | <?php endif ?> |
22 | 22 | |
23 | -<?php if(($this->sCsrfMetaName)): ?> |
|
23 | +<?php if (($this->sCsrfMetaName)): ?> |
|
24 | 24 | jaxon.setCsrf('<?php echo $this->sCsrfMetaName ?>'); |
25 | 25 | <?php endif ?> |
@@ -37,7 +37,6 @@ |
||
37 | 37 | public function getMetadataReader(string $sReaderId): MetadataReaderInterface |
38 | 38 | { |
39 | 39 | return $this->h("metadata_reader_$sReaderId") ? |
40 | - $this->g("metadata_reader_$sReaderId") : |
|
41 | - $this->g('metadata_reader_null'); |
|
40 | + $this->g("metadata_reader_$sReaderId") : $this->g('metadata_reader_null'); |
|
42 | 41 | } |
43 | 42 | } |
@@ -60,8 +60,7 @@ |
||
60 | 60 | /** @var ServerRequestInterface */ |
61 | 61 | $xRequest = $di->g(ServerRequestInterface::class); |
62 | 62 | $aRequestParameter = $xParameterReader->getRequestParameter($xRequest); |
63 | - return !is_array($aRequestParameter) ? $xRequest : |
|
64 | - $xRequest->withAttribute('jxncall', $aRequestParameter); |
|
63 | + return !is_array($aRequestParameter) ? $xRequest : $xRequest->withAttribute('jxncall', $aRequestParameter); |
|
65 | 64 | }); |
66 | 65 | // PSR factory |
67 | 66 | $this->set(PsrFactory::class, function($di) { |