Completed
Push — master ( 772d83...24138a )
by Jean-Christophe
10:15
created
Ajax/semantic/widgets/datatable/DataTable.php 2 patches
Doc Comments   +23 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,6 +34,10 @@  discard block
 block discarded – undo
34 34
 	protected $_visibleHover=false;
35 35
 	protected $_targetSelector;
36 36
 
37
+	/**
38
+	 * @param string $identifier
39
+	 * @param string $model
40
+	 */
37 41
 	public function __construct($identifier,$model,$modelInstance=NULL) {
38 42
 		parent::__construct($identifier, $model,$modelInstance);
39 43
 		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
@@ -58,6 +62,9 @@  discard block
 block discarded – undo
58 62
 		return parent::run($js);
59 63
 	}
60 64
 
65
+	/**
66
+	 * @param string $op
67
+	 */
61 68
 	protected function _generateBehavior($op,JsUtils $js){
62 69
 		if(isset($this->_urls[$op]))
63 70
 			$js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]);
@@ -190,6 +197,9 @@  discard block
 block discarded – undo
190 197
 		return $this;
191 198
 	}
192 199
 
200
+	/**
201
+	 * @param PositionInTable $part
202
+	 */
193 203
 	private function addToolbarRow($part,$table,$captions){
194 204
 		$hasPart=$table->hasPart($part);
195 205
 		if($hasPart){
@@ -246,7 +256,7 @@  discard block
 block discarded – undo
246 256
 	 * @param string $caption
247 257
 	 * @param callable $callback
248 258
 	 * @param boolean $visibleHover
249
-	 * @return callable
259
+	 * @return \Closure
250 260
 	 */
251 261
 	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
252 262
 		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
@@ -256,7 +266,7 @@  discard block
 block discarded – undo
256 266
 	 * @param callable $thisCallback
257 267
 	 * @param array $parameters
258 268
 	 * @param callable $callback
259
-	 * @return callable
269
+	 * @return \Closure
260 270
 	 */
261 271
 	private function getCallable($thisCallback,$parameters,$callback=null){
262 272
 		$result=function($instance) use($thisCallback,$parameters,$callback){
@@ -325,11 +335,19 @@  discard block
 block discarded – undo
325 335
 		return $this;
326 336
 	}
327 337
 
338
+	/**
339
+	 * @param string $icon
340
+	 * @param string $class
341
+	 */
328 342
 	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
329 343
 		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
330 344
 		return $this;
331 345
 	}
332 346
 
347
+	/**
348
+	 * @param string $icon
349
+	 * @param string $class
350
+	 */
333 351
 	private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){
334 352
 		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
335 353
 		return $this;
@@ -416,6 +434,9 @@  discard block
 block discarded – undo
416 434
 		}, $index,$attributes);
417 435
 	}
418 436
 
437
+	/**
438
+	 * @param HtmlButton $element
439
+	 */
419 440
 	protected function _visibleOver($element){
420 441
 		$this->_visibleHover=true;
421 442
 		return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;");
Please login to merge, or discard this patch.
Braces   +32 added lines, -22 removed lines patch added patch discarded remove patch
@@ -51,16 +51,19 @@  discard block
 block discarded – undo
51 51
 			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
52 52
 			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
53 53
 		}
54
-		if($this->_hasDelete)
55
-			$this->_generateBehavior("delete", $js);
56
-		if($this->_hasEdit)
57
-			$this->_generateBehavior("edit", $js);
54
+		if($this->_hasDelete) {
55
+					$this->_generateBehavior("delete", $js);
56
+		}
57
+		if($this->_hasEdit) {
58
+					$this->_generateBehavior("edit", $js);
59
+		}
58 60
 		return parent::run($js);
59 61
 	}
60 62
 
61 63
 	protected function _generateBehavior($op,JsUtils $js){
62
-		if(isset($this->_urls[$op]))
63
-			$js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]);
64
+		if(isset($this->_urls[$op])) {
65
+					$js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]);
66
+		}
64 67
 	}
65 68
 
66 69
 	/**
@@ -85,12 +88,14 @@  discard block
 block discarded – undo
85 88
 
86 89
 			$table->setRowCount(0, \sizeof($captions));
87 90
 			$table->setHeaderValues($captions);
88
-			if(isset($this->_compileParts))
89
-				$table->setCompileParts($this->_compileParts);
91
+			if(isset($this->_compileParts)) {
92
+							$table->setCompileParts($this->_compileParts);
93
+			}
90 94
 
91 95
 			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"]);
96
+				if(isset($this->_urls["refresh"])) {
97
+									$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
98
+				}
94 99
 			}
95 100
 
96 101
 			$this->_generateContent($table);
@@ -150,8 +155,9 @@  discard block
 block discarded – undo
150 155
 		$menu->floatRight();
151 156
 		$menu->setActiveItem($this->_pagination->getPage()-1);
152 157
 		$footer->setValues($menu);
153
-		if(isset($this->_urls["refresh"]))
154
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
158
+		if(isset($this->_urls["refresh"])) {
159
+					$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
160
+		}
155 161
 	}
156 162
 
157 163
 	protected function _getFieldName($index){
@@ -194,7 +200,7 @@  discard block
 block discarded – undo
194 200
 		$hasPart=$table->hasPart($part);
195 201
 		if($hasPart){
196 202
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
197
-		}else{
203
+		} else{
198 204
 			$row=$table->getPart($part)->getRow(0);
199 205
 		}
200 206
 		$row->mergeCol();
@@ -219,7 +225,7 @@  discard block
 block discarded – undo
219 225
 			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
220 226
 			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
221 227
 			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
222
-		}else{
228
+		} else{
223 229
 			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
224 230
 		}
225 231
 		return $this;
@@ -284,8 +290,9 @@  discard block
 block discarded – undo
284 290
 	 */
285 291
 	private function getFieldButton($caption,$visibleHover=true){
286 292
 		$bt= new HtmlButton("",$caption);
287
-		if($visibleHover)
288
-			$this->_visibleOver($bt);
293
+		if($visibleHover) {
294
+					$this->_visibleOver($bt);
295
+		}
289 296
 		return $bt;
290 297
 	}
291 298
 
@@ -338,8 +345,9 @@  discard block
 block discarded – undo
338 345
 	private function getDefaultButton($icon,$class=null,$visibleHover=true){
339 346
 		$bt=$this->getFieldButton("",$visibleHover);
340 347
 		$bt->asIcon($icon);
341
-		if(isset($class))
342
-			$bt->addToProperty("class", $class);
348
+		if(isset($class)) {
349
+					$bt->addToProperty("class", $class);
350
+		}
343 351
 		return $bt;
344 352
 	}
345 353
 
@@ -410,8 +418,9 @@  discard block
 block discarded – undo
410 418
 		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){
411 419
 			$button=new HtmlButton($id,$value,$cssStyle);
412 420
 			$button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]);
413
-			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
414
-				$this->_visibleOver($button);
421
+			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) {
422
+							$this->_visibleOver($button);
423
+			}
415 424
 			return $button;
416 425
 		}, $index,$attributes);
417 426
 	}
@@ -423,8 +432,9 @@  discard block
 block discarded – undo
423 432
 
424 433
 	protected function getTargetSelector() {
425 434
 		$result=$this->_targetSelector;
426
-		if(!isset($result))
427
-			$result="#".$this->identifier;
435
+		if(!isset($result)) {
436
+					$result="#".$this->identifier;
437
+		}
428 438
 		return $result;
429 439
 	}
430 440
 
Please login to merge, or discard this patch.