Completed
Push — master ( b92773...4d236d )
by Jean-Christophe
03:15
created
Ajax/semantic/html/base/traits/MenuItemTrait.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@  discard block
 block discarded – undo
8 8
 
9 9
 trait MenuItemTrait {
10 10
 
11
-	public function setContent($content){
12
-		if($content==="-"){
11
+	public function setContent($content) {
12
+		if ($content==="-") {
13 13
 			$this->asDivider();
14
-		}elseif($content==="-search-"){
15
-			$values=\explode(",",$content,-1);
16
-			$this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search"));
17
-		}elseif(JString::startswith($content, "-")){
18
-			$content=\ltrim($content,"-");
14
+		}elseif ($content==="-search-") {
15
+			$values=\explode(",", $content, -1);
16
+			$this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."), JArray::getDefaultValue($values, 1, "search"));
17
+		}elseif (JString::startswith($content, "-")) {
18
+			$content=\ltrim($content, "-");
19 19
 			$this->asHeader($content);
20
-		}else
20
+		} else
21 21
 			parent::setContent($content);
22 22
 		return $this;
23 23
 	}
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 	 * @param string $icon
28 28
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem
29 29
 	 */
30
-	public function asSearchInput($placeholder=NULL,$icon=NULL){
30
+	public function asSearchInput($placeholder=NULL, $icon=NULL) {
31 31
 		$this->setClass("ui icon search input");
32 32
 		$input=new HtmlInput("search-".$this->identifier);
33
-		if(isset($placeholder))
33
+		if (isset($placeholder))
34 34
 			$input->setProperty("placeholder", $placeholder);
35 35
 			$this->content=$input;
36
-			if(isset($icon))
36
+			if (isset($icon))
37 37
 				$this->addIcon($icon);
38 38
 				return $this;
39 39
 	}
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	/**
42 42
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem
43 43
 	 */
44
-	public function asDivider(){
44
+	public function asDivider() {
45 45
 		$this->content=NULL;
46 46
 		$this->tagName="div";
47 47
 		$this->setClass("divider");
@@ -53,16 +53,16 @@  discard block
 block discarded – undo
53 53
 	 * @param string $icon
54 54
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem
55 55
 	 */
56
-	public function asHeader($caption=NULL,$icon=NULL){
56
+	public function asHeader($caption=NULL, $icon=NULL) {
57 57
 		$this->setClass("header");
58 58
 		$this->tagName="div";
59 59
 		$this->content=$caption;
60
-		if(isset($icon))
61
-			$this->addIcon($icon,Direction::LEFT);
60
+		if (isset($icon))
61
+			$this->addIcon($icon, Direction::LEFT);
62 62
 			return $this;
63 63
 	}
64 64
 
65
-	public function setPosition($direction){
66
-		$this->addToProperty("class",$direction);
65
+	public function setPosition($direction) {
66
+		$this->addToProperty("class", $direction);
67 67
 	}
68 68
 }
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/modules/checkbox/AbstractCheckbox.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Ajax\JsUtils;
8 8
 
9 9
 abstract class AbstractCheckbox extends HtmlSemDoubleElement {
10
-	protected $_params=array ();
10
+	protected $_params=array();
11 11
 
12 12
 	public function __construct($identifier, $name=NULL, $label=NULL, $value=NULL, $inputType="checkbox", $type="checkbox") {
13 13
 		parent::__construct("ck-".$identifier, "div", "ui ".$type);
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 			$this->setLabel($label);
19 19
 	}
20 20
 
21
-	public function setChecked($value=true){
22
-		if($value===true){
21
+	public function setChecked($value=true) {
22
+		if ($value===true) {
23 23
 			$this->getField()->setProperty("checked", "checked");
24
-		}else{
24
+		} else {
25 25
 			$this->getField()->removeProperty("checked");
26 26
 		}
27 27
 		return $this;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @return \Ajax\semantic\html\collections\form\AbstractHtmlFormRadioCheckbox
84 84
 	 */
85 85
 	public function attachEvent($selector, $action=NULL) {
86
-		if (isset($action)!==false||\is_numeric($action)===true) {
86
+		if (isset($action)!==false || \is_numeric($action)===true) {
87 87
 			$js='$("#%identifier%").checkbox("attach events", "'.$selector.'", "'.$action.'");';
88 88
 		} else {
89 89
 			$js='$("#%identifier%").checkbox("attach events", "'.$selector.'");';
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function attachEvents($events=array()) {
101 101
 		if (\is_array($events)) {
102
-			foreach ( $events as $action => $selector ) {
102
+			foreach ($events as $action => $selector) {
103 103
 				$this->attachEvent($selector, $action);
104 104
 			}
105 105
 		}
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
 		return $this->addToProperty("class", "fitted");
111 111
 	}
112 112
 
113
-	public function setOnChecked($jsCode){
113
+	public function setOnChecked($jsCode) {
114 114
 		$this->_params["onChecked"]=$jsCode;
115 115
 	}
116 116
 
117
-	public function setOnUnchecked($jsCode){
117
+	public function setOnUnchecked($jsCode) {
118 118
 		$this->_params["onUnchecked"]=$jsCode;
119 119
 	}
120 120
 
121 121
 	public function run(JsUtils $js) {
122
-			$this->_bsComponent=$js->semantic()->checkbox("#" . $this->identifier, $this->_params);
122
+			$this->_bsComponent=$js->semantic()->checkbox("#".$this->identifier, $this->_params);
123 123
 			return parent::run($js);
124 124
 	}
125 125
 }
126 126
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/service/JString.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,33 +2,33 @@
 block discarded – undo
2 2
 namespace Ajax\service;
3 3
 class JString {
4 4
 
5
-	public static function contains($hay,$needle){
6
-		return strpos($hay, $needle) !== false;
5
+	public static function contains($hay, $needle) {
6
+		return strpos($hay, $needle)!==false;
7 7
 	}
8 8
 	public static function startswith($hay, $needle) {
9
-		return substr($hay, 0, strlen($needle)) === $needle;
9
+		return substr($hay, 0, strlen($needle))===$needle;
10 10
 	}
11 11
 
12 12
 	public static function endswith($hay, $needle) {
13
-		return substr($hay, -strlen($needle)) === $needle;
13
+		return substr($hay, -strlen($needle))===$needle;
14 14
 	}
15 15
 
16
-	public static function isNull($s){
16
+	public static function isNull($s) {
17 17
 		return (!isset($s) || NULL===$s || ""===$s);
18 18
 	}
19
-	public static function isNotNull($s){
19
+	public static function isNotNull($s) {
20 20
 		return (isset($s) && NULL!==$s && ""!==$s);
21 21
 	}
22 22
 
23
-	public static function isBoolean($value){
23
+	public static function isBoolean($value) {
24 24
 		return \is_bool($value) || $value==1 || $value==0;
25 25
 	}
26 26
 
27
-	public static function isBooleanTrue($value){
27
+	public static function isBooleanTrue($value) {
28 28
 		return $value==1 || $value;
29 29
 	}
30 30
 
31
-	public static function isBooleanFalse($value){
31
+	public static function isBooleanFalse($value) {
32 32
 		return $value==0 || !$value;
33 33
 	}
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/InstanceViewer.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -12,25 +12,25 @@  discard block
 block discarded – undo
12 12
 	private $afterCompile;
13 13
 	private static $index=0;
14 14
 
15
-	public function __construct($instance=NULL,$captions=NULL){
15
+	public function __construct($instance=NULL, $captions=NULL) {
16 16
 		$this->values=[];
17 17
 		$this->afterCompile=[];
18
-		if(isset($instance))
18
+		if (isset($instance))
19 19
 			$this->setInstance($instance);
20 20
 		$this->setCaptions($captions);
21 21
 	}
22 22
 
23
-	public function getCaption($index){
24
-		if($this->properties[$index] instanceof \ReflectionProperty)
23
+	public function getCaption($index) {
24
+		if ($this->properties[$index] instanceof \ReflectionProperty)
25 25
 			return $this->properties[$index]->getName();
26 26
 		else
27 27
 			return $this->properties[$index];
28 28
 	}
29 29
 
30
-	public function getCaptions(){
31
-		if(isset($this->captions)){
32
-			$result= $this->captions;
33
-			for($i=\sizeof($result);$i<$this->count();$i++){
30
+	public function getCaptions() {
31
+		if (isset($this->captions)) {
32
+			$result=$this->captions;
33
+			for ($i=\sizeof($result); $i<$this->count(); $i++) {
34 34
 				$result[]="";
35 35
 			}
36 36
 			return $result;
@@ -38,122 +38,122 @@  discard block
 block discarded – undo
38 38
 		$captions=[];
39 39
 		$index=0;
40 40
 		$count=$this->count();
41
-		while($index<$count){
41
+		while ($index<$count) {
42 42
 			$captions[]=$this->getCaption($index++);
43 43
 		}
44 44
 		return $captions;
45 45
 	}
46 46
 
47
-	public function getValues(){
47
+	public function getValues() {
48 48
 		$values=[];
49 49
 		$index=0;
50 50
 		$count=$this->count();
51
-		while($index<$count){
51
+		while ($index<$count) {
52 52
 			$values[]=$this->getValue($index++);
53 53
 		}
54 54
 		return $values;
55 55
 	}
56 56
 
57
-	public function getIdentifier(){
57
+	public function getIdentifier() {
58 58
 		$value=self::$index;
59
-		if(isset($this->values["identifier"]))
60
-			$value=$this->values["identifier"](self::$index,$this->instance);
59
+		if (isset($this->values["identifier"]))
60
+			$value=$this->values["identifier"](self::$index, $this->instance);
61 61
 		self::$index++;
62 62
 		return $value;
63 63
 	}
64 64
 
65
-	public function getValue($index){
65
+	public function getValue($index) {
66 66
 		$property=$this->properties[$index];
67 67
 		return $this->_getValue($property, $index);
68 68
 	}
69 69
 
70
-	private function _getValue($property,$index){
71
-		if($property instanceof \ReflectionProperty){
70
+	private function _getValue($property, $index) {
71
+		if ($property instanceof \ReflectionProperty) {
72 72
 			$property->setAccessible(true);
73 73
 			$value=$property->getValue($this->instance);
74
-			if(isset($this->values[$index])){
75
-				$value= $this->values[$index]($value);
74
+			if (isset($this->values[$index])) {
75
+				$value=$this->values[$index]($value);
76 76
 			}
77
-		}else{
78
-			if(\is_callable($property))
77
+		} else {
78
+			if (\is_callable($property))
79 79
 				$value=$property($this->instance);
80
-			elseif(\is_array($property)){
81
-				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
80
+			elseif (\is_array($property)) {
81
+				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property);
82 82
 				$value=\implode("", $values);
83
-			}else
83
+			} else
84 84
 				$value=$property;
85 85
 		}
86
-		if(isset($this->afterCompile[$index])){
87
-			if(\is_callable($this->afterCompile[$index])){
88
-				$this->afterCompile[$index]($value,$this->instance,$index);
86
+		if (isset($this->afterCompile[$index])) {
87
+			if (\is_callable($this->afterCompile[$index])) {
88
+				$this->afterCompile[$index]($value, $this->instance, $index);
89 89
 			}
90 90
 		}
91 91
 		return $value;
92 92
 	}
93 93
 
94
-	public function insertField($index,$field){
95
-		array_splice( $this->visibleProperties, $index, 0, $field );
94
+	public function insertField($index, $field) {
95
+		array_splice($this->visibleProperties, $index, 0, $field);
96 96
 		return $this;
97 97
 	}
98 98
 
99
-	public function insertInField($index,$field){
99
+	public function insertInField($index, $field) {
100 100
 		$vb=$this->visibleProperties;
101
-		if(isset($vb[$index])){
102
-			if(\is_array($vb[$index])){
101
+		if (isset($vb[$index])) {
102
+			if (\is_array($vb[$index])) {
103 103
 				$this->visibleProperties[$index][]=$field;
104
-			}else{
105
-				$this->visibleProperties[$index]=[$vb[$index],$field];
104
+			} else {
105
+				$this->visibleProperties[$index]=[$vb[$index], $field];
106 106
 			}
107
-		}else{
107
+		} else {
108 108
 			return $this->insertField($index, $field);
109 109
 		}
110 110
 		return $this;
111 111
 	}
112 112
 
113
-	public function addField($field){
113
+	public function addField($field) {
114 114
 		$this->visibleProperties[]=$field;
115 115
 		return $this;
116 116
 	}
117 117
 
118
-	public function count(){
118
+	public function count() {
119 119
 		return \sizeof($this->properties);
120 120
 	}
121 121
 
122
-	public function visiblePropertiesCount(){
122
+	public function visiblePropertiesCount() {
123 123
 		return \sizeof($this->visibleProperties);
124 124
 	}
125 125
 
126
-	private function showableProperty(\ReflectionProperty $rProperty){
127
-		return JString::startswith($rProperty->getName(),"_")===false;
126
+	private function showableProperty(\ReflectionProperty $rProperty) {
127
+		return JString::startswith($rProperty->getName(), "_")===false;
128 128
 	}
129 129
 
130 130
 	public function setInstance($instance) {
131
-		if(\is_string($instance)){
131
+		if (\is_string($instance)) {
132 132
 			$instance=new $instance();
133 133
 		}
134 134
 		$this->instance=$instance;
135 135
 		$this->properties=[];
136 136
 		$this->reflect=new \ReflectionClass($instance);
137
-		if(\sizeof($this->visibleProperties)===0){
137
+		if (\sizeof($this->visibleProperties)===0) {
138 138
 			$this->properties=$this->getDefaultProperties();
139
-		}else{
140
-			foreach ($this->visibleProperties as $property){
141
-				if(\is_callable($property)){
139
+		} else {
140
+			foreach ($this->visibleProperties as $property) {
141
+				if (\is_callable($property)) {
142 142
 					$this->properties[]=$property;
143
-				}elseif(\is_string($property)){
144
-					try{
143
+				}elseif (\is_string($property)) {
144
+					try {
145 145
 						$rProperty=$this->reflect->getProperty($property);
146 146
 						$this->properties[]=$rProperty;
147
-					}catch(\Exception $e){
147
+					}catch (\Exception $e) {
148 148
 						$this->properties[]=$property;
149 149
 					}
150
-				}elseif(\is_int($property)){
150
+				}elseif (\is_int($property)) {
151 151
 					$props=$this->getDefaultProperties();
152
-					if(isset($props[$property]))
152
+					if (isset($props[$property]))
153 153
 						$this->properties[]=$props[$property];
154 154
 					else
155 155
 						$this->properties[]=$property;
156
-				}else{
156
+				} else {
157 157
 					$this->properties[]=$property;
158 158
 				}
159 159
 			}
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
 		return $this;
162 162
 	}
163 163
 
164
-	private function getDefaultProperties(){
164
+	private function getDefaultProperties() {
165 165
 		$result=[];
166 166
 		$properties=$this->reflect->getProperties();
167
-		foreach ($properties as $property){
167
+		foreach ($properties as $property) {
168 168
 			$showable=$this->showableProperty($property);
169
-			if($showable!==false){
169
+			if ($showable!==false) {
170 170
 				$result[]=$property;
171 171
 			}
172 172
 		}
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
 		return $this;
184 184
 	}
185 185
 
186
-	public function setValueFunction($index,$callback){
186
+	public function setValueFunction($index, $callback) {
187 187
 		$this->values[$index]=$callback;
188 188
 		return $this;
189 189
 	}
190 190
 
191
-	public function setIdentifierFunction($callback){
191
+	public function setIdentifierFunction($callback) {
192 192
 		$this->values["identifier"]=$callback;
193 193
 		return $this;
194 194
 	}
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @param callable $callback function called after the field compilation
209 209
 	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
210 210
 	 */
211
-	public function afterCompile($index,$callback){
211
+	public function afterCompile($index, $callback) {
212 212
 		$this->afterCompile[$index]=$callback;
213 213
 		return $this;
214 214
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/PositionInTable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,5 +3,5 @@
 block discarded – undo
3 3
 use Ajax\common\BaseEnum;
4 4
 
5 5
 abstract class PositionInTable extends BaseEnum {
6
-	const BEFORETABLE="beforeTable",AFTERTABLE="afterTable",HEADER="thead",FOOTER="tfoot",BODY="tbody";
6
+	const BEFORETABLE="beforeTable", AFTERTABLE="afterTable", HEADER="thead", FOOTER="tfoot", BODY="tbody";
7 7
 }
8 8
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -14,41 +14,41 @@  discard block
 block discarded – undo
14 14
  * @property InstanceViewer $_instanceViewer
15 15
  */
16 16
 
17
-trait FieldAsTrait{
17
+trait FieldAsTrait {
18 18
 
19 19
 	protected abstract function _getFieldIdentifier($prefix);
20
-	public abstract function setValueFunction($index,$callback);
20
+	public abstract function setValueFunction($index, $callback);
21 21
 
22
-	public function fieldAsImage($index,$size=Size::SMALL,$circular=false){
23
-		$this->setValueFunction($index,function($img) use($size,$circular){
24
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
22
+	public function fieldAsImage($index, $size=Size::SMALL, $circular=false) {
23
+		$this->setValueFunction($index, function($img) use($size, $circular){
24
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
25 25
 			return $image;
26 26
 		}
27 27
 		);
28 28
 			return $this;
29 29
 	}
30 30
 
31
-	public function fieldAsAvatar($index){
32
-		$this->setValueFunction($index,function($img){return (new HtmlImage("",$img))->asAvatar();});
31
+	public function fieldAsAvatar($index) {
32
+		$this->setValueFunction($index, function($img) {return (new HtmlImage("", $img))->asAvatar(); });
33 33
 		return $this;
34 34
 	}
35 35
 
36
-	public function fieldAsRadio($index,$name=NULL){
37
-		$this->setValueFunction($index,function($value)use ($index,$name){
38
-			if(isset($name)===false){
36
+	public function fieldAsRadio($index, $name=NULL) {
37
+		$this->setValueFunction($index, function($value)use ($index, $name){
38
+			if (isset($name)===false) {
39 39
 				$name=$this->_instanceViewer->getCaption($index)."[]";
40 40
 			}
41
-			$radio=new HtmlRadio($this->_getFieldIdentifier("radio"),$name,$value,$value);
41
+			$radio=new HtmlRadio($this->_getFieldIdentifier("radio"), $name, $value, $value);
42 42
 			return $radio;
43 43
 		}
44 44
 		);
45 45
 			return $this;
46 46
 	}
47 47
 
48
-	public function fieldAsInput($index,$name=NULL,$type="text",$placeholder=""){
49
-		$this->setValueFunction($index,function($value) use($index,$name,$type,$placeholder){
50
-			$input=new HtmlInput($this->_getFieldIdentifier("input"),$type,$value,$placeholder);
51
-			if(isset($name)===false){
48
+	public function fieldAsInput($index, $name=NULL, $type="text", $placeholder="") {
49
+		$this->setValueFunction($index, function($value) use($index, $name, $type, $placeholder){
50
+			$input=new HtmlInput($this->_getFieldIdentifier("input"), $type, $value, $placeholder);
51
+			if (isset($name)===false) {
52 52
 				$name=$this->_instanceViewer->getCaption($index)."[]";
53 53
 			}
54 54
 			$input->getField()->setProperty("name", $name);
@@ -59,27 +59,27 @@  discard block
 block discarded – undo
59 59
 			return $this;
60 60
 	}
61 61
 
62
-	public function fieldAsCheckbox($index,$name=NULL){
63
-		$this->setValueFunction($index,function($value) use($index,$name){
64
-			$checkbox=new HtmlCheckbox($this->_getFieldIdentifier("ck"),"",$value);
62
+	public function fieldAsCheckbox($index, $name=NULL) {
63
+		$this->setValueFunction($index, function($value) use($index, $name){
64
+			$checkbox=new HtmlCheckbox($this->_getFieldIdentifier("ck"), "", $value);
65 65
 			$checkbox->setChecked(JString::isBooleanTrue($value));
66
-			if(isset($name)===false){
66
+			if (isset($name)===false) {
67 67
 				$name=$this->_instanceViewer->getCaption($index)."[]";
68 68
 			}
69 69
 			$checkbox->getField()->setProperty("name", $name);
70
-			return $checkbox;}
70
+			return $checkbox; }
71 71
 			);
72 72
 			return $this;
73 73
 	}
74 74
 
75
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$name=NULL){
76
-		$this->setValueFunction($index,function($value) use($index,$elements,$multiple,$name){
77
-			$dd=new HtmlDropdown($this->_getFieldIdentifier("dd"),$value,$elements);
78
-			if(isset($name)===false){
75
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $name=NULL) {
76
+		$this->setValueFunction($index, function($value) use($index, $elements, $multiple, $name){
77
+			$dd=new HtmlDropdown($this->_getFieldIdentifier("dd"), $value, $elements);
78
+			if (isset($name)===false) {
79 79
 				$name=$this->_instanceViewer->getCaption($index)."[]";
80 80
 			}
81
-			$dd->asSelect($name,$multiple);
82
-			return $dd;}
81
+			$dd->asSelect($name, $multiple);
82
+			return $dd; }
83 83
 			);
84 84
 			return $this;
85 85
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	protected $_compileParts;
31 31
 	protected $_toolbarPosition;
32 32
 
33
-	public function run(JsUtils $js){
34
-		if($this->_hasCheckboxes && isset($js)){
33
+	public function run(JsUtils $js) {
34
+		if ($this->_hasCheckboxes && isset($js)) {
35 35
 			$js->execOn("change", "#".$this->identifier." [name='selection[]']", "
36 36
 		var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true;
37 37
 		\$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}});
@@ -40,21 +40,21 @@  discard block
 block discarded – undo
40 40
 		parent::run($js);
41 41
 	}
42 42
 
43
-	public function __construct($identifier,$model,$modelInstance=NULL) {
44
-		parent::__construct($identifier, $model,$modelInstance);
43
+	public function __construct($identifier, $model, $modelInstance=NULL) {
44
+		parent::__construct($identifier, $model, $modelInstance);
45 45
 		$this->_instanceViewer=new InstanceViewer();
46
-		$this->content=["table"=>new HtmlTable($identifier, 0,0)];
46
+		$this->content=["table"=>new HtmlTable($identifier, 0, 0)];
47 47
 		$this->_toolbarPosition=PositionInTable::BEFORETABLE;
48 48
 	}
49 49
 
50
-	public function compile(JsUtils $js=NULL,&$view=NULL){
50
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
51 51
 		$this->_instanceViewer->setInstance($this->_model);
52 52
 		$captions=$this->_instanceViewer->getCaptions();
53 53
 
54 54
 		$table=$this->content["table"];
55 55
 
56
-		if($this->_hasCheckboxes){
57
-			$ck=new HtmlCheckbox("main-ck-".$this->identifier,"");
56
+		if ($this->_hasCheckboxes) {
57
+			$ck=new HtmlCheckbox("main-ck-".$this->identifier, "");
58 58
 			$ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);");
59 59
 			$ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);");
60 60
 			\array_unshift($captions, $ck);
@@ -62,43 +62,43 @@  discard block
 block discarded – undo
62 62
 
63 63
 		$table->setRowCount(0, \sizeof($captions));
64 64
 		$table->setHeaderValues($captions);
65
-		if(isset($this->_compileParts))
65
+		if (isset($this->_compileParts))
66 66
 			$table->setCompileParts($this->_compileParts);
67
-		if(isset($this->_searchField)){
68
-			if(isset($js))
69
-				$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]);
67
+		if (isset($this->_searchField)) {
68
+			if (isset($js))
69
+				$this->_searchField->postOn("change", $this->_urls, "{'s':$(this).val()}", "-#".$this->identifier." tbody", ["preventDefault"=>false]);
70 70
 		}
71 71
 
72 72
 		$this->_generateContent($table);
73 73
 
74
-		if($this->_hasCheckboxes){
75
-			if($table->hasPart("thead"))
76
-				$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
74
+		if ($this->_hasCheckboxes) {
75
+			if ($table->hasPart("thead"))
76
+				$table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort");
77 77
 		}
78 78
 
79
-		if(isset($this->_pagination) && $this->_pagination->getVisible()){
79
+		if (isset($this->_pagination) && $this->_pagination->getVisible()) {
80 80
 			$this->_generatePagination($table);
81 81
 		}
82
-		if(isset($this->_toolbar)){
82
+		if (isset($this->_toolbar)) {
83 83
 			$this->_setToolbarPosition($table, $captions);
84 84
 		}
85
-		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
86
-		return parent::compile($js,$view);
85
+		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
86
+		return parent::compile($js, $view);
87 87
 	}
88 88
 
89
-	private function _generateContent($table){
89
+	private function _generateContent($table) {
90 90
 		$objects=$this->_modelInstance;
91
-		if(isset($this->_pagination)){
91
+		if (isset($this->_pagination)) {
92 92
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
93 93
 		}
94 94
 		InstanceViewer::setIndex(0);
95
-		$table->fromDatabaseObjects($objects, function($instance){
95
+		$table->fromDatabaseObjects($objects, function($instance) {
96 96
 			$this->_instanceViewer->setInstance($instance);
97
-			$result= $this->_instanceViewer->getValues();
98
-			if($this->_hasCheckboxes){
99
-				$ck=new HtmlCheckbox("ck-".$this->identifier,"");
97
+			$result=$this->_instanceViewer->getValues();
98
+			if ($this->_hasCheckboxes) {
99
+				$ck=new HtmlCheckbox("ck-".$this->identifier, "");
100 100
 				$field=$ck->getField();
101
-				$field->setProperty("value",$this->_instanceViewer->getIdentifier());
101
+				$field->setProperty("value", $this->_instanceViewer->getIdentifier());
102 102
 				$field->setProperty("name", "selection[]");
103 103
 				\array_unshift($result, $ck);
104 104
 			}
@@ -106,25 +106,25 @@  discard block
 block discarded – undo
106 106
 		});
107 107
 	}
108 108
 
109
-	private function _generatePagination($table){
109
+	private function _generatePagination($table) {
110 110
 		$footer=$table->getFooter();
111 111
 		$footer->mergeCol();
112
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
112
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
113 113
 		$menu->floatRight();
114 114
 		$menu->setActiveItem($this->_pagination->getPage()-1);
115 115
 		$footer->setValues($menu);
116
-		$menu->postOnClick($this->_urls,"{'p':$(this).attr('data-page')}","-#".$this->identifier." tbody",["preventDefault"=>false]);
116
+		$menu->postOnClick($this->_urls, "{'p':$(this).attr('data-page')}", "-#".$this->identifier." tbody", ["preventDefault"=>false]);
117 117
 	}
118 118
 
119
-	private function _setToolbarPosition($table,$captions){
120
-		switch ($this->_toolbarPosition){
119
+	private function _setToolbarPosition($table, $captions) {
120
+		switch ($this->_toolbarPosition) {
121 121
 			case PositionInTable::BEFORETABLE:case PositionInTable::AFTERTABLE:
122
-				if(isset($this->_compileParts)===false){
122
+				if (isset($this->_compileParts)===false) {
123 123
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
124 124
 				}
125 125
 				break;
126 126
 			case PositionInTable::HEADER:case PositionInTable::FOOTER: case PositionInTable::BODY:
127
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
127
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
128 128
 				break;
129 129
 		}
130 130
 	}
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
 	 * @param callable $callback function called after the field compilation
137 137
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
138 138
 	 */
139
-	public function afterCompile($index,$callback){
140
-		$this->_instanceViewer->afterCompile($index,$callback);
139
+	public function afterCompile($index, $callback) {
140
+		$this->_instanceViewer->afterCompile($index, $callback);
141 141
 		return $this;
142 142
 	}
143 143
 
144
-	private function addToolbarRow($part,$table,$captions){
144
+	private function addToolbarRow($part, $table, $captions) {
145 145
 		$row=$table->getPart($part)->addRow(\sizeof($captions));
146 146
 		$row->mergeCol();
147 147
 		$row->setValues([$this->_toolbar]);
@@ -156,42 +156,42 @@  discard block
 block discarded – undo
156 156
 		return $this;
157 157
 	}
158 158
 
159
-	public function setCaptions($captions){
159
+	public function setCaptions($captions) {
160 160
 		$this->_instanceViewer->setCaptions($captions);
161 161
 		return $this;
162 162
 	}
163 163
 
164
-	public function setFields($fields){
164
+	public function setFields($fields) {
165 165
 		$this->_instanceViewer->setVisibleProperties($fields);
166 166
 		return $this;
167 167
 	}
168 168
 
169
-	public function addField($field){
169
+	public function addField($field) {
170 170
 		$this->_instanceViewer->addField($field);
171 171
 		return $this;
172 172
 	}
173 173
 
174
-	public function insertField($index,$field){
174
+	public function insertField($index, $field) {
175 175
 		$this->_instanceViewer->insertField($index, $field);
176 176
 		return $this;
177 177
 	}
178 178
 
179
-	public function insertInField($index,$field){
179
+	public function insertInField($index, $field) {
180 180
 		$this->_instanceViewer->insertInField($index, $field);
181 181
 		return $this;
182 182
 	}
183 183
 
184
-	public function setValueFunction($index,$callback){
184
+	public function setValueFunction($index, $callback) {
185 185
 		$this->_instanceViewer->setValueFunction($index, $callback);
186 186
 		return $this;
187 187
 	}
188 188
 
189
-	public function setIdentifierFunction($callback){
189
+	public function setIdentifierFunction($callback) {
190 190
 		$this->_instanceViewer->setIdentifierFunction($callback);
191 191
 		return $this;
192 192
 	}
193 193
 
194
-	public function getHtmlComponent(){
194
+	public function getHtmlComponent() {
195 195
 		return $this->content["table"];
196 196
 	}
197 197
 
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 		return $this;
205 205
 	}
206 206
 
207
-	public function paginate($items_per_page=10,$page=1){
208
-		$this->_pagination=new Pagination($items_per_page,4,$page);
207
+	public function paginate($items_per_page=10, $page=1) {
208
+		$this->_pagination=new Pagination($items_per_page, 4, $page);
209 209
 	}
210 210
 
211 211
 	public function getHasCheckboxes() {
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		return $this;
218 218
 	}
219 219
 
220
-	public function refresh($compileParts=["tbody"]){
220
+	public function refresh($compileParts=["tbody"]) {
221 221
 		$this->_compileParts=$compileParts;
222 222
 		return $this;
223 223
 	}
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param callable $callback
227 227
 	 * @return callable
228 228
 	 */
229
-	private function getFieldButtonCallable($caption,$callback=null){
230
-		return $this->getCallable($this->getFieldButton($caption),$callback);
229
+	private function getFieldButtonCallable($caption, $callback=null) {
230
+		return $this->getCallable($this->getFieldButton($caption), $callback);
231 231
 	}
232 232
 
233 233
 	/**
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 	 * @param callable $callback
236 236
 	 * @return callable
237 237
 	 */
238
-	private function getCallable($object,$callback=null){
239
-		$result=function($instance) use($object,$callback){
240
-			if(isset($callback)){
241
-				if(\is_callable($callback)){
242
-					$callback($object,$instance);
238
+	private function getCallable($object, $callback=null) {
239
+		$result=function($instance) use($object, $callback){
240
+			if (isset($callback)) {
241
+				if (\is_callable($callback)) {
242
+					$callback($object, $instance);
243 243
 				}
244 244
 			}
245 245
 			return $object;
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	 * @param string $caption
252 252
 	 * @return HtmlButton
253 253
 	 */
254
-	private function getFieldButton($caption){
255
-			$bt=new HtmlButton("",$caption);
256
-			$bt->setProperty("data-ajax",$this->_instanceViewer->getIdentifier());
254
+	private function getFieldButton($caption) {
255
+			$bt=new HtmlButton("", $caption);
256
+			$bt->setProperty("data-ajax", $this->_instanceViewer->getIdentifier());
257 257
 			return $bt;
258 258
 	}
259 259
 
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 	 * @param callable $callback
264 264
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
265 265
 	 */
266
-	public function addFieldButton($caption,$callback=null){
267
-		$this->addField($this->getFieldButtonCallable($caption,$callback));
266
+	public function addFieldButton($caption, $callback=null) {
267
+		$this->addField($this->getFieldButtonCallable($caption, $callback));
268 268
 		return $this;
269 269
 	}
270 270
 
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 	 * @param callable $callback
276 276
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
277 277
 	 */
278
-	public function insertFieldButton($index,$caption,$callback=null){
279
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$callback));
278
+	public function insertFieldButton($index, $caption, $callback=null) {
279
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $callback));
280 280
 		return $this;
281 281
 	}
282 282
 
@@ -287,55 +287,55 @@  discard block
 block discarded – undo
287 287
 	 * @param callable $callback
288 288
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
289 289
 	 */
290
-	public function insertInFieldButton($index,$caption,$callback=null){
291
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$callback));
290
+	public function insertInFieldButton($index, $caption, $callback=null) {
291
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $callback));
292 292
 		return $this;
293 293
 	}
294 294
 
295
-	private function addDefaultButton($icon,$class=null,$callback=null){
296
-		$bt=$this->getDefaultButton($icon,$class);
297
-		$this->addField($this->getCallable($bt,$callback));
295
+	private function addDefaultButton($icon, $class=null, $callback=null) {
296
+		$bt=$this->getDefaultButton($icon, $class);
297
+		$this->addField($this->getCallable($bt, $callback));
298 298
 		return $this;
299 299
 	}
300 300
 
301
-	private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){
302
-		$bt=$this->getDefaultButton($icon,$class);
303
-		$this->insertInField($index,$this->getCallable($bt,$callback));
301
+	private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) {
302
+		$bt=$this->getDefaultButton($icon, $class);
303
+		$this->insertInField($index, $this->getCallable($bt, $callback));
304 304
 		return $this;
305 305
 	}
306 306
 
307
-	private function getDefaultButton($icon,$class=null){
307
+	private function getDefaultButton($icon, $class=null) {
308 308
 		$bt=$this->getFieldButton("");
309 309
 		$bt->asIcon($icon);
310
-		if(isset($class))
310
+		if (isset($class))
311 311
 			$bt->addToProperty("class", $class);
312 312
 		return $bt;
313 313
 	}
314 314
 
315
-	public function addDeleteButton($callback=null){
316
-		return $this->addDefaultButton("remove","delete red basic",$callback);
315
+	public function addDeleteButton($callback=null) {
316
+		return $this->addDefaultButton("remove", "delete red basic", $callback);
317 317
 	}
318 318
 
319
-	public function addEditButton($callback=null){
320
-		return $this->addDefaultButton("edit","edit basic",$callback);
319
+	public function addEditButton($callback=null) {
320
+		return $this->addDefaultButton("edit", "edit basic", $callback);
321 321
 	}
322 322
 
323
-	public function addEditDeleteButtons($callbackEdit=null,$callbackDelete=null){
323
+	public function addEditDeleteButtons($callbackEdit=null, $callbackDelete=null) {
324 324
 		$this->addEditButton($callbackEdit);
325 325
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
326
-		$this->insertDeleteButtonIn($index,$callbackDelete);
326
+		$this->insertDeleteButtonIn($index, $callbackDelete);
327 327
 		return $this;
328 328
 	}
329 329
 
330
-	public function insertDeleteButtonIn($index,$callback=null){
331
-		return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback);
330
+	public function insertDeleteButtonIn($index, $callback=null) {
331
+		return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback);
332 332
 	}
333 333
 
334
-	public function insertEditButtonIn($index,$callback=null){
335
-		return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback);
334
+	public function insertEditButtonIn($index, $callback=null) {
335
+		return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback);
336 336
 	}
337 337
 
338
-	public function setSelectable(){
338
+	public function setSelectable() {
339 339
 		$this->content["table"]->setSelectable();
340 340
 		return $this;
341 341
 	}
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	/**
344 344
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
345 345
 	 */
346
-	public function getToolbar(){
347
-		if(isset($this->_toolbar)===false){
346
+	public function getToolbar() {
347
+		if (isset($this->_toolbar)===false) {
348 348
 			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
349 349
 			$this->_toolbar->setSecondary();
350 350
 		}
@@ -355,37 +355,37 @@  discard block
 block discarded – undo
355 355
 	 * @param unknown $element
356 356
 	 * @return \Ajax\common\html\HtmlDoubleElement
357 357
 	 */
358
-	public function addInToolbar($element){
358
+	public function addInToolbar($element) {
359 359
 		$tb=$this->getToolbar();
360 360
 		return $tb->addItem($element);
361 361
 	}
362 362
 
363
-	public function addItemInToolbar($caption,$icon=NULL){
363
+	public function addItemInToolbar($caption, $icon=NULL) {
364 364
 		$result=$this->addInToolbar($caption);
365 365
 		$result->addIcon($icon);
366 366
 		return $result;
367 367
 	}
368 368
 
369
-	public function addButtonInToolbar($caption){
370
-		$bt=new HtmlButton("",$caption);
369
+	public function addButtonInToolbar($caption) {
370
+		$bt=new HtmlButton("", $caption);
371 371
 		return $this->addInToolbar($bt);
372 372
 	}
373 373
 
374
-	public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){
375
-		$bt=new HtmlButton("",$caption);
376
-		$bt->addIcon($icon,$before,$labeled);
374
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
375
+		$bt=new HtmlButton("", $caption);
376
+		$bt->addIcon($icon, $before, $labeled);
377 377
 		return $this->addInToolbar($bt);
378 378
 	}
379 379
 
380 380
 
381
-	public function addSearchInToolbar(){
381
+	public function addSearchInToolbar() {
382 382
 		return $this->addInToolbar($this->getSearchField())->setPosition("right");
383 383
 	}
384 384
 
385
-	public function getSearchField(){
386
-		if(isset($this->_searchField)===false){
387
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
388
-			$this->_searchField->addIcon("search",Direction::RIGHT);
385
+	public function getSearchField() {
386
+		if (isset($this->_searchField)===false) {
387
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
388
+			$this->_searchField->addIcon("search", Direction::RIGHT);
389 389
 		}
390 390
 		return $this->_searchField;
391 391
 	}
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 		return $this;
396 396
 	}
397 397
 
398
-	protected function _getFieldIdentifier($prefix){
398
+	protected function _getFieldIdentifier($prefix) {
399 399
 		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
400 400
 	}
401 401
 }
402 402
\ No newline at end of file
Please login to merge, or discard this patch.