@@ -25,7 +25,7 @@ |
||
| 25 | 25 | { |
| 26 | 26 | $sName = trim($sPath) ?: 'this'; |
| 27 | 27 | $this->aCall = ['_type' => 'select', '_name' => $sName, 'mode' => $sMode]; |
| 28 | - if($sName !== 'this' && $xContext !== null) |
|
| 28 | + if ($sName !== 'this' && $xContext !== null) |
|
| 29 | 29 | { |
| 30 | 30 | $this->aCall['context'] = is_a($xContext, JsonSerializable::class) ? |
| 31 | 31 | $xContext->jsonSerialize() : $xContext; |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function func(): ?Func |
| 91 | 91 | { |
| 92 | - foreach($this->aCalls as $xCall) |
|
| 92 | + foreach ($this->aCalls as $xCall) |
|
| 93 | 93 | { |
| 94 | - if(is_a($xCall, Func::class)) |
|
| 94 | + if (is_a($xCall, Func::class)) |
|
| 95 | 95 | { |
| 96 | 96 | return $xCall; |
| 97 | 97 | } |
@@ -426,15 +426,15 @@ discard block |
||
| 426 | 426 | 'calls' => array_map(fn(JsonSerializable|array $xCall) => |
| 427 | 427 | is_array($xCall) ? $xCall : $xCall->jsonSerialize(), $this->aCalls), |
| 428 | 428 | ]; |
| 429 | - if(($this->aConfirm)) |
|
| 429 | + if (($this->aConfirm)) |
|
| 430 | 430 | { |
| 431 | 431 | $aJsExpr['confirm'] = $this->aConfirm; |
| 432 | 432 | } |
| 433 | - if(($this->aCondition)) |
|
| 433 | + if (($this->aCondition)) |
|
| 434 | 434 | { |
| 435 | 435 | $aJsExpr['condition'] = $this->aCondition; |
| 436 | 436 | } |
| 437 | - if(($this->aAlert)) |
|
| 437 | + if (($this->aAlert)) |
|
| 438 | 438 | { |
| 439 | 439 | $aJsExpr['alert'] = $this->aAlert; |
| 440 | 440 | } |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | */ |
| 59 | 59 | public function __get(string $sAttribute): JsExpr |
| 60 | 60 | { |
| 61 | - return $this->_expr()->__get( $sAttribute); |
|
| 61 | + return $this->_expr()->__get($sAttribute); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | Dialog\Library\Butterup::class, // Butterup |
| 56 | 56 | Dialog\Library\IziToast::class, // IziToast |
| 57 | 57 | ]; |
| 58 | - foreach($aLibraries as $sClass) |
|
| 58 | + foreach ($aLibraries as $sClass) |
|
| 59 | 59 | { |
| 60 | 60 | try |
| 61 | 61 | { |
| 62 | 62 | $xDialog->registerLibrary($sClass, $sClass::NAME); |
| 63 | 63 | } |
| 64 | - catch(SetupException $_){} |
|
| 64 | + catch (SetupException $_) {} |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return $xDialog; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | function register(): void |
| 80 | 80 | { |
| 81 | 81 | // Do nothing if running in cli. |
| 82 | - if(php_sapi_name() !== 'cli') |
|
| 82 | + if (php_sapi_name() !== 'cli') |
|
| 83 | 83 | { |
| 84 | 84 | _register(); |
| 85 | 85 | }; |
@@ -142,15 +142,15 @@ discard block |
||
| 142 | 142 | 'defaults' => $this->xConfigManager->getAppOption('dialogs.default', []), |
| 143 | 143 | ]; |
| 144 | 144 | $aLibrariesOptions = []; |
| 145 | - foreach($this->getLibraries() as $xLibrary) |
|
| 145 | + foreach ($this->getLibraries() as $xLibrary) |
|
| 146 | 146 | { |
| 147 | 147 | $aLibOptions = $xLibrary->helper()->getJsOptions(); |
| 148 | - if(count($aLibOptions) > 0) |
|
| 148 | + if (count($aLibOptions) > 0) |
|
| 149 | 149 | { |
| 150 | 150 | $aLibrariesOptions[$xLibrary->getName()] = $aLibOptions; |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | - if(count($aLibrariesOptions) > 0) |
|
| 153 | + if (count($aLibrariesOptions) > 0) |
|
| 154 | 154 | { |
| 155 | 155 | $aOptions['options'] = $aLibrariesOptions; |
| 156 | 156 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $xJsCode->sJsBefore = $this->getConfigScript(); |
| 168 | 168 | |
| 169 | 169 | $aCodes = []; |
| 170 | - foreach($this->getHelpers() as $xHelper) |
|
| 170 | + foreach ($this->getHelpers() as $xHelper) |
|
| 171 | 171 | { |
| 172 | 172 | $aCodes[] = $xHelper->getScript(); |
| 173 | 173 | $xJsCode->aFiles = array_merge($xJsCode->aFiles, $xHelper->getFiles()); |
@@ -55,8 +55,7 @@ |
||
| 55 | 55 | */ |
| 56 | 56 | public function helper(): LibraryHelper |
| 57 | 57 | { |
| 58 | - return $this->xHelper ?: |
|
| 59 | - $this->xHelper = dialog()->getLibraryHelper($this->getName()); |
|
| 58 | + return $this->xHelper ?: $this->xHelper = dialog()->getLibraryHelper($this->getName()); |
|
| 60 | 59 | } |
| 61 | 60 | |
| 62 | 61 | /** |
@@ -110,8 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | private function getAssetUri(string $sOption, string $sFile): ?string |
| 112 | 112 | { |
| 113 | - return !$this->hasOption($sOption) ? "{$this->sUri}/$sFile" : |
|
| 114 | - (trim($this->getOption($sOption)) ?: null); |
|
| 113 | + return !$this->hasOption($sOption) ? "{$this->sUri}/$sFile" : (trim($this->getOption($sOption)) ?: null); |
|
| 115 | 114 | } |
| 116 | 115 | |
| 117 | 116 | /** |
@@ -194,7 +193,7 @@ discard block |
||
| 194 | 193 | */ |
| 195 | 194 | public function getFiles(): array |
| 196 | 195 | { |
| 197 | - if(!$this->getLibOption('js.app.export', false)) |
|
| 196 | + if (!$this->getLibOption('js.app.export', false)) |
|
| 198 | 197 | { |
| 199 | 198 | return []; |
| 200 | 199 | } |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function registerLibrary(string $sClassName, string $sLibraryName): void |
| 107 | 107 | { |
| 108 | - if(isset($this->aLibraries[$sLibraryName])) |
|
| 108 | + if (isset($this->aLibraries[$sLibraryName])) |
|
| 109 | 109 | { |
| 110 | 110 | return; |
| 111 | 111 | } |
| 112 | - if(!($aInterfaces = class_implements($sClassName))) |
|
| 112 | + if (!($aInterfaces = class_implements($sClassName))) |
|
| 113 | 113 | { |
| 114 | 114 | // The class is invalid. |
| 115 | 115 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $bIsConfirm = in_array(ConfirmInterface::class, $aInterfaces); |
| 120 | 120 | $bIsAlert = in_array(AlertInterface::class, $aInterfaces); |
| 121 | 121 | $bIsModal = in_array(ModalInterface::class, $aInterfaces); |
| 122 | - if(!$bIsConfirm && !$bIsAlert && !$bIsModal) |
|
| 122 | + if (!$bIsConfirm && !$bIsAlert && !$bIsModal) |
|
| 123 | 123 | { |
| 124 | 124 | // The class is invalid. |
| 125 | 125 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function setConfirmLibrary(string $sLibraryName) |
| 161 | 161 | { |
| 162 | - if(!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['confirm']) |
|
| 162 | + if (!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['confirm']) |
|
| 163 | 163 | { |
| 164 | 164 | $sMessage = $this->xTranslator->trans('errors.dialog.library', |
| 165 | 165 | ['type' => 'confirm', 'name' => $sLibraryName]); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function setAlertLibrary(string $sLibraryName): void |
| 191 | 191 | { |
| 192 | - if(!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['alert']) |
|
| 192 | + if (!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['alert']) |
|
| 193 | 193 | { |
| 194 | 194 | $sMessage = $this->xTranslator->trans('errors.dialog.library', |
| 195 | 195 | ['type' => 'alert', 'name' => $sLibraryName]); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function setModalLibrary(string $sLibraryName): void |
| 221 | 221 | { |
| 222 | - if(!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['modal']) |
|
| 222 | + if (!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['modal']) |
|
| 223 | 223 | { |
| 224 | 224 | $sMessage = $this->xTranslator->trans('errors.dialog.library', |
| 225 | 225 | ['type' => 'modal', 'name' => $sLibraryName]); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | protected function registerLibraries(): void |
| 249 | 249 | { |
| 250 | 250 | $aLibraries = $this->xConfigManager->getAppOption('dialogs.lib.ext', []); |
| 251 | - foreach($aLibraries as $sLibraryName => $sClassName) |
|
| 251 | + foreach ($aLibraries as $sLibraryName => $sClassName) |
|
| 252 | 252 | { |
| 253 | 253 | $this->registerLibrary($sClassName, $sLibraryName); |
| 254 | 254 | } |
@@ -263,19 +263,19 @@ discard block |
||
| 263 | 263 | protected function setDefaultLibraries(): void |
| 264 | 264 | { |
| 265 | 265 | // Set the default modal library |
| 266 | - if(($sLibraryName = $this->xConfigManager->getAppOption('dialogs.default.modal', ''))) |
|
| 266 | + if (($sLibraryName = $this->xConfigManager->getAppOption('dialogs.default.modal', ''))) |
|
| 267 | 267 | { |
| 268 | 268 | $this->setModalLibrary($sLibraryName); |
| 269 | 269 | $this->aLibraries[$sLibraryName]['used'] = true; |
| 270 | 270 | } |
| 271 | 271 | // Set the default alert library |
| 272 | - if(($sLibraryName = $this->xConfigManager->getAppOption('dialogs.default.alert', ''))) |
|
| 272 | + if (($sLibraryName = $this->xConfigManager->getAppOption('dialogs.default.alert', ''))) |
|
| 273 | 273 | { |
| 274 | 274 | $this->setAlertLibrary($sLibraryName); |
| 275 | 275 | $this->aLibraries[$sLibraryName]['used'] = true; |
| 276 | 276 | } |
| 277 | 277 | // Set the default confirm library |
| 278 | - if(($sLibraryName = $this->xConfigManager->getAppOption('dialogs.default.confirm', ''))) |
|
| 278 | + if (($sLibraryName = $this->xConfigManager->getAppOption('dialogs.default.confirm', ''))) |
|
| 279 | 279 | { |
| 280 | 280 | $this->setConfirmLibrary($sLibraryName); |
| 281 | 281 | $this->aLibraries[$sLibraryName]['used'] = true; |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | { |
| 292 | 292 | // Set the other libraries in use |
| 293 | 293 | $aLibraries = $this->xConfigManager->getAppOption('dialogs.lib.use', []); |
| 294 | - foreach($aLibraries as $sLibraryName) |
|
| 294 | + foreach ($aLibraries as $sLibraryName) |
|
| 295 | 295 | { |
| 296 | - if(isset($this->aLibraries[$sLibraryName])) // Make sure the library exists |
|
| 296 | + if (isset($this->aLibraries[$sLibraryName])) // Make sure the library exists |
|
| 297 | 297 | { |
| 298 | 298 | $this->aLibraries[$sLibraryName]['used'] = true; |
| 299 | 299 | } |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | */ |
| 328 | 328 | public function onChange(Config $xConfig, string $sName): void |
| 329 | 329 | { |
| 330 | - if($sName === '') |
|
| 330 | + if ($sName === '') |
|
| 331 | 331 | { |
| 332 | 332 | // Reset the default libraries any time the config is changed. |
| 333 | 333 | $this->registerLibraries(); |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | return; |
| 337 | 337 | } |
| 338 | 338 | $sPrefix = substr($sName, 0, 15); |
| 339 | - switch($sPrefix) |
|
| 339 | + switch ($sPrefix) |
|
| 340 | 340 | { |
| 341 | 341 | case 'dialogs.default': |
| 342 | 342 | $this->setDefaultLibraries(); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function point($iXaxis, $sLabel): static |
| 55 | 55 | { |
| 56 | 56 | $this->aPoints[] = $iXaxis; |
| 57 | - if(!$this->aLabels['data']) |
|
| 57 | + if (!$this->aLabels['data']) |
|
| 58 | 58 | { |
| 59 | 59 | $this->aLabels['data'] = []; |
| 60 | 60 | } |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function points($aPoints): int |
| 73 | 73 | { |
| 74 | - foreach($aPoints as $aPoint) |
|
| 74 | + foreach ($aPoints as $aPoint) |
|
| 75 | 75 | { |
| 76 | - if(count($aPoint) == 2) |
|
| 76 | + if (count($aPoint) == 2) |
|
| 77 | 77 | { |
| 78 | 78 | $this->point($aPoint[0], $aPoint[1]); |
| 79 | 79 | } |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function expr($iStart, $iEnd, $iStep, $sJsLabel): int |
| 98 | 98 | { |
| 99 | - for($x = $iStart; $x < $iEnd; $x += $iStep) |
|
| 99 | + for ($x = $iStart; $x < $iEnd; $x += $iStep) |
|
| 100 | 100 | { |
| 101 | 101 | $this->aPoints[] = $x; |
| 102 | 102 | } |
| 103 | - if(($sJsLabel)) |
|
| 103 | + if (($sJsLabel)) |
|
| 104 | 104 | { |
| 105 | 105 | $this->aLabels['func'] = $sJsLabel; |
| 106 | 106 | } |