Completed
Push — master ( b1ec61...2db7b1 )
by Jean-Christophe
03:13
created
Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php 2 patches
Doc Comments   +33 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,15 +14,28 @@  discard block
 block discarded – undo
14 14
  * @property InstanceViewer $_instanceViewer
15 15
  */
16 16
 trait DataTableFieldAsTrait{
17
+
18
+	/**
19
+	 * @param \Closure $field
20
+	 */
17 21
 	abstract public function addField($field);
22
+
23
+	/**
24
+	 * @param integer $index
25
+	 * @param \Closure $field
26
+	 */
18 27
 	abstract public function insertField($index,$field);
28
+
29
+	/**
30
+	 * @param \Closure $field
31
+	 */
19 32
 	abstract public function insertInField($index,$field);
20 33
 	abstract public function fieldAs($index,$type,$attributes=NULL);
21 34
 	/**
22 35
 	 * @param string $caption
23 36
 	 * @param callable $callback
24 37
 	 * @param boolean $visibleHover
25
-	 * @return callable
38
+	 * @return \Closure
26 39
 	 */
27 40
 	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
28 41
 		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
@@ -32,7 +45,7 @@  discard block
 block discarded – undo
32 45
 	 * @param callable $thisCallback
33 46
 	 * @param array $parameters
34 47
 	 * @param callable $callback
35
-	 * @return callable
48
+	 * @return \Closure
36 49
 	 */
37 50
 	private function getCallable($thisCallback,$parameters,$callback=null){
38 51
 		$result=function($instance) use($thisCallback,$parameters,$callback){
@@ -94,7 +107,7 @@  discard block
 block discarded – undo
94 107
 	 * @param string $caption
95 108
 	 * @param callable $callback
96 109
 	 * @param boolean $visibleHover
97
-	 * @return DataTable
110
+	 * @return DataTableFieldAsTrait
98 111
 	 */
99 112
 	public function addFieldButton($caption,$visibleHover=true,$callback=null){
100 113
 		$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
@@ -106,7 +119,7 @@  discard block
 block discarded – undo
106 119
 	 * @param int $index
107 120
 	 * @param string $caption
108 121
 	 * @param callable $callback
109
-	 * @return DataTable
122
+	 * @return DataTableFieldAsTrait
110 123
 	 */
111 124
 	public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){
112 125
 		$this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
@@ -118,18 +131,27 @@  discard block
 block discarded – undo
118 131
 	 * @param int $index
119 132
 	 * @param string $caption
120 133
 	 * @param callable $callback
121
-	 * @return DataTable
134
+	 * @return DataTableFieldAsTrait
122 135
 	 */
123 136
 	public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){
124 137
 		$this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
125 138
 		return $this;
126 139
 	}
127 140
 
141
+	/**
142
+	 * @param string $icon
143
+	 * @param string $class
144
+	 * @param callable $callback
145
+	 */
128 146
 	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
129 147
 		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
130 148
 		return $this;
131 149
 	}
132 150
 
151
+	/**
152
+	 * @param string $icon
153
+	 * @param string $class
154
+	 */
133 155
 	private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){
134 156
 		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
135 157
 		return $this;
@@ -148,7 +170,7 @@  discard block
 block discarded – undo
148 170
 	 * @param boolean $visibleHover
149 171
 	 * @param array $deleteBehavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get")
150 172
 	 * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
151
-	 * @return DataTable
173
+	 * @return DataTableFieldAsTrait
152 174
 	 */
153 175
 	public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){
154 176
 		$this->_deleteBehavior=$deleteBehavior;
@@ -160,7 +182,7 @@  discard block
 block discarded – undo
160 182
 	 * @param string $visibleHover
161 183
 	 * @param array $editBehavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get")
162 184
 	 * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
163
-	 * @return DataTable
185
+	 * @return DataTableFieldAsTrait
164 186
 	 */
165 187
 	public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){
166 188
 		$this->_editBehavior=$editBehavior;
@@ -173,7 +195,7 @@  discard block
 block discarded – undo
173 195
 	 * @param array $behavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get")
174 196
 	 * @param callable $callbackEdit this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
175 197
 	 * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
176
-	 * @return DataTable
198
+	 * @return DataTableFieldAsTrait
177 199
 	 */
178 200
 	public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){
179 201
 		$this->addEditButton($visibleHover,$behavior,$callbackEdit);
@@ -182,6 +204,9 @@  discard block
 block discarded – undo
182 204
 		return $this;
183 205
 	}
184 206
 
207
+	/**
208
+	 * @param callable $callback
209
+	 */
185 210
 	public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){
186 211
 		$this->_deleteBehavior=$deleteBehavior;
187 212
 		return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback);
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
  * @property boolean $_visibleHover
14 14
  * @property InstanceViewer $_instanceViewer
15 15
  */
16
-trait DataTableFieldAsTrait{
16
+trait DataTableFieldAsTrait {
17 17
 	abstract public function addField($field);
18
-	abstract public function insertField($index,$field);
19
-	abstract public function insertInField($index,$field);
20
-	abstract public function fieldAs($index,$type,$attributes=NULL);
18
+	abstract public function insertField($index, $field);
19
+	abstract public function insertInField($index, $field);
20
+	abstract public function fieldAs($index, $type, $attributes=NULL);
21 21
 	/**
22 22
 	 * @param string $caption
23 23
 	 * @param callable $callback
24 24
 	 * @param boolean $visibleHover
25 25
 	 * @return callable
26 26
 	 */
27
-	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
28
-		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
27
+	private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) {
28
+		return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback);
29 29
 	}
30 30
 
31 31
 	/**
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 	 * @param callable $callback
35 35
 	 * @return callable
36 36
 	 */
37
-	private function getCallable($thisCallback,$parameters,$callback=null){
38
-		$result=function($instance) use($thisCallback,$parameters,$callback){
39
-			$object=call_user_func_array(array($this,$thisCallback), $parameters);
40
-			if(isset($callback)){
41
-				if(\is_callable($callback)){
42
-					$callback($object,$instance);
37
+	private function getCallable($thisCallback, $parameters, $callback=null) {
38
+		$result=function($instance) use($thisCallback, $parameters, $callback){
39
+			$object=call_user_func_array(array($this, $thisCallback), $parameters);
40
+			if (isset($callback)) {
41
+				if (\is_callable($callback)) {
42
+					$callback($object, $instance);
43 43
 				}
44 44
 			}
45
-			if($object instanceof HtmlSemDoubleElement){
46
-				$object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier());
47
-				if($object->propertyContains("class","visibleover")){
45
+			if ($object instanceof HtmlSemDoubleElement) {
46
+				$object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier());
47
+				if ($object->propertyContains("class", "visibleover")) {
48 48
 					$this->_visibleHover=true;
49
-					$object->setProperty("style","visibility:hidden;");
49
+					$object->setProperty("style", "visibility:hidden;");
50 50
 				}
51 51
 			}
52 52
 			return $object;
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 	 * @param string $caption
59 59
 	 * @return HtmlButton
60 60
 	 */
61
-	private function getFieldButton($caption,$visibleHover=true){
62
-		$bt= new HtmlButton("",$caption);
63
-		if($visibleHover)
61
+	private function getFieldButton($caption, $visibleHover=true) {
62
+		$bt=new HtmlButton("", $caption);
63
+		if ($visibleHover)
64 64
 			$this->_visibleOver($bt);
65 65
 			return $bt;
66 66
 	}
@@ -74,19 +74,19 @@  discard block
 block discarded – undo
74 74
 	 * @param array $attributes associative array (<b>ajax</b> key is for ajax post)
75 75
 	 * @return DataTable
76 76
 	 */
77
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
78
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){
79
-			$button=new HtmlButton($id,$value,$cssStyle);
80
-			$button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]);
81
-			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
77
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
78
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){
79
+			$button=new HtmlButton($id, $value, $cssStyle);
80
+			$button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]);
81
+			if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
82 82
 				$this->_visibleOver($button);
83 83
 				return $button;
84
-		}, $index,$attributes);
84
+		}, $index, $attributes);
85 85
 	}
86 86
 
87
-	protected function _visibleOver(BaseHtml $element){
87
+	protected function _visibleOver(BaseHtml $element) {
88 88
 		$this->_visibleHover=true;
89
-		return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;");
89
+		return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;");
90 90
 	}
91 91
 
92 92
 	/**
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 * @param boolean $visibleHover
97 97
 	 * @return DataTable
98 98
 	 */
99
-	public function addFieldButton($caption,$visibleHover=true,$callback=null){
100
-		$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
99
+	public function addFieldButton($caption, $visibleHover=true, $callback=null) {
100
+		$this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback));
101 101
 		return $this;
102 102
 	}
103 103
 
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 * @param callable $callback
109 109
 	 * @return DataTable
110 110
 	 */
111
-	public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){
112
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
111
+	public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) {
112
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
113 113
 		return $this;
114 114
 	}
115 115
 
@@ -120,25 +120,25 @@  discard block
 block discarded – undo
120 120
 	 * @param callable $callback
121 121
 	 * @return DataTable
122 122
 	 */
123
-	public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){
124
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
123
+	public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) {
124
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
125 125
 		return $this;
126 126
 	}
127 127
 
128
-	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
129
-		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
128
+	private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) {
129
+		$this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
130 130
 		return $this;
131 131
 	}
132 132
 
133
-	private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){
134
-		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
133
+	private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) {
134
+		$this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
135 135
 		return $this;
136 136
 	}
137 137
 
138
-	private function getDefaultButton($icon,$class=null,$visibleHover=true){
139
-		$bt=$this->getFieldButton("",$visibleHover);
138
+	private function getDefaultButton($icon, $class=null, $visibleHover=true) {
139
+		$bt=$this->getFieldButton("", $visibleHover);
140 140
 		$bt->asIcon($icon);
141
-		if(isset($class))
141
+		if (isset($class))
142 142
 			$bt->addClass($class);
143 143
 		return $bt;
144 144
 	}
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 	 * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
151 151
 	 * @return DataTable
152 152
 	 */
153
-	public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){
153
+	public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) {
154 154
 		$this->_deleteBehavior=$deleteBehavior;
155
-		return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback);
155
+		return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback);
156 156
 	}
157 157
 
158 158
 	/**
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 	 * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
163 163
 	 * @return DataTable
164 164
 	 */
165
-	public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){
165
+	public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) {
166 166
 		$this->_editBehavior=$editBehavior;
167
-		return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback);
167
+		return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback);
168 168
 	}
169 169
 
170 170
 	/**
@@ -175,20 +175,20 @@  discard block
 block discarded – undo
175 175
 	 * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
176 176
 	 * @return DataTable
177 177
 	 */
178
-	public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){
179
-		$this->addEditButton($visibleHover,$behavior,$callbackEdit);
178
+	public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) {
179
+		$this->addEditButton($visibleHover, $behavior, $callbackEdit);
180 180
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
181
-		$this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete);
181
+		$this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete);
182 182
 		return $this;
183 183
 	}
184 184
 
185
-	public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){
185
+	public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) {
186 186
 		$this->_deleteBehavior=$deleteBehavior;
187
-		return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback);
187
+		return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback);
188 188
 	}
189 189
 
190
-	public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){
190
+	public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) {
191 191
 		$this->_editBehavior=$editBehavior;
192
-		return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback);
192
+		return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback);
193 193
 	}
194 194
 }
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *
25 25
  */
26 26
 class DataTable extends Widget {
27
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait;
27
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait;
28 28
 	protected $_searchField;
29 29
 	protected $_urls;
30 30
 	protected $_pagination;
@@ -42,35 +42,35 @@  discard block
 block discarded – undo
42 42
 	protected $_colWidths;
43 43
 
44 44
 
45
-	public function __construct($identifier,$model,$modelInstance=NULL) {
46
-		parent::__construct($identifier, $model,$modelInstance);
47
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
45
+	public function __construct($identifier, $model, $modelInstance=NULL) {
46
+		parent::__construct($identifier, $model, $modelInstance);
47
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
48 48
 		$this->_urls=[];
49
-		$this->_emptyMessage=new HtmlMessage("","nothing to display");
49
+		$this->_emptyMessage=new HtmlMessage("", "nothing to display");
50 50
 		$this->_emptyMessage->setIcon("info circle");
51 51
 	}
52 52
 
53
-	public function run(JsUtils $js){
54
-		if($this->_hasCheckboxes && isset($js)){
53
+	public function run(JsUtils $js) {
54
+		if ($this->_hasCheckboxes && isset($js)) {
55 55
 			$this->_runCheckboxes($js);
56 56
 		}
57
-		if($this->_visibleHover){
58
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
59
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
57
+		if ($this->_visibleHover) {
58
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
59
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
60 60
 		}
61
-		if(\is_array($this->_deleteBehavior))
62
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
63
-		if(\is_array($this->_editBehavior))
64
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
61
+		if (\is_array($this->_deleteBehavior))
62
+			$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
63
+		if (\is_array($this->_editBehavior))
64
+			$this->_generateBehavior("edit", $this->_editBehavior, $js);
65 65
 		return parent::run($js);
66 66
 	}
67 67
 
68 68
 
69 69
 
70
-	protected function _generateBehavior($op,$params,JsUtils $js){
71
-		if(isset($this->_urls[$op])){
72
-			$params=\array_merge($params,["attr"=>"data-ajax"]);
73
-			$js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector($op),$params);
70
+	protected function _generateBehavior($op, $params, JsUtils $js) {
71
+		if (isset($this->_urls[$op])) {
72
+			$params=\array_merge($params, ["attr"=>"data-ajax"]);
73
+			$js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params);
74 74
 		}
75 75
 	}
76 76
 
@@ -83,156 +83,156 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 
85 85
 
86
-	public function compile(JsUtils $js=NULL,&$view=NULL){
87
-		if(!$this->_generated){
86
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
87
+		if (!$this->_generated) {
88 88
 			$this->_instanceViewer->setInstance($this->_model);
89 89
 			$captions=$this->_instanceViewer->getCaptions();
90 90
 			$table=$this->content["table"];
91
-			if($this->_hasCheckboxes){
91
+			if ($this->_hasCheckboxes) {
92 92
 				$this->_generateMainCheckbox($captions);
93 93
 			}
94 94
 			$table->setRowCount(0, \sizeof($captions));
95
-			$this->_generateHeader($table,$captions);
95
+			$this->_generateHeader($table, $captions);
96 96
 
97
-			if(isset($this->_compileParts))
97
+			if (isset($this->_compileParts))
98 98
 				$table->setCompileParts($this->_compileParts);
99 99
 
100 100
 			$this->_generateContent($table);
101 101
 
102
-			$this->compileExtraElements($table, $captions,$js);
102
+			$this->compileExtraElements($table, $captions, $js);
103 103
 
104
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
104
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
105 105
 			$this->_compileForm();
106 106
 			$this->_applyStyleAttributes($table);
107 107
 			$this->_generated=true;
108 108
 		}
109
-		return parent::compile($js,$view);
109
+		return parent::compile($js, $view);
110 110
 	}
111 111
 
112
-	protected function compileExtraElements($table,$captions,JsUtils $js=NULL){
113
-		if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){
114
-				$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
112
+	protected function compileExtraElements($table, $captions, JsUtils $js=NULL) {
113
+		if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) {
114
+				$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
115 115
 		}
116
-		if($this->_hasCheckboxes && $table->hasPart("thead")){
116
+		if ($this->_hasCheckboxes && $table->hasPart("thead")) {
117 117
 			$table->getHeader()->getCell(0, 0)->addClass("no-sort");
118 118
 		}
119 119
 
120
-		if(isset($this->_toolbar)){
120
+		if (isset($this->_toolbar)) {
121 121
 			$this->_setToolbarPosition($table, $captions);
122 122
 		}
123
-		if(isset($this->_pagination) && $this->_pagination->getVisible()){
124
-			$this->_generatePagination($table,$js);
123
+		if (isset($this->_pagination) && $this->_pagination->getVisible()) {
124
+			$this->_generatePagination($table, $js);
125 125
 		}
126 126
 	}
127 127
 
128
-	protected function _applyStyleAttributes($table){
129
-		if(isset($this->_hiddenColumns))
128
+	protected function _applyStyleAttributes($table) {
129
+		if (isset($this->_hiddenColumns))
130 130
 			$this->_hideColumns();
131
-			if(isset($this->_colWidths)){
132
-				foreach ($this->_colWidths as $colIndex=>$width){
133
-					$table->setColWidth($colIndex,$width);
131
+			if (isset($this->_colWidths)) {
132
+				foreach ($this->_colWidths as $colIndex=>$width) {
133
+					$table->setColWidth($colIndex, $width);
134 134
 				}
135 135
 			}
136 136
 	}
137 137
 
138
-	protected function _hideColumns(){
139
-		foreach ($this->_hiddenColumns as $colIndex){
138
+	protected function _hideColumns() {
139
+		foreach ($this->_hiddenColumns as $colIndex) {
140 140
 			$this->_self->hideColumn($colIndex);
141 141
 		}
142 142
 		return $this;
143 143
 	}
144 144
 
145
-	protected function _generateHeader(HtmlTable $table,$captions){
145
+	protected function _generateHeader(HtmlTable $table, $captions) {
146 146
 		$table->setHeaderValues($captions);
147
-		if(isset($this->_sortable)){
147
+		if (isset($this->_sortable)) {
148 148
 			$table->setSortable($this->_sortable);
149 149
 		}
150 150
 	}
151 151
 
152 152
 
153 153
 
154
-	protected function _generateContent($table){
154
+	protected function _generateContent($table) {
155 155
 		$objects=$this->_modelInstance;
156
-		if(isset($this->_pagination)){
156
+		if (isset($this->_pagination)) {
157 157
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
158 158
 		}
159 159
 			InstanceViewer::setIndex(0);
160 160
 			$table->fromDatabaseObjects($objects, function($instance) use($table){
161 161
 				return $this->_generateRow($instance, $table);
162 162
 			});
163
-		if($table->getRowCount()==0){
163
+		if ($table->getRowCount()==0) {
164 164
 			$result=$table->addRow();
165 165
 			$result->mergeRow();
166 166
 			$result->setValues([$this->_emptyMessage]);
167 167
 		}
168 168
 	}
169 169
 
170
-	protected function _generateRow($instance,&$table,$checkedClass=null){
170
+	protected function _generateRow($instance, &$table, $checkedClass=null) {
171 171
 		$this->_instanceViewer->setInstance($instance);
172 172
 		InstanceViewer::$index++;
173
-		$values= $this->_instanceViewer->getValues();
173
+		$values=$this->_instanceViewer->getValues();
174 174
 		$id=$this->_instanceViewer->getIdentifier();
175
-		if($this->_hasCheckboxes){
176
-			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,"");
175
+		if ($this->_hasCheckboxes) {
176
+			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, "");
177 177
 			$ck->setOnChange("event.stopPropagation();");
178 178
 			$field=$ck->getField();
179
-			$field->setProperty("value",$id);
179
+			$field->setProperty("value", $id);
180 180
 			$field->setProperty("name", "selection[]");
181
-			if(isset($checkedClass))
181
+			if (isset($checkedClass))
182 182
 				$field->setClass($checkedClass);
183 183
 			\array_unshift($values, $ck);
184 184
 		}
185 185
 		$result=$table->newRow();
186 186
 		$result->setIdentifier($this->identifier."-tr-".$id);
187
-		$result->setProperty("data-ajax",$id);
187
+		$result->setProperty("data-ajax", $id);
188 188
 		$result->setValues($values);
189
-		$result->addToProperty("class",$this->_rowClass);
189
+		$result->addToProperty("class", $this->_rowClass);
190 190
 		return $result;
191 191
 	}
192 192
 
193
-	protected function _generatePagination($table,$js=NULL){
194
-		if(isset($this->_toolbar)){
195
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
193
+	protected function _generatePagination($table, $js=NULL) {
194
+		if (isset($this->_toolbar)) {
195
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
196 196
 				$this->_toolbar->setFloated("left");
197 197
 		}
198 198
 		$footer=$table->getFooter();
199 199
 		$footer->mergeCol();
200
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
200
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
201 201
 		$menu->floatRight();
202 202
 		$menu->setActiveItem($this->_pagination->getPage()-1);
203 203
 		$footer->addValues($menu);
204
-		$this->_associatePaginationBehavior($menu,$js);
204
+		$this->_associatePaginationBehavior($menu, $js);
205 205
 	}
206 206
 
207
-	protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){
208
-		if(isset($this->_urls["refresh"])){
209
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false]);
207
+	protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) {
208
+		if (isset($this->_urls["refresh"])) {
209
+			$menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith", "hasLoader"=>false]);
210 210
 		}
211 211
 	}
212 212
 
213
-	protected function _getFieldName($index){
213
+	protected function _getFieldName($index) {
214 214
 		$fieldName=parent::_getFieldName($index);
215
-		if(\is_object($fieldName))
215
+		if (\is_object($fieldName))
216 216
 			$fieldName="field-".$index;
217 217
 		return $fieldName."[]";
218 218
 	}
219 219
 
220
-	protected function _getFieldCaption($index){
220
+	protected function _getFieldCaption($index) {
221 221
 		return null;
222 222
 	}
223 223
 
224
-	protected function _setToolbarPosition($table,$captions=NULL){
225
-		switch ($this->_toolbarPosition){
224
+	protected function _setToolbarPosition($table, $captions=NULL) {
225
+		switch ($this->_toolbarPosition) {
226 226
 			case PositionInTable::BEFORETABLE:
227 227
 			case PositionInTable::AFTERTABLE:
228
-				if(isset($this->_compileParts)===false){
228
+				if (isset($this->_compileParts)===false) {
229 229
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
230 230
 				}
231 231
 				break;
232 232
 			case PositionInTable::HEADER:
233 233
 			case PositionInTable::FOOTER:
234 234
 			case PositionInTable::BODY:
235
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
235
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
236 236
 				break;
237 237
 		}
238 238
 	}
@@ -244,16 +244,16 @@  discard block
 block discarded – undo
244 244
 	 * @param callable $callback function called after the field compilation
245 245
 	 * @return DataTable
246 246
 	 */
247
-	public function afterCompile($index,$callback){
248
-		$this->_instanceViewer->afterCompile($index,$callback);
247
+	public function afterCompile($index, $callback) {
248
+		$this->_instanceViewer->afterCompile($index, $callback);
249 249
 		return $this;
250 250
 	}
251 251
 
252
-	private function addToolbarRow($part,$table,$captions){
252
+	private function addToolbarRow($part, $table, $captions) {
253 253
 		$hasPart=$table->hasPart($part);
254
-		if($hasPart){
254
+		if ($hasPart) {
255 255
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
256
-		}else{
256
+		} else {
257 257
 			$row=$table->getPart($part)->getRow(0);
258 258
 		}
259 259
 		$row->mergeCol();
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	 * @see Widget::getHtmlComponent()
266 266
 	 * @return HtmlTable
267 267
 	 */
268
-	public function getHtmlComponent(){
268
+	public function getHtmlComponent() {
269 269
 		return $this->content["table"];
270 270
 	}
271 271
 
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
 	 * @return DataTable
281 281
 	 */
282 282
 	public function setUrls($urls) {
283
-		if(\is_array($urls)){
284
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
285
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
286
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
287
-		}else{
288
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
283
+		if (\is_array($urls)) {
284
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
285
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
286
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
287
+		} else {
288
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls];
289 289
 		}
290 290
 		return $this;
291 291
 	}
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
299 299
 	 * @return DataTable
300 300
 	 */
301
-	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){
302
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount);
301
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
302
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
303 303
 		return $this;
304 304
 	}
305 305
 
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
311 311
 	 * @return DataTable
312 312
 	 */
313
-	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
314
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
313
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
314
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
315 315
 		return $this;
316 316
 	}
317 317
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	 * @param array $compileParts
322 322
 	 * @return DataTable
323 323
 	 */
324
-	public function refresh($compileParts=["tbody"]){
324
+	public function refresh($compileParts=["tbody"]) {
325 325
 		$this->_compileParts=$compileParts;
326 326
 		return $this;
327 327
 	}
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 	 * @param string $position
333 333
 	 * @return \Ajax\common\html\HtmlDoubleElement
334 334
 	 */
335
-	public function addSearchInToolbar($position=Direction::RIGHT){
335
+	public function addSearchInToolbar($position=Direction::RIGHT) {
336 336
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
337 337
 	}
338 338
 
339
-	public function getSearchField(){
340
-		if(isset($this->_searchField)===false){
341
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
342
-			$this->_searchField->addIcon("search",Direction::RIGHT);
339
+	public function getSearchField() {
340
+		if (isset($this->_searchField)===false) {
341
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
342
+			$this->_searchField->addIcon("search", Direction::RIGHT);
343 343
 		}
344 344
 		return $this->_searchField;
345 345
 	}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 * Returns a form corresponding to the Datatable
360 360
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
361 361
 	 */
362
-	public function asForm(){
362
+	public function asForm() {
363 363
 		return $this->getForm();
364 364
 	}
365 365
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 
368 368
 	protected function getTargetSelector($op) {
369 369
 		$result=$this->_targetSelector;
370
-		if(!isset($result[$op]))
370
+		if (!isset($result[$op]))
371 371
 			$result="#".$this->identifier;
372 372
 		return $result[$op];
373 373
 	}
@@ -378,15 +378,15 @@  discard block
 block discarded – undo
378 378
 	 * @return DataTable
379 379
 	 */
380 380
 	public function setTargetSelector($_targetSelector) {
381
-		if(!\is_array($_targetSelector)){
382
-			$_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector];
381
+		if (!\is_array($_targetSelector)) {
382
+			$_targetSelector=["edit"=>$_targetSelector, "delete"=>$_targetSelector];
383 383
 		}
384 384
 		$this->_targetSelector=$_targetSelector;
385 385
 		return $this;
386 386
 	}
387 387
 
388 388
 	public function getRefreshSelector() {
389
-		if(isset($this->_refreshSelector))
389
+		if (isset($this->_refreshSelector))
390 390
 			return $this->_refreshSelector;
391 391
 		return "#".$this->identifier." tbody";
392 392
 	}
@@ -404,9 +404,9 @@  discard block
 block discarded – undo
404 404
 	 * {@inheritDoc}
405 405
 	 * @see \Ajax\common\Widget::show()
406 406
 	 */
407
-	public function show($modelInstance){
408
-		if(\is_array($modelInstance)){
409
-			if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
407
+	public function show($modelInstance) {
408
+		if (\is_array($modelInstance)) {
409
+			if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
410 410
 				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
411 411
 		}
412 412
 		$this->_modelInstance=$modelInstance;
@@ -441,24 +441,24 @@  discard block
 block discarded – undo
441 441
 		return $this;
442 442
 	}
443 443
 
444
-	public function setActiveRowSelector($class="active",$event="click",$multiple=false){
445
-		$this->_self->setActiveRowSelector($class,$event,$multiple);
444
+	public function setActiveRowSelector($class="active", $event="click", $multiple=false) {
445
+		$this->_self->setActiveRowSelector($class, $event, $multiple);
446 446
 		return $this;
447 447
 	}
448 448
 
449
-	public function hideColumn($colIndex){
450
-		if(!\is_array($this->_hiddenColumns))
449
+	public function hideColumn($colIndex) {
450
+		if (!\is_array($this->_hiddenColumns))
451 451
 			$this->_hiddenColumns=[];
452 452
 		$this->_hiddenColumns[]=$colIndex;
453 453
 		return $this;
454 454
 	}
455 455
 
456
-	public function setColWidth($colIndex,$width){
456
+	public function setColWidth($colIndex, $width) {
457 457
 		$this->_colWidths[$colIndex]=$width;
458 458
 		return $this;
459 459
 	}
460 460
 	public function setColWidths($_colWidths) {
461
-		$this->_colWidths = $_colWidths;
461
+		$this->_colWidths=$_colWidths;
462 462
 		return $this;
463 463
 	}
464 464
 }
Please login to merge, or discard this patch.