@@ -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( |
@@ -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->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
325 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
326 | 326 | { |
327 | 327 | return true; |
328 | 328 | } |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | public function processRequest() |
342 | 342 | { |
343 | 343 | $xUploadPlugin = $this->getRequestPlugin(Jaxon::FILE_UPLOAD); |
344 | - foreach($this->aRequestPlugins as $xPlugin) |
|
344 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
345 | 345 | { |
346 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
346 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
347 | 347 | { |
348 | 348 | // Process uploaded files |
349 | - if($xUploadPlugin != null) |
|
349 | + if ($xUploadPlugin != null) |
|
350 | 350 | { |
351 | 351 | $xUploadPlugin->processRequest(); |
352 | 352 | } |
@@ -370,10 +370,10 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function register($aArgs) |
372 | 372 | { |
373 | - foreach($this->aRequestPlugins as $xPlugin) |
|
373 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
374 | 374 | { |
375 | 375 | $mResult = $xPlugin->register($aArgs); |
376 | - if($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
376 | + if ($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
377 | 377 | { |
378 | 378 | return $mResult; |
379 | 379 | } |
@@ -393,37 +393,37 @@ discard block |
||
393 | 393 | */ |
394 | 394 | public function addClassDir($sDirectory, $sNamespace = '', $sSeparator = '.', array $aProtected = array()) |
395 | 395 | { |
396 | - if(!is_dir(($sDirectory = trim($sDirectory)))) |
|
396 | + if (!is_dir(($sDirectory = trim($sDirectory)))) |
|
397 | 397 | { |
398 | 398 | return false; |
399 | 399 | } |
400 | 400 | // Only '.' and '_' are allowed to be used as separator. Any other value is ignored and '.' is used instead. |
401 | - if(($sSeparator = trim($sSeparator)) != '_') |
|
401 | + if (($sSeparator = trim($sSeparator)) != '_') |
|
402 | 402 | { |
403 | 403 | $sSeparator = '.'; |
404 | 404 | } |
405 | - if(!($sNamespace = trim($sNamespace, ' \\'))) |
|
405 | + if (!($sNamespace = trim($sNamespace, ' \\'))) |
|
406 | 406 | { |
407 | 407 | $sNamespace = ''; |
408 | 408 | } |
409 | - if(($sNamespace)) |
|
409 | + if (($sNamespace)) |
|
410 | 410 | { |
411 | 411 | // If there is an autoloader, register the dir with PSR4 autoloading |
412 | - if(($this->xAutoloader)) |
|
412 | + if (($this->xAutoloader)) |
|
413 | 413 | { |
414 | 414 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
415 | 415 | } |
416 | 416 | } |
417 | - elseif(($this->xAutoloader)) |
|
417 | + elseif (($this->xAutoloader)) |
|
418 | 418 | { |
419 | 419 | // If there is an autoloader, register the dir with classmap autoloading |
420 | 420 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
421 | 421 | $itFile = new RecursiveIteratorIterator($itDir); |
422 | 422 | // Iterate on dir content |
423 | - foreach($itFile as $xFile) |
|
423 | + foreach ($itFile as $xFile) |
|
424 | 424 | { |
425 | 425 | // skip everything except PHP files |
426 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
426 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
427 | 427 | { |
428 | 428 | continue; |
429 | 429 | } |
@@ -459,33 +459,33 @@ discard block |
||
459 | 459 | $sClassPath = substr($xFile->getPath(), strlen($sDirectory)); |
460 | 460 | $sClassPath = str_replace($sDS, '\\', trim($sClassPath, $sDS)); |
461 | 461 | $sClassName = $xFile->getBasename('.php'); |
462 | - if(($sNamespace)) |
|
462 | + if (($sNamespace)) |
|
463 | 463 | { |
464 | 464 | $sClassPath = ($sClassPath) ? $sNamespace . '\\' . $sClassPath : $sNamespace; |
465 | 465 | $sClassName = '\\' . $sClassPath . '\\' . $sClassName; |
466 | 466 | } |
467 | 467 | // Require the file only if autoload is enabled but there is no autoloader |
468 | - if(($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
468 | + if (($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
469 | 469 | { |
470 | 470 | require_once($xFile->getPathname()); |
471 | 471 | } |
472 | 472 | // Create and register an instance of the class |
473 | - if(!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
473 | + if (!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
474 | 474 | { |
475 | 475 | $aOptions['*'] = array(); |
476 | 476 | } |
477 | 477 | $aOptions['*']['separator'] = $sSeparator; |
478 | - if(($sNamespace)) |
|
478 | + if (($sNamespace)) |
|
479 | 479 | { |
480 | 480 | $aOptions['*']['namespace'] = $sNamespace; |
481 | 481 | } |
482 | - if(($sClassPath)) |
|
482 | + if (($sClassPath)) |
|
483 | 483 | { |
484 | 484 | $aOptions['*']['classpath'] = $sClassPath; |
485 | 485 | } |
486 | 486 | // Filter excluded methods |
487 | - $aProtected = array_filter($aProtected, function ($sName) {return is_string($sName);}); |
|
488 | - if(count($aProtected) > 0) |
|
487 | + $aProtected = array_filter($aProtected, function($sName) {return is_string($sName); }); |
|
488 | + if (count($aProtected) > 0) |
|
489 | 489 | { |
490 | 490 | $aOptions['*']['protected'] = $aProtected; |
491 | 491 | } |
@@ -504,13 +504,13 @@ discard block |
||
504 | 504 | $sDS = DIRECTORY_SEPARATOR; |
505 | 505 | // Change the keys in $aOptions to have "\" as separator |
506 | 506 | $aNewOptions = array(); |
507 | - foreach($aOptions as $key => $aOption) |
|
507 | + foreach ($aOptions as $key => $aOption) |
|
508 | 508 | { |
509 | 509 | $key = trim(str_replace(['.', '_'], ['\\', '\\'], $key), ' \\'); |
510 | 510 | $aNewOptions[$key] = $aOption; |
511 | 511 | } |
512 | 512 | |
513 | - foreach($this->aClassDirs as $aClassDir) |
|
513 | + foreach ($this->aClassDirs as $aClassDir) |
|
514 | 514 | { |
515 | 515 | // Get the directory |
516 | 516 | $sDirectory = $aClassDir['directory']; |
@@ -520,10 +520,10 @@ discard block |
||
520 | 520 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
521 | 521 | $itFile = new RecursiveIteratorIterator($itDir); |
522 | 522 | // Iterate on dir content |
523 | - foreach($itFile as $xFile) |
|
523 | + foreach ($itFile as $xFile) |
|
524 | 524 | { |
525 | 525 | // skip everything except PHP files |
526 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
526 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
527 | 527 | { |
528 | 528 | continue; |
529 | 529 | } |
@@ -532,13 +532,13 @@ discard block |
||
532 | 532 | $sClassPath = substr($xFile->getPath(), strlen($sDirectory)); |
533 | 533 | $sClassPath = trim(str_replace($sDS, '\\', $sClassPath), '\\'); |
534 | 534 | $sClassName = $sClassPath . '\\' . $xFile->getBasename('.php'); |
535 | - if(($sNamespace)) |
|
535 | + if (($sNamespace)) |
|
536 | 536 | { |
537 | 537 | $sClassName = $sNamespace . '\\' . $sClassName; |
538 | 538 | } |
539 | 539 | // Get the class options |
540 | 540 | $aClassOptions = []; |
541 | - if(array_key_exists($sClassName, $aNewOptions)) |
|
541 | + if (array_key_exists($sClassName, $aNewOptions)) |
|
542 | 542 | { |
543 | 543 | $aClassOptions = $aNewOptions[$sClassName]; |
544 | 544 | } |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | */ |
560 | 560 | public function registerClass($sClassName, array $aOptions = array()) |
561 | 561 | { |
562 | - if(!($sClassName = trim($sClassName, ' \\._'))) |
|
562 | + if (!($sClassName = trim($sClassName, ' \\._'))) |
|
563 | 563 | { |
564 | 564 | return false; |
565 | 565 | } |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | // Replace "." and "_" with antislashes, and set the class path. |
569 | 569 | $sClassName = str_replace(['.', '_'], ['\\', '\\'], $sClassName); |
570 | 570 | $sClassPath = ''; |
571 | - if(($nLastSlashPosition = strrpos($sClassName, '\\')) !== false) |
|
571 | + if (($nLastSlashPosition = strrpos($sClassName, '\\')) !== false) |
|
572 | 572 | { |
573 | 573 | $sClassPath = substr($sClassName, 0, $nLastSlashPosition); |
574 | 574 | $sClassName = substr($sClassName, $nLastSlashPosition + 1); |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | $sPartPath = str_replace('\\', $sDS, $sClassPath) . $sDS . $sClassName . '.php'; |
578 | 578 | |
579 | 579 | // Search for the class file in all directories. |
580 | - foreach($this->aClassDirs as $aClassDir) |
|
580 | + foreach ($this->aClassDirs as $aClassDir) |
|
581 | 581 | { |
582 | 582 | // Get the separator |
583 | 583 | $sSeparator = $aClassDir['separator']; |
@@ -586,15 +586,15 @@ discard block |
||
586 | 586 | $nLen = strlen($sNamespace); |
587 | 587 | $sFullPath = ''; |
588 | 588 | // Check if the class belongs to the namespace |
589 | - if(($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
|
589 | + if (($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
|
590 | 590 | { |
591 | 591 | $sFullPath = $aClassDir['directory'] . $sDS . substr($sPartPath, $nLen + 1); |
592 | 592 | } |
593 | - elseif(!($sNamespace)) |
|
593 | + elseif (!($sNamespace)) |
|
594 | 594 | { |
595 | 595 | $sFullPath = $aClassDir['directory'] . $sDS . $sPartPath; |
596 | 596 | } |
597 | - if(($sFullPath) && is_file($sFullPath)) |
|
597 | + if (($sFullPath) && is_file($sFullPath)) |
|
598 | 598 | { |
599 | 599 | // Found the file in this directory |
600 | 600 | $xFileInfo = new \SplFileInfo($sFullPath); |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | { |
619 | 619 | $xObject = null; // The user registered object |
620 | 620 | $xPlugin = $this->getRequestPlugin('CallableObject'); // The CallableObject plugin |
621 | - if(($xPlugin)) |
|
621 | + if (($xPlugin)) |
|
622 | 622 | { |
623 | 623 | $xObject = $xPlugin->getRegisteredObject($sClassName); |
624 | 624 | } |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | */ |
633 | 633 | private function getJsLibUri() |
634 | 634 | { |
635 | - if(!$this->hasOption('js.lib.uri')) |
|
635 | + if (!$this->hasOption('js.lib.uri')) |
|
636 | 636 | { |
637 | 637 | // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
638 | 638 | return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/'; |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | // The jsDelivr CDN only hosts minified files |
656 | 656 | // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
657 | 657 | // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files. |
658 | - if(($this->getOption('js.app.minify'))) |
|
658 | + if (($this->getOption('js.app.minify'))) |
|
659 | 659 | { |
660 | 660 | return '.min.js'; |
661 | 661 | } |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | // Check config options |
673 | 673 | // - The js.app.extern option must be set to true |
674 | 674 | // - The js.app.uri and js.app.dir options must be set to non null values |
675 | - if(!$this->getOption('js.app.extern') || |
|
675 | + if (!$this->getOption('js.app.extern') || |
|
676 | 676 | !$this->getOption('js.app.uri') || |
677 | 677 | !$this->getOption('js.app.dir')) |
678 | 678 | { |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | // Check dir access |
682 | 682 | // - The js.app.dir must be writable |
683 | 683 | $sJsAppDir = $this->getOption('js.app.dir'); |
684 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
684 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
685 | 685 | { |
686 | 686 | return false; |
687 | 687 | } |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | */ |
696 | 696 | private function setTemplateCacheDir() |
697 | 697 | { |
698 | - if($this->hasOption('core.template.cache_dir')) |
|
698 | + if ($this->hasOption('core.template.cache_dir')) |
|
699 | 699 | { |
700 | 700 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
701 | 701 | } |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | |
718 | 718 | // Add component files to the javascript file array; |
719 | 719 | $aJsFiles = array($sJsCoreUrl); |
720 | - if($this->getOption('core.debug.on')) |
|
720 | + if ($this->getOption('core.debug.on')) |
|
721 | 721 | { |
722 | 722 | $aJsFiles[] = $sJsDebugUrl; |
723 | 723 | $aJsFiles[] = $sJsLanguageUrl; |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | 'sJsOptions' => $this->getOption('js.app.options'), |
734 | 734 | 'aUrls' => $aJsFiles, |
735 | 735 | )); |
736 | - foreach($this->aResponsePlugins as $xPlugin) |
|
736 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
737 | 737 | { |
738 | 738 | $sCode .= rtrim($xPlugin->getJs(), " \n") . "\n"; |
739 | 739 | } |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | $this->setTemplateCacheDir(); |
752 | 752 | |
753 | 753 | $sCode = ''; |
754 | - foreach($this->aResponsePlugins as $xPlugin) |
|
754 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
755 | 755 | { |
756 | 756 | $sCode .= rtrim($xPlugin->getCss(), " \n") . "\n"; |
757 | 757 | } |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | ));*/ |
840 | 840 | |
841 | 841 | $sPluginScript = ''; |
842 | - foreach($this->aResponsePlugins as $xPlugin) |
|
842 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
843 | 843 | { |
844 | 844 | $sPluginScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
845 | 845 | } |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | { |
870 | 870 | // Get the config and plugins scripts |
871 | 871 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
872 | - foreach($this->aRequestPlugins as $xPlugin) |
|
872 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
873 | 873 | { |
874 | 874 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
875 | 875 | } |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | // Set the template engine cache dir |
892 | 892 | $this->setTemplateCacheDir(); |
893 | 893 | |
894 | - if($this->canExportJavascript()) |
|
894 | + if ($this->canExportJavascript()) |
|
895 | 895 | { |
896 | 896 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
897 | 897 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -900,13 +900,13 @@ discard block |
||
900 | 900 | $sHash = $this->generateHash(); |
901 | 901 | $sOutFile = $sHash . '.js'; |
902 | 902 | $sMinFile = $sHash . '.min.js'; |
903 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
903 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
904 | 904 | { |
905 | 905 | file_put_contents($sJsAppDir . $sOutFile, $this->getAllScripts()); |
906 | 906 | } |
907 | - if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
907 | + if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
908 | 908 | { |
909 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
909 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
910 | 910 | { |
911 | 911 | $sOutFile = $sMinFile; |
912 | 912 | } |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | */ |
940 | 940 | public function getResponsePlugin($sName) |
941 | 941 | { |
942 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
942 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
943 | 943 | { |
944 | 944 | return $this->aResponsePlugins[$sName]; |
945 | 945 | } |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | */ |
956 | 956 | public function getRequestPlugin($sName) |
957 | 957 | { |
958 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
958 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
959 | 959 | { |
960 | 960 | return $this->aRequestPlugins[$sName]; |
961 | 961 | } |
@@ -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,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 | } |
@@ -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,7 +195,7 @@ 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 | } |
@@ -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 ''; |
@@ -201,7 +201,7 @@ |
||
201 | 201 | /** |
202 | 202 | * Create a new the config manager |
203 | 203 | * |
204 | - * @return Jaxon\Utils\Config\Config The config manager |
|
204 | + * @return Config\Config The config manager |
|
205 | 205 | */ |
206 | 206 | public function newConfig() |
207 | 207 | { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public static function getInstance() |
29 | 29 | { |
30 | - if(!self::$xInstance) |
|
30 | + if (!self::$xInstance) |
|
31 | 31 | { |
32 | 32 | self::$xInstance = new Container(); |
33 | 33 | } |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | * Managers |
66 | 66 | */ |
67 | 67 | // Plugin Manager |
68 | - $this->di['plugin_manager'] = function ($c) { |
|
68 | + $this->di['plugin_manager'] = function($c) { |
|
69 | 69 | return new \Jaxon\Plugin\Manager(); |
70 | 70 | }; |
71 | 71 | // Request Manager |
72 | - $this->di['request_manager'] = function ($c) { |
|
72 | + $this->di['request_manager'] = function($c) { |
|
73 | 73 | return new \Jaxon\Request\Manager(); |
74 | 74 | }; |
75 | 75 | // Request Factory |
76 | - $this->di['request_factory'] = function ($c) { |
|
76 | + $this->di['request_factory'] = function($c) { |
|
77 | 77 | return new \Jaxon\Request\Factory(); |
78 | 78 | }; |
79 | 79 | // Response Manager |
80 | - $this->di['response_manager'] = function ($c) { |
|
80 | + $this->di['response_manager'] = function($c) { |
|
81 | 81 | return new \Jaxon\Response\Manager(); |
82 | 82 | }; |
83 | 83 | |
@@ -85,35 +85,35 @@ discard block |
||
85 | 85 | * Services |
86 | 86 | */ |
87 | 87 | // Config manager |
88 | - $this->di['config'] = function ($c) { |
|
88 | + $this->di['config'] = function($c) { |
|
89 | 89 | return new Config\Config(); |
90 | 90 | }; |
91 | 91 | // Minifier |
92 | - $this->di['minifier'] = function ($c) { |
|
92 | + $this->di['minifier'] = function($c) { |
|
93 | 93 | return new Template\Minifier(); |
94 | 94 | }; |
95 | 95 | // Translator |
96 | - $this->di['translator'] = function ($c) { |
|
96 | + $this->di['translator'] = function($c) { |
|
97 | 97 | return new Translation\Translator($c['translation_dir'], $c['config']); |
98 | 98 | }; |
99 | 99 | // Template engine |
100 | - $this->di['template'] = function ($c) { |
|
100 | + $this->di['template'] = function($c) { |
|
101 | 101 | return new Template\Template($c['template_dir']); |
102 | 102 | }; |
103 | 103 | // Validator |
104 | - $this->di['validator'] = function ($c) { |
|
104 | + $this->di['validator'] = function($c) { |
|
105 | 105 | return new Validation\Validator($c['translator'], $c['config']); |
106 | 106 | }; |
107 | 107 | // Pagination Renderer |
108 | - $this->di['pagination.renderer'] = function ($c) { |
|
108 | + $this->di['pagination.renderer'] = function($c) { |
|
109 | 109 | return new Pagination\Renderer(); |
110 | 110 | }; |
111 | 111 | // Pagination Paginator |
112 | - $this->di['pagination.paginator'] = function ($c) { |
|
112 | + $this->di['pagination.paginator'] = function($c) { |
|
113 | 113 | return new Pagination\Paginator($c['pagination.renderer']); |
114 | 114 | }; |
115 | 115 | // Event Dispatcher |
116 | - $this->di['events'] = function ($c) { |
|
116 | + $this->di['events'] = function($c) { |
|
117 | 117 | return new EventDispatcher(); |
118 | 118 | }; |
119 | 119 | |
@@ -121,27 +121,27 @@ discard block |
||
121 | 121 | * Core library objects |
122 | 122 | */ |
123 | 123 | // Global Response |
124 | - $this->di['response'] = function ($c) { |
|
124 | + $this->di['response'] = function($c) { |
|
125 | 125 | return new \Jaxon\Response\Response(); |
126 | 126 | }; |
127 | 127 | // Jaxon Core |
128 | - $this->di['jaxon'] = function ($c) { |
|
128 | + $this->di['jaxon'] = function($c) { |
|
129 | 129 | return new \Jaxon\Jaxon(); |
130 | 130 | }; |
131 | 131 | // Jaxon Sentry |
132 | - $this->di['sentry'] = function ($c) { |
|
132 | + $this->di['sentry'] = function($c) { |
|
133 | 133 | // This class is not defined in this package |
134 | 134 | $sClass = '\\Jaxon\\Sentry\\Sentry'; |
135 | 135 | return new $sClass; |
136 | 136 | }; |
137 | 137 | // Armada |
138 | - $this->di['armada'] = function ($c) { |
|
138 | + $this->di['armada'] = function($c) { |
|
139 | 139 | // This class is not defined in this package |
140 | 140 | $sClass = '\\Jaxon\\Armada\\Armada'; |
141 | 141 | return new $sClass; |
142 | 142 | }; |
143 | 143 | // View Renderer Facade |
144 | - $this->di['sentry.view.renderer'] = function ($c) { |
|
144 | + $this->di['sentry.view.renderer'] = function($c) { |
|
145 | 145 | $aRenderers = $c['view.data.renderers']; |
146 | 146 | $sDefaultNamespace = $c['view.data.namespace.default']; |
147 | 147 | return new \Jaxon\Sentry\View\Facade($aRenderers, $sDefaultNamespace); |
@@ -391,14 +391,14 @@ discard block |
||
391 | 391 | $this->di['sentry.view.base.' . $sId] = $xClosure; |
392 | 392 | |
393 | 393 | // Return the initialized view renderer |
394 | - $this->di['sentry.view.' . $sId] = function ($c) use ($sId) { |
|
394 | + $this->di['sentry.view.' . $sId] = function($c) use ($sId) { |
|
395 | 395 | // Get the defined renderer |
396 | 396 | $renderer = $c['sentry.view.base.' . $sId]; |
397 | 397 | // Init the renderer with the template namespaces |
398 | 398 | $aNamespaces = $this->di['view.data.namespaces']; |
399 | - if(key_exists($sId, $aNamespaces)) |
|
399 | + if (key_exists($sId, $aNamespaces)) |
|
400 | 400 | { |
401 | - foreach($aNamespaces[$sId] as $ns) |
|
401 | + foreach ($aNamespaces[$sId] as $ns) |
|
402 | 402 | { |
403 | 403 | $renderer->addNamespace($ns['namespace'], $ns['directory'], $ns['extension']); |
404 | 404 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | */ |
417 | 417 | public function getViewRenderer($sId = '') |
418 | 418 | { |
419 | - if(!$sId) |
|
419 | + if (!$sId) |
|
420 | 420 | { |
421 | 421 | // Return the view renderer facade |
422 | 422 | return $this->di['sentry.view.renderer']; |
@@ -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 | } |