@@ -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 | } |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | $this->aArgs = []; |
| 64 | 64 | $this->nMethod = Jaxon::METHOD_UNKNOWN; |
| 65 | 65 | |
| 66 | - if(isset($_POST['jxnargs'])) |
|
| 66 | + if (isset($_POST['jxnargs'])) |
|
| 67 | 67 | { |
| 68 | 68 | $this->nMethod = Jaxon::METHOD_POST; |
| 69 | 69 | $this->aArgs = $_POST['jxnargs']; |
| 70 | 70 | } |
| 71 | - elseif(isset($_GET['jxnargs'])) |
|
| 71 | + elseif (isset($_GET['jxnargs'])) |
|
| 72 | 72 | { |
| 73 | 73 | $this->nMethod = Jaxon::METHOD_GET; |
| 74 | 74 | $this->aArgs = $_GET['jxnargs']; |
| 75 | 75 | } |
| 76 | - if(get_magic_quotes_gpc() == 1) |
|
| 76 | + if (get_magic_quotes_gpc() == 1) |
|
| 77 | 77 | { |
| 78 | 78 | array_walk($this->aArgs, array(&$this, '__argumentStripSlashes')); |
| 79 | 79 | } |
@@ -89,17 +89,17 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | private function __convertStringToBool($sValue) |
| 91 | 91 | { |
| 92 | - if(strcasecmp($sValue, 'true') == 0) |
|
| 92 | + if (strcasecmp($sValue, 'true') == 0) |
|
| 93 | 93 | { |
| 94 | 94 | return true; |
| 95 | 95 | } |
| 96 | - if(strcasecmp($sValue, 'false') == 0) |
|
| 96 | + if (strcasecmp($sValue, 'false') == 0) |
|
| 97 | 97 | { |
| 98 | 98 | return false; |
| 99 | 99 | } |
| 100 | - if(is_numeric($sValue)) |
|
| 100 | + if (is_numeric($sValue)) |
|
| 101 | 101 | { |
| 102 | - if($sValue == 0) |
|
| 102 | + if ($sValue == 0) |
|
| 103 | 103 | { |
| 104 | 104 | return false; |
| 105 | 105 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | private function __argumentStripSlashes(&$sArg) |
| 119 | 119 | { |
| 120 | - if(!is_string($sArg)) |
|
| 120 | + if (!is_string($sArg)) |
|
| 121 | 121 | { |
| 122 | 122 | return ''; |
| 123 | 123 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | private function __argumentDecode(&$sArg) |
| 167 | 167 | { |
| 168 | - if($sArg == '') |
|
| 168 | + if ($sArg == '') |
|
| 169 | 169 | { |
| 170 | 170 | return ''; |
| 171 | 171 | } |
@@ -174,22 +174,22 @@ discard block |
||
| 174 | 174 | $sType = 'multipart/form-data'; |
| 175 | 175 | $iLen = strlen($sType); |
| 176 | 176 | $sContentType = ''; |
| 177 | - if(key_exists('CONTENT_TYPE', $_SERVER)) |
|
| 177 | + if (key_exists('CONTENT_TYPE', $_SERVER)) |
|
| 178 | 178 | { |
| 179 | 179 | $sContentType = substr($_SERVER['CONTENT_TYPE'], 0, $iLen); |
| 180 | 180 | } |
| 181 | - elseif(key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
| 181 | + elseif (key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
| 182 | 182 | { |
| 183 | 183 | $sContentType = substr($_SERVER['HTTP_CONTENT_TYPE'], 0, $iLen); |
| 184 | 184 | } |
| 185 | - if($sContentType == $sType) |
|
| 185 | + if ($sContentType == $sType) |
|
| 186 | 186 | { |
| 187 | 187 | $sArg = urldecode($sArg); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $data = json_decode($sArg, true); |
| 191 | 191 | |
| 192 | - if($data !== null && $sArg != $data) |
|
| 192 | + if ($data !== null && $sArg != $data) |
|
| 193 | 193 | { |
| 194 | 194 | $sArg = $data; |
| 195 | 195 | } |
@@ -208,13 +208,13 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | private function __argumentDecodeUTF8_iconv(&$mArg) |
| 210 | 210 | { |
| 211 | - if(is_array($mArg)) |
|
| 211 | + if (is_array($mArg)) |
|
| 212 | 212 | { |
| 213 | - foreach($mArg as $sKey => &$xArg) |
|
| 213 | + foreach ($mArg as $sKey => &$xArg) |
|
| 214 | 214 | { |
| 215 | 215 | $sNewKey = $sKey; |
| 216 | 216 | $this->__argumentDecodeUTF8_iconv($sNewKey); |
| 217 | - if($sNewKey != $sKey) |
|
| 217 | + if ($sNewKey != $sKey) |
|
| 218 | 218 | { |
| 219 | 219 | $mArg[$sNewKey] = $xArg; |
| 220 | 220 | unset($mArg[$sKey]); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $this->__argumentDecodeUTF8_iconv($xArg); |
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | - elseif(is_string($mArg)) |
|
| 226 | + elseif (is_string($mArg)) |
|
| 227 | 227 | { |
| 228 | 228 | $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg); |
| 229 | 229 | } |
@@ -238,13 +238,13 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | private function __argumentDecodeUTF8_mb_convert_encoding(&$mArg) |
| 240 | 240 | { |
| 241 | - if(is_array($mArg)) |
|
| 241 | + if (is_array($mArg)) |
|
| 242 | 242 | { |
| 243 | - foreach($mArg as $sKey => &$xArg) |
|
| 243 | + foreach ($mArg as $sKey => &$xArg) |
|
| 244 | 244 | { |
| 245 | 245 | $sNewKey = $sKey; |
| 246 | 246 | $this->__argumentDecodeUTF8_mb_convert_encoding($sNewKey); |
| 247 | - if($sNewKey != $sKey) |
|
| 247 | + if ($sNewKey != $sKey) |
|
| 248 | 248 | { |
| 249 | 249 | $mArg[$sNewKey] = $xArg; |
| 250 | 250 | unset($mArg[$sKey]); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $this->__argumentDecodeUTF8_mb_convert_encoding($xArg); |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | - elseif(is_string($mArg)) |
|
| 256 | + elseif (is_string($mArg)) |
|
| 257 | 257 | { |
| 258 | 258 | $mArg = mb_convert_encoding($mArg, $this->getOption('core.encoding'), "UTF-8"); |
| 259 | 259 | } |
@@ -268,14 +268,14 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | private function __argumentDecodeUTF8_utf8_decode(&$mArg) |
| 270 | 270 | { |
| 271 | - if(is_array($mArg)) |
|
| 271 | + if (is_array($mArg)) |
|
| 272 | 272 | { |
| 273 | - foreach($mArg as $sKey => &$xArg) |
|
| 273 | + foreach ($mArg as $sKey => &$xArg) |
|
| 274 | 274 | { |
| 275 | 275 | $sNewKey = $sKey; |
| 276 | 276 | $this->__argumentDecodeUTF8_utf8_decode($sNewKey); |
| 277 | 277 | |
| 278 | - if($sNewKey != $sKey) |
|
| 278 | + if ($sNewKey != $sKey) |
|
| 279 | 279 | { |
| 280 | 280 | $mArg[$sNewKey] = $xArg; |
| 281 | 281 | unset($mArg[$sKey]); |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $this->__argumentDecodeUTF8_utf8_decode($xArg); |
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | - elseif(is_string($mArg)) |
|
| 288 | + elseif (is_string($mArg)) |
|
| 289 | 289 | { |
| 290 | 290 | $mArg = utf8_decode($mArg); |
| 291 | 291 | } |
@@ -310,19 +310,19 @@ discard block |
||
| 310 | 310 | */ |
| 311 | 311 | public function processArguments() |
| 312 | 312 | { |
| 313 | - if(($this->getOption('core.decode_utf8'))) |
|
| 313 | + if (($this->getOption('core.decode_utf8'))) |
|
| 314 | 314 | { |
| 315 | 315 | $sFunction = ''; |
| 316 | 316 | |
| 317 | - if(function_exists('iconv')) |
|
| 317 | + if (function_exists('iconv')) |
|
| 318 | 318 | { |
| 319 | 319 | $sFunction = "iconv"; |
| 320 | 320 | } |
| 321 | - elseif(function_exists('mb_convert_encoding')) |
|
| 321 | + elseif (function_exists('mb_convert_encoding')) |
|
| 322 | 322 | { |
| 323 | 323 | $sFunction = "mb_convert_encoding"; |
| 324 | 324 | } |
| 325 | - elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
| 325 | + elseif ($this->getOption('core.encoding') == "ISO-8859-1") |
|
| 326 | 326 | { |
| 327 | 327 | $sFunction = "utf8_decode"; |
| 328 | 328 | } |
@@ -349,9 +349,9 @@ discard block |
||
| 349 | 349 | */ |
| 350 | 350 | public function canProcessRequest() |
| 351 | 351 | { |
| 352 | - foreach($this->xPluginManager->getRequestPlugins() as $xPlugin) |
|
| 352 | + foreach ($this->xPluginManager->getRequestPlugins() as $xPlugin) |
|
| 353 | 353 | { |
| 354 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 354 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 355 | 355 | { |
| 356 | 356 | return true; |
| 357 | 357 | } |
@@ -369,13 +369,13 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | public function processRequest() |
| 371 | 371 | { |
| 372 | - foreach($this->xPluginManager->getRequestPlugins() as $xPlugin) |
|
| 372 | + foreach ($this->xPluginManager->getRequestPlugins() as $xPlugin) |
|
| 373 | 373 | { |
| 374 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 374 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 375 | 375 | { |
| 376 | 376 | $xUploadPlugin = $this->xPluginManager->getRequestPlugin(Jaxon::FILE_UPLOAD); |
| 377 | 377 | // Process uploaded files |
| 378 | - if($xUploadPlugin != null) |
|
| 378 | + if ($xUploadPlugin != null) |
|
| 379 | 379 | { |
| 380 | 380 | $xUploadPlugin->processRequest(); |
| 381 | 381 | } |
@@ -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']; |
@@ -169,8 +168,7 @@ discard block |
||
| 169 | 168 | if(key_exists('CONTENT_TYPE', $_SERVER)) |
| 170 | 169 | { |
| 171 | 170 | $sContentType = substr($_SERVER['CONTENT_TYPE'], 0, $iLen); |
| 172 | - } |
|
| 173 | - elseif(key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
| 171 | + } elseif(key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
| 174 | 172 | { |
| 175 | 173 | $sContentType = substr($_SERVER['HTTP_CONTENT_TYPE'], 0, $iLen); |
| 176 | 174 | } |
@@ -184,8 +182,7 @@ discard block |
||
| 184 | 182 | if($data !== null && $sArg != $data) |
| 185 | 183 | { |
| 186 | 184 | $sArg = $data; |
| 187 | - } |
|
| 188 | - else |
|
| 185 | + } else |
|
| 189 | 186 | { |
| 190 | 187 | $sArg = $this->__convertValue($sArg); |
| 191 | 188 | } |
@@ -214,8 +211,7 @@ discard block |
||
| 214 | 211 | } |
| 215 | 212 | $this->__argumentDecodeUTF8_iconv($xArg); |
| 216 | 213 | } |
| 217 | - } |
|
| 218 | - elseif(is_string($mArg)) |
|
| 214 | + } elseif(is_string($mArg)) |
|
| 219 | 215 | { |
| 220 | 216 | $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg); |
| 221 | 217 | } |
@@ -244,8 +240,7 @@ discard block |
||
| 244 | 240 | } |
| 245 | 241 | $this->__argumentDecodeUTF8_mb_convert_encoding($xArg); |
| 246 | 242 | } |
| 247 | - } |
|
| 248 | - elseif(is_string($mArg)) |
|
| 243 | + } elseif(is_string($mArg)) |
|
| 249 | 244 | { |
| 250 | 245 | $mArg = mb_convert_encoding($mArg, $this->getOption('core.encoding'), "UTF-8"); |
| 251 | 246 | } |
@@ -276,8 +271,7 @@ discard block |
||
| 276 | 271 | |
| 277 | 272 | $this->__argumentDecodeUTF8_utf8_decode($xArg); |
| 278 | 273 | } |
| 279 | - } |
|
| 280 | - elseif(is_string($mArg)) |
|
| 274 | + } elseif(is_string($mArg)) |
|
| 281 | 275 | { |
| 282 | 276 | $mArg = utf8_decode($mArg); |
| 283 | 277 | } |
@@ -309,16 +303,13 @@ discard block |
||
| 309 | 303 | if(function_exists('iconv')) |
| 310 | 304 | { |
| 311 | 305 | $sFunction = "iconv"; |
| 312 | - } |
|
| 313 | - elseif(function_exists('mb_convert_encoding')) |
|
| 306 | + } elseif(function_exists('mb_convert_encoding')) |
|
| 314 | 307 | { |
| 315 | 308 | $sFunction = "mb_convert_encoding"; |
| 316 | - } |
|
| 317 | - elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
| 309 | + } elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
| 318 | 310 | { |
| 319 | 311 | $sFunction = "utf8_decode"; |
| 320 | - } |
|
| 321 | - else |
|
| 312 | + } else |
|
| 322 | 313 | { |
| 323 | 314 | throw new \Jaxon\Exception\Error($this->trans('errors.request.conversion')); |
| 324 | 315 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | 'core.prefix.class' => 'Jaxon', |
| 157 | 157 | // 'core.request.uri' => '', |
| 158 | 158 | 'core.request.mode' => 'asynchronous', |
| 159 | - 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 159 | + 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 160 | 160 | 'core.response.merge.ap' => true, |
| 161 | 161 | 'core.response.merge.js' => true, |
| 162 | 162 | 'core.debug.on' => false, |
@@ -244,17 +244,17 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public function getScript($bIncludeJs = false, $bIncludeCss = false) |
| 246 | 246 | { |
| 247 | - if(!$this->getOption('core.request.uri')) |
|
| 247 | + if (!$this->getOption('core.request.uri')) |
|
| 248 | 248 | { |
| 249 | 249 | $this->setOption('core.request.uri', URI::detect()); |
| 250 | 250 | } |
| 251 | 251 | $sCode = ''; |
| 252 | 252 | $xCodeGenerator = $this->di()->getCodeGenerator(); |
| 253 | - if(($bIncludeCss)) |
|
| 253 | + if (($bIncludeCss)) |
|
| 254 | 254 | { |
| 255 | 255 | $sCode .= $xCodeGenerator->getCss() . "\n"; |
| 256 | 256 | } |
| 257 | - if(($bIncludeJs)) |
|
| 257 | + if (($bIncludeJs)) |
|
| 258 | 258 | { |
| 259 | 259 | $sCode .= $xCodeGenerator->getJs() . "\n"; |
| 260 | 260 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | public function processRequest() |
| 326 | 326 | { |
| 327 | 327 | // Check to see if headers have already been sent out, in which case we can't do our job |
| 328 | - if(headers_sent($filename, $linenumber)) |
|
| 328 | + if (headers_sent($filename, $linenumber)) |
|
| 329 | 329 | { |
| 330 | 330 | echo $this->trans('errors.output.already-sent', array( |
| 331 | 331 | 'location' => $filename . ':' . $linenumber |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Check if there is a plugin to process this request |
| 337 | - if(!$this->canProcessRequest()) |
|
| 337 | + if (!$this->canProcessRequest()) |
|
| 338 | 338 | { |
| 339 | 339 | return; |
| 340 | 340 | } |
@@ -344,18 +344,18 @@ discard block |
||
| 344 | 344 | $xResponseManager = $this->getResponseManager(); |
| 345 | 345 | |
| 346 | 346 | // Handle before processing event |
| 347 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 347 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 348 | 348 | { |
| 349 | 349 | $this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest)); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - if(!$bEndRequest) |
|
| 352 | + if (!$bEndRequest) |
|
| 353 | 353 | { |
| 354 | 354 | try |
| 355 | 355 | { |
| 356 | 356 | $mResult = $this->getRequestHandler()->processRequest(); |
| 357 | 357 | } |
| 358 | - catch(Exception $e) |
|
| 358 | + catch (Exception $e) |
|
| 359 | 359 | { |
| 360 | 360 | // An exception was thrown while processing the request. |
| 361 | 361 | // The request missed the corresponding handler function, |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | $xResponseManager->debug($e->getMessage()); |
| 368 | 368 | $mResult = false; |
| 369 | 369 | |
| 370 | - if($e instanceof \Jaxon\Exception\Error) |
|
| 370 | + if ($e instanceof \Jaxon\Exception\Error) |
|
| 371 | 371 | { |
| 372 | 372 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 373 | 373 | $aParams = array($e->getMessage()); |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $aParams = array($e); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if(isset($this->aProcessingEvents[$sEvent])) |
|
| 381 | + if (isset($this->aProcessingEvents[$sEvent])) |
|
| 382 | 382 | { |
| 383 | 383 | // Call the processing event |
| 384 | 384 | $this->aProcessingEvents[$sEvent]->call($aParams); |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | // Clean the processing buffer |
| 394 | - if(($this->getOption('core.process.clean'))) |
|
| 394 | + if (($this->getOption('core.process.clean'))) |
|
| 395 | 395 | { |
| 396 | 396 | $er = error_reporting(0); |
| 397 | 397 | while (ob_get_level() > 0) |
@@ -401,16 +401,16 @@ discard block |
||
| 401 | 401 | error_reporting($er); |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - if($mResult === true) |
|
| 404 | + if ($mResult === true) |
|
| 405 | 405 | { |
| 406 | 406 | // Handle after processing event |
| 407 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 407 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 408 | 408 | { |
| 409 | 409 | $bEndRequest = false; |
| 410 | 410 | $this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]->call(array($bEndRequest)); |
| 411 | 411 | } |
| 412 | 412 | // If the called function returned no response, give the the global response instead |
| 413 | - if($xResponseManager->hasNoResponse()) |
|
| 413 | + if ($xResponseManager->hasNoResponse()) |
|
| 414 | 414 | { |
| 415 | 415 | $xResponseManager->append($this->getResponse()); |
| 416 | 416 | } |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | $xResponseManager->printDebug(); |
| 420 | 420 | |
| 421 | - if(($this->getOption('core.process.exit'))) |
|
| 421 | + if (($this->getOption('core.process.exit'))) |
|
| 422 | 422 | { |
| 423 | 423 | $xResponseManager->sendOutput(); |
| 424 | 424 | exit(); |
@@ -354,8 +354,7 @@ discard block |
||
| 354 | 354 | try |
| 355 | 355 | { |
| 356 | 356 | $mResult = $this->getRequestHandler()->processRequest(); |
| 357 | - } |
|
| 358 | - catch(Exception $e) |
|
| 357 | + } catch(Exception $e) |
|
| 359 | 358 | { |
| 360 | 359 | // An exception was thrown while processing the request. |
| 361 | 360 | // The request missed the corresponding handler function, |
@@ -371,8 +370,7 @@ discard block |
||
| 371 | 370 | { |
| 372 | 371 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 373 | 372 | $aParams = array($e->getMessage()); |
| 374 | - } |
|
| 375 | - else |
|
| 373 | + } else |
|
| 376 | 374 | { |
| 377 | 375 | $sEvent = self::PROCESSING_EVENT_ERROR; |
| 378 | 376 | $aParams = array($e); |
@@ -382,8 +380,7 @@ discard block |
||
| 382 | 380 | { |
| 383 | 381 | // Call the processing event |
| 384 | 382 | $this->aProcessingEvents[$sEvent]->call($aParams); |
| 385 | - } |
|
| 386 | - else |
|
| 383 | + } else |
|
| 387 | 384 | { |
| 388 | 385 | // The exception is not to be processed here. |
| 389 | 386 | throw $e; |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function confirm($question, $yesScript, $noScript) |
| 24 | 24 | { |
| 25 | - if(!$noScript) |
|
| 25 | + if (!$noScript) |
|
| 26 | 26 | { |
| 27 | 27 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}'; |
| 28 | 28 | } |
@@ -25,8 +25,7 @@ |
||
| 25 | 25 | if(!$noScript) |
| 26 | 26 | { |
| 27 | 27 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}'; |
| 28 | - } |
|
| 29 | - else |
|
| 28 | + } else |
|
| 30 | 29 | { |
| 31 | 30 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}else{' . $noScript . ';}'; |
| 32 | 31 | } |
@@ -136,13 +136,11 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | // The name of a request plugin is used as key in the plugin table |
| 138 | 138 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 139 | - } |
|
| 140 | - elseif($xPlugin instanceof Response) |
|
| 139 | + } elseif($xPlugin instanceof Response) |
|
| 141 | 140 | { |
| 142 | 141 | // The name of a response plugin is used as key in the plugin table |
| 143 | 142 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 144 | - } |
|
| 145 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 143 | + } elseif(!$bIsConfirm && !$bIsAlert) |
|
| 146 | 144 | { |
| 147 | 145 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', ['name' => get_class($xPlugin)])); |
| 148 | 146 | } |
@@ -226,13 +224,11 @@ discard block |
||
| 226 | 224 | { |
| 227 | 225 | // Register a function without options |
| 228 | 226 | $this->register(Jaxon::USER_FUNCTION, $xValue); |
| 229 | - } |
|
| 230 | - elseif(is_string($xKey) && is_array($xValue)) |
|
| 227 | + } elseif(is_string($xKey) && is_array($xValue)) |
|
| 231 | 228 | { |
| 232 | 229 | // Register a function with options |
| 233 | 230 | $this->register(Jaxon::USER_FUNCTION, $xKey, $xValue); |
| 234 | - } |
|
| 235 | - else |
|
| 231 | + } else |
|
| 236 | 232 | { |
| 237 | 233 | continue; |
| 238 | 234 | // Todo: throw an exception |
@@ -247,13 +243,11 @@ discard block |
||
| 247 | 243 | { |
| 248 | 244 | // Register a class without options |
| 249 | 245 | $this->register(Jaxon::CALLABLE_CLASS, $xValue); |
| 250 | - } |
|
| 251 | - elseif(is_string($xKey) && is_array($xValue)) |
|
| 246 | + } elseif(is_string($xKey) && is_array($xValue)) |
|
| 252 | 247 | { |
| 253 | 248 | // Register a class with options |
| 254 | 249 | $this->register(Jaxon::CALLABLE_CLASS, $xKey, $xValue); |
| 255 | - } |
|
| 256 | - elseif(is_integer($xKey) && is_array($xValue)) |
|
| 250 | + } elseif(is_integer($xKey) && is_array($xValue)) |
|
| 257 | 251 | { |
| 258 | 252 | // The directory path is required |
| 259 | 253 | if(!key_exists('directory', $xValue)) |
@@ -280,8 +274,7 @@ discard block |
||
| 280 | 274 | } |
| 281 | 275 | // Register a class without options |
| 282 | 276 | $this->register(Jaxon::CALLABLE_DIR, $sDirectory, $aOptions); |
| 283 | - } |
|
| 284 | - else |
|
| 277 | + } else |
|
| 285 | 278 | { |
| 286 | 279 | continue; |
| 287 | 280 | // Todo: throw an exception |
@@ -132,32 +132,32 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $bIsAlert = ($xPlugin instanceof \Jaxon\Dialog\Interfaces\Alert); |
| 134 | 134 | $bIsConfirm = ($xPlugin instanceof \Jaxon\Dialog\Interfaces\Confirm); |
| 135 | - if($xPlugin instanceof Request) |
|
| 135 | + if ($xPlugin instanceof Request) |
|
| 136 | 136 | { |
| 137 | 137 | // The name of a request plugin is used as key in the plugin table |
| 138 | 138 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 139 | 139 | } |
| 140 | - elseif($xPlugin instanceof Response) |
|
| 140 | + elseif ($xPlugin instanceof Response) |
|
| 141 | 141 | { |
| 142 | 142 | // The name of a response plugin is used as key in the plugin table |
| 143 | 143 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 144 | 144 | } |
| 145 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 145 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
| 146 | 146 | { |
| 147 | 147 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', ['name' => get_class($xPlugin)])); |
| 148 | 148 | } |
| 149 | 149 | // This plugin implements the Alert interface |
| 150 | - if($bIsAlert) |
|
| 150 | + if ($bIsAlert) |
|
| 151 | 151 | { |
| 152 | 152 | jaxon()->dialog()->setAlert($xPlugin); |
| 153 | 153 | } |
| 154 | 154 | // This plugin implements the Confirm interface |
| 155 | - if($bIsConfirm) |
|
| 155 | + if ($bIsConfirm) |
|
| 156 | 156 | { |
| 157 | 157 | jaxon()->dialog()->setConfirm($xPlugin); |
| 158 | 158 | } |
| 159 | 159 | // Register the plugin as an event listener |
| 160 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 160 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 161 | 161 | { |
| 162 | 162 | $this->addEventListener($xPlugin); |
| 163 | 163 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function register($sType, $sCallable, $aOptions = []) |
| 194 | 194 | { |
| 195 | - if(!key_exists($sType, $this->aRequestPlugins)) |
|
| 195 | + if (!key_exists($sType, $this->aRequestPlugins)) |
|
| 196 | 196 | { |
| 197 | 197 | throw new \Jaxon\Exception\Error($this->trans('errors.register.plugin', ['name' => $sType])); |
| 198 | 198 | } |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | // Register user functions |
| 222 | 222 | $aFunctionsConfig = $xAppConfig->getOption('functions', []); |
| 223 | - foreach($aFunctionsConfig as $xKey => $xValue) |
|
| 223 | + foreach ($aFunctionsConfig as $xKey => $xValue) |
|
| 224 | 224 | { |
| 225 | - if(is_integer($xKey) && is_string($xValue)) |
|
| 225 | + if (is_integer($xKey) && is_string($xValue)) |
|
| 226 | 226 | { |
| 227 | 227 | // Register a function without options |
| 228 | 228 | $this->register(Jaxon::USER_FUNCTION, $xValue); |
| 229 | 229 | } |
| 230 | - elseif(is_string($xKey) && is_array($xValue)) |
|
| 230 | + elseif (is_string($xKey) && is_array($xValue)) |
|
| 231 | 231 | { |
| 232 | 232 | // Register a function with options |
| 233 | 233 | $this->register(Jaxon::USER_FUNCTION, $xKey, $xValue); |
@@ -241,22 +241,22 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | // Register classes and directories |
| 243 | 243 | $aClassesConfig = $xAppConfig->getOption('classes', []); |
| 244 | - foreach($aClassesConfig as $xKey => $xValue) |
|
| 244 | + foreach ($aClassesConfig as $xKey => $xValue) |
|
| 245 | 245 | { |
| 246 | - if(is_integer($xKey) && is_string($xValue)) |
|
| 246 | + if (is_integer($xKey) && is_string($xValue)) |
|
| 247 | 247 | { |
| 248 | 248 | // Register a class without options |
| 249 | 249 | $this->register(Jaxon::CALLABLE_CLASS, $xValue); |
| 250 | 250 | } |
| 251 | - elseif(is_string($xKey) && is_array($xValue)) |
|
| 251 | + elseif (is_string($xKey) && is_array($xValue)) |
|
| 252 | 252 | { |
| 253 | 253 | // Register a class with options |
| 254 | 254 | $this->register(Jaxon::CALLABLE_CLASS, $xKey, $xValue); |
| 255 | 255 | } |
| 256 | - elseif(is_integer($xKey) && is_array($xValue)) |
|
| 256 | + elseif (is_integer($xKey) && is_array($xValue)) |
|
| 257 | 257 | { |
| 258 | 258 | // The directory path is required |
| 259 | - if(!key_exists('directory', $xValue)) |
|
| 259 | + if (!key_exists('directory', $xValue)) |
|
| 260 | 260 | { |
| 261 | 261 | continue; |
| 262 | 262 | // Todo: throw an exception |
@@ -264,17 +264,17 @@ discard block |
||
| 264 | 264 | // Registering a directory |
| 265 | 265 | $sDirectory = $xValue['directory']; |
| 266 | 266 | $aOptions = []; |
| 267 | - if(key_exists('options', $xValue) && |
|
| 267 | + if (key_exists('options', $xValue) && |
|
| 268 | 268 | (is_array($xValue['options']) || is_string($xValue['options']))) |
| 269 | 269 | { |
| 270 | 270 | $aOptions = $xValue['options']; |
| 271 | 271 | } |
| 272 | 272 | // Setup directory options |
| 273 | - if(key_exists('namespace', $xValue)) |
|
| 273 | + if (key_exists('namespace', $xValue)) |
|
| 274 | 274 | { |
| 275 | 275 | $aOptions['namespace'] = $xValue['namespace']; |
| 276 | 276 | } |
| 277 | - if(key_exists('separator', $xValue)) |
|
| 277 | + if (key_exists('separator', $xValue)) |
|
| 278 | 278 | { |
| 279 | 279 | $aOptions['separator'] = $xValue['separator']; |
| 280 | 280 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | public function getResponsePlugin($sName) |
| 301 | 301 | { |
| 302 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
| 302 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
| 303 | 303 | { |
| 304 | 304 | return $this->aResponsePlugins[$sName]; |
| 305 | 305 | } |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | public function getRequestPlugin($sName) |
| 317 | 317 | { |
| 318 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
| 318 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
| 319 | 319 | { |
| 320 | 320 | return $this->aRequestPlugins[$sName]; |
| 321 | 321 | } |
@@ -96,7 +96,6 @@ discard block |
||
| 96 | 96 | * Return the javascript call to a Jaxon function or object method |
| 97 | 97 | * |
| 98 | 98 | * @param string $sFunction The function or method (without class) name |
| 99 | - * @param ... $xParams The parameters of the function or method |
|
| 100 | 99 | * |
| 101 | 100 | * @return Request |
| 102 | 101 | */ |
@@ -125,7 +124,6 @@ discard block |
||
| 125 | 124 | * Return the javascript call to a generic function |
| 126 | 125 | * |
| 127 | 126 | * @param string $sFunction The function or method (with class) name |
| 128 | - * @param ... $xParams The parameters of the function or method |
|
| 129 | 127 | * |
| 130 | 128 | * @return Request |
| 131 | 129 | */ |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | $this->sPrefix = $this->getOption('core.prefix.function'); |
| 62 | 62 | |
| 63 | 63 | $sClass = trim($sClass, '.\\ '); |
| 64 | - if(!$sClass) |
|
| 64 | + if (!$sClass) |
|
| 65 | 65 | { |
| 66 | 66 | return $this; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if(!($xCallable = $this->xRepository->getCallableObject($sClass))) |
|
| 69 | + if (!($xCallable = $this->xRepository->getCallableObject($sClass))) |
|
| 70 | 70 | { |
| 71 | 71 | // Todo: decide which of these values to return |
| 72 | 72 | // return null; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | array_shift($aArguments); |
| 108 | 108 | |
| 109 | 109 | // Makes legacy code works |
| 110 | - if(strpos($sFunction, '.') !== false) |
|
| 110 | + if (strpos($sFunction, '.') !== false) |
|
| 111 | 111 | { |
| 112 | 112 | // If there is a dot in the name, then it is a call to a class |
| 113 | 113 | $this->sPrefix = $this->getOption('core.prefix.class'); |
@@ -20,7 +20,6 @@ |
||
| 20 | 20 | |
| 21 | 21 | namespace Jaxon\Request\Factory; |
| 22 | 22 | |
| 23 | -use JsonSerializable; |
|
| 24 | 23 | use Jaxon\Jaxon; |
| 25 | 24 | |
| 26 | 25 | class Request extends JsCall |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function hasPageNumber() |
| 53 | 53 | { |
| 54 | - foreach($this->aParameters as $xParameter) |
|
| 54 | + foreach ($this->aParameters as $xParameter) |
|
| 55 | 55 | { |
| 56 | - if($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
| 56 | + if ($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
| 57 | 57 | { |
| 58 | 58 | return true; |
| 59 | 59 | } |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | public function setPageNumber($nPageNumber) |
| 72 | 72 | { |
| 73 | 73 | // Set the value of the Jaxon::PAGE_NUMBER parameter |
| 74 | - foreach($this->aParameters as $xParameter) |
|
| 74 | + foreach ($this->aParameters as $xParameter) |
|
| 75 | 75 | { |
| 76 | - if($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
| 76 | + if ($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
| 77 | 77 | { |
| 78 | 78 | $xParameter->setValue(intval($nPageNumber)); |
| 79 | 79 | break; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | private function setMessageArgs(array $aArgs) |
| 93 | 93 | { |
| 94 | - array_walk($aArgs, function (&$xParameter) { |
|
| 94 | + array_walk($aArgs, function(&$xParameter) { |
|
| 95 | 95 | $xParameter = Parameter::make($xParameter); |
| 96 | 96 | }); |
| 97 | 97 | $this->aMessageArgs = $aArgs; |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | // This array will avoid declaring multiple variables with the same value. |
| 147 | 147 | // The array key is the variable value, while the array value is the variable name. |
| 148 | 148 | $aVariables = []; // Array of local variables. |
| 149 | - foreach($this->aParameters as &$xParameter) |
|
| 149 | + foreach ($this->aParameters as &$xParameter) |
|
| 150 | 150 | { |
| 151 | 151 | $sParameterStr = $xParameter->getScript(); |
| 152 | - if($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element) |
|
| 152 | + if ($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element) |
|
| 153 | 153 | { |
| 154 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
| 154 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
| 155 | 155 | { |
| 156 | 156 | // The value is not yet defined. A new variable is created. |
| 157 | 157 | $sVarName = "jxnVar$nVarId"; |
@@ -169,19 +169,19 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $sPhrase = ''; |
| 172 | - if(count($this->aMessageArgs) > 0) |
|
| 172 | + if (count($this->aMessageArgs) > 0) |
|
| 173 | 173 | { |
| 174 | 174 | $sPhrase = array_shift($this->aMessageArgs); // The first array entry is the question. |
| 175 | 175 | // $sPhrase = "'" . addslashes($sPhrase) . "'"; // Wrap the phrase with single quotes |
| 176 | - if(count($this->aMessageArgs) > 0) |
|
| 176 | + if (count($this->aMessageArgs) > 0) |
|
| 177 | 177 | { |
| 178 | 178 | $nParamId = 1; |
| 179 | - foreach($this->aMessageArgs as &$xParameter) |
|
| 179 | + foreach ($this->aMessageArgs as &$xParameter) |
|
| 180 | 180 | { |
| 181 | 181 | $sParameterStr = $xParameter->getScript(); |
| 182 | - if($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element) |
|
| 182 | + if ($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element) |
|
| 183 | 183 | { |
| 184 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
| 184 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
| 185 | 185 | { |
| 186 | 186 | // The value is not yet defined. A new variable is created. |
| 187 | 187 | $sVarName = "jxnVar$nVarId"; |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | $sScript = parent::getScript(); |
| 207 | 207 | $xDialog = jaxon()->dialog(); |
| 208 | - if($this->sCondition == '__confirm__') |
|
| 208 | + if ($this->sCondition == '__confirm__') |
|
| 209 | 209 | { |
| 210 | 210 | $sScript = $xDialog->confirm($sPhrase, $sScript, ''); |
| 211 | 211 | } |
| 212 | - elseif($this->sCondition !== null) |
|
| 212 | + elseif ($this->sCondition !== null) |
|
| 213 | 213 | { |
| 214 | 214 | $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}'; |
| 215 | - if(($sPhrase)) |
|
| 215 | + if (($sPhrase)) |
|
| 216 | 216 | { |
| 217 | 217 | $xDialog->getAlert()->setReturn(true); |
| 218 | 218 | $sScript .= 'else{' . $xDialog->warning($sPhrase) . ';}'; |
@@ -270,8 +270,7 @@ discard block |
||
| 270 | 270 | $aVariables[$sParameterStr] = $sVarName; |
| 271 | 271 | $sVars .= "$sVarName=$xParameter;"; |
| 272 | 272 | $nVarId++; |
| 273 | - } |
|
| 274 | - else |
|
| 273 | + } else |
|
| 275 | 274 | { |
| 276 | 275 | // The value is already defined. The corresponding variable is assigned. |
| 277 | 276 | $sVarName = $aVariables[$sParameterStr]; |
@@ -300,8 +299,7 @@ discard block |
||
| 300 | 299 | $aVariables[$sParameterStr] = $sVarName; |
| 301 | 300 | $sVars .= "$sVarName=$xParameter;"; |
| 302 | 301 | $nVarId++; |
| 303 | - } |
|
| 304 | - else |
|
| 302 | + } else |
|
| 305 | 303 | { |
| 306 | 304 | // The value is already defined. The corresponding variable is assigned. |
| 307 | 305 | $sVarName = $aVariables[$sParameterStr]; |
@@ -320,8 +318,7 @@ discard block |
||
| 320 | 318 | if($this->sCondition == '__confirm__') |
| 321 | 319 | { |
| 322 | 320 | $sScript = $xDialog->confirm($sPhrase, $sScript, ''); |
| 323 | - } |
|
| 324 | - elseif($this->sCondition !== null) |
|
| 321 | + } elseif($this->sCondition !== null) |
|
| 325 | 322 | { |
| 326 | 323 | $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}'; |
| 327 | 324 | if(($sPhrase)) |
@@ -60,19 +60,19 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $this->xRepository = $xRepository; |
| 62 | 62 | |
| 63 | - if(!empty($_GET['jxncls'])) |
|
| 63 | + if (!empty($_GET['jxncls'])) |
|
| 64 | 64 | { |
| 65 | 65 | $this->sRequestedClass = $_GET['jxncls']; |
| 66 | 66 | } |
| 67 | - if(!empty($_GET['jxnmthd'])) |
|
| 67 | + if (!empty($_GET['jxnmthd'])) |
|
| 68 | 68 | { |
| 69 | 69 | $this->sRequestedMethod = $_GET['jxnmthd']; |
| 70 | 70 | } |
| 71 | - if(!empty($_POST['jxncls'])) |
|
| 71 | + if (!empty($_POST['jxncls'])) |
|
| 72 | 72 | { |
| 73 | 73 | $this->sRequestedClass = $_POST['jxncls']; |
| 74 | 74 | } |
| 75 | - if(!empty($_POST['jxnmthd'])) |
|
| 75 | + if (!empty($_POST['jxnmthd'])) |
|
| 76 | 76 | { |
| 77 | 77 | $this->sRequestedMethod = $_POST['jxnmthd']; |
| 78 | 78 | } |
@@ -99,20 +99,20 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function register($sType, $sClassName, $aOptions) |
| 101 | 101 | { |
| 102 | - if($sType != $this->getName()) |
|
| 102 | + if ($sType != $this->getName()) |
|
| 103 | 103 | { |
| 104 | 104 | return false; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if(!is_string($sClassName)) |
|
| 107 | + if (!is_string($sClassName)) |
|
| 108 | 108 | { |
| 109 | 109 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 110 | 110 | } |
| 111 | - if(is_string($aOptions)) |
|
| 111 | + if (is_string($aOptions)) |
|
| 112 | 112 | { |
| 113 | 113 | $aOptions = ['include' => $aOptions]; |
| 114 | 114 | } |
| 115 | - if(!is_array($aOptions)) |
|
| 115 | + if (!is_array($aOptions)) |
|
| 116 | 116 | { |
| 117 | 117 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 118 | 118 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | public function canProcessRequest() |
| 151 | 151 | { |
| 152 | 152 | // Check the validity of the class name |
| 153 | - if(($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) || |
|
| 153 | + if (($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) || |
|
| 154 | 154 | ($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod))) |
| 155 | 155 | { |
| 156 | 156 | $this->sRequestedClass = null; |
@@ -166,14 +166,14 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function processRequest() |
| 168 | 168 | { |
| 169 | - if(!$this->canProcessRequest()) |
|
| 169 | + if (!$this->canProcessRequest()) |
|
| 170 | 170 | { |
| 171 | 171 | return false; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Find the requested method |
| 175 | 175 | $xCallableObject = $this->xRepository->getCallableObject($this->sRequestedClass); |
| 176 | - if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 176 | + if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 177 | 177 | { |
| 178 | 178 | // Unable to find the requested object or method |
| 179 | 179 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid', |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $jaxon = jaxon(); |
| 185 | 185 | $aArgs = $jaxon->getRequestHandler()->processArguments(); |
| 186 | 186 | $xResponse = $xCallableObject->call($this->sRequestedMethod, $aArgs); |
| 187 | - if(($xResponse)) |
|
| 187 | + if (($xResponse)) |
|
| 188 | 188 | { |
| 189 | 189 | $jaxon->getResponseManager()->append($xResponse); |
| 190 | 190 | } |
@@ -84,19 +84,19 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public static function make($xValue) |
| 86 | 86 | { |
| 87 | - if($xValue instanceof Interfaces\Parameter) |
|
| 87 | + if ($xValue instanceof Interfaces\Parameter) |
|
| 88 | 88 | { |
| 89 | 89 | return $xValue; |
| 90 | 90 | } |
| 91 | - elseif(is_numeric($xValue)) |
|
| 91 | + elseif (is_numeric($xValue)) |
|
| 92 | 92 | { |
| 93 | 93 | return new Parameter(Jaxon::NUMERIC_VALUE, $xValue); |
| 94 | 94 | } |
| 95 | - elseif(is_string($xValue)) |
|
| 95 | + elseif (is_string($xValue)) |
|
| 96 | 96 | { |
| 97 | 97 | return new Parameter(Jaxon::QUOTED_VALUE, $xValue); |
| 98 | 98 | } |
| 99 | - elseif(is_bool($xValue)) |
|
| 99 | + elseif (is_bool($xValue)) |
|
| 100 | 100 | { |
| 101 | 101 | return new Parameter(Jaxon::BOOL_VALUE, $xValue); |
| 102 | 102 | } |
@@ -115,16 +115,16 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | $sJsCode = ''; |
| 117 | 117 | $sQuoteCharacter = "'"; |
| 118 | - switch($this->sType) |
|
| 118 | + switch ($this->sType) |
|
| 119 | 119 | { |
| 120 | 120 | case Jaxon::FORM_VALUES: |
| 121 | 121 | $sJsCode = "jaxon.getFormValues(" . $sQuoteCharacter . $this->xValue . $sQuoteCharacter . ")"; |
| 122 | 122 | break; |
| 123 | 123 | case Jaxon::INPUT_VALUE: |
| 124 | - $sJsCode = "jaxon.$(" . $sQuoteCharacter . $this->xValue . $sQuoteCharacter . ").value"; |
|
| 124 | + $sJsCode = "jaxon.$(" . $sQuoteCharacter . $this->xValue . $sQuoteCharacter . ").value"; |
|
| 125 | 125 | break; |
| 126 | 126 | case Jaxon::CHECKED_VALUE: |
| 127 | - $sJsCode = "jaxon.$(" . $sQuoteCharacter . $this->xValue . $sQuoteCharacter . ").checked"; |
|
| 127 | + $sJsCode = "jaxon.$(" . $sQuoteCharacter . $this->xValue . $sQuoteCharacter . ").checked"; |
|
| 128 | 128 | break; |
| 129 | 129 | case Jaxon::ELEMENT_INNERHTML: |
| 130 | 130 | $sJsCode = "jaxon.$(" . $sQuoteCharacter . $this->xValue . $sQuoteCharacter . ").innerHTML"; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $sJsCode = (string)$this->xValue; |
| 143 | 143 | break; |
| 144 | 144 | case Jaxon::JS_VALUE: |
| 145 | - if(is_array($this->xValue) || is_object($this->xValue)) |
|
| 145 | + if (is_array($this->xValue) || is_object($this->xValue)) |
|
| 146 | 146 | { |
| 147 | 147 | // Unable to use double quotes here because they cannot be handled on client side. |
| 148 | 148 | // So we are using simple quotes even if the Json standard recommends double quotes. |
@@ -94,20 +94,16 @@ discard block |
||
| 94 | 94 | if($xValue instanceof Interfaces\Parameter) |
| 95 | 95 | { |
| 96 | 96 | return $xValue; |
| 97 | - } |
|
| 98 | - elseif(is_numeric($xValue)) |
|
| 97 | + } elseif(is_numeric($xValue)) |
|
| 99 | 98 | { |
| 100 | 99 | return new Parameter(Jaxon::NUMERIC_VALUE, $xValue); |
| 101 | - } |
|
| 102 | - elseif(is_string($xValue)) |
|
| 100 | + } elseif(is_string($xValue)) |
|
| 103 | 101 | { |
| 104 | 102 | return new Parameter(Jaxon::QUOTED_VALUE, $xValue); |
| 105 | - } |
|
| 106 | - elseif(is_bool($xValue)) |
|
| 103 | + } elseif(is_bool($xValue)) |
|
| 107 | 104 | { |
| 108 | 105 | return new Parameter(Jaxon::BOOL_VALUE, $xValue); |
| 109 | - } |
|
| 110 | - else // if(is_array($xValue) || is_object($xValue)) |
|
| 106 | + } else // if(is_array($xValue) || is_object($xValue)) |
|
| 111 | 107 | { |
| 112 | 108 | return new Parameter(Jaxon::JS_VALUE, $xValue); |
| 113 | 109 | } |
@@ -158,8 +154,7 @@ discard block |
||
| 158 | 154 | // Unable to use double quotes here because they cannot be handled on client side. |
| 159 | 155 | // So we are using simple quotes even if the Json standard recommends double quotes. |
| 160 | 156 | $sJsCode = str_replace(['"'], ["'"], json_encode($this->xValue, JSON_HEX_APOS | JSON_HEX_QUOT)); |
| 161 | - } |
|
| 162 | - else |
|
| 157 | + } else |
|
| 163 | 158 | { |
| 164 | 159 | $sJsCode = (string)$this->xValue; |
| 165 | 160 | } |
@@ -168,9 +168,9 @@ |
||
| 168 | 168 | */ |
| 169 | 169 | public function addParameters(array $aParameters) |
| 170 | 170 | { |
| 171 | - foreach($aParameters as $xParameter) |
|
| 171 | + foreach ($aParameters as $xParameter) |
|
| 172 | 172 | { |
| 173 | - if($xParameter instanceof JsCall) |
|
| 173 | + if ($xParameter instanceof JsCall) |
|
| 174 | 174 | { |
| 175 | 175 | $this->addParameter(Jaxon::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}'); |
| 176 | 176 | } |
@@ -173,8 +173,7 @@ |
||
| 173 | 173 | if($xParameter instanceof JsCall) |
| 174 | 174 | { |
| 175 | 175 | $this->addParameter(Jaxon::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}'); |
| 176 | - } |
|
| 177 | - else |
|
| 176 | + } else |
|
| 178 | 177 | { |
| 179 | 178 | $this->pushParameter(Parameter::make($xParameter)); |
| 180 | 179 | } |