@@ -24,8 +24,6 @@ |
||
24 | 24 | use Jaxon\Jaxon; |
25 | 25 | use RecursiveDirectoryIterator; |
26 | 26 | use RecursiveIteratorIterator; |
27 | -use RegexIterator; |
|
28 | -use RecursiveRegexIterator; |
|
29 | 27 | |
30 | 28 | class Manager |
31 | 29 | { |
@@ -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( |
@@ -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 | } |
@@ -152,7 +152,7 @@ |
||
152 | 152 | * |
153 | 153 | * @param string $sArg The Jaxon request argument |
154 | 154 | * |
155 | - * @return mixed |
|
155 | + * @return string|null |
|
156 | 156 | */ |
157 | 157 | private function __argumentDecode(&$sArg) |
158 | 158 | { |
@@ -131,19 +131,19 @@ |
||
131 | 131 | $sValue = substr($sValue, 1); |
132 | 132 | switch ($cType) |
133 | 133 | { |
134 | - case 'S': |
|
135 | - $value = ($sValue === false ? '' : $sValue); |
|
136 | - break; |
|
137 | - case 'B': |
|
138 | - $value = $this->__convertStringToBool($sValue); |
|
139 | - break; |
|
140 | - case 'N': |
|
141 | - $value = ($sValue == floor($sValue) ? (int)$sValue : (float)$sValue); |
|
142 | - break; |
|
143 | - case '*': |
|
144 | - default: |
|
145 | - $value = null; |
|
146 | - break; |
|
134 | + case 'S': |
|
135 | + $value = ($sValue === false ? '' : $sValue); |
|
136 | + break; |
|
137 | + case 'B': |
|
138 | + $value = $this->__convertStringToBool($sValue); |
|
139 | + break; |
|
140 | + case 'N': |
|
141 | + $value = ($sValue == floor($sValue) ? (int)$sValue : (float)$sValue); |
|
142 | + break; |
|
143 | + case '*': |
|
144 | + default: |
|
145 | + $value = null; |
|
146 | + break; |
|
147 | 147 | } |
148 | 148 | return $value; |
149 | 149 | } |
@@ -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,7 +157,7 @@ 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 | } |
@@ -166,22 +166,22 @@ discard block |
||
166 | 166 | $sType = 'multipart/form-data'; |
167 | 167 | $iLen = strlen($sType); |
168 | 168 | $sContentType = ''; |
169 | - if(key_exists('CONTENT_TYPE', $_SERVER)) |
|
169 | + if (key_exists('CONTENT_TYPE', $_SERVER)) |
|
170 | 170 | { |
171 | 171 | $sContentType = substr($_SERVER['CONTENT_TYPE'], 0, $iLen); |
172 | 172 | } |
173 | - else if(key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
173 | + else if (key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
174 | 174 | { |
175 | 175 | $sContentType = substr($_SERVER['HTTP_CONTENT_TYPE'], 0, $iLen); |
176 | 176 | } |
177 | - if($sContentType == $sType) |
|
177 | + if ($sContentType == $sType) |
|
178 | 178 | { |
179 | 179 | $sArg = urldecode($sArg); |
180 | 180 | } |
181 | 181 | |
182 | 182 | $data = json_decode($sArg, true); |
183 | 183 | |
184 | - if($data !== null && $sArg != $data) |
|
184 | + if ($data !== null && $sArg != $data) |
|
185 | 185 | { |
186 | 186 | $sArg = $data; |
187 | 187 | } |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | */ |
201 | 201 | private function __argumentDecodeUTF8_iconv(&$mArg) |
202 | 202 | { |
203 | - if(is_array($mArg)) |
|
203 | + if (is_array($mArg)) |
|
204 | 204 | { |
205 | - foreach($mArg as $sKey => &$xArg) |
|
205 | + foreach ($mArg as $sKey => &$xArg) |
|
206 | 206 | { |
207 | 207 | $sNewKey = $sKey; |
208 | 208 | $this->__argumentDecodeUTF8_iconv($sNewKey); |
209 | - if($sNewKey != $sKey) |
|
209 | + if ($sNewKey != $sKey) |
|
210 | 210 | { |
211 | 211 | $mArg[$sNewKey] = $xArg; |
212 | 212 | unset($mArg[$sKey]); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $this->__argumentDecodeUTF8_iconv($xArg); |
216 | 216 | } |
217 | 217 | } |
218 | - elseif(is_string($mArg)) |
|
218 | + elseif (is_string($mArg)) |
|
219 | 219 | { |
220 | 220 | $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg); |
221 | 221 | } |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | */ |
231 | 231 | private function __argumentDecodeUTF8_mb_convert_encoding(&$mArg) |
232 | 232 | { |
233 | - if(is_array($mArg)) |
|
233 | + if (is_array($mArg)) |
|
234 | 234 | { |
235 | - foreach($mArg as $sKey => &$xArg) |
|
235 | + foreach ($mArg as $sKey => &$xArg) |
|
236 | 236 | { |
237 | 237 | $sNewKey = $sKey; |
238 | 238 | $this->__argumentDecodeUTF8_mb_convert_encoding($sNewKey); |
239 | - if($sNewKey != $sKey) |
|
239 | + if ($sNewKey != $sKey) |
|
240 | 240 | { |
241 | 241 | $mArg[$sNewKey] = $xArg; |
242 | 242 | unset($mArg[$sKey]); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | $this->__argumentDecodeUTF8_mb_convert_encoding($xArg); |
246 | 246 | } |
247 | 247 | } |
248 | - elseif(is_string($mArg)) |
|
248 | + elseif (is_string($mArg)) |
|
249 | 249 | { |
250 | 250 | $mArg = mb_convert_encoding($mArg, $this->getOption('core.encoding'), "UTF-8"); |
251 | 251 | } |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | */ |
261 | 261 | private function __argumentDecodeUTF8_utf8_decode(&$mArg) |
262 | 262 | { |
263 | - if(is_array($mArg)) |
|
263 | + if (is_array($mArg)) |
|
264 | 264 | { |
265 | - foreach($mArg as $sKey => &$xArg) |
|
265 | + foreach ($mArg as $sKey => &$xArg) |
|
266 | 266 | { |
267 | 267 | $sNewKey = $sKey; |
268 | 268 | $this->__argumentDecodeUTF8_utf8_decode($sNewKey); |
269 | 269 | |
270 | - if($sNewKey != $sKey) |
|
270 | + if ($sNewKey != $sKey) |
|
271 | 271 | { |
272 | 272 | $mArg[$sNewKey] = $xArg; |
273 | 273 | unset($mArg[$sKey]); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $this->__argumentDecodeUTF8_utf8_decode($xArg); |
278 | 278 | } |
279 | 279 | } |
280 | - elseif(is_string($mArg)) |
|
280 | + elseif (is_string($mArg)) |
|
281 | 281 | { |
282 | 282 | $mArg = utf8_decode($mArg); |
283 | 283 | } |
@@ -302,19 +302,19 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function process() |
304 | 304 | { |
305 | - if(($this->getOption('core.decode_utf8'))) |
|
305 | + if (($this->getOption('core.decode_utf8'))) |
|
306 | 306 | { |
307 | 307 | $sFunction = ''; |
308 | 308 | |
309 | - if(function_exists('iconv')) |
|
309 | + if (function_exists('iconv')) |
|
310 | 310 | { |
311 | 311 | $sFunction = "iconv"; |
312 | 312 | } |
313 | - elseif(function_exists('mb_convert_encoding')) |
|
313 | + elseif (function_exists('mb_convert_encoding')) |
|
314 | 314 | { |
315 | 315 | $sFunction = "mb_convert_encoding"; |
316 | 316 | } |
317 | - elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
317 | + elseif ($this->getOption('core.encoding') == "ISO-8859-1") |
|
318 | 318 | { |
319 | 319 | $sFunction = "utf8_decode"; |
320 | 320 | } |
@@ -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']; |
@@ -169,8 +168,7 @@ discard block |
||
169 | 168 | if(key_exists('CONTENT_TYPE', $_SERVER)) |
170 | 169 | { |
171 | 170 | $sContentType = substr($_SERVER['CONTENT_TYPE'], 0, $iLen); |
172 | - } |
|
173 | - else if(key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
171 | + } else if(key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
174 | 172 | { |
175 | 173 | $sContentType = substr($_SERVER['HTTP_CONTENT_TYPE'], 0, $iLen); |
176 | 174 | } |
@@ -184,8 +182,7 @@ discard block |
||
184 | 182 | if($data !== null && $sArg != $data) |
185 | 183 | { |
186 | 184 | $sArg = $data; |
187 | - } |
|
188 | - else |
|
185 | + } else |
|
189 | 186 | { |
190 | 187 | $sArg = $this->__convertValue($sArg); |
191 | 188 | } |
@@ -214,8 +211,7 @@ discard block |
||
214 | 211 | } |
215 | 212 | $this->__argumentDecodeUTF8_iconv($xArg); |
216 | 213 | } |
217 | - } |
|
218 | - elseif(is_string($mArg)) |
|
214 | + } elseif(is_string($mArg)) |
|
219 | 215 | { |
220 | 216 | $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg); |
221 | 217 | } |
@@ -244,8 +240,7 @@ discard block |
||
244 | 240 | } |
245 | 241 | $this->__argumentDecodeUTF8_mb_convert_encoding($xArg); |
246 | 242 | } |
247 | - } |
|
248 | - elseif(is_string($mArg)) |
|
243 | + } elseif(is_string($mArg)) |
|
249 | 244 | { |
250 | 245 | $mArg = mb_convert_encoding($mArg, $this->getOption('core.encoding'), "UTF-8"); |
251 | 246 | } |
@@ -276,8 +271,7 @@ discard block |
||
276 | 271 | |
277 | 272 | $this->__argumentDecodeUTF8_utf8_decode($xArg); |
278 | 273 | } |
279 | - } |
|
280 | - elseif(is_string($mArg)) |
|
274 | + } elseif(is_string($mArg)) |
|
281 | 275 | { |
282 | 276 | $mArg = utf8_decode($mArg); |
283 | 277 | } |
@@ -309,16 +303,13 @@ discard block |
||
309 | 303 | if(function_exists('iconv')) |
310 | 304 | { |
311 | 305 | $sFunction = "iconv"; |
312 | - } |
|
313 | - elseif(function_exists('mb_convert_encoding')) |
|
306 | + } elseif(function_exists('mb_convert_encoding')) |
|
314 | 307 | { |
315 | 308 | $sFunction = "mb_convert_encoding"; |
316 | - } |
|
317 | - elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
309 | + } elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
318 | 310 | { |
319 | 311 | $sFunction = "utf8_decode"; |
320 | - } |
|
321 | - else |
|
312 | + } else |
|
322 | 313 | { |
323 | 314 | throw new \Jaxon\Exception\Error($this->trans('errors.request.conversion')); |
324 | 315 | } |
@@ -23,7 +23,6 @@ |
||
23 | 23 | |
24 | 24 | use Jaxon\Jaxon; |
25 | 25 | use Jaxon\Plugin\Request as RequestPlugin; |
26 | -use Jaxon\Request\Manager as RequestManager; |
|
27 | 26 | |
28 | 27 | class UserFunction extends RequestPlugin |
29 | 28 | { |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | |
52 | 52 | $this->sRequestedFunction = null; |
53 | 53 | |
54 | - if(isset($_GET['jxnfun'])) |
|
54 | + if (isset($_GET['jxnfun'])) |
|
55 | 55 | { |
56 | 56 | $this->sRequestedFunction = $_GET['jxnfun']; |
57 | 57 | } |
58 | - if(isset($_POST['jxnfun'])) |
|
58 | + if (isset($_POST['jxnfun'])) |
|
59 | 59 | { |
60 | 60 | $this->sRequestedFunction = $_POST['jxnfun']; |
61 | 61 | } |
@@ -80,22 +80,22 @@ 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::USER_FUNCTION) |
|
87 | + if ($sType == Jaxon::USER_FUNCTION) |
|
88 | 88 | { |
89 | 89 | $xUserFunction = $aArgs[1]; |
90 | 90 | |
91 | - if(!($xUserFunction instanceof \Jaxon\Request\Support\UserFunction)) |
|
91 | + if (!($xUserFunction instanceof \Jaxon\Request\Support\UserFunction)) |
|
92 | 92 | $xUserFunction = new \Jaxon\Request\Support\UserFunction($xUserFunction); |
93 | 93 | |
94 | - if(count($aArgs) > 2) |
|
94 | + if (count($aArgs) > 2) |
|
95 | 95 | { |
96 | - if(is_array($aArgs[2])) |
|
96 | + if (is_array($aArgs[2])) |
|
97 | 97 | { |
98 | - foreach($aArgs[2] as $sName => $sValue) |
|
98 | + foreach ($aArgs[2] as $sName => $sValue) |
|
99 | 99 | { |
100 | 100 | $xUserFunction->configure($sName, $sValue); |
101 | 101 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | public function generateHash() |
123 | 123 | { |
124 | 124 | $sHash = ''; |
125 | - foreach($this->aFunctions as $xFunction) |
|
125 | + foreach ($this->aFunctions as $xFunction) |
|
126 | 126 | { |
127 | 127 | $sHash .= $xFunction->getName(); |
128 | 128 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public function getScript() |
138 | 138 | { |
139 | 139 | $code = ''; |
140 | - foreach($this->aFunctions as $xFunction) |
|
140 | + foreach ($this->aFunctions as $xFunction) |
|
141 | 141 | { |
142 | 142 | $code .= $xFunction->getScript(); |
143 | 143 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | public function canProcessRequest() |
153 | 153 | { |
154 | 154 | // Check the validity of the function name |
155 | - if(($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction)) |
|
155 | + if (($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction)) |
|
156 | 156 | { |
157 | 157 | $this->sRequestedFunction = null; |
158 | 158 | } |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function processRequest() |
168 | 168 | { |
169 | - if(!$this->canProcessRequest()) |
|
169 | + if (!$this->canProcessRequest()) |
|
170 | 170 | return false; |
171 | 171 | |
172 | 172 | $aArgs = $this->getRequestManager()->process(); |
173 | 173 | |
174 | - if(array_key_exists($this->sRequestedFunction, $this->aFunctions)) |
|
174 | + if (array_key_exists($this->sRequestedFunction, $this->aFunctions)) |
|
175 | 175 | { |
176 | 176 | $this->aFunctions[$this->sRequestedFunction]->call($aArgs); |
177 | 177 | return true; |
@@ -88,8 +88,9 @@ discard block |
||
88 | 88 | { |
89 | 89 | $xUserFunction = $aArgs[1]; |
90 | 90 | |
91 | - if(!($xUserFunction instanceof \Jaxon\Request\Support\UserFunction)) |
|
92 | - $xUserFunction = new \Jaxon\Request\Support\UserFunction($xUserFunction); |
|
91 | + if(!($xUserFunction instanceof \Jaxon\Request\Support\UserFunction)) { |
|
92 | + $xUserFunction = new \Jaxon\Request\Support\UserFunction($xUserFunction); |
|
93 | + } |
|
93 | 94 | |
94 | 95 | if(count($aArgs) > 2) |
95 | 96 | { |
@@ -99,8 +100,7 @@ discard block |
||
99 | 100 | { |
100 | 101 | $xUserFunction->configure($sName, $sValue); |
101 | 102 | } |
102 | - } |
|
103 | - else |
|
103 | + } else |
|
104 | 104 | { |
105 | 105 | $xUserFunction->configure('include', $aArgs[2]); |
106 | 106 | } |
@@ -166,8 +166,9 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function processRequest() |
168 | 168 | { |
169 | - if(!$this->canProcessRequest()) |
|
170 | - return false; |
|
169 | + if(!$this->canProcessRequest()) { |
|
170 | + return false; |
|
171 | + } |
|
171 | 172 | |
172 | 173 | $aArgs = $this->getRequestManager()->process(); |
173 | 174 |
@@ -20,7 +20,6 @@ |
||
20 | 20 | |
21 | 21 | namespace Jaxon\Request; |
22 | 22 | |
23 | -use JsonSerializable; |
|
24 | 23 | use Jaxon\Jaxon; |
25 | 24 | |
26 | 25 | class Request extends JsCall |
@@ -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 | $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}'; |
248 | 245 | if(($sPhrase)) |
@@ -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; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | public function elseShow($sMessage) |
246 | 246 | { |
247 | 247 | $this->aMessageArgs = func_get_args(); |
248 | - array_walk($this->aMessageArgs, function (&$xParameter) { |
|
248 | + array_walk($this->aMessageArgs, function(&$xParameter) { |
|
249 | 249 | $xParameter = Parameter::make($xParameter); |
250 | 250 | }); |
251 | 251 | return $this; |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | // This array will avoid declaring multiple variables with the same value. |
271 | 271 | // The array key is the variable value, while the array value is the variable name. |
272 | 272 | $aVariables = array(); // Array of local variables. |
273 | - foreach($this->aParameters as &$xParameter) |
|
273 | + foreach ($this->aParameters as &$xParameter) |
|
274 | 274 | { |
275 | 275 | $sParameterStr = $xParameter->getScript(); |
276 | - if($xParameter instanceof \Jaxon\JQuery\Dom\Element) |
|
276 | + if ($xParameter instanceof \Jaxon\JQuery\Dom\Element) |
|
277 | 277 | { |
278 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
278 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
279 | 279 | { |
280 | 280 | // The value is not yet defined. A new variable is created. |
281 | 281 | $sVarName = "jxnVar$nVarId"; |
@@ -293,19 +293,19 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | $sPhrase = ''; |
296 | - if(count($this->aMessageArgs) > 0) |
|
296 | + if (count($this->aMessageArgs) > 0) |
|
297 | 297 | { |
298 | 298 | $sPhrase = array_shift($this->aMessageArgs); // The first array entry is the question. |
299 | 299 | // $sPhrase = "'" . addslashes($sPhrase) . "'"; // Wrap the phrase with single quotes |
300 | - if(count($this->aMessageArgs) > 0) |
|
300 | + if (count($this->aMessageArgs) > 0) |
|
301 | 301 | { |
302 | 302 | $nParamId = 1; |
303 | - foreach($this->aMessageArgs as &$xParameter) |
|
303 | + foreach ($this->aMessageArgs as &$xParameter) |
|
304 | 304 | { |
305 | 305 | $sParameterStr = $xParameter->getScript(); |
306 | - if($xParameter instanceof \Jaxon\JQuery\Dom\Element) |
|
306 | + if ($xParameter instanceof \Jaxon\JQuery\Dom\Element) |
|
307 | 307 | { |
308 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
308 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
309 | 309 | { |
310 | 310 | // The value is not yet defined. A new variable is created. |
311 | 311 | $sVarName = "jxnVar$nVarId"; |
@@ -328,15 +328,15 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | $sScript = $this->getOption('core.prefix.' . $this->sType) . parent::getScript(); |
331 | - if($this->sCondition == '__confirm__') |
|
331 | + if ($this->sCondition == '__confirm__') |
|
332 | 332 | { |
333 | 333 | $xConfirm = $this->getPluginManager()->getConfirm(); |
334 | 334 | $sScript = $xConfirm->confirm($sPhrase, $sScript, ''); |
335 | 335 | } |
336 | - elseif($this->sCondition !== null) |
|
336 | + elseif ($this->sCondition !== null) |
|
337 | 337 | { |
338 | 338 | $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}'; |
339 | - if(($sPhrase)) |
|
339 | + if (($sPhrase)) |
|
340 | 340 | { |
341 | 341 | $xAlert = $this->getPluginManager()->getAlert(); |
342 | 342 | $xAlert->setReturn(true); |
@@ -158,7 +158,7 @@ |
||
158 | 158 | /** |
159 | 159 | * Constructs and returns a <Jaxon\Request\Request> object which is capable of generating the javascript call to invoke this jaxon enabled function |
160 | 160 | * |
161 | - * @return Jaxon\Request\Request |
|
161 | + * @return Request |
|
162 | 162 | */ |
163 | 163 | public function generateRequest() |
164 | 164 | { |
@@ -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 | } |
@@ -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 | require_once $this->sInclude; |
201 | 201 | } |
202 | 202 | $response = call_user_func_array($this->sUserFunction, $aArgs); |
203 | - if(($response)) |
|
203 | + if (($response)) |
|
204 | 204 | { |
205 | 205 | $this->getResponseManager()->append($response); |
206 | 206 | } |
@@ -89,7 +89,6 @@ discard block |
||
89 | 89 | * Return the javascript call to an Jaxon object method |
90 | 90 | * |
91 | 91 | * @param string $sMethod The method (without class) name |
92 | - * @param ... $xParams The parameters of the method |
|
93 | 92 | * |
94 | 93 | * @return object |
95 | 94 | */ |
@@ -110,7 +109,6 @@ discard block |
||
110 | 109 | * @param integer $nItemsPerPage the number of items per page |
111 | 110 | * @param integer $nCurrentPage the current page |
112 | 111 | * @param string $sMethod the name of the method |
113 | - * @param ... $parameters the parameters of the method |
|
114 | 112 | * |
115 | 113 | * @return string the pagination links |
116 | 114 | */ |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function getJaxonClassName() |
46 | 46 | { |
47 | - if(!$this->xJaxonCallable) |
|
47 | + if (!$this->xJaxonCallable) |
|
48 | 48 | { |
49 | 49 | // Make the Jaxon class name for a class without an associated callable |
50 | 50 | // !! Warning !! This can happen only if this object is not registered with the Jaxon libary |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function getJaxonNamespace() |
64 | 64 | { |
65 | - if(!$this->xJaxonCallable) |
|
65 | + if (!$this->xJaxonCallable) |
|
66 | 66 | { |
67 | 67 | // Return an empty string. |
68 | 68 | return ''; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function getJaxonClassPath() |
79 | 79 | { |
80 | - if(!$this->xJaxonCallable) |
|
80 | + if (!$this->xJaxonCallable) |
|
81 | 81 | { |
82 | 82 | // Return an empty string. |
83 | 83 | return ''; |
@@ -161,7 +161,7 @@ |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
164 | - * @return string |
|
164 | + * @return Request |
|
165 | 165 | */ |
166 | 166 | public function getRequest() |
167 | 167 | { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | protected function updateNumPages() |
67 | 67 | { |
68 | - $this->numPages = ($this->itemsPerPage == 0 ? 0 : (int) ceil($this->totalItems/$this->itemsPerPage)); |
|
68 | + $this->numPages = ($this->itemsPerPage == 0 ? 0 : (int)ceil($this->totalItems / $this->itemsPerPage)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function setMaxPagesToShow($maxPagesToShow) |
76 | 76 | { |
77 | - if($maxPagesToShow < 3) |
|
77 | + if ($maxPagesToShow < 3) |
|
78 | 78 | { |
79 | 79 | throw new \InvalidArgumentException('maxPagesToShow cannot be less than 3.'); |
80 | 80 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | { |
155 | 155 | $this->request = $request; |
156 | 156 | // Append the page number to the parameter list, if not yet given. |
157 | - if(($this->request) && !$this->request->hasPageNumber()) |
|
157 | + if (($this->request) && !$this->request->hasPageNumber()) |
|
158 | 158 | { |
159 | 159 | $this->request->addParameter(Jaxon::PAGE_NUMBER, 0); |
160 | 160 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | public function getNextPage() |
195 | 195 | { |
196 | - if($this->currentPage < $this->numPages) |
|
196 | + if ($this->currentPage < $this->numPages) |
|
197 | 197 | { |
198 | 198 | return $this->currentPage + 1; |
199 | 199 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | public function getPrevPage() |
205 | 205 | { |
206 | - if($this->currentPage > 1) |
|
206 | + if ($this->currentPage > 1) |
|
207 | 207 | { |
208 | 208 | return $this->currentPage - 1; |
209 | 209 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | public function getNextCall() |
215 | 215 | { |
216 | - if(!$this->getNextPage()) |
|
216 | + if (!$this->getNextPage()) |
|
217 | 217 | { |
218 | 218 | return null; |
219 | 219 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function getPrevCall() |
228 | 228 | { |
229 | - if(!$this->getPrevPage()) |
|
229 | + if (!$this->getPrevPage()) |
|
230 | 230 | { |
231 | 231 | return null; |
232 | 232 | } |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | { |
255 | 255 | $pages = array(); |
256 | 256 | |
257 | - if($this->numPages <= 1) |
|
257 | + if ($this->numPages <= 1) |
|
258 | 258 | { |
259 | 259 | return array(); |
260 | 260 | } |
261 | 261 | |
262 | - if($this->numPages <= $this->maxPagesToShow) |
|
262 | + if ($this->numPages <= $this->maxPagesToShow) |
|
263 | 263 | { |
264 | - for($i = 1; $i <= $this->numPages; $i++) |
|
264 | + for ($i = 1; $i <= $this->numPages; $i++) |
|
265 | 265 | { |
266 | 266 | $pages[] = $this->createPage($i, $i == $this->currentPage); |
267 | 267 | } |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | else |
270 | 270 | { |
271 | 271 | // Determine the sliding range, centered around the current page. |
272 | - $numAdjacents = (int) floor(($this->maxPagesToShow - 3) / 2); |
|
272 | + $numAdjacents = (int)floor(($this->maxPagesToShow - 3) / 2); |
|
273 | 273 | |
274 | - if($this->currentPage + $numAdjacents > $this->numPages) |
|
274 | + if ($this->currentPage + $numAdjacents > $this->numPages) |
|
275 | 275 | { |
276 | 276 | $slidingStart = $this->numPages - $this->maxPagesToShow + 2; |
277 | 277 | } |
@@ -279,28 +279,28 @@ discard block |
||
279 | 279 | { |
280 | 280 | $slidingStart = $this->currentPage - $numAdjacents; |
281 | 281 | } |
282 | - if($slidingStart < 2) |
|
282 | + if ($slidingStart < 2) |
|
283 | 283 | { |
284 | 284 | $slidingStart = 2; |
285 | 285 | } |
286 | 286 | |
287 | 287 | $slidingEnd = $slidingStart + $this->maxPagesToShow - 3; |
288 | - if($slidingEnd >= $this->numPages) |
|
288 | + if ($slidingEnd >= $this->numPages) |
|
289 | 289 | { |
290 | 290 | $slidingEnd = $this->numPages - 1; |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Build the list of pages. |
294 | 294 | $pages[] = $this->createPage(1, $this->currentPage == 1); |
295 | - if($slidingStart > 2) |
|
295 | + if ($slidingStart > 2) |
|
296 | 296 | { |
297 | 297 | $pages[] = $this->createPageEllipsis(); |
298 | 298 | } |
299 | - for($i = $slidingStart; $i <= $slidingEnd; $i++) |
|
299 | + for ($i = $slidingStart; $i <= $slidingEnd; $i++) |
|
300 | 300 | { |
301 | 301 | $pages[] = $this->createPage($i, $i == $this->currentPage); |
302 | 302 | } |
303 | - if($slidingEnd < $this->numPages - 1) |
|
303 | + if ($slidingEnd < $this->numPages - 1) |
|
304 | 304 | { |
305 | 305 | $pages[] = $this->createPageEllipsis(); |
306 | 306 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | */ |
347 | 347 | public function toHtml() |
348 | 348 | { |
349 | - if($this->getNumPages() <= 1) |
|
349 | + if ($this->getNumPages() <= 1) |
|
350 | 350 | { |
351 | 351 | return ''; |
352 | 352 | } |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | { |
370 | 370 | $first = ($this->currentPage - 1) * $this->itemsPerPage + 1; |
371 | 371 | |
372 | - if($first > $this->totalItems) |
|
372 | + if ($first > $this->totalItems) |
|
373 | 373 | { |
374 | 374 | return null; |
375 | 375 | } |
@@ -380,13 +380,13 @@ discard block |
||
380 | 380 | public function getCurrentPageLastItem() |
381 | 381 | { |
382 | 382 | $first = $this->getCurrentPageFirstItem(); |
383 | - if($first === null) |
|
383 | + if ($first === null) |
|
384 | 384 | { |
385 | 385 | return null; |
386 | 386 | } |
387 | 387 | |
388 | 388 | $last = $first + $this->itemsPerPage - 1; |
389 | - if($last > $this->totalItems) |
|
389 | + if ($last > $this->totalItems) |
|
390 | 390 | { |
391 | 391 | return $this->totalItems; |
392 | 392 | } |
@@ -265,8 +265,7 @@ discard block |
||
265 | 265 | { |
266 | 266 | $pages[] = $this->createPage($i, $i == $this->currentPage); |
267 | 267 | } |
268 | - } |
|
269 | - else |
|
268 | + } else |
|
270 | 269 | { |
271 | 270 | // Determine the sliding range, centered around the current page. |
272 | 271 | $numAdjacents = (int) floor(($this->maxPagesToShow - 3) / 2); |
@@ -274,8 +273,7 @@ discard block |
||
274 | 273 | if($this->currentPage + $numAdjacents > $this->numPages) |
275 | 274 | { |
276 | 275 | $slidingStart = $this->numPages - $this->maxPagesToShow + 2; |
277 | - } |
|
278 | - else |
|
276 | + } else |
|
279 | 277 | { |
280 | 278 | $slidingStart = $this->currentPage - $numAdjacents; |
281 | 279 | } |
@@ -168,9 +168,9 @@ |
||
168 | 168 | */ |
169 | 169 | public function addParameters(array $aParameters) |
170 | 170 | { |
171 | - foreach($aParameters as $xParameter) |
|
171 | + foreach ($aParameters as $xParameter) |
|
172 | 172 | { |
173 | - if($xParameter instanceof JsCall) |
|
173 | + if ($xParameter instanceof JsCall) |
|
174 | 174 | { |
175 | 175 | $this->addParameter(Jaxon::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}'); |
176 | 176 | } |
@@ -173,8 +173,7 @@ |
||
173 | 173 | if($xParameter instanceof JsCall) |
174 | 174 | { |
175 | 175 | $this->addParameter(Jaxon::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}'); |
176 | - } |
|
177 | - else |
|
176 | + } else |
|
178 | 177 | { |
179 | 178 | $this->pushParameter(Parameter::make($xParameter)); |
180 | 179 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | protected function alert($message, $title) |
28 | 28 | { |
29 | - if($this->getReturn()) |
|
29 | + if ($this->getReturn()) |
|
30 | 30 | { |
31 | 31 | return 'alert(' . $message . ')'; |
32 | 32 | } |