Completed
Push — master ( c6edab...f99fed )
by Jean-Christophe
03:30
created
Ajax/semantic/widgets/datatable/DataTable.php 3 patches
Doc Comments   +18 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,6 +33,10 @@  discard block
 block discarded – undo
33 33
 	protected $_refreshSelector;
34 34
 
35 35
 
36
+	/**
37
+	 * @param string $identifier
38
+	 * @param string $model
39
+	 */
36 40
 	public function __construct($identifier,$model,$modelInstance=NULL) {
37 41
 		parent::__construct($identifier, $model,$modelInstance);
38 42
 		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
@@ -56,6 +60,9 @@  discard block
 block discarded – undo
56 60
 
57 61
 
58 62
 
63
+	/**
64
+	 * @param string $op
65
+	 */
59 66
 	protected function _generateBehavior($op,$params,JsUtils $js){
60 67
 		if(isset($this->_urls[$op])){
61 68
 			$params=\array_merge($params,["attr"=>"data-ajax"]);
@@ -185,6 +192,9 @@  discard block
 block discarded – undo
185 192
 		return $this;
186 193
 	}
187 194
 
195
+	/**
196
+	 * @param PositionInTable $part
197
+	 */
188 198
 	private function addToolbarRow($part,$table,$captions){
189 199
 		$hasPart=$table->hasPart($part);
190 200
 		if($hasPart){
@@ -224,8 +234,8 @@  discard block
 block discarded – undo
224 234
 	 * Paginates the DataTable element with a Semantic HtmlPaginationMenu component
225 235
 	 * @param number $page the active page number
226 236
 	 * @param number $total_rowcount the total number of items
227
-	 * @param number $items_per_page The number of items per page
228
-	 * @param number $pages_visibles The number of visible pages in the Pagination component
237
+	 * @param integer $items_per_page The number of items per page
238
+	 * @param integer $pages_visibles The number of visible pages in the Pagination component
229 239
 	 * @return DataTable
230 240
 	 */
231 241
 	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=4){
@@ -235,9 +245,9 @@  discard block
 block discarded – undo
235 245
 
236 246
 	/**
237 247
 	 * Auto Paginates the DataTable element with a Semantic HtmlPaginationMenu component
238
-	 * @param number $page the active page number
239
-	 * @param number $items_per_page The number of items per page
240
-	 * @param number $pages_visibles The number of visible pages in the Pagination component
248
+	 * @param integer $page the active page number
249
+	 * @param integer $items_per_page The number of items per page
250
+	 * @param integer $pages_visibles The number of visible pages in the Pagination component
241 251
 	 * @return DataTable
242 252
 	 */
243 253
 	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
@@ -303,6 +313,9 @@  discard block
 block discarded – undo
303 313
 		return $this;
304 314
 	}
305 315
 
316
+	/**
317
+	 * @return string
318
+	 */
306 319
 	public function getRefreshSelector() {
307 320
 		if(isset($this->_refreshSelector))
308 321
 			return $this->_refreshSelector;
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  */
23 23
 class DataTable extends Widget {
24
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait;
24
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait;
25 25
 	protected $_searchField;
26 26
 	protected $_urls;
27 27
 	protected $_pagination;
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
 	protected $_refreshSelector;
34 34
 
35 35
 
36
-	public function __construct($identifier,$model,$modelInstance=NULL) {
37
-		parent::__construct($identifier, $model,$modelInstance);
38
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
36
+	public function __construct($identifier, $model, $modelInstance=NULL) {
37
+		parent::__construct($identifier, $model, $modelInstance);
38
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
39 39
 		$this->_urls=[];
40 40
 	}
41 41
 
42
-	public function run(JsUtils $js){
43
-		if($this->_hasCheckboxes && isset($js)){
42
+	public function run(JsUtils $js) {
43
+		if ($this->_hasCheckboxes && isset($js)) {
44 44
 			$this->_runCheckboxes($js);
45 45
 		}
46
-		if($this->_visibleHover){
47
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
48
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
46
+		if ($this->_visibleHover) {
47
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
48
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
49 49
 		}
50
-		if(\is_array($this->_deleteBehavior))
51
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
52
-		if(\is_array($this->_editBehavior))
53
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
50
+		if (\is_array($this->_deleteBehavior))
51
+			$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
52
+		if (\is_array($this->_editBehavior))
53
+			$this->_generateBehavior("edit", $this->_editBehavior, $js);
54 54
 		return parent::run($js);
55 55
 	}
56 56
 
57 57
 
58 58
 
59
-	protected function _generateBehavior($op,$params,JsUtils $js){
60
-		if(isset($this->_urls[$op])){
61
-			$params=\array_merge($params,["attr"=>"data-ajax"]);
62
-			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params);
59
+	protected function _generateBehavior($op, $params, JsUtils $js) {
60
+		if (isset($this->_urls[$op])) {
61
+			$params=\array_merge($params, ["attr"=>"data-ajax"]);
62
+			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params);
63 63
 		}
64 64
 	}
65 65
 
@@ -72,62 +72,62 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 
75
-	public function compile(JsUtils $js=NULL,&$view=NULL){
76
-		if(!$this->_generated){
75
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
76
+		if (!$this->_generated) {
77 77
 			$this->_instanceViewer->setInstance($this->_model);
78 78
 			$captions=$this->_instanceViewer->getCaptions();
79 79
 
80 80
 			$table=$this->content["table"];
81 81
 
82
-			if($this->_hasCheckboxes){
82
+			if ($this->_hasCheckboxes) {
83 83
 				$this->_generateMainCheckbox($captions);
84 84
 			}
85 85
 
86 86
 			$table->setRowCount(0, \sizeof($captions));
87 87
 			$table->setHeaderValues($captions);
88
-			if(isset($this->_compileParts))
88
+			if (isset($this->_compileParts))
89 89
 				$table->setCompileParts($this->_compileParts);
90 90
 
91
-			if(isset($this->_searchField) && isset($js)){
92
-				if(isset($this->_urls["refresh"]))
93
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
91
+			if (isset($this->_searchField) && isset($js)) {
92
+				if (isset($this->_urls["refresh"]))
93
+					$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
94 94
 			}
95 95
 
96 96
 			$this->_generateContent($table);
97 97
 
98
-			if($this->_hasCheckboxes && $table->hasPart("thead")){
98
+			if ($this->_hasCheckboxes && $table->hasPart("thead")) {
99 99
 					$table->getHeader()->getCell(0, 0)->addClass("no-sort");
100 100
 			}
101 101
 
102
-			if(isset($this->_pagination) && $this->_pagination->getVisible()){
102
+			if (isset($this->_pagination) && $this->_pagination->getVisible()) {
103 103
 				$this->_generatePagination($table);
104 104
 			}
105
-			if(isset($this->_toolbar)){
105
+			if (isset($this->_toolbar)) {
106 106
 				$this->_setToolbarPosition($table, $captions);
107 107
 			}
108
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
108
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
109 109
 			$this->_compileForm();
110 110
 			$this->_generated=true;
111 111
 		}
112
-		return parent::compile($js,$view);
112
+		return parent::compile($js, $view);
113 113
 	}
114 114
 
115 115
 
116 116
 
117
-	protected function _generateContent($table){
117
+	protected function _generateContent($table) {
118 118
 		$objects=$this->_modelInstance;
119
-		if(isset($this->_pagination)){
119
+		if (isset($this->_pagination)) {
120 120
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
121 121
 		}
122 122
 		InstanceViewer::setIndex(0);
123 123
 		$table->fromDatabaseObjects($objects, function($instance) use($table){
124 124
 			$this->_instanceViewer->setInstance($instance);
125 125
 			InstanceViewer::$index++;
126
-			$values= $this->_instanceViewer->getValues();
127
-			if($this->_hasCheckboxes){
128
-				$ck=new HtmlCheckbox("ck-".$this->identifier,"");
126
+			$values=$this->_instanceViewer->getValues();
127
+			if ($this->_hasCheckboxes) {
128
+				$ck=new HtmlCheckbox("ck-".$this->identifier, "");
129 129
 				$field=$ck->getField();
130
-				$field->setProperty("value",$this->_instanceViewer->getIdentifier());
130
+				$field->setProperty("value", $this->_instanceViewer->getIdentifier());
131 131
 				$field->setProperty("name", "selection[]");
132 132
 				\array_unshift($values, $ck);
133 133
 			}
@@ -138,37 +138,37 @@  discard block
 block discarded – undo
138 138
 		});
139 139
 	}
140 140
 
141
-	private function _generatePagination($table){
141
+	private function _generatePagination($table) {
142 142
 		$footer=$table->getFooter();
143 143
 		$footer->mergeCol();
144
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
144
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
145 145
 		$menu->floatRight();
146 146
 		$menu->setActiveItem($this->_pagination->getPage()-1);
147 147
 		$footer->setValues($menu);
148
-		if(isset($this->_urls["refresh"]))
149
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
148
+		if (isset($this->_urls["refresh"]))
149
+			$menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
150 150
 	}
151 151
 
152
-	protected function _getFieldName($index){
152
+	protected function _getFieldName($index) {
153 153
 		return parent::_getFieldName($index)."[]";
154 154
 	}
155 155
 
156
-	protected function _getFieldCaption($index){
156
+	protected function _getFieldCaption($index) {
157 157
 		return null;
158 158
 	}
159 159
 
160
-	protected function _setToolbarPosition($table,$captions=NULL){
161
-		switch ($this->_toolbarPosition){
160
+	protected function _setToolbarPosition($table, $captions=NULL) {
161
+		switch ($this->_toolbarPosition) {
162 162
 			case PositionInTable::BEFORETABLE:
163 163
 			case PositionInTable::AFTERTABLE:
164
-				if(isset($this->_compileParts)===false){
164
+				if (isset($this->_compileParts)===false) {
165 165
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
166 166
 				}
167 167
 				break;
168 168
 			case PositionInTable::HEADER:
169 169
 			case PositionInTable::FOOTER:
170 170
 			case PositionInTable::BODY:
171
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
171
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
172 172
 				break;
173 173
 		}
174 174
 	}
@@ -180,23 +180,23 @@  discard block
 block discarded – undo
180 180
 	 * @param callable $callback function called after the field compilation
181 181
 	 * @return DataTable
182 182
 	 */
183
-	public function afterCompile($index,$callback){
184
-		$this->_instanceViewer->afterCompile($index,$callback);
183
+	public function afterCompile($index, $callback) {
184
+		$this->_instanceViewer->afterCompile($index, $callback);
185 185
 		return $this;
186 186
 	}
187 187
 
188
-	private function addToolbarRow($part,$table,$captions){
188
+	private function addToolbarRow($part, $table, $captions) {
189 189
 		$hasPart=$table->hasPart($part);
190
-		if($hasPart){
190
+		if ($hasPart) {
191 191
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
192
-		}else{
192
+		} else {
193 193
 			$row=$table->getPart($part)->getRow(0);
194 194
 		}
195 195
 		$row->mergeCol();
196 196
 		$row->setValues([$this->_toolbar]);
197 197
 	}
198 198
 
199
-	public function getHtmlComponent(){
199
+	public function getHtmlComponent() {
200 200
 		return $this->content["table"];
201 201
 	}
202 202
 
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
 	 * @return DataTable
211 211
 	 */
212 212
 	public function setUrls($urls) {
213
-		if(\is_array($urls)){
214
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
215
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
216
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
217
-		}else{
218
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
213
+		if (\is_array($urls)) {
214
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
215
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
216
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
217
+		} else {
218
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls];
219 219
 		}
220 220
 		return $this;
221 221
 	}
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
229 229
 	 * @return DataTable
230 230
 	 */
231
-	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=4){
232
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount);
231
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=4) {
232
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
233 233
 		return $this;
234 234
 	}
235 235
 
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
241 241
 	 * @return DataTable
242 242
 	 */
243
-	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
244
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
243
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
244
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
245 245
 		return $this;
246 246
 	}
247 247
 
@@ -251,20 +251,20 @@  discard block
 block discarded – undo
251 251
 	 * @param array $compileParts
252 252
 	 * @return DataTable
253 253
 	 */
254
-	public function refresh($compileParts=["tbody"]){
254
+	public function refresh($compileParts=["tbody"]) {
255 255
 		$this->_compileParts=$compileParts;
256 256
 		return $this;
257 257
 	}
258 258
 
259 259
 
260
-	public function addSearchInToolbar($position=Direction::RIGHT){
260
+	public function addSearchInToolbar($position=Direction::RIGHT) {
261 261
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
262 262
 	}
263 263
 
264
-	public function getSearchField(){
265
-		if(isset($this->_searchField)===false){
266
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
267
-			$this->_searchField->addIcon("search",Direction::RIGHT);
264
+	public function getSearchField() {
265
+		if (isset($this->_searchField)===false) {
266
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
267
+			$this->_searchField->addIcon("search", Direction::RIGHT);
268 268
 		}
269 269
 		return $this->_searchField;
270 270
 	}
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		return $this;
281 281
 	}
282 282
 
283
-	public function asForm(){
283
+	public function asForm() {
284 284
 		return $this->getForm();
285 285
 	}
286 286
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
 	protected function getTargetSelector() {
290 290
 		$result=$this->_targetSelector;
291
-		if(!isset($result))
291
+		if (!isset($result))
292 292
 			$result="#".$this->identifier;
293 293
 		return $result;
294 294
 	}
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	}
305 305
 
306 306
 	public function getRefreshSelector() {
307
-		if(isset($this->_refreshSelector))
307
+		if (isset($this->_refreshSelector))
308 308
 			return $this->_refreshSelector;
309 309
 		return "#".$this->identifier." tbody";
310 310
 	}
Please login to merge, or discard this patch.
Braces   +23 added lines, -16 removed lines patch added patch discarded remove patch
@@ -47,10 +47,12 @@  discard block
 block discarded – undo
47 47
 			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
48 48
 			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
49 49
 		}
50
-		if(\is_array($this->_deleteBehavior))
51
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
52
-		if(\is_array($this->_editBehavior))
53
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
50
+		if(\is_array($this->_deleteBehavior)) {
51
+					$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
52
+		}
53
+		if(\is_array($this->_editBehavior)) {
54
+					$this->_generateBehavior("edit",$this->_editBehavior,$js);
55
+		}
54 56
 		return parent::run($js);
55 57
 	}
56 58
 
@@ -85,12 +87,14 @@  discard block
 block discarded – undo
85 87
 
86 88
 			$table->setRowCount(0, \sizeof($captions));
87 89
 			$table->setHeaderValues($captions);
88
-			if(isset($this->_compileParts))
89
-				$table->setCompileParts($this->_compileParts);
90
+			if(isset($this->_compileParts)) {
91
+							$table->setCompileParts($this->_compileParts);
92
+			}
90 93
 
91 94
 			if(isset($this->_searchField) && isset($js)){
92
-				if(isset($this->_urls["refresh"]))
93
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
95
+				if(isset($this->_urls["refresh"])) {
96
+									$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
97
+				}
94 98
 			}
95 99
 
96 100
 			$this->_generateContent($table);
@@ -145,8 +149,9 @@  discard block
 block discarded – undo
145 149
 		$menu->floatRight();
146 150
 		$menu->setActiveItem($this->_pagination->getPage()-1);
147 151
 		$footer->setValues($menu);
148
-		if(isset($this->_urls["refresh"]))
149
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
152
+		if(isset($this->_urls["refresh"])) {
153
+					$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
154
+		}
150 155
 	}
151 156
 
152 157
 	protected function _getFieldName($index){
@@ -189,7 +194,7 @@  discard block
 block discarded – undo
189 194
 		$hasPart=$table->hasPart($part);
190 195
 		if($hasPart){
191 196
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
192
-		}else{
197
+		} else{
193 198
 			$row=$table->getPart($part)->getRow(0);
194 199
 		}
195 200
 		$row->mergeCol();
@@ -214,7 +219,7 @@  discard block
 block discarded – undo
214 219
 			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
215 220
 			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
216 221
 			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
217
-		}else{
222
+		} else{
218 223
 			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
219 224
 		}
220 225
 		return $this;
@@ -288,8 +293,9 @@  discard block
 block discarded – undo
288 293
 
289 294
 	protected function getTargetSelector() {
290 295
 		$result=$this->_targetSelector;
291
-		if(!isset($result))
292
-			$result="#".$this->identifier;
296
+		if(!isset($result)) {
297
+					$result="#".$this->identifier;
298
+		}
293 299
 		return $result;
294 300
 	}
295 301
 
@@ -304,8 +310,9 @@  discard block
 block discarded – undo
304 310
 	}
305 311
 
306 312
 	public function getRefreshSelector() {
307
-		if(isset($this->_refreshSelector))
308
-			return $this->_refreshSelector;
313
+		if(isset($this->_refreshSelector)) {
314
+					return $this->_refreshSelector;
315
+		}
309 316
 		return "#".$this->identifier." tbody";
310 317
 	}
311 318
 
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/Pagination.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	private $pages_visibles;
10 10
 	private $row_count;
11 11
 
12
-	public function __construct($items_per_page=10,$pages_visibles=4,$page=1,$row_count=null){
12
+	public function __construct($items_per_page=10, $pages_visibles=4, $page=1, $row_count=null) {
13 13
 		$this->items_per_page=$items_per_page;
14 14
 		$this->row_count=$row_count;
15 15
 		$this->page=$page;
@@ -17,29 +17,29 @@  discard block
 block discarded – undo
17 17
 		$this->visible=true;
18 18
 	}
19 19
 
20
-	public function getObjects($objects){
20
+	public function getObjects($objects) {
21 21
 		$auto=(!isset($this->row_count));
22 22
 		$os=$objects;
23
-		if(!\is_array($os)){
23
+		if (!\is_array($os)) {
24 24
 			$os=[];
25
-			foreach ($objects as $o){
25
+			foreach ($objects as $o) {
26 26
 				$os[]=$o;
27 27
 			}
28 28
 		}
29
-		$this->page_count = 0;
30
-		$row_count=($auto)?\sizeof($os):$this->row_count;
31
-		if (0 === $row_count) {
29
+		$this->page_count=0;
30
+		$row_count=($auto) ? \sizeof($os) : $this->row_count;
31
+		if (0===$row_count) {
32 32
 			$this->visible=false;
33 33
 		} else {
34 34
 			$this->visible=true;
35
-			$this->page_count = (int)ceil($row_count / $this->items_per_page);
36
-			if($this->page > $this->page_count+1) {
37
-				$this->page = 1;
35
+			$this->page_count=(int)ceil($row_count/$this->items_per_page);
36
+			if ($this->page>$this->page_count+1) {
37
+				$this->page=1;
38 38
 			}
39 39
 		}
40
-		if($auto){
41
-			$offset = ($this->page - 1) * $this->items_per_page;
42
-			return array_slice($os, $offset,$this->items_per_page);
40
+		if ($auto) {
41
+			$offset=($this->page-1)*$this->items_per_page;
42
+			return array_slice($os, $offset, $this->items_per_page);
43 43
 		}
44 44
 		return $os;
45 45
 	}
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
 		return $this->page_count;
76 76
 	}
77 77
 
78
-	public function getPagesNumbers(){
79
-		$middle= (int)ceil(($this->pages_visibles-1)/ 2);
78
+	public function getPagesNumbers() {
79
+		$middle=(int)ceil(($this->pages_visibles-1)/2);
80 80
 		$first=$this->page-$middle;
81
-		if($first<1){
81
+		if ($first<1) {
82 82
 			$first=1;
83 83
 		}
84 84
 		$last=$first+$this->pages_visibles-1;
85
-		if($last>$this->page_count){
85
+		if ($last>$this->page_count) {
86 86
 			$last=$this->page_count;
87 87
 		}
88 88
 		return \range($first, $last);
Please login to merge, or discard this patch.