@@ -32,15 +32,17 @@ discard block |
||
32 | 32 | |
33 | 33 | public function addContent($content,$before=false) { |
34 | 34 | if (!\is_array($this->content)) { |
35 | - if(isset($this->content)) |
|
36 | - $this->content=array ($this->content); |
|
37 | - else |
|
38 | - $this->content=array(); |
|
35 | + if(isset($this->content)) { |
|
36 | + $this->content=array ($this->content); |
|
37 | + } else { |
|
38 | + $this->content=array(); |
|
39 | + } |
|
40 | + } |
|
41 | + if($before) { |
|
42 | + array_unshift($this->content,$content); |
|
43 | + } else { |
|
44 | + $this->content []=$content; |
|
39 | 45 | } |
40 | - if($before) |
|
41 | - array_unshift($this->content,$content); |
|
42 | - else |
|
43 | - $this->content []=$content; |
|
44 | 46 | return $this; |
45 | 47 | } |
46 | 48 | |
@@ -78,9 +80,9 @@ discard block |
||
78 | 80 | $instances=[]; |
79 | 81 | if($content instanceof $class){ |
80 | 82 | $instances[]=$content; |
81 | - }elseif($content instanceof HtmlDoubleElement){ |
|
83 | + } elseif($content instanceof HtmlDoubleElement){ |
|
82 | 84 | $instances=\array_merge($instances,$content->getContentInstances($class)); |
83 | - }elseif (\is_array($content)){ |
|
85 | + } elseif (\is_array($content)){ |
|
84 | 86 | foreach ($content as $element){ |
85 | 87 | $instances=\array_merge($instances,$this->_getContentInstances($class, $element)); |
86 | 88 | } |
@@ -93,10 +95,12 @@ discard block |
||
93 | 95 | * @return HtmlDoubleElement |
94 | 96 | */ |
95 | 97 | public function asLink($href=NULL,$target=NULL) { |
96 | - if (isset($href)) |
|
97 | - $this->setProperty("href", $href); |
|
98 | - if(isset($target)) |
|
99 | - $this->setProperty("target", $target); |
|
98 | + if (isset($href)) { |
|
99 | + $this->setProperty("href", $href); |
|
100 | + } |
|
101 | + if(isset($target)) { |
|
102 | + $this->setProperty("target", $target); |
|
103 | + } |
|
100 | 104 | return $this->setTagName("a"); |
101 | 105 | } |
102 | 106 | |
@@ -121,7 +125,7 @@ discard block |
||
121 | 125 | $this->_editableContent=$frm; |
122 | 126 | $keypress=""; |
123 | 127 | $focusOut=""; |
124 | - }else{ |
|
128 | + } else{ |
|
125 | 129 | $focusOut="if(e.relatedTarget==null)elm.trigger('endEdit');"; |
126 | 130 | $this->_editableContent=$field; |
127 | 131 | $keypress="$('#".$idF."').keyup(function(e){if(e.which == 13) {\$('#".$idE."').trigger('validate',{value: $('#'+idF+' input').val()});}if(e.keyCode===27) {\$('#".$idE."').trigger('endEdit');}});"; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $this->_generateFields($form, [$v], $headers, $i, $wrappers,$nb++); |
65 | 65 | $i++; |
66 | 66 | } |
67 | - }else{ |
|
67 | + } else{ |
|
68 | 68 | $separators[]=$count; |
69 | 69 | for($i=0;$i<$size;$i++){ |
70 | 70 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
@@ -78,17 +78,19 @@ discard block |
||
78 | 78 | |
79 | 79 | protected function _generateFields($form,$values,$headers,$sepFirst,$wrappers,$nb){ |
80 | 80 | $wrapper=null; |
81 | - if(isset($headers[$sepFirst+1])) |
|
82 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
81 | + if(isset($headers[$sepFirst+1])) { |
|
82 | + $form->addHeader($headers[$sepFirst+1],4,true); |
|
83 | + } |
|
83 | 84 | if(isset($wrappers[$sepFirst+1])){ |
84 | 85 | $wrapper=$wrappers[$sepFirst+1]; |
85 | 86 | } |
86 | 87 | if(\sizeof($values)===1){ |
87 | 88 | $added=$form->addField($values[0]); |
88 | - }elseif(\sizeof($values)>1){ |
|
89 | + } elseif(\sizeof($values)>1){ |
|
89 | 90 | $added=$form->addFields($values); |
90 | - }else |
|
91 | - return; |
|
91 | + } else { |
|
92 | + return; |
|
93 | + } |
|
92 | 94 | if(isset($wrapper)){ |
93 | 95 | $added->wrap($wrapper[0],$wrapper[1]); |
94 | 96 | } |
@@ -79,8 +79,9 @@ discard block |
||
79 | 79 | $actionO=$action; |
80 | 80 | if (\is_object($action) === false) { |
81 | 81 | $actionO=new HtmlButton("action-" . $this->identifier, $action); |
82 | - if (isset($icon)) |
|
83 | - $actionO->addIcon($icon, true, $labeled); |
|
82 | + if (isset($icon)) { |
|
83 | + $actionO->addIcon($icon, true, $labeled); |
|
84 | + } |
|
84 | 85 | } |
85 | 86 | $field->addToProperty("class", $direction . " action"); |
86 | 87 | $field->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
@@ -120,8 +121,9 @@ discard block |
||
120 | 121 | |
121 | 122 | public function setDisabled($disable=true) { |
122 | 123 | $field=$this->getField(); |
123 | - if($disable) |
|
124 | - $field->addToProperty("class", "disabled"); |
|
124 | + if($disable) { |
|
125 | + $field->addToProperty("class", "disabled"); |
|
126 | + } |
|
125 | 127 | return $this; |
126 | 128 | } |
127 | 129 |
@@ -29,11 +29,12 @@ discard block |
||
29 | 29 | if(\is_array($value)){ |
30 | 30 | $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
31 | 31 | return $itemO; |
32 | - }elseif(\is_object($value)){ |
|
32 | + } elseif(\is_object($value)){ |
|
33 | 33 | $itemO=new HtmlFormField("field-".$this->identifier, $value); |
34 | 34 | return $itemO; |
35 | - }else |
|
36 | - return new HtmlFormInput($value); |
|
35 | + } else { |
|
36 | + return new HtmlFormInput($value); |
|
37 | + } |
|
37 | 38 | } |
38 | 39 | |
39 | 40 | protected function createCondition($value){ |
@@ -67,8 +68,7 @@ discard block |
||
67 | 68 | if(isset($c)){ |
68 | 69 | $df=$c->getDataField(); |
69 | 70 | $df->setProperty($property,$value); |
70 | - } |
|
71 | - else{ |
|
71 | + } else{ |
|
72 | 72 | return $this; |
73 | 73 | } |
74 | 74 | } |
@@ -163,10 +163,12 @@ discard block |
||
163 | 163 | public function addButtonIcon($identifier,$icon,$cssStyle=NULL,$onClick=NULL){ |
164 | 164 | $bt=new HtmlButton($identifier); |
165 | 165 | $bt->asIcon($icon); |
166 | - if(isset($onClick)) |
|
167 | - $bt->onClick($onClick); |
|
168 | - if (isset($cssStyle)) |
|
169 | - $bt->addClass($cssStyle); |
|
166 | + if(isset($onClick)) { |
|
167 | + $bt->onClick($onClick); |
|
168 | + } |
|
169 | + if (isset($cssStyle)) { |
|
170 | + $bt->addClass($cssStyle); |
|
171 | + } |
|
170 | 172 | return $this->addItem($bt); |
171 | 173 | } |
172 | 174 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $retour.=$before; |
37 | 37 | if($hasLoader===true && JString::isNotNull($responseElement)){ |
38 | 38 | $this->addLoading($retour, $responseElement,$ajaxLoader); |
39 | - }elseif($hasLoader==="internal"){ |
|
39 | + } elseif($hasLoader==="internal"){ |
|
40 | 40 | $retour.="\n$(this).addClass('loading');"; |
41 | 41 | } |
42 | 42 | $ajaxParameters=["url"=>"url","method"=>"'".\strtoupper($method)."'"]; |
@@ -53,8 +53,9 @@ discard block |
||
53 | 53 | $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
54 | 54 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback,$hasLoader,($historize?$originalSelector:null))."});\n"; |
55 | 55 | $retour=$this->_addJsCondition($jsCondition,$retour); |
56 | - if ($immediatly) |
|
57 | - $this->jquery_code_for_compile[]=$retour; |
|
56 | + if ($immediatly) { |
|
57 | + $this->jquery_code_for_compile[]=$retour; |
|
58 | + } |
|
58 | 59 | return $retour; |
59 | 60 | } |
60 | 61 | |
@@ -75,7 +76,7 @@ discard block |
||
75 | 76 | } |
76 | 77 | if(is_array($v)){ |
77 | 78 | $s .= "'{$k}':{".self::implodeAjaxParameters($v)."}"; |
78 | - }else{ |
|
79 | + } else{ |
|
79 | 80 | $s .= "'{$k}':{$v}"; |
80 | 81 | } |
81 | 82 | } |
@@ -100,12 +101,13 @@ discard block |
||
100 | 101 | if(JString::isNotNull($attr)){ |
101 | 102 | if ($attr==="value"){ |
102 | 103 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
103 | - }elseif ($attr==="html"){ |
|
104 | + } elseif ($attr==="html"){ |
|
104 | 105 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
105 | - }elseif(\substr($attr, 0,3)==="js:"){ |
|
106 | + } elseif(\substr($attr, 0,3)==="js:"){ |
|
106 | 107 | $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
107 | - }elseif($attr!==null && $attr!=="") |
|
108 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
108 | + } elseif($attr!==null && $attr!=="") { |
|
109 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
110 | + } |
|
109 | 111 | } |
110 | 112 | return $retour; |
111 | 113 | } |
@@ -125,13 +127,14 @@ discard block |
||
125 | 127 | if (JString::isNotNull($responseElement)) { |
126 | 128 | if(isset($ajaxTransition)){ |
127 | 129 | $call=$this->setAjaxDataCall($ajaxTransition); |
128 | - }elseif(isset($this->ajaxTransition)){ |
|
130 | + } elseif(isset($this->ajaxTransition)){ |
|
129 | 131 | $call=$this->ajaxTransition; |
130 | 132 | } |
131 | - if(\is_callable($call)) |
|
132 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
133 | - else |
|
134 | - $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
133 | + if(\is_callable($call)) { |
|
134 | + $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
135 | + } else { |
|
136 | + $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
137 | + } |
|
135 | 138 | } |
136 | 139 | if(isset($history)){ |
137 | 140 | if($this->params["autoActiveLinks"]){ |
@@ -154,8 +157,9 @@ discard block |
||
154 | 157 | } |
155 | 158 | |
156 | 159 | protected function _correctAjaxUrl($url) { |
157 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
158 | - $url=substr($url, 0, strlen($url)-1); |
|
160 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
161 | + $url=substr($url, 0, strlen($url)-1); |
|
162 | + } |
|
159 | 163 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
160 | 164 | $url=$this->getUrl($url); |
161 | 165 | } |
@@ -169,7 +173,7 @@ discard block |
||
169 | 173 | if(\preg_match("@^\{.*?\}$@", $params)){ |
170 | 174 | if( !isset($ajaxParameters['contentType'])|| !UString::contains('json', $ajaxParameters['contentType'])){ |
171 | 175 | return '$.param('.$params.')'; |
172 | - }else{ |
|
176 | + } else{ |
|
173 | 177 | return 'JSON.stringify('.$params.')'; |
174 | 178 | } |
175 | 179 | } |
@@ -179,8 +183,9 @@ discard block |
||
179 | 183 | public static function _implodeParams($parameters){ |
180 | 184 | $allParameters=[]; |
181 | 185 | foreach ($parameters as $params){ |
182 | - if(isset($params)) |
|
183 | - $allParameters[]=self::_correctParams($params); |
|
186 | + if(isset($params)) { |
|
187 | + $allParameters[]=self::_correctParams($params); |
|
188 | + } |
|
184 | 189 | } |
185 | 190 | return \implode("+'&'+", $allParameters); |
186 | 191 | } |
@@ -206,8 +211,9 @@ discard block |
||
206 | 211 | |
207 | 212 | protected function setDefaultParameters(&$parameters,$default){ |
208 | 213 | foreach ($default as $k=>$v){ |
209 | - if(!isset($parameters[$k])) |
|
210 | - $parameters[$k]=$v; |
|
214 | + if(!isset($parameters[$k])) { |
|
215 | + $parameters[$k]=$v; |
|
216 | + } |
|
211 | 217 | } |
212 | 218 | } |
213 | 219 | |
@@ -340,7 +346,7 @@ discard block |
||
340 | 346 | if($context===null){ |
341 | 347 | $parent="$('".$maskSelector."').parent()"; |
342 | 348 | $newElm = "$('#'+newId)"; |
343 | - }else{ |
|
349 | + } else{ |
|
344 | 350 | $parent=$context; |
345 | 351 | $newElm = $context.".find('#'+newId)"; |
346 | 352 | } |
@@ -567,7 +573,7 @@ discard block |
||
567 | 573 | $retour.="var self=this;\n"; |
568 | 574 | if($hasLoader===true){ |
569 | 575 | $this->addLoading($retour, $responseElement,$ajaxLoader); |
570 | - }elseif($hasLoader==="internal"){ |
|
576 | + } elseif($hasLoader==="internal"){ |
|
571 | 577 | $retour.="\n$(this).addClass('loading');"; |
572 | 578 | } |
573 | 579 | $ajaxParameters=["url"=>"url","method"=>"'POST'","data"=>"params","async"=>$async]; |
@@ -585,8 +591,9 @@ discard block |
||
585 | 591 | $retour.="$('#".$form."').submit();\n"; |
586 | 592 | } |
587 | 593 | $retour=$this->_addJsCondition($jsCondition, $retour); |
588 | - if ($immediatly) |
|
589 | - $this->jquery_code_for_compile[]=$retour; |
|
594 | + if ($immediatly) { |
|
595 | + $this->jquery_code_for_compile[]=$retour; |
|
596 | + } |
|
590 | 597 | return $retour; |
591 | 598 | } |
592 | 599 |