Completed
Push — master ( 7abd10...04d259 )
by Jean-Christophe
03:18
created
Ajax/semantic/widgets/dataform/DataForm.php 3 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,14 +55,14 @@
 block discarded – undo
55 55
 			foreach ($values as $v){
56 56
 				$form->addField($v);
57 57
 			}
58
-		}else{
58
+		} else{
59 59
 			$separators[]=$count;
60 60
 			for($i=0;$i<$size;$i++){
61 61
 				$fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]);
62 62
 				//TODO check why $fields is empty
63 63
 				if(\sizeof($fields)===1){
64 64
 					$form->addField($fields[0]);
65
-				}elseif(\sizeof($fields)>1){
65
+				} elseif(\sizeof($fields)>1){
66 66
 					$form->addFields($fields);
67 67
 					$i+=\sizeof($fields)-1;
68 68
 				}
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -18,6 +18,9 @@
 block discarded – undo
18 18
  */
19 19
 class DataForm extends Widget {
20 20
 
21
+	/**
22
+	 * @param string $identifier
23
+	 */
21 24
 	public function __construct($identifier, $modelInstance=NULL) {
22 25
 		parent::__construct($identifier, null,$modelInstance);
23 26
 		$this->_form=new HtmlForm($identifier);
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -19,49 +19,49 @@  discard block
 block discarded – undo
19 19
 class DataForm extends Widget {
20 20
 
21 21
 	public function __construct($identifier, $modelInstance=NULL) {
22
-		parent::__construct($identifier, null,$modelInstance);
22
+		parent::__construct($identifier, null, $modelInstance);
23 23
 		$this->_form=new HtmlForm($identifier);
24 24
 		$this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true);
25 25
 	}
26 26
 
27
-	protected function _getFieldIdentifier($prefix,$name=""){
27
+	protected function _getFieldIdentifier($prefix, $name="") {
28 28
 		return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier();
29 29
 	}
30 30
 
31
-	public function compile(JsUtils $js=NULL,&$view=NULL){
31
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
32 32
 		$this->_instanceViewer->setInstance($this->_modelInstance);
33 33
 
34 34
 		$form=$this->content["form"];
35 35
 		$this->_generateContent($form);
36 36
 
37
-		if(isset($this->_toolbar)){
37
+		if (isset($this->_toolbar)) {
38 38
 			$this->_setToolbarPosition($form);
39 39
 		}
40
-		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]);
41
-		return parent::compile($js,$view);
40
+		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]);
41
+		return parent::compile($js, $view);
42 42
 	}
43 43
 
44 44
 	/**
45 45
 	 * @param HtmlForm $form
46 46
 	 */
47
-	protected function _generateContent($form){
48
-		$values= $this->_instanceViewer->getValues();
47
+	protected function _generateContent($form) {
48
+		$values=$this->_instanceViewer->getValues();
49 49
 		$count=$this->_instanceViewer->count();
50 50
 
51 51
 		$separators=$this->_instanceViewer->getSeparators();
52 52
 		$size=\sizeof($separators);
53
-		if($size===1){
54
-			foreach ($values as $v){
53
+		if ($size===1) {
54
+			foreach ($values as $v) {
55 55
 				$form->addField($v);
56 56
 			}
57
-		}else{
57
+		} else {
58 58
 			$separators[]=$count;
59
-			for($i=0;$i<$size;$i++){
60
-				$fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]);
59
+			for ($i=0; $i<$size; $i++) {
60
+				$fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]);
61 61
 				//TODO check why $fields is empty
62
-				if(\sizeof($fields)===1){
62
+				if (\sizeof($fields)===1) {
63 63
 					$form->addField($fields[0]);
64
-				}elseif(\sizeof($fields)>1){
64
+				}elseif (\sizeof($fields)>1) {
65 65
 					$form->addFields($fields);
66 66
 					$i+=\sizeof($fields)-1;
67 67
 				}
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 	 * {@inheritDoc}
74 74
 	 * @see \Ajax\common\Widget::getForm()
75 75
 	 */
76
-	public function getForm(){
76
+	public function getForm() {
77 77
 		return $this->content["form"];
78 78
 	}
79 79
 
80
-	public function addSeparatorAfter($fieldNum){
80
+	public function addSeparatorAfter($fieldNum) {
81 81
 		$this->_instanceViewer->addSeparatorAfter($fieldNum);
82 82
 		return $this;
83 83
 	}
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 		return $this;
92 92
 	}
93 93
 
94
-	public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){
95
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
96
-			$button=new HtmlButton($id,$value,$cssStyle);
94
+	public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) {
95
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){
96
+			$button=new HtmlButton($id, $value, $cssStyle);
97 97
 			$button->setProperty("type", "reset");
98 98
 			return $button;
99
-		}, $index,$attributes);
99
+		}, $index, $attributes);
100 100
 	}
101 101
 
102 102
 	/**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		$this->content[$this->_toolbarPosition]=$this->_toolbar;
116 116
 	}
117 117
 
118
-	public function run(JsUtils $js){
118
+	public function run(JsUtils $js) {
119 119
 		return parent::run($js);
120 120
 	}
121 121
 }
122 122
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/common/html/HtmlDoubleElement.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 		return $this->content;
28 28
 	}
29 29
 
30
-	public function addContent($content,$before=false) {
30
+	public function addContent($content, $before=false) {
31 31
 		if (!\is_array($this->content)) {
32
-			if(isset($this->content))
33
-				$this->content=array ($this->content);
32
+			if (isset($this->content))
33
+				$this->content=array($this->content);
34 34
 			else
35 35
 				$this->content=array();
36 36
 		}
37
-		if($before)
38
-			array_unshift($this->content,$content);
37
+		if ($before)
38
+			array_unshift($this->content, $content);
39 39
 		else
40 40
 			$this->content []=$content;
41 41
 		return $this;
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		if ($this->content instanceof HtmlDoubleElement) {
51 51
 			$this->content->run($js);
52 52
 		} else if (\is_array($this->content)) {
53
-			foreach ( $this->content as $itemContent ) {
53
+			foreach ($this->content as $itemContent) {
54 54
 				if ($itemContent instanceof HtmlDoubleElement) {
55 55
 					$itemContent->run($js);
56 56
 				}
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
 		return $this;
68 68
 	}
69 69
 
70
-	public function getContentInstances($class){
71
-		return $this->_getContentInstances($class,$this->content);
70
+	public function getContentInstances($class) {
71
+		return $this->_getContentInstances($class, $this->content);
72 72
 	}
73 73
 
74
-	protected function _getContentInstances($class,$content){
74
+	protected function _getContentInstances($class, $content) {
75 75
 		$instances=[];
76
-		if($content instanceof $class){
76
+		if ($content instanceof $class) {
77 77
 			$instances[]=$content;
78
-		}elseif($content instanceof HtmlDoubleElement){
79
-			$instances=\array_merge($instances,$content->getContentInstances($class));
80
-		}elseif (\is_array($content)){
81
-			foreach ($content as $element){
82
-				$instances=\array_merge($instances,$this->_getContentInstances($class, $element));
78
+		}elseif ($content instanceof HtmlDoubleElement) {
79
+			$instances=\array_merge($instances, $content->getContentInstances($class));
80
+		}elseif (\is_array($content)) {
81
+			foreach ($content as $element) {
82
+				$instances=\array_merge($instances, $this->_getContentInstances($class, $element));
83 83
 			}
84 84
 		}
85 85
 		return $instances;
Please login to merge, or discard this patch.
Braces   +12 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,15 +29,17 @@  discard block
 block discarded – undo
29 29
 
30 30
 	public function addContent($content,$before=false) {
31 31
 		if (!\is_array($this->content)) {
32
-			if(isset($this->content))
33
-				$this->content=array ($this->content);
34
-			else
35
-				$this->content=array();
32
+			if(isset($this->content)) {
33
+							$this->content=array ($this->content);
34
+			} else {
35
+							$this->content=array();
36
+			}
37
+		}
38
+		if($before) {
39
+					array_unshift($this->content,$content);
40
+		} else {
41
+					$this->content []=$content;
36 42
 		}
37
-		if($before)
38
-			array_unshift($this->content,$content);
39
-		else
40
-			$this->content []=$content;
41 43
 		return $this;
42 44
 	}
43 45
 
@@ -75,9 +77,9 @@  discard block
 block discarded – undo
75 77
 		$instances=[];
76 78
 		if($content instanceof $class){
77 79
 			$instances[]=$content;
78
-		}elseif($content instanceof HtmlDoubleElement){
80
+		} elseif($content instanceof HtmlDoubleElement){
79 81
 			$instances=\array_merge($instances,$content->getContentInstances($class));
80
-		}elseif (\is_array($content)){
82
+		} elseif (\is_array($content)){
81 83
 			foreach ($content as $element){
82 84
 				$instances=\array_merge($instances,$this->_getContentInstances($class, $element));
83 85
 			}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 3 patches
Doc Comments   +19 added lines patch added patch discarded remove patch
@@ -26,9 +26,18 @@  discard block
 block discarded – undo
26 26
 trait FieldAsTrait{
27 27
 
28 28
 	abstract protected function _getFieldIdentifier($prefix,$name="");
29
+
30
+	/**
31
+	 * @param \Closure $callback
32
+	 */
29 33
 	abstract public function setValueFunction($index,$callback);
30 34
 	abstract protected function _getFieldName($index);
31 35
 	abstract protected function _getFieldCaption($index);
36
+
37
+	/**
38
+	 * @param HtmlButton $button
39
+	 * @param string $event
40
+	 */
32 41
 	abstract protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL);
33 42
 
34 43
 	/**
@@ -65,12 +74,19 @@  discard block
 block discarded – undo
65 74
 		}
66 75
 	}
67 76
 
77
+	/**
78
+	 * @param HtmlFormInput $field
79
+	 */
68 80
 	protected function _prepareFormFields(&$field,$name,&$attributes){
69 81
 		$field->setName($name);
70 82
 		$this->_addRules($field, $attributes);
71 83
 		return $field;
72 84
 	}
73 85
 
86
+	/**
87
+	 * @param \Closure $elementCallback
88
+	 * @param string $prefix
89
+	 */
74 90
 	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){
75 91
 		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){
76 92
 			$caption=$this->_getFieldCaption($index);
@@ -221,6 +237,9 @@  discard block
 block discarded – undo
221 237
 		}
222 238
 	}
223 239
 
240
+	/**
241
+	 * @param integer $index
242
+	 */
224 243
 	public function fieldAs($index,$type,$attributes=NULL){
225 244
 		$method="fieldAs".\ucfirst($type);
226 245
 		if(\method_exists($this, $method)){
Please login to merge, or discard this patch.
Braces   +14 added lines, -11 removed lines patch added patch discarded remove patch
@@ -57,8 +57,7 @@  discard block
 block discarded – undo
57 57
 			$rules=$attributes["rules"];
58 58
 			if(\is_array($rules)){
59 59
 				$element->addRules($rules);
60
-			}
61
-			else{
60
+			} else{
62 61
 				$element->addRule($rules);
63 62
 			}
64 63
 			unset($attributes["rules"]);
@@ -118,8 +117,9 @@  discard block
 block discarded – undo
118 117
 	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
119 118
 		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
120 119
 			$header=new HtmlHeader($id,$niveau,$value);
121
-			if(isset($icon))
122
-				$header->asIcon($icon, $value);
120
+			if(isset($icon)) {
121
+							$header->asIcon($icon, $value);
122
+			}
123 123
 			return $header;
124 124
 		}, $index,$attributes,"header");
125 125
 	}
@@ -127,7 +127,9 @@  discard block
 block discarded – undo
127 127
 
128 128
 	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
129 129
 		$this->setValueFunction($index,function($img) use($size,$circular){
130
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
130
+			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) {
131
+				$image->setCircular();
132
+			}
131 133
 			return $image;
132 134
 		});
133 135
 			return $this;
@@ -209,12 +211,13 @@  discard block
 block discarded – undo
209 211
 		$i=0;
210 212
 		if(JArray::isAssociative($types)){
211 213
 			foreach ($types as $type=>$attributes){
212
-				if(\is_int($type))
213
-					$this->fieldAs($i++,$attributes,[]);
214
-				else
215
-					$this->fieldAs($i++,$type,$attributes);
214
+				if(\is_int($type)) {
215
+									$this->fieldAs($i++,$attributes,[]);
216
+				} else {
217
+									$this->fieldAs($i++,$type,$attributes);
218
+				}
216 219
 			}
217
-		}else{
220
+		} else{
218 221
 			foreach ($types as $type){
219 222
 				$this->fieldAs($i++,$type);
220 223
 			}
@@ -226,7 +229,7 @@  discard block
 block discarded – undo
226 229
 		if(\method_exists($this, $method)){
227 230
 			if(!\is_array($attributes)){
228 231
 				$attributes=[$index];
229
-			}else{
232
+			} else{
230 233
 				\array_unshift($attributes, $index);
231 234
 			}
232 235
 			\call_user_func_array([$this,$method], $attributes);
Please login to merge, or discard this patch.
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -23,23 +23,23 @@  discard block
 block discarded – undo
23 23
  * @property boolean $_edition
24 24
  * @property mixed _modelInstance
25 25
  */
26
-trait FieldAsTrait{
26
+trait FieldAsTrait {
27 27
 
28
-	abstract protected function _getFieldIdentifier($prefix,$name="");
29
-	abstract public function setValueFunction($index,$callback);
28
+	abstract protected function _getFieldIdentifier($prefix, $name="");
29
+	abstract public function setValueFunction($index, $callback);
30 30
 	abstract protected function _getFieldName($index);
31 31
 	abstract protected function _getFieldCaption($index);
32
-	abstract protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL);
32
+	abstract protected function _buttonAsSubmit(&$button, $event, $url, $responseElement=NULL);
33 33
 
34 34
 	/**
35 35
 	 * @param HtmlFormField $element
36 36
 	 * @param array $attributes
37 37
 	 */
38
-	protected function _applyAttributes($element,&$attributes,$index){
39
-		if(isset($attributes["callback"])){
38
+	protected function _applyAttributes($element, &$attributes, $index) {
39
+		if (isset($attributes["callback"])) {
40 40
 			$callback=$attributes["callback"];
41
-			if(\is_callable($callback)){
42
-				$callback($element,$this->_modelInstance,$index);
41
+			if (\is_callable($callback)) {
42
+				$callback($element, $this->_modelInstance, $index);
43 43
 				unset($attributes["callback"]);
44 44
 			}
45 45
 		}
@@ -47,42 +47,42 @@  discard block
 block discarded – undo
47 47
 		$element->fromArray($attributes);
48 48
 	}
49 49
 
50
-	private function _getLabelField($caption,$icon=NULL){
51
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
50
+	private function _getLabelField($caption, $icon=NULL) {
51
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
52 52
 		return $label;
53 53
 	}
54 54
 
55
-	protected function _addRules($element,&$attributes){
56
-		if(isset($attributes["rules"])){
55
+	protected function _addRules($element, &$attributes) {
56
+		if (isset($attributes["rules"])) {
57 57
 			$rules=$attributes["rules"];
58
-			if(\is_array($rules)){
58
+			if (\is_array($rules)) {
59 59
 				$element->addRules($rules);
60 60
 			}
61
-			else{
61
+			else {
62 62
 				$element->addRule($rules);
63 63
 			}
64 64
 			unset($attributes["rules"]);
65 65
 		}
66 66
 	}
67 67
 
68
-	protected function _prepareFormFields(&$field,$name,&$attributes){
68
+	protected function _prepareFormFields(&$field, $name, &$attributes) {
69 69
 		$field->setName($name);
70 70
 		$this->_addRules($field, $attributes);
71 71
 		return $field;
72 72
 	}
73 73
 
74
-	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){
75
-		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){
74
+	protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) {
75
+		$this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){
76 76
 			$caption=$this->_getFieldCaption($index);
77 77
 			$name=$this->_getFieldName($index);
78
-			$id=$this->_getFieldIdentifier($prefix,$name);
79
-			if(isset($attributes["name"])){
78
+			$id=$this->_getFieldIdentifier($prefix, $name);
79
+			if (isset($attributes["name"])) {
80 80
 				$name=$attributes["name"];
81 81
 				unset($attributes["name"]);
82 82
 			}
83
-			$element=$elementCallback($id,$name,$value,$caption);
84
-			if(\is_array($attributes)){
85
-				$this->_applyAttributes($element, $attributes,$index);
83
+			$element=$elementCallback($id, $name, $value, $caption);
84
+			if (\is_array($attributes)) {
85
+				$this->_applyAttributes($element, $attributes, $index);
86 86
 			}
87 87
 			$element->setDisabled(!$this->_edition);
88 88
 			return $element;
@@ -91,153 +91,153 @@  discard block
 block discarded – undo
91 91
 	}
92 92
 
93 93
 
94
-	public function fieldAsProgress($index,$label=NULL, $attributes=array()){
95
-		$this->setValueFunction($index,function($value) use($label,$attributes){
96
-			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes);
94
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
95
+		$this->setValueFunction($index, function($value) use($label, $attributes){
96
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
97 97
 			return $pb;
98 98
 		});
99 99
 			return $this;
100 100
 	}
101 101
 
102
-	public function fieldAsRating($index,$max=5, $icon=""){
103
-		$this->setValueFunction($index,function($value) use($max,$icon){
104
-			$rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon);
102
+	public function fieldAsRating($index, $max=5, $icon="") {
103
+		$this->setValueFunction($index, function($value) use($max, $icon){
104
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
105 105
 			return $rating;
106 106
 		});
107 107
 			return $this;
108 108
 	}
109 109
 
110
-	public function fieldAsLabel($index,$icon=NULL){
111
-		$this->setValueFunction($index,function($caption) use($icon){
112
-			$lbl=$this->_getLabelField($caption,$icon);
110
+	public function fieldAsLabel($index, $icon=NULL) {
111
+		$this->setValueFunction($index, function($caption) use($icon){
112
+			$lbl=$this->_getLabelField($caption, $icon);
113 113
 			return $lbl;
114 114
 		});
115 115
 			return $this;
116 116
 	}
117 117
 
118
-	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
119
-		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
120
-			$header=new HtmlHeader($id,$niveau,$value);
121
-			if(isset($icon))
118
+	public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) {
119
+		return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){
120
+			$header=new HtmlHeader($id, $niveau, $value);
121
+			if (isset($icon))
122 122
 				$header->asIcon($icon, $value);
123 123
 			return $header;
124
-		}, $index,$attributes,"header");
124
+		}, $index, $attributes, "header");
125 125
 	}
126 126
 
127 127
 
128
-	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
129
-		$this->setValueFunction($index,function($img) use($size,$circular){
130
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
128
+	public function fieldAsImage($index, $size=Size::MINI, $circular=false) {
129
+		$this->setValueFunction($index, function($img) use($size, $circular){
130
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
131 131
 			return $image;
132 132
 		});
133 133
 			return $this;
134 134
 	}
135 135
 
136
-	public function fieldAsAvatar($index,$attributes=NULL){
137
-		return $this->_fieldAs(function($id,$name,$value){
138
-			$img=new HtmlImage($id,$value);
136
+	public function fieldAsAvatar($index, $attributes=NULL) {
137
+		return $this->_fieldAs(function($id, $name, $value) {
138
+			$img=new HtmlImage($id, $value);
139 139
 			$img->asAvatar();
140 140
 			return $img;
141
-		}, $index,$attributes,"avatar");
141
+		}, $index, $attributes, "avatar");
142 142
 	}
143 143
 
144
-	public function fieldAsRadio($index,$attributes=NULL){
145
-		return $this->_fieldAs(function($id,$name,$value){
146
-			$input= new HtmlRadio($id,$name,$value,$value);
144
+	public function fieldAsRadio($index, $attributes=NULL) {
145
+		return $this->_fieldAs(function($id, $name, $value) {
146
+			$input=new HtmlRadio($id, $name, $value, $value);
147 147
 			return $input;
148
-		}, $index,$attributes,"radio");
148
+		}, $index, $attributes, "radio");
149 149
 	}
150 150
 
151
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
152
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){
153
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
154
-		}, $index,$attributes,"radios");
151
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
152
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){
153
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
154
+		}, $index, $attributes, "radios");
155 155
 	}
156 156
 
157
-	public function fieldAsInput($index,$attributes=NULL){
158
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
159
-			$input= new HtmlFormInput($id,$caption,"text",$value);
157
+	public function fieldAsInput($index, $attributes=NULL) {
158
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
159
+			$input=new HtmlFormInput($id, $caption, "text", $value);
160 160
 			return $this->_prepareFormFields($input, $name, $attributes);
161
-		}, $index,$attributes,"input");
161
+		}, $index, $attributes, "input");
162 162
 	}
163 163
 
164
-	public function fieldAsTextarea($index,$attributes=NULL){
165
-		return $this->_fieldAs(function($id,$name,$value){
166
-			$textarea=new HtmlFormTextarea($id,null,$value);
164
+	public function fieldAsTextarea($index, $attributes=NULL) {
165
+		return $this->_fieldAs(function($id, $name, $value) {
166
+			$textarea=new HtmlFormTextarea($id, null, $value);
167 167
 			$textarea->setName($name);
168 168
 			return $textarea;
169
-		}, $index,$attributes,"textarea");
169
+		}, $index, $attributes, "textarea");
170 170
 	}
171 171
 
172
-	public function fieldAsHidden($index,$attributes=NULL){
173
-		if(!\is_array($attributes)){
172
+	public function fieldAsHidden($index, $attributes=NULL) {
173
+		if (!\is_array($attributes)) {
174 174
 			$attributes=[];
175 175
 		}
176 176
 		$attributes["imputType"]="hidden";
177
-		return $this->fieldAsInput($index,$attributes);
177
+		return $this->fieldAsInput($index, $attributes);
178 178
 	}
179 179
 
180
-	public function fieldAsCheckbox($index,$attributes=NULL){
181
-		return $this->_fieldAs(function($id,$name,$value){
182
-			$input=new HtmlFormCheckbox($id,NULL,$this->_instanceViewer->getIdentifier());
180
+	public function fieldAsCheckbox($index, $attributes=NULL) {
181
+		return $this->_fieldAs(function($id, $name, $value) {
182
+			$input=new HtmlFormCheckbox($id, NULL, $this->_instanceViewer->getIdentifier());
183 183
 			$input->setChecked(JString::isBooleanTrue($value));
184 184
 			$input->setName($name);
185 185
 			return $input;
186
-		}, $index,$attributes,"ck");
186
+		}, $index, $attributes, "ck");
187 187
 	}
188 188
 
189
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
190
-		return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){
191
-			$dd=new HtmlFormDropdown($id,$elements,NULL,$value);
192
-			$dd->asSelect($name,$multiple);
189
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
190
+		return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){
191
+			$dd=new HtmlFormDropdown($id, $elements, NULL, $value);
192
+			$dd->asSelect($name, $multiple);
193 193
 			return $dd;
194
-		}, $index,$attributes,"dd");
194
+		}, $index, $attributes, "dd");
195 195
 	}
196 196
 
197
-	public function fieldAsMessage($index,$attributes=NULL){
198
-		return $this->_fieldAs(function($id,$name,$value,$caption){
199
-			$mess= new HtmlMessage("message-".$id,$value);
197
+	public function fieldAsMessage($index, $attributes=NULL) {
198
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
199
+			$mess=new HtmlMessage("message-".$id, $value);
200 200
 			$mess->addHeader($caption);
201 201
 			return $mess;
202
-		}, $index,$attributes,"message");
202
+		}, $index, $attributes, "message");
203 203
 	}
204 204
 
205 205
 	/**Change fields type
206 206
 	 * @param array $types an array or associative array $type=>$attribute
207 207
 	 */
208
-	public function fieldsAs(array $types){
208
+	public function fieldsAs(array $types) {
209 209
 		$i=0;
210
-		if(JArray::isAssociative($types)){
211
-			foreach ($types as $type=>$attributes){
212
-				if(\is_int($type))
213
-					$this->fieldAs($i++,$attributes,[]);
210
+		if (JArray::isAssociative($types)) {
211
+			foreach ($types as $type=>$attributes) {
212
+				if (\is_int($type))
213
+					$this->fieldAs($i++, $attributes, []);
214 214
 				else
215
-					$this->fieldAs($i++,$type,$attributes);
215
+					$this->fieldAs($i++, $type, $attributes);
216 216
 			}
217
-		}else{
218
-			foreach ($types as $type){
219
-				$this->fieldAs($i++,$type);
217
+		} else {
218
+			foreach ($types as $type) {
219
+				$this->fieldAs($i++, $type);
220 220
 			}
221 221
 		}
222 222
 	}
223 223
 
224
-	public function fieldAs($index,$type,$attributes=NULL){
224
+	public function fieldAs($index, $type, $attributes=NULL) {
225 225
 		$method="fieldAs".\ucfirst($type);
226
-		if(\method_exists($this, $method)){
227
-			if(!\is_array($attributes)){
226
+		if (\method_exists($this, $method)) {
227
+			if (!\is_array($attributes)) {
228 228
 				$attributes=[$index];
229
-			}else{
229
+			} else {
230 230
 				\array_unshift($attributes, $index);
231 231
 			}
232
-			\call_user_func_array([$this,$method], $attributes);
232
+			\call_user_func_array([$this, $method], $attributes);
233 233
 		}
234 234
 	}
235 235
 
236
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
237
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle){
238
-			$button=new HtmlButton($id,$value,$cssStyle);
239
-			$this->_buttonAsSubmit($button,"click",$url,$responseElement);
236
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
237
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle){
238
+			$button=new HtmlButton($id, $value, $cssStyle);
239
+			$this->_buttonAsSubmit($button, "click", $url, $responseElement);
240 240
 			return $button;
241
-		}, $index,$attributes,"submit");
241
+		}, $index, $attributes, "submit");
242 242
 	}
243 243
 }
244 244
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/common/html/html5/HtmlInput.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 class HtmlInput extends HtmlSingleElement {
10 10
 	protected $_placeholder;
11
-	public function __construct($identifier,$type="text",$value=NULL,$placeholder=NULL) {
11
+	public function __construct($identifier, $type="text", $value=NULL, $placeholder=NULL) {
12 12
 		parent::__construct($identifier, "input");
13 13
 		$this->setProperty("name", $identifier);
14 14
 		$this->setValue($value);
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	}
18 18
 
19 19
 	public function setValue($value) {
20
-		if(isset($value))
20
+		if (isset($value))
21 21
 		$this->setProperty("value", $value);
22 22
 		return $this;
23 23
 	}
@@ -26,19 +26,19 @@  discard block
 block discarded – undo
26 26
 		return $this->setProperty("type", $value);
27 27
 	}
28 28
 
29
-	public function setPlaceholder($value){
30
-		if(JString::isNotNull($value))
29
+	public function setPlaceholder($value) {
30
+		if (JString::isNotNull($value))
31 31
 			$this->_placeholder=$value;
32 32
 		return $this;
33 33
 	}
34 34
 
35
-	public function compile(JsUtils $js=NULL,&$view=NULL){
35
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
36 36
 		$value=$this->_placeholder;
37
-		if(JString::isNull($value)){
38
-			if(JString::isNotNull($this->getProperty("name")))
37
+		if (JString::isNull($value)) {
38
+			if (JString::isNotNull($this->getProperty("name")))
39 39
 				$value=\ucfirst($this->getProperty("name"));
40 40
 		}
41 41
 		$this->setProperty("placeholder", $value);
42
-		return parent::compile($js,$view);
42
+		return parent::compile($js, $view);
43 43
 	}
44 44
 }
45 45
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
 	}
18 18
 
19 19
 	public function setValue($value) {
20
-		if(isset($value))
21
-		$this->setProperty("value", $value);
20
+		if(isset($value)) {
21
+				$this->setProperty("value", $value);
22
+		}
22 23
 		return $this;
23 24
 	}
24 25
 
@@ -27,16 +28,18 @@  discard block
 block discarded – undo
27 28
 	}
28 29
 
29 30
 	public function setPlaceholder($value){
30
-		if(JString::isNotNull($value))
31
-			$this->_placeholder=$value;
31
+		if(JString::isNotNull($value)) {
32
+					$this->_placeholder=$value;
33
+		}
32 34
 		return $this;
33 35
 	}
34 36
 
35 37
 	public function compile(JsUtils $js=NULL,&$view=NULL){
36 38
 		$value=$this->_placeholder;
37 39
 		if(JString::isNull($value)){
38
-			if(JString::isNotNull($this->getProperty("name")))
39
-				$value=\ucfirst($this->getProperty("name"));
40
+			if(JString::isNotNull($this->getProperty("name"))) {
41
+							$value=\ucfirst($this->getProperty("name"));
42
+			}
40 43
 		}
41 44
 		$this->setProperty("placeholder", $value);
42 45
 		return parent::compile($js,$view);
Please login to merge, or discard this patch.
Ajax/common/Widget.php 2 patches
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -186,8 +186,9 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){
188 188
 		$result=$this->addInToolbar($caption,$callback);
189
-		if(isset($icon))
190
-			$result->addIcon($icon);
189
+		if(isset($icon)) {
190
+					$result->addIcon($icon);
191
+		}
191 192
 		return $result;
192 193
 	}
193 194
 
@@ -201,7 +202,7 @@  discard block
 block discarded – undo
201 202
 			foreach ($items as $icon=>$item){
202 203
 				$this->addItemInToolbar($item,$icon,$callback);
203 204
 			}
204
-		}else{
205
+		} else{
205 206
 			foreach ($items as $item){
206 207
 				$this->addItemInToolbar($item,null,$callback);
207 208
 			}
@@ -352,8 +353,9 @@  discard block
 block discarded – undo
352 353
 	protected function _compileForm(){
353 354
 		if(isset($this->_form)){
354 355
 			$noValidate="";
355
-			if(\sizeof($this->_form->getValidationParams())>0)
356
-				$noValidate="novalidate";
356
+			if(\sizeof($this->_form->getValidationParams())>0) {
357
+							$noValidate="novalidate";
358
+			}
357 359
 			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>");
358 360
 		}
359 361
 	}
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use Ajax\semantic\html\collections\form\traits\FormTrait;
19 19
 
20 20
 abstract class Widget extends HtmlDoubleElement {
21
-	use FieldAsTrait,FormTrait;
21
+	use FieldAsTrait, FormTrait;
22 22
 
23 23
 	/**
24 24
 	 * @var string classname
@@ -51,37 +51,37 @@  discard block
 block discarded – undo
51 51
 	protected $_generated;
52 52
 
53 53
 
54
-	public function __construct($identifier,$model,$modelInstance=NULL) {
54
+	public function __construct($identifier, $model, $modelInstance=NULL) {
55 55
 		parent::__construct($identifier);
56 56
 		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
57 57
 		$this->setModel($model);
58
-		if(isset($modelInstance));
58
+		if (isset($modelInstance));
59 59
 			$this->show($modelInstance);
60 60
 		$this->_generated=false;
61 61
 	}
62 62
 
63
-	protected function _init($instanceViewer,$contentKey,$content,$edition){
63
+	protected function _init($instanceViewer, $contentKey, $content, $edition) {
64 64
 		$this->_instanceViewer=$instanceViewer;
65 65
 		$this->content=[$contentKey=>$content];
66 66
 		$this->_toolbarPosition=PositionInTable::BEFORETABLE;
67 67
 		$this->_edition=$edition;
68 68
 	}
69 69
 
70
-	protected function _getFieldIdentifier($prefix,$name=""){
70
+	protected function _getFieldIdentifier($prefix, $name="") {
71 71
 		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
72 72
 	}
73 73
 
74
-	protected function _getFieldName($index){
74
+	protected function _getFieldName($index) {
75 75
 		return $this->_instanceViewer->getFieldName($index);
76 76
 	}
77 77
 
78
-	protected function _getFieldCaption($index){
78
+	protected function _getFieldCaption($index) {
79 79
 		return $this->_instanceViewer->getCaption($index);
80 80
 	}
81 81
 
82
-	abstract protected  function _setToolbarPosition($table,$captions=NULL);
82
+	abstract protected  function _setToolbarPosition($table, $captions=NULL);
83 83
 
84
-	public function show($modelInstance){
84
+	public function show($modelInstance) {
85 85
 		$this->_modelInstance=$modelInstance;
86 86
 	}
87 87
 
@@ -105,52 +105,52 @@  discard block
 block discarded – undo
105 105
 
106 106
 	abstract public function getHtmlComponent();
107 107
 
108
-	public function setColor($color){
108
+	public function setColor($color) {
109 109
 		return $this->getHtmlComponent()->setColor($color);
110 110
 	}
111 111
 
112 112
 
113
-	public function setCaptions($captions){
113
+	public function setCaptions($captions) {
114 114
 		$this->_instanceViewer->setCaptions($captions);
115 115
 		return $this;
116 116
 	}
117 117
 
118
-	public function setFields($fields){
118
+	public function setFields($fields) {
119 119
 		$this->_instanceViewer->setVisibleProperties($fields);
120 120
 		return $this;
121 121
 	}
122 122
 
123
-	public function addField($field){
123
+	public function addField($field) {
124 124
 		$this->_instanceViewer->addField($field);
125 125
 		return $this;
126 126
 	}
127 127
 
128
-	public function addMessage($attributes=NULL,$fieldName="message"){
128
+	public function addMessage($attributes=NULL, $fieldName="message") {
129 129
 		$this->_instanceViewer->addField($fieldName);
130 130
 		$count=$this->_instanceViewer->visiblePropertiesCount();
131
-		return $this->fieldAsMessage($count-1,$attributes);
131
+		return $this->fieldAsMessage($count-1, $attributes);
132 132
 	}
133 133
 
134
-	public function addErrorMessage(){
135
-		return $this->addMessage(["error"=>true],"message");
134
+	public function addErrorMessage() {
135
+		return $this->addMessage(["error"=>true], "message");
136 136
 	}
137 137
 
138
-	public function insertField($index,$field){
138
+	public function insertField($index, $field) {
139 139
 		$this->_instanceViewer->insertField($index, $field);
140 140
 		return $this;
141 141
 	}
142 142
 
143
-	public function insertInField($index,$field){
143
+	public function insertInField($index, $field) {
144 144
 		$this->_instanceViewer->insertInField($index, $field);
145 145
 		return $this;
146 146
 	}
147 147
 
148
-	public function setValueFunction($index,$callback){
148
+	public function setValueFunction($index, $callback) {
149 149
 		$this->_instanceViewer->setValueFunction($index, $callback);
150 150
 		return $this;
151 151
 	}
152 152
 
153
-	public function setIdentifierFunction($callback){
153
+	public function setIdentifierFunction($callback) {
154 154
 		$this->_instanceViewer->setIdentifierFunction($callback);
155 155
 		return $this;
156 156
 	}
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	/**
159 159
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
160 160
 	 */
161
-	public function getToolbar(){
162
-		if(isset($this->_toolbar)===false){
161
+	public function getToolbar() {
162
+		if (isset($this->_toolbar)===false) {
163 163
 			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
164 164
 		}
165 165
 		return $this->_toolbar;
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 	 * @param callable $callback function to call on $element
172 172
 	 * @return \Ajax\common\html\HtmlDoubleElement
173 173
 	 */
174
-	public function addInToolbar($element,$callback=NULL){
174
+	public function addInToolbar($element, $callback=NULL) {
175 175
 		$tb=$this->getToolbar();
176
-		if(isset($callback)){
177
-			if(\is_callable($callback)){
176
+		if (isset($callback)) {
177
+			if (\is_callable($callback)) {
178 178
 				$callback($element);
179 179
 			}
180 180
 		}
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 	 * @param callable $callback function($element)
188 188
 	 * @return \Ajax\common\html\HtmlDoubleElement
189 189
 	 */
190
-	public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){
191
-		$result=$this->addInToolbar($caption,$callback);
192
-		if(isset($icon))
190
+	public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) {
191
+		$result=$this->addInToolbar($caption, $callback);
192
+		if (isset($icon))
193 193
 			$result->addIcon($icon);
194 194
 		return $result;
195 195
 	}
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 	 * @param callable $callback function($element)
200 200
 	 * @return \Ajax\common\Widget
201 201
 	 */
202
-	public function addItemsInToolbar(array $items,$callback=NULL){
203
-		if(JArray::isAssociative($items)){
204
-			foreach ($items as $icon=>$item){
205
-				$this->addItemInToolbar($item,$icon,$callback);
202
+	public function addItemsInToolbar(array $items, $callback=NULL) {
203
+		if (JArray::isAssociative($items)) {
204
+			foreach ($items as $icon=>$item) {
205
+				$this->addItemInToolbar($item, $icon, $callback);
206 206
 			}
207
-		}else{
208
-			foreach ($items as $item){
209
-				$this->addItemInToolbar($item,null,$callback);
207
+		} else {
208
+			foreach ($items as $item) {
209
+				$this->addItemInToolbar($item, null, $callback);
210 210
 			}
211 211
 		}
212 212
 		return $this;
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 	 * @param callable $callback function($element)
219 219
 	 * @return \Ajax\common\html\HtmlDoubleElement
220 220
 	 */
221
-	public function addDropdownInToolbar($value,$items,$callback=NULL){
221
+	public function addDropdownInToolbar($value, $items, $callback=NULL) {
222 222
 		$dd=$value;
223 223
 		if (\is_string($value)) {
224
-			$dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items);
224
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items);
225 225
 		}
226
-		return $this->addInToolbar($dd,$callback);
226
+		return $this->addInToolbar($dd, $callback);
227 227
 	}
228 228
 
229 229
 	/**
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 	 * @param callable $callback function($element)
232 232
 	 * @return \Ajax\common\html\HtmlDoubleElement
233 233
 	 */
234
-	public function addButtonInToolbar($caption,$callback=NULL){
235
-		$bt=new HtmlButton("bt-".$caption,$caption);
236
-		return $this->addInToolbar($bt,$callback);
234
+	public function addButtonInToolbar($caption, $callback=NULL) {
235
+		$bt=new HtmlButton("bt-".$caption, $caption);
236
+		return $this->addInToolbar($bt, $callback);
237 237
 	}
238 238
 
239 239
 	/**
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 	 * @param callable $callback function($element)
243 243
 	 * @return \Ajax\common\html\HtmlDoubleElement
244 244
 	 */
245
-	public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){
246
-		$bts=new HtmlButtonGroups("",$captions,$asIcon);
247
-		return $this->addInToolbar($bts,$callback);
245
+	public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) {
246
+		$bts=new HtmlButtonGroups("", $captions, $asIcon);
247
+		return $this->addInToolbar($bts, $callback);
248 248
 	}
249 249
 
250 250
 	/**
@@ -254,15 +254,15 @@  discard block
 block discarded – undo
254 254
 	 * @param boolean $labeled
255 255
 	 * @return \Ajax\common\html\HtmlDoubleElement
256 256
 	 */
257
-	public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){
258
-		$bt=new HtmlButton("",$caption);
259
-		$bt->addIcon($icon,$before,$labeled);
257
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
258
+		$bt=new HtmlButton("", $caption);
259
+		$bt->addIcon($icon, $before, $labeled);
260 260
 		return $this->addInToolbar($bt);
261 261
 	}
262 262
 
263
-	public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){
264
-		$button=new HtmlButton($identifier,$value,$cssStyle);
265
-		$this->_buttonAsSubmit($button,"click",$url,$responseElement);
263
+	public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) {
264
+		$button=new HtmlButton($identifier, $value, $cssStyle);
265
+		$this->_buttonAsSubmit($button, "click", $url, $responseElement);
266 266
 		return $this->addInToolbar($button);
267 267
 	}
268 268
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model
293 293
 	 * @return \Ajax\common\Widget
294 294
 	 */
295
-	public function setDefaultValueFunction($defaultValueFunction){
295
+	public function setDefaultValueFunction($defaultValueFunction) {
296 296
 		$this->_instanceViewer->setDefaultValueFunction($defaultValueFunction);
297 297
 		return $this;
298 298
 	}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 * @param string|boolean $disable
302 302
 	 * @return string
303 303
 	 */
304
-	public function jsDisabled($disable=true){
304
+	public function jsDisabled($disable=true) {
305 305
 		return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");";
306 306
 	}
307 307
 
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
 	 * @param callable $callback function($element)
311 311
 	 * @return \Ajax\common\html\HtmlDoubleElement
312 312
 	 */
313
-	public function addEditButtonInToolbar($caption,$callback=NULL){
314
-		$bt=new HtmlButton($this->identifier."-editBtn",$caption);
313
+	public function addEditButtonInToolbar($caption, $callback=NULL) {
314
+		$bt=new HtmlButton($this->identifier."-editBtn", $caption);
315 315
 		$bt->setToggle();
316 316
 		$bt->setActive($this->_edition);
317 317
 		$bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')")));
318
-		return $this->addInToolbar($bt,$callback);
318
+		return $this->addInToolbar($bt, $callback);
319 319
 	}
320 320
 
321 321
 	public function setToolbar(HtmlMenu $_toolbar) {
@@ -329,35 +329,35 @@  discard block
 block discarded – undo
329 329
 	}
330 330
 
331 331
 	public function getForm() {
332
-		if(!isset($this->_form)){
332
+		if (!isset($this->_form)) {
333 333
 			$this->_form=new HtmlForm("frm-".$this->identifier);
334 334
 			$this->setEdition(true);
335 335
 		}
336 336
 		return $this->_form;
337 337
 	}
338 338
 
339
-	public function run(JsUtils $js){
339
+	public function run(JsUtils $js) {
340 340
 		$result=parent::run($js);
341
-		if(isset($this->_form)){
341
+		if (isset($this->_form)) {
342 342
 			$result=$this->runForm($js);
343 343
 		}
344 344
 		return $result;
345 345
 	}
346 346
 
347
-	protected function runForm(JsUtils $js){
347
+	protected function runForm(JsUtils $js) {
348 348
 		$fields=$this->getContentInstances(HtmlFormField::class);
349
-		foreach ($fields as $field){
349
+		foreach ($fields as $field) {
350 350
 			$this->_form->addField($field);
351 351
 		}
352 352
 		return $this->_form->run($js);
353 353
 	}
354 354
 
355
-	protected function _compileForm(){
356
-		if(isset($this->_form)){
355
+	protected function _compileForm() {
356
+		if (isset($this->_form)) {
357 357
 			$noValidate="";
358
-			if(\sizeof($this->_form->getValidationParams())>0)
358
+			if (\sizeof($this->_form->getValidationParams())>0)
359 359
 				$noValidate="novalidate";
360
-			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>");
360
+			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>");
361 361
 		}
362 362
 	}
363 363
 
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlForm.php 2 patches
Braces   +25 added lines, -17 removed lines patch added patch discarded remove patch
@@ -52,8 +52,9 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function addHeader($title, $niveau=1, $dividing=true) {
54 54
 		$header=new HtmlHeader("", $niveau, $title);
55
-		if ($dividing)
56
-			$header->setDividing();
55
+		if ($dividing) {
56
+					$header->setDividing();
57
+		}
57 58
 		return $this->addItem($header);
58 59
 	}
59 60
 
@@ -74,14 +75,16 @@  discard block
 block discarded – undo
74 75
 					if (\is_string($end)) {
75 76
 						$label=$end;
76 77
 						\array_pop($fields);
77
-					} else
78
-						$label=NULL;
78
+					} else {
79
+											$label=NULL;
80
+					}
79 81
 				}
80 82
 				$this->_fields=\array_merge($this->_fields, $fields);
81 83
 				$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields);
82 84
 			}
83
-			if (isset($label))
84
-				$fields=new HtmlFormField("", $fields, $label);
85
+			if (isset($label)) {
86
+							$fields=new HtmlFormField("", $fields, $label);
87
+			}
85 88
 		} else {
86 89
 			$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count());
87 90
 		}
@@ -134,27 +137,31 @@  discard block
 block discarded – undo
134 137
 	 */
135 138
 	public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) {
136 139
 		$message=new HtmlMessage($identifier, $content);
137
-		if (isset($header))
138
-			$message->addHeader($header);
139
-		if (isset($icon))
140
-			$message->setIcon($icon);
141
-		if (isset($type))
142
-			$message->setStyle($type);
140
+		if (isset($header)) {
141
+					$message->addHeader($header);
142
+		}
143
+		if (isset($icon)) {
144
+					$message->setIcon($icon);
145
+		}
146
+		if (isset($type)) {
147
+					$message->setStyle($type);
148
+		}
143 149
 		return $this->addItem($message);
144 150
 	}
145 151
 
146 152
 
147 153
 
148 154
 	public function compile(JsUtils $js=NULL,&$view=NULL){
149
-		if(\sizeof($this->_validationParams)>0)
150
-			$this->setProperty("novalidate", "");
155
+		if(\sizeof($this->_validationParams)>0) {
156
+					$this->setProperty("novalidate", "");
157
+		}
151 158
 		return parent::compile($js,$view);
152 159
 	}
153 160
 
154 161
 	public function run(JsUtils $js) {
155 162
 		if(isset($js)){
156 163
 			$compo=$js->semantic()->form("#".$this->identifier);
157
-		}else{
164
+		} else{
158 165
 			$compo=new Form();
159 166
 			$compo->attach("#".$this->identifier);
160 167
 		}
@@ -167,8 +174,9 @@  discard block
 block discarded – undo
167 174
 			if($field instanceof HtmlFormFields){
168 175
 				$items=$field->getItems();
169 176
 				foreach ($items as $_field){
170
-					if($_field instanceof HtmlFormField)
171
-						$compo=$this->addCompoValidation($compo, $_field);
177
+					if($_field instanceof HtmlFormField) {
178
+											$compo=$this->addCompoValidation($compo, $_field);
179
+					}
172 180
 				}
173 181
 			}
174 182
 		}
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class HtmlForm extends HtmlSemCollection {
22 22
 
23
-	use FieldsTrait,FormTrait;
23
+	use FieldsTrait, FormTrait;
24 24
 	/**
25 25
 	 * @var array
26 26
 	 */
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 
34 34
 	public function __construct($identifier, $elements=array()) {
35 35
 		parent::__construct($identifier, "form", "ui form");
36
-		$this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ];
36
+		$this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED];
37 37
 		$this->setProperty("name", $this->identifier);
38
-		$this->_fields=array ();
38
+		$this->_fields=array();
39 39
 		$this->addItems($elements);
40 40
 		$this->_validationParams=[];
41 41
 	}
42 42
 
43
-	protected function getForm(){
43
+	protected function getForm() {
44 44
 		return $this;
45 45
 	}
46 46
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @param string $caption
62 62
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
63 63
 	 */
64
-	public function addDivider($caption=NULL){
65
-		return $this->addContent(new HtmlDivider("",$caption));
64
+	public function addDivider($caption=NULL) {
65
+		return $this->addContent(new HtmlDivider("", $caption));
66 66
 	}
67 67
 
68 68
 	public function addFields($fields=NULL, $label=NULL) {
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
 						$label=NULL;
79 79
 				}
80 80
 				$this->_fields=\array_merge($this->_fields, $fields);
81
-				$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields);
81
+				$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields);
82 82
 			}
83 83
 			if (isset($label))
84 84
 				$fields=new HtmlFormField("", $fields, $label);
85 85
 		} else {
86
-			$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count());
86
+			$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count());
87 87
 		}
88 88
 		$this->addItem($fields);
89 89
 		return $fields;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	public function addItem($item) {
93 93
 		$item=parent::addItem($item);
94
-		if (\is_subclass_of($item, HtmlFormField::class) === true) {
94
+		if (\is_subclass_of($item, HtmlFormField::class)===true) {
95 95
 			$this->_fields[]=$item;
96 96
 		}
97 97
 		return $item;
@@ -145,38 +145,38 @@  discard block
 block discarded – undo
145 145
 
146 146
 
147 147
 
148
-	public function compile(JsUtils $js=NULL,&$view=NULL){
149
-		if(\sizeof($this->_validationParams)>0)
148
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
149
+		if (\sizeof($this->_validationParams)>0)
150 150
 			$this->setProperty("novalidate", "");
151
-		return parent::compile($js,$view);
151
+		return parent::compile($js, $view);
152 152
 	}
153 153
 
154 154
 	public function run(JsUtils $js) {
155
-		if(isset($js)){
155
+		if (isset($js)) {
156 156
 			$compo=$js->semantic()->form("#".$this->identifier);
157
-		}else{
157
+		} else {
158 158
 			$compo=new Form();
159 159
 			$compo->attach("#".$this->identifier);
160 160
 		}
161
-		foreach ($this->_fields as $field){
162
-			if($field instanceof HtmlFormField){
161
+		foreach ($this->_fields as $field) {
162
+			if ($field instanceof HtmlFormField) {
163 163
 				$compo=$this->addCompoValidation($compo, $field);
164 164
 			}
165 165
 		}
166
-		foreach ($this->content as $field){
167
-			if($field instanceof HtmlFormFields){
166
+		foreach ($this->content as $field) {
167
+			if ($field instanceof HtmlFormFields) {
168 168
 				$items=$field->getItems();
169
-				foreach ($items as $_field){
170
-					if($_field instanceof HtmlFormField)
169
+				foreach ($items as $_field) {
170
+					if ($_field instanceof HtmlFormField)
171 171
 						$compo=$this->addCompoValidation($compo, $_field);
172 172
 				}
173 173
 			}
174 174
 		}
175
-		$this->_runValidationParams($compo,$js);
175
+		$this->_runValidationParams($compo, $js);
176 176
 		return $this->_bsComponent;
177 177
 	}
178 178
 
179
-	public function addValidationParam($paramName,$paramValue){
179
+	public function addValidationParam($paramName, $paramValue) {
180 180
 		$this->_validationParams[$paramName]=$paramValue;
181 181
 		return $this;
182 182
 	}
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		return $this->_validationParams;
191 191
 	}
192 192
 
193
-	public function removeValidationParam($param){
193
+	public function removeValidationParam($param) {
194 194
 		unset($this->_validationParams[$param]);
195 195
 		return $this;
196 196
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/InstanceViewer.php 2 patches
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -17,180 +17,180 @@  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($index=NULL){
42
-		if(!isset($index))
41
+	public function getIdentifier($index=NULL) {
42
+		if (!isset($index))
43 43
 			$index=self::$index;
44 44
 		$value=$index;
45
-		if(isset($this->values["identifier"]))
46
-			$value=$this->values["identifier"]($index,$this->instance);
45
+		if (isset($this->values["identifier"]))
46
+			$value=$this->values["identifier"]($index, $this->instance);
47 47
 		return $value;
48 48
 	}
49 49
 
50
-	public function getValue($index){
50
+	public function getValue($index) {
51 51
 		$property=$this->properties[$index];
52 52
 		return $this->_getValue($property, $index);
53 53
 	}
54 54
 
55
-	protected function _beforeAddProperty($index,&$field){
55
+	protected function _beforeAddProperty($index, &$field) {
56 56
 
57 57
 	}
58 58
 
59
-	protected function _getDefaultValue($name,$value,$index){
59
+	protected function _getDefaultValue($name, $value, $index) {
60 60
 		$func=$this->defaultValueFunction;
61
-		return $func($name,$value,$index,$this->instance);
61
+		return $func($name, $value, $index, $this->instance);
62 62
 	}
63 63
 
64
-	protected function _getValue($property,$index){
65
-		if($property instanceof \ReflectionProperty){
64
+	protected function _getValue($property, $index) {
65
+		if ($property instanceof \ReflectionProperty) {
66 66
 			$property->setAccessible(true);
67 67
 			$value=$property->getValue($this->instance);
68
-			if(isset($this->values[$index])){
69
-				$value= $this->values[$index]($value,$this->instance,$index);
70
-			}else{
71
-				$value=$this->_getDefaultValue($property->getName(),$value, $index);
68
+			if (isset($this->values[$index])) {
69
+				$value=$this->values[$index]($value, $this->instance, $index);
70
+			} else {
71
+				$value=$this->_getDefaultValue($property->getName(), $value, $index);
72 72
 			}
73
-		}else{
74
-			if(\is_callable($property))
73
+		} else {
74
+			if (\is_callable($property))
75 75
 				$value=$property($this->instance);
76
-			elseif(\is_array($property)){
77
-				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
76
+			elseif (\is_array($property)) {
77
+				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property);
78 78
 				$value=\implode("", $values);
79
-			}else{
80
-				if(isset($this->values[$index])){
81
-					$value= $this->values[$index]($property,$this->instance,$index);
82
-				}else{
79
+			} else {
80
+				if (isset($this->values[$index])) {
81
+					$value=$this->values[$index]($property, $this->instance, $index);
82
+				} else {
83 83
 					$value=$property;
84 84
 				}
85 85
 			}
86 86
 		}
87
-		if(isset($this->afterCompile[$index])){
88
-			if(\is_callable($this->afterCompile[$index])){
89
-				$this->afterCompile[$index]($value,$this->instance,$index);
87
+		if (isset($this->afterCompile[$index])) {
88
+			if (\is_callable($this->afterCompile[$index])) {
89
+				$this->afterCompile[$index]($value, $this->instance, $index);
90 90
 			}
91 91
 		}
92 92
 		return $value;
93 93
 	}
94 94
 
95
-	public function insertField($index,$field){
96
-		array_splice( $this->visibleProperties, $index, 0, $field );
95
+	public function insertField($index, $field) {
96
+		array_splice($this->visibleProperties, $index, 0, $field);
97 97
 		return $this;
98 98
 	}
99 99
 
100
-	public function insertInField($index,$field){
100
+	public function insertInField($index, $field) {
101 101
 		$vb=$this->visibleProperties;
102
-		if(isset($vb[$index])){
103
-			if(\is_array($vb[$index])){
102
+		if (isset($vb[$index])) {
103
+			if (\is_array($vb[$index])) {
104 104
 				$this->visibleProperties[$index][]=$field;
105
-			}else{
106
-				$this->visibleProperties[$index]=[$vb[$index],$field];
105
+			} else {
106
+				$this->visibleProperties[$index]=[$vb[$index], $field];
107 107
 			}
108
-		}else{
108
+		} else {
109 109
 			return $this->insertField($index, $field);
110 110
 		}
111 111
 		return $this;
112 112
 	}
113 113
 
114
-	public function addField($field){
114
+	public function addField($field) {
115 115
 		$this->visibleProperties[]=$field;
116 116
 		return $this;
117 117
 	}
118 118
 
119
-	public function count(){
119
+	public function count() {
120 120
 		return \sizeof($this->properties);
121 121
 	}
122 122
 
123
-	public function visiblePropertiesCount(){
123
+	public function visiblePropertiesCount() {
124 124
 		return \sizeof($this->visibleProperties);
125 125
 	}
126 126
 
127
-	public function getProperty($index){
127
+	public function getProperty($index) {
128 128
 		return $this->properties[$index];
129 129
 	}
130 130
 
131
-	public function getFieldName($index){
131
+	public function getFieldName($index) {
132 132
 		$property=$this->getProperty($index);
133
-		if($property instanceof \ReflectionProperty){
133
+		if ($property instanceof \ReflectionProperty) {
134 134
 			$result=$property->getName();
135
-		}elseif(\is_callable($property)){
135
+		}elseif (\is_callable($property)) {
136 136
 			$result=$this->visibleProperties[$index];
137
-		}else{
137
+		} else {
138 138
 			$result=$property;
139 139
 		}
140 140
 		return $result;
141 141
 	}
142 142
 
143 143
 
144
-	protected function showableProperty(\ReflectionProperty $rProperty){
145
-		return JString::startswith($rProperty->getName(),"_")===false;
144
+	protected function showableProperty(\ReflectionProperty $rProperty) {
145
+		return JString::startswith($rProperty->getName(), "_")===false;
146 146
 	}
147 147
 
148 148
 	public function setInstance($instance) {
149
-		if(\is_string($instance)){
149
+		if (\is_string($instance)) {
150 150
 			$instance=new $instance();
151 151
 		}
152 152
 		$this->instance=$instance;
153 153
 		$this->properties=[];
154 154
 		$this->reflect=new \ReflectionClass($instance);
155
-		if(\sizeof($this->visibleProperties)===0){
155
+		if (\sizeof($this->visibleProperties)===0) {
156 156
 			$this->properties=$this->getDefaultProperties();
157
-		}else{
158
-			foreach ($this->visibleProperties as $property){
157
+		} else {
158
+			foreach ($this->visibleProperties as $property) {
159 159
 				$this->setInstanceProperty($property);
160 160
 			}
161 161
 		}
162 162
 		return $this;
163 163
 	}
164 164
 
165
-	private function setInstanceProperty($property){
166
-		if(\is_callable($property)){
165
+	private function setInstanceProperty($property) {
166
+		if (\is_callable($property)) {
167 167
 			$this->properties[]=$property;
168
-		}elseif(\is_string($property)){
169
-			try{
168
+		}elseif (\is_string($property)) {
169
+			try {
170 170
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
171 171
 				$rProperty=$this->reflect->getProperty($property);
172 172
 				$this->properties[]=$rProperty;
173
-			}catch(\Exception $e){
173
+			}catch (\Exception $e) {
174 174
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
175 175
 				$this->properties[]=$property;
176 176
 			}
177
-		}elseif(\is_int($property)){
177
+		}elseif (\is_int($property)) {
178 178
 			$props=$this->getDefaultProperties();
179
-			if(isset($props[$property]))
179
+			if (isset($props[$property]))
180 180
 				$this->properties[]=$props[$property];
181 181
 				else
182 182
 					$this->properties[]=$property;
183
-		}else{
183
+		} else {
184 184
 			$this->properties[]=$property;
185 185
 		}
186 186
 	}
187 187
 
188
-	protected function getDefaultProperties(){
188
+	protected function getDefaultProperties() {
189 189
 		$result=[];
190 190
 		$properties=$this->reflect->getProperties();
191
-		foreach ($properties as $property){
191
+		foreach ($properties as $property) {
192 192
 			$showable=$this->showableProperty($property);
193
-			if($showable!==false){
193
+			if ($showable!==false) {
194 194
 				$result[]=$property;
195 195
 			}
196 196
 		}
@@ -202,12 +202,12 @@  discard block
 block discarded – undo
202 202
 		return $this;
203 203
 	}
204 204
 
205
-	public function setValueFunction($index,$callback){
205
+	public function setValueFunction($index, $callback) {
206 206
 		$this->values[$index]=$callback;
207 207
 		return $this;
208 208
 	}
209 209
 
210
-	public function setIdentifierFunction($callback){
210
+	public function setIdentifierFunction($callback) {
211 211
 		$this->values["identifier"]=$callback;
212 212
 		return $this;
213 213
 	}
@@ -220,41 +220,41 @@  discard block
 block discarded – undo
220 220
 		return $this->properties;
221 221
 	}
222 222
 
223
-	public function getCaption($index){
224
-		if(isset($this->captions[$index])){
223
+	public function getCaption($index) {
224
+		if (isset($this->captions[$index])) {
225 225
 			return $this->captions[$index];
226 226
 		}
227
-		if($this->properties[$index] instanceof \ReflectionProperty)
227
+		if ($this->properties[$index] instanceof \ReflectionProperty)
228 228
 			return $this->properties[$index]->getName();
229
-		elseif(\is_callable($this->properties[$index]))
229
+		elseif (\is_callable($this->properties[$index]))
230 230
 			return "";
231 231
 		else
232 232
 			return $this->properties[$index];
233 233
 	}
234 234
 
235
-	public function getCaptions(){
236
-		if(isset($this->captions)){
237
-			$captions= $this->captions;
238
-			for($i=\sizeof($captions);$i<$this->count();$i++){
235
+	public function getCaptions() {
236
+		if (isset($this->captions)) {
237
+			$captions=$this->captions;
238
+			for ($i=\sizeof($captions); $i<$this->count(); $i++) {
239 239
 				$captions[]="";
240 240
 			}
241
-		}else{
241
+		} else {
242 242
 			$captions=[];
243 243
 			$index=0;
244 244
 			$count=$this->count();
245
-			while($index<$count){
245
+			while ($index<$count) {
246 246
 				$captions[]=$this->getCaption($index++);
247 247
 			}
248 248
 		}
249
-		if(isset($this->captionCallback) && \is_callable($this->captionCallback)){
249
+		if (isset($this->captionCallback) && \is_callable($this->captionCallback)) {
250 250
 			$callback=$this->captionCallback;
251
-			$callback($captions,$this->instance);
251
+			$callback($captions, $this->instance);
252 252
 		}
253 253
 		return $captions;
254 254
 	}
255 255
 
256
-	public function setCaption($index,$caption){
257
-		if(isset($this->captions)===false)
256
+	public function setCaption($index, $caption) {
257
+		if (isset($this->captions)===false)
258 258
 			$this->captions=[];
259 259
 		$this->captions[$index]=$caption;
260 260
 		return $this;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @param callable $callback function called after the field compilation
273 273
 	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
274 274
 	 */
275
-	public function afterCompile($index,$callback){
275
+	public function afterCompile($index, $callback) {
276 276
 		$this->afterCompile[$index]=$callback;
277 277
 		return $this;
278 278
 	}
Please login to merge, or discard this patch.
Braces   +41 added lines, -35 removed lines patch added patch discarded remove patch
@@ -21,8 +21,9 @@  discard block
 block discarded – undo
21 21
 		$this->widgetIdentifier=$identifier;
22 22
 		$this->values=[];
23 23
 		$this->afterCompile=[];
24
-		if(isset($instance))
25
-			$this->setInstance($instance);
24
+		if(isset($instance)) {
25
+					$this->setInstance($instance);
26
+		}
26 27
 		$this->setCaptions($captions);
27 28
 		$this->captionCallback=NULL;
28 29
 		$this->defaultValueFunction=function($name,$value){return $value;};
@@ -39,11 +40,13 @@  discard block
 block discarded – undo
39 40
 	}
40 41
 
41 42
 	public function getIdentifier($index=NULL){
42
-		if(!isset($index))
43
-			$index=self::$index;
43
+		if(!isset($index)) {
44
+					$index=self::$index;
45
+		}
44 46
 		$value=$index;
45
-		if(isset($this->values["identifier"]))
46
-			$value=$this->values["identifier"]($index,$this->instance);
47
+		if(isset($this->values["identifier"])) {
48
+					$value=$this->values["identifier"]($index,$this->instance);
49
+		}
47 50
 		return $value;
48 51
 	}
49 52
 
@@ -67,19 +70,19 @@  discard block
 block discarded – undo
67 70
 			$value=$property->getValue($this->instance);
68 71
 			if(isset($this->values[$index])){
69 72
 				$value= $this->values[$index]($value,$this->instance,$index);
70
-			}else{
73
+			} else{
71 74
 				$value=$this->_getDefaultValue($property->getName(),$value, $index);
72 75
 			}
73
-		}else{
74
-			if(\is_callable($property))
75
-				$value=$property($this->instance);
76
-			elseif(\is_array($property)){
76
+		} else{
77
+			if(\is_callable($property)) {
78
+							$value=$property($this->instance);
79
+			} elseif(\is_array($property)){
77 80
 				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
78 81
 				$value=\implode("", $values);
79
-			}else{
82
+			} else{
80 83
 				if(isset($this->values[$index])){
81 84
 					$value= $this->values[$index]($property,$this->instance,$index);
82
-				}else{
85
+				} else{
83 86
 					$value=$property;
84 87
 				}
85 88
 			}
@@ -102,10 +105,10 @@  discard block
 block discarded – undo
102 105
 		if(isset($vb[$index])){
103 106
 			if(\is_array($vb[$index])){
104 107
 				$this->visibleProperties[$index][]=$field;
105
-			}else{
108
+			} else{
106 109
 				$this->visibleProperties[$index]=[$vb[$index],$field];
107 110
 			}
108
-		}else{
111
+		} else{
109 112
 			return $this->insertField($index, $field);
110 113
 		}
111 114
 		return $this;
@@ -132,9 +135,9 @@  discard block
 block discarded – undo
132 135
 		$property=$this->getProperty($index);
133 136
 		if($property instanceof \ReflectionProperty){
134 137
 			$result=$property->getName();
135
-		}elseif(\is_callable($property)){
138
+		} elseif(\is_callable($property)){
136 139
 			$result=$this->visibleProperties[$index];
137
-		}else{
140
+		} else{
138 141
 			$result=$property;
139 142
 		}
140 143
 		return $result;
@@ -154,7 +157,7 @@  discard block
 block discarded – undo
154 157
 		$this->reflect=new \ReflectionClass($instance);
155 158
 		if(\sizeof($this->visibleProperties)===0){
156 159
 			$this->properties=$this->getDefaultProperties();
157
-		}else{
160
+		} else{
158 161
 			foreach ($this->visibleProperties as $property){
159 162
 				$this->setInstanceProperty($property);
160 163
 			}
@@ -165,22 +168,23 @@  discard block
 block discarded – undo
165 168
 	private function setInstanceProperty($property){
166 169
 		if(\is_callable($property)){
167 170
 			$this->properties[]=$property;
168
-		}elseif(\is_string($property)){
171
+		} elseif(\is_string($property)){
169 172
 			try{
170 173
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
171 174
 				$rProperty=$this->reflect->getProperty($property);
172 175
 				$this->properties[]=$rProperty;
173
-			}catch(\Exception $e){
176
+			} catch(\Exception $e){
174 177
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
175 178
 				$this->properties[]=$property;
176 179
 			}
177
-		}elseif(\is_int($property)){
180
+		} elseif(\is_int($property)){
178 181
 			$props=$this->getDefaultProperties();
179
-			if(isset($props[$property]))
180
-				$this->properties[]=$props[$property];
181
-				else
182
-					$this->properties[]=$property;
183
-		}else{
182
+			if(isset($props[$property])) {
183
+							$this->properties[]=$props[$property];
184
+			} else {
185
+									$this->properties[]=$property;
186
+				}
187
+		} else{
184 188
 			$this->properties[]=$property;
185 189
 		}
186 190
 	}
@@ -224,12 +228,13 @@  discard block
 block discarded – undo
224 228
 		if(isset($this->captions[$index])){
225 229
 			return $this->captions[$index];
226 230
 		}
227
-		if($this->properties[$index] instanceof \ReflectionProperty)
228
-			return $this->properties[$index]->getName();
229
-		elseif(\is_callable($this->properties[$index]))
230
-			return "";
231
-		else
232
-			return $this->properties[$index];
231
+		if($this->properties[$index] instanceof \ReflectionProperty) {
232
+					return $this->properties[$index]->getName();
233
+		} elseif(\is_callable($this->properties[$index])) {
234
+					return "";
235
+		} else {
236
+					return $this->properties[$index];
237
+		}
233 238
 	}
234 239
 
235 240
 	public function getCaptions(){
@@ -238,7 +243,7 @@  discard block
 block discarded – undo
238 243
 			for($i=\sizeof($captions);$i<$this->count();$i++){
239 244
 				$captions[]="";
240 245
 			}
241
-		}else{
246
+		} else{
242 247
 			$captions=[];
243 248
 			$index=0;
244 249
 			$count=$this->count();
@@ -254,8 +259,9 @@  discard block
 block discarded – undo
254 259
 	}
255 260
 
256 261
 	public function setCaption($index,$caption){
257
-		if(isset($this->captions)===false)
258
-			$this->captions=[];
262
+		if(isset($this->captions)===false) {
263
+					$this->captions=[];
264
+		}
259 265
 		$this->captions[$index]=$caption;
260 266
 		return $this;
261 267
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 3 patches
Doc Comments   +20 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,6 +45,10 @@  discard block
 block discarded – undo
45 45
 		return parent::run($js);
46 46
 	}
47 47
 
48
+	/**
49
+	 * @param string $identifier
50
+	 * @param string $model
51
+	 */
48 52
 	public function __construct($identifier,$model,$modelInstance=NULL) {
49 53
 		parent::__construct($identifier, $model,$modelInstance);
50 54
 		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
@@ -174,6 +178,9 @@  discard block
 block discarded – undo
174 178
 		return $this;
175 179
 	}
176 180
 
181
+	/**
182
+	 * @param PositionInTable $part
183
+	 */
177 184
 	private function addToolbarRow($part,$table,$captions){
178 185
 		$hasPart=$table->hasPart($part);
179 186
 		if($hasPart){
@@ -219,7 +226,7 @@  discard block
 block discarded – undo
219 226
 	 * @param string $caption
220 227
 	 * @param callable $callback
221 228
 	 * @param boolean $visibleHover
222
-	 * @return callable
229
+	 * @return \Closure
223 230
 	 */
224 231
 	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
225 232
 		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
@@ -229,7 +236,7 @@  discard block
 block discarded – undo
229 236
 	 * @param callable $thisCallback
230 237
 	 * @param array $parameters
231 238
 	 * @param callable $callback
232
-	 * @return callable
239
+	 * @return \Closure
233 240
 	 */
234 241
 	private function getCallable($thisCallback,$parameters,$callback=null){
235 242
 		$result=function($instance) use($thisCallback,$parameters,$callback){
@@ -298,11 +305,19 @@  discard block
 block discarded – undo
298 305
 		return $this;
299 306
 	}
300 307
 
308
+	/**
309
+	 * @param string $icon
310
+	 * @param string $class
311
+	 */
301 312
 	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
302 313
 		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
303 314
 		return $this;
304 315
 	}
305 316
 
317
+	/**
318
+	 * @param string $icon
319
+	 * @param string $class
320
+	 */
306 321
 	private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){
307 322
 		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
308 323
 		return $this;
@@ -374,6 +389,9 @@  discard block
 block discarded – undo
374 389
 		}, $index,$attributes);
375 390
 	}
376 391
 
392
+	/**
393
+	 * @param HtmlButton $element
394
+	 */
377 395
 	protected function _visibleOver($element){
378 396
 		$this->_visibleHover=true;
379 397
 		return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;");
Please login to merge, or discard this patch.
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
31 31
 	protected $_compileParts;
32 32
 	protected $_visibleHover=false;
33 33
 
34
-	public function run(JsUtils $js){
35
-		if($this->_hasCheckboxes && isset($js)){
34
+	public function run(JsUtils $js) {
35
+		if ($this->_hasCheckboxes && isset($js)) {
36 36
 			$js->execOn("change", "#".$this->identifier." [name='selection[]']", "
37 37
 		var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true;
38 38
 		\$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}});
39 39
 		if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');}");
40 40
 		}
41
-		if($this->_visibleHover){
42
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
43
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
41
+		if ($this->_visibleHover) {
42
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
43
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
44 44
 		}
45 45
 		return parent::run($js);
46 46
 	}
47 47
 
48
-	public function __construct($identifier,$model,$modelInstance=NULL) {
49
-		parent::__construct($identifier, $model,$modelInstance);
50
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
48
+	public function __construct($identifier, $model, $modelInstance=NULL) {
49
+		parent::__construct($identifier, $model, $modelInstance);
50
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
51 51
 	}
52 52
 
53 53
 	/**
@@ -59,65 +59,65 @@  discard block
 block discarded – undo
59 59
 	}
60 60
 
61 61
 
62
-	public function compile(JsUtils $js=NULL,&$view=NULL){
63
-		if(!$this->_generated){
62
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
63
+		if (!$this->_generated) {
64 64
 			$this->_instanceViewer->setInstance($this->_model);
65 65
 			$captions=$this->_instanceViewer->getCaptions();
66 66
 
67 67
 			$table=$this->content["table"];
68 68
 
69
-			if($this->_hasCheckboxes){
69
+			if ($this->_hasCheckboxes) {
70 70
 				$this->_generateMainCheckbox($captions);
71 71
 			}
72 72
 
73 73
 			$table->setRowCount(0, \sizeof($captions));
74 74
 			$table->setHeaderValues($captions);
75
-			if(isset($this->_compileParts))
75
+			if (isset($this->_compileParts))
76 76
 				$table->setCompileParts($this->_compileParts);
77
-			if(isset($this->_searchField) && isset($js)){
78
-				$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
77
+			if (isset($this->_searchField) && isset($js)) {
78
+				$this->_searchField->postOn("change", $this->_urls, "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
79 79
 			}
80 80
 
81 81
 			$this->_generateContent($table);
82 82
 
83
-			if($this->_hasCheckboxes && $table->hasPart("thead")){
84
-					$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
83
+			if ($this->_hasCheckboxes && $table->hasPart("thead")) {
84
+					$table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort");
85 85
 			}
86 86
 
87
-			if(isset($this->_pagination) && $this->_pagination->getVisible()){
87
+			if (isset($this->_pagination) && $this->_pagination->getVisible()) {
88 88
 				$this->_generatePagination($table);
89 89
 			}
90
-			if(isset($this->_toolbar)){
90
+			if (isset($this->_toolbar)) {
91 91
 				$this->_setToolbarPosition($table, $captions);
92 92
 			}
93
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
93
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
94 94
 			$this->_compileForm();
95 95
 			$this->_generated=true;
96 96
 		}
97
-		return parent::compile($js,$view);
97
+		return parent::compile($js, $view);
98 98
 	}
99 99
 
100
-	private function _generateMainCheckbox(&$captions){
101
-		$ck=new HtmlCheckbox("main-ck-".$this->identifier,"");
100
+	private function _generateMainCheckbox(&$captions) {
101
+		$ck=new HtmlCheckbox("main-ck-".$this->identifier, "");
102 102
 		$ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);");
103 103
 		$ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);");
104 104
 		\array_unshift($captions, $ck);
105 105
 	}
106 106
 
107
-	protected function _generateContent($table){
107
+	protected function _generateContent($table) {
108 108
 		$objects=$this->_modelInstance;
109
-		if(isset($this->_pagination)){
109
+		if (isset($this->_pagination)) {
110 110
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
111 111
 		}
112 112
 		InstanceViewer::setIndex(0);
113 113
 		$table->fromDatabaseObjects($objects, function($instance) use($table){
114 114
 			$this->_instanceViewer->setInstance($instance);
115 115
 			InstanceViewer::$index++;
116
-			$values= $this->_instanceViewer->getValues();
117
-			if($this->_hasCheckboxes){
118
-				$ck=new HtmlCheckbox("ck-".$this->identifier,"");
116
+			$values=$this->_instanceViewer->getValues();
117
+			if ($this->_hasCheckboxes) {
118
+				$ck=new HtmlCheckbox("ck-".$this->identifier, "");
119 119
 				$field=$ck->getField();
120
-				$field->setProperty("value",$this->_instanceViewer->getIdentifier());
120
+				$field->setProperty("value", $this->_instanceViewer->getIdentifier());
121 121
 				$field->setProperty("name", "selection[]");
122 122
 				\array_unshift($values, $ck);
123 123
 			}
@@ -128,36 +128,36 @@  discard block
 block discarded – undo
128 128
 		});
129 129
 	}
130 130
 
131
-	private function _generatePagination($table){
131
+	private function _generatePagination($table) {
132 132
 		$footer=$table->getFooter();
133 133
 		$footer->mergeCol();
134
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
134
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
135 135
 		$menu->floatRight();
136 136
 		$menu->setActiveItem($this->_pagination->getPage()-1);
137 137
 		$footer->setValues($menu);
138
-		$menu->postOnClick($this->_urls,"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
138
+		$menu->postOnClick($this->_urls, "{'p':$(this).attr('data-page')}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
139 139
 	}
140 140
 
141
-	protected function _getFieldName($index){
141
+	protected function _getFieldName($index) {
142 142
 		return parent::_getFieldName($index)."[]";
143 143
 	}
144 144
 
145
-	protected function _getFieldCaption($index){
145
+	protected function _getFieldCaption($index) {
146 146
 		return null;
147 147
 	}
148 148
 
149
-	protected function _setToolbarPosition($table,$captions=NULL){
150
-		switch ($this->_toolbarPosition){
149
+	protected function _setToolbarPosition($table, $captions=NULL) {
150
+		switch ($this->_toolbarPosition) {
151 151
 			case PositionInTable::BEFORETABLE:
152 152
 			case PositionInTable::AFTERTABLE:
153
-				if(isset($this->_compileParts)===false){
153
+				if (isset($this->_compileParts)===false) {
154 154
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
155 155
 				}
156 156
 				break;
157 157
 			case PositionInTable::HEADER:
158 158
 			case PositionInTable::FOOTER:
159 159
 			case PositionInTable::BODY:
160
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
160
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
161 161
 				break;
162 162
 		}
163 163
 	}
@@ -169,23 +169,23 @@  discard block
 block discarded – undo
169 169
 	 * @param callable $callback function called after the field compilation
170 170
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
171 171
 	 */
172
-	public function afterCompile($index,$callback){
173
-		$this->_instanceViewer->afterCompile($index,$callback);
172
+	public function afterCompile($index, $callback) {
173
+		$this->_instanceViewer->afterCompile($index, $callback);
174 174
 		return $this;
175 175
 	}
176 176
 
177
-	private function addToolbarRow($part,$table,$captions){
177
+	private function addToolbarRow($part, $table, $captions) {
178 178
 		$hasPart=$table->hasPart($part);
179
-		if($hasPart){
179
+		if ($hasPart) {
180 180
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
181
-		}else{
181
+		} else {
182 182
 			$row=$table->getPart($part)->getRow(0);
183 183
 		}
184 184
 		$row->mergeCol();
185 185
 		$row->setValues([$this->_toolbar]);
186 186
 	}
187 187
 
188
-	public function getHtmlComponent(){
188
+	public function getHtmlComponent() {
189 189
 		return $this->content["table"];
190 190
 	}
191 191
 
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 		return $this;
199 199
 	}
200 200
 
201
-	public function paginate($items_per_page=10,$page=1){
202
-		$this->_pagination=new Pagination($items_per_page,4,$page);
201
+	public function paginate($items_per_page=10, $page=1) {
202
+		$this->_pagination=new Pagination($items_per_page, 4, $page);
203 203
 	}
204 204
 
205 205
 	public function getHasCheckboxes() {
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		return $this;
212 212
 	}
213 213
 
214
-	public function refresh($compileParts=["tbody"]){
214
+	public function refresh($compileParts=["tbody"]) {
215 215
 		$this->_compileParts=$compileParts;
216 216
 		return $this;
217 217
 	}
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 * @param boolean $visibleHover
222 222
 	 * @return callable
223 223
 	 */
224
-	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
225
-		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
224
+	private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) {
225
+		return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback);
226 226
 	}
227 227
 
228 228
 	/**
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
 	 * @param callable $callback
232 232
 	 * @return callable
233 233
 	 */
234
-	private function getCallable($thisCallback,$parameters,$callback=null){
235
-		$result=function($instance) use($thisCallback,$parameters,$callback){
236
-			$object=call_user_func_array(array($this,$thisCallback), $parameters);
237
-			if(isset($callback)){
238
-				if(\is_callable($callback)){
239
-					$callback($object,$instance);
234
+	private function getCallable($thisCallback, $parameters, $callback=null) {
235
+		$result=function($instance) use($thisCallback, $parameters, $callback){
236
+			$object=call_user_func_array(array($this, $thisCallback), $parameters);
237
+			if (isset($callback)) {
238
+				if (\is_callable($callback)) {
239
+					$callback($object, $instance);
240 240
 				}
241 241
 			}
242
-			if($object instanceof HtmlSemDoubleElement){
243
-				$object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier());
244
-				if($object->propertyContains("class","visibleover")){
242
+			if ($object instanceof HtmlSemDoubleElement) {
243
+				$object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier());
244
+				if ($object->propertyContains("class", "visibleover")) {
245 245
 					$this->_visibleHover=true;
246
-					$object->setProperty("style","visibility:hidden;");
246
+					$object->setProperty("style", "visibility:hidden;");
247 247
 				}
248 248
 			}
249 249
 			return $object;
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 	 * @param string $caption
256 256
 	 * @return HtmlButton
257 257
 	 */
258
-	private function getFieldButton($caption,$visibleHover=true){
259
-		$bt= new HtmlButton("",$caption);
260
-		if($visibleHover)
258
+	private function getFieldButton($caption, $visibleHover=true) {
259
+		$bt=new HtmlButton("", $caption);
260
+		if ($visibleHover)
261 261
 			$this->_visibleOver($bt);
262 262
 		return $bt;
263 263
 	}
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 	 * @param boolean $visibleHover
270 270
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
271 271
 	 */
272
-	public function addFieldButton($caption,$visibleHover=true,$callback=null){
273
-		$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
272
+	public function addFieldButton($caption, $visibleHover=true, $callback=null) {
273
+		$this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback));
274 274
 		return $this;
275 275
 	}
276 276
 
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param callable $callback
282 282
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
283 283
 	 */
284
-	public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){
285
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
284
+	public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) {
285
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
286 286
 		return $this;
287 287
 	}
288 288
 
@@ -293,60 +293,60 @@  discard block
 block discarded – undo
293 293
 	 * @param callable $callback
294 294
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
295 295
 	 */
296
-	public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){
297
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
296
+	public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) {
297
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
298 298
 		return $this;
299 299
 	}
300 300
 
301
-	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
302
-		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
301
+	private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) {
302
+		$this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
303 303
 		return $this;
304 304
 	}
305 305
 
306
-	private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){
307
-		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
306
+	private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) {
307
+		$this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
308 308
 		return $this;
309 309
 	}
310 310
 
311
-	private function getDefaultButton($icon,$class=null,$visibleHover=true){
312
-		$bt=$this->getFieldButton("",$visibleHover);
311
+	private function getDefaultButton($icon, $class=null, $visibleHover=true) {
312
+		$bt=$this->getFieldButton("", $visibleHover);
313 313
 		$bt->asIcon($icon);
314
-		if(isset($class))
314
+		if (isset($class))
315 315
 			$bt->addToProperty("class", $class);
316 316
 		return $bt;
317 317
 	}
318 318
 
319
-	public function addDeleteButton($visibleHover=true,$callback=null){
320
-		return $this->addDefaultButton("remove","delete red basic",$visibleHover,$callback);
319
+	public function addDeleteButton($visibleHover=true, $callback=null) {
320
+		return $this->addDefaultButton("remove", "delete red basic", $visibleHover, $callback);
321 321
 	}
322 322
 
323
-	public function addEditButton($visibleHover=true,$callback=null){
324
-		return $this->addDefaultButton("edit","edit basic",$visibleHover,$callback);
323
+	public function addEditButton($visibleHover=true, $callback=null) {
324
+		return $this->addDefaultButton("edit", "edit basic", $visibleHover, $callback);
325 325
 	}
326 326
 
327
-	public function addEditDeleteButtons($visibleHover=true,$callbackEdit=null,$callbackDelete=null){
328
-		$this->addEditButton($visibleHover,$callbackEdit);
327
+	public function addEditDeleteButtons($visibleHover=true, $callbackEdit=null, $callbackDelete=null) {
328
+		$this->addEditButton($visibleHover, $callbackEdit);
329 329
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
330
-		$this->insertDeleteButtonIn($index,$visibleHover,$callbackDelete);
330
+		$this->insertDeleteButtonIn($index, $visibleHover, $callbackDelete);
331 331
 		return $this;
332 332
 	}
333 333
 
334
-	public function insertDeleteButtonIn($index,$visibleHover=true,$callback=null){
335
-		return $this->insertDefaultButtonIn($index,"remove","delete red basic",$visibleHover,$callback);
334
+	public function insertDeleteButtonIn($index, $visibleHover=true, $callback=null) {
335
+		return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $visibleHover, $callback);
336 336
 	}
337 337
 
338
-	public function insertEditButtonIn($index,$visibleHover=true,$callback=null){
339
-		return $this->insertDefaultButtonIn($index,"edit","edit basic",$visibleHover,$callback);
338
+	public function insertEditButtonIn($index, $visibleHover=true, $callback=null) {
339
+		return $this->insertDefaultButtonIn($index, "edit", "edit basic", $visibleHover, $callback);
340 340
 	}
341 341
 
342
-	public function addSearchInToolbar($position=Direction::RIGHT){
342
+	public function addSearchInToolbar($position=Direction::RIGHT) {
343 343
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
344 344
 	}
345 345
 
346
-	public function getSearchField(){
347
-		if(isset($this->_searchField)===false){
348
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
349
-			$this->_searchField->addIcon("search",Direction::RIGHT);
346
+	public function getSearchField() {
347
+		if (isset($this->_searchField)===false) {
348
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
349
+			$this->_searchField->addIcon("search", Direction::RIGHT);
350 350
 		}
351 351
 		return $this->_searchField;
352 352
 	}
@@ -362,20 +362,20 @@  discard block
 block discarded – undo
362 362
 		return $this;
363 363
 	}
364 364
 
365
-	public function asForm(){
365
+	public function asForm() {
366 366
 		return $this->getForm();
367 367
 	}
368 368
 
369
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
370
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index){
371
-			$button=new HtmlButton($id,$value,$cssStyle);
372
-			$button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement);
369
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
370
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index){
371
+			$button=new HtmlButton($id, $value, $cssStyle);
372
+			$button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement);
373 373
 			return $this->_visibleOver($button);
374
-		}, $index,$attributes);
374
+		}, $index, $attributes);
375 375
 	}
376 376
 
377
-	protected function _visibleOver($element){
377
+	protected function _visibleOver($element) {
378 378
 		$this->_visibleHover=true;
379
-		return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;");
379
+		return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;");
380 380
 	}
381 381
 }
382 382
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +10 added lines, -7 removed lines patch added patch discarded remove patch
@@ -72,8 +72,9 @@  discard block
 block discarded – undo
72 72
 
73 73
 			$table->setRowCount(0, \sizeof($captions));
74 74
 			$table->setHeaderValues($captions);
75
-			if(isset($this->_compileParts))
76
-				$table->setCompileParts($this->_compileParts);
75
+			if(isset($this->_compileParts)) {
76
+							$table->setCompileParts($this->_compileParts);
77
+			}
77 78
 			if(isset($this->_searchField) && isset($js)){
78 79
 				$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
79 80
 			}
@@ -178,7 +179,7 @@  discard block
 block discarded – undo
178 179
 		$hasPart=$table->hasPart($part);
179 180
 		if($hasPart){
180 181
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
181
-		}else{
182
+		} else{
182 183
 			$row=$table->getPart($part)->getRow(0);
183 184
 		}
184 185
 		$row->mergeCol();
@@ -257,8 +258,9 @@  discard block
 block discarded – undo
257 258
 	 */
258 259
 	private function getFieldButton($caption,$visibleHover=true){
259 260
 		$bt= new HtmlButton("",$caption);
260
-		if($visibleHover)
261
-			$this->_visibleOver($bt);
261
+		if($visibleHover) {
262
+					$this->_visibleOver($bt);
263
+		}
262 264
 		return $bt;
263 265
 	}
264 266
 
@@ -311,8 +313,9 @@  discard block
 block discarded – undo
311 313
 	private function getDefaultButton($icon,$class=null,$visibleHover=true){
312 314
 		$bt=$this->getFieldButton("",$visibleHover);
313 315
 		$bt->asIcon($icon);
314
-		if(isset($class))
315
-			$bt->addToProperty("class", $class);
316
+		if(isset($class)) {
317
+					$bt->addToProperty("class", $class);
318
+		}
316 319
 		return $bt;
317 320
 	}
318 321
 
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/traits/FormTrait.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,28 +6,28 @@  discard block
 block discarded – undo
6 6
 use Ajax\service\AjaxCall;
7 7
 use Ajax\JsUtils;
8 8
 
9
-trait FormTrait{
9
+trait FormTrait {
10 10
 
11 11
 	/**
12 12
 	 * @return HtmlForm
13 13
 	 */
14 14
 	abstract protected function getForm();
15 15
 
16
-	protected function addCompoValidation($compo,$field){
16
+	protected function addCompoValidation($compo, $field) {
17 17
 		$validation=$field->getValidation();
18
-		if(isset($validation)){
18
+		if (isset($validation)) {
19 19
 			$validation->setIdentifier($field->getDataField()->getIdentifier());
20 20
 			$compo->addFieldValidation($validation);
21 21
 		}
22 22
 		return $compo;
23 23
 	}
24 24
 
25
-	protected function _runValidationParams(&$compo,JsUtils $js=NULL){
25
+	protected function _runValidationParams(&$compo, JsUtils $js=NULL) {
26 26
 		$form=$this->getForm();
27 27
 		$params=$form->getValidationParams();
28
-		if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){
28
+		if (isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall) {
29 29
 			$compilation=$params["_ajaxSubmit"]->compile($js);
30
-			$compilation=str_ireplace("\"","%quote%", $compilation);
30
+			$compilation=str_ireplace("\"", "%quote%", $compilation);
31 31
 			$this->onSuccess($compilation);
32 32
 			$form->removeValidationParam("_ajaxSubmit");
33 33
 		}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		return $this->getForm()->addToProperty("class", "loading");
41 41
 	}
42 42
 
43
-	public function addErrorMessage(){
43
+	public function addErrorMessage() {
44 44
 		return $this->getForm()->addContent((new HtmlMessage(""))->setError());
45 45
 	}
46 46
 
@@ -55,35 +55,35 @@  discard block
 block discarded – undo
55 55
 	 * @param string $responseElement
56 56
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
57 57
 	 */
58
-	public function submitOn($event,$identifier,$url,$responseElement){
58
+	public function submitOn($event, $identifier, $url, $responseElement) {
59 59
 		$form=$this->getForm();
60 60
 		$elem=$form->getElementById($identifier, $form->getContent());
61
-		if(isset($elem)){
62
-			$this->_buttonAsSubmit($elem, $event,$url,$responseElement);
61
+		if (isset($elem)) {
62
+			$this->_buttonAsSubmit($elem, $event, $url, $responseElement);
63 63
 		}
64 64
 		return $form;
65 65
 	}
66 66
 
67
-	public function submitOnClick($identifier,$url,$responseElement){
67
+	public function submitOnClick($identifier, $url, $responseElement) {
68 68
 		return $this->submitOn("click", $identifier, $url, $responseElement);
69 69
 	}
70 70
 
71
-	public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){
72
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
73
-		return $this->_buttonAsSubmit($bt, "click",$url,$responseElement);
71
+	public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) {
72
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
73
+		return $this->_buttonAsSubmit($bt, "click", $url, $responseElement);
74 74
 	}
75 75
 
76
-	protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL){
76
+	protected function _buttonAsSubmit(&$button, $event, $url, $responseElement=NULL) {
77 77
 		$form=$this->getForm();
78
-		if(isset($url) && isset($responseElement)){
78
+		if (isset($url) && isset($responseElement)) {
79 79
 			$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');");
80
-			$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", ["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url]));
80
+			$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", ["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url]));
81 81
 		}
82 82
 		return $button;
83 83
 	}
84 84
 
85
-	public function addReset($identifier,$value,$cssStyle=NULL){
86
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
85
+	public function addReset($identifier, $value, $cssStyle=NULL) {
86
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
87 87
 		$bt->setProperty("type", "reset");
88 88
 		return $bt;
89 89
 	}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param string $jsCode
94 94
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
95 95
 	 */
96
-	public function onValid($jsCode){
96
+	public function onValid($jsCode) {
97 97
 		$form=$this->getForm();
98 98
 		$form->addValidationParam("onValid", "%function(){".$jsCode."}%");
99 99
 		return $form;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @param string $jsCode can use event and fields parameters
105 105
 	 * @return HtmlForm
106 106
 	 */
107
-	public function onSuccess($jsCode){
107
+	public function onSuccess($jsCode) {
108 108
 		$form=$this->getForm();
109 109
 		$form->addValidationParam("onSuccess", "%function(evt,fields){".$jsCode."}%");
110 110
 		return $form;
Please login to merge, or discard this patch.