@@ -378,7 +378,7 @@ |
||
| 378 | 378 | /** |
| 379 | 379 | * Check uploaded files validity and move them to the user dir |
| 380 | 380 | * |
| 381 | - * @return boolean |
|
| 381 | + * @return string |
|
| 382 | 382 | */ |
| 383 | 383 | public function saveUploadedFiles() |
| 384 | 384 | { |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | * @param string $sUserFunction The name of the function being registered |
| 79 | 79 | * @param array|string $aOptions The associated options |
| 80 | 80 | * |
| 81 | - * @return \Jaxon\Request\Request |
|
| 81 | + * @return boolean |
|
| 82 | 82 | */ |
| 83 | 83 | public function register($sType, $sUserFunction, $aOptions) |
| 84 | 84 | { |
@@ -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 | } |
@@ -82,30 +82,30 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function register($sType, $sUserFunction, $aOptions) |
| 84 | 84 | { |
| 85 | - if($sType != $this->getName()) |
|
| 85 | + if ($sType != $this->getName()) |
|
| 86 | 86 | { |
| 87 | 87 | return false; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if(!is_string($sUserFunction)) |
|
| 90 | + if (!is_string($sUserFunction)) |
|
| 91 | 91 | { |
| 92 | 92 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration')); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if(is_string($aOptions)) |
|
| 95 | + if (is_string($aOptions)) |
|
| 96 | 96 | { |
| 97 | 97 | $aOptions = ['include' => $aOptions]; |
| 98 | 98 | } |
| 99 | - if(!is_array($aOptions)) |
|
| 99 | + if (!is_array($aOptions)) |
|
| 100 | 100 | { |
| 101 | 101 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration')); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // Check if an alias is defined |
| 105 | 105 | $sFunctionName = $sUserFunction; |
| 106 | - foreach($aOptions as $sName => $sValue) |
|
| 106 | + foreach ($aOptions as $sName => $sValue) |
|
| 107 | 107 | { |
| 108 | - if($sName == 'alias') |
|
| 108 | + if ($sName == 'alias') |
|
| 109 | 109 | { |
| 110 | 110 | $sFunctionName = $sValue; |
| 111 | 111 | break; |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $this->aFunctions[$sFunctionName] = $sUserFunction; |
| 116 | - jaxon()->di()->set($sFunctionName, function () use ($sUserFunction, $aOptions) { |
|
| 116 | + jaxon()->di()->set($sFunctionName, function() use ($sUserFunction, $aOptions) { |
|
| 117 | 117 | $xUserFunction = new \Jaxon\Request\Support\UserFunction($sUserFunction); |
| 118 | 118 | |
| 119 | - foreach($aOptions as $sName => $sValue) |
|
| 119 | + foreach ($aOptions as $sName => $sValue) |
|
| 120 | 120 | { |
| 121 | 121 | $xUserFunction->configure($sName, $sValue); |
| 122 | 122 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $di = jaxon()->di(); |
| 148 | 148 | $code = ''; |
| 149 | - foreach($this->aFunctions as $sName) |
|
| 149 | + foreach ($this->aFunctions as $sName) |
|
| 150 | 150 | { |
| 151 | 151 | $xFunction = $di->get($sName); |
| 152 | 152 | $code .= $xFunction->getScript(); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | public function canProcessRequest() |
| 163 | 163 | { |
| 164 | 164 | // Check the validity of the function name |
| 165 | - if(($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction)) |
|
| 165 | + if (($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction)) |
|
| 166 | 166 | { |
| 167 | 167 | $this->sRequestedFunction = null; |
| 168 | 168 | } |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function processRequest() |
| 178 | 178 | { |
| 179 | - if(!$this->canProcessRequest()) |
|
| 179 | + if (!$this->canProcessRequest()) |
|
| 180 | 180 | { |
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if(!key_exists($this->sRequestedFunction, $this->aFunctions)) |
|
| 184 | + if (!key_exists($this->sRequestedFunction, $this->aFunctions)) |
|
| 185 | 185 | { |
| 186 | 186 | // Unable to find the requested function |
| 187 | 187 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid', |
@@ -219,32 +219,32 @@ discard block |
||
| 219 | 219 | { |
| 220 | 220 | $bIsAlert = ($xPlugin instanceof Dialogs\Interfaces\Alert); |
| 221 | 221 | $bIsConfirm = ($xPlugin instanceof Dialogs\Interfaces\Confirm); |
| 222 | - if($xPlugin instanceof Request) |
|
| 222 | + if ($xPlugin instanceof Request) |
|
| 223 | 223 | { |
| 224 | 224 | // The name of a request plugin is used as key in the plugin table |
| 225 | 225 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 226 | 226 | } |
| 227 | - elseif($xPlugin instanceof Response) |
|
| 227 | + elseif ($xPlugin instanceof Response) |
|
| 228 | 228 | { |
| 229 | 229 | // The name of a response plugin is used as key in the plugin table |
| 230 | 230 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 231 | 231 | } |
| 232 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 232 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
| 233 | 233 | { |
| 234 | 234 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 235 | 235 | } |
| 236 | 236 | // This plugin implements the Alert interface |
| 237 | - if($bIsAlert) |
|
| 237 | + if ($bIsAlert) |
|
| 238 | 238 | { |
| 239 | 239 | $this->setAlert($xPlugin); |
| 240 | 240 | } |
| 241 | 241 | // This plugin implements the Confirm interface |
| 242 | - if($bIsConfirm) |
|
| 242 | + if ($bIsConfirm) |
|
| 243 | 243 | { |
| 244 | 244 | $this->setConfirm($xPlugin); |
| 245 | 245 | } |
| 246 | 246 | // Register the plugin as an event listener |
| 247 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 247 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 248 | 248 | { |
| 249 | 249 | $this->addEventListener($xPlugin); |
| 250 | 250 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | private function generateHash() |
| 275 | 275 | { |
| 276 | 276 | $sHash = $this->getVersion(); |
| 277 | - foreach($this->aPlugins as $xPlugin) |
|
| 277 | + foreach ($this->aPlugins as $xPlugin) |
|
| 278 | 278 | { |
| 279 | 279 | $sHash .= $xPlugin->generateHash(); |
| 280 | 280 | } |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | public function canProcessRequest() |
| 293 | 293 | { |
| 294 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 294 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 295 | 295 | { |
| 296 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 296 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 297 | 297 | { |
| 298 | 298 | return true; |
| 299 | 299 | } |
@@ -312,12 +312,12 @@ discard block |
||
| 312 | 312 | public function processRequest() |
| 313 | 313 | { |
| 314 | 314 | $xUploadPlugin = $this->getRequestPlugin(Jaxon::FILE_UPLOAD); |
| 315 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 315 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 316 | 316 | { |
| 317 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 317 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 318 | 318 | { |
| 319 | 319 | // Process uploaded files |
| 320 | - if($xUploadPlugin != null) |
|
| 320 | + if ($xUploadPlugin != null) |
|
| 321 | 321 | { |
| 322 | 322 | $xUploadPlugin->processRequest(); |
| 323 | 323 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function register($sType, $sCallable, $aOptions) |
| 344 | 344 | { |
| 345 | - if(!key_exists($sType, $this->aRequestPlugins)) |
|
| 345 | + if (!key_exists($sType, $this->aRequestPlugins)) |
|
| 346 | 346 | { |
| 347 | 347 | throw new \Jaxon\Exception\Error($this->trans('errors.register.plugin', ['name' => $sType])); |
| 348 | 348 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | */ |
| 367 | 367 | private function getJsLibUri() |
| 368 | 368 | { |
| 369 | - if(!$this->hasOption('js.lib.uri')) |
|
| 369 | + if (!$this->hasOption('js.lib.uri')) |
|
| 370 | 370 | { |
| 371 | 371 | // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
| 372 | 372 | return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/'; |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | // The jsDelivr CDN only hosts minified files |
| 390 | 390 | // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
| 391 | 391 | // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files. |
| 392 | - if(($this->getOption('js.app.minify'))) |
|
| 392 | + if (($this->getOption('js.app.minify'))) |
|
| 393 | 393 | { |
| 394 | 394 | return '.min.js'; |
| 395 | 395 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | // Check config options |
| 407 | 407 | // - The js.app.extern option must be set to true |
| 408 | 408 | // - The js.app.uri and js.app.dir options must be set to non null values |
| 409 | - if(!$this->getOption('js.app.extern') || |
|
| 409 | + if (!$this->getOption('js.app.extern') || |
|
| 410 | 410 | !$this->getOption('js.app.uri') || |
| 411 | 411 | !$this->getOption('js.app.dir')) |
| 412 | 412 | { |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | // Check dir access |
| 416 | 416 | // - The js.app.dir must be writable |
| 417 | 417 | $sJsAppDir = $this->getOption('js.app.dir'); |
| 418 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 418 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 419 | 419 | { |
| 420 | 420 | return false; |
| 421 | 421 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | private function setTemplateCacheDir() |
| 431 | 431 | { |
| 432 | - if($this->hasOption('core.template.cache_dir')) |
|
| 432 | + if ($this->hasOption('core.template.cache_dir')) |
|
| 433 | 433 | { |
| 434 | 434 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
| 435 | 435 | } |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | // Add component files to the javascript file array; |
| 453 | 453 | $aJsFiles = array($sJsCoreUrl); |
| 454 | - if($this->getOption('core.debug.on')) |
|
| 454 | + if ($this->getOption('core.debug.on')) |
|
| 455 | 455 | { |
| 456 | 456 | $aJsFiles[] = $sJsDebugUrl; |
| 457 | 457 | $aJsFiles[] = $sJsLanguageUrl; |
@@ -467,17 +467,17 @@ discard block |
||
| 467 | 467 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 468 | 468 | 'aUrls' => $aJsFiles, |
| 469 | 469 | )); |
| 470 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 470 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 471 | 471 | { |
| 472 | - if(($str = trim($xPlugin->getJs()))) |
|
| 472 | + if (($str = trim($xPlugin->getJs()))) |
|
| 473 | 473 | { |
| 474 | 474 | $sCode .= rtrim($str, " \n") . "\n"; |
| 475 | 475 | } |
| 476 | 476 | } |
| 477 | - foreach($this->aPackages as $sClass) |
|
| 477 | + foreach ($this->aPackages as $sClass) |
|
| 478 | 478 | { |
| 479 | 479 | $xPackage = jaxon()->di()->get($sClass); |
| 480 | - if(($str = trim($xPackage->js()))) |
|
| 480 | + if (($str = trim($xPackage->js()))) |
|
| 481 | 481 | { |
| 482 | 482 | $sCode .= rtrim($str, " \n") . "\n"; |
| 483 | 483 | } |
@@ -496,17 +496,17 @@ discard block |
||
| 496 | 496 | $this->setTemplateCacheDir(); |
| 497 | 497 | |
| 498 | 498 | $sCode = ''; |
| 499 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 499 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 500 | 500 | { |
| 501 | - if(($str = trim($xPlugin->getCss()))) |
|
| 501 | + if (($str = trim($xPlugin->getCss()))) |
|
| 502 | 502 | { |
| 503 | 503 | $sCode .= rtrim($str, " \n") . "\n"; |
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | - foreach($this->aPackages as $sClass) |
|
| 506 | + foreach ($this->aPackages as $sClass) |
|
| 507 | 507 | { |
| 508 | 508 | $xPackage = jaxon()->di()->get($sClass); |
| 509 | - if(($str = trim($xPackage->css()))) |
|
| 509 | + if (($str = trim($xPackage->css()))) |
|
| 510 | 510 | { |
| 511 | 511 | $sCode .= rtrim($str, " \n") . "\n"; |
| 512 | 512 | } |
@@ -570,17 +570,17 @@ discard block |
||
| 570 | 570 | private function getReadyScript() |
| 571 | 571 | { |
| 572 | 572 | $sPluginScript = ''; |
| 573 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 573 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 574 | 574 | { |
| 575 | - if(($str = trim($xPlugin->getScript()))) |
|
| 575 | + if (($str = trim($xPlugin->getScript()))) |
|
| 576 | 576 | { |
| 577 | 577 | $sPluginScript .= "\n" . trim($str, " \n"); |
| 578 | 578 | } |
| 579 | 579 | } |
| 580 | - foreach($this->aPackages as $sClass) |
|
| 580 | + foreach ($this->aPackages as $sClass) |
|
| 581 | 581 | { |
| 582 | 582 | $xPackage = jaxon()->di()->get($sClass); |
| 583 | - if(($str = trim($xPackage->ready()))) |
|
| 583 | + if (($str = trim($xPackage->ready()))) |
|
| 584 | 584 | { |
| 585 | 585 | $sPluginScript .= "\n" . trim($str, " \n"); |
| 586 | 586 | } |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | { |
| 604 | 604 | // Get the config and plugins scripts |
| 605 | 605 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
| 606 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 606 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 607 | 607 | { |
| 608 | 608 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
| 609 | 609 | } |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | // Set the template engine cache dir |
| 626 | 626 | $this->setTemplateCacheDir(); |
| 627 | 627 | |
| 628 | - if($this->canExportJavascript()) |
|
| 628 | + if ($this->canExportJavascript()) |
|
| 629 | 629 | { |
| 630 | 630 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
| 631 | 631 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -634,13 +634,13 @@ discard block |
||
| 634 | 634 | $sHash = $this->generateHash(); |
| 635 | 635 | $sOutFile = $sHash . '.js'; |
| 636 | 636 | $sMinFile = $sHash . '.min.js'; |
| 637 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
| 637 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
| 638 | 638 | { |
| 639 | 639 | file_put_contents($sJsAppDir . $sOutFile, $this->getAllScripts()); |
| 640 | 640 | } |
| 641 | - if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
| 641 | + if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
| 642 | 642 | { |
| 643 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 643 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 644 | 644 | { |
| 645 | 645 | $sOutFile = $sMinFile; |
| 646 | 646 | } |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | */ |
| 674 | 674 | public function getResponsePlugin($sName) |
| 675 | 675 | { |
| 676 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
| 676 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
| 677 | 677 | { |
| 678 | 678 | return $this->aResponsePlugins[$sName]; |
| 679 | 679 | } |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | */ |
| 690 | 690 | public function getRequestPlugin($sName) |
| 691 | 691 | { |
| 692 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
| 692 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
| 693 | 693 | { |
| 694 | 694 | return $this->aRequestPlugins[$sName]; |
| 695 | 695 | } |
@@ -91,19 +91,19 @@ discard block |
||
| 91 | 91 | $this->sRequestedClass = null; |
| 92 | 92 | $this->sRequestedMethod = null; |
| 93 | 93 | |
| 94 | - if(!empty($_GET['jxncls'])) |
|
| 94 | + if (!empty($_GET['jxncls'])) |
|
| 95 | 95 | { |
| 96 | 96 | $this->sRequestedClass = $_GET['jxncls']; |
| 97 | 97 | } |
| 98 | - if(!empty($_GET['jxnmthd'])) |
|
| 98 | + if (!empty($_GET['jxnmthd'])) |
|
| 99 | 99 | { |
| 100 | 100 | $this->sRequestedMethod = $_GET['jxnmthd']; |
| 101 | 101 | } |
| 102 | - if(!empty($_POST['jxncls'])) |
|
| 102 | + if (!empty($_POST['jxncls'])) |
|
| 103 | 103 | { |
| 104 | 104 | $this->sRequestedClass = $_POST['jxncls']; |
| 105 | 105 | } |
| 106 | - if(!empty($_POST['jxnmthd'])) |
|
| 106 | + if (!empty($_POST['jxnmthd'])) |
|
| 107 | 107 | { |
| 108 | 108 | $this->sRequestedMethod = $_POST['jxnmthd']; |
| 109 | 109 | } |
@@ -154,43 +154,43 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function register($sType, $sClassName, $aOptions) |
| 156 | 156 | { |
| 157 | - if($sType != $this->getName()) |
|
| 157 | + if ($sType != $this->getName()) |
|
| 158 | 158 | { |
| 159 | 159 | return false; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if(!is_string($sClassName) || !class_exists($sClassName)) |
|
| 162 | + if (!is_string($sClassName) || !class_exists($sClassName)) |
|
| 163 | 163 | { |
| 164 | 164 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 165 | 165 | } |
| 166 | 166 | $sClassName = trim($sClassName, '\\'); |
| 167 | 167 | $this->aCallableObjects[] = $sClassName; |
| 168 | 168 | |
| 169 | - if(is_string($aOptions)) |
|
| 169 | + if (is_string($aOptions)) |
|
| 170 | 170 | { |
| 171 | 171 | $aOptions = ['namespace' => $aOptions]; |
| 172 | 172 | } |
| 173 | - if(!is_array($aOptions)) |
|
| 173 | + if (!is_array($aOptions)) |
|
| 174 | 174 | { |
| 175 | 175 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // Save the classpath and the separator in this class |
| 179 | - if(key_exists('*', $aOptions) && is_array($aOptions['*'])) |
|
| 179 | + if (key_exists('*', $aOptions) && is_array($aOptions['*'])) |
|
| 180 | 180 | { |
| 181 | 181 | $_aOptions = $aOptions['*']; |
| 182 | 182 | $sSeparator = '.'; |
| 183 | - if(key_exists('separator', $_aOptions)) |
|
| 183 | + if (key_exists('separator', $_aOptions)) |
|
| 184 | 184 | { |
| 185 | 185 | $sSeparator = trim($_aOptions['separator']); |
| 186 | 186 | } |
| 187 | - if(!in_array($sSeparator, ['.', '_'])) |
|
| 187 | + if (!in_array($sSeparator, ['.', '_'])) |
|
| 188 | 188 | { |
| 189 | 189 | $sSeparator = '.'; |
| 190 | 190 | } |
| 191 | 191 | $_aOptions['separator'] = $sSeparator; |
| 192 | 192 | |
| 193 | - if(array_key_exists('classpath', $_aOptions)) |
|
| 193 | + if (array_key_exists('classpath', $_aOptions)) |
|
| 194 | 194 | { |
| 195 | 195 | $_aOptions['classpath'] = trim($_aOptions['classpath'], ' \\._'); |
| 196 | 196 | // Save classpath with "\" in the parameters |
@@ -201,12 +201,12 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // Register the callable object |
| 204 | - jaxon()->di()->set($sClassName, function () use ($sClassName, $aOptions) { |
|
| 204 | + jaxon()->di()->set($sClassName, function() use ($sClassName, $aOptions) { |
|
| 205 | 205 | $xCallableObject = new \Jaxon\Request\Support\CallableObject($sClassName); |
| 206 | 206 | |
| 207 | - foreach($aOptions as $sMethod => $aValue) |
|
| 207 | + foreach ($aOptions as $sMethod => $aValue) |
|
| 208 | 208 | { |
| 209 | - foreach($aValue as $sName => $sValue) |
|
| 209 | + foreach ($aValue as $sName => $sValue) |
|
| 210 | 210 | { |
| 211 | 211 | $xCallableObject->configure($sMethod, $sName, $sValue); |
| 212 | 212 | } |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | }); |
| 217 | 217 | |
| 218 | 218 | // Register the request factory for this callable object |
| 219 | - jaxon()->di()->set($sClassName . '\Factory\Rq', function ($di) use ($sClassName) { |
|
| 219 | + jaxon()->di()->set($sClassName . '\Factory\Rq', function($di) use ($sClassName) { |
|
| 220 | 220 | $xCallableObject = $di->get($sClassName); |
| 221 | 221 | return new \Jaxon\Factory\Request\Portable($xCallableObject); |
| 222 | 222 | }); |
| 223 | 223 | |
| 224 | 224 | // Register the paginator factory for this callable object |
| 225 | - jaxon()->di()->set($sClassName . '\Factory\Pg', function ($di) use ($sClassName) { |
|
| 225 | + jaxon()->di()->set($sClassName . '\Factory\Pg', function($di) use ($sClassName) { |
|
| 226 | 226 | $xCallableObject = $di->get($sClassName); |
| 227 | 227 | return new \Jaxon\Factory\Request\Paginator($xCallableObject); |
| 228 | 228 | }); |
@@ -242,37 +242,37 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | public function addClassDir($sDirectory, $sNamespace = '', $sSeparator = '.', array $aProtected = []) |
| 244 | 244 | { |
| 245 | - if(!is_dir(($sDirectory = trim($sDirectory)))) |
|
| 245 | + if (!is_dir(($sDirectory = trim($sDirectory)))) |
|
| 246 | 246 | { |
| 247 | 247 | return false; |
| 248 | 248 | } |
| 249 | 249 | // Only '.' and '_' are allowed to be used as separator. Any other value is ignored and '.' is used instead. |
| 250 | - if(($sSeparator = trim($sSeparator)) != '_') |
|
| 250 | + if (($sSeparator = trim($sSeparator)) != '_') |
|
| 251 | 251 | { |
| 252 | 252 | $sSeparator = '.'; |
| 253 | 253 | } |
| 254 | - if(!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 254 | + if (!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 255 | 255 | { |
| 256 | 256 | $sNamespace = ''; |
| 257 | 257 | } |
| 258 | - if(($sNamespace)) |
|
| 258 | + if (($sNamespace)) |
|
| 259 | 259 | { |
| 260 | 260 | // If there is an autoloader, register the dir with PSR4 autoloading |
| 261 | - if(($this->xAutoloader)) |
|
| 261 | + if (($this->xAutoloader)) |
|
| 262 | 262 | { |
| 263 | 263 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | - elseif(($this->xAutoloader)) |
|
| 266 | + elseif (($this->xAutoloader)) |
|
| 267 | 267 | { |
| 268 | 268 | // If there is an autoloader, register the dir with classmap autoloading |
| 269 | 269 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 270 | 270 | $itFile = new RecursiveIteratorIterator($itDir); |
| 271 | 271 | // Iterate on dir content |
| 272 | - foreach($itFile as $xFile) |
|
| 272 | + foreach ($itFile as $xFile) |
|
| 273 | 273 | { |
| 274 | 274 | // skip everything except PHP files |
| 275 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 275 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 276 | 276 | { |
| 277 | 277 | continue; |
| 278 | 278 | } |
@@ -308,33 +308,33 @@ discard block |
||
| 308 | 308 | $sClassPath = substr($xFile->getPath(), strlen($sDirectory)); |
| 309 | 309 | $sClassPath = str_replace($sDS, '\\', trim($sClassPath, $sDS)); |
| 310 | 310 | $sClassName = $xFile->getBasename('.php'); |
| 311 | - if(($sNamespace)) |
|
| 311 | + if (($sNamespace)) |
|
| 312 | 312 | { |
| 313 | 313 | $sClassPath = ($sClassPath) ? $sNamespace . '\\' . $sClassPath : $sNamespace; |
| 314 | 314 | $sClassName = '\\' . $sClassPath . '\\' . $sClassName; |
| 315 | 315 | } |
| 316 | 316 | // Require the file only if autoload is enabled but there is no autoloader |
| 317 | - if(($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
| 317 | + if (($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
| 318 | 318 | { |
| 319 | 319 | require_once($xFile->getPathname()); |
| 320 | 320 | } |
| 321 | 321 | // Create and register an instance of the class |
| 322 | - if(!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
| 322 | + if (!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
| 323 | 323 | { |
| 324 | 324 | $aOptions['*'] = []; |
| 325 | 325 | } |
| 326 | 326 | $aOptions['*']['separator'] = $sSeparator; |
| 327 | - if(($sNamespace)) |
|
| 327 | + if (($sNamespace)) |
|
| 328 | 328 | { |
| 329 | 329 | $aOptions['*']['namespace'] = $sNamespace; |
| 330 | 330 | } |
| 331 | - if(($sClassPath)) |
|
| 331 | + if (($sClassPath)) |
|
| 332 | 332 | { |
| 333 | 333 | $aOptions['*']['classpath'] = $sClassPath; |
| 334 | 334 | } |
| 335 | 335 | // Filter excluded methods |
| 336 | - $aProtected = array_filter($aProtected, function ($sName) {return is_string($sName);}); |
|
| 337 | - if(count($aProtected) > 0) |
|
| 336 | + $aProtected = array_filter($aProtected, function($sName) {return is_string($sName); }); |
|
| 337 | + if (count($aProtected) > 0) |
|
| 338 | 338 | { |
| 339 | 339 | $aOptions['*']['protected'] = $aProtected; |
| 340 | 340 | } |
@@ -353,13 +353,13 @@ discard block |
||
| 353 | 353 | $sDS = DIRECTORY_SEPARATOR; |
| 354 | 354 | // Change the keys in $aOptions to have "\" as separator |
| 355 | 355 | $aNewOptions = []; |
| 356 | - foreach($aOptions as $key => $aOption) |
|
| 356 | + foreach ($aOptions as $key => $aOption) |
|
| 357 | 357 | { |
| 358 | 358 | $key = trim(str_replace(['.', '_'], ['\\', '\\'], $key), ' \\'); |
| 359 | 359 | $aNewOptions[$key] = $aOption; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - foreach($this->aClassDirs as $aClassDir) |
|
| 362 | + foreach ($this->aClassDirs as $aClassDir) |
|
| 363 | 363 | { |
| 364 | 364 | // Get the directory |
| 365 | 365 | $sDirectory = $aClassDir['directory']; |
@@ -369,10 +369,10 @@ discard block |
||
| 369 | 369 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 370 | 370 | $itFile = new RecursiveIteratorIterator($itDir); |
| 371 | 371 | // Iterate on dir content |
| 372 | - foreach($itFile as $xFile) |
|
| 372 | + foreach ($itFile as $xFile) |
|
| 373 | 373 | { |
| 374 | 374 | // skip everything except PHP files |
| 375 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 375 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 376 | 376 | { |
| 377 | 377 | continue; |
| 378 | 378 | } |
@@ -381,17 +381,17 @@ discard block |
||
| 381 | 381 | $sClassPath = substr($xFile->getPath(), strlen($sDirectory)); |
| 382 | 382 | $sClassPath = trim(str_replace($sDS, '\\', $sClassPath), '\\'); |
| 383 | 383 | $sClassName = $xFile->getBasename('.php'); |
| 384 | - if(($sClassPath)) |
|
| 384 | + if (($sClassPath)) |
|
| 385 | 385 | { |
| 386 | 386 | $sClassName = $sClassPath . '\\' . $sClassName; |
| 387 | 387 | } |
| 388 | - if(($sNamespace)) |
|
| 388 | + if (($sNamespace)) |
|
| 389 | 389 | { |
| 390 | 390 | $sClassName = $sNamespace . '\\' . $sClassName; |
| 391 | 391 | } |
| 392 | 392 | // Get the class options |
| 393 | 393 | $aClassOptions = []; |
| 394 | - if(array_key_exists($sClassName, $aNewOptions)) |
|
| 394 | + if (array_key_exists($sClassName, $aNewOptions)) |
|
| 395 | 395 | { |
| 396 | 396 | $aClassOptions = $aNewOptions[$sClassName]; |
| 397 | 397 | } |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | */ |
| 413 | 413 | public function registerClass($sClassName, array $aOptions = []) |
| 414 | 414 | { |
| 415 | - if(!($sClassName = trim($sClassName, ' \\._'))) |
|
| 415 | + if (!($sClassName = trim($sClassName, ' \\._'))) |
|
| 416 | 416 | { |
| 417 | 417 | return false; |
| 418 | 418 | } |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | // Replace "." and "_" with antislashes, and set the class path. |
| 422 | 422 | $sClassName = str_replace(['.', '_'], ['\\', '\\'], $sClassName); |
| 423 | 423 | $sClassPath = ''; |
| 424 | - if(($nLastSlashPosition = strrpos($sClassName, '\\')) !== false) |
|
| 424 | + if (($nLastSlashPosition = strrpos($sClassName, '\\')) !== false) |
|
| 425 | 425 | { |
| 426 | 426 | $sClassPath = substr($sClassName, 0, $nLastSlashPosition); |
| 427 | 427 | $sClassName = substr($sClassName, $nLastSlashPosition + 1); |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | $sPartPath = str_replace('\\', $sDS, $sClassPath) . $sDS . $sClassName . '.php'; |
| 431 | 431 | |
| 432 | 432 | // Search for the class file in all directories. |
| 433 | - foreach($this->aClassDirs as $aClassDir) |
|
| 433 | + foreach ($this->aClassDirs as $aClassDir) |
|
| 434 | 434 | { |
| 435 | 435 | // Get the separator |
| 436 | 436 | $sSeparator = $aClassDir['separator']; |
@@ -439,15 +439,15 @@ discard block |
||
| 439 | 439 | $nLen = strlen($sNamespace); |
| 440 | 440 | $sFullPath = ''; |
| 441 | 441 | // Check if the class belongs to the namespace |
| 442 | - if(($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
|
| 442 | + if (($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
|
| 443 | 443 | { |
| 444 | 444 | $sFullPath = $aClassDir['directory'] . $sDS . substr($sPartPath, $nLen + 1); |
| 445 | 445 | } |
| 446 | - elseif(!($sNamespace)) |
|
| 446 | + elseif (!($sNamespace)) |
|
| 447 | 447 | { |
| 448 | 448 | $sFullPath = $aClassDir['directory'] . $sDS . $sPartPath; |
| 449 | 449 | } |
| 450 | - if(($sFullPath) && is_file($sFullPath)) |
|
| 450 | + if (($sFullPath) && is_file($sFullPath)) |
|
| 451 | 451 | { |
| 452 | 452 | // Found the file in this directory |
| 453 | 453 | $xFileInfo = new \SplFileInfo($sFullPath); |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | { |
| 470 | 470 | $di = jaxon()->di(); |
| 471 | 471 | $sHash = ''; |
| 472 | - foreach($this->aCallableObjects as $sName) |
|
| 472 | + foreach ($this->aCallableObjects as $sName) |
|
| 473 | 473 | { |
| 474 | 474 | $xCallableObject = $di->get($sName); |
| 475 | 475 | $sHash .= $sName . implode('|', $xCallableObject->getMethods()); |
@@ -488,15 +488,15 @@ discard block |
||
| 488 | 488 | // Generate code for javascript objects declaration |
| 489 | 489 | $code = ''; |
| 490 | 490 | $classes = []; |
| 491 | - foreach($this->aClassPaths as $sClassPath) |
|
| 491 | + foreach ($this->aClassPaths as $sClassPath) |
|
| 492 | 492 | { |
| 493 | 493 | $offset = 0; |
| 494 | 494 | $sClassPath .= '.Null'; // This is a sentinel. The last token is not processed in the while loop. |
| 495 | - while(($dotPosition = strpos($sClassPath, '.', $offset)) !== false) |
|
| 495 | + while (($dotPosition = strpos($sClassPath, '.', $offset)) !== false) |
|
| 496 | 496 | { |
| 497 | 497 | $class = substr($sClassPath, 0, $dotPosition); |
| 498 | 498 | // Generate code for this object |
| 499 | - if(!array_key_exists($class, $classes)) |
|
| 499 | + if (!array_key_exists($class, $classes)) |
|
| 500 | 500 | { |
| 501 | 501 | $code .= "$sJaxonPrefix$class = {};\n"; |
| 502 | 502 | $classes[$class] = $class; |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | } |
| 507 | 507 | // Generate code for javascript methods |
| 508 | 508 | $di = jaxon()->di(); |
| 509 | - foreach($this->aCallableObjects as $sName) |
|
| 509 | + foreach ($this->aCallableObjects as $sName) |
|
| 510 | 510 | { |
| 511 | 511 | $xCallableObject = $di->get($sName); |
| 512 | 512 | $code .= $xCallableObject->getScript(); |
@@ -522,13 +522,13 @@ discard block |
||
| 522 | 522 | public function canProcessRequest() |
| 523 | 523 | { |
| 524 | 524 | // Check the validity of the class name |
| 525 | - if(($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass)) |
|
| 525 | + if (($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass)) |
|
| 526 | 526 | { |
| 527 | 527 | $this->sRequestedClass = null; |
| 528 | 528 | $this->sRequestedMethod = null; |
| 529 | 529 | } |
| 530 | 530 | // Check the validity of the method name |
| 531 | - if(($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod)) |
|
| 531 | + if (($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod)) |
|
| 532 | 532 | { |
| 533 | 533 | $this->sRequestedClass = null; |
| 534 | 534 | $this->sRequestedMethod = null; |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | public function processRequest() |
| 545 | 545 | { |
| 546 | - if(!$this->canProcessRequest()) |
|
| 546 | + if (!$this->canProcessRequest()) |
|
| 547 | 547 | { |
| 548 | 548 | return false; |
| 549 | 549 | } |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | |
| 553 | 553 | // Find the requested method |
| 554 | 554 | $xCallableObject = $this->getCallableObject($this->sRequestedClass); |
| 555 | - if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 555 | + if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 556 | 556 | { |
| 557 | 557 | // Unable to find the requested object or method |
| 558 | 558 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid', |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | // at the beginning and the end of the class name. |
| 578 | 578 | $sClassName = trim(str_replace(['.', '_'], ['\\', '\\'], (string)$sClassName), '\\'); |
| 579 | 579 | // Register an instance of the requested class, if it isn't yet |
| 580 | - if(!key_exists($sClassName, $this->aCallableObjects)) |
|
| 580 | + if (!key_exists($sClassName, $this->aCallableObjects)) |
|
| 581 | 581 | { |
| 582 | 582 | $this->getPluginManager()->registerClass($sClassName); |
| 583 | 583 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public function getName() |
| 78 | 78 | { |
| 79 | 79 | // Do not use sAlias here! |
| 80 | - if(is_array($this->sUserFunction)) |
|
| 80 | + if (is_array($this->sUserFunction)) |
|
| 81 | 81 | { |
| 82 | 82 | return $this->sUserFunction[1]; |
| 83 | 83 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function configure($sName, $sValue) |
| 96 | 96 | { |
| 97 | - switch($sName) |
|
| 97 | + switch ($sName) |
|
| 98 | 98 | { |
| 99 | 99 | case 'class': // The user function is a method in the given class |
| 100 | 100 | $this->sUserFunction = [new $sValue, $this->sUserFunction]; |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function call($aArgs = []) |
| 153 | 153 | { |
| 154 | - if(($this->sInclude)) |
|
| 154 | + if (($this->sInclude)) |
|
| 155 | 155 | { |
| 156 | 156 | require_once $this->sInclude; |
| 157 | 157 | } |
| 158 | 158 | $response = call_user_func_array($this->sUserFunction, $aArgs); |
| 159 | - if(($response)) |
|
| 159 | + if (($response)) |
|
| 160 | 160 | { |
| 161 | 161 | $this->getResponseManager()->append($response); |
| 162 | 162 | } |