@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | protected $ajaxLoader="<div class=\"ui active centered inline text loader\">Loading</div>"; |
18 | 18 | |
19 | 19 | abstract public function getUrl($url); |
20 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
20 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
21 | 21 | |
22 | - protected function _ajax($method,$url,$responseElement="",$parameters=[]) { |
|
23 | - if(isset($this->params["ajax"])){ |
|
22 | + protected function _ajax($method, $url, $responseElement="", $parameters=[]) { |
|
23 | + if (isset($this->params["ajax"])) { |
|
24 | 24 | extract($this->params["ajax"]); |
25 | 25 | } |
26 | 26 | extract($parameters); |
@@ -30,102 +30,102 @@ discard block |
||
30 | 30 | $originalSelector=$responseElement; |
31 | 31 | $responseElement=$this->_getResponseElement($responseElement); |
32 | 32 | $retour.="var self=this;\n"; |
33 | - if($hasLoader===true && JString::isNotNull($responseElement)){ |
|
34 | - $this->addLoading($retour, $responseElement,$ajaxLoader); |
|
35 | - }elseif($hasLoader==="internal"){ |
|
33 | + if ($hasLoader===true && JString::isNotNull($responseElement)) { |
|
34 | + $this->addLoading($retour, $responseElement, $ajaxLoader); |
|
35 | + }elseif ($hasLoader==="internal") { |
|
36 | 36 | $retour.="\n$(this).addClass('loading');"; |
37 | 37 | } |
38 | - $ajaxParameters=["url"=>"url","method"=>"'".\strtoupper($method)."'"]; |
|
38 | + $ajaxParameters=["url"=>"url", "method"=>"'".\strtoupper($method)."'"]; |
|
39 | 39 | |
40 | - $ajaxParameters["async"]=($async?"true":"false"); |
|
40 | + $ajaxParameters["async"]=($async ? "true" : "false"); |
|
41 | 41 | |
42 | - if(isset($params)){ |
|
42 | + if (isset($params)) { |
|
43 | 43 | $ajaxParameters["data"]=self::_correctParams($params); |
44 | 44 | } |
45 | - if(isset($headers)){ |
|
45 | + if (isset($headers)) { |
|
46 | 46 | $ajaxParameters["headers"]=$headers; |
47 | 47 | } |
48 | 48 | $this->createAjaxParameters($ajaxParameters, $parameters); |
49 | 49 | $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
50 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback,$hasLoader,($historize?$originalSelector:null))."});\n"; |
|
51 | - $retour=$this->_addJsCondition($jsCondition,$retour); |
|
50 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null))."});\n"; |
|
51 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
52 | 52 | if ($immediatly) |
53 | 53 | $this->jquery_code_for_compile[]=$retour; |
54 | 54 | return $retour; |
55 | 55 | } |
56 | 56 | |
57 | - protected function createAjaxParameters(&$original,$parameters){ |
|
58 | - $validParameters=["dataType"=>"'%value%'","beforeSend"=>"function(jqXHR,settings){%value%}","complete"=>"function(jqXHR){%value%}"]; |
|
59 | - foreach ($validParameters as $param=>$mask){ |
|
60 | - if(isset($parameters[$param])){ |
|
57 | + protected function createAjaxParameters(&$original, $parameters) { |
|
58 | + $validParameters=["dataType"=>"'%value%'", "beforeSend"=>"function(jqXHR,settings){%value%}", "complete"=>"function(jqXHR){%value%}"]; |
|
59 | + foreach ($validParameters as $param=>$mask) { |
|
60 | + if (isset($parameters[$param])) { |
|
61 | 61 | $original[$param]=\str_replace("%value%", $parameters[$param], $mask); |
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - protected function implodeAjaxParameters($ajaxParameters){ |
|
67 | - $s = ''; foreach ($ajaxParameters as $k=>$v) { if ($s !== '') { $s .= ','; } $s .= "'{$k}':{$v}"; } |
|
66 | + protected function implodeAjaxParameters($ajaxParameters) { |
|
67 | + $s=''; foreach ($ajaxParameters as $k=>$v) { if ($s!=='') { $s.=','; } $s.="'{$k}':{$v}"; } |
|
68 | 68 | return $s; |
69 | 69 | } |
70 | 70 | |
71 | - protected function _addJsCondition($jsCondition,$jsSource){ |
|
72 | - if(isset($jsCondition)){ |
|
71 | + protected function _addJsCondition($jsCondition, $jsSource) { |
|
72 | + if (isset($jsCondition)) { |
|
73 | 73 | return "if(".$jsCondition."){\n".$jsSource."\n}"; |
74 | 74 | } |
75 | 75 | return $jsSource; |
76 | 76 | } |
77 | 77 | |
78 | 78 | |
79 | - protected function _getAjaxUrl($url,$attr){ |
|
79 | + protected function _getAjaxUrl($url, $attr) { |
|
80 | 80 | $url=$this->_correctAjaxUrl($url); |
81 | 81 | $retour="url='".$url."';"; |
82 | 82 | $slash="/"; |
83 | - if(JString::endswith($url, "/")===true){ |
|
83 | + if (JString::endswith($url, "/")===true) { |
|
84 | 84 | $slash=""; |
85 | 85 | } |
86 | - if(JString::isNotNull($attr)){ |
|
87 | - if ($attr==="value"){ |
|
86 | + if (JString::isNotNull($attr)) { |
|
87 | + if ($attr==="value") { |
|
88 | 88 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
89 | - }elseif ($attr==="html"){ |
|
89 | + }elseif ($attr==="html") { |
|
90 | 90 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
91 | - }elseif(\substr($attr, 0,3)==="js:"){ |
|
91 | + }elseif (\substr($attr, 0, 3)==="js:") { |
|
92 | 92 | $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
93 | - }elseif($attr!==null && $attr!=="") |
|
93 | + }elseif ($attr!==null && $attr!=="") |
|
94 | 94 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
95 | 95 | } |
96 | 96 | return $retour; |
97 | 97 | } |
98 | 98 | |
99 | - protected function onPopstate(){ |
|
99 | + protected function onPopstate() { |
|
100 | 100 | return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};"; |
101 | 101 | } |
102 | 102 | |
103 | - protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback,$hasLoader=false,$history=null){ |
|
104 | - $retour="";$call=null; |
|
103 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null) { |
|
104 | + $retour=""; $call=null; |
|
105 | 105 | if (JString::isNotNull($responseElement)) { |
106 | - if(isset($ajaxTransition)){ |
|
106 | + if (isset($ajaxTransition)) { |
|
107 | 107 | $call=$this->setAjaxDataCall($ajaxTransition); |
108 | - }elseif(isset($this->ajaxTransition)){ |
|
108 | + }elseif (isset($this->ajaxTransition)) { |
|
109 | 109 | $call=$this->ajaxTransition; |
110 | 110 | } |
111 | - if(\is_callable($call)) |
|
112 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
111 | + if (\is_callable($call)) |
|
112 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
113 | 113 | else |
114 | 114 | $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
115 | 115 | } |
116 | - if(isset($history)){ |
|
116 | + if (isset($history)) { |
|
117 | 117 | $retour.="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
118 | 118 | $retour.="\nif(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(url).addClass('active');"; |
119 | 119 | $retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);window._previousURL=url;"; |
120 | 120 | } |
121 | - if($hasLoader==="internal"){ |
|
121 | + if ($hasLoader==="internal") { |
|
122 | 122 | $retour.="\n$(self).removeClass('loading');"; |
123 | 123 | } |
124 | 124 | $retour.="\t".$jsCallback."\n"; |
125 | 125 | return $retour; |
126 | 126 | } |
127 | 127 | |
128 | - protected function _getResponseElement($responseElement){ |
|
128 | + protected function _getResponseElement($responseElement) { |
|
129 | 129 | if (JString::isNotNull($responseElement)) { |
130 | 130 | $responseElement=Javascript::prep_jquery_selector($responseElement); |
131 | 131 | } |
@@ -135,33 +135,33 @@ discard block |
||
135 | 135 | protected function _correctAjaxUrl($url) { |
136 | 136 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
137 | 137 | $url=substr($url, 0, strlen($url)-1); |
138 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
138 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
139 | 139 | $url=$this->getUrl($url); |
140 | 140 | } |
141 | 141 | return $url; |
142 | 142 | } |
143 | 143 | |
144 | - public static function _correctParams($params){ |
|
145 | - if(JString::isNull($params)){ |
|
144 | + public static function _correctParams($params) { |
|
145 | + if (JString::isNull($params)) { |
|
146 | 146 | return ""; |
147 | 147 | } |
148 | - if(\preg_match("@^\{.*?\}$@", $params)){ |
|
148 | + if (\preg_match("@^\{.*?\}$@", $params)) { |
|
149 | 149 | return '$.param('.$params.')'; |
150 | 150 | } |
151 | 151 | return $params; |
152 | 152 | } |
153 | 153 | |
154 | - public static function _implodeParams($parameters){ |
|
154 | + public static function _implodeParams($parameters) { |
|
155 | 155 | $allParameters=[]; |
156 | - foreach ($parameters as $params){ |
|
157 | - if(isset($params)) |
|
156 | + foreach ($parameters as $params) { |
|
157 | + if (isset($params)) |
|
158 | 158 | $allParameters[]=self::_correctParams($params); |
159 | 159 | } |
160 | 160 | return \implode("+'&'+", $allParameters); |
161 | 161 | } |
162 | 162 | |
163 | - protected function addLoading(&$retour, $responseElement,$ajaxLoader=null) { |
|
164 | - if(!isset($ajaxLoader)){ |
|
163 | + protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
164 | + if (!isset($ajaxLoader)) { |
|
165 | 165 | $ajaxLoader=$this->ajaxLoader; |
166 | 166 | } |
167 | 167 | $loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>'; |
@@ -169,19 +169,19 @@ discard block |
||
169 | 169 | $retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
170 | 170 | } |
171 | 171 | |
172 | - protected function setAjaxDataCall($params){ |
|
172 | + protected function setAjaxDataCall($params) { |
|
173 | 173 | $result=null; |
174 | - if(!\is_callable($params)){ |
|
175 | - $result=function ($responseElement,$jqueryDone="html") use($params){ |
|
176 | - return AjaxTransition::{$params}($responseElement,$jqueryDone); |
|
174 | + if (!\is_callable($params)) { |
|
175 | + $result=function($responseElement, $jqueryDone="html") use($params){ |
|
176 | + return AjaxTransition::{$params}($responseElement, $jqueryDone); |
|
177 | 177 | }; |
178 | 178 | } |
179 | 179 | return $result; |
180 | 180 | } |
181 | 181 | |
182 | - protected function setDefaultParameters(&$parameters,$default){ |
|
183 | - foreach ($default as $k=>$v){ |
|
184 | - if(!isset($parameters[$k])) |
|
182 | + protected function setDefaultParameters(&$parameters, $default) { |
|
183 | + foreach ($default as $k=>$v) { |
|
184 | + if (!isset($parameters[$k])) |
|
185 | 185 | $parameters[$k]=$v; |
186 | 186 | } |
187 | 187 | } |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | * @param string $url The url of the request |
196 | 196 | * @param string $responseElement selector of the HTML element displaying the answer |
197 | 197 | */ |
198 | - private function _get($url, $responseElement="",$parameters=[]) { |
|
199 | - return $this->_ajax("get", $url,$responseElement,$parameters); |
|
198 | + private function _get($url, $responseElement="", $parameters=[]) { |
|
199 | + return $this->_ajax("get", $url, $responseElement, $parameters); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | * @param string $responseElement selector of the HTML element displaying the answer |
206 | 206 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
207 | 207 | */ |
208 | - public function get($url, $responseElement="",$parameters=[]) { |
|
208 | + public function get($url, $responseElement="", $parameters=[]) { |
|
209 | 209 | $parameters["immediatly"]=true; |
210 | - return $this->_get($url,$responseElement,$parameters); |
|
210 | + return $this->_get($url, $responseElement, $parameters); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * @param string $responseElement selector of the HTML element displaying the answer |
218 | 218 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
219 | 219 | */ |
220 | - public function ajax($method,$url, $responseElement="", $parameters=[]) { |
|
220 | + public function ajax($method, $url, $responseElement="", $parameters=[]) { |
|
221 | 221 | $parameters["immediatly"]=true; |
222 | - return $this->_ajax($method,$url,$responseElement,$parameters); |
|
222 | + return $this->_ajax($method, $url, $responseElement, $parameters); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | * @param string $responseElement selector of the HTML element displaying the answer |
230 | 230 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
231 | 231 | */ |
232 | - public function ajaxDeferred($method,$url, $responseElement="", $parameters=[]) { |
|
232 | + public function ajaxDeferred($method, $url, $responseElement="", $parameters=[]) { |
|
233 | 233 | $parameters["immediatly"]=false; |
234 | - return $this->_ajax($method,$url,$responseElement,$parameters); |
|
234 | + return $this->_ajax($method, $url, $responseElement, $parameters); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -240,15 +240,15 @@ discard block |
||
240 | 240 | * @param string $method Method used |
241 | 241 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false) |
242 | 242 | */ |
243 | - private function _json($url, $method="get",$parameters=[]) { |
|
244 | - $parameters=\array_merge($parameters,["hasLoader"=>false]); |
|
243 | + private function _json($url, $method="get", $parameters=[]) { |
|
244 | + $parameters=\array_merge($parameters, ["hasLoader"=>false]); |
|
245 | 245 | $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
246 | 246 | $context=isset($parameters['context']) ? $parameters['context'] : "document"; |
247 | 247 | $retour="\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t".$jsCallback.";\n\tfor(var key in data){" |
248 | 248 | ."if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n"; |
249 | 249 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
250 | 250 | $parameters["jsCallback"]=$retour; |
251 | - return $this->_ajax($method, $url,null,$parameters); |
|
251 | + return $this->_ajax($method, $url, null, $parameters); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false) |
259 | 259 | */ |
260 | 260 | public function json($url, $method="get", $parameters=[]) { |
261 | - return $this->_json($url,$method,$parameters); |
|
261 | + return $this->_json($url, $method, $parameters); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | * @param string $method default get |
270 | 270 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
271 | 271 | */ |
272 | - public function jsonOn($event,$element, $url,$method="get",$parameters=array()) { |
|
273 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
274 | - return $this->_add_event($element, $this->jsonDeferred($url,$method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
272 | + public function jsonOn($event, $element, $url, $method="get", $parameters=array()) { |
|
273 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
274 | + return $this->_add_event($element, $this->jsonDeferred($url, $method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public function jsonDeferred($url, $method="get", $parameters=[]) { |
284 | 284 | $parameters["immediatly"]=false; |
285 | - return $this->_json($url,$method,$parameters); |
|
285 | + return $this->_json($url, $method, $parameters); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -293,26 +293,26 @@ discard block |
||
293 | 293 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json") |
294 | 294 | */ |
295 | 295 | private function _jsonArray($maskSelector, $url, $method="get", $parameters=[]) { |
296 | - $parameters=\array_merge($parameters,["hasLoader"=>false]); |
|
296 | + $parameters=\array_merge($parameters, ["hasLoader"=>false]); |
|
297 | 297 | $rowClass=isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json"; |
298 | 298 | $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
299 | 299 | $context=isset($parameters['context']) ? $parameters['context'] : null; |
300 | - if($context===null){ |
|
300 | + if ($context===null) { |
|
301 | 301 | $parent="$('".$maskSelector."').parent()"; |
302 | - $newElm = "$('#'+newId)"; |
|
303 | - }else{ |
|
302 | + $newElm="$('#'+newId)"; |
|
303 | + } else { |
|
304 | 304 | $parent=$context; |
305 | - $newElm = $context.".find('#'+newId)"; |
|
305 | + $newElm=$context.".find('#'+newId)"; |
|
306 | 306 | } |
307 | 307 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
308 | 308 | $retour=$parent.".find('.{$rowClass}').remove();"; |
309 | 309 | $retour.="\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t".$jsCallback.";\n$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone(); |
310 | 310 | newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
311 | - $retour.= $appendTo; |
|
311 | + $retour.=$appendTo; |
|
312 | 312 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
313 | 313 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
314 | 314 | $parameters["jsCallback"]=$retour; |
315 | - return $this->_ajax($method, $url,null,$parameters); |
|
315 | + return $this->_ajax($method, $url, null, $parameters); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json") |
324 | 324 | */ |
325 | 325 | public function jsonArray($maskSelector, $url, $method="get", $parameters=[]) { |
326 | - return $this->_jsonArray($maskSelector, $url,$method,$parameters); |
|
326 | + return $this->_jsonArray($maskSelector, $url, $method, $parameters); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | * @param string $method Method used, default : get |
347 | 347 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true) |
348 | 348 | */ |
349 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$method="get",$parameters=array()) { |
|
350 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
351 | - return $this->_add_event($element, $this->jsonArrayDeferred($maskSelector,$url,$method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
349 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $method="get", $parameters=array()) { |
|
350 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
351 | + return $this->_add_event($element, $this->jsonArrayDeferred($maskSelector, $url, $method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | */ |
361 | 361 | public function getDeferred($url, $responseElement="", $parameters=[]) { |
362 | 362 | $parameters["immediatly"]=false; |
363 | - return $this->_get($url, $responseElement,$parameters); |
|
363 | + return $this->_get($url, $responseElement, $parameters); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false) |
374 | 374 | */ |
375 | 375 | public function getOn($event, $element, $url, $responseElement="", $parameters=array()) { |
376 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
377 | - return $this->_add_event($element, $this->getDeferred($url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
376 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
377 | + return $this->_add_event($element, $this->getDeferred($url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | * @param array $parameters default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
388 | 388 | */ |
389 | 389 | public function ajaxOn($event, $element, $url, $responseElement="", $parameters=array()) { |
390 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true,"method"=>"get"]); |
|
391 | - return $this->_add_event($element, $this->ajaxDeferred($parameters["method"],$url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
390 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true, "method"=>"get"]); |
|
391 | + return $this->_add_event($element, $this->ajaxDeferred($parameters["method"], $url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -422,15 +422,15 @@ discard block |
||
422 | 422 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true) |
423 | 423 | * @return $this |
424 | 424 | */ |
425 | - public function getHref($element,$responseElement="",$parameters=array()){ |
|
425 | + public function getHref($element, $responseElement="", $parameters=array()) { |
|
426 | 426 | $parameters["attr"]="href"; |
427 | - if(JString::isNull($responseElement)){ |
|
427 | + if (JString::isNull($responseElement)) { |
|
428 | 428 | $responseElement='%$(self).attr("data-target")%'; |
429 | 429 | } |
430 | - if(!isset($parameters["historize"])){ |
|
430 | + if (!isset($parameters["historize"])) { |
|
431 | 431 | $parameters["historize"]=true; |
432 | 432 | } |
433 | - return $this->getOnClick($element, "",$responseElement,$parameters); |
|
433 | + return $this->getOnClick($element, "", $responseElement, $parameters); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -440,20 +440,20 @@ discard block |
||
440 | 440 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
441 | 441 | * @return $this |
442 | 442 | */ |
443 | - public function postHref($element,$responseElement="",$parameters=array()){ |
|
443 | + public function postHref($element, $responseElement="", $parameters=array()) { |
|
444 | 444 | $parameters["attr"]="href"; |
445 | - if(JString::isNull($responseElement)){ |
|
445 | + if (JString::isNull($responseElement)) { |
|
446 | 446 | $responseElement='%$(this).attr("data-target")%'; |
447 | 447 | } |
448 | - if(!isset($parameters["historize"])){ |
|
448 | + if (!isset($parameters["historize"])) { |
|
449 | 449 | $parameters["historize"]=true; |
450 | 450 | } |
451 | - return $this->postOnClick($element, "","{}",$responseElement,$parameters); |
|
451 | + return $this->postOnClick($element, "", "{}", $responseElement, $parameters); |
|
452 | 452 | } |
453 | 453 | |
454 | - private function _post($url, $params="{}",$responseElement="", $parameters=[]) { |
|
454 | + private function _post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
455 | 455 | $parameters["params"]=$params; |
456 | - return $this->_ajax("POST", $url,$responseElement,$parameters); |
|
456 | + return $this->_ajax("POST", $url, $responseElement, $parameters); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | * @param string $params JSON parameters |
464 | 464 | * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
465 | 465 | */ |
466 | - public function post($url, $params="{}",$responseElement="", $parameters=[]) { |
|
467 | - return $this->_post($url, $params,$responseElement, $parameters); |
|
466 | + public function post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
467 | + return $this->_post($url, $params, $responseElement, $parameters); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @param string $responseElement selector of the HTML element displaying the answer |
476 | 476 | * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
477 | 477 | */ |
478 | - public function postDeferred($url, $params="{}",$responseElement="", $parameters=[]) { |
|
478 | + public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) { |
|
479 | 479 | $parameters["immediatly"]=false; |
480 | 480 | return $this->_post($url, $params, $responseElement, $parameters); |
481 | 481 | } |
@@ -491,8 +491,8 @@ discard block |
||
491 | 491 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
492 | 492 | */ |
493 | 493 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
494 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
495 | - return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
494 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
495 | + return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -509,33 +509,33 @@ discard block |
||
509 | 509 | } |
510 | 510 | |
511 | 511 | private function _postForm($url, $form, $responseElement, $parameters=[]) { |
512 | - if(isset($this->params["ajax"])){ |
|
512 | + if (isset($this->params["ajax"])) { |
|
513 | 513 | extract($this->params["ajax"]); |
514 | 514 | } |
515 | - $params="{}";$validation=false; |
|
515 | + $params="{}"; $validation=false; |
|
516 | 516 | \extract($parameters); |
517 | - $async=($async)?"true":"false"; |
|
517 | + $async=($async) ? "true" : "false"; |
|
518 | 518 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
519 | 519 | $retour=$this->_getAjaxUrl($url, $attr); |
520 | 520 | $retour.="\n$('#".$form."').trigger('ajaxSubmit');"; |
521 | 521 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
522 | - if(isset($params)){ |
|
522 | + if (isset($params)) { |
|
523 | 523 | $retour.="params+='&'+".self::_correctParams($params).";\n"; |
524 | 524 | } |
525 | 525 | $responseElement=$this->_getResponseElement($responseElement); |
526 | 526 | $retour.="var self=this;\n"; |
527 | - if($hasLoader===true){ |
|
528 | - $this->addLoading($retour, $responseElement,$ajaxLoader); |
|
529 | - }elseif($hasLoader==="internal"){ |
|
527 | + if ($hasLoader===true) { |
|
528 | + $this->addLoading($retour, $responseElement, $ajaxLoader); |
|
529 | + }elseif ($hasLoader==="internal") { |
|
530 | 530 | $retour.="\n$(this).addClass('loading');"; |
531 | 531 | } |
532 | - $ajaxParameters=["url"=>"url","method"=>"'POST'","data"=>"params","async"=>$async]; |
|
533 | - if(isset($headers)){ |
|
532 | + $ajaxParameters=["url"=>"url", "method"=>"'POST'", "data"=>"params", "async"=>$async]; |
|
533 | + if (isset($headers)) { |
|
534 | 534 | $ajaxParameters["headers"]=$headers; |
535 | 535 | } |
536 | 536 | $this->createAjaxParameters($ajaxParameters, $parameters); |
537 | 537 | $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n"; |
538 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback,$hasLoader)."});\n"; |
|
538 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader)."});\n"; |
|
539 | 539 | |
540 | 540 | if ($validation) { |
541 | 541 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -585,8 +585,8 @@ discard block |
||
585 | 585 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false) |
586 | 586 | */ |
587 | 587 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
588 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
589 | - return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
588 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
589 | + return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $retour.="var self=this;\n"; |
33 | 33 | if($hasLoader===true && JString::isNotNull($responseElement)){ |
34 | 34 | $this->addLoading($retour, $responseElement,$ajaxLoader); |
35 | - }elseif($hasLoader==="internal"){ |
|
35 | + } elseif($hasLoader==="internal"){ |
|
36 | 36 | $retour.="\n$(this).addClass('loading');"; |
37 | 37 | } |
38 | 38 | $ajaxParameters=["url"=>"url","method"=>"'".\strtoupper($method)."'"]; |
@@ -49,8 +49,9 @@ discard block |
||
49 | 49 | $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
50 | 50 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback,$hasLoader,($historize?$originalSelector:null))."});\n"; |
51 | 51 | $retour=$this->_addJsCondition($jsCondition,$retour); |
52 | - if ($immediatly) |
|
53 | - $this->jquery_code_for_compile[]=$retour; |
|
52 | + if ($immediatly) { |
|
53 | + $this->jquery_code_for_compile[]=$retour; |
|
54 | + } |
|
54 | 55 | return $retour; |
55 | 56 | } |
56 | 57 | |
@@ -86,12 +87,13 @@ discard block |
||
86 | 87 | if(JString::isNotNull($attr)){ |
87 | 88 | if ($attr==="value"){ |
88 | 89 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
89 | - }elseif ($attr==="html"){ |
|
90 | + } elseif ($attr==="html"){ |
|
90 | 91 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
91 | - }elseif(\substr($attr, 0,3)==="js:"){ |
|
92 | + } elseif(\substr($attr, 0,3)==="js:"){ |
|
92 | 93 | $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
93 | - }elseif($attr!==null && $attr!=="") |
|
94 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
94 | + } elseif($attr!==null && $attr!=="") { |
|
95 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
96 | + } |
|
95 | 97 | } |
96 | 98 | return $retour; |
97 | 99 | } |
@@ -105,13 +107,14 @@ discard block |
||
105 | 107 | if (JString::isNotNull($responseElement)) { |
106 | 108 | if(isset($ajaxTransition)){ |
107 | 109 | $call=$this->setAjaxDataCall($ajaxTransition); |
108 | - }elseif(isset($this->ajaxTransition)){ |
|
110 | + } elseif(isset($this->ajaxTransition)){ |
|
109 | 111 | $call=$this->ajaxTransition; |
110 | 112 | } |
111 | - if(\is_callable($call)) |
|
112 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
113 | - else |
|
114 | - $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
113 | + if(\is_callable($call)) { |
|
114 | + $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
115 | + } else { |
|
116 | + $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
117 | + } |
|
115 | 118 | } |
116 | 119 | if(isset($history)){ |
117 | 120 | $retour.="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
@@ -133,8 +136,9 @@ discard block |
||
133 | 136 | } |
134 | 137 | |
135 | 138 | protected function _correctAjaxUrl($url) { |
136 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
137 | - $url=substr($url, 0, strlen($url)-1); |
|
139 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
140 | + $url=substr($url, 0, strlen($url)-1); |
|
141 | + } |
|
138 | 142 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
139 | 143 | $url=$this->getUrl($url); |
140 | 144 | } |
@@ -154,8 +158,9 @@ discard block |
||
154 | 158 | public static function _implodeParams($parameters){ |
155 | 159 | $allParameters=[]; |
156 | 160 | foreach ($parameters as $params){ |
157 | - if(isset($params)) |
|
158 | - $allParameters[]=self::_correctParams($params); |
|
161 | + if(isset($params)) { |
|
162 | + $allParameters[]=self::_correctParams($params); |
|
163 | + } |
|
159 | 164 | } |
160 | 165 | return \implode("+'&'+", $allParameters); |
161 | 166 | } |
@@ -181,8 +186,9 @@ discard block |
||
181 | 186 | |
182 | 187 | protected function setDefaultParameters(&$parameters,$default){ |
183 | 188 | foreach ($default as $k=>$v){ |
184 | - if(!isset($parameters[$k])) |
|
185 | - $parameters[$k]=$v; |
|
189 | + if(!isset($parameters[$k])) { |
|
190 | + $parameters[$k]=$v; |
|
191 | + } |
|
186 | 192 | } |
187 | 193 | } |
188 | 194 | |
@@ -300,7 +306,7 @@ discard block |
||
300 | 306 | if($context===null){ |
301 | 307 | $parent="$('".$maskSelector."').parent()"; |
302 | 308 | $newElm = "$('#'+newId)"; |
303 | - }else{ |
|
309 | + } else{ |
|
304 | 310 | $parent=$context; |
305 | 311 | $newElm = $context.".find('#'+newId)"; |
306 | 312 | } |
@@ -526,7 +532,7 @@ discard block |
||
526 | 532 | $retour.="var self=this;\n"; |
527 | 533 | if($hasLoader===true){ |
528 | 534 | $this->addLoading($retour, $responseElement,$ajaxLoader); |
529 | - }elseif($hasLoader==="internal"){ |
|
535 | + } elseif($hasLoader==="internal"){ |
|
530 | 536 | $retour.="\n$(this).addClass('loading');"; |
531 | 537 | } |
532 | 538 | $ajaxParameters=["url"=>"url","method"=>"'POST'","data"=>"params","async"=>$async]; |
@@ -544,8 +550,9 @@ discard block |
||
544 | 550 | $retour.="$('#".$form."').submit();\n"; |
545 | 551 | } |
546 | 552 | $retour=$this->_addJsCondition($jsCondition, $retour); |
547 | - if ($immediatly) |
|
548 | - $this->jquery_code_for_compile[]=$retour; |
|
553 | + if ($immediatly) { |
|
554 | + $this->jquery_code_for_compile[]=$retour; |
|
555 | + } |
|
549 | 556 | return $retour; |
550 | 557 | } |
551 | 558 |
@@ -6,16 +6,16 @@ discard block |
||
6 | 6 | public static $preventDefault="\nif(event && event.preventDefault) event.preventDefault();\n"; |
7 | 7 | public static $stopPropagation="\nif(event && event.stopPropagation) event.stopPropagation();\n"; |
8 | 8 | |
9 | - public static function draggable($attr="id"){ |
|
9 | + public static function draggable($attr="id") { |
|
10 | 10 | return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;dt.setData("text/plain",JSON.stringify({id:$(event.target).attr("id"),data:$(event.target).attr("'.$attr.'")}));'; |
11 | 11 | } |
12 | 12 | |
13 | - public static function dropZone($jqueryDone,$jsCallback=""){ |
|
13 | + public static function dropZone($jqueryDone, $jsCallback="") { |
|
14 | 14 | return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var _data=JSON.parse(dt.getData("text/plain"));$(event.target).'.$jqueryDone.'($("#"+_data.id));var data=_data.data;'.$jsCallback; |
15 | 15 | } |
16 | 16 | |
17 | - public static function containsCode($expression){ |
|
18 | - return strrpos($expression, 'this')!==false||strrpos($expression, 'event')!==false||strrpos($expression, 'self')!==false; |
|
17 | + public static function containsCode($expression) { |
|
18 | + return strrpos($expression, 'this')!==false || strrpos($expression, 'event')!==false || strrpos($expression, 'self')!==false; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | $value=implode(",", $value); |
47 | 47 | } |
48 | 48 | if (self::containsCode($value)===false) { |
49 | - $value=\str_replace(["\\","\""], ["\\\\","\\\""], $value); |
|
49 | + $value=\str_replace(["\\", "\""], ["\\\\", "\\\""], $value); |
|
50 | 50 | $value='"'.$value.'"'; |
51 | 51 | } |
52 | - return trim($value,"%"); |
|
52 | + return trim($value, "%"); |
|
53 | 53 | } |
54 | 54 | |
55 | - public static function prep_jquery_selector($value){ |
|
56 | - if(JString::startswith($value, '$(')===false){ |
|
55 | + public static function prep_jquery_selector($value) { |
|
56 | + if (JString::startswith($value, '$(')===false) { |
|
57 | 57 | return '$('.self::prep_value($value).')'; |
58 | 58 | } |
59 | 59 | return $value; |