Completed
Push — master ( 3c0bc3...b6875a )
by Jean-Christophe
03:24
created
Ajax/common/Widget.php 2 patches
Doc Comments   +15 added lines patch added patch discarded remove patch
@@ -44,6 +44,11 @@  discard block
 block discarded – undo
44 44
 			$this->show($modelInstance);
45 45
 	}
46 46
 
47
+	/**
48
+	 * @param InstanceViewer $instanceViewer
49
+	 * @param string $contentKey
50
+	 * @param boolean $edition
51
+	 */
47 52
 	protected function _init($instanceViewer,$contentKey,$content,$edition){
48 53
 		$this->_instanceViewer=$instanceViewer;
49 54
 		$this->content=[$contentKey=>$content];
@@ -96,16 +101,26 @@  discard block
 block discarded – undo
96 101
 		return $this;
97 102
 	}
98 103
 
104
+	/**
105
+	 * @param \Closure $field
106
+	 */
99 107
 	public function addField($field){
100 108
 		$this->_instanceViewer->addField($field);
101 109
 		return $this;
102 110
 	}
103 111
 
112
+	/**
113
+	 * @param integer $index
114
+	 * @param \Closure $field
115
+	 */
104 116
 	public function insertField($index,$field){
105 117
 		$this->_instanceViewer->insertField($index, $field);
106 118
 		return $this;
107 119
 	}
108 120
 
121
+	/**
122
+	 * @param \Closure $field
123
+	 */
109 124
 	public function insertInField($index,$field){
110 125
 		$this->_instanceViewer->insertInField($index, $field);
111 126
 		return $this;
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -36,28 +36,28 @@  discard block
 block discarded – undo
36 36
 	protected $_edition;
37 37
 
38 38
 
39
-	public function __construct($identifier,$model,$modelInstance=NULL) {
39
+	public function __construct($identifier, $model, $modelInstance=NULL) {
40 40
 		parent::__construct($identifier);
41 41
 		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
42 42
 		$this->setModel($model);
43
-		if(isset($modelInstance));
43
+		if (isset($modelInstance));
44 44
 			$this->show($modelInstance);
45 45
 	}
46 46
 
47
-	protected function _init($instanceViewer,$contentKey,$content,$edition){
47
+	protected function _init($instanceViewer, $contentKey, $content, $edition) {
48 48
 		$this->_instanceViewer=$instanceViewer;
49 49
 		$this->content=[$contentKey=>$content];
50 50
 		$this->_toolbarPosition=PositionInTable::BEFORETABLE;
51 51
 		$this->_edition=$edition;
52 52
 	}
53 53
 
54
-	protected function _getFieldIdentifier($prefix){
54
+	protected function _getFieldIdentifier($prefix) {
55 55
 		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
56 56
 	}
57 57
 
58
-	abstract protected  function _setToolbarPosition($table,$captions=NULL);
58
+	abstract protected  function _setToolbarPosition($table, $captions=NULL);
59 59
 
60
-	public function show($modelInstance){
60
+	public function show($modelInstance) {
61 61
 		$this->_modelInstance=$modelInstance;
62 62
 	}
63 63
 
@@ -81,42 +81,42 @@  discard block
 block discarded – undo
81 81
 
82 82
 	abstract public function getHtmlComponent();
83 83
 
84
-	public function setColor($color){
84
+	public function setColor($color) {
85 85
 		return $this->getHtmlComponent()->setColor($color);
86 86
 	}
87 87
 
88 88
 
89
-	public function setCaptions($captions){
89
+	public function setCaptions($captions) {
90 90
 		$this->_instanceViewer->setCaptions($captions);
91 91
 		return $this;
92 92
 	}
93 93
 
94
-	public function setFields($fields){
94
+	public function setFields($fields) {
95 95
 		$this->_instanceViewer->setVisibleProperties($fields);
96 96
 		return $this;
97 97
 	}
98 98
 
99
-	public function addField($field){
99
+	public function addField($field) {
100 100
 		$this->_instanceViewer->addField($field);
101 101
 		return $this;
102 102
 	}
103 103
 
104
-	public function insertField($index,$field){
104
+	public function insertField($index, $field) {
105 105
 		$this->_instanceViewer->insertField($index, $field);
106 106
 		return $this;
107 107
 	}
108 108
 
109
-	public function insertInField($index,$field){
109
+	public function insertInField($index, $field) {
110 110
 		$this->_instanceViewer->insertInField($index, $field);
111 111
 		return $this;
112 112
 	}
113 113
 
114
-	public function setValueFunction($index,$callback){
114
+	public function setValueFunction($index, $callback) {
115 115
 		$this->_instanceViewer->setValueFunction($index, $callback);
116 116
 		return $this;
117 117
 	}
118 118
 
119
-	public function setIdentifierFunction($callback){
119
+	public function setIdentifierFunction($callback) {
120 120
 		$this->_instanceViewer->setIdentifierFunction($callback);
121 121
 		return $this;
122 122
 	}
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 	/**
125 125
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
126 126
 	 */
127
-	public function getToolbar(){
128
-		if(isset($this->_toolbar)===false){
127
+	public function getToolbar() {
128
+		if (isset($this->_toolbar)===false) {
129 129
 			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
130 130
 			//$this->_toolbar->setSecondary();
131 131
 		}
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 	 * @param callable $callback function to call on $element
139 139
 	 * @return \Ajax\common\html\HtmlDoubleElement
140 140
 	 */
141
-	public function addInToolbar($element,$callback=NULL){
141
+	public function addInToolbar($element, $callback=NULL) {
142 142
 		$tb=$this->getToolbar();
143
-		if(isset($callback)){
144
-			if(\is_callable($callback)){
143
+		if (isset($callback)) {
144
+			if (\is_callable($callback)) {
145 145
 				$callback($element);
146 146
 			}
147 147
 		}
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
 	 * @param callable $callback function($element)
155 155
 	 * @return \Ajax\common\html\HtmlDoubleElement
156 156
 	 */
157
-	public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){
158
-		$result=$this->addInToolbar($caption,$callback);
159
-		if(isset($icon))
157
+	public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) {
158
+		$result=$this->addInToolbar($caption, $callback);
159
+		if (isset($icon))
160 160
 			$result->addIcon($icon);
161 161
 		return $result;
162 162
 	}
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 	 * @param callable $callback function($element)
167 167
 	 * @return \Ajax\common\Widget
168 168
 	 */
169
-	public function addItemsInToolbar(array $items,$callback=NULL){
170
-		if(JArray::isAssociative($items)){
171
-			foreach ($items as $icon=>$item){
172
-				$this->addItemInToolbar($item,$icon,$callback);
169
+	public function addItemsInToolbar(array $items, $callback=NULL) {
170
+		if (JArray::isAssociative($items)) {
171
+			foreach ($items as $icon=>$item) {
172
+				$this->addItemInToolbar($item, $icon, $callback);
173 173
 			}
174
-		}else{
175
-			foreach ($items as $item){
176
-				$this->addItemInToolbar($item,null,$callback);
174
+		} else {
175
+			foreach ($items as $item) {
176
+				$this->addItemInToolbar($item, null, $callback);
177 177
 			}
178 178
 		}
179 179
 		return $this;
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 	 * @param callable $callback function($element)
186 186
 	 * @return \Ajax\common\html\HtmlDoubleElement
187 187
 	 */
188
-	public function addDropdownInToolbar($value,$items=NULL,$callback=NULL){
188
+	public function addDropdownInToolbar($value, $items=NULL, $callback=NULL) {
189 189
 		$dd=$value;
190 190
 		if (\is_string($value)) {
191
-			$dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items);
191
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items);
192 192
 		}
193
-		return $this->addInToolbar($dd,$callback);
193
+		return $this->addInToolbar($dd, $callback);
194 194
 	}
195 195
 
196 196
 	/**
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 	 * @param callable $callback function($element)
199 199
 	 * @return \Ajax\common\html\HtmlDoubleElement
200 200
 	 */
201
-	public function addButtonInToolbar($caption,$callback=NULL){
202
-		$bt=new HtmlButton("",$caption);
203
-		return $this->addInToolbar($bt,$callback);
201
+	public function addButtonInToolbar($caption, $callback=NULL) {
202
+		$bt=new HtmlButton("", $caption);
203
+		return $this->addInToolbar($bt, $callback);
204 204
 	}
205 205
 
206 206
 	/**
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
 	 * @param callable $callback function($element)
210 210
 	 * @return \Ajax\common\html\HtmlDoubleElement
211 211
 	 */
212
-	public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){
213
-		$bts=new HtmlButtonGroups("",$captions,$asIcon);
214
-		return $this->addInToolbar($bts,$callback);
212
+	public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) {
213
+		$bts=new HtmlButtonGroups("", $captions, $asIcon);
214
+		return $this->addInToolbar($bts, $callback);
215 215
 	}
216 216
 
217 217
 	/**
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 	 * @param boolean $labeled
222 222
 	 * @return \Ajax\common\html\HtmlDoubleElement
223 223
 	 */
224
-	public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){
225
-		$bt=new HtmlButton("",$caption);
226
-		$bt->addIcon($icon,$before,$labeled);
224
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
225
+		$bt=new HtmlButton("", $caption);
226
+		$bt->addIcon($icon, $before, $labeled);
227 227
 		return $this->addInToolbar($bt);
228 228
 	}
229 229
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @param callable $defaultValueFunction
254 254
 	 * @return \Ajax\common\Widget
255 255
 	 */
256
-	public function setDefaultValueFunction($defaultValueFunction){
256
+	public function setDefaultValueFunction($defaultValueFunction) {
257 257
 		$this->_instanceViewer->setDefaultValueFunction($defaultValueFunction);
258 258
 		return $this;
259 259
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/InstanceViewer.php 2 patches
Doc Comments   +13 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,6 +45,9 @@  discard block
 block discarded – undo
45 45
 		return $value;
46 46
 	}
47 47
 
48
+	/**
49
+	 * @param integer $index
50
+	 */
48 51
 	public function getValue($index){
49 52
 		$property=$this->properties[$index];
50 53
 		return $this->_getValue($property, $index);
@@ -54,6 +57,9 @@  discard block
 block discarded – undo
54 57
 
55 58
 	}
56 59
 
60
+	/**
61
+	 * @param string $name
62
+	 */
57 63
 	protected function _getDefaultValue($name,$value,$index){
58 64
 		$func=$this->defaultValueFunction;
59 65
 		return $func($name,$value,$index);
@@ -197,6 +203,9 @@  discard block
 block discarded – undo
197 203
 		return $this;
198 204
 	}
199 205
 
206
+	/**
207
+	 * @param integer $index
208
+	 */
200 209
 	public static function setIndex($index) {
201 210
 		self::$index=$index;
202 211
 	}
@@ -255,7 +264,7 @@  discard block
 block discarded – undo
255 264
 	 * The $callback function can take the following arguments : $field=>the compiled field, $instance : the active instance of the object, $index: the field position
256 265
 	 * @param int $index postion of the compiled field
257 266
 	 * @param callable $callback function called after the field compilation
258
-	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
267
+	 * @return InstanceViewer
259 268
 	 */
260 269
 	public function afterCompile($index,$callback){
261 270
 		$this->afterCompile[$index]=$callback;
@@ -273,6 +282,9 @@  discard block
 block discarded – undo
273 282
 		return $this;
274 283
 	}
275 284
 
285
+	/**
286
+	 * @param callable $defaultValueFunction
287
+	 */
276 288
 	public function setDefaultValueFunction($defaultValueFunction) {
277 289
 		$this->defaultValueFunction=$defaultValueFunction;
278 290
 		return $this;
Please login to merge, or discard this 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,$index){return $value;};
28
+		$this->defaultValueFunction=function($name, $value, $index) {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/widgets/dataform/FormFieldAsTrait.php 2 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -17,7 +17,14 @@  discard block
 block discarded – undo
17 17
 
18 18
 trait FormFieldAsTrait{
19 19
 
20
+	/**
21
+	 * @param string $prefix
22
+	 */
20 23
 	abstract protected function _getFieldIdentifier($prefix);
24
+
25
+	/**
26
+	 * @param \Closure $callback
27
+	 */
21 28
 	abstract public function setValueFunction($index,$callback);
22 29
 	abstract protected function _applyAttributes($element,&$attributes,$index);
23 30
 
@@ -38,6 +45,10 @@  discard block
 block discarded – undo
38 45
 		}
39 46
 	}
40 47
 
48
+	/**
49
+	 * @param \Closure $elementCallback
50
+	 * @param string $identifier
51
+	 */
41 52
 	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$identifier=null){
42 53
 		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback){
43 54
 			$caption=$this->_instanceViewer->getCaption($index);
Please login to merge, or discard this 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.