@@ -189,15 +189,6 @@ discard block |
||
| 189 | 189 | * - Jaxon::CALLABLE_OBJECT: an object who's methods are to be registered |
| 190 | 190 | * - Jaxon::BROWSER_EVENT: an event which will cause zero or more event handlers to be called |
| 191 | 191 | * - Jaxon::EVENT_HANDLER: register an event handler function. |
| 192 | - * @param mixed $sFunction | $objObject | $sEvent |
|
| 193 | - * When registering a function, this is the name of the function |
|
| 194 | - * When registering a callable object, this is the object being registered |
|
| 195 | - * When registering an event or event handler, this is the name of the event |
|
| 196 | - * @param mixed $sIncludeFile | $aCallOptions | $sEventHandler |
|
| 197 | - * When registering a function, this is the (optional) include file |
|
| 198 | - * When registering a callable object, this is an (optional) array |
|
| 199 | - * of call options for the functions being registered |
|
| 200 | - * When registering an event handler, this is the name of the function |
|
| 201 | 192 | * |
| 202 | 193 | * @return mixed |
| 203 | 194 | */ |
@@ -473,7 +464,7 @@ discard block |
||
| 473 | 464 | * @param string $sLibKey The key of the library options in the file |
| 474 | 465 | * @param string|null $sAppKey The key of the application options in the file |
| 475 | 466 | * |
| 476 | - * @return array |
|
| 467 | + * @return null|Utils\Config\Config |
|
| 477 | 468 | */ |
| 478 | 469 | public function readPhpConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 479 | 470 | { |
@@ -487,7 +478,7 @@ discard block |
||
| 487 | 478 | * @param string $sLibKey The key of the library options in the file |
| 488 | 479 | * @param string|null $sAppKey The key of the application options in the file |
| 489 | 480 | * |
| 490 | - * @return array |
|
| 481 | + * @return null|Utils\Config\Config |
|
| 491 | 482 | */ |
| 492 | 483 | public function readYamlConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 493 | 484 | { |
@@ -501,7 +492,7 @@ discard block |
||
| 501 | 492 | * @param string $sLibKey The key of the library options in the file |
| 502 | 493 | * @param string|null $sAppKey The key of the application options in the file |
| 503 | 494 | * |
| 504 | - * @return array |
|
| 495 | + * @return Utils\Config\Config|null |
|
| 505 | 496 | */ |
| 506 | 497 | public function readJsonConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 507 | 498 | { |
@@ -515,7 +506,7 @@ discard block |
||
| 515 | 506 | * @param string $sLibKey The key of the library options in the file |
| 516 | 507 | * @param string|null $sAppKey The key of the application options in the file |
| 517 | 508 | * |
| 518 | - * @return array |
|
| 509 | + * @return null|Utils\Config\Config |
|
| 519 | 510 | */ |
| 520 | 511 | public function readConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 521 | 512 | { |
@@ -547,7 +538,7 @@ discard block |
||
| 547 | 538 | * - 1000 thru 8999: User created plugins, typically, these plugins don't care about order |
| 548 | 539 | * - 9000 thru 9999: Plugins that generally need to be last or near the end of the plugin list |
| 549 | 540 | * |
| 550 | - * @param Plugin $xPlugin An instance of a plugin |
|
| 541 | + * @param Plugin\Plugin $xPlugin An instance of a plugin |
|
| 551 | 542 | * @param integer $nPriority The plugin priority, used to order the plugins |
| 552 | 543 | * |
| 553 | 544 | * @return void |
@@ -25,10 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | namespace Jaxon; |
| 27 | 27 | |
| 28 | -use Jaxon\Plugin\Manager as PluginManager; |
|
| 29 | -use Jaxon\Request\Manager as RequestManager; |
|
| 30 | -use Jaxon\Response\Manager as ResponseManager; |
|
| 31 | - |
|
| 32 | 28 | use Jaxon\Utils\URI; |
| 33 | 29 | use Exception; |
| 34 | 30 | |
@@ -212,8 +212,9 @@ discard block |
||
| 212 | 212 | { |
| 213 | 213 | $sEvent = $aArgs[1]; |
| 214 | 214 | $xUserFunction = $aArgs[2]; |
| 215 | - if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
| 216 | - $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
|
| 215 | + if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) { |
|
| 216 | + $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
|
| 217 | + } |
|
| 217 | 218 | $this->aProcessingEvents[$sEvent] = $xUserFunction; |
| 218 | 219 | return true; |
| 219 | 220 | } |
@@ -324,8 +325,7 @@ discard block |
||
| 324 | 325 | try |
| 325 | 326 | { |
| 326 | 327 | $mResult = $this->getPluginManager()->processRequest(); |
| 327 | - } |
|
| 328 | - catch(Exception $e) |
|
| 328 | + } catch(Exception $e) |
|
| 329 | 329 | { |
| 330 | 330 | // An exception was thrown while processing the request. |
| 331 | 331 | // The request missed the corresponding handler function, |
@@ -342,8 +342,7 @@ discard block |
||
| 342 | 342 | { |
| 343 | 343 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 344 | 344 | $aParams = array($e->getMessage()); |
| 345 | - } |
|
| 346 | - else |
|
| 345 | + } else |
|
| 347 | 346 | { |
| 348 | 347 | $sEvent = self::PROCESSING_EVENT_ERROR; |
| 349 | 348 | $aParams = array($e); |
@@ -353,8 +352,7 @@ discard block |
||
| 353 | 352 | { |
| 354 | 353 | // Call the processing event |
| 355 | 354 | $this->aProcessingEvents[$sEvent]->call($aParams); |
| 356 | - } |
|
| 357 | - else |
|
| 355 | + } else |
|
| 358 | 356 | { |
| 359 | 357 | // The exception is not to be processed here. |
| 360 | 358 | throw $e; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | 'core.prefix.event' => 'jaxon_event_', |
| 130 | 130 | // 'core.request.uri' => '', |
| 131 | 131 | 'core.request.mode' => 'asynchronous', |
| 132 | - 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 132 | + 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 133 | 133 | 'core.debug.on' => false, |
| 134 | 134 | 'core.debug.verbose' => false, |
| 135 | 135 | 'core.process.exit' => true, |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | $aArgs = func_get_args(); |
| 207 | 207 | $nArgs = func_num_args(); |
| 208 | 208 | |
| 209 | - if(self::PROCESSING_EVENT == $aArgs[0]) |
|
| 209 | + if (self::PROCESSING_EVENT == $aArgs[0]) |
|
| 210 | 210 | { |
| 211 | - if($nArgs > 2) |
|
| 211 | + if ($nArgs > 2) |
|
| 212 | 212 | { |
| 213 | 213 | $sEvent = $aArgs[1]; |
| 214 | 214 | $xUserFunction = $aArgs[2]; |
| 215 | - if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
| 215 | + if (!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
| 216 | 216 | $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
| 217 | 217 | $this->aProcessingEvents[$sEvent] = $xUserFunction; |
| 218 | 218 | return true; |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | public function processRequest() |
| 297 | 297 | { |
| 298 | 298 | // Check to see if headers have already been sent out, in which case we can't do our job |
| 299 | - if(headers_sent($filename, $linenumber)) |
|
| 299 | + if (headers_sent($filename, $linenumber)) |
|
| 300 | 300 | { |
| 301 | 301 | echo $this->trans('errors.output.already-sent', array( |
| 302 | 302 | 'location' => $filename . ':' . $linenumber |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | // Check if there is a plugin to process this request |
| 308 | - if(!$this->canProcessRequest()) |
|
| 308 | + if (!$this->canProcessRequest()) |
|
| 309 | 309 | { |
| 310 | 310 | return; |
| 311 | 311 | } |
@@ -314,18 +314,18 @@ discard block |
||
| 314 | 314 | $mResult = true; |
| 315 | 315 | |
| 316 | 316 | // Handle before processing event |
| 317 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 317 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 318 | 318 | { |
| 319 | 319 | $this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest)); |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - if(!$bEndRequest) |
|
| 322 | + if (!$bEndRequest) |
|
| 323 | 323 | { |
| 324 | 324 | try |
| 325 | 325 | { |
| 326 | 326 | $mResult = $this->getPluginManager()->processRequest(); |
| 327 | 327 | } |
| 328 | - catch(Exception $e) |
|
| 328 | + catch (Exception $e) |
|
| 329 | 329 | { |
| 330 | 330 | // An exception was thrown while processing the request. |
| 331 | 331 | // The request missed the corresponding handler function, |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $xResponseManager->debug($e->getMessage()); |
| 339 | 339 | $mResult = false; |
| 340 | 340 | |
| 341 | - if($e instanceof \Jaxon\Exception\Error) |
|
| 341 | + if ($e instanceof \Jaxon\Exception\Error) |
|
| 342 | 342 | { |
| 343 | 343 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 344 | 344 | $aParams = array($e->getMessage()); |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | $aParams = array($e); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - if(isset($this->aProcessingEvents[$sEvent])) |
|
| 352 | + if (isset($this->aProcessingEvents[$sEvent])) |
|
| 353 | 353 | { |
| 354 | 354 | // Call the processing event |
| 355 | 355 | $this->aProcessingEvents[$sEvent]->call($aParams); |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | // Clean the processing buffer |
| 365 | - if(($this->getOption('core.process.clean'))) |
|
| 365 | + if (($this->getOption('core.process.clean'))) |
|
| 366 | 366 | { |
| 367 | 367 | $er = error_reporting(0); |
| 368 | 368 | while (ob_get_level() > 0) |
@@ -372,10 +372,10 @@ discard block |
||
| 372 | 372 | error_reporting($er); |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - if($mResult === true) |
|
| 375 | + if ($mResult === true) |
|
| 376 | 376 | { |
| 377 | 377 | // Handle after processing event |
| 378 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 378 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 379 | 379 | { |
| 380 | 380 | $bEndRequest = false; |
| 381 | 381 | $this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]->call(array($bEndRequest)); |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | $this->getResponseManager()->printDebug(); |
| 386 | 386 | |
| 387 | - if(($this->getOption('core.process.exit'))) |
|
| 387 | + if (($this->getOption('core.process.exit'))) |
|
| 388 | 388 | { |
| 389 | 389 | $this->getResponseManager()->sendOutput(); |
| 390 | 390 | exit(); |
@@ -434,16 +434,16 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | public function getScript($bIncludeJs = false, $bIncludeCss = false) |
| 436 | 436 | { |
| 437 | - if(!$this->getOption('core.request.uri')) |
|
| 437 | + if (!$this->getOption('core.request.uri')) |
|
| 438 | 438 | { |
| 439 | 439 | $this->setOption('core.request.uri', URI::detect()); |
| 440 | 440 | } |
| 441 | 441 | $sCode = ''; |
| 442 | - if(($bIncludeCss)) |
|
| 442 | + if (($bIncludeCss)) |
|
| 443 | 443 | { |
| 444 | 444 | $sCode .= $this->getPluginManager()->getCss() . "\n"; |
| 445 | 445 | } |
| 446 | - if(($bIncludeJs)) |
|
| 446 | + if (($bIncludeJs)) |
|
| 447 | 447 | { |
| 448 | 448 | $sCode .= $this->getPluginManager()->getJs() . "\n"; |
| 449 | 449 | } |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | public function readConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 542 | 542 | { |
| 543 | 543 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
| 544 | - switch($sExt) |
|
| 544 | + switch ($sExt) |
|
| 545 | 545 | { |
| 546 | 546 | case 'php': |
| 547 | 547 | return $this->readPhpConfigFile($sConfigFile, $sLibKey, $sAppKey); |
@@ -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 | { |
@@ -262,32 +262,32 @@ discard block |
||
| 262 | 262 | { |
| 263 | 263 | $bIsAlert = ($xPlugin instanceof \Jaxon\Request\Interfaces\Alert); |
| 264 | 264 | $bIsConfirm = ($xPlugin instanceof \Jaxon\Request\Interfaces\Confirm); |
| 265 | - if($xPlugin instanceof Request) |
|
| 265 | + if ($xPlugin instanceof Request) |
|
| 266 | 266 | { |
| 267 | 267 | // The name of a request plugin is used as key in the plugin table |
| 268 | 268 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 269 | 269 | } |
| 270 | - elseif($xPlugin instanceof Response) |
|
| 270 | + elseif ($xPlugin instanceof Response) |
|
| 271 | 271 | { |
| 272 | 272 | // The name of a response plugin is used as key in the plugin table |
| 273 | 273 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 274 | 274 | } |
| 275 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 275 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
| 276 | 276 | { |
| 277 | 277 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 278 | 278 | } |
| 279 | 279 | // This plugin implements the Alert interface |
| 280 | - if($bIsAlert) |
|
| 280 | + if ($bIsAlert) |
|
| 281 | 281 | { |
| 282 | 282 | $this->setAlert($xPlugin); |
| 283 | 283 | } |
| 284 | 284 | // This plugin implements the Confirm interface |
| 285 | - if($bIsConfirm) |
|
| 285 | + if ($bIsConfirm) |
|
| 286 | 286 | { |
| 287 | 287 | $this->setConfirm($xPlugin); |
| 288 | 288 | } |
| 289 | 289 | // Register the plugin as an event listener |
| 290 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 290 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 291 | 291 | { |
| 292 | 292 | $this->addEventListener($xPlugin); |
| 293 | 293 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | private function generateHash() |
| 304 | 304 | { |
| 305 | 305 | $sHash = $this->getVersion(); |
| 306 | - foreach($this->aPlugins as $xPlugin) |
|
| 306 | + foreach ($this->aPlugins as $xPlugin) |
|
| 307 | 307 | { |
| 308 | 308 | $sHash .= $xPlugin->generateHash(); |
| 309 | 309 | } |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | public function canProcessRequest() |
| 322 | 322 | { |
| 323 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 323 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 324 | 324 | { |
| 325 | - if($xPlugin->canProcessRequest()) |
|
| 325 | + if ($xPlugin->canProcessRequest()) |
|
| 326 | 326 | { |
| 327 | 327 | return true; |
| 328 | 328 | } |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | public function processRequest() |
| 342 | 342 | { |
| 343 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 343 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 344 | 344 | { |
| 345 | - if($xPlugin->canProcessRequest()) |
|
| 345 | + if ($xPlugin->canProcessRequest()) |
|
| 346 | 346 | { |
| 347 | 347 | return $xPlugin->processRequest(); |
| 348 | 348 | } |
@@ -363,10 +363,10 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function register($aArgs) |
| 365 | 365 | { |
| 366 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 366 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 367 | 367 | { |
| 368 | 368 | $mResult = $xPlugin->register($aArgs); |
| 369 | - if($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
| 369 | + if ($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
| 370 | 370 | { |
| 371 | 371 | return $mResult; |
| 372 | 372 | } |
@@ -386,38 +386,38 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | public function addClassDir($sDirectory, $sNamespace = null, $sSeparator = '.', array $aProtected = array()) |
| 388 | 388 | { |
| 389 | - if(!is_dir(($sDirectory = trim($sDirectory)))) |
|
| 389 | + if (!is_dir(($sDirectory = trim($sDirectory)))) |
|
| 390 | 390 | { |
| 391 | 391 | return false; |
| 392 | 392 | } |
| 393 | 393 | // Only '.' and '_' are allowed to be used as separator. Any other value is ignored and '.' is used instead. |
| 394 | - if(($sSeparator = trim($sSeparator)) != '_') |
|
| 394 | + if (($sSeparator = trim($sSeparator)) != '_') |
|
| 395 | 395 | { |
| 396 | 396 | $sSeparator = '.'; |
| 397 | 397 | } |
| 398 | - if(!($sNamespace = trim($sNamespace))) |
|
| 398 | + if (!($sNamespace = trim($sNamespace))) |
|
| 399 | 399 | { |
| 400 | 400 | $sNamespace = null; |
| 401 | 401 | } |
| 402 | - if(($sNamespace)) |
|
| 402 | + if (($sNamespace)) |
|
| 403 | 403 | { |
| 404 | 404 | $sNamespace = trim($sNamespace, '\\'); |
| 405 | 405 | // If there is an autoloader, register the dir with PSR4 autoloading |
| 406 | - if(($this->xAutoloader)) |
|
| 406 | + if (($this->xAutoloader)) |
|
| 407 | 407 | { |
| 408 | 408 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | - elseif(($this->xAutoloader)) |
|
| 411 | + elseif (($this->xAutoloader)) |
|
| 412 | 412 | { |
| 413 | 413 | // If there is an autoloader, register the dir with classmap autoloading |
| 414 | 414 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 415 | 415 | $itFile = new RecursiveIteratorIterator($itDir); |
| 416 | 416 | // Iterate on dir content |
| 417 | - foreach($itFile as $xFile) |
|
| 417 | + foreach ($itFile as $xFile) |
|
| 418 | 418 | { |
| 419 | 419 | // skip everything except PHP files |
| 420 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 420 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 421 | 421 | { |
| 422 | 422 | continue; |
| 423 | 423 | } |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | $sClassPath = trim(substr($xFile->getPath(), strlen($sDirectory)), DIRECTORY_SEPARATOR); |
| 449 | 449 | $sClassPath = str_replace(array(DIRECTORY_SEPARATOR), array($sSeparator), $sClassPath); |
| 450 | 450 | $sClassName = $xFile->getBasename('.php'); |
| 451 | - if(($sNamespace)) |
|
| 451 | + if (($sNamespace)) |
|
| 452 | 452 | { |
| 453 | 453 | $sNamespace = trim($sNamespace, '\\'); |
| 454 | 454 | $sClassPath = str_replace(array('\\'), array($sSeparator), $sNamespace) . $sSeparator . $sClassPath; |
@@ -456,27 +456,27 @@ discard block |
||
| 456 | 456 | $sClassName = '\\' . str_replace(array($sSeparator), array('\\'), $sClassPath) . '\\' . $sClassName; |
| 457 | 457 | } |
| 458 | 458 | // Require the file only if autoload is enabled but there is no autoloader |
| 459 | - if(($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
| 459 | + if (($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
| 460 | 460 | { |
| 461 | 461 | require_once($xFile->getPathname()); |
| 462 | 462 | } |
| 463 | 463 | // Create and register an instance of the class |
| 464 | - if(!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
| 464 | + if (!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
| 465 | 465 | { |
| 466 | 466 | $aOptions['*'] = array(); |
| 467 | 467 | } |
| 468 | 468 | $aOptions['*']['separator'] = $sSeparator; |
| 469 | - if(($sNamespace)) |
|
| 469 | + if (($sNamespace)) |
|
| 470 | 470 | { |
| 471 | 471 | $aOptions['*']['namespace'] = $sNamespace; |
| 472 | 472 | } |
| 473 | - if(($sClassPath)) |
|
| 473 | + if (($sClassPath)) |
|
| 474 | 474 | { |
| 475 | 475 | $aOptions['*']['classpath'] = $sClassPath; |
| 476 | 476 | } |
| 477 | 477 | // Filter excluded methods |
| 478 | - $aProtected = array_filter($aProtected, function ($sName) {return is_string($sName);}); |
|
| 479 | - if(count($aProtected) > 0) |
|
| 478 | + $aProtected = array_filter($aProtected, function($sName) {return is_string($sName); }); |
|
| 479 | + if (count($aProtected) > 0) |
|
| 480 | 480 | { |
| 481 | 481 | $aOptions['*']['protected'] = $aProtected; |
| 482 | 482 | } |
@@ -490,15 +490,15 @@ discard block |
||
| 490 | 490 | */ |
| 491 | 491 | public function registerClasses() |
| 492 | 492 | { |
| 493 | - foreach($this->aClassDirs as $sClassDir) |
|
| 493 | + foreach ($this->aClassDirs as $sClassDir) |
|
| 494 | 494 | { |
| 495 | 495 | $itDir = new RecursiveDirectoryIterator($sClassDir['directory']); |
| 496 | 496 | $itFile = new RecursiveIteratorIterator($itDir); |
| 497 | 497 | // Iterate on dir content |
| 498 | - foreach($itFile as $xFile) |
|
| 498 | + foreach ($itFile as $xFile) |
|
| 499 | 499 | { |
| 500 | 500 | // skip everything except PHP files |
| 501 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 501 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 502 | 502 | { |
| 503 | 503 | continue; |
| 504 | 504 | } |
@@ -518,18 +518,18 @@ discard block |
||
| 518 | 518 | */ |
| 519 | 519 | public function registerClass($sClassName, array $aOptions = array()) |
| 520 | 520 | { |
| 521 | - if(!($sInitialClassName = trim($sClassName))) |
|
| 521 | + if (!($sInitialClassName = trim($sClassName))) |
|
| 522 | 522 | { |
| 523 | 523 | return false; |
| 524 | 524 | } |
| 525 | - foreach($this->aClassDirs as $aClassDir) |
|
| 525 | + foreach ($this->aClassDirs as $aClassDir) |
|
| 526 | 526 | { |
| 527 | 527 | // Get the separator |
| 528 | 528 | $sSeparator = $aClassDir['separator']; |
| 529 | 529 | // Replace / and \ with dots, and trim the string |
| 530 | 530 | $sClassName = trim(str_replace(array('\\', '/'), array($sSeparator, $sSeparator), $sInitialClassName), $sSeparator); |
| 531 | 531 | $sClassPath = ''; |
| 532 | - if(($nLastDotPosition = strrpos($sClassName, $sSeparator)) !== false) |
|
| 532 | + if (($nLastDotPosition = strrpos($sClassName, $sSeparator)) !== false) |
|
| 533 | 533 | { |
| 534 | 534 | $sClassPath = substr($sClassName, 0, $nLastDotPosition); |
| 535 | 535 | $sClassName = substr($sClassName, $nLastDotPosition + 1); |
@@ -541,17 +541,17 @@ discard block |
||
| 541 | 541 | $nLen = strlen($sNamespace); |
| 542 | 542 | $bRegister = false; |
| 543 | 543 | // Check if the class belongs to the namespace |
| 544 | - if(($sNamespace) && substr($sClassPath, 0, $nLen) == str_replace(array('\\'), array($sSeparator), $sNamespace)) |
|
| 544 | + if (($sNamespace) && substr($sClassPath, 0, $nLen) == str_replace(array('\\'), array($sSeparator), $sNamespace)) |
|
| 545 | 545 | { |
| 546 | 546 | $sClassFile = $aClassDir['directory'] . DIRECTORY_SEPARATOR . substr($sClassFile, $nLen); |
| 547 | 547 | $bRegister = true; |
| 548 | 548 | } |
| 549 | - elseif(!($sNamespace)) |
|
| 549 | + elseif (!($sNamespace)) |
|
| 550 | 550 | { |
| 551 | 551 | $sClassFile = $aClassDir['directory'] . DIRECTORY_SEPARATOR . $sClassFile; |
| 552 | 552 | $bRegister = true; |
| 553 | 553 | } |
| 554 | - if($bRegister && is_file($sClassFile)) |
|
| 554 | + if ($bRegister && is_file($sClassFile)) |
|
| 555 | 555 | { |
| 556 | 556 | // Found the file in this directory |
| 557 | 557 | $xFileInfo = new \SplFileInfo($sClassFile); |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | { |
| 576 | 576 | $xObject = null; // The user registered object |
| 577 | 577 | $xPlugin = $this->getRequestPlugin('CallableObject'); // The CallableObject plugin |
| 578 | - if(($xPlugin)) |
|
| 578 | + if (($xPlugin)) |
|
| 579 | 579 | { |
| 580 | 580 | $xObject = $xPlugin->getRegisteredObject($sClassName); |
| 581 | 581 | } |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | */ |
| 590 | 590 | private function getJsLibUri() |
| 591 | 591 | { |
| 592 | - if(!$this->hasOption('js.lib.uri')) |
|
| 592 | + if (!$this->hasOption('js.lib.uri')) |
|
| 593 | 593 | { |
| 594 | 594 | return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
| 595 | 595 | } |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | $jsDelivrUri = 'https://cdn.jsdelivr.net'; |
| 610 | 610 | $nLen = strlen($jsDelivrUri); |
| 611 | 611 | // The jsDelivr CDN only hosts minified files |
| 612 | - if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
|
| 612 | + if (($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
|
| 613 | 613 | { |
| 614 | 614 | return '.min.js'; |
| 615 | 615 | } |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | // Check config options |
| 627 | 627 | // - The js.app.extern option must be set to true |
| 628 | 628 | // - The js.app.uri and js.app.dir options must be set to non null values |
| 629 | - if(!$this->getOption('js.app.extern') || |
|
| 629 | + if (!$this->getOption('js.app.extern') || |
|
| 630 | 630 | !$this->getOption('js.app.uri') || |
| 631 | 631 | !$this->getOption('js.app.dir')) |
| 632 | 632 | { |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | // Check dir access |
| 636 | 636 | // - The js.app.dir must be writable |
| 637 | 637 | $sJsAppDir = $this->getOption('js.app.dir'); |
| 638 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 638 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 639 | 639 | { |
| 640 | 640 | return false; |
| 641 | 641 | } |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | */ |
| 650 | 650 | private function setTemplateCacheDir() |
| 651 | 651 | { |
| 652 | - if($this->hasOption('core.template.cache_dir')) |
|
| 652 | + if ($this->hasOption('core.template.cache_dir')) |
|
| 653 | 653 | { |
| 654 | 654 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
| 655 | 655 | } |
@@ -671,11 +671,11 @@ discard block |
||
| 671 | 671 | |
| 672 | 672 | // Add component files to the javascript file array; |
| 673 | 673 | $aJsFiles = array($sJsCoreUrl); |
| 674 | - if($this->getOption('core.debug.on')) |
|
| 674 | + if ($this->getOption('core.debug.on')) |
|
| 675 | 675 | { |
| 676 | 676 | $aJsFiles[] = $sJsDebugUrl; |
| 677 | 677 | $aJsFiles[] = $sJsLanguageUrl; |
| 678 | - if($this->getOption('core.debug.verbose')) |
|
| 678 | + if ($this->getOption('core.debug.verbose')) |
|
| 679 | 679 | { |
| 680 | 680 | $aJsFiles[] = $sJsVerboseUrl; |
| 681 | 681 | } |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 688 | 688 | 'aUrls' => $aJsFiles, |
| 689 | 689 | )); |
| 690 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 690 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 691 | 691 | { |
| 692 | 692 | $sCode .= rtrim($xPlugin->getJs(), " \n") . "\n"; |
| 693 | 693 | } |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | $this->setTemplateCacheDir(); |
| 706 | 706 | |
| 707 | 707 | $sCode = ''; |
| 708 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 708 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 709 | 709 | { |
| 710 | 710 | $sCode .= rtrim($xPlugin->getCss(), " \n") . "\n"; |
| 711 | 711 | } |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | )); |
| 794 | 794 | |
| 795 | 795 | $sPluginScript = ''; |
| 796 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 796 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 797 | 797 | { |
| 798 | 798 | $sPluginScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
| 799 | 799 | } |
@@ -825,11 +825,11 @@ discard block |
||
| 825 | 825 | |
| 826 | 826 | // Get the config and plugins scripts |
| 827 | 827 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
| 828 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 828 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 829 | 829 | { |
| 830 | 830 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
| 831 | 831 | } |
| 832 | - if($this->canExportJavascript()) |
|
| 832 | + if ($this->canExportJavascript()) |
|
| 833 | 833 | { |
| 834 | 834 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
| 835 | 835 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -838,13 +838,13 @@ discard block |
||
| 838 | 838 | $sHash = $this->generateHash(); |
| 839 | 839 | $sOutFile = $sHash . '.js'; |
| 840 | 840 | $sMinFile = $sHash . '.min.js'; |
| 841 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
| 841 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
| 842 | 842 | { |
| 843 | 843 | file_put_contents($sJsAppDir . $sOutFile, $sScript); |
| 844 | 844 | } |
| 845 | - if(($this->getOption('js.app.minify'))) |
|
| 845 | + if (($this->getOption('js.app.minify'))) |
|
| 846 | 846 | { |
| 847 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 847 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 848 | 848 | { |
| 849 | 849 | $sOutFile = $sMinFile; |
| 850 | 850 | } |
@@ -877,7 +877,7 @@ discard block |
||
| 877 | 877 | */ |
| 878 | 878 | public function getResponsePlugin($sName) |
| 879 | 879 | { |
| 880 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
| 880 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
| 881 | 881 | { |
| 882 | 882 | return $this->aResponsePlugins[$sName]; |
| 883 | 883 | } |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | */ |
| 894 | 894 | public function getRequestPlugin($sName) |
| 895 | 895 | { |
| 896 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
| 896 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
| 897 | 897 | { |
| 898 | 898 | return $this->aRequestPlugins[$sName]; |
| 899 | 899 | } |
@@ -266,13 +266,11 @@ discard block |
||
| 266 | 266 | { |
| 267 | 267 | // The name of a request plugin is used as key in the plugin table |
| 268 | 268 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 269 | - } |
|
| 270 | - elseif($xPlugin instanceof Response) |
|
| 269 | + } elseif($xPlugin instanceof Response) |
|
| 271 | 270 | { |
| 272 | 271 | // The name of a response plugin is used as key in the plugin table |
| 273 | 272 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 274 | - } |
|
| 275 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 273 | + } elseif(!$bIsConfirm && !$bIsAlert) |
|
| 276 | 274 | { |
| 277 | 275 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 278 | 276 | } |
@@ -407,8 +405,7 @@ discard block |
||
| 407 | 405 | { |
| 408 | 406 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
| 409 | 407 | } |
| 410 | - } |
|
| 411 | - elseif(($this->xAutoloader)) |
|
| 408 | + } elseif(($this->xAutoloader)) |
|
| 412 | 409 | { |
| 413 | 410 | // If there is an autoloader, register the dir with classmap autoloading |
| 414 | 411 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
@@ -545,8 +542,7 @@ discard block |
||
| 545 | 542 | { |
| 546 | 543 | $sClassFile = $aClassDir['directory'] . DIRECTORY_SEPARATOR . substr($sClassFile, $nLen); |
| 547 | 544 | $bRegister = true; |
| 548 | - } |
|
| 549 | - elseif(!($sNamespace)) |
|
| 545 | + } elseif(!($sNamespace)) |
|
| 550 | 546 | { |
| 551 | 547 | $sClassFile = $aClassDir['directory'] . DIRECTORY_SEPARATOR . $sClassFile; |
| 552 | 548 | $bRegister = true; |
@@ -855,8 +851,7 @@ discard block |
||
| 855 | 851 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 856 | 852 | 'sUrl' => $sJsAppURI . $sOutFile, |
| 857 | 853 | )); |
| 858 | - } |
|
| 859 | - else |
|
| 854 | + } else |
|
| 860 | 855 | { |
| 861 | 856 | // The plugins scripts are wrapped with javascript tags |
| 862 | 857 | $sScript = $this->render('jaxon::plugins/wrapper.js', array( |
@@ -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 |
@@ -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 else($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); |
@@ -242,9 +242,11 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return Request |
| 244 | 244 | */ |
| 245 | - public function else($sMessage) |
|
| 245 | + public function else { |
|
| 246 | + ($sMessage) |
|
| 246 | 247 | { |
| 247 | 248 | $this->aMessageArgs = func_get_args(); |
| 249 | + } |
|
| 248 | 250 | array_walk($this->aMessageArgs, function (&$xParameter) { |
| 249 | 251 | $xParameter = Parameter::make($xParameter); |
| 250 | 252 | }); |
@@ -282,8 +284,7 @@ discard block |
||
| 282 | 284 | $aVariables[$sParameterStr] = $sVarName; |
| 283 | 285 | $sVars .= "$sVarName=$xParameter;"; |
| 284 | 286 | $nVarId++; |
| 285 | - } |
|
| 286 | - else |
|
| 287 | + } else |
|
| 287 | 288 | { |
| 288 | 289 | // The value is already defined. The corresponding variable is assigned. |
| 289 | 290 | $sVarName = $aVariables[$sParameterStr]; |
@@ -312,8 +313,7 @@ discard block |
||
| 312 | 313 | $aVariables[$sParameterStr] = $sVarName; |
| 313 | 314 | $sVars .= "$sVarName=$xParameter;"; |
| 314 | 315 | $nVarId++; |
| 315 | - } |
|
| 316 | - else |
|
| 316 | + } else |
|
| 317 | 317 | { |
| 318 | 318 | // The value is already defined. The corresponding variable is assigned. |
| 319 | 319 | $sVarName = $aVariables[$sParameterStr]; |
@@ -332,8 +332,7 @@ discard block |
||
| 332 | 332 | { |
| 333 | 333 | $xConfirm = $this->getPluginManager()->getConfirm(); |
| 334 | 334 | $sScript = $xConfirm->confirm($sPhrase, $sScript, ''); |
| 335 | - } |
|
| 336 | - elseif($this->sCondition !== null) |
|
| 335 | + } elseif($this->sCondition !== null) |
|
| 337 | 336 | { |
| 338 | 337 | $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}'; |
| 339 | 338 | if(($sPhrase)) |
@@ -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 | { |
@@ -90,13 +90,13 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $this->aConfiguration = array(); |
| 92 | 92 | $this->sAlias = ''; |
| 93 | - if(is_array($sUserFunction)) |
|
| 93 | + if (is_array($sUserFunction)) |
|
| 94 | 94 | { |
| 95 | - if(count($sUserFunction) != 2 && count($sUserFunction) != 3) |
|
| 95 | + if (count($sUserFunction) != 2 && count($sUserFunction) != 3) |
|
| 96 | 96 | { |
| 97 | 97 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration')); |
| 98 | 98 | } |
| 99 | - if(count($sUserFunction) == 3) |
|
| 99 | + if (count($sUserFunction) == 3) |
|
| 100 | 100 | { |
| 101 | 101 | $this->sAlias = $sUserFunction[0]; |
| 102 | 102 | $this->sUserFunction = array_slice($sUserFunction, 1); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $this->sUserFunction = $sUserFunction; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | - elseif(is_string($sUserFunction)) |
|
| 109 | + elseif (is_string($sUserFunction)) |
|
| 110 | 110 | { |
| 111 | 111 | $this->sUserFunction = $sUserFunction; |
| 112 | 112 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | public function getName() |
| 125 | 125 | { |
| 126 | 126 | // Do not use sAlias here! |
| 127 | - if(is_array($this->sUserFunction)) |
|
| 127 | + if (is_array($this->sUserFunction)) |
|
| 128 | 128 | { |
| 129 | 129 | return $this->sUserFunction[1]; |
| 130 | 130 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function configure($sName, $sValue) |
| 143 | 143 | { |
| 144 | - switch($sName) |
|
| 144 | + switch ($sName) |
|
| 145 | 145 | { |
| 146 | 146 | case 'alias': |
| 147 | 147 | $this->sAlias = $sValue; |
@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | public function call($aArgs = array()) |
| 197 | 197 | { |
| 198 | - if(($this->sInclude)) |
|
| 198 | + if (($this->sInclude)) |
|
| 199 | 199 | { |
| 200 | 200 | ob_start(); |
| 201 | 201 | require_once $this->sInclude; |
| 202 | 202 | $sOutput = ob_get_clean(); |
| 203 | - if(($sOutput)) |
|
| 203 | + if (($sOutput)) |
|
| 204 | 204 | { |
| 205 | 205 | $sOutput = $this->trans('debug.function.include', array( |
| 206 | 206 | 'file' => $this->sInclude, |
@@ -100,17 +100,14 @@ |
||
| 100 | 100 | { |
| 101 | 101 | $this->sAlias = $sUserFunction[0]; |
| 102 | 102 | $this->sUserFunction = array_slice($sUserFunction, 1); |
| 103 | - } |
|
| 104 | - else |
|
| 103 | + } else |
|
| 105 | 104 | { |
| 106 | 105 | $this->sUserFunction = $sUserFunction; |
| 107 | 106 | } |
| 108 | - } |
|
| 109 | - elseif(is_string($sUserFunction)) |
|
| 107 | + } elseif(is_string($sUserFunction)) |
|
| 110 | 108 | { |
| 111 | 109 | $this->sUserFunction = $sUserFunction; |
| 112 | - } |
|
| 113 | - else |
|
| 110 | + } else |
|
| 114 | 111 | { |
| 115 | 112 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration')); |
| 116 | 113 | } |
@@ -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(); |
| 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 | } |