@@ -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,38 +386,38 @@ 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 | $sNamespace = trim($sNamespace, '\\'); |
405 | 405 | // If there is an autoloader, register the dir with PSR4 autoloading |
406 | - if(($this->xAutoloader)) |
|
406 | + if (($this->xAutoloader)) |
|
407 | 407 | { |
408 | 408 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
409 | 409 | } |
410 | 410 | } |
411 | - elseif(($this->xAutoloader)) |
|
411 | + elseif (($this->xAutoloader)) |
|
412 | 412 | { |
413 | 413 | // If there is an autoloader, register the dir with classmap autoloading |
414 | 414 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
415 | 415 | $itFile = new RecursiveIteratorIterator($itDir); |
416 | 416 | // Iterate on dir content |
417 | - foreach($itFile as $xFile) |
|
417 | + foreach ($itFile as $xFile) |
|
418 | 418 | { |
419 | 419 | // skip everything except PHP files |
420 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
420 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
421 | 421 | { |
422 | 422 | continue; |
423 | 423 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | $sClassPath = trim(substr($xFile->getPath(), strlen($sDirectory)), DIRECTORY_SEPARATOR); |
449 | 449 | $sClassPath = str_replace(array(DIRECTORY_SEPARATOR), array($sSeparator), $sClassPath); |
450 | 450 | $sClassName = $xFile->getBasename('.php'); |
451 | - if(($sNamespace)) |
|
451 | + if (($sNamespace)) |
|
452 | 452 | { |
453 | 453 | $sNamespace = trim($sNamespace, '\\'); |
454 | 454 | $sClassPath = str_replace(array('\\'), array($sSeparator), $sNamespace) . $sSeparator . $sClassPath; |
@@ -456,27 +456,27 @@ discard block |
||
456 | 456 | $sClassName = '\\' . str_replace(array($sSeparator), array('\\'), $sClassPath) . '\\' . $sClassName; |
457 | 457 | } |
458 | 458 | // Require the file only if autoload is enabled but there is no autoloader |
459 | - if(($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
459 | + if (($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
460 | 460 | { |
461 | 461 | require_once($xFile->getPathname()); |
462 | 462 | } |
463 | 463 | // Create and register an instance of the class |
464 | - if(!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
464 | + if (!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
465 | 465 | { |
466 | 466 | $aOptions['*'] = array(); |
467 | 467 | } |
468 | 468 | $aOptions['*']['separator'] = $sSeparator; |
469 | - if(($sNamespace)) |
|
469 | + if (($sNamespace)) |
|
470 | 470 | { |
471 | 471 | $aOptions['*']['namespace'] = $sNamespace; |
472 | 472 | } |
473 | - if(($sClassPath)) |
|
473 | + if (($sClassPath)) |
|
474 | 474 | { |
475 | 475 | $aOptions['*']['classpath'] = $sClassPath; |
476 | 476 | } |
477 | 477 | // Filter excluded methods |
478 | - $aProtected = array_filter($aProtected, function ($sName) {return is_string($sName);}); |
|
479 | - if(count($aProtected) > 0) |
|
478 | + $aProtected = array_filter($aProtected, function($sName) {return is_string($sName); }); |
|
479 | + if (count($aProtected) > 0) |
|
480 | 480 | { |
481 | 481 | $aOptions['*']['protected'] = $aProtected; |
482 | 482 | } |
@@ -490,15 +490,15 @@ discard block |
||
490 | 490 | */ |
491 | 491 | public function registerClasses() |
492 | 492 | { |
493 | - foreach($this->aClassDirs as $sClassDir) |
|
493 | + foreach ($this->aClassDirs as $sClassDir) |
|
494 | 494 | { |
495 | 495 | $itDir = new RecursiveDirectoryIterator($sClassDir['directory']); |
496 | 496 | $itFile = new RecursiveIteratorIterator($itDir); |
497 | 497 | // Iterate on dir content |
498 | - foreach($itFile as $xFile) |
|
498 | + foreach ($itFile as $xFile) |
|
499 | 499 | { |
500 | 500 | // skip everything except PHP files |
501 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
501 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
502 | 502 | { |
503 | 503 | continue; |
504 | 504 | } |
@@ -518,18 +518,18 @@ discard block |
||
518 | 518 | */ |
519 | 519 | public function registerClass($sClassName, array $aOptions = array()) |
520 | 520 | { |
521 | - if(!($sInitialClassName = trim($sClassName))) |
|
521 | + if (!($sInitialClassName = trim($sClassName))) |
|
522 | 522 | { |
523 | 523 | return false; |
524 | 524 | } |
525 | - foreach($this->aClassDirs as $aClassDir) |
|
525 | + foreach ($this->aClassDirs as $aClassDir) |
|
526 | 526 | { |
527 | 527 | // Get the separator |
528 | 528 | $sSeparator = $aClassDir['separator']; |
529 | 529 | // Replace / and \ with dots, and trim the string |
530 | 530 | $sClassName = trim(str_replace(array('\\', '/'), array($sSeparator, $sSeparator), $sInitialClassName), $sSeparator); |
531 | 531 | $sClassPath = ''; |
532 | - if(($nLastDotPosition = strrpos($sClassName, $sSeparator)) !== false) |
|
532 | + if (($nLastDotPosition = strrpos($sClassName, $sSeparator)) !== false) |
|
533 | 533 | { |
534 | 534 | $sClassPath = substr($sClassName, 0, $nLastDotPosition); |
535 | 535 | $sClassName = substr($sClassName, $nLastDotPosition + 1); |
@@ -541,17 +541,17 @@ discard block |
||
541 | 541 | $nLen = strlen($sNamespace); |
542 | 542 | $bRegister = false; |
543 | 543 | // Check if the class belongs to the namespace |
544 | - if(($sNamespace) && substr($sClassPath, 0, $nLen) == str_replace(array('\\'), array($sSeparator), $sNamespace)) |
|
544 | + if (($sNamespace) && substr($sClassPath, 0, $nLen) == str_replace(array('\\'), array($sSeparator), $sNamespace)) |
|
545 | 545 | { |
546 | 546 | $sClassFile = $aClassDir['directory'] . DIRECTORY_SEPARATOR . substr($sClassFile, $nLen); |
547 | 547 | $bRegister = true; |
548 | 548 | } |
549 | - elseif(!($sNamespace)) |
|
549 | + elseif (!($sNamespace)) |
|
550 | 550 | { |
551 | 551 | $sClassFile = $aClassDir['directory'] . DIRECTORY_SEPARATOR . $sClassFile; |
552 | 552 | $bRegister = true; |
553 | 553 | } |
554 | - if($bRegister && is_file($sClassFile)) |
|
554 | + if ($bRegister && is_file($sClassFile)) |
|
555 | 555 | { |
556 | 556 | // Found the file in this directory |
557 | 557 | $xFileInfo = new \SplFileInfo($sClassFile); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | { |
576 | 576 | $xObject = null; // The user registered object |
577 | 577 | $xPlugin = $this->getRequestPlugin('CallableObject'); // The CallableObject plugin |
578 | - if(($xPlugin)) |
|
578 | + if (($xPlugin)) |
|
579 | 579 | { |
580 | 580 | $xObject = $xPlugin->getRegisteredObject($sClassName); |
581 | 581 | } |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | */ |
590 | 590 | private function getJsLibUri() |
591 | 591 | { |
592 | - if(!$this->hasOption('js.lib.uri')) |
|
592 | + if (!$this->hasOption('js.lib.uri')) |
|
593 | 593 | { |
594 | 594 | return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
595 | 595 | } |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | $jsDelivrUri = 'https://cdn.jsdelivr.net'; |
610 | 610 | $nLen = strlen($jsDelivrUri); |
611 | 611 | // The jsDelivr CDN only hosts minified files |
612 | - if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
|
612 | + if (($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
|
613 | 613 | { |
614 | 614 | return '.min.js'; |
615 | 615 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | // Check config options |
627 | 627 | // - The js.app.extern option must be set to true |
628 | 628 | // - The js.app.uri and js.app.dir options must be set to non null values |
629 | - if(!$this->getOption('js.app.extern') || |
|
629 | + if (!$this->getOption('js.app.extern') || |
|
630 | 630 | !$this->getOption('js.app.uri') || |
631 | 631 | !$this->getOption('js.app.dir')) |
632 | 632 | { |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | // Check dir access |
636 | 636 | // - The js.app.dir must be writable |
637 | 637 | $sJsAppDir = $this->getOption('js.app.dir'); |
638 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
638 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
639 | 639 | { |
640 | 640 | return false; |
641 | 641 | } |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | private function setTemplateCacheDir() |
651 | 651 | { |
652 | - if($this->hasOption('core.template.cache_dir')) |
|
652 | + if ($this->hasOption('core.template.cache_dir')) |
|
653 | 653 | { |
654 | 654 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
655 | 655 | } |
@@ -671,11 +671,11 @@ discard block |
||
671 | 671 | |
672 | 672 | // Add component files to the javascript file array; |
673 | 673 | $aJsFiles = array($sJsCoreUrl); |
674 | - if($this->getOption('core.debug.on')) |
|
674 | + if ($this->getOption('core.debug.on')) |
|
675 | 675 | { |
676 | 676 | $aJsFiles[] = $sJsDebugUrl; |
677 | 677 | $aJsFiles[] = $sJsLanguageUrl; |
678 | - if($this->getOption('core.debug.verbose')) |
|
678 | + if ($this->getOption('core.debug.verbose')) |
|
679 | 679 | { |
680 | 680 | $aJsFiles[] = $sJsVerboseUrl; |
681 | 681 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | 'sJsOptions' => $this->getOption('js.app.options'), |
688 | 688 | 'aUrls' => $aJsFiles, |
689 | 689 | )); |
690 | - foreach($this->aResponsePlugins as $xPlugin) |
|
690 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
691 | 691 | { |
692 | 692 | $sCode .= rtrim($xPlugin->getJs(), " \n") . "\n"; |
693 | 693 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $this->setTemplateCacheDir(); |
706 | 706 | |
707 | 707 | $sCode = ''; |
708 | - foreach($this->aResponsePlugins as $xPlugin) |
|
708 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
709 | 709 | { |
710 | 710 | $sCode .= rtrim($xPlugin->getCss(), " \n") . "\n"; |
711 | 711 | } |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | )); |
794 | 794 | |
795 | 795 | $sPluginScript = ''; |
796 | - foreach($this->aResponsePlugins as $xPlugin) |
|
796 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
797 | 797 | { |
798 | 798 | $sPluginScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
799 | 799 | } |
@@ -825,11 +825,11 @@ discard block |
||
825 | 825 | |
826 | 826 | // Get the config and plugins scripts |
827 | 827 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
828 | - foreach($this->aRequestPlugins as $xPlugin) |
|
828 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
829 | 829 | { |
830 | 830 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
831 | 831 | } |
832 | - if($this->canExportJavascript()) |
|
832 | + if ($this->canExportJavascript()) |
|
833 | 833 | { |
834 | 834 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
835 | 835 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -838,13 +838,13 @@ discard block |
||
838 | 838 | $sHash = $this->generateHash(); |
839 | 839 | $sOutFile = $sHash . '.js'; |
840 | 840 | $sMinFile = $sHash . '.min.js'; |
841 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
841 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
842 | 842 | { |
843 | 843 | file_put_contents($sJsAppDir . $sOutFile, $sScript); |
844 | 844 | } |
845 | - if(($this->getOption('js.app.minify'))) |
|
845 | + if (($this->getOption('js.app.minify'))) |
|
846 | 846 | { |
847 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
847 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
848 | 848 | { |
849 | 849 | $sOutFile = $sMinFile; |
850 | 850 | } |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | */ |
878 | 878 | public function getResponsePlugin($sName) |
879 | 879 | { |
880 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
880 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
881 | 881 | { |
882 | 882 | return $this->aResponsePlugins[$sName]; |
883 | 883 | } |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | */ |
894 | 894 | public function getRequestPlugin($sName) |
895 | 895 | { |
896 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
896 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
897 | 897 | { |
898 | 898 | return $this->aRequestPlugins[$sName]; |
899 | 899 | } |
@@ -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 | } |
@@ -407,8 +405,7 @@ discard block |
||
407 | 405 | { |
408 | 406 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
409 | 407 | } |
410 | - } |
|
411 | - elseif(($this->xAutoloader)) |
|
408 | + } elseif(($this->xAutoloader)) |
|
412 | 409 | { |
413 | 410 | // If there is an autoloader, register the dir with classmap autoloading |
414 | 411 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
@@ -545,8 +542,7 @@ discard block |
||
545 | 542 | { |
546 | 543 | $sClassFile = $aClassDir['directory'] . DIRECTORY_SEPARATOR . substr($sClassFile, $nLen); |
547 | 544 | $bRegister = true; |
548 | - } |
|
549 | - elseif(!($sNamespace)) |
|
545 | + } elseif(!($sNamespace)) |
|
550 | 546 | { |
551 | 547 | $sClassFile = $aClassDir['directory'] . DIRECTORY_SEPARATOR . $sClassFile; |
552 | 548 | $bRegister = true; |
@@ -855,8 +851,7 @@ discard block |
||
855 | 851 | 'sJsOptions' => $this->getOption('js.app.options'), |
856 | 852 | 'sUrl' => $sJsAppURI . $sOutFile, |
857 | 853 | )); |
858 | - } |
|
859 | - else |
|
854 | + } else |
|
860 | 855 | { |
861 | 856 | // The plugins scripts are wrapped with javascript tags |
862 | 857 | $sScript = $this->render('jaxon::plugins/wrapper.js', array( |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | $this->aArgs = array(); |
56 | 56 | $this->nMethod = Jaxon::METHOD_UNKNOWN; |
57 | 57 | |
58 | - if(isset($_POST['jxnargs'])) |
|
58 | + if (isset($_POST['jxnargs'])) |
|
59 | 59 | { |
60 | 60 | $this->nMethod = Jaxon::METHOD_POST; |
61 | 61 | $this->aArgs = $_POST['jxnargs']; |
62 | 62 | } |
63 | - elseif(isset($_GET['jxnargs'])) |
|
63 | + elseif (isset($_GET['jxnargs'])) |
|
64 | 64 | { |
65 | 65 | $this->nMethod = Jaxon::METHOD_GET; |
66 | 66 | $this->aArgs = $_GET['jxnargs']; |
67 | 67 | } |
68 | - if(get_magic_quotes_gpc() == 1) |
|
68 | + if (get_magic_quotes_gpc() == 1) |
|
69 | 69 | { |
70 | 70 | array_walk($this->aArgs, array(&$this, '__argumentStripSlashes')); |
71 | 71 | } |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | */ |
82 | 82 | private function __convertStringToBool($sValue) |
83 | 83 | { |
84 | - if(strcasecmp($sValue, 'true') == 0) |
|
84 | + if (strcasecmp($sValue, 'true') == 0) |
|
85 | 85 | { |
86 | 86 | return true; |
87 | 87 | } |
88 | - if(strcasecmp($sValue, 'false') == 0) |
|
88 | + if (strcasecmp($sValue, 'false') == 0) |
|
89 | 89 | { |
90 | 90 | return false; |
91 | 91 | } |
92 | - if(is_numeric($sValue)) |
|
92 | + if (is_numeric($sValue)) |
|
93 | 93 | { |
94 | - if($sValue == 0) |
|
94 | + if ($sValue == 0) |
|
95 | 95 | { |
96 | 96 | return false; |
97 | 97 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | private function __argumentStripSlashes(&$sArg) |
111 | 111 | { |
112 | - if(!is_string($sArg)) |
|
112 | + if (!is_string($sArg)) |
|
113 | 113 | { |
114 | 114 | return ''; |
115 | 115 | } |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | */ |
158 | 158 | private function __argumentDecode(&$sArg) |
159 | 159 | { |
160 | - if($sArg == '') |
|
160 | + if ($sArg == '') |
|
161 | 161 | { |
162 | 162 | return ''; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $data = json_decode($sArg, true); |
166 | 166 | |
167 | - if($data !== null && $sArg != $data) |
|
167 | + if ($data !== null && $sArg != $data) |
|
168 | 168 | { |
169 | 169 | $sArg = $data; |
170 | 170 | } |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | */ |
184 | 184 | private function __argumentDecodeUTF8_iconv(&$mArg) |
185 | 185 | { |
186 | - if(is_array($mArg)) |
|
186 | + if (is_array($mArg)) |
|
187 | 187 | { |
188 | - foreach($mArg as $sKey => $xArg) |
|
188 | + foreach ($mArg as $sKey => $xArg) |
|
189 | 189 | { |
190 | 190 | $sNewKey = $sKey; |
191 | 191 | $this->__argumentDecodeUTF8_iconv($sNewKey); |
192 | - if($sNewKey != $sKey) |
|
192 | + if ($sNewKey != $sKey) |
|
193 | 193 | { |
194 | 194 | $mArg[$sNewKey] = $xArg; |
195 | 195 | unset($mArg[$sKey]); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $this->__argumentDecodeUTF8_iconv($xArg); |
199 | 199 | } |
200 | 200 | } |
201 | - elseif(is_string($mArg)) |
|
201 | + elseif (is_string($mArg)) |
|
202 | 202 | { |
203 | 203 | $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg); |
204 | 204 | } |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | */ |
214 | 214 | private function __argumentDecodeUTF8_mb_convert_encoding(&$mArg) |
215 | 215 | { |
216 | - if(is_array($mArg)) |
|
216 | + if (is_array($mArg)) |
|
217 | 217 | { |
218 | - foreach($mArg as $sKey => $xArg) |
|
218 | + foreach ($mArg as $sKey => $xArg) |
|
219 | 219 | { |
220 | 220 | $sNewKey = $sKey; |
221 | 221 | $this->__argumentDecodeUTF8_mb_convert_encoding($sNewKey); |
222 | - if($sNewKey != $sKey) |
|
222 | + if ($sNewKey != $sKey) |
|
223 | 223 | { |
224 | 224 | $mArg[$sNewKey] = $xArg; |
225 | 225 | unset($mArg[$sKey]); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $this->__argumentDecodeUTF8_mb_convert_encoding($xArg); |
229 | 229 | } |
230 | 230 | } |
231 | - elseif(is_string($mArg)) |
|
231 | + elseif (is_string($mArg)) |
|
232 | 232 | { |
233 | 233 | $mArg = mb_convert_encoding($mArg, $this->getOption('core.encoding'), "UTF-8"); |
234 | 234 | } |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | */ |
244 | 244 | private function __argumentDecodeUTF8_utf8_decode(&$mArg) |
245 | 245 | { |
246 | - if(is_array($mArg)) |
|
246 | + if (is_array($mArg)) |
|
247 | 247 | { |
248 | - foreach($mArg as $sKey => $xArg) |
|
248 | + foreach ($mArg as $sKey => $xArg) |
|
249 | 249 | { |
250 | 250 | $sNewKey = $sKey; |
251 | 251 | $this->__argumentDecodeUTF8_utf8_decode($sNewKey); |
252 | 252 | |
253 | - if($sNewKey != $sKey) |
|
253 | + if ($sNewKey != $sKey) |
|
254 | 254 | { |
255 | 255 | $mArg[$sNewKey] = $xArg; |
256 | 256 | unset($mArg[$sKey]); |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $this->__argumentDecodeUTF8_utf8_decode($xArg); |
261 | 261 | } |
262 | 262 | } |
263 | - elseif(is_string($mArg)) |
|
263 | + elseif (is_string($mArg)) |
|
264 | 264 | { |
265 | 265 | $mArg = utf8_decode($mArg); |
266 | 266 | } |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | */ |
286 | 286 | public function process() |
287 | 287 | { |
288 | - if(($this->getOption('core.decode_utf8'))) |
|
288 | + if (($this->getOption('core.decode_utf8'))) |
|
289 | 289 | { |
290 | 290 | $sFunction = ''; |
291 | 291 | |
292 | - if(function_exists('iconv')) |
|
292 | + if (function_exists('iconv')) |
|
293 | 293 | { |
294 | 294 | $sFunction = "iconv"; |
295 | 295 | } |
296 | - elseif(function_exists('mb_convert_encoding')) |
|
296 | + elseif (function_exists('mb_convert_encoding')) |
|
297 | 297 | { |
298 | 298 | $sFunction = "mb_convert_encoding"; |
299 | 299 | } |
300 | - elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
300 | + elseif ($this->getOption('core.encoding') == "ISO-8859-1") |
|
301 | 301 | { |
302 | 302 | $sFunction = "utf8_decode"; |
303 | 303 | } |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | $this->nMethod = Jaxon::METHOD_POST; |
61 | 61 | $this->aArgs = $_POST['jxnargs']; |
62 | - } |
|
63 | - elseif(isset($_GET['jxnargs'])) |
|
62 | + } elseif(isset($_GET['jxnargs'])) |
|
64 | 63 | { |
65 | 64 | $this->nMethod = Jaxon::METHOD_GET; |
66 | 65 | $this->aArgs = $_GET['jxnargs']; |
@@ -167,8 +166,7 @@ discard block |
||
167 | 166 | if($data !== null && $sArg != $data) |
168 | 167 | { |
169 | 168 | $sArg = $data; |
170 | - } |
|
171 | - else |
|
169 | + } else |
|
172 | 170 | { |
173 | 171 | $sArg = $this->__convertValue($sArg); |
174 | 172 | } |
@@ -197,8 +195,7 @@ discard block |
||
197 | 195 | } |
198 | 196 | $this->__argumentDecodeUTF8_iconv($xArg); |
199 | 197 | } |
200 | - } |
|
201 | - elseif(is_string($mArg)) |
|
198 | + } elseif(is_string($mArg)) |
|
202 | 199 | { |
203 | 200 | $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg); |
204 | 201 | } |
@@ -227,8 +224,7 @@ discard block |
||
227 | 224 | } |
228 | 225 | $this->__argumentDecodeUTF8_mb_convert_encoding($xArg); |
229 | 226 | } |
230 | - } |
|
231 | - elseif(is_string($mArg)) |
|
227 | + } elseif(is_string($mArg)) |
|
232 | 228 | { |
233 | 229 | $mArg = mb_convert_encoding($mArg, $this->getOption('core.encoding'), "UTF-8"); |
234 | 230 | } |
@@ -259,8 +255,7 @@ discard block |
||
259 | 255 | |
260 | 256 | $this->__argumentDecodeUTF8_utf8_decode($xArg); |
261 | 257 | } |
262 | - } |
|
263 | - elseif(is_string($mArg)) |
|
258 | + } elseif(is_string($mArg)) |
|
264 | 259 | { |
265 | 260 | $mArg = utf8_decode($mArg); |
266 | 261 | } |
@@ -292,16 +287,13 @@ discard block |
||
292 | 287 | if(function_exists('iconv')) |
293 | 288 | { |
294 | 289 | $sFunction = "iconv"; |
295 | - } |
|
296 | - elseif(function_exists('mb_convert_encoding')) |
|
290 | + } elseif(function_exists('mb_convert_encoding')) |
|
297 | 291 | { |
298 | 292 | $sFunction = "mb_convert_encoding"; |
299 | - } |
|
300 | - elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
293 | + } elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
301 | 294 | { |
302 | 295 | $sFunction = "utf8_decode"; |
303 | - } |
|
304 | - else |
|
296 | + } else |
|
305 | 297 | { |
306 | 298 | throw new \Jaxon\Exception\Error($this->trans('errors.request.conversion')); |
307 | 299 | } |
@@ -91,19 +91,19 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function make($xValue) |
93 | 93 | { |
94 | - if($xValue instanceof Interfaces\Parameter) |
|
94 | + if ($xValue instanceof Interfaces\Parameter) |
|
95 | 95 | { |
96 | 96 | return $xValue; |
97 | 97 | } |
98 | - elseif(is_numeric($xValue)) |
|
98 | + elseif (is_numeric($xValue)) |
|
99 | 99 | { |
100 | 100 | return new Parameter(Jaxon::NUMERIC_VALUE, $xValue); |
101 | 101 | } |
102 | - elseif(is_string($xValue)) |
|
102 | + elseif (is_string($xValue)) |
|
103 | 103 | { |
104 | 104 | return new Parameter(Jaxon::QUOTED_VALUE, $xValue); |
105 | 105 | } |
106 | - elseif(is_bool($xValue)) |
|
106 | + elseif (is_bool($xValue)) |
|
107 | 107 | { |
108 | 108 | return new Parameter(Jaxon::BOOL_VALUE, $xValue); |
109 | 109 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | { |
123 | 123 | $sJsCode = ''; |
124 | 124 | $sQuoteCharacter = "'"; |
125 | - switch($this->sType) |
|
125 | + switch ($this->sType) |
|
126 | 126 | { |
127 | 127 | case Jaxon::FORM_VALUES: |
128 | 128 | $sFormID = (string)$this->xValue; |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | break; |
131 | 131 | case Jaxon::INPUT_VALUE: |
132 | 132 | $sInputID = (string)$this->xValue; |
133 | - $sJsCode = "jaxon.$(" . $sQuoteCharacter . $sInputID . $sQuoteCharacter . ").value"; |
|
133 | + $sJsCode = "jaxon.$(" . $sQuoteCharacter . $sInputID . $sQuoteCharacter . ").value"; |
|
134 | 134 | break; |
135 | 135 | case Jaxon::CHECKED_VALUE: |
136 | 136 | $sCheckedID = (string)$this->xValue; |
137 | - $sJsCode = "jaxon.$(" . $sQuoteCharacter . $sCheckedID . $sQuoteCharacter . ").checked"; |
|
137 | + $sJsCode = "jaxon.$(" . $sQuoteCharacter . $sCheckedID . $sQuoteCharacter . ").checked"; |
|
138 | 138 | break; |
139 | 139 | case Jaxon::ELEMENT_INNERHTML: |
140 | 140 | $sElementID = (string)$this->xValue; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $sJsCode = (string)$this->xValue; |
154 | 154 | break; |
155 | 155 | case Jaxon::JS_VALUE: |
156 | - if(is_array($this->xValue) || is_object($this->xValue)) |
|
156 | + if (is_array($this->xValue) || is_object($this->xValue)) |
|
157 | 157 | { |
158 | 158 | // Unable to use double quotes here because they cannot be handled on client side. |
159 | 159 | // So we are using simple quotes even if the Json standard recommends double quotes. |
@@ -94,20 +94,16 @@ discard block |
||
94 | 94 | if($xValue instanceof Interfaces\Parameter) |
95 | 95 | { |
96 | 96 | return $xValue; |
97 | - } |
|
98 | - elseif(is_numeric($xValue)) |
|
97 | + } elseif(is_numeric($xValue)) |
|
99 | 98 | { |
100 | 99 | return new Parameter(Jaxon::NUMERIC_VALUE, $xValue); |
101 | - } |
|
102 | - elseif(is_string($xValue)) |
|
100 | + } elseif(is_string($xValue)) |
|
103 | 101 | { |
104 | 102 | return new Parameter(Jaxon::QUOTED_VALUE, $xValue); |
105 | - } |
|
106 | - elseif(is_bool($xValue)) |
|
103 | + } elseif(is_bool($xValue)) |
|
107 | 104 | { |
108 | 105 | return new Parameter(Jaxon::BOOL_VALUE, $xValue); |
109 | - } |
|
110 | - else // if(is_array($xValue) || is_object($xValue)) |
|
106 | + } else // if(is_array($xValue) || is_object($xValue)) |
|
111 | 107 | { |
112 | 108 | return new Parameter(Jaxon::JS_VALUE, $xValue); |
113 | 109 | } |
@@ -158,8 +154,7 @@ discard block |
||
158 | 154 | // Unable to use double quotes here because they cannot be handled on client side. |
159 | 155 | // So we are using simple quotes even if the Json standard recommends double quotes. |
160 | 156 | $sJsCode = str_replace(['"'], ["'"], json_encode($this->xValue, JSON_HEX_APOS | JSON_HEX_QUOT)); |
161 | - } |
|
162 | - else |
|
157 | + } else |
|
163 | 158 | { |
164 | 159 | $sJsCode = (string)$this->xValue; |
165 | 160 | } |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function hasPageNumber() |
72 | 72 | { |
73 | - foreach($this->aParameters as $xParameter) |
|
73 | + foreach ($this->aParameters as $xParameter) |
|
74 | 74 | { |
75 | - if($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
75 | + if ($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
76 | 76 | { |
77 | 77 | return true; |
78 | 78 | } |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | public function setPageNumber($nPageNumber) |
91 | 91 | { |
92 | 92 | // Set the value of the Jaxon::PAGE_NUMBER parameter |
93 | - foreach($this->aParameters as $xParameter) |
|
93 | + foreach ($this->aParameters as $xParameter) |
|
94 | 94 | { |
95 | - if($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
95 | + if ($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
96 | 96 | { |
97 | 97 | $xParameter->setValue(intval($nPageNumber)); |
98 | 98 | break; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | { |
113 | 113 | $this->sCondition = '__confirm__'; |
114 | 114 | $this->aMessageArgs = func_get_args(); |
115 | - array_walk($this->aMessageArgs, function (&$xParameter) { |
|
115 | + array_walk($this->aMessageArgs, function(&$xParameter) { |
|
116 | 116 | $xParameter = Parameter::make($xParameter); |
117 | 117 | }); |
118 | 118 | return $this; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $this->sCondition = Parameter::make($sCondition)->getScript(); |
134 | 134 | $this->aMessageArgs = func_get_args(); |
135 | 135 | array_shift($this->aMessageArgs); // Remove the first entry (the condition) from the array |
136 | - array_walk($this->aMessageArgs, function (&$xParameter) { |
|
136 | + array_walk($this->aMessageArgs, function(&$xParameter) { |
|
137 | 137 | $xParameter = Parameter::make($xParameter); |
138 | 138 | }); |
139 | 139 | return $this; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $this->sCondition = '!(' . Parameter::make($sCondition)->getScript() . ')'; |
155 | 155 | $this->aMessageArgs = func_get_args(); |
156 | 156 | array_shift($this->aMessageArgs); // Remove the first entry (the condition) from the array |
157 | - array_walk($this->aMessageArgs, function (&$xParameter) { |
|
157 | + array_walk($this->aMessageArgs, function(&$xParameter) { |
|
158 | 158 | $xParameter = Parameter::make($xParameter); |
159 | 159 | }); |
160 | 160 | return $this; |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | // This array will avoid declaring many variables with the same value. |
180 | 180 | // The array key is the variable value, while the array value is the variable name. |
181 | 181 | $aVariables = array(); // Array of local variables. |
182 | - foreach($this->aParameters as &$xParameter) |
|
182 | + foreach ($this->aParameters as &$xParameter) |
|
183 | 183 | { |
184 | 184 | $sParameterStr = $xParameter->getScript(); |
185 | - if($xParameter instanceof \Jaxon\JQuery\Dom\Element) |
|
185 | + if ($xParameter instanceof \Jaxon\JQuery\Dom\Element) |
|
186 | 186 | { |
187 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
187 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
188 | 188 | { |
189 | 189 | // The value is not yet defined. A new variable is created. |
190 | 190 | $sVarName = "jxnVar$nVarId"; |
@@ -202,19 +202,19 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | $sPhrase = ''; |
205 | - if(count($this->aMessageArgs) > 0) |
|
205 | + if (count($this->aMessageArgs) > 0) |
|
206 | 206 | { |
207 | 207 | $sPhrase = array_shift($this->aMessageArgs); // The first array entry is the question. |
208 | 208 | // $sPhrase = "'" . addslashes($sPhrase) . "'"; // Wrap the phrase with single quotes |
209 | - if(count($this->aMessageArgs) > 0) |
|
209 | + if (count($this->aMessageArgs) > 0) |
|
210 | 210 | { |
211 | 211 | $nParamId = 1; |
212 | - foreach($this->aMessageArgs as &$xParameter) |
|
212 | + foreach ($this->aMessageArgs as &$xParameter) |
|
213 | 213 | { |
214 | 214 | $sParameterStr = $xParameter->getScript(); |
215 | - if($xParameter instanceof \Jaxon\JQuery\Dom\Element) |
|
215 | + if ($xParameter instanceof \Jaxon\JQuery\Dom\Element) |
|
216 | 216 | { |
217 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
217 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
218 | 218 | { |
219 | 219 | // The value is not yet defined. A new variable is created. |
220 | 220 | $sVarName = "jxnVar$nVarId"; |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | $sScript = $this->getOption('core.prefix.' . $this->sType) . parent::getScript(); |
240 | - if($this->sCondition == '__confirm__') |
|
240 | + if ($this->sCondition == '__confirm__') |
|
241 | 241 | { |
242 | 242 | $xConfirm = $this->getPluginManager()->getConfirm(); |
243 | 243 | $sScript = $xConfirm->confirm($sPhrase, $sScript, ''); |
244 | 244 | } |
245 | - elseif($this->sCondition !== null) |
|
245 | + elseif ($this->sCondition !== null) |
|
246 | 246 | { |
247 | 247 | $xAlert = $this->getPluginManager()->getAlert(); |
248 | 248 | $xAlert->setReturn(true); |
249 | 249 | $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}'; |
250 | - if(($sPhrase)) |
|
250 | + if (($sPhrase)) |
|
251 | 251 | { |
252 | 252 | $sScript .= 'else{' . $xAlert->warning($sPhrase) . ';}'; |
253 | 253 | } |
@@ -191,8 +191,7 @@ discard block |
||
191 | 191 | $aVariables[$sParameterStr] = $sVarName; |
192 | 192 | $sVars .= "$sVarName=$xParameter;"; |
193 | 193 | $nVarId++; |
194 | - } |
|
195 | - else |
|
194 | + } else |
|
196 | 195 | { |
197 | 196 | // The value is already defined. The corresponding variable is assigned. |
198 | 197 | $sVarName = $aVariables[$sParameterStr]; |
@@ -221,8 +220,7 @@ discard block |
||
221 | 220 | $aVariables[$sParameterStr] = $sVarName; |
222 | 221 | $sVars .= "$sVarName=$xParameter;"; |
223 | 222 | $nVarId++; |
224 | - } |
|
225 | - else |
|
223 | + } else |
|
226 | 224 | { |
227 | 225 | // The value is already defined. The corresponding variable is assigned. |
228 | 226 | $sVarName = $aVariables[$sParameterStr]; |
@@ -241,8 +239,7 @@ discard block |
||
241 | 239 | { |
242 | 240 | $xConfirm = $this->getPluginManager()->getConfirm(); |
243 | 241 | $sScript = $xConfirm->confirm($sPhrase, $sScript, ''); |
244 | - } |
|
245 | - elseif($this->sCondition !== null) |
|
242 | + } elseif($this->sCondition !== null) |
|
246 | 243 | { |
247 | 244 | $xAlert = $this->getPluginManager()->getAlert(); |
248 | 245 | $xAlert->setReturn(true); |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | |
52 | 52 | $this->sRequestedEvent = null; |
53 | 53 | |
54 | - if(isset($_GET['jxnevt'])) |
|
54 | + if (isset($_GET['jxnevt'])) |
|
55 | 55 | { |
56 | 56 | $this->sRequestedEvent = $_GET['jxnevt']; |
57 | 57 | } |
58 | - if(isset($_POST['jxnevt'])) |
|
58 | + if (isset($_POST['jxnevt'])) |
|
59 | 59 | { |
60 | 60 | $this->sRequestedEvent = $_POST['jxnevt']; |
61 | 61 | } |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function register($aArgs) |
82 | 82 | { |
83 | - if(count($aArgs) > 1) |
|
83 | + if (count($aArgs) > 1) |
|
84 | 84 | { |
85 | 85 | $sType = $aArgs[0]; |
86 | 86 | |
87 | - if($sType == Jaxon::BROWSER_EVENT) |
|
87 | + if ($sType == Jaxon::BROWSER_EVENT) |
|
88 | 88 | { |
89 | 89 | $sEvent = $aArgs[1]; |
90 | - if(!isset($this->aEvents[$sEvent])) |
|
90 | + if (!isset($this->aEvents[$sEvent])) |
|
91 | 91 | { |
92 | 92 | $xBrowserEvent = new \Jaxon\Support\BrowserEvent($sEvent); |
93 | - if(count($aArgs) > 2 && is_array($aArgs[2])) |
|
93 | + if (count($aArgs) > 2 && is_array($aArgs[2])) |
|
94 | 94 | { |
95 | - foreach($aArgs[2] as $sKey => $sValue) |
|
95 | + foreach ($aArgs[2] as $sKey => $sValue) |
|
96 | 96 | { |
97 | 97 | $xBrowserEvent->configure($sKey, $sValue); |
98 | 98 | } |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | return $xBrowserEvent->generateRequest(); |
102 | 102 | } |
103 | 103 | } |
104 | - elseif($sType == Jaxon::EVENT_HANDLER) |
|
104 | + elseif ($sType == Jaxon::EVENT_HANDLER) |
|
105 | 105 | { |
106 | 106 | $sEvent = $aArgs[1]; |
107 | - if(isset($this->aEvents[$sEvent]) && isset($aArgs[2])) |
|
107 | + if (isset($this->aEvents[$sEvent]) && isset($aArgs[2])) |
|
108 | 108 | { |
109 | 109 | $xUserFunction = $aArgs[2]; |
110 | - if(!($xUserFunction instanceof \Jaxon\Request\Support\UserFunction)) |
|
110 | + if (!($xUserFunction instanceof \Jaxon\Request\Support\UserFunction)) |
|
111 | 111 | { |
112 | 112 | $xUserFunction = new \Jaxon\Request\Support\UserFunction($xUserFunction); |
113 | 113 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | public function generateHash() |
130 | 130 | { |
131 | 131 | $sHash = ''; |
132 | - foreach($this->aEvents as $xEvent) |
|
132 | + foreach ($this->aEvents as $xEvent) |
|
133 | 133 | { |
134 | 134 | $sHash .= $xEvent->getName(); |
135 | 135 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public function getScript() |
145 | 145 | { |
146 | 146 | $sCode = ''; |
147 | - foreach($this->aEvents as $xEvent) |
|
147 | + foreach ($this->aEvents as $xEvent) |
|
148 | 148 | { |
149 | 149 | $sCode .= $xEvent->getScript(); |
150 | 150 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | public function canProcessRequest() |
160 | 160 | { |
161 | 161 | // Check the validity of the event name |
162 | - if(($this->sRequestedEvent) && !$this->validateEvent($this->sRequestedEvent)) |
|
162 | + if (($this->sRequestedEvent) && !$this->validateEvent($this->sRequestedEvent)) |
|
163 | 163 | { |
164 | 164 | $this->sRequestedEvent = null; |
165 | 165 | } |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function processRequest() |
175 | 175 | { |
176 | - if(!$this->canProcessRequest()) |
|
176 | + if (!$this->canProcessRequest()) |
|
177 | 177 | return false; |
178 | 178 | |
179 | 179 | $aArgs = $this->getRequestManager()->process(); |
180 | 180 | |
181 | - if(array_key_exists($this->sRequestedEvent, $this->aEvents)) |
|
181 | + if (array_key_exists($this->sRequestedEvent, $this->aEvents)) |
|
182 | 182 | { |
183 | 183 | $this->aEvents[$this->sRequestedEvent]->fire($aArgs); |
184 | 184 | return true; |
@@ -100,8 +100,7 @@ discard block |
||
100 | 100 | $this->aEvents[$sEvent] = $xBrowserEvent; |
101 | 101 | return $xBrowserEvent->generateRequest(); |
102 | 102 | } |
103 | - } |
|
104 | - elseif($sType == Jaxon::EVENT_HANDLER) |
|
103 | + } elseif($sType == Jaxon::EVENT_HANDLER) |
|
105 | 104 | { |
106 | 105 | $sEvent = $aArgs[1]; |
107 | 106 | if(isset($this->aEvents[$sEvent]) && isset($aArgs[2])) |
@@ -173,8 +172,9 @@ discard block |
||
173 | 172 | */ |
174 | 173 | public function processRequest() |
175 | 174 | { |
176 | - if(!$this->canProcessRequest()) |
|
177 | - return false; |
|
175 | + if(!$this->canProcessRequest()) { |
|
176 | + return false; |
|
177 | + } |
|
178 | 178 | |
179 | 179 | $aArgs = $this->getRequestManager()->process(); |
180 | 180 |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | { |
91 | 91 | $this->aConfiguration = array(); |
92 | 92 | $this->sAlias = ''; |
93 | - if(is_array($sUserFunction)) |
|
93 | + if (is_array($sUserFunction)) |
|
94 | 94 | { |
95 | - if(count($sUserFunction) != 2 && count($sUserFunction) != 3) |
|
95 | + if (count($sUserFunction) != 2 && count($sUserFunction) != 3) |
|
96 | 96 | { |
97 | 97 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration')); |
98 | 98 | } |
99 | - if(count($sUserFunction) == 3) |
|
99 | + if (count($sUserFunction) == 3) |
|
100 | 100 | { |
101 | 101 | $this->sAlias = $sUserFunction[0]; |
102 | 102 | $this->sUserFunction = array_slice($sUserFunction, 1); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $this->sUserFunction = $sUserFunction; |
107 | 107 | } |
108 | 108 | } |
109 | - elseif(is_string($sUserFunction)) |
|
109 | + elseif (is_string($sUserFunction)) |
|
110 | 110 | { |
111 | 111 | $this->sUserFunction = $sUserFunction; |
112 | 112 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | public function getName() |
125 | 125 | { |
126 | 126 | // Do not use sAlias here! |
127 | - if(is_array($this->sUserFunction)) |
|
127 | + if (is_array($this->sUserFunction)) |
|
128 | 128 | { |
129 | 129 | return $this->sUserFunction[1]; |
130 | 130 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function configure($sName, $sValue) |
143 | 143 | { |
144 | - switch($sName) |
|
144 | + switch ($sName) |
|
145 | 145 | { |
146 | 146 | case 'alias': |
147 | 147 | $this->sAlias = $sValue; |
@@ -195,12 +195,12 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function call($aArgs = array()) |
197 | 197 | { |
198 | - if(($this->sInclude)) |
|
198 | + if (($this->sInclude)) |
|
199 | 199 | { |
200 | 200 | ob_start(); |
201 | 201 | require_once $this->sInclude; |
202 | 202 | $sOutput = ob_get_clean(); |
203 | - if(($sOutput)) |
|
203 | + if (($sOutput)) |
|
204 | 204 | { |
205 | 205 | $sOutput = $this->trans('debug.function.include', array( |
206 | 206 | 'file' => $this->sInclude, |
@@ -100,17 +100,14 @@ |
||
100 | 100 | { |
101 | 101 | $this->sAlias = $sUserFunction[0]; |
102 | 102 | $this->sUserFunction = array_slice($sUserFunction, 1); |
103 | - } |
|
104 | - else |
|
103 | + } else |
|
105 | 104 | { |
106 | 105 | $this->sUserFunction = $sUserFunction; |
107 | 106 | } |
108 | - } |
|
109 | - elseif(is_string($sUserFunction)) |
|
107 | + } elseif(is_string($sUserFunction)) |
|
110 | 108 | { |
111 | 109 | $this->sUserFunction = $sUserFunction; |
112 | - } |
|
113 | - else |
|
110 | + } else |
|
114 | 111 | { |
115 | 112 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration')); |
116 | 113 | } |
@@ -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 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | // The class name without the namespace. |
168 | 168 | $name = $this->reflectionClass->getShortName(); |
169 | 169 | // Append the classpath to the name |
170 | - if(($this->classpath)) |
|
170 | + if (($this->classpath)) |
|
171 | 171 | { |
172 | 172 | $name = $this->classpath . $this->separator . $name; |
173 | 173 | } |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | public function getMethods() |
205 | 205 | { |
206 | 206 | $aReturn = array(); |
207 | - foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
207 | + foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
208 | 208 | { |
209 | 209 | $sMethodName = $xMethod->getShortName(); |
210 | 210 | // Don't take magic __call, __construct, __destruct methods |
211 | - if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
211 | + if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
212 | 212 | { |
213 | 213 | continue; |
214 | 214 | } |
215 | 215 | // Don't take excluded methods |
216 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
216 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
217 | 217 | { |
218 | 218 | continue; |
219 | 219 | } |
@@ -234,37 +234,37 @@ discard block |
||
234 | 234 | public function configure($sMethod, $sName, $sValue) |
235 | 235 | { |
236 | 236 | // Set the namespace |
237 | - if($sName == 'namespace') |
|
237 | + if ($sName == 'namespace') |
|
238 | 238 | { |
239 | - if($sValue != '') |
|
239 | + if ($sValue != '') |
|
240 | 240 | $this->namespace = $sValue; |
241 | 241 | return; |
242 | 242 | } |
243 | 243 | // Set the classpath |
244 | - if($sName == 'classpath') |
|
244 | + if ($sName == 'classpath') |
|
245 | 245 | { |
246 | - if($sValue != '') |
|
246 | + if ($sValue != '') |
|
247 | 247 | $this->classpath = $sValue; |
248 | 248 | return; |
249 | 249 | } |
250 | 250 | // Set the separator |
251 | - if($sName == 'separator') |
|
251 | + if ($sName == 'separator') |
|
252 | 252 | { |
253 | - if($sValue == '_' || $sValue == '.') |
|
253 | + if ($sValue == '_' || $sValue == '.') |
|
254 | 254 | $this->separator = $sValue; |
255 | 255 | return; |
256 | 256 | } |
257 | 257 | // Set the excluded methods |
258 | - if($sName == 'protected') |
|
258 | + if ($sName == 'protected') |
|
259 | 259 | { |
260 | - if(is_array($sValue)) |
|
260 | + if (is_array($sValue)) |
|
261 | 261 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
262 | - elseif(is_string($sValue)) |
|
262 | + elseif (is_string($sValue)) |
|
263 | 263 | $this->aProtectedMethods[] = $sValue; |
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | - if(!isset($this->aConfiguration[$sMethod])) |
|
267 | + if (!isset($this->aConfiguration[$sMethod])) |
|
268 | 268 | { |
269 | 269 | $this->aConfiguration[$sMethod] = array(); |
270 | 270 | } |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | |
285 | 285 | // Common options to be set on all methods |
286 | 286 | $aCommonConfig = array_key_exists('*', $this->aConfiguration) ? $this->aConfiguration['*'] : array(); |
287 | - foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
287 | + foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
288 | 288 | { |
289 | 289 | $sMethodName = $xMethod->getShortName(); |
290 | 290 | // Don't export magic __call, __construct, __destruct methods |
291 | - if(strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__') |
|
291 | + if (strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__') |
|
292 | 292 | { |
293 | 293 | continue; |
294 | 294 | } |
295 | 295 | // Don't export "protected" methods |
296 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
296 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
297 | 297 | { |
298 | 298 | continue; |
299 | 299 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function call($sMethod, $aArgs) |
345 | 345 | { |
346 | - if(!$this->hasMethod($sMethod)) |
|
346 | + if (!$this->hasMethod($sMethod)) |
|
347 | 347 | return; |
348 | 348 | $reflectionMethod = $this->reflectionClass->getMethod($sMethod); |
349 | 349 | $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); |
@@ -236,31 +237,35 @@ discard block |
||
236 | 237 | // Set the namespace |
237 | 238 | if($sName == 'namespace') |
238 | 239 | { |
239 | - if($sValue != '') |
|
240 | - $this->namespace = $sValue; |
|
240 | + if($sValue != '') { |
|
241 | + $this->namespace = $sValue; |
|
242 | + } |
|
241 | 243 | return; |
242 | 244 | } |
243 | 245 | // Set the classpath |
244 | 246 | if($sName == 'classpath') |
245 | 247 | { |
246 | - if($sValue != '') |
|
247 | - $this->classpath = $sValue; |
|
248 | + if($sValue != '') { |
|
249 | + $this->classpath = $sValue; |
|
250 | + } |
|
248 | 251 | return; |
249 | 252 | } |
250 | 253 | // Set the separator |
251 | 254 | if($sName == 'separator') |
252 | 255 | { |
253 | - if($sValue == '_' || $sValue == '.') |
|
254 | - $this->separator = $sValue; |
|
256 | + if($sValue == '_' || $sValue == '.') { |
|
257 | + $this->separator = $sValue; |
|
258 | + } |
|
255 | 259 | return; |
256 | 260 | } |
257 | 261 | // Set the excluded methods |
258 | 262 | if($sName == 'protected') |
259 | 263 | { |
260 | - if(is_array($sValue)) |
|
261 | - $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
|
262 | - elseif(is_string($sValue)) |
|
263 | - $this->aProtectedMethods[] = $sValue; |
|
264 | + if(is_array($sValue)) { |
|
265 | + $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
|
266 | + } elseif(is_string($sValue)) { |
|
267 | + $this->aProtectedMethods[] = $sValue; |
|
268 | + } |
|
264 | 269 | return; |
265 | 270 | } |
266 | 271 | |
@@ -343,8 +348,9 @@ discard block |
||
343 | 348 | */ |
344 | 349 | public function call($sMethod, $aArgs) |
345 | 350 | { |
346 | - if(!$this->hasMethod($sMethod)) |
|
347 | - return; |
|
351 | + if(!$this->hasMethod($sMethod)) { |
|
352 | + return; |
|
353 | + } |
|
348 | 354 | $reflectionMethod = $this->reflectionClass->getMethod($sMethod); |
349 | 355 | $callableObject = $this->getRegisteredObject(); |
350 | 356 | $this->getResponseManager()->append($reflectionMethod->invokeArgs($callableObject, $aArgs)); |