@@ -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; |
@@ -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\Request\Factory\Contracts\Parameter as ParameterContract; |
| 26 | 25 | use Jaxon\Response\Plugin\JQuery\Dom\Element as DomElement; |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function hasPageNumber() |
| 55 | 55 | { |
| 56 | - foreach($this->aParameters as $xParameter) |
|
| 56 | + foreach ($this->aParameters as $xParameter) |
|
| 57 | 57 | { |
| 58 | - if($xParameter->getType() == Parameter::PAGE_NUMBER) |
|
| 58 | + if ($xParameter->getType() == Parameter::PAGE_NUMBER) |
|
| 59 | 59 | { |
| 60 | 60 | return true; |
| 61 | 61 | } |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | public function setPageNumber($nPageNumber) |
| 74 | 74 | { |
| 75 | 75 | // Set the value of the Parameter::PAGE_NUMBER parameter |
| 76 | - foreach($this->aParameters as $xParameter) |
|
| 76 | + foreach ($this->aParameters as $xParameter) |
|
| 77 | 77 | { |
| 78 | - if($xParameter->getType() == Parameter::PAGE_NUMBER) |
|
| 78 | + if ($xParameter->getType() == Parameter::PAGE_NUMBER) |
|
| 79 | 79 | { |
| 80 | 80 | $xParameter->setValue(intval($nPageNumber)); |
| 81 | 81 | break; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | private function setMessageArgs(array $aArgs) |
| 95 | 95 | { |
| 96 | - array_walk($aArgs, function (&$xParameter) { |
|
| 96 | + array_walk($aArgs, function(&$xParameter) { |
|
| 97 | 97 | $xParameter = Parameter::make($xParameter); |
| 98 | 98 | }); |
| 99 | 99 | $this->aMessageArgs = $aArgs; |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | private function _makeUniqueJsVar(ParameterContract $xParameter, array &$aVariables, &$sVars, &$nVarId) |
| 143 | 143 | { |
| 144 | - if($xParameter instanceof DomElement) |
|
| 144 | + if ($xParameter instanceof DomElement) |
|
| 145 | 145 | { |
| 146 | 146 | $sParameterStr = $xParameter->getScript(); |
| 147 | - if(!array_key_exists($sParameterStr, $aVariables)) |
|
| 147 | + if (!array_key_exists($sParameterStr, $aVariables)) |
|
| 148 | 148 | { |
| 149 | 149 | // The value is not yet defined. A new variable is created. |
| 150 | 150 | $sVarName = "jxnVar$nVarId"; |
@@ -181,20 +181,20 @@ discard block |
||
| 181 | 181 | // This array will avoid declaring multiple variables with the same value. |
| 182 | 182 | // The array key is the variable value, while the array value is the variable name. |
| 183 | 183 | $aVariables = []; // Array of local variables. |
| 184 | - foreach($this->aParameters as &$xParameter) |
|
| 184 | + foreach ($this->aParameters as &$xParameter) |
|
| 185 | 185 | { |
| 186 | 186 | $xParameter = $this->_makeUniqueJsVar($xParameter, $aVariables, $sVars, $nVarId); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $sPhrase = ''; |
| 190 | - if(count($this->aMessageArgs) > 0) |
|
| 190 | + if (count($this->aMessageArgs) > 0) |
|
| 191 | 191 | { |
| 192 | 192 | $sPhrase = array_shift($this->aMessageArgs); // The first array entry is the question. |
| 193 | 193 | // $sPhrase = "'" . addslashes($sPhrase) . "'"; // Wrap the phrase with single quotes |
| 194 | - if(count($this->aMessageArgs) > 0) |
|
| 194 | + if (count($this->aMessageArgs) > 0) |
|
| 195 | 195 | { |
| 196 | 196 | $nParamId = 1; |
| 197 | - foreach($this->aMessageArgs as &$xParameter) |
|
| 197 | + foreach ($this->aMessageArgs as &$xParameter) |
|
| 198 | 198 | { |
| 199 | 199 | $xParameter = $this->_makeUniqueJsVar($xParameter, $aVariables, $sVars, $nVarId); |
| 200 | 200 | $xParameter = "'$nParamId':" . $xParameter->getScript(); |
@@ -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) . ';}'; |
@@ -151,8 +151,7 @@ discard block |
||
| 151 | 151 | $aVariables[$sParameterStr] = $sVarName; |
| 152 | 152 | $sVars .= "$sVarName=$xParameter;"; |
| 153 | 153 | $nVarId++; |
| 154 | - } |
|
| 155 | - else |
|
| 154 | + } else |
|
| 156 | 155 | { |
| 157 | 156 | // The value is already defined. The corresponding variable is assigned. |
| 158 | 157 | $sVarName = $aVariables[$sParameterStr]; |
@@ -209,8 +208,7 @@ discard block |
||
| 209 | 208 | if($this->sCondition == '__confirm__') |
| 210 | 209 | { |
| 211 | 210 | $sScript = $xDialog->confirm($sPhrase, $sScript, ''); |
| 212 | - } |
|
| 213 | - elseif($this->sCondition !== null) |
|
| 211 | + } elseif($this->sCondition !== null) |
|
| 214 | 212 | { |
| 215 | 213 | $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}'; |
| 216 | 214 | if(($sPhrase)) |
@@ -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 | } |
@@ -97,7 +97,7 @@ |
||
| 97 | 97 | */ |
| 98 | 98 | public function delete($sKey) |
| 99 | 99 | { |
| 100 | - if(key_exists($sKey, $_SESSION)) |
|
| 100 | + if (key_exists($sKey, $_SESSION)) |
|
| 101 | 101 | { |
| 102 | 102 | unset($_SESSION[$sKey]); |
| 103 | 103 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | protected function getPrevLink($xPaginator) |
| 48 | 48 | { |
| 49 | - if(!($sCall = $xPaginator->getPrevCall())) |
|
| 49 | + if (!($sCall = $xPaginator->getPrevCall())) |
|
| 50 | 50 | { |
| 51 | 51 | return $this->xRenderer->render('pagination::links/disabled', ['text' => $xPaginator->getPreviousText()]); |
| 52 | 52 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function getNextLink($xPaginator) |
| 65 | 65 | { |
| 66 | - if(!($sCall = $xPaginator->getNextCall())) |
|
| 66 | + if (!($sCall = $xPaginator->getNextCall())) |
|
| 67 | 67 | { |
| 68 | 68 | return $this->xRenderer->render('pagination::links/disabled', ['text' => $xPaginator->getNextText()]); |
| 69 | 69 | } |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | protected function getLinks($xPaginator) |
| 82 | 82 | { |
| 83 | 83 | $sLinks = ''; |
| 84 | - foreach($xPaginator->getPages() as $page) |
|
| 84 | + foreach ($xPaginator->getPages() as $page) |
|
| 85 | 85 | { |
| 86 | - if($page['call']) |
|
| 86 | + if ($page['call']) |
|
| 87 | 87 | { |
| 88 | 88 | $sTemplate = ($page['isCurrent'] ? 'pagination::links/current' : 'pagination::links/enabled'); |
| 89 | 89 | $sLinks .= $this->xRenderer->render($sTemplate, ['call' => $page['call'], 'text' => $page['num']]); |
@@ -87,8 +87,7 @@ |
||
| 87 | 87 | { |
| 88 | 88 | $sTemplate = ($page['isCurrent'] ? 'pagination::links/current' : 'pagination::links/enabled'); |
| 89 | 89 | $sLinks .= $this->xRenderer->render($sTemplate, ['call' => $page['call'], 'text' => $page['num']]); |
| 90 | - } |
|
| 91 | - else |
|
| 90 | + } else |
|
| 92 | 91 | { |
| 93 | 92 | $sLinks .= $this->xRenderer->render('pagination::links/disabled', ['text' => $page['num']]); |
| 94 | 93 | } |
@@ -26,13 +26,13 @@ |
||
| 26 | 26 | public static function read($sConfigFile) |
| 27 | 27 | { |
| 28 | 28 | $sConfigFile = realpath($sConfigFile); |
| 29 | - if(!is_readable($sConfigFile)) |
|
| 29 | + if (!is_readable($sConfigFile)) |
|
| 30 | 30 | { |
| 31 | 31 | throw new \Jaxon\Utils\Config\Exception\File(jaxon_trans('config.errors.file.access', ['path' => $sConfigFile])); |
| 32 | 32 | } |
| 33 | 33 | $sFileContent = file_get_contents($sConfigFile); |
| 34 | 34 | $aConfigOptions = json_decode($sFileContent, true); |
| 35 | - if(!is_array($aConfigOptions)) |
|
| 35 | + if (!is_array($aConfigOptions)) |
|
| 36 | 36 | { |
| 37 | 37 | throw new \Jaxon\Utils\Config\Exception\File(jaxon_trans('config.errors.file.content', ['path' => $sConfigFile])); |
| 38 | 38 | } |