@@ -221,32 +221,32 @@ discard block |
||
221 | 221 | { |
222 | 222 | $bIsAlert = ($xPlugin instanceof Dialogs\Interfaces\Alert); |
223 | 223 | $bIsConfirm = ($xPlugin instanceof Dialogs\Interfaces\Confirm); |
224 | - if($xPlugin instanceof Request) |
|
224 | + if ($xPlugin instanceof Request) |
|
225 | 225 | { |
226 | 226 | // The name of a request plugin is used as key in the plugin table |
227 | 227 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
228 | 228 | } |
229 | - elseif($xPlugin instanceof Response) |
|
229 | + elseif ($xPlugin instanceof Response) |
|
230 | 230 | { |
231 | 231 | // The name of a response plugin is used as key in the plugin table |
232 | 232 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
233 | 233 | } |
234 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
234 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
235 | 235 | { |
236 | 236 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
237 | 237 | } |
238 | 238 | // This plugin implements the Alert interface |
239 | - if($bIsAlert) |
|
239 | + if ($bIsAlert) |
|
240 | 240 | { |
241 | 241 | $this->setAlert($xPlugin); |
242 | 242 | } |
243 | 243 | // This plugin implements the Confirm interface |
244 | - if($bIsConfirm) |
|
244 | + if ($bIsConfirm) |
|
245 | 245 | { |
246 | 246 | $this->setConfirm($xPlugin); |
247 | 247 | } |
248 | 248 | // Register the plugin as an event listener |
249 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
249 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
250 | 250 | { |
251 | 251 | $this->addEventListener($xPlugin); |
252 | 252 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | private function generateHash() |
277 | 277 | { |
278 | 278 | $sHash = jaxon()->getVersion(); |
279 | - foreach($this->aPlugins as $xPlugin) |
|
279 | + foreach ($this->aPlugins as $xPlugin) |
|
280 | 280 | { |
281 | 281 | $sHash .= $xPlugin->generateHash(); |
282 | 282 | } |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public function canProcessRequest() |
295 | 295 | { |
296 | - foreach($this->aRequestPlugins as $xPlugin) |
|
296 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
297 | 297 | { |
298 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
298 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
299 | 299 | { |
300 | 300 | return true; |
301 | 301 | } |
@@ -314,12 +314,12 @@ discard block |
||
314 | 314 | public function processRequest() |
315 | 315 | { |
316 | 316 | $xUploadPlugin = $this->getRequestPlugin(Jaxon::FILE_UPLOAD); |
317 | - foreach($this->aRequestPlugins as $xPlugin) |
|
317 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
318 | 318 | { |
319 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
319 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
320 | 320 | { |
321 | 321 | // Process uploaded files |
322 | - if($xUploadPlugin != null) |
|
322 | + if ($xUploadPlugin != null) |
|
323 | 323 | { |
324 | 324 | $xUploadPlugin->processRequest(); |
325 | 325 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | public function register($sType, $sCallable, $aOptions = []) |
346 | 346 | { |
347 | - if(!key_exists($sType, $this->aRequestPlugins)) |
|
347 | + if (!key_exists($sType, $this->aRequestPlugins)) |
|
348 | 348 | { |
349 | 349 | throw new \Jaxon\Exception\Error($this->trans('errors.register.plugin', ['name' => $sType])); |
350 | 350 | } |
@@ -372,15 +372,15 @@ discard block |
||
372 | 372 | { |
373 | 373 | // Register user functions |
374 | 374 | $aFunctionsConfig = $xAppConfig->getOption('functions', []); |
375 | - foreach($aFunctionsConfig as $xKey => $xValue) |
|
375 | + foreach ($aFunctionsConfig as $xKey => $xValue) |
|
376 | 376 | { |
377 | - if(is_integer($xKey) && is_string($xValue)) |
|
377 | + if (is_integer($xKey) && is_string($xValue)) |
|
378 | 378 | { |
379 | 379 | $sFunction = $xValue; |
380 | 380 | // Register a function without options |
381 | 381 | $this->register(Jaxon::USER_FUNCTION, $sFunction); |
382 | 382 | } |
383 | - elseif(is_string($xKey) && is_array($xValue)) |
|
383 | + elseif (is_string($xKey) && is_array($xValue)) |
|
384 | 384 | { |
385 | 385 | $sFunction = $xKey; |
386 | 386 | $aOptions = $xValue; |
@@ -396,25 +396,25 @@ discard block |
||
396 | 396 | |
397 | 397 | // Register classes and directories |
398 | 398 | $aClassesConfig = $xAppConfig->getOption('classes', []); |
399 | - foreach($aClassesConfig as $xKey => $xValue) |
|
399 | + foreach ($aClassesConfig as $xKey => $xValue) |
|
400 | 400 | { |
401 | - if(is_integer($xKey) && is_string($xValue)) |
|
401 | + if (is_integer($xKey) && is_string($xValue)) |
|
402 | 402 | { |
403 | 403 | $sClass = $xValue; |
404 | 404 | // Register a class without options |
405 | 405 | $this->register(Jaxon::CALLABLE_CLASS, $sClass); |
406 | 406 | } |
407 | - elseif(is_string($xKey) && is_array($xValue)) |
|
407 | + elseif (is_string($xKey) && is_array($xValue)) |
|
408 | 408 | { |
409 | 409 | $sClass = $xKey; |
410 | 410 | $aOptions = $xValue; |
411 | 411 | // Register a class with options |
412 | 412 | $this->register(Jaxon::CALLABLE_CLASS, $sClass, $aOptions); |
413 | 413 | } |
414 | - elseif(is_integer($xKey) && is_array($xValue)) |
|
414 | + elseif (is_integer($xKey) && is_array($xValue)) |
|
415 | 415 | { |
416 | 416 | // The directory path is required |
417 | - if(!key_exists('directory', $xValue)) |
|
417 | + if (!key_exists('directory', $xValue)) |
|
418 | 418 | { |
419 | 419 | continue; |
420 | 420 | // Todo: throw an exception |
@@ -422,17 +422,17 @@ discard block |
||
422 | 422 | // Registering a directory |
423 | 423 | $sDirectory = $xValue['directory']; |
424 | 424 | $aOptions = []; |
425 | - if(key_exists('options', $xValue) && |
|
425 | + if (key_exists('options', $xValue) && |
|
426 | 426 | is_array($xValue['options']) || is_string($xValue['options'])) |
427 | 427 | { |
428 | 428 | $aOptions = $xValue['options']; |
429 | 429 | } |
430 | 430 | // Setup directory options |
431 | - if(key_exists('namespace', $xValue)) |
|
431 | + if (key_exists('namespace', $xValue)) |
|
432 | 432 | { |
433 | 433 | $aOptions['namespace'] = $xValue['namespace']; |
434 | 434 | } |
435 | - if(key_exists('separator', $xValue)) |
|
435 | + if (key_exists('separator', $xValue)) |
|
436 | 436 | { |
437 | 437 | $aOptions['separator'] = $xValue['separator']; |
438 | 438 | } |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | */ |
455 | 455 | private function getJsLibUri() |
456 | 456 | { |
457 | - if(!$this->hasOption('js.lib.uri')) |
|
457 | + if (!$this->hasOption('js.lib.uri')) |
|
458 | 458 | { |
459 | 459 | // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
460 | 460 | return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/'; |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | // The jsDelivr CDN only hosts minified files |
478 | 478 | // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
479 | 479 | // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files. |
480 | - if(($this->getOption('js.app.minify'))) |
|
480 | + if (($this->getOption('js.app.minify'))) |
|
481 | 481 | { |
482 | 482 | return '.min.js'; |
483 | 483 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | // Check config options |
495 | 495 | // - The js.app.extern option must be set to true |
496 | 496 | // - The js.app.uri and js.app.dir options must be set to non null values |
497 | - if(!$this->getOption('js.app.extern') || |
|
497 | + if (!$this->getOption('js.app.extern') || |
|
498 | 498 | !$this->getOption('js.app.uri') || |
499 | 499 | !$this->getOption('js.app.dir')) |
500 | 500 | { |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | // Check dir access |
504 | 504 | // - The js.app.dir must be writable |
505 | 505 | $sJsAppDir = $this->getOption('js.app.dir'); |
506 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
506 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
507 | 507 | { |
508 | 508 | return false; |
509 | 509 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | */ |
518 | 518 | private function setTemplateCacheDir() |
519 | 519 | { |
520 | - if($this->hasOption('core.template.cache_dir')) |
|
520 | + if ($this->hasOption('core.template.cache_dir')) |
|
521 | 521 | { |
522 | 522 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
523 | 523 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | |
540 | 540 | // Add component files to the javascript file array; |
541 | 541 | $aJsFiles = array($sJsCoreUrl); |
542 | - if($this->getOption('core.debug.on')) |
|
542 | + if ($this->getOption('core.debug.on')) |
|
543 | 543 | { |
544 | 544 | $aJsFiles[] = $sJsDebugUrl; |
545 | 545 | $aJsFiles[] = $sJsLanguageUrl; |
@@ -555,17 +555,17 @@ discard block |
||
555 | 555 | 'sJsOptions' => $this->getOption('js.app.options'), |
556 | 556 | 'aUrls' => $aJsFiles, |
557 | 557 | )); |
558 | - foreach($this->aResponsePlugins as $xPlugin) |
|
558 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
559 | 559 | { |
560 | - if(($str = trim($xPlugin->getJs()))) |
|
560 | + if (($str = trim($xPlugin->getJs()))) |
|
561 | 561 | { |
562 | 562 | $sCode .= rtrim($str, " \n") . "\n"; |
563 | 563 | } |
564 | 564 | } |
565 | - foreach($this->aPackages as $sClass) |
|
565 | + foreach ($this->aPackages as $sClass) |
|
566 | 566 | { |
567 | 567 | $xPackage = jaxon()->di()->get($sClass); |
568 | - if(($str = trim($xPackage->js()))) |
|
568 | + if (($str = trim($xPackage->js()))) |
|
569 | 569 | { |
570 | 570 | $sCode .= rtrim($str, " \n") . "\n"; |
571 | 571 | } |
@@ -584,17 +584,17 @@ discard block |
||
584 | 584 | $this->setTemplateCacheDir(); |
585 | 585 | |
586 | 586 | $sCode = ''; |
587 | - foreach($this->aResponsePlugins as $xPlugin) |
|
587 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
588 | 588 | { |
589 | - if(($str = trim($xPlugin->getCss()))) |
|
589 | + if (($str = trim($xPlugin->getCss()))) |
|
590 | 590 | { |
591 | 591 | $sCode .= rtrim($str, " \n") . "\n"; |
592 | 592 | } |
593 | 593 | } |
594 | - foreach($this->aPackages as $sClass) |
|
594 | + foreach ($this->aPackages as $sClass) |
|
595 | 595 | { |
596 | 596 | $xPackage = jaxon()->di()->get($sClass); |
597 | - if(($str = trim($xPackage->css()))) |
|
597 | + if (($str = trim($xPackage->css()))) |
|
598 | 598 | { |
599 | 599 | $sCode .= rtrim($str, " \n") . "\n"; |
600 | 600 | } |
@@ -658,17 +658,17 @@ discard block |
||
658 | 658 | private function getReadyScript() |
659 | 659 | { |
660 | 660 | $sPluginScript = ''; |
661 | - foreach($this->aResponsePlugins as $xPlugin) |
|
661 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
662 | 662 | { |
663 | - if(($str = trim($xPlugin->getScript()))) |
|
663 | + if (($str = trim($xPlugin->getScript()))) |
|
664 | 664 | { |
665 | 665 | $sPluginScript .= "\n" . trim($str, " \n"); |
666 | 666 | } |
667 | 667 | } |
668 | - foreach($this->aPackages as $sClass) |
|
668 | + foreach ($this->aPackages as $sClass) |
|
669 | 669 | { |
670 | 670 | $xPackage = jaxon()->di()->get($sClass); |
671 | - if(($str = trim($xPackage->ready()))) |
|
671 | + if (($str = trim($xPackage->ready()))) |
|
672 | 672 | { |
673 | 673 | $sPluginScript .= "\n" . trim($str, " \n"); |
674 | 674 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | { |
692 | 692 | // Get the config and plugins scripts |
693 | 693 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
694 | - foreach($this->aRequestPlugins as $xPlugin) |
|
694 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
695 | 695 | { |
696 | 696 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
697 | 697 | } |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | // Set the template engine cache dir |
714 | 714 | $this->setTemplateCacheDir(); |
715 | 715 | |
716 | - if($this->canExportJavascript()) |
|
716 | + if ($this->canExportJavascript()) |
|
717 | 717 | { |
718 | 718 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
719 | 719 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -722,13 +722,13 @@ discard block |
||
722 | 722 | $sHash = $this->generateHash(); |
723 | 723 | $sOutFile = $sHash . '.js'; |
724 | 724 | $sMinFile = $sHash . '.min.js'; |
725 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
725 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
726 | 726 | { |
727 | 727 | file_put_contents($sJsAppDir . $sOutFile, $this->getAllScripts()); |
728 | 728 | } |
729 | - if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
729 | + if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
730 | 730 | { |
731 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
731 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
732 | 732 | { |
733 | 733 | $sOutFile = $sMinFile; |
734 | 734 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | */ |
762 | 762 | public function getResponsePlugin($sName) |
763 | 763 | { |
764 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
764 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
765 | 765 | { |
766 | 766 | return $this->aResponsePlugins[$sName]; |
767 | 767 | } |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | */ |
778 | 778 | public function getRequestPlugin($sName) |
779 | 779 | { |
780 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
780 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
781 | 781 | { |
782 | 782 | return $this->aRequestPlugins[$sName]; |
783 | 783 | } |