Completed
Push — master ( 462f88...b88904 )
by Jean-Christophe
03:19
created
Ajax/semantic/html/elements/HtmlHeader.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
10 10
 use Ajax\semantic\html\base\traits\AttachedTrait;
11 11
 
12 12
 class HtmlHeader extends HtmlSemDoubleElement {
13
-	use TextAlignmentTrait,AttachedTrait;
13
+	use TextAlignmentTrait, AttachedTrait;
14 14
 	protected $image;
15 15
 
16 16
 	public function __construct($identifier, $niveau=1, $content=NULL, $type="page") {
17 17
 		parent::__construct($identifier, "div", "ui header");
18 18
 		$this->_template="<%tagName%  id='%identifier%' %properties%>%image%%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>";
19 19
 		if (isset($type)) {
20
-			if ($type == "page") {
20
+			if ($type=="page") {
21 21
 				$this->asPageHeader($niveau);
22 22
 			} else
23 23
 				$this->asContentHeader($niveau);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	}
27 27
 
28 28
 	public function asPageHeader($niveau) {
29
-		$this->tagName="h" . $niveau;
29
+		$this->tagName="h".$niveau;
30 30
 	}
31 31
 
32 32
 	public function asContentHeader($niveau) {
@@ -39,25 +39,25 @@  discard block
 block discarded – undo
39 39
 
40 40
 	public function asIcon($icon, $title, $subHeader=NULL) {
41 41
 		$this->addToProperty("class", "icon");
42
-		$this->image=new HtmlIcon("icon-" . $this->identifier, $icon);
42
+		$this->image=new HtmlIcon("icon-".$this->identifier, $icon);
43 43
 		return $this->asTitle($title, $subHeader);
44 44
 	}
45 45
 
46 46
 	public function asImage($src, $title, $subHeader=NULL) {
47
-		$this->image=new HtmlImg("img-" . $this->identifier, $src, $title);
47
+		$this->image=new HtmlImg("img-".$this->identifier, $src, $title);
48 48
 		return $this->asTitle($title, $subHeader);
49 49
 	}
50 50
 
51 51
 	public function asTitle($title, $subHeader=NULL) {
52 52
 		if (!\is_object($title)) {
53
-			$this->content=new HtmlDoubleElement("content-" . $this->identifier, "div");
53
+			$this->content=new HtmlDoubleElement("content-".$this->identifier, "div");
54 54
 			$this->content->setContent($title);
55 55
 		} else {
56 56
 			$this->content=$title;
57 57
 		}
58 58
 		$this->content->setClass("content");
59 59
 		if (isset($subHeader)) {
60
-			$sub=new HtmlDoubleElement("subheader-" . $this->identifier, "div");
60
+			$sub=new HtmlDoubleElement("subheader-".$this->identifier, "div");
61 61
 			$sub->setClass("sub header");
62 62
 			$sub->setContent($subHeader);
63 63
 			$this->content->addContent($sub);
Please login to merge, or discard this patch.
Ajax/semantic/html/elements/HtmlButton.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	}
57 57
 
58 58
 	public function setFocusable($value=true) {
59
-		if ($value === true)
59
+		if ($value===true)
60 60
 			$this->setProperty("tabindex", "0");
61 61
 		else {
62 62
 			$this->removeProperty("tabindex");
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
 
67 67
 	public function setAnimated($content, $animation="") {
68 68
 		$this->setTagName("div");
69
-		$this->addToProperty("class", "animated " . $animation);
70
-		$visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div");
69
+		$this->addToProperty("class", "animated ".$animation);
70
+		$visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div");
71 71
 		$visible->setClass("visible content");
72 72
 		$visible->setContent($this->content);
73
-		$hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div");
73
+		$hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div");
74 74
 		$hidden->setClass("hidden content");
75 75
 		$hidden->setContent($content);
76
-		$this->content=array ($visible,$hidden );
76
+		$this->content=array($visible, $hidden);
77 77
 		return $hidden;
78 78
 	}
79 79
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	public function asIcon($icon) {
86 86
 		$iconO=$icon;
87 87
 		if (\is_string($icon)) {
88
-			$iconO=new HtmlIcon("icon-" . $this->identifier, $icon);
88
+			$iconO=new HtmlIcon("icon-".$this->identifier, $icon);
89 89
 		}
90 90
 		$this->addToProperty("class", "icon");
91 91
 		$this->content=$iconO;
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 	 * @return HtmlLabel
106 106
 	 */
107 107
 	public function addLabel($label, $before=false, $icon=NULL) {
108
-		$this->tagName="div";$prefix="";
109
-		if($before)
108
+		$this->tagName="div"; $prefix="";
109
+		if ($before)
110 110
 			$prefix="left ";
111 111
 		$this->addToProperty("class", $prefix."labeled");
112
-		$this->content=new HtmlButton("button-" . $this->identifier, $this->content);
112
+		$this->content=new HtmlButton("button-".$this->identifier, $this->content);
113 113
 		$this->content->setTagName("div");
114
-		$label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a");
114
+		$label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a");
115 115
 		$label->setBasic();
116 116
 		$this->addContent($label, $before);
117 117
 		return $label;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	public function fromArray($array) {
125 125
 		$array=parent::fromArray($array);
126
-		foreach ( $array as $key => $value ) {
126
+		foreach ($array as $key => $value) {
127 127
 			$this->setProperty($key, $value);
128 128
 		}
129 129
 		return $array;
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 		return $this->addToProperty("class", "positive");
138 138
 	}
139 139
 
140
-	public function setColor($color){
140
+	public function setColor($color) {
141 141
 		//TODO check button content
142
-		if(\is_array($this->content)){
143
-			foreach ($this->content as $content){
144
-				if($content instanceof HtmlButton)
142
+		if (\is_array($this->content)) {
143
+			foreach ($this->content as $content) {
144
+				if ($content instanceof HtmlButton)
145 145
 					$content->setColor($color);
146 146
 			}
147 147
 		}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @return HtmlButton
200 200
 	 */
201 201
 	public static function social($identifier, $social, $value=NULL) {
202
-		if ($value === NULL)
202
+		if ($value===NULL)
203 203
 			$value=\ucfirst($social);
204 204
 		$return=new HtmlButton($identifier, $value);
205 205
 		$return->addIcon($social);
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 	 * {@inheritDoc}
237 237
 	 * @see HtmlSemDoubleElement::asLink()
238 238
 	 */
239
-	public function asLink($href=NULL,$target=NULL) {
240
-		$lnk=new HtmlLink("lnk-".$this->identifier,$href,$this->content,$target);
239
+	public function asLink($href=NULL, $target=NULL) {
240
+		$lnk=new HtmlLink("lnk-".$this->identifier, $href, $this->content, $target);
241 241
 		$this->content=$lnk;
242 242
 		return $this;
243 243
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -27,23 +27,23 @@  discard block
 block discarded – undo
27 27
  * @property boolean $_edition
28 28
  * @property mixed _modelInstance
29 29
  */
30
-trait FieldAsTrait{
30
+trait FieldAsTrait {
31 31
 
32
-	abstract protected function _getFieldIdentifier($prefix,$name="");
33
-	abstract public function setValueFunction($index,$callback);
32
+	abstract protected function _getFieldIdentifier($prefix, $name="");
33
+	abstract public function setValueFunction($index, $callback);
34 34
 	abstract protected function _getFieldName($index);
35 35
 	abstract protected function _getFieldCaption($index);
36
-	abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL);
36
+	abstract protected function _buttonAsSubmit(BaseHtml&$button, $event, $url, $responseElement=NULL, $parameters=NULL);
37 37
 
38 38
 	/**
39 39
 	 * @param HtmlFormField $element
40 40
 	 * @param array $attributes
41 41
 	 */
42
-	protected function _applyAttributes($element,&$attributes,$index){
43
-		if(isset($attributes["jsCallback"])){
42
+	protected function _applyAttributes($element, &$attributes, $index) {
43
+		if (isset($attributes["jsCallback"])) {
44 44
 			$callback=$attributes["jsCallback"];
45
-			if(\is_callable($callback)){
46
-				$callback($element,$this->_modelInstance,$index);
45
+			if (\is_callable($callback)) {
46
+				$callback($element, $this->_modelInstance, $index);
47 47
 				unset($attributes["jsCallback"]);
48 48
 			}
49 49
 		}
@@ -53,43 +53,43 @@  discard block
 block discarded – undo
53 53
 		$element->fromArray($attributes);
54 54
 	}
55 55
 
56
-	private function _getLabelField($caption,$icon=NULL){
57
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
56
+	private function _getLabelField($caption, $icon=NULL) {
57
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
58 58
 		return $label;
59 59
 	}
60 60
 
61 61
 
62
-	protected function _addRules($element,&$attributes){
63
-		if(isset($attributes["rules"])){
62
+	protected function _addRules($element, &$attributes) {
63
+		if (isset($attributes["rules"])) {
64 64
 			$rules=$attributes["rules"];
65
-			if(\is_array($rules)){
65
+			if (\is_array($rules)) {
66 66
 				$element->addRules($rules);
67 67
 			}
68
-			else{
68
+			else {
69 69
 				$element->addRule($rules);
70 70
 			}
71 71
 			unset($attributes["rules"]);
72 72
 		}
73 73
 	}
74 74
 
75
-	protected function _prepareFormFields(&$field,$name,&$attributes){
75
+	protected function _prepareFormFields(&$field, $name, &$attributes) {
76 76
 		$field->setName($name);
77 77
 		$this->_addRules($field, $attributes);
78 78
 		return $field;
79 79
 	}
80 80
 
81
-	protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){
82
-		$this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){
81
+	protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) {
82
+		$this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){
83 83
 			$caption=$this->_getFieldCaption($index);
84 84
 			$name=$this->_getFieldName($index);
85
-			$id=$this->_getFieldIdentifier($prefix,$name);
86
-			if(isset($attributes["name"])){
85
+			$id=$this->_getFieldIdentifier($prefix, $name);
86
+			if (isset($attributes["name"])) {
87 87
 				$name=$attributes["name"];
88 88
 				unset($attributes["name"]);
89 89
 			}
90
-			$element=$elementCallback($id,$name,$value,$caption);
91
-			if(\is_array($attributes)){
92
-				$this->_applyAttributes($element, $attributes,$index);
90
+			$element=$elementCallback($id, $name, $value, $caption);
91
+			if (\is_array($attributes)) {
92
+				$this->_applyAttributes($element, $attributes, $index);
93 93
 			}
94 94
 			$element->setDisabled(!$this->_edition);
95 95
 			return $element;
@@ -98,178 +98,178 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 
101
-	public function fieldAsProgress($index,$label=NULL, $attributes=array()){
102
-		$this->setValueFunction($index,function($value) use($label,$attributes){
103
-			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes);
101
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
102
+		$this->setValueFunction($index, function($value) use($label, $attributes){
103
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
104 104
 			return $pb;
105 105
 		});
106 106
 			return $this;
107 107
 	}
108 108
 
109
-	public function fieldAsRating($index,$max=5, $icon=""){
110
-		$this->setValueFunction($index,function($value) use($max,$icon){
111
-			$rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon);
109
+	public function fieldAsRating($index, $max=5, $icon="") {
110
+		$this->setValueFunction($index, function($value) use($max, $icon){
111
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
112 112
 			return $rating;
113 113
 		});
114 114
 			return $this;
115 115
 	}
116 116
 
117
-	public function fieldAsLabel($index,$icon=NULL,$attributes=NULL){
118
-		return $this->_fieldAs(function($id,$name,$value) use($icon){
119
-			$lbl=new HtmlLabel($id,$value);
120
-			if(isset($icon))
117
+	public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) {
118
+		return $this->_fieldAs(function($id, $name, $value) use($icon){
119
+			$lbl=new HtmlLabel($id, $value);
120
+			if (isset($icon))
121 121
 				$lbl->addIcon($icon);
122 122
 				return $lbl;
123
-		}, $index,$attributes,"label");
123
+		}, $index, $attributes, "label");
124 124
 	}
125 125
 
126
-	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
127
-		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
128
-			$header=new HtmlHeader($id,$niveau,$value);
129
-			if(isset($icon))
126
+	public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) {
127
+		return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){
128
+			$header=new HtmlHeader($id, $niveau, $value);
129
+			if (isset($icon))
130 130
 				$header->asIcon($icon, $value);
131 131
 			return $header;
132
-		}, $index,$attributes,"header");
132
+		}, $index, $attributes, "header");
133 133
 	}
134 134
 
135 135
 
136
-	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
137
-		$this->setValueFunction($index,function($img) use($size,$circular){
138
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
136
+	public function fieldAsImage($index, $size=Size::MINI, $circular=false) {
137
+		$this->setValueFunction($index, function($img) use($size, $circular){
138
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
139 139
 			return $image;
140 140
 		});
141 141
 			return $this;
142 142
 	}
143 143
 
144
-	public function fieldAsFlag($index){
145
-		$this->setValueFunction($index,function($flag){
146
-			$flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag);
144
+	public function fieldAsFlag($index) {
145
+		$this->setValueFunction($index, function($flag) {
146
+			$flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag);
147 147
 			return $flag;
148 148
 		});
149 149
 			return $this;
150 150
 	}
151 151
 
152
-	public function fieldAsAvatar($index,$attributes=NULL){
153
-		return $this->_fieldAs(function($id,$name,$value){
154
-			$img=new HtmlImage($id,$value);
152
+	public function fieldAsAvatar($index, $attributes=NULL) {
153
+		return $this->_fieldAs(function($id, $name, $value) {
154
+			$img=new HtmlImage($id, $value);
155 155
 			$img->asAvatar();
156 156
 			return $img;
157
-		}, $index,$attributes,"avatar");
157
+		}, $index, $attributes, "avatar");
158 158
 	}
159 159
 
160
-	public function fieldAsRadio($index,$attributes=NULL){
161
-		return $this->_fieldAs(function($id,$name,$value) use($attributes){
162
-			$input= new HtmlRadio($id,$name,$value,$value);
160
+	public function fieldAsRadio($index, $attributes=NULL) {
161
+		return $this->_fieldAs(function($id, $name, $value) use($attributes){
162
+			$input=new HtmlRadio($id, $name, $value, $value);
163 163
 			return $this->_prepareFormFields($input, $name, $attributes);
164
-		}, $index,$attributes,"radio");
164
+		}, $index, $attributes, "radio");
165 165
 	}
166 166
 
167
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
168
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){
169
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
170
-		}, $index,$attributes,"radios");
167
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
168
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){
169
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
170
+		}, $index, $attributes, "radios");
171 171
 	}
172 172
 
173
-	public function fieldAsInput($index,$attributes=NULL){
174
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
175
-			$input= new HtmlFormInput($id,$caption,"text",$value);
173
+	public function fieldAsInput($index, $attributes=NULL) {
174
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
175
+			$input=new HtmlFormInput($id, $caption, "text", $value);
176 176
 			return $this->_prepareFormFields($input, $name, $attributes);
177
-		}, $index,$attributes,"input");
177
+		}, $index, $attributes, "input");
178 178
 	}
179 179
 
180
-	public function fieldAsTextarea($index,$attributes=NULL){
181
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
182
-			$textarea=new HtmlFormTextarea($id,$caption,$value);
180
+	public function fieldAsTextarea($index, $attributes=NULL) {
181
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
182
+			$textarea=new HtmlFormTextarea($id, $caption, $value);
183 183
 			return $this->_prepareFormFields($textarea, $name, $attributes);
184
-		}, $index,$attributes,"textarea");
184
+		}, $index, $attributes, "textarea");
185 185
 	}
186 186
 
187
-	public function fieldAsHidden($index,$attributes=NULL){
188
-		if(!\is_array($attributes)){
187
+	public function fieldAsHidden($index, $attributes=NULL) {
188
+		if (!\is_array($attributes)) {
189 189
 			$attributes=[];
190 190
 		}
191 191
 		$attributes["inputType"]="hidden";
192
-		return $this->fieldAsInput($index,$attributes);
192
+		return $this->fieldAsInput($index, $attributes);
193 193
 	}
194 194
 
195
-	public function fieldAsCheckbox($index,$attributes=NULL){
196
-		return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){
197
-			if($caption===null || $caption==="")
195
+	public function fieldAsCheckbox($index, $attributes=NULL) {
196
+		return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){
197
+			if ($caption===null || $caption==="")
198 198
 				$caption="";
199
-			$input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier());
199
+			$input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier());
200 200
 			$input->setChecked(JString::isBooleanTrue($value));
201 201
 			return $this->_prepareFormFields($input, $name, $attributes);
202
-		}, $index,$attributes,"ck");
202
+		}, $index, $attributes, "ck");
203 203
 	}
204 204
 
205
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
206
-		return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){
207
-			$dd=new HtmlFormDropdown($id,$elements,$caption,$value);
208
-			$dd->asSelect($name,$multiple);
205
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
206
+		return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){
207
+			$dd=new HtmlFormDropdown($id, $elements, $caption, $value);
208
+			$dd->asSelect($name, $multiple);
209 209
 			return $this->_prepareFormFields($dd, $name, $attributes);
210
-		}, $index,$attributes,"dd");
210
+		}, $index, $attributes, "dd");
211 211
 	}
212 212
 
213
-	public function fieldAsMessage($index,$attributes=NULL){
214
-		return $this->_fieldAs(function($id,$name,$value,$caption){
215
-			$mess= new HtmlMessage("message-".$id,$caption);
213
+	public function fieldAsMessage($index, $attributes=NULL) {
214
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
215
+			$mess=new HtmlMessage("message-".$id, $caption);
216 216
 			$mess->addHeader($value);
217 217
 			return $mess;
218
-		}, $index,$attributes,"message");
218
+		}, $index, $attributes, "message");
219 219
 	}
220 220
 
221
-	public function fieldAsLink($index,$attributes=NULL){
222
-		return $this->_fieldAs(function($id,$name,$value,$caption){
223
-			$lnk= new HtmlLink("message-".$id,"#",$caption);
221
+	public function fieldAsLink($index, $attributes=NULL) {
222
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
223
+			$lnk=new HtmlLink("message-".$id, "#", $caption);
224 224
 			return $lnk;
225
-		}, $index,$attributes,"link");
225
+		}, $index, $attributes, "link");
226 226
 	}
227 227
 
228 228
 	/**Change fields type
229 229
 	 * @param array $types an array or associative array $type=>$attributes
230 230
 	 */
231
-	public function fieldsAs(array $types){
231
+	public function fieldsAs(array $types) {
232 232
 		$i=0;
233
-		if(JArray::isAssociative($types)){
234
-			foreach ($types as $type=>$attributes){
235
-				if(\is_int($type))
236
-					$this->fieldAs($i++,$attributes,[]);
237
-				else{
238
-					$type=preg_replace('/\d/', '', $type );
239
-					$this->fieldAs($i++,$type,$attributes);
233
+		if (JArray::isAssociative($types)) {
234
+			foreach ($types as $type=>$attributes) {
235
+				if (\is_int($type))
236
+					$this->fieldAs($i++, $attributes, []);
237
+				else {
238
+					$type=preg_replace('/\d/', '', $type);
239
+					$this->fieldAs($i++, $type, $attributes);
240 240
 				}
241 241
 			}
242
-		}else{
243
-			foreach ($types as $type){
244
-				$this->fieldAs($i++,$type);
242
+		} else {
243
+			foreach ($types as $type) {
244
+				$this->fieldAs($i++, $type);
245 245
 			}
246 246
 		}
247 247
 	}
248 248
 
249
-	public function fieldAs($index,$type,$attributes=NULL){
249
+	public function fieldAs($index, $type, $attributes=NULL) {
250 250
 		$method="fieldAs".\ucfirst($type);
251
-		if(\method_exists($this, $method)){
252
-			if(!\is_array($attributes)){
251
+		if (\method_exists($this, $method)) {
252
+			if (!\is_array($attributes)) {
253 253
 				$attributes=[$index];
254
-			}else{
254
+			} else {
255 255
 				\array_unshift($attributes, $index);
256 256
 			}
257
-			\call_user_func_array([$this,$method], $attributes);
257
+			\call_user_func_array([$this, $method], $attributes);
258 258
 		}
259 259
 	}
260 260
 
261
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
262
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){
263
-			$button=new HtmlButton($id,$caption,$cssStyle);
264
-			$this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]);
261
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
262
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){
263
+			$button=new HtmlButton($id, $caption, $cssStyle);
264
+			$this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]);
265 265
 			return $button;
266
-		}, $index,$attributes,"submit");
266
+		}, $index, $attributes, "submit");
267 267
 	}
268 268
 
269
-	public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){
270
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
271
-			$button=new HtmlButton($id,$value,$cssStyle);
269
+	public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) {
270
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){
271
+			$button=new HtmlButton($id, $value, $cssStyle);
272 272
 			return $button;
273
-		}, $index,$attributes,"button");
273
+		}, $index, $attributes, "button");
274 274
 	}
275 275
 }
276 276
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/common/html/traits/BaseHtmlEventsTrait.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
  * @property string identifier
13 13
  * @property BaseHtml _self
14 14
  */
15
-trait BaseHtmlEventsTrait{
15
+trait BaseHtmlEventsTrait {
16 16
 
17
-	protected $_events=array ();
17
+	protected $_events=array();
18 18
 
19 19
 	/**
20 20
 	 * @param string $event
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
 	 * @return BaseHtml
25 25
 	 */
26 26
 	public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
27
-		if ($stopPropagation === true) {
28
-			$jsCode=Javascript::$stopPropagation . $jsCode;
27
+		if ($stopPropagation===true) {
28
+			$jsCode=Javascript::$stopPropagation.$jsCode;
29 29
 		}
30
-		if ($preventDefault === true) {
31
-			$jsCode=Javascript::$preventDefault . $jsCode;
30
+		if ($preventDefault===true) {
31
+			$jsCode=Javascript::$preventDefault.$jsCode;
32 32
 		}
33 33
 		return $this->_addEvent($event, $jsCode);
34 34
 	}
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 			if (\is_array($this->_events[$event])) {
44 44
 				$this->_events[$event][]=$jsCode;
45 45
 			} else {
46
-				$this->_events[$event]=array ($this->_events[$event],$jsCode );
46
+				$this->_events[$event]=array($this->_events[$event], $jsCode);
47 47
 			}
48 48
 		} else {
49 49
 			$this->_events[$event]=$jsCode;
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
 		return $this->onClick($jsCode);
71 71
 	}
72 72
 
73
-	public function onCreate($jsCode){
74
-		if(isset($this->_events["_create"])){
73
+	public function onCreate($jsCode) {
74
+		if (isset($this->_events["_create"])) {
75 75
 			$this->_events["_create"][]=$jsCode;
76
-		}else{
76
+		} else {
77 77
 			$this->_events["_create"]=[$jsCode];
78 78
 		}
79 79
 		return $this;
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 	public function addEventsOnRun(JsUtils $js=NULL) {
83 83
 		$this->_eventsOnCreate($js);
84 84
 		if (isset($this->_bsComponent)) {
85
-			foreach ( $this->_events as $event => $jsCode ) {
85
+			foreach ($this->_events as $event => $jsCode) {
86 86
 				$code=$jsCode;
87 87
 				if (\is_array($jsCode)) {
88 88
 					$code="";
89
-					foreach ( $jsCode as $jsC ) {
89
+					foreach ($jsCode as $jsC) {
90 90
 						if ($jsC instanceof AjaxCall) {
91
-							$code.="\n" . $jsC->compile($js);
91
+							$code.="\n".$jsC->compile($js);
92 92
 						} else {
93
-							$code.="\n" . $jsC;
93
+							$code.="\n".$jsC;
94 94
 						}
95 95
 					}
96 96
 				} elseif ($jsCode instanceof AjaxCall) {
@@ -98,18 +98,18 @@  discard block
 block discarded – undo
98 98
 				}
99 99
 				$this->_bsComponent->addEvent($event, $code);
100 100
 			}
101
-			$this->_events=array ();
101
+			$this->_events=array();
102 102
 		}
103 103
 	}
104 104
 
105
-	protected function _eventsOnCreate(JsUtils $js=NULL){
106
-		if(isset($this->_events["_create"])){
105
+	protected function _eventsOnCreate(JsUtils $js=NULL) {
106
+		if (isset($this->_events["_create"])) {
107 107
 			$create=$this->_events["_create"];
108
-			if(\is_array($create)){
108
+			if (\is_array($create)) {
109 109
 				$create=\implode("", $create);
110 110
 			}
111
-			if(isset($js) && $create!=="")
112
-				$js->exec($create,true);
111
+			if (isset($js) && $create!=="")
112
+				$js->exec($create, true);
113 113
 			unset($this->_events["_create"]);
114 114
 		}
115 115
 	}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @return BaseHtml
124 124
 	 */
125 125
 	public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) {
126
-		$params=array ("url" => $url,"responseElement" => $responseElement );
126
+		$params=array("url" => $url, "responseElement" => $responseElement);
127 127
 		$params=array_merge($params, $parameters);
128 128
 		$this->_addEvent($event, new AjaxCall($operation, $params));
129 129
 		return $this;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	}
157 157
 
158 158
 	public function jsDoJquery($jqueryCall, $param="") {
159
-		return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . Javascript::prep_value($param) . ");";
159
+		return "$('#".$this->identifier."').".$jqueryCall."(".Javascript::prep_value($param).");";
160 160
 	}
161 161
 
162 162
 	public function executeOnRun($jsCode) {
@@ -176,6 +176,6 @@  discard block
 block discarded – undo
176 176
 	}
177 177
 
178 178
 	public function jsToggle($value) {
179
-		return $this->jsDoJquery("toggle",$value);
179
+		return $this->jsDoJquery("toggle", $value);
180 180
 	}
181 181
 }
Please login to merge, or discard this patch.