@@ -262,32 +262,32 @@ discard block |
||
| 262 | 262 | { |
| 263 | 263 | $bIsAlert = ($xPlugin instanceof \Jaxon\Request\Interfaces\Alert); |
| 264 | 264 | $bIsConfirm = ($xPlugin instanceof \Jaxon\Request\Interfaces\Confirm); |
| 265 | - if($xPlugin instanceof Request) |
|
| 265 | + if ($xPlugin instanceof Request) |
|
| 266 | 266 | { |
| 267 | 267 | // The name of a request plugin is used as key in the plugin table |
| 268 | 268 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 269 | 269 | } |
| 270 | - elseif($xPlugin instanceof Response) |
|
| 270 | + elseif ($xPlugin instanceof Response) |
|
| 271 | 271 | { |
| 272 | 272 | // The name of a response plugin is used as key in the plugin table |
| 273 | 273 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 274 | 274 | } |
| 275 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 275 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
| 276 | 276 | { |
| 277 | 277 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 278 | 278 | } |
| 279 | 279 | // This plugin implements the Alert interface |
| 280 | - if($bIsAlert) |
|
| 280 | + if ($bIsAlert) |
|
| 281 | 281 | { |
| 282 | 282 | $this->setAlert($xPlugin); |
| 283 | 283 | } |
| 284 | 284 | // This plugin implements the Confirm interface |
| 285 | - if($bIsConfirm) |
|
| 285 | + if ($bIsConfirm) |
|
| 286 | 286 | { |
| 287 | 287 | $this->setConfirm($xPlugin); |
| 288 | 288 | } |
| 289 | 289 | // Register the plugin as an event listener |
| 290 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 290 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 291 | 291 | { |
| 292 | 292 | $this->addEventListener($xPlugin); |
| 293 | 293 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | private function generateHash() |
| 304 | 304 | { |
| 305 | 305 | $sHash = $this->getVersion(); |
| 306 | - foreach($this->aPlugins as $xPlugin) |
|
| 306 | + foreach ($this->aPlugins as $xPlugin) |
|
| 307 | 307 | { |
| 308 | 308 | $sHash .= $xPlugin->generateHash(); |
| 309 | 309 | } |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | public function canProcessRequest() |
| 322 | 322 | { |
| 323 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 323 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 324 | 324 | { |
| 325 | - if($xPlugin->canProcessRequest()) |
|
| 325 | + if ($xPlugin->canProcessRequest()) |
|
| 326 | 326 | { |
| 327 | 327 | return true; |
| 328 | 328 | } |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | public function processRequest() |
| 342 | 342 | { |
| 343 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 343 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 344 | 344 | { |
| 345 | - if($xPlugin->canProcessRequest()) |
|
| 345 | + if ($xPlugin->canProcessRequest()) |
|
| 346 | 346 | { |
| 347 | 347 | return $xPlugin->processRequest(); |
| 348 | 348 | } |
@@ -363,10 +363,10 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function register($aArgs) |
| 365 | 365 | { |
| 366 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 366 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 367 | 367 | { |
| 368 | 368 | $mResult = $xPlugin->register($aArgs); |
| 369 | - if($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
| 369 | + if ($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
| 370 | 370 | { |
| 371 | 371 | return $mResult; |
| 372 | 372 | } |
@@ -386,37 +386,37 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | public function addClassDir($sDirectory, $sNamespace = null, $sSeparator = '.', array $aProtected = array()) |
| 388 | 388 | { |
| 389 | - if(!is_dir(($sDirectory = trim($sDirectory)))) |
|
| 389 | + if (!is_dir(($sDirectory = trim($sDirectory)))) |
|
| 390 | 390 | { |
| 391 | 391 | return false; |
| 392 | 392 | } |
| 393 | 393 | // Only '.' and '_' are allowed to be used as separator. Any other value is ignored and '.' is used instead. |
| 394 | - if(($sSeparator = trim($sSeparator)) != '_') |
|
| 394 | + if (($sSeparator = trim($sSeparator)) != '_') |
|
| 395 | 395 | { |
| 396 | 396 | $sSeparator = '.'; |
| 397 | 397 | } |
| 398 | - if(!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 398 | + if (!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 399 | 399 | { |
| 400 | 400 | $sNamespace = null; |
| 401 | 401 | } |
| 402 | - if(($sNamespace)) |
|
| 402 | + if (($sNamespace)) |
|
| 403 | 403 | { |
| 404 | 404 | // If there is an autoloader, register the dir with PSR4 autoloading |
| 405 | - if(($this->xAutoloader)) |
|
| 405 | + if (($this->xAutoloader)) |
|
| 406 | 406 | { |
| 407 | 407 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | - elseif(($this->xAutoloader)) |
|
| 410 | + elseif (($this->xAutoloader)) |
|
| 411 | 411 | { |
| 412 | 412 | // If there is an autoloader, register the dir with classmap autoloading |
| 413 | 413 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 414 | 414 | $itFile = new RecursiveIteratorIterator($itDir); |
| 415 | 415 | // Iterate on dir content |
| 416 | - foreach($itFile as $xFile) |
|
| 416 | + foreach ($itFile as $xFile) |
|
| 417 | 417 | { |
| 418 | 418 | // skip everything except PHP files |
| 419 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 419 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 420 | 420 | { |
| 421 | 421 | continue; |
| 422 | 422 | } |
@@ -451,33 +451,33 @@ discard block |
||
| 451 | 451 | // Get the corresponding class path and name |
| 452 | 452 | $sClassPath = trim(substr($xFile->getPath(), strlen($sDirectory)), $sDS); |
| 453 | 453 | $sClassName = $xFile->getBasename('.php'); |
| 454 | - if(($sNamespace)) |
|
| 454 | + if (($sNamespace)) |
|
| 455 | 455 | { |
| 456 | 456 | $sClassPath = $sNamespace . '\\' . $sClassPath; |
| 457 | 457 | $sClassName = '\\' . $sClassPath . '\\' . $sClassName; |
| 458 | 458 | } |
| 459 | 459 | // Require the file only if autoload is enabled but there is no autoloader |
| 460 | - if(($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
| 460 | + if (($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
| 461 | 461 | { |
| 462 | 462 | require_once($xFile->getPathname()); |
| 463 | 463 | } |
| 464 | 464 | // Create and register an instance of the class |
| 465 | - if(!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
| 465 | + if (!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
| 466 | 466 | { |
| 467 | 467 | $aOptions['*'] = array(); |
| 468 | 468 | } |
| 469 | 469 | $aOptions['*']['separator'] = $sSeparator; |
| 470 | - if(($sNamespace)) |
|
| 470 | + if (($sNamespace)) |
|
| 471 | 471 | { |
| 472 | 472 | $aOptions['*']['namespace'] = $sNamespace; |
| 473 | 473 | } |
| 474 | - if(($sClassPath)) |
|
| 474 | + if (($sClassPath)) |
|
| 475 | 475 | { |
| 476 | 476 | $aOptions['*']['classpath'] = $sClassPath; |
| 477 | 477 | } |
| 478 | 478 | // Filter excluded methods |
| 479 | - $aProtected = array_filter($aProtected, function ($sName) {return is_string($sName);}); |
|
| 480 | - if(count($aProtected) > 0) |
|
| 479 | + $aProtected = array_filter($aProtected, function($sName) {return is_string($sName); }); |
|
| 480 | + if (count($aProtected) > 0) |
|
| 481 | 481 | { |
| 482 | 482 | $aOptions['*']['protected'] = $aProtected; |
| 483 | 483 | } |
@@ -496,13 +496,13 @@ discard block |
||
| 496 | 496 | $sDS = DIRECTORY_SEPARATOR; |
| 497 | 497 | // Change the keys in $aOptions to have "\" as separator |
| 498 | 498 | $aNewOptions = array(); |
| 499 | - foreach($aOptions as $key => $aOption) |
|
| 499 | + foreach ($aOptions as $key => $aOption) |
|
| 500 | 500 | { |
| 501 | 501 | $key = trim(str_replace(['.', '_'], ['\\', '\\'], $key), ' \\'); |
| 502 | 502 | $aNewOptions[$key] = $aOption; |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - foreach($this->aClassDirs as $aClassDir) |
|
| 505 | + foreach ($this->aClassDirs as $aClassDir) |
|
| 506 | 506 | { |
| 507 | 507 | // Get the directory |
| 508 | 508 | $sDirectory = $aClassDir['directory']; |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 514 | 514 | $itFile = new RecursiveIteratorIterator($itDir); |
| 515 | 515 | // Iterate on dir content |
| 516 | - foreach($itFile as $xFile) |
|
| 516 | + foreach ($itFile as $xFile) |
|
| 517 | 517 | { |
| 518 | 518 | // skip everything except PHP files |
| 519 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 519 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 520 | 520 | { |
| 521 | 521 | continue; |
| 522 | 522 | } |
@@ -525,13 +525,13 @@ discard block |
||
| 525 | 525 | $sClassPath = substr($xFile->getPath(), strlen($sDirectory)); |
| 526 | 526 | $sClassPath = trim(str_replace($sDS, '\\', $sClassPath), '\\'); |
| 527 | 527 | $sClassName = $sClassPath . '\\' . $xFile->getBasename('.php'); |
| 528 | - if(($sNamespace)) |
|
| 528 | + if (($sNamespace)) |
|
| 529 | 529 | { |
| 530 | 530 | $sClassName = $sNamespace . '\\' . $sClassName; |
| 531 | 531 | } |
| 532 | 532 | // Get the class options |
| 533 | 533 | $aClassOptions = []; |
| 534 | - if(array_key_exists($sClassName, $aNewOptions)) |
|
| 534 | + if (array_key_exists($sClassName, $aNewOptions)) |
|
| 535 | 535 | { |
| 536 | 536 | $aClassOptions = $aNewOptions[$sClassName]; |
| 537 | 537 | } |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | */ |
| 553 | 553 | public function registerClass($sClassName, array $aOptions = array()) |
| 554 | 554 | { |
| 555 | - if(!($sClassName = trim($sClassName, ' \\._'))) |
|
| 555 | + if (!($sClassName = trim($sClassName, ' \\._'))) |
|
| 556 | 556 | { |
| 557 | 557 | return false; |
| 558 | 558 | } |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | // Replace "." and "_" with antislashes, and set the class path. |
| 562 | 562 | $sClassName = str_replace(['.', '_'], ['\\', '\\'], $sClassName); |
| 563 | 563 | $sClassPath = ''; |
| 564 | - if(($nLastSlashPosition = strrpos($sClassName, '\\')) !== false) |
|
| 564 | + if (($nLastSlashPosition = strrpos($sClassName, '\\')) !== false) |
|
| 565 | 565 | { |
| 566 | 566 | $sClassPath = substr($sClassName, 0, $nLastSlashPosition); |
| 567 | 567 | $sClassName = substr($sClassName, $nLastSlashPosition + 1); |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | $sPartPath = str_replace('\\', $sDS, $sClassPath) . $sDS . $sClassName . '.php'; |
| 571 | 571 | |
| 572 | 572 | // Search for the class file in all directories. |
| 573 | - foreach($this->aClassDirs as $aClassDir) |
|
| 573 | + foreach ($this->aClassDirs as $aClassDir) |
|
| 574 | 574 | { |
| 575 | 575 | // Get the separator |
| 576 | 576 | $sSeparator = $aClassDir['separator']; |
@@ -579,15 +579,15 @@ discard block |
||
| 579 | 579 | $nLen = strlen($sNamespace); |
| 580 | 580 | $sFullPath = ''; |
| 581 | 581 | // Check if the class belongs to the namespace |
| 582 | - if(($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
|
| 582 | + if (($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
|
| 583 | 583 | { |
| 584 | 584 | $sFullPath = $aClassDir['directory'] . $sDS . substr($sPartPath, $nLen + 1); |
| 585 | 585 | } |
| 586 | - elseif(!($sNamespace)) |
|
| 586 | + elseif (!($sNamespace)) |
|
| 587 | 587 | { |
| 588 | 588 | $sFullPath = $aClassDir['directory'] . $sDS . $sPartPath; |
| 589 | 589 | } |
| 590 | - if(($sFullPath) && is_file($sFullPath)) |
|
| 590 | + if (($sFullPath) && is_file($sFullPath)) |
|
| 591 | 591 | { |
| 592 | 592 | // Found the file in this directory |
| 593 | 593 | $xFileInfo = new \SplFileInfo($sFullPath); |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | { |
| 612 | 612 | $xObject = null; // The user registered object |
| 613 | 613 | $xPlugin = $this->getRequestPlugin('CallableObject'); // The CallableObject plugin |
| 614 | - if(($xPlugin)) |
|
| 614 | + if (($xPlugin)) |
|
| 615 | 615 | { |
| 616 | 616 | $xObject = $xPlugin->getRegisteredObject($sClassName); |
| 617 | 617 | } |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | */ |
| 626 | 626 | private function getJsLibUri() |
| 627 | 627 | { |
| 628 | - if(!$this->hasOption('js.lib.uri')) |
|
| 628 | + if (!$this->hasOption('js.lib.uri')) |
|
| 629 | 629 | { |
| 630 | 630 | return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
| 631 | 631 | } |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | $jsDelivrUri = 'https://cdn.jsdelivr.net'; |
| 646 | 646 | $nLen = strlen($jsDelivrUri); |
| 647 | 647 | // The jsDelivr CDN only hosts minified files |
| 648 | - if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
|
| 648 | + if (($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
|
| 649 | 649 | { |
| 650 | 650 | return '.min.js'; |
| 651 | 651 | } |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | // Check config options |
| 663 | 663 | // - The js.app.extern option must be set to true |
| 664 | 664 | // - The js.app.uri and js.app.dir options must be set to non null values |
| 665 | - if(!$this->getOption('js.app.extern') || |
|
| 665 | + if (!$this->getOption('js.app.extern') || |
|
| 666 | 666 | !$this->getOption('js.app.uri') || |
| 667 | 667 | !$this->getOption('js.app.dir')) |
| 668 | 668 | { |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | // Check dir access |
| 672 | 672 | // - The js.app.dir must be writable |
| 673 | 673 | $sJsAppDir = $this->getOption('js.app.dir'); |
| 674 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 674 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 675 | 675 | { |
| 676 | 676 | return false; |
| 677 | 677 | } |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | */ |
| 686 | 686 | private function setTemplateCacheDir() |
| 687 | 687 | { |
| 688 | - if($this->hasOption('core.template.cache_dir')) |
|
| 688 | + if ($this->hasOption('core.template.cache_dir')) |
|
| 689 | 689 | { |
| 690 | 690 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
| 691 | 691 | } |
@@ -707,11 +707,11 @@ discard block |
||
| 707 | 707 | |
| 708 | 708 | // Add component files to the javascript file array; |
| 709 | 709 | $aJsFiles = array($sJsCoreUrl); |
| 710 | - if($this->getOption('core.debug.on')) |
|
| 710 | + if ($this->getOption('core.debug.on')) |
|
| 711 | 711 | { |
| 712 | 712 | $aJsFiles[] = $sJsDebugUrl; |
| 713 | 713 | $aJsFiles[] = $sJsLanguageUrl; |
| 714 | - if($this->getOption('core.debug.verbose')) |
|
| 714 | + if ($this->getOption('core.debug.verbose')) |
|
| 715 | 715 | { |
| 716 | 716 | $aJsFiles[] = $sJsVerboseUrl; |
| 717 | 717 | } |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 724 | 724 | 'aUrls' => $aJsFiles, |
| 725 | 725 | )); |
| 726 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 726 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 727 | 727 | { |
| 728 | 728 | $sCode .= rtrim($xPlugin->getJs(), " \n") . "\n"; |
| 729 | 729 | } |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | $this->setTemplateCacheDir(); |
| 742 | 742 | |
| 743 | 743 | $sCode = ''; |
| 744 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 744 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 745 | 745 | { |
| 746 | 746 | $sCode .= rtrim($xPlugin->getCss(), " \n") . "\n"; |
| 747 | 747 | } |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | )); |
| 830 | 830 | |
| 831 | 831 | $sPluginScript = ''; |
| 832 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 832 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 833 | 833 | { |
| 834 | 834 | $sPluginScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
| 835 | 835 | } |
@@ -861,11 +861,11 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | // Get the config and plugins scripts |
| 863 | 863 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
| 864 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 864 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 865 | 865 | { |
| 866 | 866 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
| 867 | 867 | } |
| 868 | - if($this->canExportJavascript()) |
|
| 868 | + if ($this->canExportJavascript()) |
|
| 869 | 869 | { |
| 870 | 870 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
| 871 | 871 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -874,13 +874,13 @@ discard block |
||
| 874 | 874 | $sHash = $this->generateHash(); |
| 875 | 875 | $sOutFile = $sHash . '.js'; |
| 876 | 876 | $sMinFile = $sHash . '.min.js'; |
| 877 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
| 877 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
| 878 | 878 | { |
| 879 | 879 | file_put_contents($sJsAppDir . $sOutFile, $sScript); |
| 880 | 880 | } |
| 881 | - if(($this->getOption('js.app.minify'))) |
|
| 881 | + if (($this->getOption('js.app.minify'))) |
|
| 882 | 882 | { |
| 883 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 883 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 884 | 884 | { |
| 885 | 885 | $sOutFile = $sMinFile; |
| 886 | 886 | } |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | */ |
| 914 | 914 | public function getResponsePlugin($sName) |
| 915 | 915 | { |
| 916 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
| 916 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
| 917 | 917 | { |
| 918 | 918 | return $this->aResponsePlugins[$sName]; |
| 919 | 919 | } |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | */ |
| 930 | 930 | public function getRequestPlugin($sName) |
| 931 | 931 | { |
| 932 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
| 932 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
| 933 | 933 | { |
| 934 | 934 | return $this->aRequestPlugins[$sName]; |
| 935 | 935 | } |
@@ -266,13 +266,11 @@ discard block |
||
| 266 | 266 | { |
| 267 | 267 | // The name of a request plugin is used as key in the plugin table |
| 268 | 268 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 269 | - } |
|
| 270 | - elseif($xPlugin instanceof Response) |
|
| 269 | + } elseif($xPlugin instanceof Response) |
|
| 271 | 270 | { |
| 272 | 271 | // The name of a response plugin is used as key in the plugin table |
| 273 | 272 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 274 | - } |
|
| 275 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 273 | + } elseif(!$bIsConfirm && !$bIsAlert) |
|
| 276 | 274 | { |
| 277 | 275 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 278 | 276 | } |
@@ -406,8 +404,7 @@ discard block |
||
| 406 | 404 | { |
| 407 | 405 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
| 408 | 406 | } |
| 409 | - } |
|
| 410 | - elseif(($this->xAutoloader)) |
|
| 407 | + } elseif(($this->xAutoloader)) |
|
| 411 | 408 | { |
| 412 | 409 | // If there is an autoloader, register the dir with classmap autoloading |
| 413 | 410 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
@@ -582,8 +579,7 @@ discard block |
||
| 582 | 579 | if(($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
| 583 | 580 | { |
| 584 | 581 | $sFullPath = $aClassDir['directory'] . $sDS . substr($sPartPath, $nLen + 1); |
| 585 | - } |
|
| 586 | - elseif(!($sNamespace)) |
|
| 582 | + } elseif(!($sNamespace)) |
|
| 587 | 583 | { |
| 588 | 584 | $sFullPath = $aClassDir['directory'] . $sDS . $sPartPath; |
| 589 | 585 | } |
@@ -891,8 +887,7 @@ discard block |
||
| 891 | 887 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 892 | 888 | 'sUrl' => $sJsAppURI . $sOutFile, |
| 893 | 889 | )); |
| 894 | - } |
|
| 895 | - else |
|
| 890 | + } else |
|
| 896 | 891 | { |
| 897 | 892 | // The plugins scripts are wrapped with javascript tags |
| 898 | 893 | $sScript = $this->render('jaxon::plugins/wrapper.js', array( |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function __construct($xCallable) |
| 94 | 94 | { |
| 95 | - if(is_string($xCallable)) // Received a class name |
|
| 95 | + if (is_string($xCallable)) // Received a class name |
|
| 96 | 96 | { |
| 97 | 97 | $this->reflectionClass = new \ReflectionClass($xCallable); |
| 98 | 98 | $this->callableObject = null; |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | private function setCallable($xCallable = null) |
| 120 | 120 | { |
| 121 | - if($xCallable == null) |
|
| 121 | + if ($xCallable == null) |
|
| 122 | 122 | { |
| 123 | 123 | $xCallable = $this->reflectionClass->newInstance(); |
| 124 | 124 | } |
| 125 | 125 | // Save the Jaxon callable object into the user callable object |
| 126 | - if($this->reflectionClass->hasMethod('setJaxonCallable')) |
|
| 126 | + if ($this->reflectionClass->hasMethod('setJaxonCallable')) |
|
| 127 | 127 | { |
| 128 | 128 | $xCallable->setJaxonCallable($this); |
| 129 | 129 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function getRegisteredObject() |
| 139 | 139 | { |
| 140 | - if($this->callableObject == null) |
|
| 140 | + if ($this->callableObject == null) |
|
| 141 | 141 | { |
| 142 | 142 | $this->setCallable(); |
| 143 | 143 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | // The class name without the namespace. |
| 166 | 166 | $name = $this->reflectionClass->getShortName(); |
| 167 | 167 | // Append the classpath to the name |
| 168 | - if(($this->classpath)) |
|
| 168 | + if (($this->classpath)) |
|
| 169 | 169 | { |
| 170 | 170 | $name = $this->classpath . '\\' . $name; |
| 171 | 171 | } |
@@ -212,16 +212,16 @@ discard block |
||
| 212 | 212 | public function getMethods() |
| 213 | 213 | { |
| 214 | 214 | $aReturn = array(); |
| 215 | - foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 215 | + foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 216 | 216 | { |
| 217 | 217 | $sMethodName = $xMethod->getShortName(); |
| 218 | 218 | // Don't take magic __call, __construct, __destruct methods |
| 219 | - if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
| 219 | + if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
| 220 | 220 | { |
| 221 | 221 | continue; |
| 222 | 222 | } |
| 223 | 223 | // Don't take excluded methods |
| 224 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
| 224 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
| 225 | 225 | { |
| 226 | 226 | continue; |
| 227 | 227 | } |
@@ -242,37 +242,37 @@ discard block |
||
| 242 | 242 | public function configure($sMethod, $sName, $sValue) |
| 243 | 243 | { |
| 244 | 244 | // Set the namespace |
| 245 | - if($sName == 'namespace') |
|
| 245 | + if ($sName == 'namespace') |
|
| 246 | 246 | { |
| 247 | - if($sValue != '') |
|
| 247 | + if ($sValue != '') |
|
| 248 | 248 | $this->namespace = $sValue; |
| 249 | 249 | return; |
| 250 | 250 | } |
| 251 | 251 | // Set the classpath |
| 252 | - if($sName == 'classpath') |
|
| 252 | + if ($sName == 'classpath') |
|
| 253 | 253 | { |
| 254 | - if($sValue != '') |
|
| 254 | + if ($sValue != '') |
|
| 255 | 255 | $this->classpath = trim($sValue, '\\'); |
| 256 | 256 | return; |
| 257 | 257 | } |
| 258 | 258 | // Set the separator |
| 259 | - if($sName == 'separator') |
|
| 259 | + if ($sName == 'separator') |
|
| 260 | 260 | { |
| 261 | - if($sValue == '_' || $sValue == '.') |
|
| 261 | + if ($sValue == '_' || $sValue == '.') |
|
| 262 | 262 | $this->separator = $sValue; |
| 263 | 263 | return; |
| 264 | 264 | } |
| 265 | 265 | // Set the excluded methods |
| 266 | - if($sName == 'protected') |
|
| 266 | + if ($sName == 'protected') |
|
| 267 | 267 | { |
| 268 | - if(is_array($sValue)) |
|
| 268 | + if (is_array($sValue)) |
|
| 269 | 269 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
| 270 | - elseif(is_string($sValue)) |
|
| 270 | + elseif (is_string($sValue)) |
|
| 271 | 271 | $this->aProtectedMethods[] = $sValue; |
| 272 | 272 | return; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - if(!isset($this->aConfiguration[$sMethod])) |
|
| 275 | + if (!isset($this->aConfiguration[$sMethod])) |
|
| 276 | 276 | { |
| 277 | 277 | $this->aConfiguration[$sMethod] = array(); |
| 278 | 278 | } |
@@ -293,16 +293,16 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | // Common options to be set on all methods |
| 295 | 295 | $aCommonConfig = array_key_exists('*', $this->aConfiguration) ? $this->aConfiguration['*'] : array(); |
| 296 | - foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 296 | + foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 297 | 297 | { |
| 298 | 298 | $sMethodName = $xMethod->getShortName(); |
| 299 | 299 | // Don't export magic __call, __construct, __destruct methods |
| 300 | - if(strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__') |
|
| 300 | + if (strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__') |
|
| 301 | 301 | { |
| 302 | 302 | continue; |
| 303 | 303 | } |
| 304 | 304 | // Don't export "protected" methods |
| 305 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
| 305 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
| 306 | 306 | { |
| 307 | 307 | continue; |
| 308 | 308 | } |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | public function call($sMethod, $aArgs) |
| 354 | 354 | { |
| 355 | - if(!$this->hasMethod($sMethod)) |
|
| 355 | + if (!$this->hasMethod($sMethod)) |
|
| 356 | 356 | return; |
| 357 | 357 | $reflectionMethod = $this->reflectionClass->getMethod($sMethod); |
| 358 | 358 | $callableObject = $this->getRegisteredObject(); |
@@ -92,12 +92,13 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function __construct($xCallable) |
| 94 | 94 | { |
| 95 | - if(is_string($xCallable)) // Received a class name |
|
| 95 | + if(is_string($xCallable)) { |
|
| 96 | + // Received a class name |
|
| 96 | 97 | { |
| 97 | 98 | $this->reflectionClass = new \ReflectionClass($xCallable); |
| 98 | - $this->callableObject = null; |
|
| 99 | 99 | } |
| 100 | - else // if(is_object($xCallable)) // Received a class instance |
|
| 100 | + $this->callableObject = null; |
|
| 101 | + } else // if(is_object($xCallable)) // Received a class instance |
|
| 101 | 102 | { |
| 102 | 103 | $this->reflectionClass = new \ReflectionClass(get_class($xCallable)); |
| 103 | 104 | $this->setCallable($xCallable); |
@@ -244,31 +245,35 @@ discard block |
||
| 244 | 245 | // Set the namespace |
| 245 | 246 | if($sName == 'namespace') |
| 246 | 247 | { |
| 247 | - if($sValue != '') |
|
| 248 | - $this->namespace = $sValue; |
|
| 248 | + if($sValue != '') { |
|
| 249 | + $this->namespace = $sValue; |
|
| 250 | + } |
|
| 249 | 251 | return; |
| 250 | 252 | } |
| 251 | 253 | // Set the classpath |
| 252 | 254 | if($sName == 'classpath') |
| 253 | 255 | { |
| 254 | - if($sValue != '') |
|
| 255 | - $this->classpath = trim($sValue, '\\'); |
|
| 256 | + if($sValue != '') { |
|
| 257 | + $this->classpath = trim($sValue, '\\'); |
|
| 258 | + } |
|
| 256 | 259 | return; |
| 257 | 260 | } |
| 258 | 261 | // Set the separator |
| 259 | 262 | if($sName == 'separator') |
| 260 | 263 | { |
| 261 | - if($sValue == '_' || $sValue == '.') |
|
| 262 | - $this->separator = $sValue; |
|
| 264 | + if($sValue == '_' || $sValue == '.') { |
|
| 265 | + $this->separator = $sValue; |
|
| 266 | + } |
|
| 263 | 267 | return; |
| 264 | 268 | } |
| 265 | 269 | // Set the excluded methods |
| 266 | 270 | if($sName == 'protected') |
| 267 | 271 | { |
| 268 | - if(is_array($sValue)) |
|
| 269 | - $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
|
| 270 | - elseif(is_string($sValue)) |
|
| 271 | - $this->aProtectedMethods[] = $sValue; |
|
| 272 | + if(is_array($sValue)) { |
|
| 273 | + $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
|
| 274 | + } elseif(is_string($sValue)) { |
|
| 275 | + $this->aProtectedMethods[] = $sValue; |
|
| 276 | + } |
|
| 272 | 277 | return; |
| 273 | 278 | } |
| 274 | 279 | |
@@ -352,8 +357,9 @@ discard block |
||
| 352 | 357 | */ |
| 353 | 358 | public function call($sMethod, $aArgs) |
| 354 | 359 | { |
| 355 | - if(!$this->hasMethod($sMethod)) |
|
| 356 | - return; |
|
| 360 | + if(!$this->hasMethod($sMethod)) { |
|
| 361 | + return; |
|
| 362 | + } |
|
| 357 | 363 | $reflectionMethod = $this->reflectionClass->getMethod($sMethod); |
| 358 | 364 | $callableObject = $this->getRegisteredObject(); |
| 359 | 365 | $this->getResponseManager()->append($reflectionMethod->invokeArgs($callableObject, $aArgs)); |
@@ -67,19 +67,19 @@ discard block |
||
| 67 | 67 | $this->sRequestedClass = null; |
| 68 | 68 | $this->sRequestedMethod = null; |
| 69 | 69 | |
| 70 | - if(!empty($_GET['jxncls'])) |
|
| 70 | + if (!empty($_GET['jxncls'])) |
|
| 71 | 71 | { |
| 72 | 72 | $this->sRequestedClass = $_GET['jxncls']; |
| 73 | 73 | } |
| 74 | - if(!empty($_GET['jxnmthd'])) |
|
| 74 | + if (!empty($_GET['jxnmthd'])) |
|
| 75 | 75 | { |
| 76 | 76 | $this->sRequestedMethod = $_GET['jxnmthd']; |
| 77 | 77 | } |
| 78 | - if(!empty($_POST['jxncls'])) |
|
| 78 | + if (!empty($_POST['jxncls'])) |
|
| 79 | 79 | { |
| 80 | 80 | $this->sRequestedClass = $_POST['jxncls']; |
| 81 | 81 | } |
| 82 | - if(!empty($_POST['jxnmthd'])) |
|
| 82 | + if (!empty($_POST['jxnmthd'])) |
|
| 83 | 83 | { |
| 84 | 84 | $this->sRequestedMethod = $_POST['jxnmthd']; |
| 85 | 85 | } |
@@ -104,44 +104,44 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function register($aArgs) |
| 106 | 106 | { |
| 107 | - if(count($aArgs) > 1) |
|
| 107 | + if (count($aArgs) > 1) |
|
| 108 | 108 | { |
| 109 | 109 | $sType = $aArgs[0]; |
| 110 | 110 | |
| 111 | - if($sType == Jaxon::CALLABLE_OBJECT) |
|
| 111 | + if ($sType == Jaxon::CALLABLE_OBJECT) |
|
| 112 | 112 | { |
| 113 | 113 | $xCallableObject = $aArgs[1]; |
| 114 | 114 | |
| 115 | - if(!is_object($xCallableObject) && !is_string($xCallableObject)) |
|
| 115 | + if (!is_object($xCallableObject) && !is_string($xCallableObject)) |
|
| 116 | 116 | { |
| 117 | 117 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.instance')); |
| 118 | 118 | } |
| 119 | - if(is_string($xCallableObject) && !class_exists($xCallableObject)) |
|
| 119 | + if (is_string($xCallableObject) && !class_exists($xCallableObject)) |
|
| 120 | 120 | { |
| 121 | 121 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.instance')); |
| 122 | 122 | } |
| 123 | - if(!($xCallableObject instanceof \Jaxon\Request\Support\CallableObject)) |
|
| 123 | + if (!($xCallableObject instanceof \Jaxon\Request\Support\CallableObject)) |
|
| 124 | 124 | { |
| 125 | 125 | $xCallableObject = new \Jaxon\Request\Support\CallableObject($xCallableObject); |
| 126 | 126 | } |
| 127 | - if(count($aArgs) > 2 && is_array($aArgs[2])) |
|
| 127 | + if (count($aArgs) > 2 && is_array($aArgs[2])) |
|
| 128 | 128 | { |
| 129 | 129 | $aOptions = $aArgs[2]; |
| 130 | 130 | // Save the classpath and the separator in this class |
| 131 | - if(array_key_exists('*', $aOptions) && is_array($aOptions['*'])) |
|
| 131 | + if (array_key_exists('*', $aOptions) && is_array($aOptions['*'])) |
|
| 132 | 132 | { |
| 133 | 133 | $aOptions = $aOptions['*']; |
| 134 | 134 | $sSeparator = '.'; |
| 135 | - if(array_key_exists('separator', $aOptions)) |
|
| 135 | + if (array_key_exists('separator', $aOptions)) |
|
| 136 | 136 | { |
| 137 | 137 | $sSeparator = trim($aOptions['separator']); |
| 138 | 138 | } |
| 139 | - if(!in_array($sSeparator, ['.', '_'])) |
|
| 139 | + if (!in_array($sSeparator, ['.', '_'])) |
|
| 140 | 140 | { |
| 141 | 141 | $sSeparator = '.'; |
| 142 | 142 | } |
| 143 | 143 | $aOptions['separator'] = $sSeparator; |
| 144 | - if(array_key_exists('classpath', $aOptions)) |
|
| 144 | + if (array_key_exists('classpath', $aOptions)) |
|
| 145 | 145 | { |
| 146 | 146 | $aOptions['classpath'] = trim($aOptions['classpath'], ' \\._'); |
| 147 | 147 | // Save classpath with "\" in the parameters |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | $this->aClassPaths[] = str_replace('\\', $sSeparator, $aOptions['classpath']); |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | - foreach($aArgs[2] as $sKey => $aValue) |
|
| 153 | + foreach ($aArgs[2] as $sKey => $aValue) |
|
| 154 | 154 | { |
| 155 | - foreach($aValue as $sName => $sValue) |
|
| 155 | + foreach ($aValue as $sName => $sValue) |
|
| 156 | 156 | { |
| 157 | 157 | $xCallableObject->configure($sKey, $sName, $sValue); |
| 158 | 158 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | public function generateHash() |
| 177 | 177 | { |
| 178 | 178 | $sHash = ''; |
| 179 | - foreach($this->aCallableObjects as $xCallableObject) |
|
| 179 | + foreach ($this->aCallableObjects as $xCallableObject) |
|
| 180 | 180 | { |
| 181 | 181 | $sHash .= $xCallableObject->getName(); |
| 182 | 182 | $sHash .= implode('|', $xCallableObject->getMethods()); |
@@ -195,15 +195,15 @@ discard block |
||
| 195 | 195 | // Generate code for javascript objects declaration |
| 196 | 196 | $code = ''; |
| 197 | 197 | $classes = array(); |
| 198 | - foreach($this->aClassPaths as $sClassPath) |
|
| 198 | + foreach ($this->aClassPaths as $sClassPath) |
|
| 199 | 199 | { |
| 200 | 200 | $offset = 0; |
| 201 | 201 | $sClassPath .= '.Null'; // This is a sentinel. The last token is not processed in the while loop. |
| 202 | - while(($dotPosition = strpos($sClassPath, '.', $offset)) !== false) |
|
| 202 | + while (($dotPosition = strpos($sClassPath, '.', $offset)) !== false) |
|
| 203 | 203 | { |
| 204 | 204 | $class = substr($sClassPath, 0, $dotPosition); |
| 205 | 205 | // Generate code for this object |
| 206 | - if(!array_key_exists($class, $classes)) |
|
| 206 | + if (!array_key_exists($class, $classes)) |
|
| 207 | 207 | { |
| 208 | 208 | $code .= "$sJaxonPrefix$class = {};\n"; |
| 209 | 209 | $classes[$class] = $class; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | // Generate code for javascript methods |
| 215 | - foreach($this->aCallableObjects as $xCallableObject) |
|
| 215 | + foreach ($this->aCallableObjects as $xCallableObject) |
|
| 216 | 216 | { |
| 217 | 217 | $code .= $xCallableObject->getScript(); |
| 218 | 218 | } |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | public function canProcessRequest() |
| 228 | 228 | { |
| 229 | 229 | // Check the validity of the class name |
| 230 | - if(($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass)) |
|
| 230 | + if (($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass)) |
|
| 231 | 231 | { |
| 232 | 232 | $this->sRequestedClass = null; |
| 233 | 233 | $this->sRequestedMethod = null; |
| 234 | 234 | } |
| 235 | 235 | // Check the validity of the method name |
| 236 | - if(($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod)) |
|
| 236 | + if (($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod)) |
|
| 237 | 237 | { |
| 238 | 238 | $this->sRequestedClass = null; |
| 239 | 239 | $this->sRequestedMethod = null; |
@@ -248,20 +248,20 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | public function processRequest() |
| 250 | 250 | { |
| 251 | - if(!$this->canProcessRequest()) |
|
| 251 | + if (!$this->canProcessRequest()) |
|
| 252 | 252 | return false; |
| 253 | 253 | |
| 254 | 254 | $aArgs = $this->getRequestManager()->process(); |
| 255 | 255 | |
| 256 | 256 | // Register an instance of the requested class, if it isn't yet |
| 257 | - if(!($xCallableObject = $this->getCallableObject($this->sRequestedClass))) |
|
| 257 | + if (!($xCallableObject = $this->getCallableObject($this->sRequestedClass))) |
|
| 258 | 258 | { |
| 259 | 259 | $this->getPluginManager()->registerClass($this->sRequestedClass); |
| 260 | 260 | $xCallableObject = $this->getCallableObject($this->sRequestedClass); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // Find the requested method |
| 264 | - if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 264 | + if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 265 | 265 | { |
| 266 | 266 | // Unable to find the requested object or method |
| 267 | 267 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid', |
@@ -248,8 +248,9 @@ |
||
| 248 | 248 | */ |
| 249 | 249 | public function processRequest() |
| 250 | 250 | { |
| 251 | - if(!$this->canProcessRequest()) |
|
| 252 | - return false; |
|
| 251 | + if(!$this->canProcessRequest()) { |
|
| 252 | + return false; |
|
| 253 | + } |
|
| 253 | 254 | |
| 254 | 255 | $aArgs = $this->getRequestManager()->process(); |
| 255 | 256 | |