@@ -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,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,15 +121,15 @@ 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 | // View Renderer Facade |
| 132 | - $this->di['sentry.view.renderer'] = function ($c) { |
|
| 132 | + $this->di['sentry.view.renderer'] = function($c) { |
|
| 133 | 133 | $aRenderers = $c['view.data.renderers']; |
| 134 | 134 | $sDefaultNamespace = $c['view.data.namespace.default']; |
| 135 | 135 | 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 | } |