Completed
Push — master ( baf19c...6831db )
by Jean-Christophe
03:30
created
Ajax/semantic/widgets/datatable/DataTable.php 2 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -36,6 +36,10 @@  discard block
 block discarded – undo
36 36
 	protected $_targetSelector;
37 37
 	protected $_checkedMessage;
38 38
 
39
+	/**
40
+	 * @param string $identifier
41
+	 * @param string $model
42
+	 */
39 43
 	public function __construct($identifier,$model,$modelInstance=NULL) {
40 44
 		parent::__construct($identifier, $model,$modelInstance);
41 45
 		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
@@ -75,6 +79,9 @@  discard block
 block discarded – undo
75 79
 				if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');};".$checkedMessageCall);
76 80
 	}
77 81
 
82
+	/**
83
+	 * @param string $op
84
+	 */
78 85
 	protected function _generateBehavior($op,JsUtils $js){
79 86
 		if(isset($this->_urls[$op]))
80 87
 			$js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]);
@@ -210,6 +217,9 @@  discard block
 block discarded – undo
210 217
 		return $this;
211 218
 	}
212 219
 
220
+	/**
221
+	 * @param PositionInTable $part
222
+	 */
213 223
 	private function addToolbarRow($part,$table,$captions){
214 224
 		$hasPart=$table->hasPart($part);
215 225
 		if($hasPart){
Please login to merge, or discard this patch.
Braces   +29 added lines, -20 removed lines patch added patch discarded remove patch
@@ -50,10 +50,12 @@  discard block
 block discarded – undo
50 50
 			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
51 51
 			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
52 52
 		}
53
-		if($this->_hasDelete)
54
-			$this->_generateBehavior("delete", $js);
55
-		if($this->_hasEdit)
56
-			$this->_generateBehavior("edit", $js);
53
+		if($this->_hasDelete) {
54
+					$this->_generateBehavior("delete", $js);
55
+		}
56
+		if($this->_hasEdit) {
57
+					$this->_generateBehavior("edit", $js);
58
+		}
57 59
 		return parent::run($js);
58 60
 	}
59 61
 
@@ -76,8 +78,9 @@  discard block
 block discarded – undo
76 78
 	}
77 79
 
78 80
 	protected function _generateBehavior($op,JsUtils $js){
79
-		if(isset($this->_urls[$op]))
80
-			$js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]);
81
+		if(isset($this->_urls[$op])) {
82
+					$js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]);
83
+		}
81 84
 	}
82 85
 
83 86
 	/**
@@ -102,12 +105,14 @@  discard block
 block discarded – undo
102 105
 
103 106
 			$table->setRowCount(0, \sizeof($captions));
104 107
 			$table->setHeaderValues($captions);
105
-			if(isset($this->_compileParts))
106
-				$table->setCompileParts($this->_compileParts);
108
+			if(isset($this->_compileParts)) {
109
+							$table->setCompileParts($this->_compileParts);
110
+			}
107 111
 
108 112
 			if(isset($this->_searchField) && isset($js)){
109
-				if(isset($this->_urls["refresh"]))
110
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
113
+				if(isset($this->_urls["refresh"])) {
114
+									$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
115
+				}
111 116
 			}
112 117
 
113 118
 			$this->_generateContent($table);
@@ -132,8 +137,9 @@  discard block
 block discarded – undo
132 137
 	private function _generateMainCheckbox(&$captions){
133 138
 		$ck=new HtmlCheckbox("main-ck-".$this->identifier,"");
134 139
 		$checkedMessageCall="";
135
-		if($this->_hasCheckedMessage)
136
-			$checkedMessageCall="updateChecked();";
140
+		if($this->_hasCheckedMessage) {
141
+					$checkedMessageCall="updateChecked();";
142
+		}
137 143
 		$ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);".$checkedMessageCall);
138 144
 		$ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);".$checkedMessageCall);
139 145
 		\array_unshift($captions, $ck);
@@ -170,8 +176,9 @@  discard block
 block discarded – undo
170 176
 		$menu->floatRight();
171 177
 		$menu->setActiveItem($this->_pagination->getPage()-1);
172 178
 		$footer->setValues($menu);
173
-		if(isset($this->_urls["refresh"]))
174
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
179
+		if(isset($this->_urls["refresh"])) {
180
+					$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
181
+		}
175 182
 	}
176 183
 
177 184
 	protected function _getFieldName($index){
@@ -214,7 +221,7 @@  discard block
 block discarded – undo
214 221
 		$hasPart=$table->hasPart($part);
215 222
 		if($hasPart){
216 223
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
217
-		}else{
224
+		} else{
218 225
 			$row=$table->getPart($part)->getRow(0);
219 226
 		}
220 227
 		$row->mergeCol();
@@ -239,7 +246,7 @@  discard block
 block discarded – undo
239 246
 			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
240 247
 			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
241 248
 			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
242
-		}else{
249
+		} else{
243 250
 			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
244 251
 		}
245 252
 		return $this;
@@ -295,8 +302,9 @@  discard block
 block discarded – undo
295 302
 
296 303
 	protected function getTargetSelector() {
297 304
 		$result=$this->_targetSelector;
298
-		if(!isset($result))
299
-			$result="#".$this->identifier;
305
+		if(!isset($result)) {
306
+					$result="#".$this->identifier;
307
+		}
300 308
 		return $result;
301 309
 	}
302 310
 
@@ -334,8 +342,9 @@  discard block
 block discarded – undo
334 342
 	 * @param callable $callback
335 343
 	 */
336 344
 	public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){
337
-		if(isset($checkedMessage))
338
-			$this->_checkedMessage=$checkedMessage;
345
+		if(isset($checkedMessage)) {
346
+					$this->_checkedMessage=$checkedMessage;
347
+		}
339 348
 		$checkedMessage=$this->getCheckedMessage();
340 349
 		$this->_hasCheckboxes=true;
341 350
 		$this->_hasCheckedMessage=true;
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php 2 patches
Doc Comments   +29 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,14 +12,27 @@  discard block
 block discarded – undo
12 12
  * @property InstanceViewer $_instanceViewer
13 13
  */
14 14
 trait DataTableFieldAsTrait{
15
+
16
+	/**
17
+	 * @param \Closure $field
18
+	 */
15 19
 	abstract public function addField($field);
20
+
21
+	/**
22
+	 * @param integer $index
23
+	 * @param \Closure $field
24
+	 */
16 25
 	abstract public function insertField($index,$field);
26
+
27
+	/**
28
+	 * @param \Closure $field
29
+	 */
17 30
 	abstract public function insertInField($index,$field);
18 31
 	/**
19 32
 	 * @param string $caption
20 33
 	 * @param callable $callback
21 34
 	 * @param boolean $visibleHover
22
-	 * @return callable
35
+	 * @return \Closure
23 36
 	 */
24 37
 	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
25 38
 		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
@@ -29,7 +42,7 @@  discard block
 block discarded – undo
29 42
 	 * @param callable $thisCallback
30 43
 	 * @param array $parameters
31 44
 	 * @param callable $callback
32
-	 * @return callable
45
+	 * @return \Closure
33 46
 	 */
34 47
 	private function getCallable($thisCallback,$parameters,$callback=null){
35 48
 		$result=function($instance) use($thisCallback,$parameters,$callback){
@@ -81,6 +94,9 @@  discard block
 block discarded – undo
81 94
 		}, $index,$attributes);
82 95
 	}
83 96
 
97
+	/**
98
+	 * @param HtmlButton $element
99
+	 */
84 100
 	protected function _visibleOver($element){
85 101
 		$this->_visibleHover=true;
86 102
 		return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;");
@@ -91,7 +107,7 @@  discard block
 block discarded – undo
91 107
 	 * @param string $caption
92 108
 	 * @param callable $callback
93 109
 	 * @param boolean $visibleHover
94
-	 * @return \Ajax\semantic\widgets\datatable\DataTable
110
+	 * @return DataTableFieldAsTrait
95 111
 	 */
96 112
 	public function addFieldButton($caption,$visibleHover=true,$callback=null){
97 113
 		$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
@@ -103,7 +119,7 @@  discard block
 block discarded – undo
103 119
 	 * @param int $index
104 120
 	 * @param string $caption
105 121
 	 * @param callable $callback
106
-	 * @return \Ajax\semantic\widgets\datatable\DataTable
122
+	 * @return DataTableFieldAsTrait
107 123
 	 */
108 124
 	public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){
109 125
 		$this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
@@ -115,18 +131,26 @@  discard block
 block discarded – undo
115 131
 	 * @param int $index
116 132
 	 * @param string $caption
117 133
 	 * @param callable $callback
118
-	 * @return \Ajax\semantic\widgets\datatable\DataTable
134
+	 * @return DataTableFieldAsTrait
119 135
 	 */
120 136
 	public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){
121 137
 		$this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
122 138
 		return $this;
123 139
 	}
124 140
 
141
+	/**
142
+	 * @param string $icon
143
+	 * @param string $class
144
+	 */
125 145
 	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
126 146
 		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
127 147
 		return $this;
128 148
 	}
129 149
 
150
+	/**
151
+	 * @param string $icon
152
+	 * @param string $class
153
+	 */
130 154
 	private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){
131 155
 		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
132 156
 		return $this;
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,8 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	private function getFieldButton($caption,$visibleHover=true){
59 59
 		$bt= new HtmlButton("",$caption);
60
-		if($visibleHover)
61
-			$this->_visibleOver($bt);
60
+		if($visibleHover) {
61
+					$this->_visibleOver($bt);
62
+		}
62 63
 			return $bt;
63 64
 	}
64 65
 
@@ -75,8 +76,9 @@  discard block
 block discarded – undo
75 76
 		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){
76 77
 			$button=new HtmlButton($id,$value,$cssStyle);
77 78
 			$button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]);
78
-			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
79
-				$this->_visibleOver($button);
79
+			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) {
80
+							$this->_visibleOver($button);
81
+			}
80 82
 				return $button;
81 83
 		}, $index,$attributes);
82 84
 	}
@@ -135,8 +137,9 @@  discard block
 block discarded – undo
135 137
 	private function getDefaultButton($icon,$class=null,$visibleHover=true){
136 138
 		$bt=$this->getFieldButton("",$visibleHover);
137 139
 		$bt->asIcon($icon);
138
-		if(isset($class))
139
-			$bt->addClass($class);
140
+		if(isset($class)) {
141
+					$bt->addClass($class);
142
+		}
140 143
 			return $bt;
141 144
 	}
142 145
 
Please login to merge, or discard this patch.