This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Ajax\common\traits; |
||
4 | |||
5 | trait JqueryActionsTrait { |
||
6 | public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
||
7 | public abstract function _prep_element($element); |
||
8 | public abstract function _prep_value($value); |
||
9 | |||
10 | /** |
||
11 | * Get or set the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element. |
||
12 | * @param string $element |
||
13 | * @param string $attributeName |
||
14 | * @param string $value |
||
15 | * @param boolean $immediatly delayed if false |
||
16 | */ |
||
17 | View Code Duplication | public function _attr($element='this', $attributeName, $value="", $immediatly=false) { |
|
0 ignored issues
–
show
|
|||
18 | $element=$this->_prep_element($element); |
||
19 | if (isset($value)) { |
||
20 | $value=$this->_prep_value($value); |
||
21 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
||
22 | } else |
||
23 | $str="$({$element}).attr(\"$attributeName\");"; |
||
24 | if ($immediatly) |
||
25 | $this->jquery_code_for_compile[]=$str; |
||
0 ignored issues
–
show
The property
jquery_code_for_compile does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
26 | return $str; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Insert content, specified by the parameter, after each element in the set of matched elements |
||
31 | * @param string $element |
||
32 | * @param string $value |
||
33 | * @param boolean $immediatly defers the execution if set to false |
||
34 | * @return string |
||
35 | */ |
||
36 | public function after($element='this', $value='', $immediatly=false){ |
||
37 | $element=$this->_prep_element($element); |
||
38 | $value=$this->_prep_value($value); |
||
39 | $str="$({$element}).after({$value});"; |
||
40 | if ($immediatly) |
||
41 | $this->jquery_code_for_compile[]=$str; |
||
42 | return $str; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Execute a jQuery animate action |
||
47 | * |
||
48 | * @param string $element element |
||
49 | * @param string|array $params One of 'slow', 'normal', 'fast', or time in milliseconds |
||
50 | * @param string $speed |
||
51 | * @param string $extra |
||
52 | * @param boolean $immediatly delayed if false |
||
53 | * @return string |
||
54 | */ |
||
55 | public function _animate($element='this', $params=array(), $speed='', $extra='', $immediatly=false) { |
||
56 | $element=$this->_prep_element($element); |
||
57 | $speed=$this->_validate_speed($speed); |
||
58 | |||
59 | $animations="\t\t\t"; |
||
60 | if (is_array($params)) { |
||
61 | foreach ( $params as $param => $value ) { |
||
62 | $animations.=$param.': \''.$value.'\', '; |
||
63 | } |
||
64 | } |
||
65 | $animations=substr($animations, 0, -2); // remove the last ", " |
||
66 | |||
67 | if ($speed!='') { |
||
68 | $speed=', '.$speed; |
||
69 | } |
||
70 | |||
71 | if ($extra!='') { |
||
72 | $extra=', '.$extra; |
||
73 | } |
||
74 | |||
75 | $str="$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; |
||
76 | |||
77 | if ($immediatly) |
||
78 | $this->jquery_code_for_compile[]=$str; |
||
79 | return $str; |
||
80 | } |
||
81 | |||
82 | // -------------------------------------------------------------------- |
||
83 | |||
84 | /** |
||
85 | * Execute a jQuery hide action |
||
86 | * |
||
87 | * @param string $element element |
||
88 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
89 | * @param string $callback Javascript callback function |
||
90 | * @param boolean $immediatly delayed if false |
||
91 | * @return string |
||
92 | */ |
||
93 | View Code Duplication | public function _fadeIn($element='this', $speed='', $callback='', $immediatly=false) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
94 | $element=$this->_prep_element($element); |
||
95 | $speed=$this->_validate_speed($speed); |
||
96 | |||
97 | if ($callback!='') { |
||
98 | $callback=", function(){\n{$callback}\n}"; |
||
99 | } |
||
100 | |||
101 | $str="$({$element}).fadeIn({$speed}{$callback});"; |
||
102 | |||
103 | if ($immediatly) |
||
104 | $this->jquery_code_for_compile[]=$str; |
||
105 | return $str; |
||
106 | } |
||
107 | |||
108 | // -------------------------------------------------------------------- |
||
109 | |||
110 | /** |
||
111 | * Execute a jQuery fadeOut action |
||
112 | * |
||
113 | * @param string $element element |
||
114 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
115 | * @param string $callback Javascript callback function |
||
116 | * @param boolean $immediatly delayed if false |
||
117 | * @return string |
||
118 | */ |
||
119 | View Code Duplication | public function _fadeOut($element='this', $speed='', $callback='', $immediatly=false) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
120 | $element=$this->_prep_element($element); |
||
121 | $speed=$this->_validate_speed($speed); |
||
122 | |||
123 | if ($callback!='') { |
||
124 | $callback=", function(){\n{$callback}\n}"; |
||
125 | } |
||
126 | |||
127 | $str="$({$element}).fadeOut({$speed}{$callback});"; |
||
128 | |||
129 | if ($immediatly) |
||
130 | $this->jquery_code_for_compile[]=$str; |
||
131 | return $str; |
||
132 | } |
||
133 | |||
134 | // -------------------------------------------------------------------- |
||
135 | |||
136 | /** |
||
137 | * Execute a jQuery hide action |
||
138 | * |
||
139 | * @param string $element element |
||
140 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
141 | * @param string $callback Javascript callback function |
||
142 | * @param boolean $immediatly delayed if false |
||
143 | * @return string |
||
144 | */ |
||
145 | View Code Duplication | public function _hide($element='this', $speed='', $callback='', $immediatly=false) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
146 | $element=$this->_prep_element($element); |
||
147 | $speed=$this->_validate_speed($speed); |
||
148 | |||
149 | if ($callback!='') { |
||
150 | $callback=", function(){\n{$callback}\n}"; |
||
151 | } |
||
152 | |||
153 | $str="$({$element}).hide({$speed}{$callback});"; |
||
154 | |||
155 | if ($immediatly) |
||
156 | $this->jquery_code_for_compile[]=$str; |
||
157 | return $str; |
||
158 | } |
||
159 | |||
160 | // -------------------------------------------------------------------- |
||
161 | |||
162 | // -------------------------------------------------------------------- |
||
163 | |||
164 | /** |
||
165 | * Execute a jQuery slideUp action |
||
166 | * |
||
167 | * @param string $element element |
||
168 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
169 | * @param string $callback Javascript callback function |
||
170 | * @param boolean $immediatly delayed if false |
||
171 | * @return string |
||
172 | */ |
||
173 | View Code Duplication | public function _slideUp($element='this', $speed='', $callback='', $immediatly=false) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
174 | $element=$this->_prep_element($element); |
||
175 | $speed=$this->_validate_speed($speed); |
||
176 | |||
177 | if ($callback!='') { |
||
178 | $callback=", function(){\n{$callback}\n}"; |
||
179 | } |
||
180 | |||
181 | $str="$({$element}).slideUp({$speed}{$callback});"; |
||
182 | |||
183 | if ($immediatly) |
||
184 | $this->jquery_code_for_compile[]=$str; |
||
185 | return $str; |
||
186 | } |
||
187 | |||
188 | // -------------------------------------------------------------------- |
||
189 | |||
190 | /** |
||
191 | * Execute a jQuery slideDown action |
||
192 | * |
||
193 | * @param string $element element |
||
194 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
195 | * @param string $callback Javascript callback function |
||
196 | * @param boolean $immediatly delayed if false |
||
197 | * @return string |
||
198 | */ |
||
199 | View Code Duplication | public function _slideDown($element='this', $speed='', $callback='', $immediatly=false) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
200 | $element=$this->_prep_element($element); |
||
201 | $speed=$this->_validate_speed($speed); |
||
202 | |||
203 | if ($callback!='') { |
||
204 | $callback=", function(){\n{$callback}\n}"; |
||
205 | } |
||
206 | |||
207 | $str="$({$element}).slideDown({$speed}{$callback});"; |
||
208 | |||
209 | if ($immediatly) |
||
210 | $this->jquery_code_for_compile[]=$str; |
||
211 | return $str; |
||
212 | } |
||
213 | |||
214 | // -------------------------------------------------------------------- |
||
215 | |||
216 | /** |
||
217 | * Execute a jQuery slideToggle action |
||
218 | * |
||
219 | * @param string $element element |
||
220 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
221 | * @param string $callback Javascript callback function |
||
222 | * @param boolean $immediatly delayed if false |
||
223 | * @return string |
||
224 | */ |
||
225 | View Code Duplication | public function _slideToggle($element='this', $speed='', $callback='', $immediatly=false) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
226 | $element=$this->_prep_element($element); |
||
227 | $speed=$this->_validate_speed($speed); |
||
228 | |||
229 | if ($callback!='') { |
||
230 | $callback=", function(){\n{$callback}\n}"; |
||
231 | } |
||
232 | |||
233 | $str="$({$element}).slideToggle({$speed}{$callback});"; |
||
234 | |||
235 | if ($immediatly) |
||
236 | $this->jquery_code_for_compile[]=$str; |
||
237 | return $str; |
||
238 | } |
||
239 | |||
240 | // -------------------------------------------------------------------- |
||
241 | |||
242 | /** |
||
243 | * Outputs a jQuery toggle event |
||
244 | * |
||
245 | * @param string $element element |
||
246 | * @param boolean $immediatly delayed if false |
||
247 | * @return string |
||
248 | */ |
||
249 | View Code Duplication | public function _toggle($element='this', $immediatly=false) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
250 | $element=$this->_prep_element($element); |
||
251 | $str="$({$element}).toggle();"; |
||
252 | |||
253 | if ($immediatly) |
||
254 | $this->jquery_code_for_compile[]=$str; |
||
255 | return $str; |
||
256 | } |
||
257 | |||
258 | // -------------------------------------------------------------------- |
||
259 | |||
260 | /** |
||
261 | * Execute all handlers and behaviors attached to the matched elements for the given event. |
||
262 | * @param string $element |
||
263 | * @param string $event |
||
264 | * @param boolean $immediatly delayed if false |
||
265 | */ |
||
266 | View Code Duplication | public function _trigger($element='this', $event='click', $immediatly=false) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
267 | $element=$this->_prep_element($element); |
||
268 | $str="$({$element}).trigger(\"$event\");"; |
||
269 | |||
270 | if ($immediatly) |
||
271 | $this->jquery_code_for_compile[]=$str; |
||
272 | return $str; |
||
273 | } |
||
274 | |||
275 | // -------------------------------------------------------------------- |
||
276 | |||
277 | /** |
||
278 | * Execute a jQuery show action |
||
279 | * |
||
280 | * @param string $element element |
||
281 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
282 | * @param string $callback Javascript callback function |
||
283 | * @param boolean $immediatly delayed if false |
||
284 | * @return string |
||
285 | */ |
||
286 | View Code Duplication | public function _show($element='this', $speed='', $callback='', $immediatly=false) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
287 | $element=$this->_prep_element($element); |
||
288 | $speed=$this->_validate_speed($speed); |
||
289 | |||
290 | if ($callback!='') { |
||
291 | $callback=", function(){\n{$callback}\n}"; |
||
292 | } |
||
293 | |||
294 | $str="$({$element}).show({$speed}{$callback});"; |
||
295 | |||
296 | if ($immediatly) |
||
297 | $this->jquery_code_for_compile[]=$str; |
||
298 | return $str; |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * Places a condition |
||
303 | * @param string $condition |
||
304 | * @param string $jsCodeIfTrue |
||
305 | * @param string $jsCodeIfFalse |
||
306 | * @param boolean $immediatly delayed if false |
||
307 | * @return string |
||
308 | */ |
||
309 | public function _condition($condition, $jsCodeIfTrue, $jsCodeIfFalse=null, $immediatly=false) { |
||
310 | $str="if(".$condition."){".$jsCodeIfTrue."}"; |
||
311 | if (isset($jsCodeIfFalse)) { |
||
312 | $str.="else{".$jsCodeIfFalse."}"; |
||
313 | } |
||
314 | |||
315 | if ($immediatly) |
||
316 | $this->jquery_code_for_compile[]=$str; |
||
317 | return $str; |
||
318 | } |
||
319 | |||
320 | // ------------------------------------------------------------------------ |
||
321 | /** |
||
322 | * Call the JQuery method $jqueryCall on $element with parameters $param |
||
323 | * @param string $element |
||
324 | * @param string $jqueryCall |
||
325 | * @param mixed $param |
||
326 | * @param string $jsCallback javascript code to execute after the jquery call |
||
327 | * @param boolean $immediatly |
||
328 | * @return string |
||
329 | */ |
||
330 | public function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) { |
||
331 | $param=$this->_prep_value($param); |
||
332 | $callback=""; |
||
333 | if ($jsCallback!="") |
||
334 | $callback=", function(event){\n{$jsCallback}\n}"; |
||
335 | $script="$(".$this->_prep_element($element).").".$jqueryCall."(".$param.$callback.");\n"; |
||
336 | if ($immediatly) |
||
337 | $this->jquery_code_for_compile[]=$script; |
||
338 | return $script; |
||
339 | } |
||
340 | |||
341 | /** |
||
342 | * |
||
343 | * @param string $event |
||
344 | * @param string $element |
||
345 | * @param string $elementToModify |
||
346 | * @param string $jqueryCall |
||
347 | * @param string|array $param |
||
348 | * @param boolean $preventDefault |
||
349 | * @param boolean $stopPropagation |
||
350 | * @param string $jsCallback javascript code to execute after the jquery call |
||
351 | * @param boolean $immediatly |
||
352 | * @return string |
||
353 | */ |
||
354 | public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) { |
||
355 | return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly); |
||
356 | } |
||
357 | |||
358 | /** |
||
359 | * Execute the code $js |
||
360 | * @param string $js Code to execute |
||
361 | * @param boolean $immediatly diffère l'exécution si false |
||
362 | * @return String |
||
363 | */ |
||
364 | public function _exec($js, $immediatly=false) { |
||
365 | $script=$js."\n"; |
||
366 | if ($immediatly) |
||
367 | $this->jquery_code_for_compile[]=$script; |
||
368 | return $script; |
||
369 | } |
||
370 | |||
371 | /** |
||
372 | * |
||
373 | * @param string $element |
||
374 | * @param string $event |
||
375 | * @param string $js Code to execute |
||
376 | * @param boolean $preventDefault |
||
377 | * @param boolean $stopPropagation |
||
378 | * @param boolean $immediatly |
||
379 | * @return String |
||
380 | */ |
||
381 | public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
||
382 | return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation,$immediatly); |
||
383 | } |
||
384 | |||
385 | /** |
||
386 | * Ensures the speed parameter is valid for jQuery |
||
387 | * @param string|int $speed |
||
388 | * @return string |
||
389 | */ |
||
390 | private function _validate_speed($speed) { |
||
391 | if (in_array($speed, array ( |
||
392 | 'slow','normal','fast' |
||
393 | ))) { |
||
394 | $speed='"'.$speed.'"'; |
||
395 | } elseif (preg_match("/[^0-9]/", $speed)) { |
||
396 | $speed=''; |
||
397 | } |
||
398 | |||
399 | return $speed; |
||
400 | } |
||
401 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.