1 | <?php |
||
27 | class Argument |
||
28 | { |
||
29 | use \Jaxon\Features\Config; |
||
30 | use \Jaxon\Features\Translator; |
||
31 | |||
32 | /* |
||
33 | * Request methods |
||
34 | */ |
||
35 | const METHOD_UNKNOWN = 0; |
||
36 | const METHOD_GET = 1; |
||
37 | const METHOD_POST = 2; |
||
38 | |||
39 | /** |
||
40 | * An array of arguments received via the GET or POST parameter jxnargs. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | private $aArgs; |
||
45 | |||
46 | /** |
||
47 | * Stores the method that was used to send the arguments from the client. |
||
48 | * Will be one of: self::METHOD_UNKNOWN, self::METHOD_GET, self::METHOD_POST. |
||
49 | * |
||
50 | * @var integer |
||
51 | */ |
||
52 | private $nMethod; |
||
53 | |||
54 | /** |
||
55 | * The function which decodes utf8 string. |
||
56 | * |
||
57 | * @var callable |
||
58 | */ |
||
59 | private $cUtf8Decoder; |
||
60 | |||
61 | /** |
||
62 | * The constructor |
||
63 | * |
||
64 | * Get and decode the arguments of the HTTP request |
||
65 | */ |
||
66 | public function __construct() |
||
82 | |||
83 | /** |
||
84 | * Return the method that was used to send the arguments from the client |
||
85 | * |
||
86 | * The method is one of: self::METHOD_UNKNOWN, self::METHOD_GET, self::METHOD_POST. |
||
87 | * |
||
88 | * @return integer |
||
89 | */ |
||
90 | public function getRequestMethod() |
||
94 | |||
95 | /** |
||
96 | * Converts a string to a boolean var |
||
97 | * |
||
98 | * @param string $sValue The string to be converted |
||
99 | * |
||
100 | * @return boolean |
||
101 | */ |
||
102 | private function __convertStringToBool($sValue) |
||
122 | |||
123 | /** |
||
124 | * Strip the slashes from a string |
||
125 | * |
||
126 | * @param string $sArg The string to be stripped |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | // private function __argumentStripSlashes(&$sArg) |
||
131 | // { |
||
132 | // if(!is_string($sArg)) |
||
133 | // { |
||
134 | // return ''; |
||
135 | // } |
||
136 | // $sArg = stripslashes($sArg); |
||
137 | // return $sArg; |
||
138 | // } |
||
139 | |||
140 | /** |
||
141 | * Convert an Jaxon request argument to its value |
||
142 | * |
||
143 | * Depending of its first char, the Jaxon request argument is converted to a given type. |
||
144 | * |
||
145 | * @param string $sValue The keys of the options in the file |
||
146 | * |
||
147 | * @return string|boolean|integer|double|null |
||
148 | */ |
||
149 | private function __convertValue($sValue) |
||
171 | |||
172 | /** |
||
173 | * Decode and convert an Jaxon request argument from JSON |
||
174 | * |
||
175 | * @param string $sArg The Jaxon request argument |
||
176 | * |
||
177 | * @return string|null |
||
178 | */ |
||
179 | private function __argumentDecode(&$sArg) |
||
214 | |||
215 | /** |
||
216 | * Decode an Jaxon request argument from UTF8 |
||
217 | * |
||
218 | * @param array $aDst An array to store the decoded arguments |
||
219 | * @param string $sKey The key of the argument being decoded |
||
220 | * @param string|array $mValue The value of the argument being decoded |
||
221 | * |
||
222 | * @return void |
||
223 | */ |
||
224 | private function _decode_utf8_argument(array &$aDst, $sKey, $mValue) |
||
250 | |||
251 | /** |
||
252 | * Return the array of arguments that were extracted and parsed from the GET or POST data |
||
253 | * |
||
254 | * @return array |
||
255 | */ |
||
256 | public function process() |
||
305 | } |
||
306 |