@@ -14,18 +14,18 @@ |
||
| 14 | 14 | jaxon.config.defaultMode = "<?php echo $this->sDefaultMode ?>"; |
| 15 | 15 | jaxon.config.defaultMethod = "<?php echo $this->sDefaultMethod ?>"; |
| 16 | 16 | jaxon.config.responseType = "<?php echo $this->sResponseType ?>"; |
| 17 | -<?php if($this->nResponseQueueSize > 0): ?> |
|
| 17 | +<?php if ($this->nResponseQueueSize > 0): ?> |
|
| 18 | 18 | jaxon.config.responseQueueSize = <?php echo $this->nResponseQueueSize ?>; |
| 19 | 19 | <?php endif ?> |
| 20 | -<?php if(($this->bDebug)): ?> |
|
| 21 | -<?php if(($this->sDebugOutputID)): ?> |
|
| 20 | +<?php if (($this->bDebug)): ?> |
|
| 21 | +<?php if (($this->sDebugOutputID)): ?> |
|
| 22 | 22 | jaxon.debug.outputID = "<?php echo $this->sDebugOutputID ?>"; |
| 23 | 23 | <?php endif ?> |
| 24 | -<?php if(($this->bVerboseDebug)): ?> |
|
| 24 | +<?php if (($this->bVerboseDebug)): ?> |
|
| 25 | 25 | jaxon.debug.verbose.active = true; |
| 26 | 26 | <?php endif ?> |
| 27 | 27 | <?php endif ?> |
| 28 | -<?php if(($this->sCsrfMetaName)): ?> |
|
| 28 | +<?php if (($this->sCsrfMetaName)): ?> |
|
| 29 | 29 | metaTags = document.getElementsByTagName('meta'); |
| 30 | 30 | for(i = 0; i < metaTags.length; i++) |
| 31 | 31 | { |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | $this->aCalls = []; |
| 59 | 59 | |
| 60 | 60 | $jQueryNs = jaxon()->getOption('core.jquery.no_conflict', false) ? 'jQuery' : '$'; |
| 61 | - if(!$sSelector) |
|
| 61 | + if (!$sSelector) |
|
| 62 | 62 | { |
| 63 | 63 | $this->sSelector = "$jQueryNs(this)"; // If an empty selector is given, use javascript "this" instead |
| 64 | 64 | } |
| 65 | - elseif(($sContext)) |
|
| 65 | + elseif (($sContext)) |
|
| 66 | 66 | { |
| 67 | 67 | $this->sSelector = "$jQueryNs('" . $sSelector . "', $jQueryNs('" . $sContext . "'))"; |
| 68 | 68 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function getScript() |
| 120 | 120 | { |
| 121 | - if(count($this->aCalls) == 0) |
|
| 121 | + if (count($this->aCalls) == 0) |
|
| 122 | 122 | { |
| 123 | 123 | return $this->sSelector; |
| 124 | 124 | } |
@@ -57,12 +57,10 @@ |
||
| 57 | 57 | if(!$sSelector) |
| 58 | 58 | { |
| 59 | 59 | $this->sSelector = "$jQueryNs(this)"; // If an empty selector is given, use javascript "this" instead |
| 60 | - } |
|
| 61 | - elseif(($sContext)) |
|
| 60 | + } elseif(($sContext)) |
|
| 62 | 61 | { |
| 63 | 62 | $this->sSelector = "$jQueryNs('" . $sSelector . "', $jQueryNs('" . $sContext . "'))"; |
| 64 | - } |
|
| 65 | - else |
|
| 63 | + } else |
|
| 66 | 64 | { |
| 67 | 65 | $this->sSelector = "$jQueryNs('" . $sSelector . "')"; |
| 68 | 66 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | public function render($sPath, array $aVars = []) |
| 28 | 28 | { |
| 29 | 29 | // Make the template vars available as attributes |
| 30 | - foreach($aVars as $sName => $xValue) |
|
| 30 | + foreach ($aVars as $sName => $xValue) |
|
| 31 | 31 | { |
| 32 | 32 | $sName = (string)$sName; |
| 33 | 33 | $this->$sName = $xValue; |
@@ -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)) |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param integer $nItemsPerPage The number of items per page page |
| 240 | 240 | * @param integer $nItemsTotal The total number of items |
| 241 | 241 | * |
| 242 | - * @return Paginator |
|
| 242 | + * @return \Jaxon\Utils\Pagination\Paginator |
|
| 243 | 243 | */ |
| 244 | 244 | public function pg($nCurrentPage, $nItemsPerPage, $nItemsTotal) |
| 245 | 245 | { |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @param integer $nItemsPerPage The number of items per page page |
| 255 | 255 | * @param integer $nItemsTotal The total number of items |
| 256 | 256 | * |
| 257 | - * @return Paginator |
|
| 257 | + * @return \Jaxon\Utils\Pagination\Paginator |
|
| 258 | 258 | */ |
| 259 | 259 | public function paginate($nCurrentPage, $nItemsPerPage, $nItemsTotal) |
| 260 | 260 | { |
@@ -20,7 +20,6 @@ |
||
| 20 | 20 | |
| 21 | 21 | namespace Jaxon\Request\Factory; |
| 22 | 22 | |
| 23 | -use JsonSerializable; |
|
| 24 | 23 | use Jaxon\Request\Factory\Parameter; |
| 25 | 24 | use Jaxon\Response\Plugin\JQuery\Dom\Element as DomElement; |
| 26 | 25 | |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function hasPageNumber() |
| 54 | 54 | { |
| 55 | - foreach($this->aParameters as $xParameter) |
|
| 55 | + foreach ($this->aParameters as $xParameter) |
|
| 56 | 56 | { |
| 57 | - if($xParameter->getType() == Parameter::PAGE_NUMBER) |
|
| 57 | + if ($xParameter->getType() == Parameter::PAGE_NUMBER) |
|
| 58 | 58 | { |
| 59 | 59 | return true; |
| 60 | 60 | } |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | public function setPageNumber($nPageNumber) |
| 73 | 73 | { |
| 74 | 74 | // Set the value of the Parameter::PAGE_NUMBER parameter |
| 75 | - foreach($this->aParameters as $xParameter) |
|
| 75 | + foreach ($this->aParameters as $xParameter) |
|
| 76 | 76 | { |
| 77 | - if($xParameter->getType() == Parameter::PAGE_NUMBER) |
|
| 77 | + if ($xParameter->getType() == Parameter::PAGE_NUMBER) |
|
| 78 | 78 | { |
| 79 | 79 | $xParameter->setValue(intval($nPageNumber)); |
| 80 | 80 | break; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | private function setMessageArgs(array $aArgs) |
| 94 | 94 | { |
| 95 | - array_walk($aArgs, function (&$xParameter) { |
|
| 95 | + array_walk($aArgs, function(&$xParameter) { |
|
| 96 | 96 | $xParameter = Parameter::make($xParameter); |
| 97 | 97 | }); |
| 98 | 98 | $this->aMessageArgs = $aArgs; |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | // This array will avoid declaring multiple variables with the same value. |
| 148 | 148 | // The array key is the variable value, while the array value is the variable name. |
| 149 | 149 | $aVariables = []; // Array of local variables. |
| 150 | - foreach($this->aParameters as &$xParameter) |
|
| 150 | + foreach ($this->aParameters as &$xParameter) |
|
| 151 | 151 | { |
| 152 | 152 | $sParameterStr = $xParameter->getScript(); |
| 153 | - if($xParameter instanceof DomElement) |
|
| 153 | + if ($xParameter instanceof DomElement) |
|
| 154 | 154 | { |
| 155 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
| 155 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
| 156 | 156 | { |
| 157 | 157 | // The value is not yet defined. A new variable is created. |
| 158 | 158 | $sVarName = "jxnVar$nVarId"; |
@@ -170,19 +170,19 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $sPhrase = ''; |
| 173 | - if(count($this->aMessageArgs) > 0) |
|
| 173 | + if (count($this->aMessageArgs) > 0) |
|
| 174 | 174 | { |
| 175 | 175 | $sPhrase = array_shift($this->aMessageArgs); // The first array entry is the question. |
| 176 | 176 | // $sPhrase = "'" . addslashes($sPhrase) . "'"; // Wrap the phrase with single quotes |
| 177 | - if(count($this->aMessageArgs) > 0) |
|
| 177 | + if (count($this->aMessageArgs) > 0) |
|
| 178 | 178 | { |
| 179 | 179 | $nParamId = 1; |
| 180 | - foreach($this->aMessageArgs as &$xParameter) |
|
| 180 | + foreach ($this->aMessageArgs as &$xParameter) |
|
| 181 | 181 | { |
| 182 | 182 | $sParameterStr = $xParameter->getScript(); |
| 183 | - if($xParameter instanceof DomElement) |
|
| 183 | + if ($xParameter instanceof DomElement) |
|
| 184 | 184 | { |
| 185 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
| 185 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
| 186 | 186 | { |
| 187 | 187 | // The value is not yet defined. A new variable is created. |
| 188 | 188 | $sVarName = "jxnVar$nVarId"; |
@@ -206,14 +206,14 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | $sScript = parent::getScript(); |
| 208 | 208 | $xDialog = jaxon()->dialog(); |
| 209 | - if($this->sCondition == '__confirm__') |
|
| 209 | + if ($this->sCondition == '__confirm__') |
|
| 210 | 210 | { |
| 211 | 211 | $sScript = $xDialog->confirm($sPhrase, $sScript, ''); |
| 212 | 212 | } |
| 213 | - elseif($this->sCondition !== null) |
|
| 213 | + elseif ($this->sCondition !== null) |
|
| 214 | 214 | { |
| 215 | 215 | $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}'; |
| 216 | - if(($sPhrase)) |
|
| 216 | + if (($sPhrase)) |
|
| 217 | 217 | { |
| 218 | 218 | $xDialog->getAlert()->setReturn(true); |
| 219 | 219 | $sScript .= 'else{' . $xDialog->warning($sPhrase) . ';}'; |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | /** |
| 60 | 60 | * Process an incoming Jaxon request, and return the response. |
| 61 | 61 | * |
| 62 | - * @return void |
|
| 62 | + * @return boolean|null |
|
| 63 | 63 | */ |
| 64 | 64 | public function processRequest() |
| 65 | 65 | { |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function setup($sConfigFile) |
| 30 | 30 | { |
| 31 | - if(!file_exists($sConfigFile)) |
|
| 31 | + if (!file_exists($sConfigFile)) |
|
| 32 | 32 | { |
| 33 | 33 | throw new Exception("Unable to find config file at $sConfigFile"); |
| 34 | 34 | } |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | $aLibOptions = key_exists('lib', $aOptions) ? $aOptions['lib'] : []; |
| 39 | 39 | $aAppOptions = key_exists('app', $aOptions) ? $aOptions['app'] : []; |
| 40 | 40 | |
| 41 | - if(!is_array($aLibOptions) || !is_array($aAppOptions)) |
|
| 41 | + if (!is_array($aLibOptions) || !is_array($aAppOptions)) |
|
| 42 | 42 | { |
| 43 | 43 | throw new Exception("Unexpected content in config file at $sConfigFile"); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // Set the session manager |
| 47 | - jaxon()->di()->setSessionManager(function () { |
|
| 47 | + jaxon()->di()->setSessionManager(function() { |
|
| 48 | 48 | return new SessionManager(); |
| 49 | 49 | }); |
| 50 | 50 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @param string|null $sClass The callable class |
| 55 | 55 | * |
| 56 | - * @return Factory |
|
| 56 | + * @return RequestFactory |
|
| 57 | 57 | */ |
| 58 | 58 | public function setClassName($sClass) |
| 59 | 59 | { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @param CallableObject $xCallable The callable object |
| 82 | 82 | * |
| 83 | - * @return Factory |
|
| 83 | + * @return RequestFactory |
|
| 84 | 84 | */ |
| 85 | 85 | public function setCallable(CallableObject $xCallable) |
| 86 | 86 | { |
@@ -93,7 +93,6 @@ discard block |
||
| 93 | 93 | * Return the javascript call to a Jaxon function or object method |
| 94 | 94 | * |
| 95 | 95 | * @param string $sFunction The function or method (without class) name |
| 96 | - * @param ... $xParams The parameters of the function or method |
|
| 97 | 96 | * |
| 98 | 97 | * @return Request |
| 99 | 98 | */ |
@@ -122,7 +121,6 @@ discard block |
||
| 122 | 121 | * Return the javascript call to a generic function |
| 123 | 122 | * |
| 124 | 123 | * @param string $sFunction The function or method (with class) name |
| 125 | - * @param ... $xParams The parameters of the function or method |
|
| 126 | 124 | * |
| 127 | 125 | * @return Request |
| 128 | 126 | */ |
@@ -17,7 +17,6 @@ |
||
| 17 | 17 | |
| 18 | 18 | use Jaxon\Request\Support\CallableObject; |
| 19 | 19 | use Jaxon\Request\Support\CallableRepository; |
| 20 | -use Jaxon\Utils\Pagination\Paginator; |
|
| 21 | 20 | |
| 22 | 21 | // Extends Parameter for compatibility with older versions (see function rq()) |
| 23 | 22 | class RequestFactory |
@@ -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'); |
@@ -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 | } |
@@ -58,17 +58,17 @@ discard block |
||
| 58 | 58 | $this->aArgs = []; |
| 59 | 59 | $this->nMethod = self::METHOD_UNKNOWN; |
| 60 | 60 | |
| 61 | - if(isset($_POST['jxnargs'])) |
|
| 61 | + if (isset($_POST['jxnargs'])) |
|
| 62 | 62 | { |
| 63 | 63 | $this->nMethod = self::METHOD_POST; |
| 64 | 64 | $this->aArgs = $_POST['jxnargs']; |
| 65 | 65 | } |
| 66 | - elseif(isset($_GET['jxnargs'])) |
|
| 66 | + elseif (isset($_GET['jxnargs'])) |
|
| 67 | 67 | { |
| 68 | 68 | $this->nMethod = self::METHOD_GET; |
| 69 | 69 | $this->aArgs = $_GET['jxnargs']; |
| 70 | 70 | } |
| 71 | - if(get_magic_quotes_gpc() == 1) |
|
| 71 | + if (get_magic_quotes_gpc() == 1) |
|
| 72 | 72 | { |
| 73 | 73 | array_walk($this->aArgs, [&$this, '__argumentStripSlashes']); |
| 74 | 74 | } |
@@ -84,17 +84,17 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | private function __convertStringToBool($sValue) |
| 86 | 86 | { |
| 87 | - if(strcasecmp($sValue, 'true') == 0) |
|
| 87 | + if (strcasecmp($sValue, 'true') == 0) |
|
| 88 | 88 | { |
| 89 | 89 | return true; |
| 90 | 90 | } |
| 91 | - if(strcasecmp($sValue, 'false') == 0) |
|
| 91 | + if (strcasecmp($sValue, 'false') == 0) |
|
| 92 | 92 | { |
| 93 | 93 | return false; |
| 94 | 94 | } |
| 95 | - if(is_numeric($sValue)) |
|
| 95 | + if (is_numeric($sValue)) |
|
| 96 | 96 | { |
| 97 | - if($sValue == 0) |
|
| 97 | + if ($sValue == 0) |
|
| 98 | 98 | { |
| 99 | 99 | return false; |
| 100 | 100 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | private function __argumentStripSlashes(&$sArg) |
| 114 | 114 | { |
| 115 | - if(!is_string($sArg)) |
|
| 115 | + if (!is_string($sArg)) |
|
| 116 | 116 | { |
| 117 | 117 | return ''; |
| 118 | 118 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | private function __argumentDecode(&$sArg) |
| 162 | 162 | { |
| 163 | - if($sArg == '') |
|
| 163 | + if ($sArg == '') |
|
| 164 | 164 | { |
| 165 | 165 | return ''; |
| 166 | 166 | } |
@@ -169,22 +169,22 @@ discard block |
||
| 169 | 169 | $sType = 'multipart/form-data'; |
| 170 | 170 | $iLen = strlen($sType); |
| 171 | 171 | $sContentType = ''; |
| 172 | - if(key_exists('CONTENT_TYPE', $_SERVER)) |
|
| 172 | + if (key_exists('CONTENT_TYPE', $_SERVER)) |
|
| 173 | 173 | { |
| 174 | 174 | $sContentType = substr($_SERVER['CONTENT_TYPE'], 0, $iLen); |
| 175 | 175 | } |
| 176 | - elseif(key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
| 176 | + elseif (key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
| 177 | 177 | { |
| 178 | 178 | $sContentType = substr($_SERVER['HTTP_CONTENT_TYPE'], 0, $iLen); |
| 179 | 179 | } |
| 180 | - if($sContentType == $sType) |
|
| 180 | + if ($sContentType == $sType) |
|
| 181 | 181 | { |
| 182 | 182 | $sArg = urldecode($sArg); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | $data = json_decode($sArg, true); |
| 186 | 186 | |
| 187 | - if($data !== null && $sArg != $data) |
|
| 187 | + if ($data !== null && $sArg != $data) |
|
| 188 | 188 | { |
| 189 | 189 | $sArg = $data; |
| 190 | 190 | } |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | private function __argumentDecodeUTF8_iconv(&$mArg) |
| 205 | 205 | { |
| 206 | - if(is_array($mArg)) |
|
| 206 | + if (is_array($mArg)) |
|
| 207 | 207 | { |
| 208 | - foreach($mArg as $sKey => &$xArg) |
|
| 208 | + foreach ($mArg as $sKey => &$xArg) |
|
| 209 | 209 | { |
| 210 | 210 | $sNewKey = $sKey; |
| 211 | 211 | $this->__argumentDecodeUTF8_iconv($sNewKey); |
| 212 | - if($sNewKey != $sKey) |
|
| 212 | + if ($sNewKey != $sKey) |
|
| 213 | 213 | { |
| 214 | 214 | $mArg[$sNewKey] = $xArg; |
| 215 | 215 | unset($mArg[$sKey]); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $this->__argumentDecodeUTF8_iconv($xArg); |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | - elseif(is_string($mArg)) |
|
| 221 | + elseif (is_string($mArg)) |
|
| 222 | 222 | { |
| 223 | 223 | $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg); |
| 224 | 224 | } |
@@ -233,13 +233,13 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | private function __argumentDecodeUTF8_mb_convert_encoding(&$mArg) |
| 235 | 235 | { |
| 236 | - if(is_array($mArg)) |
|
| 236 | + if (is_array($mArg)) |
|
| 237 | 237 | { |
| 238 | - foreach($mArg as $sKey => &$xArg) |
|
| 238 | + foreach ($mArg as $sKey => &$xArg) |
|
| 239 | 239 | { |
| 240 | 240 | $sNewKey = $sKey; |
| 241 | 241 | $this->__argumentDecodeUTF8_mb_convert_encoding($sNewKey); |
| 242 | - if($sNewKey != $sKey) |
|
| 242 | + if ($sNewKey != $sKey) |
|
| 243 | 243 | { |
| 244 | 244 | $mArg[$sNewKey] = $xArg; |
| 245 | 245 | unset($mArg[$sKey]); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | $this->__argumentDecodeUTF8_mb_convert_encoding($xArg); |
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | - elseif(is_string($mArg)) |
|
| 251 | + elseif (is_string($mArg)) |
|
| 252 | 252 | { |
| 253 | 253 | $mArg = mb_convert_encoding($mArg, $this->getOption('core.encoding'), "UTF-8"); |
| 254 | 254 | } |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | private function __argumentDecodeUTF8_utf8_decode(&$mArg) |
| 265 | 265 | { |
| 266 | - if(is_array($mArg)) |
|
| 266 | + if (is_array($mArg)) |
|
| 267 | 267 | { |
| 268 | - foreach($mArg as $sKey => &$xArg) |
|
| 268 | + foreach ($mArg as $sKey => &$xArg) |
|
| 269 | 269 | { |
| 270 | 270 | $sNewKey = $sKey; |
| 271 | 271 | $this->__argumentDecodeUTF8_utf8_decode($sNewKey); |
| 272 | 272 | |
| 273 | - if($sNewKey != $sKey) |
|
| 273 | + if ($sNewKey != $sKey) |
|
| 274 | 274 | { |
| 275 | 275 | $mArg[$sNewKey] = $xArg; |
| 276 | 276 | unset($mArg[$sKey]); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $this->__argumentDecodeUTF8_utf8_decode($xArg); |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | - elseif(is_string($mArg)) |
|
| 283 | + elseif (is_string($mArg)) |
|
| 284 | 284 | { |
| 285 | 285 | $mArg = utf8_decode($mArg); |
| 286 | 286 | } |
@@ -305,19 +305,19 @@ discard block |
||
| 305 | 305 | */ |
| 306 | 306 | public function process() |
| 307 | 307 | { |
| 308 | - if(($this->getOption('core.decode_utf8'))) |
|
| 308 | + if (($this->getOption('core.decode_utf8'))) |
|
| 309 | 309 | { |
| 310 | 310 | $sFunction = ''; |
| 311 | 311 | |
| 312 | - if(function_exists('iconv')) |
|
| 312 | + if (function_exists('iconv')) |
|
| 313 | 313 | { |
| 314 | 314 | $sFunction = "iconv"; |
| 315 | 315 | } |
| 316 | - elseif(function_exists('mb_convert_encoding')) |
|
| 316 | + elseif (function_exists('mb_convert_encoding')) |
|
| 317 | 317 | { |
| 318 | 318 | $sFunction = "mb_convert_encoding"; |
| 319 | 319 | } |
| 320 | - elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
| 320 | + elseif ($this->getOption('core.encoding') == "ISO-8859-1") |
|
| 321 | 321 | { |
| 322 | 322 | $sFunction = "utf8_decode"; |
| 323 | 323 | } |
@@ -62,8 +62,7 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $this->nMethod = self::METHOD_POST; |
| 64 | 64 | $this->aArgs = $_POST['jxnargs']; |
| 65 | - } |
|
| 66 | - elseif(isset($_GET['jxnargs'])) |
|
| 65 | + } elseif(isset($_GET['jxnargs'])) |
|
| 67 | 66 | { |
| 68 | 67 | $this->nMethod = self::METHOD_GET; |
| 69 | 68 | $this->aArgs = $_GET['jxnargs']; |
@@ -172,8 +171,7 @@ discard block |
||
| 172 | 171 | if(key_exists('CONTENT_TYPE', $_SERVER)) |
| 173 | 172 | { |
| 174 | 173 | $sContentType = substr($_SERVER['CONTENT_TYPE'], 0, $iLen); |
| 175 | - } |
|
| 176 | - elseif(key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
| 174 | + } elseif(key_exists('HTTP_CONTENT_TYPE', $_SERVER)) |
|
| 177 | 175 | { |
| 178 | 176 | $sContentType = substr($_SERVER['HTTP_CONTENT_TYPE'], 0, $iLen); |
| 179 | 177 | } |
@@ -187,8 +185,7 @@ discard block |
||
| 187 | 185 | if($data !== null && $sArg != $data) |
| 188 | 186 | { |
| 189 | 187 | $sArg = $data; |
| 190 | - } |
|
| 191 | - else |
|
| 188 | + } else |
|
| 192 | 189 | { |
| 193 | 190 | $sArg = $this->__convertValue($sArg); |
| 194 | 191 | } |
@@ -217,8 +214,7 @@ discard block |
||
| 217 | 214 | } |
| 218 | 215 | $this->__argumentDecodeUTF8_iconv($xArg); |
| 219 | 216 | } |
| 220 | - } |
|
| 221 | - elseif(is_string($mArg)) |
|
| 217 | + } elseif(is_string($mArg)) |
|
| 222 | 218 | { |
| 223 | 219 | $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg); |
| 224 | 220 | } |
@@ -247,8 +243,7 @@ discard block |
||
| 247 | 243 | } |
| 248 | 244 | $this->__argumentDecodeUTF8_mb_convert_encoding($xArg); |
| 249 | 245 | } |
| 250 | - } |
|
| 251 | - elseif(is_string($mArg)) |
|
| 246 | + } elseif(is_string($mArg)) |
|
| 252 | 247 | { |
| 253 | 248 | $mArg = mb_convert_encoding($mArg, $this->getOption('core.encoding'), "UTF-8"); |
| 254 | 249 | } |
@@ -279,8 +274,7 @@ discard block |
||
| 279 | 274 | |
| 280 | 275 | $this->__argumentDecodeUTF8_utf8_decode($xArg); |
| 281 | 276 | } |
| 282 | - } |
|
| 283 | - elseif(is_string($mArg)) |
|
| 277 | + } elseif(is_string($mArg)) |
|
| 284 | 278 | { |
| 285 | 279 | $mArg = utf8_decode($mArg); |
| 286 | 280 | } |
@@ -312,16 +306,13 @@ discard block |
||
| 312 | 306 | if(function_exists('iconv')) |
| 313 | 307 | { |
| 314 | 308 | $sFunction = "iconv"; |
| 315 | - } |
|
| 316 | - elseif(function_exists('mb_convert_encoding')) |
|
| 309 | + } elseif(function_exists('mb_convert_encoding')) |
|
| 317 | 310 | { |
| 318 | 311 | $sFunction = "mb_convert_encoding"; |
| 319 | - } |
|
| 320 | - elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
| 312 | + } elseif($this->getOption('core.encoding') == "ISO-8859-1") |
|
| 321 | 313 | { |
| 322 | 314 | $sFunction = "utf8_decode"; |
| 323 | - } |
|
| 324 | - else |
|
| 315 | + } else |
|
| 325 | 316 | { |
| 326 | 317 | throw new \Jaxon\Exception\Error($this->trans('errors.request.conversion')); |
| 327 | 318 | } |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | * @param string $sCallableFunction The name of the function being registered |
| 91 | 91 | * @param array|string $aOptions The associated options |
| 92 | 92 | * |
| 93 | - * @return \Jaxon\Request\Request |
|
| 93 | + * @return boolean |
|
| 94 | 94 | */ |
| 95 | 95 | public function register($sType, $sCallableFunction, $aOptions) |
| 96 | 96 | { |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function __construct() |
| 51 | 51 | { |
| 52 | - if(isset($_GET['jxnfun'])) |
|
| 52 | + if (isset($_GET['jxnfun'])) |
|
| 53 | 53 | { |
| 54 | 54 | $this->sRequestedFunction = $_GET['jxnfun']; |
| 55 | 55 | } |
| 56 | - if(isset($_POST['jxnfun'])) |
|
| 56 | + if (isset($_POST['jxnfun'])) |
|
| 57 | 57 | { |
| 58 | 58 | $this->sRequestedFunction = $_POST['jxnfun']; |
| 59 | 59 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function getTarget() |
| 78 | 78 | { |
| 79 | - if(!$this->sRequestedFunction) |
|
| 79 | + if (!$this->sRequestedFunction) |
|
| 80 | 80 | { |
| 81 | 81 | return null; |
| 82 | 82 | } |
@@ -95,21 +95,21 @@ discard block |
||
| 95 | 95 | public function register($sType, $sCallableFunction, $aOptions) |
| 96 | 96 | { |
| 97 | 97 | $sType = trim($sType); |
| 98 | - if($sType != $this->getName()) |
|
| 98 | + if ($sType != $this->getName()) |
|
| 99 | 99 | { |
| 100 | 100 | return false; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if(!is_string($sCallableFunction)) |
|
| 103 | + if (!is_string($sCallableFunction)) |
|
| 104 | 104 | { |
| 105 | 105 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration')); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if(is_string($aOptions)) |
|
| 108 | + if (is_string($aOptions)) |
|
| 109 | 109 | { |
| 110 | 110 | $aOptions = ['include' => $aOptions]; |
| 111 | 111 | } |
| 112 | - if(!is_array($aOptions)) |
|
| 112 | + if (!is_array($aOptions)) |
|
| 113 | 113 | { |
| 114 | 114 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration')); |
| 115 | 115 | } |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | $sCallableFunction = trim($sCallableFunction); |
| 118 | 118 | // Check if an alias is defined |
| 119 | 119 | $sFunctionName = $sCallableFunction; |
| 120 | - foreach($aOptions as $sName => $sValue) |
|
| 120 | + foreach ($aOptions as $sName => $sValue) |
|
| 121 | 121 | { |
| 122 | - if($sName == 'alias') |
|
| 122 | + if ($sName == 'alias') |
|
| 123 | 123 | { |
| 124 | 124 | $sFunctionName = $sValue; |
| 125 | 125 | break; |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $this->aFunctions[$sFunctionName] = $aOptions; |
| 130 | - jaxon()->di()->set($sFunctionName, function () use ($sFunctionName, $sCallableFunction) { |
|
| 130 | + jaxon()->di()->set($sFunctionName, function() use ($sFunctionName, $sCallableFunction) { |
|
| 131 | 131 | $xCallableFunction = new \Jaxon\Request\Support\CallableFunction($sCallableFunction); |
| 132 | 132 | |
| 133 | 133 | $aOptions = $this->aFunctions[$sFunctionName]; |
| 134 | - foreach($aOptions as $sName => $sValue) |
|
| 134 | + foreach ($aOptions as $sName => $sValue) |
|
| 135 | 135 | { |
| 136 | 136 | $xCallableFunction->configure($sName, $sValue); |
| 137 | 137 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | { |
| 162 | 162 | $di = jaxon()->di(); |
| 163 | 163 | $code = ''; |
| 164 | - foreach(array_keys($this->aFunctions) as $sName) |
|
| 164 | + foreach (array_keys($this->aFunctions) as $sName) |
|
| 165 | 165 | { |
| 166 | 166 | $xFunction = $di->get($sName); |
| 167 | 167 | $code .= $xFunction->getScript(); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | public function canProcessRequest() |
| 178 | 178 | { |
| 179 | 179 | // Check the validity of the function name |
| 180 | - if(($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction)) |
|
| 180 | + if (($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction)) |
|
| 181 | 181 | { |
| 182 | 182 | $this->sRequestedFunction = null; |
| 183 | 183 | } |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function processRequest() |
| 193 | 193 | { |
| 194 | - if(!$this->canProcessRequest()) |
|
| 194 | + if (!$this->canProcessRequest()) |
|
| 195 | 195 | { |
| 196 | 196 | return false; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Security check: make sure the requested function was registered. |
| 200 | - if(!key_exists($this->sRequestedFunction, $this->aFunctions)) |
|
| 200 | + if (!key_exists($this->sRequestedFunction, $this->aFunctions)) |
|
| 201 | 201 | { |
| 202 | 202 | // Unable to find the requested function |
| 203 | 203 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid', |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $xFunction = $di->get($this->sRequestedFunction); |
| 209 | 209 | $aArgs = $di->getRequestHandler()->processArguments(); |
| 210 | 210 | $xResponse = $xFunction->call($aArgs); |
| 211 | - if(($xResponse)) |
|
| 211 | + if (($xResponse)) |
|
| 212 | 212 | { |
| 213 | 213 | $di->getResponseManager()->append($xResponse); |
| 214 | 214 | } |
@@ -41,6 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Set the path to the uploaded file |
| 44 | + * @param string $sUploadedFile |
|
| 44 | 45 | */ |
| 45 | 46 | public function setUploadedFile($sUploadedFile) |
| 46 | 47 | { |
@@ -49,6 +50,7 @@ discard block |
||
| 49 | 50 | |
| 50 | 51 | /** |
| 51 | 52 | * Set the error message |
| 53 | + * @param string $sErrorMessage |
|
| 52 | 54 | */ |
| 53 | 55 | public function setErrorMessage($sErrorMessage) |
| 54 | 56 | { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | $sCharacterSet = ''; |
| 88 | 88 | $sCharacterEncoding = trim($this->getOption('core.encoding')); |
| 89 | - if(($sCharacterEncoding) && strlen($sCharacterEncoding) > 0) |
|
| 89 | + if (($sCharacterEncoding) && strlen($sCharacterEncoding) > 0) |
|
| 90 | 90 | { |
| 91 | 91 | $sCharacterSet = '; charset="' . trim($sCharacterEncoding) . '"'; |
| 92 | 92 | } |
@@ -102,8 +102,7 @@ discard block |
||
| 102 | 102 | public function getOutput() |
| 103 | 103 | { |
| 104 | 104 | $aResponse = ($this->sUploadedFile) ? |
| 105 | - ['code' => 'success', 'upl' => $this->sUploadedFile] : |
|
| 106 | - ['code' => 'error', 'msg' => $this->sErrorMessage]; |
|
| 105 | + ['code' => 'success', 'upl' => $this->sUploadedFile] : ['code' => 'error', 'msg' => $this->sErrorMessage]; |
|
| 107 | 106 | return '<script>var res = ' . json_encode($aResponse) . '; </script>'; |
| 108 | 107 | } |
| 109 | 108 | |