@@ -263,32 +263,32 @@ discard block |
||
263 | 263 | { |
264 | 264 | $bIsAlert = ($xPlugin instanceof \Jaxon\Request\Interfaces\Alert); |
265 | 265 | $bIsConfirm = ($xPlugin instanceof \Jaxon\Request\Interfaces\Confirm); |
266 | - if($xPlugin instanceof Request) |
|
266 | + if ($xPlugin instanceof Request) |
|
267 | 267 | { |
268 | 268 | // The name of a request plugin is used as key in the plugin table |
269 | 269 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
270 | 270 | } |
271 | - elseif($xPlugin instanceof Response) |
|
271 | + elseif ($xPlugin instanceof Response) |
|
272 | 272 | { |
273 | 273 | // The name of a response plugin is used as key in the plugin table |
274 | 274 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
275 | 275 | } |
276 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
276 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
277 | 277 | { |
278 | 278 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
279 | 279 | } |
280 | 280 | // This plugin implements the Alert interface |
281 | - if($bIsAlert) |
|
281 | + if ($bIsAlert) |
|
282 | 282 | { |
283 | 283 | $this->setAlert($xPlugin); |
284 | 284 | } |
285 | 285 | // This plugin implements the Confirm interface |
286 | - if($bIsConfirm) |
|
286 | + if ($bIsConfirm) |
|
287 | 287 | { |
288 | 288 | $this->setConfirm($xPlugin); |
289 | 289 | } |
290 | 290 | // Register the plugin as an event listener |
291 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
291 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
292 | 292 | { |
293 | 293 | $this->addEventListener($xPlugin); |
294 | 294 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | private function generateHash() |
305 | 305 | { |
306 | 306 | $sHash = $this->getVersion(); |
307 | - foreach($this->aPlugins as $xPlugin) |
|
307 | + foreach ($this->aPlugins as $xPlugin) |
|
308 | 308 | { |
309 | 309 | $sHash .= $xPlugin->generateHash(); |
310 | 310 | } |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | */ |
322 | 322 | public function canProcessRequest() |
323 | 323 | { |
324 | - foreach($this->aRequestPlugins as $xPlugin) |
|
324 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
325 | 325 | { |
326 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
326 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
327 | 327 | { |
328 | 328 | return true; |
329 | 329 | } |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | public function processRequest() |
343 | 343 | { |
344 | 344 | $xUploadPlugin = $this->getRequestPlugin(Jaxon::FILE_UPLOAD); |
345 | - foreach($this->aRequestPlugins as $xPlugin) |
|
345 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
346 | 346 | { |
347 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
347 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
348 | 348 | { |
349 | 349 | // Process uploaded files |
350 | - if($xUploadPlugin != null) |
|
350 | + if ($xUploadPlugin != null) |
|
351 | 351 | { |
352 | 352 | $xUploadPlugin->processRequest(); |
353 | 353 | } |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function register($aArgs) |
373 | 373 | { |
374 | - foreach($this->aRequestPlugins as $xPlugin) |
|
374 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
375 | 375 | { |
376 | 376 | $mResult = $xPlugin->register($aArgs); |
377 | - if($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
377 | + if ($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
378 | 378 | { |
379 | 379 | return $mResult; |
380 | 380 | } |
@@ -394,37 +394,37 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function addClassDir($sDirectory, $sNamespace = '', $sSeparator = '.', array $aProtected = array()) |
396 | 396 | { |
397 | - if(!is_dir(($sDirectory = trim($sDirectory)))) |
|
397 | + if (!is_dir(($sDirectory = trim($sDirectory)))) |
|
398 | 398 | { |
399 | 399 | return false; |
400 | 400 | } |
401 | 401 | // Only '.' and '_' are allowed to be used as separator. Any other value is ignored and '.' is used instead. |
402 | - if(($sSeparator = trim($sSeparator)) != '_') |
|
402 | + if (($sSeparator = trim($sSeparator)) != '_') |
|
403 | 403 | { |
404 | 404 | $sSeparator = '.'; |
405 | 405 | } |
406 | - if(!($sNamespace = trim($sNamespace, ' \\'))) |
|
406 | + if (!($sNamespace = trim($sNamespace, ' \\'))) |
|
407 | 407 | { |
408 | 408 | $sNamespace = ''; |
409 | 409 | } |
410 | - if(($sNamespace)) |
|
410 | + if (($sNamespace)) |
|
411 | 411 | { |
412 | 412 | // If there is an autoloader, register the dir with PSR4 autoloading |
413 | - if(($this->xAutoloader)) |
|
413 | + if (($this->xAutoloader)) |
|
414 | 414 | { |
415 | 415 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
416 | 416 | } |
417 | 417 | } |
418 | - elseif(($this->xAutoloader)) |
|
418 | + elseif (($this->xAutoloader)) |
|
419 | 419 | { |
420 | 420 | // If there is an autoloader, register the dir with classmap autoloading |
421 | 421 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
422 | 422 | $itFile = new RecursiveIteratorIterator($itDir); |
423 | 423 | // Iterate on dir content |
424 | - foreach($itFile as $xFile) |
|
424 | + foreach ($itFile as $xFile) |
|
425 | 425 | { |
426 | 426 | // skip everything except PHP files |
427 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
427 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
428 | 428 | { |
429 | 429 | continue; |
430 | 430 | } |
@@ -460,33 +460,33 @@ discard block |
||
460 | 460 | $sClassPath = substr($xFile->getPath(), strlen($sDirectory)); |
461 | 461 | $sClassPath = str_replace($sDS, '\\', trim($sClassPath, $sDS)); |
462 | 462 | $sClassName = $xFile->getBasename('.php'); |
463 | - if(($sNamespace)) |
|
463 | + if (($sNamespace)) |
|
464 | 464 | { |
465 | 465 | $sClassPath = ($sClassPath) ? $sNamespace . '\\' . $sClassPath : $sNamespace; |
466 | 466 | $sClassName = '\\' . $sClassPath . '\\' . $sClassName; |
467 | 467 | } |
468 | 468 | // Require the file only if autoload is enabled but there is no autoloader |
469 | - if(($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
469 | + if (($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
470 | 470 | { |
471 | 471 | require_once($xFile->getPathname()); |
472 | 472 | } |
473 | 473 | // Create and register an instance of the class |
474 | - if(!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
474 | + if (!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
475 | 475 | { |
476 | 476 | $aOptions['*'] = array(); |
477 | 477 | } |
478 | 478 | $aOptions['*']['separator'] = $sSeparator; |
479 | - if(($sNamespace)) |
|
479 | + if (($sNamespace)) |
|
480 | 480 | { |
481 | 481 | $aOptions['*']['namespace'] = $sNamespace; |
482 | 482 | } |
483 | - if(($sClassPath)) |
|
483 | + if (($sClassPath)) |
|
484 | 484 | { |
485 | 485 | $aOptions['*']['classpath'] = $sClassPath; |
486 | 486 | } |
487 | 487 | // Filter excluded methods |
488 | - $aProtected = array_filter($aProtected, function ($sName) {return is_string($sName);}); |
|
489 | - if(count($aProtected) > 0) |
|
488 | + $aProtected = array_filter($aProtected, function($sName) {return is_string($sName); }); |
|
489 | + if (count($aProtected) > 0) |
|
490 | 490 | { |
491 | 491 | $aOptions['*']['protected'] = $aProtected; |
492 | 492 | } |
@@ -505,13 +505,13 @@ discard block |
||
505 | 505 | $sDS = DIRECTORY_SEPARATOR; |
506 | 506 | // Change the keys in $aOptions to have "\" as separator |
507 | 507 | $aNewOptions = array(); |
508 | - foreach($aOptions as $key => $aOption) |
|
508 | + foreach ($aOptions as $key => $aOption) |
|
509 | 509 | { |
510 | 510 | $key = trim(str_replace(['.', '_'], ['\\', '\\'], $key), ' \\'); |
511 | 511 | $aNewOptions[$key] = $aOption; |
512 | 512 | } |
513 | 513 | |
514 | - foreach($this->aClassDirs as $aClassDir) |
|
514 | + foreach ($this->aClassDirs as $aClassDir) |
|
515 | 515 | { |
516 | 516 | // Get the directory |
517 | 517 | $sDirectory = $aClassDir['directory']; |
@@ -521,10 +521,10 @@ discard block |
||
521 | 521 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
522 | 522 | $itFile = new RecursiveIteratorIterator($itDir); |
523 | 523 | // Iterate on dir content |
524 | - foreach($itFile as $xFile) |
|
524 | + foreach ($itFile as $xFile) |
|
525 | 525 | { |
526 | 526 | // skip everything except PHP files |
527 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
527 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
528 | 528 | { |
529 | 529 | continue; |
530 | 530 | } |
@@ -533,17 +533,17 @@ discard block |
||
533 | 533 | $sClassPath = substr($xFile->getPath(), strlen($sDirectory)); |
534 | 534 | $sClassPath = trim(str_replace($sDS, '\\', $sClassPath), '\\'); |
535 | 535 | $sClassName = $xFile->getBasename('.php'); |
536 | - if(($sClassPath)) |
|
536 | + if (($sClassPath)) |
|
537 | 537 | { |
538 | 538 | $sClassName = $sClassPath . '\\' . $sClassName; |
539 | 539 | } |
540 | - if(($sNamespace)) |
|
540 | + if (($sNamespace)) |
|
541 | 541 | { |
542 | 542 | $sClassName = $sNamespace . '\\' . $sClassName; |
543 | 543 | } |
544 | 544 | // Get the class options |
545 | 545 | $aClassOptions = []; |
546 | - if(array_key_exists($sClassName, $aNewOptions)) |
|
546 | + if (array_key_exists($sClassName, $aNewOptions)) |
|
547 | 547 | { |
548 | 548 | $aClassOptions = $aNewOptions[$sClassName]; |
549 | 549 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | */ |
565 | 565 | public function registerClass($sClassName, array $aOptions = array()) |
566 | 566 | { |
567 | - if(!($sClassName = trim($sClassName, ' \\._'))) |
|
567 | + if (!($sClassName = trim($sClassName, ' \\._'))) |
|
568 | 568 | { |
569 | 569 | return false; |
570 | 570 | } |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | // Replace "." and "_" with antislashes, and set the class path. |
574 | 574 | $sClassName = str_replace(['.', '_'], ['\\', '\\'], $sClassName); |
575 | 575 | $sClassPath = ''; |
576 | - if(($nLastSlashPosition = strrpos($sClassName, '\\')) !== false) |
|
576 | + if (($nLastSlashPosition = strrpos($sClassName, '\\')) !== false) |
|
577 | 577 | { |
578 | 578 | $sClassPath = substr($sClassName, 0, $nLastSlashPosition); |
579 | 579 | $sClassName = substr($sClassName, $nLastSlashPosition + 1); |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | $sPartPath = str_replace('\\', $sDS, $sClassPath) . $sDS . $sClassName . '.php'; |
583 | 583 | |
584 | 584 | // Search for the class file in all directories. |
585 | - foreach($this->aClassDirs as $aClassDir) |
|
585 | + foreach ($this->aClassDirs as $aClassDir) |
|
586 | 586 | { |
587 | 587 | // Get the separator |
588 | 588 | $sSeparator = $aClassDir['separator']; |
@@ -591,15 +591,15 @@ discard block |
||
591 | 591 | $nLen = strlen($sNamespace); |
592 | 592 | $sFullPath = ''; |
593 | 593 | // Check if the class belongs to the namespace |
594 | - if(($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
|
594 | + if (($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
|
595 | 595 | { |
596 | 596 | $sFullPath = $aClassDir['directory'] . $sDS . substr($sPartPath, $nLen + 1); |
597 | 597 | } |
598 | - elseif(!($sNamespace)) |
|
598 | + elseif (!($sNamespace)) |
|
599 | 599 | { |
600 | 600 | $sFullPath = $aClassDir['directory'] . $sDS . $sPartPath; |
601 | 601 | } |
602 | - if(($sFullPath) && is_file($sFullPath)) |
|
602 | + if (($sFullPath) && is_file($sFullPath)) |
|
603 | 603 | { |
604 | 604 | // Found the file in this directory |
605 | 605 | $xFileInfo = new \SplFileInfo($sFullPath); |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | { |
624 | 624 | $xObject = null; // The user registered object |
625 | 625 | $xPlugin = $this->getRequestPlugin('CallableObject'); // The CallableObject plugin |
626 | - if(($xPlugin)) |
|
626 | + if (($xPlugin)) |
|
627 | 627 | { |
628 | 628 | $xObject = $xPlugin->getRegisteredObject($sClassName); |
629 | 629 | } |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | */ |
638 | 638 | private function getJsLibUri() |
639 | 639 | { |
640 | - if(!$this->hasOption('js.lib.uri')) |
|
640 | + if (!$this->hasOption('js.lib.uri')) |
|
641 | 641 | { |
642 | 642 | // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
643 | 643 | return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/'; |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | // The jsDelivr CDN only hosts minified files |
661 | 661 | // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
662 | 662 | // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files. |
663 | - if(($this->getOption('js.app.minify'))) |
|
663 | + if (($this->getOption('js.app.minify'))) |
|
664 | 664 | { |
665 | 665 | return '.min.js'; |
666 | 666 | } |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | // Check config options |
678 | 678 | // - The js.app.extern option must be set to true |
679 | 679 | // - The js.app.uri and js.app.dir options must be set to non null values |
680 | - if(!$this->getOption('js.app.extern') || |
|
680 | + if (!$this->getOption('js.app.extern') || |
|
681 | 681 | !$this->getOption('js.app.uri') || |
682 | 682 | !$this->getOption('js.app.dir')) |
683 | 683 | { |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | // Check dir access |
687 | 687 | // - The js.app.dir must be writable |
688 | 688 | $sJsAppDir = $this->getOption('js.app.dir'); |
689 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
689 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
690 | 690 | { |
691 | 691 | return false; |
692 | 692 | } |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | */ |
701 | 701 | private function setTemplateCacheDir() |
702 | 702 | { |
703 | - if($this->hasOption('core.template.cache_dir')) |
|
703 | + if ($this->hasOption('core.template.cache_dir')) |
|
704 | 704 | { |
705 | 705 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
706 | 706 | } |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | |
723 | 723 | // Add component files to the javascript file array; |
724 | 724 | $aJsFiles = array($sJsCoreUrl); |
725 | - if($this->getOption('core.debug.on')) |
|
725 | + if ($this->getOption('core.debug.on')) |
|
726 | 726 | { |
727 | 727 | $aJsFiles[] = $sJsDebugUrl; |
728 | 728 | $aJsFiles[] = $sJsLanguageUrl; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | 'sJsOptions' => $this->getOption('js.app.options'), |
739 | 739 | 'aUrls' => $aJsFiles, |
740 | 740 | )); |
741 | - foreach($this->aResponsePlugins as $xPlugin) |
|
741 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
742 | 742 | { |
743 | 743 | $sCode .= rtrim($xPlugin->getJs(), " \n") . "\n"; |
744 | 744 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | $this->setTemplateCacheDir(); |
757 | 757 | |
758 | 758 | $sCode = ''; |
759 | - foreach($this->aResponsePlugins as $xPlugin) |
|
759 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
760 | 760 | { |
761 | 761 | $sCode .= rtrim($xPlugin->getCss(), " \n") . "\n"; |
762 | 762 | } |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | ));*/ |
845 | 845 | |
846 | 846 | $sPluginScript = ''; |
847 | - foreach($this->aResponsePlugins as $xPlugin) |
|
847 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
848 | 848 | { |
849 | 849 | $sPluginScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
850 | 850 | } |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | { |
875 | 875 | // Get the config and plugins scripts |
876 | 876 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
877 | - foreach($this->aRequestPlugins as $xPlugin) |
|
877 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
878 | 878 | { |
879 | 879 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
880 | 880 | } |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | // Set the template engine cache dir |
897 | 897 | $this->setTemplateCacheDir(); |
898 | 898 | |
899 | - if($this->canExportJavascript()) |
|
899 | + if ($this->canExportJavascript()) |
|
900 | 900 | { |
901 | 901 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
902 | 902 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -905,13 +905,13 @@ discard block |
||
905 | 905 | $sHash = $this->generateHash(); |
906 | 906 | $sOutFile = $sHash . '.js'; |
907 | 907 | $sMinFile = $sHash . '.min.js'; |
908 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
908 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
909 | 909 | { |
910 | 910 | file_put_contents($sJsAppDir . $sOutFile, $this->getAllScripts()); |
911 | 911 | } |
912 | - if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
912 | + if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
913 | 913 | { |
914 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
914 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
915 | 915 | { |
916 | 916 | $sOutFile = $sMinFile; |
917 | 917 | } |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | */ |
945 | 945 | public function getResponsePlugin($sName) |
946 | 946 | { |
947 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
947 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
948 | 948 | { |
949 | 949 | return $this->aResponsePlugins[$sName]; |
950 | 950 | } |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | */ |
961 | 961 | public function getRequestPlugin($sName) |
962 | 962 | { |
963 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
963 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
964 | 964 | { |
965 | 965 | return $this->aRequestPlugins[$sName]; |
966 | 966 | } |