1 | <?php |
||
16 | class Parameter implements Contracts\Parameter |
||
17 | { |
||
18 | /* |
||
19 | * Request parameters |
||
20 | */ |
||
21 | // Specifies that the parameter will consist of an array of form values. |
||
22 | const FORM_VALUES = 'FormValues'; |
||
23 | // Specifies that the parameter will contain the value of an input control. |
||
24 | const INPUT_VALUE = 'InputValue'; |
||
25 | // Specifies that the parameter will consist of a boolean value of a checkbox. |
||
26 | const CHECKED_VALUE = 'CheckedValue'; |
||
27 | // Specifies that the parameter value will be the innerHTML value of the element. |
||
28 | const ELEMENT_INNERHTML = 'ElementInnerHTML'; |
||
29 | // Specifies that the parameter will be a quoted value (string). |
||
30 | const QUOTED_VALUE = 'QuotedValue'; |
||
31 | // Specifies that the parameter will be a boolean value (true or false). |
||
32 | const BOOL_VALUE = 'BoolValue'; |
||
33 | // Specifies that the parameter will be a numeric, non-quoted value. |
||
34 | const NUMERIC_VALUE = 'NumericValue'; |
||
35 | // Specifies that the parameter will be a non-quoted value |
||
36 | // (evaluated by the browsers javascript engine at run time). |
||
37 | const JS_VALUE = 'UnquotedValue'; |
||
38 | // Specifies that the parameter will be an integer used to generate pagination links. |
||
39 | const PAGE_NUMBER = 'PageNumber'; |
||
40 | |||
41 | /** |
||
42 | * The parameter type |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $sType; |
||
47 | |||
48 | /** |
||
49 | * The parameter value |
||
50 | * |
||
51 | * @var mixed |
||
52 | */ |
||
53 | protected $xValue; |
||
54 | |||
55 | /** |
||
56 | * The constructor. |
||
57 | * |
||
58 | * @param string $sType The parameter type |
||
59 | * @param mixed $xValue The parameter value |
||
60 | */ |
||
61 | public function __construct($sType, $xValue) |
||
66 | |||
67 | /** |
||
68 | * Get the parameter type |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | public function getType() |
||
76 | |||
77 | /** |
||
78 | * Get the parameter value |
||
79 | * |
||
80 | * @return mixed |
||
81 | */ |
||
82 | public function getValue() |
||
86 | |||
87 | /** |
||
88 | * Set the parameter value |
||
89 | * |
||
90 | * @param mixed $xValue The parameter value |
||
91 | * |
||
92 | * @return void |
||
93 | */ |
||
94 | public function setValue($xValue) |
||
98 | |||
99 | /** |
||
100 | * Create a Parameter instance using the given value |
||
101 | * |
||
102 | * @param mixed $xValue The parameter value |
||
103 | * |
||
104 | * @return Parameter |
||
105 | */ |
||
106 | public static function make($xValue) |
||
129 | |||
130 | /** |
||
131 | * Add quotes to a given value |
||
132 | * |
||
133 | * @param string $xValue The value to be quoted |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | private function getQuotedValue($xValue) |
||
142 | |||
143 | /** |
||
144 | * Get a js call to Jaxon with a single parameter |
||
145 | * |
||
146 | * @param string $sFunction The function name |
||
147 | * @param string $sParameter The function parameter |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | private function getJsCall($sFunction, $sParameter) |
||
155 | |||
156 | /** |
||
157 | * Get the script for an array of form values. |
||
158 | * |
||
159 | * @return string |
||
160 | */ |
||
161 | protected function getFormValuesScript() |
||
165 | |||
166 | /** |
||
167 | * Get the script for an input control. |
||
168 | * |
||
169 | * @return string |
||
170 | */ |
||
171 | protected function getInputValueScript() |
||
175 | |||
176 | /** |
||
177 | * Get the script for a boolean value of a checkbox. |
||
178 | * |
||
179 | * @return string |
||
180 | */ |
||
181 | protected function getCheckedValueScript() |
||
185 | |||
186 | /** |
||
187 | * Get the script for the innerHTML value of the element. |
||
188 | * |
||
189 | * @return string |
||
190 | */ |
||
191 | protected function getElementInnerHTMLScript() |
||
195 | |||
196 | /** |
||
197 | * Get the script for a quoted value (string). |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | protected function getQuotedValueScript() |
||
205 | |||
206 | /** |
||
207 | * Get the script for a boolean value (true or false). |
||
208 | * |
||
209 | * @return string |
||
210 | */ |
||
211 | protected function getBoolValueScript() |
||
215 | |||
216 | /** |
||
217 | * Get the script for a numeric, non-quoted value. |
||
218 | * |
||
219 | * @return string |
||
220 | */ |
||
221 | protected function getNumericValueScript() |
||
225 | |||
226 | /** |
||
227 | * Get the script for a non-quoted value (evaluated by the browsers javascript engine at run time). |
||
228 | * |
||
229 | * @return string |
||
230 | */ |
||
231 | protected function getUnquotedValueScript() |
||
241 | |||
242 | /** |
||
243 | * Get the script for an integer used to generate pagination links. |
||
244 | * |
||
245 | * @return string |
||
246 | */ |
||
247 | protected function getPageNumberScript() |
||
251 | |||
252 | /** |
||
253 | * Generate the javascript code. |
||
254 | * |
||
255 | * @return string |
||
256 | */ |
||
257 | public function getScript() |
||
266 | |||
267 | /** |
||
268 | * Magic function to generate the jQuery call. |
||
269 | * |
||
270 | * @return string |
||
271 | */ |
||
272 | public function __toString() |
||
276 | |||
277 | /** |
||
278 | * Generate the jQuery call, when converting the response into json. |
||
279 | * |
||
280 | * This is a method of the JsonSerializable interface. |
||
281 | * |
||
282 | * @return string |
||
283 | */ |
||
284 | public function jsonSerialize() |
||
288 | } |
||
289 |