@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function shallIncludeAssets(Plugin $xPlugin): bool |
| 72 | 72 | { |
| 73 | - if($this->xConfigManager->getOption('assets.include.all', true)) |
|
| 73 | + if ($this->xConfigManager->getOption('assets.include.all', true)) |
|
| 74 | 74 | { |
| 75 | 75 | return true; |
| 76 | 76 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $sJsLibUri = rtrim($this->xConfigManager->getOption('js.lib.uri', self::JS_LIB_URL), '/') . '/'; |
| 91 | 91 | // Add component files to the javascript file array; |
| 92 | 92 | $aJsFiles = [$sJsLibUri . 'jaxon.core' . $sJsExtension]; |
| 93 | - if($this->xConfigManager->getOption('core.debug.on')) |
|
| 93 | + if ($this->xConfigManager->getOption('core.debug.on')) |
|
| 94 | 94 | { |
| 95 | 95 | $sLanguage = $this->xConfigManager->getOption('core.language'); |
| 96 | 96 | $aJsFiles[] = $sJsLibUri . 'jaxon.debug' . $sJsExtension; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function getOptionVars(): array |
| 109 | 109 | { |
| 110 | - if(!$this->xConfigManager->hasOption('core.request.uri')) |
|
| 110 | + if (!$this->xConfigManager->hasOption('core.request.uri')) |
|
| 111 | 111 | { |
| 112 | 112 | $this->xConfigManager->setOption('core.request.uri', $this->xParameterReader->uri()); |
| 113 | 113 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | // Check config options |
| 141 | 141 | // - The js.app.export option must be set to true |
| 142 | 142 | // - The js.app.uri and js.app.dir options must be set to non null values |
| 143 | - if(!$this->xConfigManager->getOption('js.app.export', false) || |
|
| 143 | + if (!$this->xConfigManager->getOption('js.app.export', false) || |
|
| 144 | 144 | !$this->xConfigManager->getOption('js.app.uri') || |
| 145 | 145 | !$this->xConfigManager->getOption('js.app.dir')) |
| 146 | 146 | { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function createJsFiles(CodeGenerator $xCodeGenerator): string |
| 160 | 160 | { |
| 161 | - if(!$this->shallCreateJsFiles()) |
|
| 161 | + if (!$this->shallCreateJsFiles()) |
|
| 162 | 162 | { |
| 163 | 163 | return ''; |
| 164 | 164 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $sJsFileName = $this->xConfigManager->getOption('js.app.file') ?: $xCodeGenerator->getHash(); |
| 168 | 168 | $sJsDirectory = rtrim($this->xConfigManager->getOption('js.app.dir'), '\/') . DIRECTORY_SEPARATOR; |
| 169 | 169 | // - The js.app.dir must be writable |
| 170 | - if(!$sJsFileName || !is_dir($sJsDirectory) || !is_writable($sJsDirectory)) |
|
| 170 | + if (!$sJsFileName || !is_dir($sJsDirectory) || !is_writable($sJsDirectory)) |
|
| 171 | 171 | { |
| 172 | 172 | return ''; |
| 173 | 173 | } |
@@ -175,15 +175,15 @@ discard block |
||
| 175 | 175 | $sJsFilePath = $sJsDirectory . $sJsFileName . '.js'; |
| 176 | 176 | $sJsMinFilePath = $sJsDirectory . $sJsFileName . '.min.js'; |
| 177 | 177 | $sJsFileUri = rtrim($this->xConfigManager->getOption('js.app.uri'), '/') . "/$sJsFileName"; |
| 178 | - if(!is_file($sJsFilePath) && !@file_put_contents($sJsFilePath, $xCodeGenerator->getJsScript())) |
|
| 178 | + if (!is_file($sJsFilePath) && !@file_put_contents($sJsFilePath, $xCodeGenerator->getJsScript())) |
|
| 179 | 179 | { |
| 180 | 180 | return ''; |
| 181 | 181 | } |
| 182 | - if(!$this->xConfigManager->getOption('js.app.minify', false)) |
|
| 182 | + if (!$this->xConfigManager->getOption('js.app.minify', false)) |
|
| 183 | 183 | { |
| 184 | 184 | return $sJsFileUri . '.js'; |
| 185 | 185 | } |
| 186 | - if(!is_file($sJsMinFilePath) && !$this->xMinifier->minify($sJsFilePath, $sJsMinFilePath)) |
|
| 186 | + if (!is_file($sJsMinFilePath) && !$this->xMinifier->minify($sJsFilePath, $sJsMinFilePath)) |
|
| 187 | 187 | { |
| 188 | 188 | // If the file cannot be minified, return the plain js file. |
| 189 | 189 | return $sJsFileUri . '.js'; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | private function generatePluginCodes(string $sClassName) |
| 142 | 142 | { |
| 143 | 143 | $xGenerator = $this->di->g($sClassName); |
| 144 | - if(!is_subclass_of($xGenerator, Plugin::class) || $this->xAssetManager->shallIncludeAssets($xGenerator)) |
|
| 144 | + if (!is_subclass_of($xGenerator, Plugin::class) || $this->xAssetManager->shallIncludeAssets($xGenerator)) |
|
| 145 | 145 | { |
| 146 | 146 | // HTML tags for CSS |
| 147 | 147 | $this->sCss = trim($this->sCss) . "\n" . trim($xGenerator->getCss(), " \n"); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | // Javascript code |
| 152 | 152 | $this->sJsScript = trim($this->sJsScript) . "\n\n" . trim($xGenerator->getScript(), " \n"); |
| 153 | - if($xGenerator->readyEnabled()) |
|
| 153 | + if ($xGenerator->readyEnabled()) |
|
| 154 | 154 | { |
| 155 | 155 | $sScriptAttr = $xGenerator->readyInlined() ? 'sJsInlineScript' : 'sJsReadyScript'; |
| 156 | 156 | $this->$sScriptAttr = trim($this->$sScriptAttr) . "\n\n" . trim($xGenerator->getReadyScript(), " \n"); |
@@ -169,11 +169,11 @@ discard block |
||
| 169 | 169 | $this->sJsScript = trim($this->sJsScript, " \n"); |
| 170 | 170 | $this->sJsReadyScript = trim($this->sJsReadyScript, " \n"); |
| 171 | 171 | $this->sJsInlineScript = trim($this->sJsInlineScript, " \n"); |
| 172 | - if(($this->sJsReadyScript)) |
|
| 172 | + if (($this->sJsReadyScript)) |
|
| 173 | 173 | { |
| 174 | 174 | $this->sJsReadyScript = $this->render('ready.js', ['sScript' => $this->sJsReadyScript . "\n"]); |
| 175 | 175 | } |
| 176 | - if(($this->sJsInlineScript)) |
|
| 176 | + if (($this->sJsInlineScript)) |
|
| 177 | 177 | { |
| 178 | 178 | $this->sJsInlineScript = $this->render('ready.js', ['sScript' => $this->sJsInlineScript . "\n"]); |
| 179 | 179 | } |
@@ -189,14 +189,14 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | private function generateCodes() |
| 191 | 191 | { |
| 192 | - if($this->bGenerated) |
|
| 192 | + if ($this->bGenerated) |
|
| 193 | 193 | { |
| 194 | 194 | return; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $this->xAssetManager = $this->di->getAssetManager(); |
| 198 | 198 | $this->sJsOptions = $this->xAssetManager->getJsOptions(); |
| 199 | - foreach($this->xPluginManager->getCodeGenerators() as $sClassName) |
|
| 199 | + foreach ($this->xPluginManager->getCodeGenerators() as $sClassName) |
|
| 200 | 200 | { |
| 201 | 201 | $this->generatePluginCodes($sClassName); |
| 202 | 202 | } |
@@ -256,16 +256,16 @@ discard block |
||
| 256 | 256 | { |
| 257 | 257 | $this->generateCodes(); |
| 258 | 258 | $sScript = ''; |
| 259 | - if(($bIncludeCss)) |
|
| 259 | + if (($bIncludeCss)) |
|
| 260 | 260 | { |
| 261 | 261 | $sScript .= $this->getCss() . "\n"; |
| 262 | 262 | } |
| 263 | - if(($bIncludeJs)) |
|
| 263 | + if (($bIncludeJs)) |
|
| 264 | 264 | { |
| 265 | 265 | $sScript .= $this->getJs() . "\n"; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if(!($sUrl = $this->xAssetManager->createJsFiles($this))) |
|
| 268 | + if (!($sUrl = $this->xAssetManager->createJsFiles($this))) |
|
| 269 | 269 | { |
| 270 | 270 | return trim($sScript) . "\n\n" . $this->render('wrapper.js', |
| 271 | 271 | ['sScript' => trim($this->sJsScript) . "\n\n" . trim($this->sJsInlineScript)]); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function registerLibrary(string $sClassName, string $sLibraryName) |
| 108 | 108 | { |
| 109 | - if(!($aInterfaces = class_implements($sClassName))) |
|
| 109 | + if (!($aInterfaces = class_implements($sClassName))) |
|
| 110 | 110 | { |
| 111 | 111 | // The class is invalid. |
| 112 | 112 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $bIsQuestion = in_array(QuestionInterface::class, $aInterfaces); |
| 117 | 117 | $bIsMessage = in_array(MessageInterface::class, $aInterfaces); |
| 118 | 118 | $bIsModal = in_array(ModalInterface::class, $aInterfaces); |
| 119 | - if(!$bIsQuestion && !$bIsMessage && !$bIsModal) |
|
| 119 | + if (!$bIsQuestion && !$bIsMessage && !$bIsModal) |
|
| 120 | 120 | { |
| 121 | 121 | // The class is invalid. |
| 122 | 122 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function setQuestionLibrary(string $sLibraryName) |
| 157 | 157 | { |
| 158 | - if(!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['question']) |
|
| 158 | + if (!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['question']) |
|
| 159 | 159 | { |
| 160 | 160 | $sMessage = $this->xTranslator->trans('errors.dialog.library', |
| 161 | 161 | ['type' => 'question', 'name' => $sLibraryName]); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function setMessageLibrary(string $sLibraryName) |
| 186 | 186 | { |
| 187 | - if(!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['message']) |
|
| 187 | + if (!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['message']) |
|
| 188 | 188 | { |
| 189 | 189 | $sMessage = $this->xTranslator->trans('errors.dialog.library', |
| 190 | 190 | ['type' => 'message', 'name' => $sLibraryName]); |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function setModalLibrary(string $sLibraryName) |
| 215 | 215 | { |
| 216 | - if(!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['modal']) |
|
| 216 | + if (!isset($this->aLibraries[$sLibraryName]) || !$this->aLibraries[$sLibraryName]['modal']) |
|
| 217 | 217 | { |
| 218 | 218 | $sMessage = $this->xTranslator->trans('errors.dialog.library', |
| 219 | 219 | ['type' => 'modal', 'name' => $sLibraryName]); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | protected function registerLibraries() |
| 254 | 254 | { |
| 255 | 255 | $aLibraries = $this->xConfigManager->getOption('dialogs.libraries', []); |
| 256 | - foreach($aLibraries as $sLibraryName => $sClassName) |
|
| 256 | + foreach ($aLibraries as $sLibraryName => $sClassName) |
|
| 257 | 257 | { |
| 258 | 258 | $this->registerLibrary($sClassName, $sLibraryName); |
| 259 | 259 | } |
@@ -268,17 +268,17 @@ discard block |
||
| 268 | 268 | protected function setDefaultLibraries() |
| 269 | 269 | { |
| 270 | 270 | // Set the default modal library |
| 271 | - if(($sLibraryName = $this->xConfigManager->getOption('dialogs.default.modal', ''))) |
|
| 271 | + if (($sLibraryName = $this->xConfigManager->getOption('dialogs.default.modal', ''))) |
|
| 272 | 272 | { |
| 273 | 273 | $this->setModalLibrary($sLibraryName); |
| 274 | 274 | } |
| 275 | 275 | // Set the default message library |
| 276 | - if(($sLibraryName = $this->xConfigManager->getOption('dialogs.default.message', ''))) |
|
| 276 | + if (($sLibraryName = $this->xConfigManager->getOption('dialogs.default.message', ''))) |
|
| 277 | 277 | { |
| 278 | 278 | $this->setMessageLibrary($sLibraryName); |
| 279 | 279 | } |
| 280 | 280 | // Set the default question library |
| 281 | - if(($sLibraryName = $this->xConfigManager->getOption('dialogs.default.question', ''))) |
|
| 281 | + if (($sLibraryName = $this->xConfigManager->getOption('dialogs.default.question', ''))) |
|
| 282 | 282 | { |
| 283 | 283 | $this->setQuestionLibrary($sLibraryName); |
| 284 | 284 | } |
@@ -290,19 +290,19 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | public function onChange(Config $xConfig, string $sName) |
| 292 | 292 | { |
| 293 | - if($sName === '') |
|
| 293 | + if ($sName === '') |
|
| 294 | 294 | { |
| 295 | 295 | // Reset the default libraries any time the config is changed. |
| 296 | 296 | $this->registerLibraries(); |
| 297 | 297 | $this->setDefaultLibraries(); |
| 298 | 298 | return; |
| 299 | 299 | } |
| 300 | - if(substr($sName, 0, 17) === 'dialogs.libraries') |
|
| 300 | + if (substr($sName, 0, 17) === 'dialogs.libraries') |
|
| 301 | 301 | { |
| 302 | 302 | $this->registerLibraries(); |
| 303 | 303 | return; |
| 304 | 304 | } |
| 305 | - if(substr($sName, 0, 15) === 'dialogs.default') |
|
| 305 | + if (substr($sName, 0, 15) === 'dialogs.default') |
|
| 306 | 306 | { |
| 307 | 307 | $this->setDefaultLibraries(); |
| 308 | 308 | } |