Completed
Push — master ( 499e5d...b007d6 )
by Jean-Christophe
03:09
created
Ajax/semantic/html/base/traits/BaseTrait.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
  * @property string $identifier
13 13
  */
14 14
 trait BaseTrait {
15
-	protected $_variations=[ ];
16
-	protected $_states=[ ];
15
+	protected $_variations=[];
16
+	protected $_states=[];
17 17
 	protected $_baseClass;
18 18
 
19 19
 	abstract protected function setPropertyCtrl($name, $value, $typeCtrl);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 	abstract public function setProperty($name, $value);
28 28
 
29
-	abstract public function addContent($content,$before=false);
29
+	abstract public function addContent($content, $before=false);
30 30
 
31 31
 	abstract public function onCreate($jsCode);
32 32
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$this->setProperty("class", $this->_baseClass);
48 48
 		if (\is_string($variations))
49 49
 			$variations=\explode(" ", $variations);
50
-		foreach ( $variations as $variation ) {
50
+		foreach ($variations as $variation) {
51 51
 			$this->addVariation($variation);
52 52
 		}
53 53
 		return $this;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	public function addVariations($variations=array()) {
62 62
 		if (\is_string($variations))
63 63
 			$variations=\explode(" ", $variations);
64
-		foreach ( $variations as $variation ) {
64
+		foreach ($variations as $variation) {
65 65
 			$this->addVariation($variation);
66 66
 		}
67 67
 		return $this;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	public function addStates($states=array()) {
71 71
 		if (\is_string($states))
72 72
 			$states=\explode(" ", $states);
73
-		foreach ( $states as $state ) {
73
+		foreach ($states as $state) {
74 74
 			$this->addState($state);
75 75
 		}
76 76
 		return $this;
@@ -80,17 +80,17 @@  discard block
 block discarded – undo
80 80
 		$this->setProperty("class", $this->_baseClass);
81 81
 		if (\is_string($states))
82 82
 			$states=\explode(" ", $states);
83
-		foreach ( $states as $state ) {
83
+		foreach ($states as $state) {
84 84
 			$this->addState($state);
85 85
 		}
86 86
 		return $this;
87 87
 	}
88 88
 
89 89
 	public function addIcon($icon, $before=true) {
90
-		return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before);
90
+		return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before);
91 91
 	}
92 92
 
93
-	public function addSticky($context="body"){
93
+	public function addSticky($context="body") {
94 94
 		$this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});");
95 95
 		return $this;
96 96
 	}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement
112 112
 	 */
113 113
 	public function setDisabled($disable=true) {
114
-		if($disable)
114
+		if ($disable)
115 115
 			$this->addToProperty("class", "disabled");
116 116
 		return $this;
117 117
 	}
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return \Ajax\semantic\html\base\HtmlSemDoubleElement
139 139
 	 */
140
-	public function asHeader(){
140
+	public function asHeader() {
141 141
 		return $this->addToProperty("class", "header");
142 142
 	}
143 143
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * show it is currently the active user selection
146 146
 	 * @return \Ajax\semantic\html\base\HtmlSemDoubleElement
147 147
 	 */
148
-	public function setActive($value=true){
148
+	public function setActive($value=true) {
149 149
 		return $this->addToProperty("class", "active");
150 150
 	}
151 151
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	}
162 162
 
163 163
 	public function setFloated($direction="right") {
164
-		return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated"));
164
+		return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated"));
165 165
 	}
166 166
 
167 167
 	public function floatRight() {
Please login to merge, or discard this patch.
Ajax/semantic/widgets/dataelement/DataElement.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,33 +19,33 @@
 block discarded – undo
19 19
 class DataElement extends Widget {
20 20
 
21 21
 	public function __construct($identifier, $modelInstance=NULL) {
22
-		parent::__construct($identifier, null,$modelInstance);
23
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,2), false);
22
+		parent::__construct($identifier, null, $modelInstance);
23
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 2), false);
24 24
 		$this->content["table"]->setDefinition();
25 25
 	}
26 26
 
27
-	public function compile(JsUtils $js=NULL,&$view=NULL){
27
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
28 28
 		$this->_instanceViewer->setInstance($this->_modelInstance);
29 29
 
30 30
 		$table=$this->content["table"];
31 31
 		$this->_generateContent($table);
32 32
 
33
-		if(isset($this->_toolbar)){
33
+		if (isset($this->_toolbar)) {
34 34
 			$this->_setToolbarPosition($table);
35 35
 		}
36
-		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
37
-		return parent::compile($js,$view);
36
+		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
37
+		return parent::compile($js, $view);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * @param HtmlTable $table
42 42
 	 */
43
-	protected function _generateContent($table){
43
+	protected function _generateContent($table) {
44 44
 		$captions=$this->_instanceViewer->getCaptions();
45
-		$values= $this->_instanceViewer->getValues();
45
+		$values=$this->_instanceViewer->getValues();
46 46
 		$count=$this->_instanceViewer->count();
47
-		for($i=0;$i<$count;$i++){
48
-			$table->addRow([$captions[$i],$values[$i]]);
47
+		for ($i=0; $i<$count; $i++) {
48
+			$table->addRow([$captions[$i], $values[$i]]);
49 49
 		}
50 50
 	}
51 51
 
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	protected $_hasCheckboxes;
31 31
 	protected $_compileParts;
32 32
 
33
-	public function run(JsUtils $js){
34
-		if($this->_hasCheckboxes && isset($js)){
33
+	public function run(JsUtils $js) {
34
+		if ($this->_hasCheckboxes && isset($js)) {
35 35
 			$js->execOn("change", "#".$this->identifier." [name='selection[]']", "
36 36
 		var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true;
37 37
 		\$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}});
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 		parent::run($js);
41 41
 	}
42 42
 
43
-	public function __construct($identifier,$model,$modelInstance=NULL) {
44
-		parent::__construct($identifier, $model,$modelInstance);
45
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
43
+	public function __construct($identifier, $model, $modelInstance=NULL) {
44
+		parent::__construct($identifier, $model, $modelInstance);
45
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
46 46
 	}
47 47
 
48 48
 	/**
@@ -54,61 +54,61 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 
57
-	public function compile(JsUtils $js=NULL,&$view=NULL){
57
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
58 58
 		$this->_instanceViewer->setInstance($this->_model);
59 59
 		$captions=$this->_instanceViewer->getCaptions();
60 60
 
61 61
 		$table=$this->content["table"];
62 62
 
63
-		if($this->_hasCheckboxes){
63
+		if ($this->_hasCheckboxes) {
64 64
 			$this->_generateMainCheckbox($captions);
65 65
 		}
66 66
 
67 67
 		$table->setRowCount(0, \sizeof($captions));
68 68
 		$table->setHeaderValues($captions);
69
-		if(isset($this->_compileParts))
69
+		if (isset($this->_compileParts))
70 70
 			$table->setCompileParts($this->_compileParts);
71
-		if(isset($this->_searchField) && isset($js)){
72
-			$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]);
71
+		if (isset($this->_searchField) && isset($js)) {
72
+			$this->_searchField->postOn("change", $this->_urls, "{'s':$(this).val()}", "-#".$this->identifier." tbody", ["preventDefault"=>false]);
73 73
 		}
74 74
 
75 75
 		$this->_generateContent($table);
76 76
 
77
-		if($this->_hasCheckboxes && $table->hasPart("thead")){
78
-				$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
77
+		if ($this->_hasCheckboxes && $table->hasPart("thead")) {
78
+				$table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort");
79 79
 		}
80 80
 
81
-		if(isset($this->_pagination) && $this->_pagination->getVisible()){
81
+		if (isset($this->_pagination) && $this->_pagination->getVisible()) {
82 82
 			$this->_generatePagination($table);
83 83
 		}
84
-		if(isset($this->_toolbar)){
84
+		if (isset($this->_toolbar)) {
85 85
 			$this->_setToolbarPosition($table, $captions);
86 86
 		}
87
-		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
88
-		return parent::compile($js,$view);
87
+		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
88
+		return parent::compile($js, $view);
89 89
 	}
90 90
 
91
-	private function _generateMainCheckbox(&$captions){
92
-		$ck=new HtmlCheckbox("main-ck-".$this->identifier,"");
91
+	private function _generateMainCheckbox(&$captions) {
92
+		$ck=new HtmlCheckbox("main-ck-".$this->identifier, "");
93 93
 		$ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);");
94 94
 		$ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);");
95 95
 		\array_unshift($captions, $ck);
96 96
 	}
97 97
 
98
-	protected function _generateContent($table){
98
+	protected function _generateContent($table) {
99 99
 		$objects=$this->_modelInstance;
100
-		if(isset($this->_pagination)){
100
+		if (isset($this->_pagination)) {
101 101
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
102 102
 		}
103 103
 		InstanceViewer::setIndex(0);
104
-		$table->fromDatabaseObjects($objects, function($instance){
104
+		$table->fromDatabaseObjects($objects, function($instance) {
105 105
 			$this->_instanceViewer->setInstance($instance);
106 106
 			InstanceViewer::$index++;
107
-			$result= $this->_instanceViewer->getValues();
108
-			if($this->_hasCheckboxes){
109
-				$ck=new HtmlCheckbox("ck-".$this->identifier,"");
107
+			$result=$this->_instanceViewer->getValues();
108
+			if ($this->_hasCheckboxes) {
109
+				$ck=new HtmlCheckbox("ck-".$this->identifier, "");
110 110
 				$field=$ck->getField();
111
-				$field->setProperty("value",$this->_instanceViewer->getIdentifier());
111
+				$field->setProperty("value", $this->_instanceViewer->getIdentifier());
112 112
 				$field->setProperty("name", "selection[]");
113 113
 				\array_unshift($result, $ck);
114 114
 			}
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
 		});
117 117
 	}
118 118
 
119
-	private function _generatePagination($table){
119
+	private function _generatePagination($table) {
120 120
 		$footer=$table->getFooter();
121 121
 		$footer->mergeCol();
122
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
122
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
123 123
 		$menu->floatRight();
124 124
 		$menu->setActiveItem($this->_pagination->getPage()-1);
125 125
 		$footer->setValues($menu);
126
-		$menu->postOnClick($this->_urls,"{'p':$(this).attr('data-page')}","-#".$this->identifier." tbody",["preventDefault"=>false]);
126
+		$menu->postOnClick($this->_urls, "{'p':$(this).attr('data-page')}", "-#".$this->identifier." tbody", ["preventDefault"=>false]);
127 127
 	}
128 128
 
129
-	protected function _setToolbarPosition($table,$captions=NULL){
130
-		switch ($this->_toolbarPosition){
129
+	protected function _setToolbarPosition($table, $captions=NULL) {
130
+		switch ($this->_toolbarPosition) {
131 131
 			case PositionInTable::BEFORETABLE:case PositionInTable::AFTERTABLE:
132
-				if(isset($this->_compileParts)===false){
132
+				if (isset($this->_compileParts)===false) {
133 133
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
134 134
 				}
135 135
 				break;
136 136
 			case PositionInTable::HEADER:case PositionInTable::FOOTER: case PositionInTable::BODY:
137
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
137
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
138 138
 				break;
139 139
 		}
140 140
 	}
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 	 * @param callable $callback function called after the field compilation
147 147
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
148 148
 	 */
149
-	public function afterCompile($index,$callback){
150
-		$this->_instanceViewer->afterCompile($index,$callback);
149
+	public function afterCompile($index, $callback) {
150
+		$this->_instanceViewer->afterCompile($index, $callback);
151 151
 		return $this;
152 152
 	}
153 153
 
154
-	private function addToolbarRow($part,$table,$captions){
154
+	private function addToolbarRow($part, $table, $captions) {
155 155
 		$row=$table->getPart($part)->addRow(\sizeof($captions));
156 156
 		$row->mergeCol();
157 157
 		$row->setValues([$this->_toolbar]);
158 158
 	}
159 159
 
160
-	public function getHtmlComponent(){
160
+	public function getHtmlComponent() {
161 161
 		return $this->content["table"];
162 162
 	}
163 163
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 		return $this;
171 171
 	}
172 172
 
173
-	public function paginate($items_per_page=10,$page=1){
174
-		$this->_pagination=new Pagination($items_per_page,4,$page);
173
+	public function paginate($items_per_page=10, $page=1) {
174
+		$this->_pagination=new Pagination($items_per_page, 4, $page);
175 175
 	}
176 176
 
177 177
 	public function getHasCheckboxes() {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		return $this;
184 184
 	}
185 185
 
186
-	public function refresh($compileParts=["tbody"]){
186
+	public function refresh($compileParts=["tbody"]) {
187 187
 		$this->_compileParts=$compileParts;
188 188
 		return $this;
189 189
 	}
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	 * @param callable $callback
193 193
 	 * @return callable
194 194
 	 */
195
-	private function getFieldButtonCallable($caption,$callback=null){
196
-		return $this->getCallable("getFieldButton",[$caption],$callback);
195
+	private function getFieldButtonCallable($caption, $callback=null) {
196
+		return $this->getCallable("getFieldButton", [$caption], $callback);
197 197
 	}
198 198
 
199 199
 	/**
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
 	 * @param callable $callback
202 202
 	 * @return callable
203 203
 	 */
204
-	private function getCallable($thisCallback,$parameters,$callback=null){
205
-		$result=function($instance) use($thisCallback,$parameters,$callback){
206
-			$object=call_user_func_array(array($this,$thisCallback), $parameters);
207
-			if(isset($callback)){
208
-				if(\is_callable($callback)){
209
-					$callback($object,$instance);
204
+	private function getCallable($thisCallback, $parameters, $callback=null) {
205
+		$result=function($instance) use($thisCallback, $parameters, $callback){
206
+			$object=call_user_func_array(array($this, $thisCallback), $parameters);
207
+			if (isset($callback)) {
208
+				if (\is_callable($callback)) {
209
+					$callback($object, $instance);
210 210
 				}
211 211
 			}
212
-			if($object instanceof HtmlSemDoubleElement){
213
-				$object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier());
212
+			if ($object instanceof HtmlSemDoubleElement) {
213
+				$object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier());
214 214
 			}
215 215
 			return $object;
216 216
 		};
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 * @param string $caption
222 222
 	 * @return HtmlButton
223 223
 	 */
224
-	private function getFieldButton($caption){
225
-		return new HtmlButton("",$caption);
224
+	private function getFieldButton($caption) {
225
+		return new HtmlButton("", $caption);
226 226
 	}
227 227
 
228 228
 	/**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	 * @param callable $callback
232 232
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
233 233
 	 */
234
-	public function addFieldButton($caption,$callback=null){
235
-		$this->addField($this->getCallable("getFieldButton",[$caption],$callback));
234
+	public function addFieldButton($caption, $callback=null) {
235
+		$this->addField($this->getCallable("getFieldButton", [$caption], $callback));
236 236
 		return $this;
237 237
 	}
238 238
 
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 	 * @param callable $callback
244 244
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
245 245
 	 */
246
-	public function insertFieldButton($index,$caption,$callback=null){
247
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$callback));
246
+	public function insertFieldButton($index, $caption, $callback=null) {
247
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $callback));
248 248
 		return $this;
249 249
 	}
250 250
 
@@ -255,60 +255,60 @@  discard block
 block discarded – undo
255 255
 	 * @param callable $callback
256 256
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
257 257
 	 */
258
-	public function insertInFieldButton($index,$caption,$callback=null){
259
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$callback));
258
+	public function insertInFieldButton($index, $caption, $callback=null) {
259
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $callback));
260 260
 		return $this;
261 261
 	}
262 262
 
263
-	private function addDefaultButton($icon,$class=null,$callback=null){
264
-		$this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback));
263
+	private function addDefaultButton($icon, $class=null, $callback=null) {
264
+		$this->addField($this->getCallable("getDefaultButton", [$icon, $class], $callback));
265 265
 		return $this;
266 266
 	}
267 267
 
268
-	private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){
269
-		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback));
268
+	private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) {
269
+		$this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class], $callback));
270 270
 		return $this;
271 271
 	}
272 272
 
273
-	private function getDefaultButton($icon,$class=null){
273
+	private function getDefaultButton($icon, $class=null) {
274 274
 		$bt=$this->getFieldButton("");
275 275
 		$bt->asIcon($icon);
276
-		if(isset($class))
276
+		if (isset($class))
277 277
 			$bt->addToProperty("class", $class);
278 278
 		return $bt;
279 279
 	}
280 280
 
281
-	public function addDeleteButton($callback=null){
282
-		return $this->addDefaultButton("remove","delete red basic",$callback);
281
+	public function addDeleteButton($callback=null) {
282
+		return $this->addDefaultButton("remove", "delete red basic", $callback);
283 283
 	}
284 284
 
285
-	public function addEditButton($callback=null){
286
-		return $this->addDefaultButton("edit","edit basic",$callback);
285
+	public function addEditButton($callback=null) {
286
+		return $this->addDefaultButton("edit", "edit basic", $callback);
287 287
 	}
288 288
 
289
-	public function addEditDeleteButtons($callbackEdit=null,$callbackDelete=null){
289
+	public function addEditDeleteButtons($callbackEdit=null, $callbackDelete=null) {
290 290
 		$this->addEditButton($callbackEdit);
291 291
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
292
-		$this->insertDeleteButtonIn($index,$callbackDelete);
292
+		$this->insertDeleteButtonIn($index, $callbackDelete);
293 293
 		return $this;
294 294
 	}
295 295
 
296
-	public function insertDeleteButtonIn($index,$callback=null){
297
-		return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback);
296
+	public function insertDeleteButtonIn($index, $callback=null) {
297
+		return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback);
298 298
 	}
299 299
 
300
-	public function insertEditButtonIn($index,$callback=null){
301
-		return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback);
300
+	public function insertEditButtonIn($index, $callback=null) {
301
+		return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback);
302 302
 	}
303 303
 
304
-	public function addSearchInToolbar($position=Direction::RIGHT){
304
+	public function addSearchInToolbar($position=Direction::RIGHT) {
305 305
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
306 306
 	}
307 307
 
308
-	public function getSearchField(){
309
-		if(isset($this->_searchField)===false){
310
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
311
-			$this->_searchField->addIcon("search",Direction::RIGHT);
308
+	public function getSearchField() {
309
+		if (isset($this->_searchField)===false) {
310
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
311
+			$this->_searchField->addIcon("search", Direction::RIGHT);
312 312
 		}
313 313
 		return $this->_searchField;
314 314
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/dataform/FormFieldAsTrait.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -15,21 +15,21 @@  discard block
 block discarded – undo
15 15
  * @property object $_modelInstance
16 16
  */
17 17
 
18
-trait FormFieldAsTrait{
18
+trait FormFieldAsTrait {
19 19
 
20 20
 	abstract protected function _getFieldIdentifier($prefix);
21
-	abstract public function setValueFunction($index,$callback);
22
-	abstract protected function _applyAttributes($element,&$attributes,$index);
21
+	abstract public function setValueFunction($index, $callback);
22
+	abstract protected function _applyAttributes($element, &$attributes, $index);
23 23
 
24
-	private function _getLabelField($caption,$icon=NULL){
25
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
24
+	private function _getLabelField($caption, $icon=NULL) {
25
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
26 26
 		return $label;
27 27
 	}
28 28
 
29
-	protected function _addRules($element,&$attributes){
30
-		if(isset($attributes["rules"])){
29
+	protected function _addRules($element, &$attributes) {
30
+		if (isset($attributes["rules"])) {
31 31
 			$rules=$attributes["rules"];
32
-			if(\is_array($rules)){
32
+			if (\is_array($rules)) {
33 33
 				$element->addRules($rules);
34 34
 			}
35 35
 			else
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
 		}
39 39
 	}
40 40
 
41
-	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$identifier=null){
42
-		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback){
41
+	protected function _fieldAs($elementCallback, $index, $attributes=NULL, $identifier=null) {
42
+		$this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback){
43 43
 			$caption=$this->_instanceViewer->getCaption($index);
44 44
 			$name=$this->_instanceViewer->getFieldName($index);
45
-			$element=$elementCallback($this->getIdentifier()."-".$name,$name,$value,$caption);
46
-			if(\is_array($attributes)){
47
-				$this->_applyAttributes($element, $attributes,$index);
45
+			$element=$elementCallback($this->getIdentifier()."-".$name, $name, $value, $caption);
46
+			if (\is_array($attributes)) {
47
+				$this->_applyAttributes($element, $attributes, $index);
48 48
 			}
49 49
 			return $element;
50 50
 		});
@@ -52,53 +52,53 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 
55
-	public function fieldAsRadio($index,$attributes=NULL){
56
-		return $this->_fieldAs(function($id,$name,$value,$caption){
57
-			return new HtmlFormRadio($id,$name,$caption,$value);
58
-		}, $index,$attributes);
55
+	public function fieldAsRadio($index, $attributes=NULL) {
56
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
57
+			return new HtmlFormRadio($id, $name, $caption, $value);
58
+		}, $index, $attributes);
59 59
 	}
60 60
 
61
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
62
-		return $this->_fieldAs(function($id,$name,$value,$caption,$elements){
63
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
64
-		}, $index,$attributes);
61
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
62
+		return $this->_fieldAs(function($id, $name, $value, $caption, $elements) {
63
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
64
+		}, $index, $attributes);
65 65
 	}
66 66
 
67
-	public function fieldAsTextarea($index,$attributes=NULL){
68
-		return $this->_fieldAs(function($id,$name,$value,$caption){
69
-			$textarea=new HtmlFormTextarea($id,$caption,$value);
67
+	public function fieldAsTextarea($index, $attributes=NULL) {
68
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
69
+			$textarea=new HtmlFormTextarea($id, $caption, $value);
70 70
 			$textarea->setName($name);
71 71
 			return $textarea;
72
-		}, $index,$attributes);
72
+		}, $index, $attributes);
73 73
 	}
74 74
 
75
-	public function fieldAsInput($index,$attributes=NULL){
76
-		return $this->_fieldAs(function($id,$name,$value,$caption){
77
-			$input= new HtmlFormInput($id,$caption,"text",$value);
75
+	public function fieldAsInput($index, $attributes=NULL) {
76
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
77
+			$input=new HtmlFormInput($id, $caption, "text", $value);
78 78
 			$input->setName($name);
79 79
 			return $input;
80
-		}, $index,$attributes);
80
+		}, $index, $attributes);
81 81
 	}
82 82
 
83
-	public function fieldAsCheckbox($index,$attributes=NULL){
84
-		return $this->_fieldAs(function($id,$name,$value,$caption){
85
-			return new HtmlFormCheckbox($id,$caption,$value);
86
-		}, $index,$attributes);
83
+	public function fieldAsCheckbox($index, $attributes=NULL) {
84
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
85
+			return new HtmlFormCheckbox($id, $caption, $value);
86
+		}, $index, $attributes);
87 87
 	}
88 88
 
89
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
90
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements,$multiple){
91
-			$dd=new HtmlFormDropdown($id,$elements,$caption,$value,$multiple);
89
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
90
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple){
91
+			$dd=new HtmlFormDropdown($id, $elements, $caption, $value, $multiple);
92 92
 			$dd->setName($name);
93 93
 			return $dd;
94
-		}, $index,$attributes);
94
+		}, $index, $attributes);
95 95
 	}
96 96
 
97
-	public function fieldAsMessage($index,$attributes=NULL){
98
-		return $this->_fieldAs(function($id,$name,$value,$caption){
99
-			$mess= new HtmlMessage("message-".$id,$value);
97
+	public function fieldAsMessage($index, $attributes=NULL) {
98
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
99
+			$mess=new HtmlMessage("message-".$id, $value);
100 100
 			$mess->addHeader($caption);
101 101
 			return $mess;
102
-		}, $index,$attributes,"message");
102
+		}, $index, $attributes, "message");
103 103
 	}
104 104
 }
105 105
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/widgets/dataform/FormInstanceViewer.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,41 +9,41 @@
 block discarded – undo
9 9
 class FormInstanceViewer extends InstanceViewer {
10 10
 	protected $separators;
11 11
 
12
-	public function __construct($identifier,$instance=NULL, $captions=NULL) {
13
-		parent::__construct($identifier,$instance=NULL, $captions=NULL);
12
+	public function __construct($identifier, $instance=NULL, $captions=NULL) {
13
+		parent::__construct($identifier, $instance=NULL, $captions=NULL);
14 14
 		$this->separators=[-1];
15
-		$this->defaultValueFunction=function($name,$value,$index){
15
+		$this->defaultValueFunction=function($name, $value, $index) {
16 16
 			$caption=$this->getCaption($index);
17
-			$input=new HtmlFormInput($this->widgetIdentifier."-".$name,$caption,"text",$value);
17
+			$input=new HtmlFormInput($this->widgetIdentifier."-".$name, $caption, "text", $value);
18 18
 			$input->setName($name);
19 19
 			return $input;
20 20
 		};
21 21
 	}
22 22
 
23
-	protected function _beforeAddProperty($index,&$field){
24
-		if(JString::endswith($field, "\n")===true){
23
+	protected function _beforeAddProperty($index, &$field) {
24
+		if (JString::endswith($field, "\n")===true) {
25 25
 			$this->addSeparatorAfter($index);
26 26
 		}
27
-		if($index>1 && JString::startswith($field, "\n")===true){
27
+		if ($index>1 && JString::startswith($field, "\n")===true) {
28 28
 			$this->addSeparatorAfter($index-1);
29 29
 		}
30 30
 		$field=\str_replace("\n", "", $field);
31 31
 	}
32 32
 
33
-	public function getFieldName($index){
33
+	public function getFieldName($index) {
34 34
 		$property=$this->getProperty($index);
35
-		if($property instanceof \ReflectionProperty){
35
+		if ($property instanceof \ReflectionProperty) {
36 36
 			$result=$property->getName();
37
-		}elseif(\is_callable($property)){
37
+		}elseif (\is_callable($property)) {
38 38
 			$result=$this->visibleProperties[$index];
39
-		}else{
39
+		} else {
40 40
 			$result=$property;
41 41
 		}
42 42
 		return $result;
43 43
 	}
44 44
 
45
-	public function addSeparatorAfter($fieldNum){
46
-		if(\array_search($fieldNum, $this->separators)===false)
45
+	public function addSeparatorAfter($fieldNum) {
46
+		if (\array_search($fieldNum, $this->separators)===false)
47 47
 			$this->separators[]=$fieldNum;
48 48
 			return $this;
49 49
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -17,43 +17,43 @@  discard block
 block discarded – undo
17 17
  * @property boolean $_edition
18 18
  */
19 19
 
20
-trait FieldAsTrait{
20
+trait FieldAsTrait {
21 21
 
22 22
 	abstract protected function _getFieldIdentifier($prefix);
23
-	abstract public function setValueFunction($index,$callback);
23
+	abstract public function setValueFunction($index, $callback);
24 24
 
25 25
 	/**
26 26
 	 * @param HtmlFormField $element
27 27
 	 * @param array $attributes
28 28
 	 */
29
-	protected function _applyAttributes($element,&$attributes,$index){
29
+	protected function _applyAttributes($element, &$attributes, $index) {
30 30
 		$this->_addRules($element, $attributes);
31
-		if(isset($attributes["callback"])){
31
+		if (isset($attributes["callback"])) {
32 32
 			$callback=$attributes["callback"];
33
-			if(\is_callable($callback)){
34
-				$callback($element,$this->_modelInstance,$index);
33
+			if (\is_callable($callback)) {
34
+				$callback($element, $this->_modelInstance, $index);
35 35
 				unset($attributes["callback"]);
36 36
 			}
37 37
 		}
38 38
 		$element->fromArray($attributes);
39 39
 	}
40 40
 
41
-	private function _getLabelField($caption,$icon=NULL){
42
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
41
+	private function _getLabelField($caption, $icon=NULL) {
42
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
43 43
 		return $label;
44 44
 	}
45 45
 
46
-	protected function _addRules($element,&$attributes){}
46
+	protected function _addRules($element, &$attributes) {}
47 47
 
48
-	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){
49
-		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){
48
+	protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) {
49
+		$this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){
50 50
 			$name=$this->_instanceViewer->getCaption($index)."[]";
51
-			if(isset($attributes["name"])){
51
+			if (isset($attributes["name"])) {
52 52
 				$name=$attributes["name"];
53 53
 			}
54
-			$element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,"");
55
-			if(\is_array($attributes))
56
-				$this->_applyAttributes($element, $attributes,$index);
54
+			$element=$elementCallback($this->_getFieldIdentifier($prefix), $name, $value, "");
55
+			if (\is_array($attributes))
56
+				$this->_applyAttributes($element, $attributes, $index);
57 57
 			$element->setDisabled(!$this->_edition);
58 58
 			return $element;
59 59
 		});
@@ -61,94 +61,94 @@  discard block
 block discarded – undo
61 61
 	}
62 62
 
63 63
 
64
-	public function fieldAsProgress($index,$label=NULL, $attributes=array()){
65
-		$this->setValueFunction($index,function($value) use($label,$attributes){
66
-			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes);
64
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
65
+		$this->setValueFunction($index, function($value) use($label, $attributes){
66
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
67 67
 			return $pb;
68 68
 		});
69 69
 			return $this;
70 70
 	}
71 71
 
72
-	public function fieldAsRating($index,$max=5, $icon=""){
73
-		$this->setValueFunction($index,function($value) use($max,$icon){
74
-			$rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon);
72
+	public function fieldAsRating($index, $max=5, $icon="") {
73
+		$this->setValueFunction($index, function($value) use($max, $icon){
74
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
75 75
 			return $rating;
76 76
 		});
77 77
 			return $this;
78 78
 	}
79 79
 
80
-	public function fieldAsLabel($index,$icon=NULL){
81
-		$this->setValueFunction($index,function($caption) use($icon){
82
-			$lbl=$this->_getLabelField($caption,$icon);
80
+	public function fieldAsLabel($index, $icon=NULL) {
81
+		$this->setValueFunction($index, function($caption) use($icon){
82
+			$lbl=$this->_getLabelField($caption, $icon);
83 83
 			return $lbl;
84 84
 		});
85 85
 			return $this;
86 86
 	}
87 87
 
88
-	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
89
-		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
90
-			$header=new HtmlHeader($id,$niveau,$value);
91
-			if(isset($icon))
88
+	public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) {
89
+		return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){
90
+			$header=new HtmlHeader($id, $niveau, $value);
91
+			if (isset($icon))
92 92
 				$header->asIcon($icon, $value);
93 93
 			return $header;
94
-		}, $index,$attributes,"header");
94
+		}, $index, $attributes, "header");
95 95
 	}
96 96
 
97 97
 
98
-	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
99
-		$this->setValueFunction($index,function($img) use($size,$circular){
100
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
98
+	public function fieldAsImage($index, $size=Size::MINI, $circular=false) {
99
+		$this->setValueFunction($index, function($img) use($size, $circular){
100
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
101 101
 			return $image;
102 102
 		});
103 103
 			return $this;
104 104
 	}
105 105
 
106
-	public function fieldAsAvatar($index,$attributes=NULL){
107
-		return $this->_fieldAs(function($id,$name,$value){
108
-			$img=new HtmlImage($id,$value);
106
+	public function fieldAsAvatar($index, $attributes=NULL) {
107
+		return $this->_fieldAs(function($id, $name, $value) {
108
+			$img=new HtmlImage($id, $value);
109 109
 			$img->asAvatar();
110 110
 			return $img;
111
-		}, $index,$attributes,"avatar");
111
+		}, $index, $attributes, "avatar");
112 112
 	}
113 113
 
114
-	public function fieldAsRadio($index,$attributes=NULL){
115
-		return $this->_fieldAs(function($id,$name,$value){
116
-			$input= new HtmlRadio($id,$name,$value,$value);
114
+	public function fieldAsRadio($index, $attributes=NULL) {
115
+		return $this->_fieldAs(function($id, $name, $value) {
116
+			$input=new HtmlRadio($id, $name, $value, $value);
117 117
 			return $input;
118
-		}, $index,$attributes,"radio");
118
+		}, $index, $attributes, "radio");
119 119
 	}
120 120
 
121
-	public function fieldAsInput($index,$attributes=NULL){
122
-		return $this->_fieldAs(function($id,$name,$value){
123
-			$input= new HtmlInput($id,"text",$value);
121
+	public function fieldAsInput($index, $attributes=NULL) {
122
+		return $this->_fieldAs(function($id, $name, $value) {
123
+			$input=new HtmlInput($id, "text", $value);
124 124
 			//TODO check getField
125 125
 			$input->setName($name);
126 126
 			return $input;
127
-		}, $index,$attributes,"input");
127
+		}, $index, $attributes, "input");
128 128
 	}
129 129
 
130
-	public function fieldAsHidden($index,$attributes=NULL){
131
-		if(\is_array($attributes)===false){
130
+	public function fieldAsHidden($index, $attributes=NULL) {
131
+		if (\is_array($attributes)===false) {
132 132
 			$attributes=[];
133 133
 		}
134 134
 		$attributes["imputType"]="hidden";
135
-		return $this->fieldAsInput($index,$attributes);
135
+		return $this->fieldAsInput($index, $attributes);
136 136
 	}
137 137
 
138
-	public function fieldAsCheckbox($index,$attributes=NULL){
139
-		return $this->_fieldAs(function($id,$name,$value){
140
-			$input=new HtmlCheckbox($id,"",$this->_instanceViewer->getIdentifier());
138
+	public function fieldAsCheckbox($index, $attributes=NULL) {
139
+		return $this->_fieldAs(function($id, $name, $value) {
140
+			$input=new HtmlCheckbox($id, "", $this->_instanceViewer->getIdentifier());
141 141
 			$input->setChecked(JString::isBooleanTrue($value));
142 142
 			$input->getField()->setProperty("name", $name);
143 143
 			return $input;
144
-		}, $index,$attributes,"ck");
144
+		}, $index, $attributes, "ck");
145 145
 	}
146 146
 
147
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
148
-		return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){
149
-			$dd=new HtmlDropdown($id,$value,$elements);
150
-			$dd->asSelect($name,$multiple);
147
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
148
+		return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){
149
+			$dd=new HtmlDropdown($id, $value, $elements);
150
+			$dd->asSelect($name, $multiple);
151 151
 			return $dd;
152
-		}, $index,$attributes,"dd");
152
+		}, $index, $attributes, "dd");
153 153
 	}
154 154
 }
155 155
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/common/Widget.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -37,28 +37,28 @@  discard block
 block discarded – undo
37 37
 	protected $_edition;
38 38
 
39 39
 
40
-	public function __construct($identifier,$model,$modelInstance=NULL) {
40
+	public function __construct($identifier, $model, $modelInstance=NULL) {
41 41
 		parent::__construct($identifier);
42 42
 		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
43 43
 		$this->setModel($model);
44
-		if(isset($modelInstance));
44
+		if (isset($modelInstance));
45 45
 			$this->show($modelInstance);
46 46
 	}
47 47
 
48
-	protected function _init($instanceViewer,$contentKey,$content,$edition){
48
+	protected function _init($instanceViewer, $contentKey, $content, $edition) {
49 49
 		$this->_instanceViewer=$instanceViewer;
50 50
 		$this->content=[$contentKey=>$content];
51 51
 		$this->_toolbarPosition=PositionInTable::BEFORETABLE;
52 52
 		$this->_edition=$edition;
53 53
 	}
54 54
 
55
-	protected function _getFieldIdentifier($prefix){
55
+	protected function _getFieldIdentifier($prefix) {
56 56
 		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
57 57
 	}
58 58
 
59
-	abstract protected  function _setToolbarPosition($table,$captions=NULL);
59
+	abstract protected  function _setToolbarPosition($table, $captions=NULL);
60 60
 
61
-	public function show($modelInstance){
61
+	public function show($modelInstance) {
62 62
 		$this->_modelInstance=$modelInstance;
63 63
 	}
64 64
 
@@ -82,42 +82,42 @@  discard block
 block discarded – undo
82 82
 
83 83
 	abstract public function getHtmlComponent();
84 84
 
85
-	public function setColor($color){
85
+	public function setColor($color) {
86 86
 		return $this->getHtmlComponent()->setColor($color);
87 87
 	}
88 88
 
89 89
 
90
-	public function setCaptions($captions){
90
+	public function setCaptions($captions) {
91 91
 		$this->_instanceViewer->setCaptions($captions);
92 92
 		return $this;
93 93
 	}
94 94
 
95
-	public function setFields($fields){
95
+	public function setFields($fields) {
96 96
 		$this->_instanceViewer->setVisibleProperties($fields);
97 97
 		return $this;
98 98
 	}
99 99
 
100
-	public function addField($field){
100
+	public function addField($field) {
101 101
 		$this->_instanceViewer->addField($field);
102 102
 		return $this;
103 103
 	}
104 104
 
105
-	public function insertField($index,$field){
105
+	public function insertField($index, $field) {
106 106
 		$this->_instanceViewer->insertField($index, $field);
107 107
 		return $this;
108 108
 	}
109 109
 
110
-	public function insertInField($index,$field){
110
+	public function insertInField($index, $field) {
111 111
 		$this->_instanceViewer->insertInField($index, $field);
112 112
 		return $this;
113 113
 	}
114 114
 
115
-	public function setValueFunction($index,$callback){
115
+	public function setValueFunction($index, $callback) {
116 116
 		$this->_instanceViewer->setValueFunction($index, $callback);
117 117
 		return $this;
118 118
 	}
119 119
 
120
-	public function setIdentifierFunction($callback){
120
+	public function setIdentifierFunction($callback) {
121 121
 		$this->_instanceViewer->setIdentifierFunction($callback);
122 122
 		return $this;
123 123
 	}
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 	/**
126 126
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
127 127
 	 */
128
-	public function getToolbar(){
129
-		if(isset($this->_toolbar)===false){
128
+	public function getToolbar() {
129
+		if (isset($this->_toolbar)===false) {
130 130
 			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
131 131
 			//$this->_toolbar->setSecondary();
132 132
 		}
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 	 * @param callable $callback function to call on $element
140 140
 	 * @return \Ajax\common\html\HtmlDoubleElement
141 141
 	 */
142
-	public function addInToolbar($element,$callback=NULL){
142
+	public function addInToolbar($element, $callback=NULL) {
143 143
 		$tb=$this->getToolbar();
144
-		if(isset($callback)){
145
-			if(\is_callable($callback)){
144
+		if (isset($callback)) {
145
+			if (\is_callable($callback)) {
146 146
 				$callback($element);
147 147
 			}
148 148
 		}
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 	 * @param callable $callback function($element)
156 156
 	 * @return \Ajax\common\html\HtmlDoubleElement
157 157
 	 */
158
-	public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){
159
-		$result=$this->addInToolbar($caption,$callback);
160
-		if(isset($icon))
158
+	public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) {
159
+		$result=$this->addInToolbar($caption, $callback);
160
+		if (isset($icon))
161 161
 			$result->addIcon($icon);
162 162
 		return $result;
163 163
 	}
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 	 * @param callable $callback function($element)
168 168
 	 * @return \Ajax\common\Widget
169 169
 	 */
170
-	public function addItemsInToolbar(array $items,$callback=NULL){
171
-		if(JArray::isAssociative($items)){
172
-			foreach ($items as $icon=>$item){
173
-				$this->addItemInToolbar($item,$icon,$callback);
170
+	public function addItemsInToolbar(array $items, $callback=NULL) {
171
+		if (JArray::isAssociative($items)) {
172
+			foreach ($items as $icon=>$item) {
173
+				$this->addItemInToolbar($item, $icon, $callback);
174 174
 			}
175
-		}else{
176
-			foreach ($items as $item){
177
-				$this->addItemInToolbar($item,null,$callback);
175
+		} else {
176
+			foreach ($items as $item) {
177
+				$this->addItemInToolbar($item, null, $callback);
178 178
 			}
179 179
 		}
180 180
 		return $this;
@@ -186,12 +186,12 @@  discard block
 block discarded – undo
186 186
 	 * @param callable $callback function($element)
187 187
 	 * @return \Ajax\common\html\HtmlDoubleElement
188 188
 	 */
189
-	public function addDropdownInToolbar($value,$items,$callback=NULL){
189
+	public function addDropdownInToolbar($value, $items, $callback=NULL) {
190 190
 		$dd=$value;
191 191
 		if (\is_string($value)) {
192
-			$dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items);
192
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items);
193 193
 		}
194
-		return $this->addInToolbar($dd,$callback);
194
+		return $this->addInToolbar($dd, $callback);
195 195
 	}
196 196
 
197 197
 	/**
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 	 * @param callable $callback function($element)
200 200
 	 * @return \Ajax\common\html\HtmlDoubleElement
201 201
 	 */
202
-	public function addButtonInToolbar($caption,$callback=NULL){
203
-		$bt=new HtmlButton("",$caption);
204
-		return $this->addInToolbar($bt,$callback);
202
+	public function addButtonInToolbar($caption, $callback=NULL) {
203
+		$bt=new HtmlButton("", $caption);
204
+		return $this->addInToolbar($bt, $callback);
205 205
 	}
206 206
 
207 207
 	/**
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	 * @param callable $callback function($element)
211 211
 	 * @return \Ajax\common\html\HtmlDoubleElement
212 212
 	 */
213
-	public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){
214
-		$bts=new HtmlButtonGroups("",$captions,$asIcon);
215
-		return $this->addInToolbar($bts,$callback);
213
+	public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) {
214
+		$bts=new HtmlButtonGroups("", $captions, $asIcon);
215
+		return $this->addInToolbar($bts, $callback);
216 216
 	}
217 217
 
218 218
 	/**
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 	 * @param boolean $labeled
223 223
 	 * @return \Ajax\common\html\HtmlDoubleElement
224 224
 	 */
225
-	public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){
226
-		$bt=new HtmlButton("",$caption);
227
-		$bt->addIcon($icon,$before,$labeled);
225
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
226
+		$bt=new HtmlButton("", $caption);
227
+		$bt->addIcon($icon, $before, $labeled);
228 228
 		return $this->addInToolbar($bt);
229 229
 	}
230 230
 
@@ -254,12 +254,12 @@  discard block
 block discarded – undo
254 254
 	 * @param callable $defaultValueFunction
255 255
 	 * @return \Ajax\common\Widget
256 256
 	 */
257
-	public function setDefaultValueFunction($defaultValueFunction){
257
+	public function setDefaultValueFunction($defaultValueFunction) {
258 258
 		$this->_instanceViewer->setDefaultValueFunction($defaultValueFunction);
259 259
 		return $this;
260 260
 	}
261 261
 
262
-	public function jsDisabled($disable=true){
262
+	public function jsDisabled($disable=true) {
263 263
 		return "$('#".$this->identifier." .ui.input').toggleClass('disabled',".$disable.");";
264 264
 	}
265 265
 
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 	 * @param callable $callback function($element)
269 269
 	 * @return \Ajax\common\html\HtmlDoubleElement
270 270
 	 */
271
-	public function addEditButtonInToolbar($caption,$callback=NULL){
272
-		$bt=new HtmlButton($this->identifier."-editBtn",$caption);
271
+	public function addEditButtonInToolbar($caption, $callback=NULL) {
272
+		$bt=new HtmlButton($this->identifier."-editBtn", $caption);
273 273
 		$bt->setToggle();
274 274
 		$bt->onClick($this->jsDisabled(Javascript::prep_value("$(event.target).hasClass('active')")));
275
-		return $this->addInToolbar($bt,$callback);
275
+		return $this->addInToolbar($bt, $callback);
276 276
 	}
277 277
 
278 278
 }
279 279
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/InstanceViewer.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -17,165 +17,165 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public static $index=0;
19 19
 
20
-	public function __construct($identifier,$instance=NULL,$captions=NULL){
20
+	public function __construct($identifier, $instance=NULL, $captions=NULL) {
21 21
 		$this->widgetIdentifier=$identifier;
22 22
 		$this->values=[];
23 23
 		$this->afterCompile=[];
24
-		if(isset($instance))
24
+		if (isset($instance))
25 25
 			$this->setInstance($instance);
26 26
 		$this->setCaptions($captions);
27 27
 		$this->captionCallback=NULL;
28
-		$this->defaultValueFunction=function($name,$value){return $value;};
28
+		$this->defaultValueFunction=function($name, $value) {return $value; };
29 29
 	}
30 30
 
31
-	public function getValues(){
31
+	public function getValues() {
32 32
 		$values=[];
33 33
 		$index=0;
34 34
 		$count=$this->count();
35
-		while($index<$count){
35
+		while ($index<$count) {
36 36
 			$values[]=$this->getValue($index++);
37 37
 		}
38 38
 		return $values;
39 39
 	}
40 40
 
41
-	public function getIdentifier(){
41
+	public function getIdentifier() {
42 42
 		$value=self::$index;
43
-		if(isset($this->values["identifier"]))
44
-			$value=$this->values["identifier"](self::$index,$this->instance);
43
+		if (isset($this->values["identifier"]))
44
+			$value=$this->values["identifier"](self::$index, $this->instance);
45 45
 		return $value;
46 46
 	}
47 47
 
48
-	public function getValue($index){
48
+	public function getValue($index) {
49 49
 		$property=$this->properties[$index];
50 50
 		return $this->_getValue($property, $index);
51 51
 	}
52 52
 
53
-	protected function _beforeAddProperty($index,&$field){
53
+	protected function _beforeAddProperty($index, &$field) {
54 54
 
55 55
 	}
56 56
 
57
-	protected function _getDefaultValue($name,$value,$index){
57
+	protected function _getDefaultValue($name, $value, $index) {
58 58
 		$func=$this->defaultValueFunction;
59
-		return $func($name,$value,$index);
59
+		return $func($name, $value, $index);
60 60
 	}
61 61
 
62
-	protected function _getValue($property,$index){
63
-		if($property instanceof \ReflectionProperty){
62
+	protected function _getValue($property, $index) {
63
+		if ($property instanceof \ReflectionProperty) {
64 64
 			$property->setAccessible(true);
65 65
 			$value=$property->getValue($this->instance);
66
-			if(isset($this->values[$index])){
67
-				$value= $this->values[$index]($value,$this->instance,$index);
68
-			}else{
69
-				$value=$this->_getDefaultValue($property->getName(),$value, $index);
66
+			if (isset($this->values[$index])) {
67
+				$value=$this->values[$index]($value, $this->instance, $index);
68
+			} else {
69
+				$value=$this->_getDefaultValue($property->getName(), $value, $index);
70 70
 			}
71
-		}else{
72
-			if(\is_callable($property))
71
+		} else {
72
+			if (\is_callable($property))
73 73
 				$value=$property($this->instance);
74
-			elseif(\is_array($property)){
75
-				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
74
+			elseif (\is_array($property)) {
75
+				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property);
76 76
 				$value=\implode("", $values);
77
-			}else{
78
-				if(isset($this->values[$index])){
79
-					$value= $this->values[$index]($property,$this->instance,$index);
80
-				}else{
77
+			} else {
78
+				if (isset($this->values[$index])) {
79
+					$value=$this->values[$index]($property, $this->instance, $index);
80
+				} else {
81 81
 					$value=$property;
82 82
 				}
83 83
 			}
84 84
 		}
85
-		if(isset($this->afterCompile[$index])){
86
-			if(\is_callable($this->afterCompile[$index])){
87
-				$this->afterCompile[$index]($value,$this->instance,$index);
85
+		if (isset($this->afterCompile[$index])) {
86
+			if (\is_callable($this->afterCompile[$index])) {
87
+				$this->afterCompile[$index]($value, $this->instance, $index);
88 88
 			}
89 89
 		}
90 90
 		return $value;
91 91
 	}
92 92
 
93
-	public function insertField($index,$field){
94
-		array_splice( $this->visibleProperties, $index, 0, $field );
93
+	public function insertField($index, $field) {
94
+		array_splice($this->visibleProperties, $index, 0, $field);
95 95
 		return $this;
96 96
 	}
97 97
 
98
-	public function insertInField($index,$field){
98
+	public function insertInField($index, $field) {
99 99
 		$vb=$this->visibleProperties;
100
-		if(isset($vb[$index])){
101
-			if(\is_array($vb[$index])){
100
+		if (isset($vb[$index])) {
101
+			if (\is_array($vb[$index])) {
102 102
 				$this->visibleProperties[$index][]=$field;
103
-			}else{
104
-				$this->visibleProperties[$index]=[$vb[$index],$field];
103
+			} else {
104
+				$this->visibleProperties[$index]=[$vb[$index], $field];
105 105
 			}
106
-		}else{
106
+		} else {
107 107
 			return $this->insertField($index, $field);
108 108
 		}
109 109
 		return $this;
110 110
 	}
111 111
 
112
-	public function addField($field){
112
+	public function addField($field) {
113 113
 		$this->visibleProperties[]=$field;
114 114
 		return $this;
115 115
 	}
116 116
 
117
-	public function count(){
117
+	public function count() {
118 118
 		return \sizeof($this->properties);
119 119
 	}
120 120
 
121
-	public function visiblePropertiesCount(){
121
+	public function visiblePropertiesCount() {
122 122
 		return \sizeof($this->visibleProperties);
123 123
 	}
124 124
 
125
-	public function getProperty($index){
125
+	public function getProperty($index) {
126 126
 		return $this->properties[$index];
127 127
 	}
128 128
 
129
-	protected function showableProperty(\ReflectionProperty $rProperty){
130
-		return JString::startswith($rProperty->getName(),"_")===false;
129
+	protected function showableProperty(\ReflectionProperty $rProperty) {
130
+		return JString::startswith($rProperty->getName(), "_")===false;
131 131
 	}
132 132
 
133 133
 	public function setInstance($instance) {
134
-		if(\is_string($instance)){
134
+		if (\is_string($instance)) {
135 135
 			$instance=new $instance();
136 136
 		}
137 137
 		$this->instance=$instance;
138 138
 		$this->properties=[];
139 139
 		$this->reflect=new \ReflectionClass($instance);
140
-		if(\sizeof($this->visibleProperties)===0){
140
+		if (\sizeof($this->visibleProperties)===0) {
141 141
 			$this->properties=$this->getDefaultProperties();
142
-		}else{
143
-			foreach ($this->visibleProperties as $property){
142
+		} else {
143
+			foreach ($this->visibleProperties as $property) {
144 144
 				$this->setInstanceProperty($property);
145 145
 			}
146 146
 		}
147 147
 		return $this;
148 148
 	}
149 149
 
150
-	private function setInstanceProperty($property){
151
-		if(\is_callable($property)){
150
+	private function setInstanceProperty($property) {
151
+		if (\is_callable($property)) {
152 152
 			$this->properties[]=$property;
153
-		}elseif(\is_string($property)){
154
-			try{
153
+		}elseif (\is_string($property)) {
154
+			try {
155 155
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
156 156
 				$rProperty=$this->reflect->getProperty($property);
157 157
 				$this->properties[]=$rProperty;
158
-			}catch(\Exception $e){
158
+			}catch (\Exception $e) {
159 159
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
160 160
 				$this->properties[]=$property;
161 161
 			}
162
-		}elseif(\is_int($property)){
162
+		}elseif (\is_int($property)) {
163 163
 			$props=$this->getDefaultProperties();
164
-			if(isset($props[$property]))
164
+			if (isset($props[$property]))
165 165
 				$this->properties[]=$props[$property];
166 166
 				else
167 167
 					$this->properties[]=$property;
168
-		}else{
168
+		} else {
169 169
 			$this->properties[]=$property;
170 170
 		}
171 171
 	}
172 172
 
173
-	protected function getDefaultProperties(){
173
+	protected function getDefaultProperties() {
174 174
 		$result=[];
175 175
 		$properties=$this->reflect->getProperties();
176
-		foreach ($properties as $property){
176
+		foreach ($properties as $property) {
177 177
 			$showable=$this->showableProperty($property);
178
-			if($showable!==false){
178
+			if ($showable!==false) {
179 179
 				$result[]=$property;
180 180
 			}
181 181
 		}
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 		return $this;
188 188
 	}
189 189
 
190
-	public function setValueFunction($index,$callback){
190
+	public function setValueFunction($index, $callback) {
191 191
 		$this->values[$index]=$callback;
192 192
 		return $this;
193 193
 	}
194 194
 
195
-	public function setIdentifierFunction($callback){
195
+	public function setIdentifierFunction($callback) {
196 196
 		$this->values["identifier"]=$callback;
197 197
 		return $this;
198 198
 	}
@@ -205,41 +205,41 @@  discard block
 block discarded – undo
205 205
 		return $this->properties;
206 206
 	}
207 207
 
208
-	public function getCaption($index){
209
-		if(isset($this->captions[$index])){
208
+	public function getCaption($index) {
209
+		if (isset($this->captions[$index])) {
210 210
 			return $this->captions[$index];
211 211
 		}
212
-		if($this->properties[$index] instanceof \ReflectionProperty)
212
+		if ($this->properties[$index] instanceof \ReflectionProperty)
213 213
 			return $this->properties[$index]->getName();
214
-		elseif(\is_callable($this->properties[$index]))
214
+		elseif (\is_callable($this->properties[$index]))
215 215
 			return "";
216 216
 		else
217 217
 			return $this->properties[$index];
218 218
 	}
219 219
 
220
-	public function getCaptions(){
221
-		if(isset($this->captions)){
222
-			$captions= $this->captions;
223
-			for($i=\sizeof($captions);$i<$this->count();$i++){
220
+	public function getCaptions() {
221
+		if (isset($this->captions)) {
222
+			$captions=$this->captions;
223
+			for ($i=\sizeof($captions); $i<$this->count(); $i++) {
224 224
 				$captions[]="";
225 225
 			}
226
-		}else{
226
+		} else {
227 227
 			$captions=[];
228 228
 			$index=0;
229 229
 			$count=$this->count();
230
-			while($index<$count){
230
+			while ($index<$count) {
231 231
 				$captions[]=$this->getCaption($index++);
232 232
 			}
233 233
 		}
234
-		if(isset($this->captionCallback) && \is_callable($this->captionCallback)){
234
+		if (isset($this->captionCallback) && \is_callable($this->captionCallback)) {
235 235
 			$callback=$this->captionCallback;
236
-			$callback($captions,$this->instance);
236
+			$callback($captions, $this->instance);
237 237
 		}
238 238
 		return $captions;
239 239
 	}
240 240
 
241
-	public function setCaption($index,$caption){
242
-		if(isset($this->captions)===false)
241
+	public function setCaption($index, $caption) {
242
+		if (isset($this->captions)===false)
243 243
 			$this->captions=[];
244 244
 		$this->captions[$index]=$caption;
245 245
 		return $this;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * @param callable $callback function called after the field compilation
258 258
 	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
259 259
 	 */
260
-	public function afterCompile($index,$callback){
260
+	public function afterCompile($index, $callback) {
261 261
 		$this->afterCompile[$index]=$callback;
262 262
 		return $this;
263 263
 	}
Please login to merge, or discard this patch.
Ajax/semantic/html/content/HtmlListItem.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
 	protected $image;
10 10
 
11 11
 	public function __construct($identifier, $content=NULL) {
12
-		parent::__construct($identifier,"item",$content);
12
+		parent::__construct($identifier, "item", $content);
13 13
 	}
14
-	protected function initContent($content){
15
-		if(\is_array($content)){
16
-			if(JArray::isAssociative($content)===false){
14
+	protected function initContent($content) {
15
+		if (\is_array($content)) {
16
+			if (JArray::isAssociative($content)===false) {
17 17
 				$icon=@$content[0];
18 18
 				$title=@$content[1];
19 19
 				$desc=@$content[2];
20
-			}else{
20
+			} else {
21 21
 				$icon=@$content["icon"];
22 22
 				$image=@$content["image"];
23 23
 				$title=@$content["title"];
@@ -25,21 +25,21 @@  discard block
 block discarded – undo
25 25
 				$desc=@$content["description"];
26 26
 				$items=@$content["items"];
27 27
 			}
28
-			if(isset($icon)){
28
+			if (isset($icon)) {
29 29
 				$this->setIcon($icon);
30 30
 			}
31
-			if(isset($image)){
31
+			if (isset($image)) {
32 32
 				$this->setImage($image);
33 33
 			}
34
-			if(isset($title)){
35
-				$this->setTitle($title,$desc);
36
-			}elseif (isset($header)){
37
-				$this->setTitle($header,$desc,"header");
34
+			if (isset($title)) {
35
+				$this->setTitle($title, $desc);
36
+			}elseif (isset($header)) {
37
+				$this->setTitle($header, $desc, "header");
38 38
 			}
39
-			if(isset($items)){
39
+			if (isset($items)) {
40 40
 				$this->addList($items);
41 41
 			}
42
-		}else{
42
+		} else {
43 43
 			$this->setContent($content);
44 44
 		}
45 45
 	}
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 		return $list;
51 51
 	}
52 52
 
53
-	public function getList(){
53
+	public function getList() {
54 54
 		return $this->content["list"];
55 55
 	}
56 56
 
57
-	public function getItem($index){
57
+	public function getItem($index) {
58 58
 		return $this->getList()->getItem($index);
59 59
 	}
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.