1 | <?php |
||
27 | class Request extends JsCall |
||
28 | { |
||
29 | /** |
||
30 | * A condition to check before sending this request |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $sCondition = null; |
||
35 | |||
36 | /** |
||
37 | * The arguments of the confirm() call |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $aMessageArgs = []; |
||
42 | |||
43 | /** |
||
44 | * The constructor. |
||
45 | * |
||
46 | * @param string $sName The javascript function or method name |
||
47 | */ |
||
48 | public function __construct($sName) |
||
52 | |||
53 | /** |
||
54 | * Add a condition to the request |
||
55 | * |
||
56 | * The request is sent only if the condition is true. |
||
57 | * |
||
58 | * @param string $sCondition The condition to check |
||
59 | * |
||
60 | * @return Request |
||
61 | */ |
||
62 | public function when($sCondition) |
||
67 | |||
68 | /** |
||
69 | * Add a condition to the request |
||
70 | * |
||
71 | * The request is sent only if the condition is false. |
||
72 | * |
||
73 | * @param string $sCondition The condition to check |
||
74 | * |
||
75 | * @return Request |
||
76 | */ |
||
77 | public function unless($sCondition) |
||
82 | |||
83 | /** |
||
84 | * Check if a value is equal to another before sending the request |
||
85 | * |
||
86 | * @param string $sValue1 The first value to compare |
||
87 | * @param string $sValue2 The second value to compare |
||
88 | * |
||
89 | * @return Request |
||
90 | */ |
||
91 | public function ifeq($sValue1, $sValue2) |
||
96 | |||
97 | /** |
||
98 | * Check if a value is not equal to another before sending the request |
||
99 | * |
||
100 | * @param string $sValue1 The first value to compare |
||
101 | * @param string $sValue2 The second value to compare |
||
102 | * |
||
103 | * @return Request |
||
104 | */ |
||
105 | public function ifne($sValue1, $sValue2) |
||
110 | |||
111 | /** |
||
112 | * Check if a value is greater than another before sending the request |
||
113 | * |
||
114 | * @param string $sValue1 The first value to compare |
||
115 | * @param string $sValue2 The second value to compare |
||
116 | * |
||
117 | * @return Request |
||
118 | */ |
||
119 | public function ifgt($sValue1, $sValue2) |
||
124 | |||
125 | /** |
||
126 | * Check if a value is greater or equal to another before sending the request |
||
127 | * |
||
128 | * @param string $sValue1 The first value to compare |
||
129 | * @param string $sValue2 The second value to compare |
||
130 | * |
||
131 | * @return Request |
||
132 | */ |
||
133 | public function ifge($sValue1, $sValue2) |
||
138 | |||
139 | /** |
||
140 | * Check if a value is lower than another before sending the request |
||
141 | * |
||
142 | * @param string $sValue1 The first value to compare |
||
143 | * @param string $sValue2 The second value to compare |
||
144 | * |
||
145 | * @return Request |
||
146 | */ |
||
147 | public function iflt($sValue1, $sValue2) |
||
152 | |||
153 | /** |
||
154 | * Check if a value is lower or equal to another before sending the request |
||
155 | * |
||
156 | * @param string $sValue1 The first value to compare |
||
157 | * @param string $sValue2 The second value to compare |
||
158 | * |
||
159 | * @return Request |
||
160 | */ |
||
161 | public function ifle($sValue1, $sValue2) |
||
166 | |||
167 | /** |
||
168 | * Create parameters for message arguments |
||
169 | * |
||
170 | * @param array $aArgs The arguments |
||
171 | * |
||
172 | * @return void |
||
173 | */ |
||
174 | private function setMessageArgs(array $aArgs) |
||
181 | |||
182 | /** |
||
183 | * Add a confirmation question to the request |
||
184 | * |
||
185 | * @param string $sQuestion The question to ask |
||
186 | * |
||
187 | * @return Request |
||
188 | */ |
||
189 | public function confirm($sQuestion) |
||
195 | |||
196 | /** |
||
197 | * Set the message to show if the condition to send the request is not met |
||
198 | * |
||
199 | * The first parameter is the message to show. The followin allow to insert data from |
||
200 | * the webpage in the message using positional placeholders. |
||
201 | * |
||
202 | * @param string $sMessage The message to show if the request is not sent |
||
203 | * |
||
204 | * @return Request |
||
205 | */ |
||
206 | public function elseShow($sMessage) |
||
211 | |||
212 | /** |
||
213 | * Make unique js vars for parameters of type DomElement |
||
214 | * |
||
215 | * @var ParameterContract $xParameter |
||
216 | * @var array &$aVariables |
||
217 | * @var string &$sVars |
||
218 | * @var integer &$nVarId |
||
219 | * |
||
220 | * @return ParameterContract |
||
221 | */ |
||
222 | private function _makeUniqueJsVar(ParameterContract $xParameter, array &$aVariables, &$sVars, &$nVarId) |
||
244 | |||
245 | /** |
||
246 | * Returns a string representation of the script output (javascript) from this request object |
||
247 | * |
||
248 | * @return string |
||
249 | */ |
||
250 | public function getScript() |
||
304 | |||
305 | /** |
||
306 | * Prints a string representation of the script output (javascript) from this request object |
||
307 | * |
||
308 | * @return void |
||
309 | */ |
||
310 | public function printScript() |
||
314 | |||
315 | /** |
||
316 | * Check if the request has a parameter of type Parameter::PAGE_NUMBER |
||
317 | * |
||
318 | * @return boolean |
||
319 | */ |
||
320 | public function hasPageNumber() |
||
331 | |||
332 | /** |
||
333 | * Set a value to the Parameter::PAGE_NUMBER parameter |
||
334 | * |
||
335 | * @param integer $nPageNumber The current page number |
||
336 | * |
||
337 | * @return Request |
||
338 | */ |
||
339 | public function setPageNumber($nPageNumber) |
||
352 | |||
353 | /** |
||
354 | * Make the pagination links for this request |
||
355 | * |
||
356 | * @param integer $nCurrentPage The current page |
||
357 | * @param integer $nItemsPerPage The number of items per page page |
||
358 | * @param integer $nItemsTotal The total number of items |
||
359 | * |
||
360 | * @return \Jaxon\Utils\Pagination\Paginator |
||
361 | */ |
||
362 | public function pg($nCurrentPage, $nItemsPerPage, $nItemsTotal) |
||
367 | |||
368 | /** |
||
369 | * Make the pagination links for this request |
||
370 | * |
||
371 | * @param integer $nCurrentPage The current page |
||
372 | * @param integer $nItemsPerPage The number of items per page page |
||
373 | * @param integer $nItemsTotal The total number of items |
||
374 | * |
||
375 | * @return \Jaxon\Utils\Pagination\Paginator |
||
376 | */ |
||
377 | public function paginate($nCurrentPage, $nItemsPerPage, $nItemsTotal) |
||
381 | } |
||
382 |