Completed
Push — master ( aa0ebb...030ef0 )
by Jean-Christophe
03:09
created
Ajax/semantic/widgets/base/FieldAsTrait.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -15,103 +15,103 @@
 block discarded – undo
15 15
  * @property InstanceViewer $_instanceViewer
16 16
  */
17 17
 
18
-trait FieldAsTrait{
18
+trait FieldAsTrait {
19 19
 
20 20
 	abstract protected function _getFieldIdentifier($prefix);
21
-	abstract public function setValueFunction($index,$callback);
21
+	abstract public function setValueFunction($index, $callback);
22 22
 
23
-	private function _getLabelField($caption,$icon=NULL){
24
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
23
+	private function _getLabelField($caption, $icon=NULL) {
24
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
25 25
 		return $label;
26 26
 	}
27 27
 
28
-	protected function _addRules($element,$attributes){}
28
+	protected function _addRules($element, $attributes) {}
29 29
 
30
-	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){
31
-		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){
30
+	protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) {
31
+		$this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){
32 32
 			$name=$this->_instanceViewer->getCaption($index)."[]";
33
-			if(isset($attributes["name"])===true){
33
+			if (isset($attributes["name"])===true) {
34 34
 				$name=$attributes["name"];
35 35
 			}
36
-			$element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,"");
37
-			if(\is_array($attributes))
38
-				$this->_applyAttributes($element, $attributes,$index);
36
+			$element=$elementCallback($this->_getFieldIdentifier($prefix), $name, $value, "");
37
+			if (\is_array($attributes))
38
+				$this->_applyAttributes($element, $attributes, $index);
39 39
 			return $element;
40 40
 		});
41 41
 			return $this;
42 42
 	}
43 43
 
44 44
 
45
-	public function fieldAsProgress($index,$label=NULL, $attributes=array()){
46
-		$this->setValueFunction($index,function($value) use($label,$attributes){
47
-			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes);
45
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
46
+		$this->setValueFunction($index, function($value) use($label, $attributes){
47
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
48 48
 			return $pb;
49 49
 		});
50 50
 			return $this;
51 51
 	}
52 52
 
53
-	public function fieldAsRating($index,$max=5, $icon=""){
54
-		$this->setValueFunction($index,function($value) use($max,$icon){
55
-			$rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon);
53
+	public function fieldAsRating($index, $max=5, $icon="") {
54
+		$this->setValueFunction($index, function($value) use($max, $icon){
55
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
56 56
 			return $rating;
57 57
 		});
58 58
 			return $this;
59 59
 	}
60 60
 
61
-	public function fieldAsLabel($index,$icon=NULL){
62
-		$this->setValueFunction($index,function($caption) use($icon){
63
-			$lbl=$this->_getLabelField($caption,$icon);
61
+	public function fieldAsLabel($index, $icon=NULL) {
62
+		$this->setValueFunction($index, function($caption) use($icon){
63
+			$lbl=$this->_getLabelField($caption, $icon);
64 64
 			return $lbl;
65 65
 		});
66 66
 			return $this;
67 67
 	}
68 68
 
69
-	public function fieldAsImage($index,$size=Size::SMALL,$circular=false){
70
-		$this->setValueFunction($index,function($img) use($size,$circular){
71
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
69
+	public function fieldAsImage($index, $size=Size::SMALL, $circular=false) {
70
+		$this->setValueFunction($index, function($img) use($size, $circular){
71
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
72 72
 			return $image;
73 73
 		});
74 74
 			return $this;
75 75
 	}
76 76
 
77
-	public function fieldAsAvatar($index,$attributes=NULL){
78
-		return $this->_fieldAs(function($id,$name,$value){
79
-			$img=new HtmlImage($id,$value);
77
+	public function fieldAsAvatar($index, $attributes=NULL) {
78
+		return $this->_fieldAs(function($id, $name, $value) {
79
+			$img=new HtmlImage($id, $value);
80 80
 			$img->asAvatar();
81 81
 			return $img;
82
-		}, $index,$attributes,"avatar");
82
+		}, $index, $attributes, "avatar");
83 83
 	}
84 84
 
85 85
 
86
-	public function fieldAsRadio($index,$attributes=NULL){
87
-		return $this->_fieldAs(function($id,$name,$value){
88
-			$input= new HtmlRadio($id,$name,$value,$value);
86
+	public function fieldAsRadio($index, $attributes=NULL) {
87
+		return $this->_fieldAs(function($id, $name, $value) {
88
+			$input=new HtmlRadio($id, $name, $value, $value);
89 89
 			return $input;
90
-		}, $index,$attributes,"radio");
90
+		}, $index, $attributes, "radio");
91 91
 	}
92 92
 
93
-	public function fieldAsInput($index,$attributes=NULL){
94
-		return $this->_fieldAs(function($id,$name,$value){
95
-			$input= new HtmlInput($id,"text",$value);
93
+	public function fieldAsInput($index, $attributes=NULL) {
94
+		return $this->_fieldAs(function($id, $name, $value) {
95
+			$input=new HtmlInput($id, "text", $value);
96 96
 			$input->getField()->setProperty("name", $name);
97 97
 			return $input;
98
-		}, $index,$attributes,"input");
98
+		}, $index, $attributes, "input");
99 99
 	}
100 100
 
101
-	public function fieldAsCheckbox($index,$attributes=NULL){
102
-		return $this->_fieldAs(function($id,$name,$value){
103
-			$input=new HtmlCheckbox($id,"",$this->_instanceViewer->getIdentifier());
101
+	public function fieldAsCheckbox($index, $attributes=NULL) {
102
+		return $this->_fieldAs(function($id, $name, $value) {
103
+			$input=new HtmlCheckbox($id, "", $this->_instanceViewer->getIdentifier());
104 104
 			$input->setChecked(JString::isBooleanTrue($value));
105 105
 			$input->getField()->setProperty("name", $name);
106 106
 			return $input;
107
-		}, $index,$attributes,"ck");
107
+		}, $index, $attributes, "ck");
108 108
 	}
109 109
 
110
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
111
-		return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){
112
-			$dd=new HtmlDropdown($id,$value,$elements);
113
-			$dd->asSelect($name,$multiple);
110
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
111
+		return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){
112
+			$dd=new HtmlDropdown($id, $value, $elements);
113
+			$dd->asSelect($name, $multiple);
114 114
 			return $dd;
115
-		}, $index,$attributes,"dd");
115
+		}, $index, $attributes, "dd");
116 116
 	}
117 117
 }
118 118
\ No newline at end of file
Please login to merge, or discard this patch.