@@ -20,7 +20,6 @@ |
||
| 20 | 20 | |
| 21 | 21 | namespace Jaxon\Request; |
| 22 | 22 | |
| 23 | -use JsonSerializable; |
|
| 24 | 23 | use Jaxon\Jaxon; |
| 25 | 24 | |
| 26 | 25 | class Request extends JsCall |
@@ -191,8 +191,7 @@ discard block |
||
| 191 | 191 | $aVariables[$sParameterStr] = $sVarName; |
| 192 | 192 | $sVars .= "$sVarName=$xParameter;"; |
| 193 | 193 | $nVarId++; |
| 194 | - } |
|
| 195 | - else |
|
| 194 | + } else |
|
| 196 | 195 | { |
| 197 | 196 | // The value is already defined. The corresponding variable is assigned. |
| 198 | 197 | $sVarName = $aVariables[$sParameterStr]; |
@@ -221,8 +220,7 @@ discard block |
||
| 221 | 220 | $aVariables[$sParameterStr] = $sVarName; |
| 222 | 221 | $sVars .= "$sVarName=$xParameter;"; |
| 223 | 222 | $nVarId++; |
| 224 | - } |
|
| 225 | - else |
|
| 223 | + } else |
|
| 226 | 224 | { |
| 227 | 225 | // The value is already defined. The corresponding variable is assigned. |
| 228 | 226 | $sVarName = $aVariables[$sParameterStr]; |
@@ -241,8 +239,7 @@ discard block |
||
| 241 | 239 | { |
| 242 | 240 | $xConfirm = $this->getPluginManager()->getConfirm(); |
| 243 | 241 | $sScript = $xConfirm->confirm($sPhrase, $sScript, ''); |
| 244 | - } |
|
| 245 | - elseif($this->sCondition !== null) |
|
| 242 | + } elseif($this->sCondition !== null) |
|
| 246 | 243 | { |
| 247 | 244 | $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}'; |
| 248 | 245 | if(($sPhrase)) |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function hasPageNumber() |
| 60 | 60 | { |
| 61 | - foreach($this->aParameters as $xParameter) |
|
| 61 | + foreach ($this->aParameters as $xParameter) |
|
| 62 | 62 | { |
| 63 | - if($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
| 63 | + if ($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
| 64 | 64 | { |
| 65 | 65 | return true; |
| 66 | 66 | } |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | public function setPageNumber($nPageNumber) |
| 79 | 79 | { |
| 80 | 80 | // Set the value of the Jaxon::PAGE_NUMBER parameter |
| 81 | - foreach($this->aParameters as $xParameter) |
|
| 81 | + foreach ($this->aParameters as $xParameter) |
|
| 82 | 82 | { |
| 83 | - if($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
| 83 | + if ($xParameter->getType() == Jaxon::PAGE_NUMBER) |
|
| 84 | 84 | { |
| 85 | 85 | $xParameter->setValue(intval($nPageNumber)); |
| 86 | 86 | break; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | $this->sCondition = '__confirm__'; |
| 102 | 102 | $this->aMessageArgs = func_get_args(); |
| 103 | - array_walk($this->aMessageArgs, function (&$xParameter) { |
|
| 103 | + array_walk($this->aMessageArgs, function(&$xParameter) { |
|
| 104 | 104 | $xParameter = Parameter::make($xParameter); |
| 105 | 105 | }); |
| 106 | 106 | return $this; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | public function elseShow($sMessage) |
| 234 | 234 | { |
| 235 | 235 | $this->aMessageArgs = func_get_args(); |
| 236 | - array_walk($this->aMessageArgs, function (&$xParameter) { |
|
| 236 | + array_walk($this->aMessageArgs, function(&$xParameter) { |
|
| 237 | 237 | $xParameter = Parameter::make($xParameter); |
| 238 | 238 | }); |
| 239 | 239 | return $this; |
@@ -258,12 +258,12 @@ discard block |
||
| 258 | 258 | // This array will avoid declaring multiple variables with the same value. |
| 259 | 259 | // The array key is the variable value, while the array value is the variable name. |
| 260 | 260 | $aVariables = []; // Array of local variables. |
| 261 | - foreach($this->aParameters as &$xParameter) |
|
| 261 | + foreach ($this->aParameters as &$xParameter) |
|
| 262 | 262 | { |
| 263 | 263 | $sParameterStr = $xParameter->getScript(); |
| 264 | - if($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element) |
|
| 264 | + if ($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element) |
|
| 265 | 265 | { |
| 266 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
| 266 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
| 267 | 267 | { |
| 268 | 268 | // The value is not yet defined. A new variable is created. |
| 269 | 269 | $sVarName = "jxnVar$nVarId"; |
@@ -281,19 +281,19 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | $sPhrase = ''; |
| 284 | - if(count($this->aMessageArgs) > 0) |
|
| 284 | + if (count($this->aMessageArgs) > 0) |
|
| 285 | 285 | { |
| 286 | 286 | $sPhrase = array_shift($this->aMessageArgs); // The first array entry is the question. |
| 287 | 287 | // $sPhrase = "'" . addslashes($sPhrase) . "'"; // Wrap the phrase with single quotes |
| 288 | - if(count($this->aMessageArgs) > 0) |
|
| 288 | + if (count($this->aMessageArgs) > 0) |
|
| 289 | 289 | { |
| 290 | 290 | $nParamId = 1; |
| 291 | - foreach($this->aMessageArgs as &$xParameter) |
|
| 291 | + foreach ($this->aMessageArgs as &$xParameter) |
|
| 292 | 292 | { |
| 293 | 293 | $sParameterStr = $xParameter->getScript(); |
| 294 | - if($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element) |
|
| 294 | + if ($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element) |
|
| 295 | 295 | { |
| 296 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
| 296 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
| 297 | 297 | { |
| 298 | 298 | // The value is not yet defined. A new variable is created. |
| 299 | 299 | $sVarName = "jxnVar$nVarId"; |
@@ -316,15 +316,15 @@ discard block |
||
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | $sScript = parent::getScript(); |
| 319 | - if($this->sCondition == '__confirm__') |
|
| 319 | + if ($this->sCondition == '__confirm__') |
|
| 320 | 320 | { |
| 321 | 321 | $xConfirm = $this->getPluginManager()->getConfirm(); |
| 322 | 322 | $sScript = $xConfirm->confirm($sPhrase, $sScript, ''); |
| 323 | 323 | } |
| 324 | - elseif($this->sCondition !== null) |
|
| 324 | + elseif ($this->sCondition !== null) |
|
| 325 | 325 | { |
| 326 | 326 | $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}'; |
| 327 | - if(($sPhrase)) |
|
| 327 | + if (($sPhrase)) |
|
| 328 | 328 | { |
| 329 | 329 | $xAlert = $this->getPluginManager()->getAlert(); |
| 330 | 330 | $xAlert->setReturn(true); |
@@ -89,7 +89,6 @@ discard block |
||
| 89 | 89 | * Return the javascript call to an Jaxon object method |
| 90 | 90 | * |
| 91 | 91 | * @param string $sMethod The method (without class) name |
| 92 | - * @param ... $xParams The parameters of the method |
|
| 93 | 92 | * |
| 94 | 93 | * @return object |
| 95 | 94 | */ |
@@ -110,7 +109,6 @@ discard block |
||
| 110 | 109 | * @param integer $nItemsPerPage the number of items per page |
| 111 | 110 | * @param integer $nCurrentPage the current page |
| 112 | 111 | * @param string $sMethod the name of the method |
| 113 | - * @param ... $parameters the parameters of the method |
|
| 114 | 112 | * |
| 115 | 113 | * @return string the pagination links |
| 116 | 114 | */ |
@@ -161,7 +161,7 @@ |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | - * @return string |
|
| 164 | + * @return Request |
|
| 165 | 165 | */ |
| 166 | 166 | public function getRequest() |
| 167 | 167 | { |
@@ -265,8 +265,7 @@ discard block |
||
| 265 | 265 | { |
| 266 | 266 | $pages[] = $this->createPage($i, $i == $this->currentPage); |
| 267 | 267 | } |
| 268 | - } |
|
| 269 | - else |
|
| 268 | + } else |
|
| 270 | 269 | { |
| 271 | 270 | // Determine the sliding range, centered around the current page. |
| 272 | 271 | $numAdjacents = (int) floor(($this->maxPagesToShow - 3) / 2); |
@@ -274,8 +273,7 @@ discard block |
||
| 274 | 273 | if($this->currentPage + $numAdjacents > $this->numPages) |
| 275 | 274 | { |
| 276 | 275 | $slidingStart = $this->numPages - $this->maxPagesToShow + 2; |
| 277 | - } |
|
| 278 | - else |
|
| 276 | + } else |
|
| 279 | 277 | { |
| 280 | 278 | $slidingStart = $this->currentPage - $numAdjacents; |
| 281 | 279 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | protected function updateNumPages() |
| 67 | 67 | { |
| 68 | - $this->numPages = ($this->itemsPerPage == 0 ? 0 : (int) ceil($this->totalItems/$this->itemsPerPage)); |
|
| 68 | + $this->numPages = ($this->itemsPerPage == 0 ? 0 : (int)ceil($this->totalItems / $this->itemsPerPage)); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function setMaxPagesToShow($maxPagesToShow) |
| 76 | 76 | { |
| 77 | - if($maxPagesToShow < 3) |
|
| 77 | + if ($maxPagesToShow < 3) |
|
| 78 | 78 | { |
| 79 | 79 | throw new \InvalidArgumentException('maxPagesToShow cannot be less than 3.'); |
| 80 | 80 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | { |
| 155 | 155 | $this->request = $request; |
| 156 | 156 | // Append the page number to the parameter list, if not yet given. |
| 157 | - if(($this->request) && !$this->request->hasPageNumber()) |
|
| 157 | + if (($this->request) && !$this->request->hasPageNumber()) |
|
| 158 | 158 | { |
| 159 | 159 | $this->request->addParameter(Jaxon::PAGE_NUMBER, 0); |
| 160 | 160 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | public function getNextPage() |
| 195 | 195 | { |
| 196 | - if($this->currentPage < $this->numPages) |
|
| 196 | + if ($this->currentPage < $this->numPages) |
|
| 197 | 197 | { |
| 198 | 198 | return $this->currentPage + 1; |
| 199 | 199 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | public function getPrevPage() |
| 205 | 205 | { |
| 206 | - if($this->currentPage > 1) |
|
| 206 | + if ($this->currentPage > 1) |
|
| 207 | 207 | { |
| 208 | 208 | return $this->currentPage - 1; |
| 209 | 209 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | public function getNextCall() |
| 215 | 215 | { |
| 216 | - if(!$this->getNextPage()) |
|
| 216 | + if (!$this->getNextPage()) |
|
| 217 | 217 | { |
| 218 | 218 | return null; |
| 219 | 219 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function getPrevCall() |
| 228 | 228 | { |
| 229 | - if(!$this->getPrevPage()) |
|
| 229 | + if (!$this->getPrevPage()) |
|
| 230 | 230 | { |
| 231 | 231 | return null; |
| 232 | 232 | } |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | { |
| 255 | 255 | $pages = []; |
| 256 | 256 | |
| 257 | - if($this->numPages <= 1) |
|
| 257 | + if ($this->numPages <= 1) |
|
| 258 | 258 | { |
| 259 | 259 | return []; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if($this->numPages <= $this->maxPagesToShow) |
|
| 262 | + if ($this->numPages <= $this->maxPagesToShow) |
|
| 263 | 263 | { |
| 264 | - for($i = 1; $i <= $this->numPages; $i++) |
|
| 264 | + for ($i = 1; $i <= $this->numPages; $i++) |
|
| 265 | 265 | { |
| 266 | 266 | $pages[] = $this->createPage($i, $i == $this->currentPage); |
| 267 | 267 | } |
@@ -269,9 +269,9 @@ discard block |
||
| 269 | 269 | else |
| 270 | 270 | { |
| 271 | 271 | // Determine the sliding range, centered around the current page. |
| 272 | - $numAdjacents = (int) floor(($this->maxPagesToShow - 3) / 2); |
|
| 272 | + $numAdjacents = (int)floor(($this->maxPagesToShow - 3) / 2); |
|
| 273 | 273 | |
| 274 | - if($this->currentPage + $numAdjacents > $this->numPages) |
|
| 274 | + if ($this->currentPage + $numAdjacents > $this->numPages) |
|
| 275 | 275 | { |
| 276 | 276 | $slidingStart = $this->numPages - $this->maxPagesToShow + 2; |
| 277 | 277 | } |
@@ -279,28 +279,28 @@ discard block |
||
| 279 | 279 | { |
| 280 | 280 | $slidingStart = $this->currentPage - $numAdjacents; |
| 281 | 281 | } |
| 282 | - if($slidingStart < 2) |
|
| 282 | + if ($slidingStart < 2) |
|
| 283 | 283 | { |
| 284 | 284 | $slidingStart = 2; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | $slidingEnd = $slidingStart + $this->maxPagesToShow - 3; |
| 288 | - if($slidingEnd >= $this->numPages) |
|
| 288 | + if ($slidingEnd >= $this->numPages) |
|
| 289 | 289 | { |
| 290 | 290 | $slidingEnd = $this->numPages - 1; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // Build the list of pages. |
| 294 | 294 | $pages[] = $this->createPage(1, $this->currentPage == 1); |
| 295 | - if($slidingStart > 2) |
|
| 295 | + if ($slidingStart > 2) |
|
| 296 | 296 | { |
| 297 | 297 | $pages[] = $this->createPageEllipsis(); |
| 298 | 298 | } |
| 299 | - for($i = $slidingStart; $i <= $slidingEnd; $i++) |
|
| 299 | + for ($i = $slidingStart; $i <= $slidingEnd; $i++) |
|
| 300 | 300 | { |
| 301 | 301 | $pages[] = $this->createPage($i, $i == $this->currentPage); |
| 302 | 302 | } |
| 303 | - if($slidingEnd < $this->numPages - 1) |
|
| 303 | + if ($slidingEnd < $this->numPages - 1) |
|
| 304 | 304 | { |
| 305 | 305 | $pages[] = $this->createPageEllipsis(); |
| 306 | 306 | } |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | */ |
| 347 | 347 | public function toHtml() |
| 348 | 348 | { |
| 349 | - if($this->getNumPages() <= 1) |
|
| 349 | + if ($this->getNumPages() <= 1) |
|
| 350 | 350 | { |
| 351 | 351 | return ''; |
| 352 | 352 | } |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | { |
| 370 | 370 | $first = ($this->currentPage - 1) * $this->itemsPerPage + 1; |
| 371 | 371 | |
| 372 | - if($first > $this->totalItems) |
|
| 372 | + if ($first > $this->totalItems) |
|
| 373 | 373 | { |
| 374 | 374 | return null; |
| 375 | 375 | } |
@@ -380,13 +380,13 @@ discard block |
||
| 380 | 380 | public function getCurrentPageLastItem() |
| 381 | 381 | { |
| 382 | 382 | $first = $this->getCurrentPageFirstItem(); |
| 383 | - if($first === null) |
|
| 383 | + if ($first === null) |
|
| 384 | 384 | { |
| 385 | 385 | return null; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | $last = $first + $this->itemsPerPage - 1; |
| 389 | - if($last > $this->totalItems) |
|
| 389 | + if ($last > $this->totalItems) |
|
| 390 | 390 | { |
| 391 | 391 | return $this->totalItems; |
| 392 | 392 | } |
@@ -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 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public function addNamespace($sNamespace, $sDirectory, $sExtension = '') |
| 46 | 46 | { |
| 47 | 47 | // The 'jaxon' key cannot be overriden |
| 48 | - if($sNamespace == 'jaxon') |
|
| 48 | + if ($sNamespace == 'jaxon') |
|
| 49 | 49 | { |
| 50 | 50 | return; |
| 51 | 51 | } |
@@ -82,18 +82,18 @@ discard block |
||
| 82 | 82 | // Get the namespace name |
| 83 | 83 | $sNamespace = ''; |
| 84 | 84 | $iSeparatorPosition = strrpos($sTemplate, '::'); |
| 85 | - if($iSeparatorPosition !== false) |
|
| 85 | + if ($iSeparatorPosition !== false) |
|
| 86 | 86 | { |
| 87 | 87 | $sNamespace = substr($sTemplate, 0, $iSeparatorPosition); |
| 88 | 88 | $sTemplate = substr($sTemplate, $iSeparatorPosition + 2); |
| 89 | 89 | } |
| 90 | 90 | // The default namespace is 'jaxon' |
| 91 | - if(!($sNamespace = trim($sNamespace))) |
|
| 91 | + if (!($sNamespace = trim($sNamespace))) |
|
| 92 | 92 | { |
| 93 | 93 | $sNamespace = 'jaxon'; |
| 94 | 94 | } |
| 95 | 95 | // Check if the namespace is defined |
| 96 | - if(!key_exists($sNamespace, $this->aNamespaces)) |
|
| 96 | + if (!key_exists($sNamespace, $this->aNamespaces)) |
|
| 97 | 97 | { |
| 98 | 98 | return false; |
| 99 | 99 | } |
@@ -80,11 +80,11 @@ |
||
| 80 | 80 | protected function includeAssets() |
| 81 | 81 | { |
| 82 | 82 | $sPluginOptionName = 'assets.include.' . $this->getName(); |
| 83 | - if($this->hasOption($sPluginOptionName) && !$this->getOption($sPluginOptionName)) |
|
| 83 | + if ($this->hasOption($sPluginOptionName) && !$this->getOption($sPluginOptionName)) |
|
| 84 | 84 | { |
| 85 | 85 | return false; |
| 86 | 86 | } |
| 87 | - if($this->hasOption('assets.include.all') && !$this->getOption('assets.include.all')) |
|
| 87 | + if ($this->hasOption('assets.include.all') && !$this->getOption('assets.include.all')) |
|
| 88 | 88 | { |
| 89 | 89 | return false; |
| 90 | 90 | } |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <ul class="pagination"> |
| 2 | 2 | <?php |
| 3 | - if(($this->prev)) |
|
| 3 | + if (($this->prev)) |
|
| 4 | 4 | { |
| 5 | 5 | echo $this->prev; |
| 6 | 6 | } |
| 7 | 7 | echo $this->links; |
| 8 | - if(($this->next)) |
|
| 8 | + if (($this->next)) |
|
| 9 | 9 | { |
| 10 | 10 | echo $this->next; |
| 11 | 11 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php echo $this->sPrefix ?><?php echo $this->sAlias ?> = function() { |
| 2 | 2 | return jaxon.request( |
| 3 | 3 | { jxnfun: '<?php echo $this->sFunction ?>' }, |
| 4 | - { parameters: arguments<?php foreach($this->aConfig as $sKey => $sValue): ?>, <?php echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> } |
|
| 4 | + { parameters: arguments<?php foreach ($this->aConfig as $sKey => $sValue): ?>, <?php echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> } |
|
| 5 | 5 | ); |
| 6 | 6 | }; |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php echo $this->sPrefix ?><?php echo $this->sClass ?> = {}; |
| 2 | -<?php foreach($this->aMethods as $aMethod): ?> |
|
| 2 | +<?php foreach ($this->aMethods as $aMethod): ?> |
|
| 3 | 3 | <?php echo $this->sPrefix ?><?php echo $this->sClass ?>.<?php echo $aMethod['name'] ?> = function() { |
| 4 | 4 | return jaxon.request( |
| 5 | 5 | { jxncls: '<?php echo $this->sClass ?>', jxnmthd: '<?php echo $aMethod['name'] ?>' }, |
| 6 | - { parameters: arguments<?php foreach($aMethod['config'] as $sKey => $sValue): ?>, <?php echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> } |
|
| 6 | + { parameters: arguments<?php foreach ($aMethod['config'] as $sKey => $sValue): ?>, <?php echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> } |
|
| 7 | 7 | ); |
| 8 | 8 | }; |
| 9 | 9 | <?php endforeach ?> |