@@ -212,8 +212,9 @@ discard block |
||
| 212 | 212 | { |
| 213 | 213 | $sEvent = $xArgs; |
| 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 | } |
| 219 | 220 | /*else |
@@ -326,8 +327,7 @@ discard block |
||
| 326 | 327 | try |
| 327 | 328 | { |
| 328 | 329 | $mResult = $this->getPluginManager()->processRequest(); |
| 329 | - } |
|
| 330 | - catch(Exception $e) |
|
| 330 | + } catch(Exception $e) |
|
| 331 | 331 | { |
| 332 | 332 | // An exception was thrown while processing the request. |
| 333 | 333 | // The request missed the corresponding handler function, |
@@ -344,8 +344,7 @@ discard block |
||
| 344 | 344 | { |
| 345 | 345 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 346 | 346 | $aParams = array($e->getMessage()); |
| 347 | - } |
|
| 348 | - else |
|
| 347 | + } else |
|
| 349 | 348 | { |
| 350 | 349 | $sEvent = self::PROCESSING_EVENT_ERROR; |
| 351 | 350 | $aParams = array($e); |
@@ -355,8 +354,7 @@ discard block |
||
| 355 | 354 | { |
| 356 | 355 | // Call the processing event |
| 357 | 356 | $this->aProcessingEvents[$sEvent]->call($aParams); |
| 358 | - } |
|
| 359 | - else |
|
| 357 | + } else |
|
| 360 | 358 | { |
| 361 | 359 | // The exception is not to be processed here. |
| 362 | 360 | throw $e; |
@@ -141,15 +141,6 @@ |
||
| 141 | 141 | * - Jaxon::CALLABLE_OBJECT: an object who's methods are to be registered |
| 142 | 142 | * - Jaxon::BROWSER_EVENT: an event which will cause zero or more event handlers to be called |
| 143 | 143 | * - Jaxon::EVENT_HANDLER: register an event handler function. |
| 144 | - * @param mixed $sFunction | $objObject | $sEvent |
|
| 145 | - * When registering a function, this is the name of the function |
|
| 146 | - * When registering a callable object, this is the object being registered |
|
| 147 | - * When registering an event or event handler, this is the name of the event |
|
| 148 | - * @param mixed $sIncludeFile | $aCallOptions | $sEventHandler |
|
| 149 | - * When registering a function, this is the (optional) include file |
|
| 150 | - * When registering a callable object, this is an (optional) array |
|
| 151 | - * of call options for the functions being registered |
|
| 152 | - * When registering an event handler, this is the name of the function |
|
| 153 | 144 | * |
| 154 | 145 | * @return mixed |
| 155 | 146 | */ |
@@ -25,13 +25,8 @@ |
||
| 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 | -use Closure; |
|
| 35 | 30 | |
| 36 | 31 | class Jaxon |
| 37 | 32 | { |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | $aArgs = func_get_args(); |
| 159 | 159 | $nArgs = func_num_args(); |
| 160 | 160 | |
| 161 | - if(self::PROCESSING_EVENT == $sType) |
|
| 161 | + if (self::PROCESSING_EVENT == $sType) |
|
| 162 | 162 | { |
| 163 | - if($nArgs > 2) |
|
| 163 | + if ($nArgs > 2) |
|
| 164 | 164 | { |
| 165 | 165 | $sEvent = $xArgs; |
| 166 | 166 | $xUserFunction = $aArgs[2]; |
| 167 | - if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
| 167 | + if (!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
| 168 | 168 | $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
| 169 | 169 | $this->aProcessingEvents[$sEvent] = $xUserFunction; |
| 170 | 170 | } |
@@ -236,16 +236,16 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | public function getScript($bIncludeJs = false, $bIncludeCss = false) |
| 238 | 238 | { |
| 239 | - if(!$this->getOption('core.request.uri')) |
|
| 239 | + if (!$this->getOption('core.request.uri')) |
|
| 240 | 240 | { |
| 241 | 241 | $this->setOption('core.request.uri', URI::detect()); |
| 242 | 242 | } |
| 243 | 243 | $sCode = ''; |
| 244 | - if(($bIncludeCss)) |
|
| 244 | + if (($bIncludeCss)) |
|
| 245 | 245 | { |
| 246 | 246 | $sCode .= $this->getPluginManager()->getCss() . "\n"; |
| 247 | 247 | } |
| 248 | - if(($bIncludeJs)) |
|
| 248 | + if (($bIncludeJs)) |
|
| 249 | 249 | { |
| 250 | 250 | $sCode .= $this->getPluginManager()->getJs() . "\n"; |
| 251 | 251 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | public function processRequest() |
| 317 | 317 | { |
| 318 | 318 | // Check to see if headers have already been sent out, in which case we can't do our job |
| 319 | - if(headers_sent($filename, $linenumber)) |
|
| 319 | + if (headers_sent($filename, $linenumber)) |
|
| 320 | 320 | { |
| 321 | 321 | echo $this->trans('errors.output.already-sent', array( |
| 322 | 322 | 'location' => $filename . ':' . $linenumber |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | // Check if there is a plugin to process this request |
| 328 | - if(!$this->canProcessRequest()) |
|
| 328 | + if (!$this->canProcessRequest()) |
|
| 329 | 329 | { |
| 330 | 330 | return; |
| 331 | 331 | } |
@@ -334,18 +334,18 @@ discard block |
||
| 334 | 334 | $mResult = true; |
| 335 | 335 | |
| 336 | 336 | // Handle before processing event |
| 337 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 337 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 338 | 338 | { |
| 339 | 339 | $this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest)); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if(!$bEndRequest) |
|
| 342 | + if (!$bEndRequest) |
|
| 343 | 343 | { |
| 344 | 344 | try |
| 345 | 345 | { |
| 346 | 346 | $mResult = $this->getPluginManager()->processRequest(); |
| 347 | 347 | } |
| 348 | - catch(Exception $e) |
|
| 348 | + catch (Exception $e) |
|
| 349 | 349 | { |
| 350 | 350 | // An exception was thrown while processing the request. |
| 351 | 351 | // The request missed the corresponding handler function, |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | $xResponseManager->debug($e->getMessage()); |
| 359 | 359 | $mResult = false; |
| 360 | 360 | |
| 361 | - if($e instanceof \Jaxon\Exception\Error) |
|
| 361 | + if ($e instanceof \Jaxon\Exception\Error) |
|
| 362 | 362 | { |
| 363 | 363 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 364 | 364 | $aParams = array($e->getMessage()); |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | $aParams = array($e); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if(isset($this->aProcessingEvents[$sEvent])) |
|
| 372 | + if (isset($this->aProcessingEvents[$sEvent])) |
|
| 373 | 373 | { |
| 374 | 374 | // Call the processing event |
| 375 | 375 | $this->aProcessingEvents[$sEvent]->call($aParams); |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | // Clean the processing buffer |
| 385 | - if(($this->getOption('core.process.clean'))) |
|
| 385 | + if (($this->getOption('core.process.clean'))) |
|
| 386 | 386 | { |
| 387 | 387 | $er = error_reporting(0); |
| 388 | 388 | while (ob_get_level() > 0) |
@@ -392,10 +392,10 @@ discard block |
||
| 392 | 392 | error_reporting($er); |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - if($mResult === true) |
|
| 395 | + if ($mResult === true) |
|
| 396 | 396 | { |
| 397 | 397 | // Handle after processing event |
| 398 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 398 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 399 | 399 | { |
| 400 | 400 | $bEndRequest = false; |
| 401 | 401 | $this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]->call(array($bEndRequest)); |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | |
| 405 | 405 | $this->getResponseManager()->printDebug(); |
| 406 | 406 | |
| 407 | - if(($this->getOption('core.process.exit'))) |
|
| 407 | + if (($this->getOption('core.process.exit'))) |
|
| 408 | 408 | { |
| 409 | 409 | $this->getResponseManager()->sendOutput(); |
| 410 | 410 | exit(); |
@@ -19,8 +19,6 @@ |
||
| 19 | 19 | |
| 20 | 20 | namespace Jaxon\Traits; |
| 21 | 21 | |
| 22 | -use Jaxon\Utils\Container; |
|
| 23 | - |
|
| 24 | 22 | trait Autoload |
| 25 | 23 | { |
| 26 | 24 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param string $sLibKey The key of the library options in the file |
| 70 | 70 | * @param string|null $sAppKey The key of the application options in the file |
| 71 | 71 | * |
| 72 | - * @return array |
|
| 72 | + * @return null|\Jaxon\Utils\Config\Config |
|
| 73 | 73 | */ |
| 74 | 74 | public function readPhpConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 75 | 75 | { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param string $sLibKey The key of the library options in the file |
| 84 | 84 | * @param string|null $sAppKey The key of the application options in the file |
| 85 | 85 | * |
| 86 | - * @return array |
|
| 86 | + * @return null|\Jaxon\Utils\Config\Config |
|
| 87 | 87 | */ |
| 88 | 88 | public function readYamlConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 89 | 89 | { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param string $sLibKey The key of the library options in the file |
| 98 | 98 | * @param string|null $sAppKey The key of the application options in the file |
| 99 | 99 | * |
| 100 | - * @return array |
|
| 100 | + * @return \Jaxon\Utils\Config\Config|null |
|
| 101 | 101 | */ |
| 102 | 102 | public function readJsonConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 103 | 103 | { |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param string $sLibKey The key of the library options in the file |
| 112 | 112 | * @param string|null $sAppKey The key of the application options in the file |
| 113 | 113 | * |
| 114 | - * @return array |
|
| 114 | + * @return null|\Jaxon\Utils\Config\Config |
|
| 115 | 115 | */ |
| 116 | 116 | public function readConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 117 | 117 | { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | 'core.prefix.event' => 'jaxon_event_', |
| 44 | 44 | // 'core.request.uri' => '', |
| 45 | 45 | 'core.request.mode' => 'asynchronous', |
| 46 | - 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 46 | + 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 47 | 47 | 'core.debug.on' => false, |
| 48 | 48 | 'core.debug.verbose' => false, |
| 49 | 49 | 'core.process.exit' => true, |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | public function readConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 117 | 117 | { |
| 118 | 118 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
| 119 | - switch($sExt) |
|
| 119 | + switch ($sExt) |
|
| 120 | 120 | { |
| 121 | 121 | case 'php': |
| 122 | 122 | return $this->readPhpConfigFile($sConfigFile, $sLibKey, $sAppKey); |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | * - 1000 thru 8999: User created plugins, typically, these plugins don't care about order |
| 32 | 32 | * - 9000 thru 9999: Plugins that generally need to be last or near the end of the plugin list |
| 33 | 33 | * |
| 34 | - * @param Plugin $xPlugin An instance of a plugin |
|
| 34 | + * @param \Jaxon\Plugin\Plugin $xPlugin An instance of a plugin |
|
| 35 | 35 | * @param integer $nPriority The plugin priority, used to order the plugins |
| 36 | 36 | * |
| 37 | 37 | * @return void |
@@ -19,8 +19,6 @@ |
||
| 19 | 19 | |
| 20 | 20 | namespace Jaxon\Traits; |
| 21 | 21 | |
| 22 | -use Jaxon\Utils\Container; |
|
| 23 | - |
|
| 24 | 22 | trait Plugin |
| 25 | 23 | { |
| 26 | 24 | /** |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | /** |
| 47 | 47 | * Check uploaded files validity and move them to the user dir |
| 48 | 48 | * |
| 49 | - * @return boolean |
|
| 49 | + * @return null|boolean |
|
| 50 | 50 | */ |
| 51 | 51 | public function saveUploadedFiles() |
| 52 | 52 | { |
@@ -19,11 +19,6 @@ |
||
| 19 | 19 | |
| 20 | 20 | namespace Jaxon\Traits; |
| 21 | 21 | |
| 22 | -use Jaxon\Plugin\Manager as PluginManager; |
|
| 23 | -use Jaxon\Request\Manager as RequestManager; |
|
| 24 | -use Jaxon\Response\Manager as ResponseManager; |
|
| 25 | - |
|
| 26 | -use Jaxon\Utils\URI; |
|
| 27 | 22 | use Exception; |
| 28 | 23 | use Closure; |
| 29 | 24 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | trait Upload |
| 31 | 31 | { |
| 32 | - /** |
|
| 32 | + /** |
|
| 33 | 33 | * Check if uploaded files are available |
| 34 | 34 | * |
| 35 | 35 | * @return boolean |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | return $xUploadPlugin->canProcessRequest(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - /** |
|
| 46 | + /** |
|
| 47 | 47 | * Check uploaded files validity and move them to the user dir |
| 48 | 48 | * |
| 49 | 49 | * @return boolean |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function hasUploadedFiles() |
| 38 | 38 | { |
| 39 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 39 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 40 | 40 | { |
| 41 | 41 | return false; |
| 42 | 42 | } |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | try |
| 54 | 54 | { |
| 55 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 55 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 56 | 56 | { |
| 57 | 57 | throw new Exception($this->trans('errors.upload.plugin')); |
| 58 | 58 | } |
| 59 | - elseif(!$xUploadPlugin->canProcessRequest()) |
|
| 59 | + elseif (!$xUploadPlugin->canProcessRequest()) |
|
| 60 | 60 | { |
| 61 | 61 | throw new Exception($this->trans('errors.upload.request')); |
| 62 | 62 | } |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | $sResponse = '{"code": "success", "upl": "' . $sKey . '"}'; |
| 66 | 66 | $return = true; |
| 67 | 67 | } |
| 68 | - catch(Exception $e) |
|
| 68 | + catch (Exception $e) |
|
| 69 | 69 | { |
| 70 | 70 | $sResponse = '{"code": "error", "msg": "' . addslashes($e->getMessage()) . '"}'; |
| 71 | 71 | $return = false; |
| 72 | 72 | } |
| 73 | 73 | // Send the response back to the browser |
| 74 | 74 | echo '<script>var res = ', $sResponse, '; </script>'; |
| 75 | - if(($this->getOption('core.process.exit'))) |
|
| 75 | + if (($this->getOption('core.process.exit'))) |
|
| 76 | 76 | { |
| 77 | 77 | exit(); |
| 78 | 78 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function getUploadedFiles() |
| 88 | 88 | { |
| 89 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 89 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 90 | 90 | { |
| 91 | 91 | return []; |
| 92 | 92 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function setUploadFileFilter(Closure $fFileFilter) |
| 104 | 104 | { |
| 105 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 105 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 106 | 106 | { |
| 107 | 107 | return; |
| 108 | 108 | } |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
| 56 | 56 | { |
| 57 | 57 | throw new Exception($this->trans('errors.upload.plugin')); |
| 58 | - } |
|
| 59 | - elseif(!$xUploadPlugin->canProcessRequest()) |
|
| 58 | + } elseif(!$xUploadPlugin->canProcessRequest()) |
|
| 60 | 59 | { |
| 61 | 60 | throw new Exception($this->trans('errors.upload.request')); |
| 62 | 61 | } |
@@ -64,8 +63,7 @@ discard block |
||
| 64 | 63 | $sKey = $xUploadPlugin->saveUploadedFiles(); |
| 65 | 64 | $sResponse = '{"code": "success", "upl": "' . $sKey . '"}'; |
| 66 | 65 | $return = true; |
| 67 | - } |
|
| 68 | - catch(Exception $e) |
|
| 66 | + } catch(Exception $e) |
|
| 69 | 67 | { |
| 70 | 68 | $sResponse = '{"code": "error", "msg": "' . addslashes($e->getMessage()) . '"}'; |
| 71 | 69 | $return = false; |