Completed
Push — master ( f99fed...57dceb )
by Jean-Christophe
03:29
created
Ajax/semantic/html/content/table/HtmlTR.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -18,6 +18,9 @@  discard block
 block discarded – undo
18 18
 	private $_container;
19 19
 	private $_row;
20 20
 
21
+	/**
22
+	 * @param string $identifier
23
+	 */
21 24
 	public function __construct($identifier) {
22 25
 		parent::__construct($identifier, "tr", "");
23 26
 		$this->_states=[ State::ACTIVE,State::POSITIVE,State::NEGATIVE,State::WARNING,State::ERROR,State::DISABLED ];
@@ -78,6 +81,7 @@  discard block
 block discarded – undo
78 81
 	/**
79 82
 	 * Sets or adds values to the row cols
80 83
 	 * @param mixed $values
84
+	 * @param \Closure $callback
81 85
 	 */
82 86
 	protected function _addOrSetValues($values,$callback) {
83 87
 		$count=$this->count();
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 
21 21
 	public function __construct($identifier) {
22 22
 		parent::__construct($identifier, "tr", "");
23
-		$this->_states=[ State::ACTIVE,State::POSITIVE,State::NEGATIVE,State::WARNING,State::ERROR,State::DISABLED ];
23
+		$this->_states=[State::ACTIVE, State::POSITIVE, State::NEGATIVE, State::WARNING, State::ERROR, State::DISABLED];
24 24
 	}
25 25
 
26 26
 	public function setColCount($colCount) {
27 27
 		$count=$this->count();
28
-		for($i=$count; $i < $colCount; $i++) {
28
+		for ($i=$count; $i<$colCount; $i++) {
29 29
 			$item=$this->addItem(NULL);
30 30
 			$item->setTagName($this->_tdTagName);
31 31
 		}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @param mixed $values
65 65
 	 */
66 66
 	public function setValues($values=array()) {
67
-		return $this->_addOrSetValues($values, function(&$cell,$value){$cell->setValue($value);});
67
+		return $this->_addOrSetValues($values, function(&$cell, $value) {$cell->setValue($value); });
68 68
 	}
69 69
 
70 70
 	/**
@@ -72,27 +72,27 @@  discard block
 block discarded – undo
72 72
 	 * @param mixed $values
73 73
 	 */
74 74
 	public function addValues($values=array()) {
75
-		return $this->_addOrSetValues($values, function(&$cell,$value){$cell->addValue($value);});
75
+		return $this->_addOrSetValues($values, function(&$cell, $value) {$cell->addValue($value); });
76 76
 	}
77 77
 
78 78
 	/**
79 79
 	 * Sets or adds values to the row cols
80 80
 	 * @param mixed $values
81 81
 	 */
82
-	protected function _addOrSetValues($values,$callback) {
82
+	protected function _addOrSetValues($values, $callback) {
83 83
 		$count=$this->count();
84 84
 		if (!\is_array($values)) {
85 85
 			$values=\array_fill(0, $count, $values);
86 86
 		} else {
87
-			if (JArray::isAssociative($values) === true) {
87
+			if (JArray::isAssociative($values)===true) {
88 88
 				$values=\array_values($values);
89 89
 			}
90 90
 		}
91 91
 		$count=\min(\sizeof($values), $count);
92 92
 
93
-		for($i=0; $i < $count; $i++) {
93
+		for ($i=0; $i<$count; $i++) {
94 94
 			$cell=$this->content[$i];
95
-			$callback($cell,$values[$i]);
95
+			$callback($cell, $values[$i]);
96 96
 		}
97 97
 		return $this;
98 98
 	}
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
 	public function getColPosition($colIndex) {
119 119
 		$pos=0;
120 120
 		$rows=$this->_container->getContent();
121
-		for($i=0; $i < $this->_row; $i++) {
121
+		for ($i=0; $i<$this->_row; $i++) {
122 122
 			$max=\min($colIndex, $rows[$i]->count());
123
-			for($j=0; $j < $max; $j++) {
123
+			for ($j=0; $j<$max; $j++) {
124 124
 				$rowspan=$rows[$i]->getItem($j)->getRowspan();
125
-				if ($rowspan + $i > $this->_row)
125
+				if ($rowspan+$i>$this->_row)
126 126
 					$pos++;
127 127
 			}
128 128
 		}
129
-		if ($pos > $colIndex)
129
+		if ($pos>$colIndex)
130 130
 			return NULL;
131 131
 		$count=$this->count();
132
-		for($i=0; $i < $count; $i++) {
132
+		for ($i=0; $i<$count; $i++) {
133 133
 			$pos+=$this->content[$i]->getColspan();
134
-			if ($pos >= $colIndex + 1)
134
+			if ($pos>=$colIndex+1)
135 135
 				return $i;
136 136
 		}
137 137
 		return null;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 	public function conditionalCellFormat($callback, $format) {
141 141
 		$cells=$this->content;
142
-		foreach ( $cells as $cell ) {
142
+		foreach ($cells as $cell) {
143 143
 			$cell->conditionalCellFormat($callback, $format);
144 144
 		}
145 145
 		return $this;
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 
155 155
 	public function containsStr($needle) {
156 156
 		$cells=$this->content;
157
-		foreach ( $cells as $cell ) {
158
-			if (\strpos($cell->getContent(), $needle) !== false)
157
+		foreach ($cells as $cell) {
158
+			if (\strpos($cell->getContent(), $needle)!==false)
159 159
 				return true;
160 160
 		}
161 161
 		return false;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
 	public function applyCells($callback) {
170 170
 		$cells=$this->content;
171
-		foreach ( $cells as $cell ) {
171
+		foreach ($cells as $cell) {
172 172
 			$cell->apply($callback);
173 173
 		}
174 174
 		return $this;
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 3 patches
Doc Comments   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,6 +63,9 @@  discard block
 block discarded – undo
63 63
 
64 64
 
65 65
 
66
+	/**
67
+	 * @param string $op
68
+	 */
66 69
 	protected function _generateBehavior($op,$params,JsUtils $js){
67 70
 		if(isset($this->_urls[$op])){
68 71
 			$params=\array_merge($params,["attr"=>"data-ajax"]);
@@ -139,6 +142,9 @@  discard block
 block discarded – undo
139 142
 		}
140 143
 	}
141 144
 
145
+	/**
146
+	 * @param string $checkedClass
147
+	 */
142 148
 	protected function _generateRow($instance,&$table,$checkedClass=null){
143 149
 		$this->_instanceViewer->setInstance($instance);
144 150
 		InstanceViewer::$index++;
@@ -215,6 +221,9 @@  discard block
 block discarded – undo
215 221
 		return $this;
216 222
 	}
217 223
 
224
+	/**
225
+	 * @param PositionInTable $part
226
+	 */
218 227
 	private function addToolbarRow($part,$table,$captions){
219 228
 		$hasPart=$table->hasPart($part);
220 229
 		if($hasPart){
@@ -254,7 +263,7 @@  discard block
 block discarded – undo
254 263
 	 * Paginates the DataTable element with a Semantic HtmlPaginationMenu component
255 264
 	 * @param number $page the active page number
256 265
 	 * @param number $total_rowcount the total number of items
257
-	 * @param number $items_per_page The number of items per page
266
+	 * @param integer $items_per_page The number of items per page
258 267
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
259 268
 	 * @return DataTable
260 269
 	 */
@@ -265,9 +274,9 @@  discard block
 block discarded – undo
265 274
 
266 275
 	/**
267 276
 	 * Auto Paginates the DataTable element with a Semantic HtmlPaginationMenu component
268
-	 * @param number $page the active page number
269
-	 * @param number $items_per_page The number of items per page
270
-	 * @param number $pages_visibles The number of visible pages in the Pagination component
277
+	 * @param integer $page the active page number
278
+	 * @param integer $items_per_page The number of items per page
279
+	 * @param integer $pages_visibles The number of visible pages in the Pagination component
271 280
 	 * @return DataTable
272 281
 	 */
273 282
 	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
@@ -333,6 +342,9 @@  discard block
 block discarded – undo
333 342
 		return $this;
334 343
 	}
335 344
 
345
+	/**
346
+	 * @return string
347
+	 */
336 348
 	public function getRefreshSelector() {
337 349
 		if(isset($this->_refreshSelector))
338 350
 			return $this->_refreshSelector;
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *
24 24
  */
25 25
 class DataTable extends Widget {
26
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait;
26
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait;
27 27
 	protected $_searchField;
28 28
 	protected $_urls;
29 29
 	protected $_pagination;
@@ -38,35 +38,35 @@  discard block
 block discarded – undo
38 38
 	protected $_rowClass="";
39 39
 
40 40
 
41
-	public function __construct($identifier,$model,$modelInstance=NULL) {
42
-		parent::__construct($identifier, $model,$modelInstance);
43
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
41
+	public function __construct($identifier, $model, $modelInstance=NULL) {
42
+		parent::__construct($identifier, $model, $modelInstance);
43
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
44 44
 		$this->_urls=[];
45
-		$this->_emptyMessage=new HtmlMessage("","nothing to display");
45
+		$this->_emptyMessage=new HtmlMessage("", "nothing to display");
46 46
 		$this->_emptyMessage->setIcon("info circle");
47 47
 	}
48 48
 
49
-	public function run(JsUtils $js){
50
-		if($this->_hasCheckboxes && isset($js)){
49
+	public function run(JsUtils $js) {
50
+		if ($this->_hasCheckboxes && isset($js)) {
51 51
 			$this->_runCheckboxes($js);
52 52
 		}
53
-		if($this->_visibleHover){
54
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
55
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
53
+		if ($this->_visibleHover) {
54
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
55
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
56 56
 		}
57
-		if(\is_array($this->_deleteBehavior))
58
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
59
-		if(\is_array($this->_editBehavior))
60
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
57
+		if (\is_array($this->_deleteBehavior))
58
+			$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
59
+		if (\is_array($this->_editBehavior))
60
+			$this->_generateBehavior("edit", $this->_editBehavior, $js);
61 61
 		return parent::run($js);
62 62
 	}
63 63
 
64 64
 
65 65
 
66
-	protected function _generateBehavior($op,$params,JsUtils $js){
67
-		if(isset($this->_urls[$op])){
68
-			$params=\array_merge($params,["attr"=>"data-ajax"]);
69
-			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params);
66
+	protected function _generateBehavior($op, $params, JsUtils $js) {
67
+		if (isset($this->_urls[$op])) {
68
+			$params=\array_merge($params, ["attr"=>"data-ajax"]);
69
+			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params);
70 70
 		}
71 71
 	}
72 72
 
@@ -79,126 +79,126 @@  discard block
 block discarded – undo
79 79
 	}
80 80
 
81 81
 
82
-	public function compile(JsUtils $js=NULL,&$view=NULL){
83
-		if(!$this->_generated){
82
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
83
+		if (!$this->_generated) {
84 84
 			$this->_instanceViewer->setInstance($this->_model);
85 85
 			$captions=$this->_instanceViewer->getCaptions();
86 86
 
87 87
 			$table=$this->content["table"];
88 88
 
89
-			if($this->_hasCheckboxes){
89
+			if ($this->_hasCheckboxes) {
90 90
 				$this->_generateMainCheckbox($captions);
91 91
 			}
92 92
 
93 93
 			$table->setRowCount(0, \sizeof($captions));
94 94
 			$table->setHeaderValues($captions);
95
-			if(isset($this->_compileParts))
95
+			if (isset($this->_compileParts))
96 96
 				$table->setCompileParts($this->_compileParts);
97 97
 
98
-			if(isset($this->_searchField) && isset($js)){
99
-				if(isset($this->_urls["refresh"]))
100
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
98
+			if (isset($this->_searchField) && isset($js)) {
99
+				if (isset($this->_urls["refresh"]))
100
+					$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
101 101
 			}
102 102
 
103 103
 			$this->_generateContent($table);
104 104
 
105
-			if($this->_hasCheckboxes && $table->hasPart("thead")){
105
+			if ($this->_hasCheckboxes && $table->hasPart("thead")) {
106 106
 					$table->getHeader()->getCell(0, 0)->addClass("no-sort");
107 107
 			}
108 108
 
109
-			if(isset($this->_toolbar)){
109
+			if (isset($this->_toolbar)) {
110 110
 				$this->_setToolbarPosition($table, $captions);
111 111
 			}
112
-			if(isset($this->_pagination) && $this->_pagination->getVisible()){
113
-				$this->_generatePagination($table,$js);
112
+			if (isset($this->_pagination) && $this->_pagination->getVisible()) {
113
+				$this->_generatePagination($table, $js);
114 114
 			}
115 115
 
116
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
116
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
117 117
 			$this->_compileForm();
118 118
 
119 119
 			$this->_generated=true;
120 120
 		}
121
-		return parent::compile($js,$view);
121
+		return parent::compile($js, $view);
122 122
 	}
123 123
 
124 124
 
125 125
 
126
-	protected function _generateContent($table){
126
+	protected function _generateContent($table) {
127 127
 		$objects=$this->_modelInstance;
128
-		if(isset($this->_pagination)){
128
+		if (isset($this->_pagination)) {
129 129
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
130 130
 		}
131 131
 			InstanceViewer::setIndex(0);
132 132
 			$table->fromDatabaseObjects($objects, function($instance) use($table){
133 133
 				return $this->_generateRow($instance, $table);
134 134
 			});
135
-		if($table->getRowCount()==0){
135
+		if ($table->getRowCount()==0) {
136 136
 			$result=$table->addRow();
137 137
 			$result->mergeRow();
138 138
 			$result->setValues([$this->_emptyMessage]);
139 139
 		}
140 140
 	}
141 141
 
142
-	protected function _generateRow($instance,&$table,$checkedClass=null){
142
+	protected function _generateRow($instance, &$table, $checkedClass=null) {
143 143
 		$this->_instanceViewer->setInstance($instance);
144 144
 		InstanceViewer::$index++;
145
-		$values= $this->_instanceViewer->getValues();
146
-		if($this->_hasCheckboxes){
147
-			$ck=new HtmlCheckbox("ck-".$this->identifier,"");
145
+		$values=$this->_instanceViewer->getValues();
146
+		if ($this->_hasCheckboxes) {
147
+			$ck=new HtmlCheckbox("ck-".$this->identifier, "");
148 148
 			$field=$ck->getField();
149
-			$field->setProperty("value",$this->_instanceViewer->getIdentifier());
149
+			$field->setProperty("value", $this->_instanceViewer->getIdentifier());
150 150
 			$field->setProperty("name", "selection[]");
151
-			if(isset($checkedClass))
151
+			if (isset($checkedClass))
152 152
 				$field->setClass($checkedClass);
153 153
 			\array_unshift($values, $ck);
154 154
 		}
155 155
 		$result=$table->newRow();
156 156
 		$result->setIdentifier($this->identifier."-tr-".$this->_instanceViewer->getIdentifier());
157 157
 		$result->setValues($values);
158
-		$result->addToProperty("class",$this->_rowClass);
158
+		$result->addToProperty("class", $this->_rowClass);
159 159
 		return $result;
160 160
 	}
161 161
 
162
-	protected function _generatePagination($table,$js=NULL){
163
-		if(isset($this->_toolbar)){
164
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
162
+	protected function _generatePagination($table, $js=NULL) {
163
+		if (isset($this->_toolbar)) {
164
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
165 165
 				$this->_toolbar->setFloated("left");
166 166
 		}
167 167
 		$footer=$table->getFooter();
168 168
 		$footer->mergeCol();
169
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
169
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
170 170
 		$menu->floatRight();
171 171
 		$menu->setActiveItem($this->_pagination->getPage()-1);
172 172
 		$footer->addValues($menu);
173
-		$this->_associatePaginationBehavior($menu,$js);
173
+		$this->_associatePaginationBehavior($menu, $js);
174 174
 	}
175 175
 
176
-	protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){
177
-		if(isset($this->_urls["refresh"])){
178
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
176
+	protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) {
177
+		if (isset($this->_urls["refresh"])) {
178
+			$menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
179 179
 		}
180 180
 	}
181 181
 
182
-	protected function _getFieldName($index){
182
+	protected function _getFieldName($index) {
183 183
 		return parent::_getFieldName($index)."[]";
184 184
 	}
185 185
 
186
-	protected function _getFieldCaption($index){
186
+	protected function _getFieldCaption($index) {
187 187
 		return null;
188 188
 	}
189 189
 
190
-	protected function _setToolbarPosition($table,$captions=NULL){
191
-		switch ($this->_toolbarPosition){
190
+	protected function _setToolbarPosition($table, $captions=NULL) {
191
+		switch ($this->_toolbarPosition) {
192 192
 			case PositionInTable::BEFORETABLE:
193 193
 			case PositionInTable::AFTERTABLE:
194
-				if(isset($this->_compileParts)===false){
194
+				if (isset($this->_compileParts)===false) {
195 195
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
196 196
 				}
197 197
 				break;
198 198
 			case PositionInTable::HEADER:
199 199
 			case PositionInTable::FOOTER:
200 200
 			case PositionInTable::BODY:
201
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
201
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
202 202
 				break;
203 203
 		}
204 204
 	}
@@ -210,23 +210,23 @@  discard block
 block discarded – undo
210 210
 	 * @param callable $callback function called after the field compilation
211 211
 	 * @return DataTable
212 212
 	 */
213
-	public function afterCompile($index,$callback){
214
-		$this->_instanceViewer->afterCompile($index,$callback);
213
+	public function afterCompile($index, $callback) {
214
+		$this->_instanceViewer->afterCompile($index, $callback);
215 215
 		return $this;
216 216
 	}
217 217
 
218
-	private function addToolbarRow($part,$table,$captions){
218
+	private function addToolbarRow($part, $table, $captions) {
219 219
 		$hasPart=$table->hasPart($part);
220
-		if($hasPart){
220
+		if ($hasPart) {
221 221
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
222
-		}else{
222
+		} else {
223 223
 			$row=$table->getPart($part)->getRow(0);
224 224
 		}
225 225
 		$row->mergeCol();
226 226
 		$row->setValues([$this->_toolbar]);
227 227
 	}
228 228
 
229
-	public function getHtmlComponent(){
229
+	public function getHtmlComponent() {
230 230
 		return $this->content["table"];
231 231
 	}
232 232
 
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
 	 * @return DataTable
241 241
 	 */
242 242
 	public function setUrls($urls) {
243
-		if(\is_array($urls)){
244
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
245
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
246
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
247
-		}else{
248
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
243
+		if (\is_array($urls)) {
244
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
245
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
246
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
247
+		} else {
248
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls];
249 249
 		}
250 250
 		return $this;
251 251
 	}
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
259 259
 	 * @return DataTable
260 260
 	 */
261
-	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){
262
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount);
261
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
262
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
263 263
 		return $this;
264 264
 	}
265 265
 
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
271 271
 	 * @return DataTable
272 272
 	 */
273
-	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
274
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
273
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
274
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
275 275
 		return $this;
276 276
 	}
277 277
 
@@ -281,20 +281,20 @@  discard block
 block discarded – undo
281 281
 	 * @param array $compileParts
282 282
 	 * @return DataTable
283 283
 	 */
284
-	public function refresh($compileParts=["tbody"]){
284
+	public function refresh($compileParts=["tbody"]) {
285 285
 		$this->_compileParts=$compileParts;
286 286
 		return $this;
287 287
 	}
288 288
 
289 289
 
290
-	public function addSearchInToolbar($position=Direction::RIGHT){
290
+	public function addSearchInToolbar($position=Direction::RIGHT) {
291 291
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
292 292
 	}
293 293
 
294
-	public function getSearchField(){
295
-		if(isset($this->_searchField)===false){
296
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
297
-			$this->_searchField->addIcon("search",Direction::RIGHT);
294
+	public function getSearchField() {
295
+		if (isset($this->_searchField)===false) {
296
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
297
+			$this->_searchField->addIcon("search", Direction::RIGHT);
298 298
 		}
299 299
 		return $this->_searchField;
300 300
 	}
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		return $this;
311 311
 	}
312 312
 
313
-	public function asForm(){
313
+	public function asForm() {
314 314
 		return $this->getForm();
315 315
 	}
316 316
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 
319 319
 	protected function getTargetSelector() {
320 320
 		$result=$this->_targetSelector;
321
-		if(!isset($result))
321
+		if (!isset($result))
322 322
 			$result="#".$this->identifier;
323 323
 		return $result;
324 324
 	}
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	}
335 335
 
336 336
 	public function getRefreshSelector() {
337
-		if(isset($this->_refreshSelector))
337
+		if (isset($this->_refreshSelector))
338 338
 			return $this->_refreshSelector;
339 339
 		return "#".$this->identifier." tbody";
340 340
 	}
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
 		return $this;
345 345
 	}
346 346
 
347
-	public function show($modelInstance){
348
-		if(\is_array($modelInstance)){
349
-			if(\is_array(array_values($modelInstance)[0]))
347
+	public function show($modelInstance) {
348
+		if (\is_array($modelInstance)) {
349
+			if (\is_array(array_values($modelInstance)[0]))
350 350
 				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
351 351
 		}
352 352
 		$this->_modelInstance=$modelInstance;
Please login to merge, or discard this patch.
Braces   +29 added lines, -20 removed lines patch added patch discarded remove patch
@@ -54,10 +54,12 @@  discard block
 block discarded – undo
54 54
 			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
55 55
 			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
56 56
 		}
57
-		if(\is_array($this->_deleteBehavior))
58
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
59
-		if(\is_array($this->_editBehavior))
60
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
57
+		if(\is_array($this->_deleteBehavior)) {
58
+					$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
59
+		}
60
+		if(\is_array($this->_editBehavior)) {
61
+					$this->_generateBehavior("edit",$this->_editBehavior,$js);
62
+		}
61 63
 		return parent::run($js);
62 64
 	}
63 65
 
@@ -92,12 +94,14 @@  discard block
 block discarded – undo
92 94
 
93 95
 			$table->setRowCount(0, \sizeof($captions));
94 96
 			$table->setHeaderValues($captions);
95
-			if(isset($this->_compileParts))
96
-				$table->setCompileParts($this->_compileParts);
97
+			if(isset($this->_compileParts)) {
98
+							$table->setCompileParts($this->_compileParts);
99
+			}
97 100
 
98 101
 			if(isset($this->_searchField) && isset($js)){
99
-				if(isset($this->_urls["refresh"]))
100
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
102
+				if(isset($this->_urls["refresh"])) {
103
+									$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
104
+				}
101 105
 			}
102 106
 
103 107
 			$this->_generateContent($table);
@@ -148,8 +152,9 @@  discard block
 block discarded – undo
148 152
 			$field=$ck->getField();
149 153
 			$field->setProperty("value",$this->_instanceViewer->getIdentifier());
150 154
 			$field->setProperty("name", "selection[]");
151
-			if(isset($checkedClass))
152
-				$field->setClass($checkedClass);
155
+			if(isset($checkedClass)) {
156
+							$field->setClass($checkedClass);
157
+			}
153 158
 			\array_unshift($values, $ck);
154 159
 		}
155 160
 		$result=$table->newRow();
@@ -161,8 +166,9 @@  discard block
 block discarded – undo
161 166
 
162 167
 	protected function _generatePagination($table,$js=NULL){
163 168
 		if(isset($this->_toolbar)){
164
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
165
-				$this->_toolbar->setFloated("left");
169
+			if($this->_toolbarPosition==PositionInTable::FOOTER) {
170
+							$this->_toolbar->setFloated("left");
171
+			}
166 172
 		}
167 173
 		$footer=$table->getFooter();
168 174
 		$footer->mergeCol();
@@ -219,7 +225,7 @@  discard block
 block discarded – undo
219 225
 		$hasPart=$table->hasPart($part);
220 226
 		if($hasPart){
221 227
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
222
-		}else{
228
+		} else{
223 229
 			$row=$table->getPart($part)->getRow(0);
224 230
 		}
225 231
 		$row->mergeCol();
@@ -244,7 +250,7 @@  discard block
 block discarded – undo
244 250
 			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
245 251
 			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
246 252
 			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
247
-		}else{
253
+		} else{
248 254
 			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
249 255
 		}
250 256
 		return $this;
@@ -318,8 +324,9 @@  discard block
 block discarded – undo
318 324
 
319 325
 	protected function getTargetSelector() {
320 326
 		$result=$this->_targetSelector;
321
-		if(!isset($result))
322
-			$result="#".$this->identifier;
327
+		if(!isset($result)) {
328
+					$result="#".$this->identifier;
329
+		}
323 330
 		return $result;
324 331
 	}
325 332
 
@@ -334,8 +341,9 @@  discard block
 block discarded – undo
334 341
 	}
335 342
 
336 343
 	public function getRefreshSelector() {
337
-		if(isset($this->_refreshSelector))
338
-			return $this->_refreshSelector;
344
+		if(isset($this->_refreshSelector)) {
345
+					return $this->_refreshSelector;
346
+		}
339 347
 		return "#".$this->identifier." tbody";
340 348
 	}
341 349
 
@@ -346,8 +354,9 @@  discard block
 block discarded – undo
346 354
 
347 355
 	public function show($modelInstance){
348 356
 		if(\is_array($modelInstance)){
349
-			if(\is_array(array_values($modelInstance)[0]))
350
-				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
357
+			if(\is_array(array_values($modelInstance)[0])) {
358
+							$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
359
+			}
351 360
 		}
352 361
 		$this->_modelInstance=$modelInstance;
353 362
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/HasCheckboxesTrait.php 3 patches
Doc Comments   +8 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,6 +17,10 @@  discard block
 block discarded – undo
17 17
 	protected $_checkedMessage;
18 18
 	protected $_checkedClass;
19 19
 
20
+	/**
21
+	 * @param HtmlLabel $element
22
+	 * @param callable $callback
23
+	 */
20 24
 	abstract public function addInToolbar($element,$callback=NULL);
21 25
 
22 26
 	protected function _runCheckboxes(JsUtils $js){
@@ -67,6 +71,9 @@  discard block
 block discarded – undo
67 71
 			\array_unshift($captions, $ck);
68 72
 	}
69 73
 
74
+	/**
75
+	 * @param string $checked
76
+	 */
70 77
 	protected function _setAllChecked($checked){
71 78
 		$result="$('#".$this->identifier." [name=%quote%selection[]%quote%]:not(._jsonArrayChecked)').prop('checked',".$checked.");";
72 79
 		if(isset($this->_checkedClass)){
@@ -96,7 +103,7 @@  discard block
 block discarded – undo
96 103
 	 * Defines the message displayed when checkboxes are checked or unchecked
97 104
 	 * with an associative array 0=>no selection,1=>one item selected, other=>{count} items selected
98 105
 	 * @param array $_checkedMessage
99
-	 * @return \Ajax\semantic\widgets\datatable\DataTable
106
+	 * @return HasCheckboxesTrait
100 107
 	 */
101 108
 	public function setCheckedMessage(array $_checkedMessage) {
102 109
 		$this->_checkedMessage=$_checkedMessage;
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,29 +11,29 @@  discard block
 block discarded – undo
11 11
  * @property string identifier
12 12
  * @property $_compileParts
13 13
  */
14
-trait HasCheckboxesTrait{
14
+trait HasCheckboxesTrait {
15 15
 	protected $_hasCheckboxes;
16 16
 	protected $_hasCheckedMessage=false;
17 17
 	protected $_checkedMessage;
18 18
 	protected $_checkedClass;
19 19
 
20
-	abstract public function addInToolbar($element,$callback=NULL);
20
+	abstract public function addInToolbar($element, $callback=NULL);
21 21
 
22
-	protected function _runCheckboxes(JsUtils $js){
22
+	protected function _runCheckboxes(JsUtils $js) {
23 23
 		$js->execOn("change", "#".$this->identifier." [name='selection[]']:not(._jsonArrayChecked)", $this->_getCheckedChange($js));
24
-		if(\sizeof($this->_compileParts)<3){
25
-			$js->trigger("#".$this->identifier." [name='selection[]']","change",true);
24
+		if (\sizeof($this->_compileParts)<3) {
25
+			$js->trigger("#".$this->identifier." [name='selection[]']", "change", true);
26 26
 		}
27 27
 	}
28 28
 
29
-	protected function _getCheckedChange(JsUtils $js=NULL){
29
+	protected function _getCheckedChange(JsUtils $js=NULL) {
30 30
 		$callback="var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true;
31 31
 				\$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}});
32 32
 				if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');};".$this->_getCheckedMessageCall($js);
33 33
 		return $callback;
34 34
 	}
35 35
 
36
-	protected function _getCheckedMessageFunction(){
36
+	protected function _getCheckedMessageFunction() {
37 37
 		$msg=$this->getCheckedMessage();
38 38
 		$checkedMessageFunction="$('#{$this->identifier}').bind('updateChecked',function() {var msg='".$msg[0]."',count=\$('#{$this->identifier} [name=\"selection[]\"]:checked').length,all=\$('#{$this->identifier} [name=\"selection[]\"]').length;
39 39
 		if(count==1) msg='".$msg[1]."';
@@ -43,23 +43,23 @@  discard block
 block discarded – undo
43 43
 		return $checkedMessageFunction;
44 44
 	}
45 45
 
46
-	protected function _getCheckedMessageCall(JsUtils $js=NULL){
46
+	protected function _getCheckedMessageCall(JsUtils $js=NULL) {
47 47
 		$checkedMessageCall="";
48
-		if($this->_hasCheckedMessage){
48
+		if ($this->_hasCheckedMessage) {
49 49
 			$checkedMessageCall="$('#{$this->identifier}').trigger('updateChecked');";
50
-			if(isset($this->_checkedClass)){
50
+			if (isset($this->_checkedClass)) {
51 51
 				$checkedMessageCall.="$(this).closest('tr').toggleClass('".$this->_checkedClass."',$(this).prop('checked'));";
52 52
 			}
53
-			if(isset($js))
54
-				$js->exec($this->_getCheckedMessageFunction(),true);
53
+			if (isset($js))
54
+				$js->exec($this->_getCheckedMessageFunction(), true);
55 55
 		}
56 56
 		return $checkedMessageCall;
57 57
 	}
58 58
 
59
-	protected function _generateMainCheckbox(&$captions){
60
-		$ck=new HtmlCheckbox("main-ck-".$this->identifier,"");
59
+	protected function _generateMainCheckbox(&$captions) {
60
+		$ck=new HtmlCheckbox("main-ck-".$this->identifier, "");
61 61
 		$checkedMessageCall="";
62
-		if($this->_hasCheckedMessage)
62
+		if ($this->_hasCheckedMessage)
63 63
 			$checkedMessageCall="$('#{$this->identifier}').trigger('updateChecked');";
64 64
 
65 65
 			$ck->setOnChecked($this->_setAllChecked("true").$checkedMessageCall);
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 			\array_unshift($captions, $ck);
68 68
 	}
69 69
 
70
-	protected function _setAllChecked($checked){
70
+	protected function _setAllChecked($checked) {
71 71
 		$result="$('#".$this->identifier." [name=%quote%selection[]%quote%]:not(._jsonArrayChecked)').prop('checked',".$checked.");";
72
-		if(isset($this->_checkedClass)){
72
+		if (isset($this->_checkedClass)) {
73 73
 			$result.="$('#".$this->identifier." tr').toggleClass('".$this->_checkedClass."',".$checked.");";
74 74
 		}
75 75
 		return $result;
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 
87 87
 	protected function getCheckedMessage() {
88
-		$result= $this->_checkedMessage;
89
-		if(!isset($result)){
90
-			$result=[0=>"none selected",1=>"one item selected","other"=>"{count} items selected"];
88
+		$result=$this->_checkedMessage;
89
+		if (!isset($result)) {
90
+			$result=[0=>"none selected", 1=>"one item selected", "other"=>"{count} items selected"];
91 91
 		}
92 92
 		return $result;
93 93
 	}
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 	 * @param array $checkedMessage
108 108
 	 * @param callable $callback
109 109
 	 */
110
-	public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){
111
-		if(isset($checkedMessage))
110
+	public function addCountCheckedInToolbar(array $checkedMessage=null, $callback=null) {
111
+		if (isset($checkedMessage))
112 112
 			$this->_checkedMessage=$checkedMessage;
113 113
 			$checkedMessage=$this->getCheckedMessage();
114 114
 			$this->_hasCheckboxes=true;
115 115
 			$this->_hasCheckedMessage=true;
116
-			$element=new HtmlLabel("checked-count-".$this->identifier,$checkedMessage[0]);
117
-			$this->addInToolbar($element,$callback);
116
+			$element=new HtmlLabel("checked-count-".$this->identifier, $checkedMessage[0]);
117
+			$this->addInToolbar($element, $callback);
118 118
 	}
119 119
 
120 120
 	public function setCheckedClass($_checkedClass) {
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,8 +50,9 @@  discard block
 block discarded – undo
50 50
 			if(isset($this->_checkedClass)){
51 51
 				$checkedMessageCall.="$(this).closest('tr').toggleClass('".$this->_checkedClass."',$(this).prop('checked'));";
52 52
 			}
53
-			if(isset($js))
54
-				$js->exec($this->_getCheckedMessageFunction(),true);
53
+			if(isset($js)) {
54
+							$js->exec($this->_getCheckedMessageFunction(),true);
55
+			}
55 56
 		}
56 57
 		return $checkedMessageCall;
57 58
 	}
@@ -59,8 +60,9 @@  discard block
 block discarded – undo
59 60
 	protected function _generateMainCheckbox(&$captions){
60 61
 		$ck=new HtmlCheckbox("main-ck-".$this->identifier,"");
61 62
 		$checkedMessageCall="";
62
-		if($this->_hasCheckedMessage)
63
-			$checkedMessageCall="$('#{$this->identifier}').trigger('updateChecked');";
63
+		if($this->_hasCheckedMessage) {
64
+					$checkedMessageCall="$('#{$this->identifier}').trigger('updateChecked');";
65
+		}
64 66
 
65 67
 			$ck->setOnChecked($this->_setAllChecked("true").$checkedMessageCall);
66 68
 			$ck->setOnUnchecked($this->_setAllChecked("false").$checkedMessageCall);
@@ -108,8 +110,9 @@  discard block
 block discarded – undo
108 110
 	 * @param callable $callback
109 111
 	 */
110 112
 	public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){
111
-		if(isset($checkedMessage))
112
-			$this->_checkedMessage=$checkedMessage;
113
+		if(isset($checkedMessage)) {
114
+					$this->_checkedMessage=$checkedMessage;
115
+		}
113 116
 			$checkedMessage=$this->getCheckedMessage();
114 117
 			$this->_hasCheckboxes=true;
115 118
 			$this->_hasCheckedMessage=true;
Please login to merge, or discard this patch.
Ajax/service/JReflection.php 3 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -3,11 +3,18 @@  discard block
 block discarded – undo
3 3
 namespace Ajax\service;
4 4
 
5 5
 class JReflection {
6
+
7
+	/**
8
+	 * @param \Ajax\common\html\HtmlCollection $object
9
+	 */
6 10
 	public static function shortClassName($object){
7 11
 		$classNameWithNamespace = get_class($object);
8 12
 		return substr($classNameWithNamespace, strrpos($classNameWithNamespace, '\\')+1);
9 13
 	}
10 14
 
15
+	/**
16
+	 * @param string $classname
17
+	 */
11 18
 	public static function jsonObject($classname){
12 19
 		$object=new $classname();
13 20
 		$class = new \ReflectionClass($classname);
@@ -27,6 +34,9 @@  discard block
 block discarded – undo
27 34
 		return $object;
28 35
 	}
29 36
 
37
+	/**
38
+	 * @param string $callback
39
+	 */
30 40
 	public static function callMethod($object,$callback,array $values){
31 41
 		return \call_user_func_array([$object,$callback],$values);
32 42
 	}
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,31 +3,31 @@
 block discarded – undo
3 3
 namespace Ajax\service;
4 4
 
5 5
 class JReflection {
6
-	public static function shortClassName($object){
7
-		$classNameWithNamespace = get_class($object);
6
+	public static function shortClassName($object) {
7
+		$classNameWithNamespace=get_class($object);
8 8
 		return substr($classNameWithNamespace, strrpos($classNameWithNamespace, '\\')+1);
9 9
 	}
10 10
 
11
-	public static function jsonObject($classname){
11
+	public static function jsonObject($classname) {
12 12
 		$object=new $classname();
13
-		$class = new \ReflectionClass($classname);
13
+		$class=new \ReflectionClass($classname);
14 14
 		$methods=$class->getMethods(\ReflectionMethod::IS_PUBLIC);
15
-		foreach ($methods as $method){
15
+		foreach ($methods as $method) {
16 16
 			$name=$method->getName();
17
-			if(JString::startswith($name, "set")){
17
+			if (JString::startswith($name, "set")) {
18 18
 				$property=\strtolower(JString::replaceAtFirst($name, "set", ""));
19 19
 				$value="__".$property."__";
20
-				try{
21
-					if($class->getProperty($property)!==null){
22
-						\call_user_func_array([$object,$name],[$value]);
20
+				try {
21
+					if ($class->getProperty($property)!==null) {
22
+						\call_user_func_array([$object, $name], [$value]);
23 23
 					}
24
-				}catch(\Exception $e){}
24
+				}catch (\Exception $e) {}
25 25
 			}
26 26
 		}
27 27
 		return $object;
28 28
 	}
29 29
 
30
-	public static function callMethod($object,$callback,array $values){
31
-		return \call_user_func_array([$object,$callback],$values);
30
+	public static function callMethod($object, $callback, array $values) {
31
+		return \call_user_func_array([$object, $callback], $values);
32 32
 	}
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 					if($class->getProperty($property)!==null){
22 22
 						\call_user_func_array([$object,$name],[$value]);
23 23
 					}
24
-				}catch(\Exception $e){}
24
+				} catch(\Exception $e){}
25 25
 			}
26 26
 		}
27 27
 		return $object;
Please login to merge, or discard this patch.
Ajax/common/Widget.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 use Ajax\semantic\html\modules\HtmlModal;
21 21
 
22 22
 abstract class Widget extends HtmlDoubleElement {
23
-	use FieldAsTrait,FormTrait;
23
+	use FieldAsTrait, FormTrait;
24 24
 
25 25
 	/**
26 26
 	 * @var string classname
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
 	protected $_generated;
54 54
 
55 55
 
56
-	public function __construct($identifier,$model,$modelInstance=NULL) {
56
+	public function __construct($identifier, $model, $modelInstance=NULL) {
57 57
 		parent::__construct($identifier);
58 58
 		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
59 59
 		$this->setModel($model);
60
-		if(isset($modelInstance)){
60
+		if (isset($modelInstance)) {
61 61
 			$this->show($modelInstance);
62 62
 		}
63 63
 		$this->_generated=false;
64 64
 	}
65 65
 
66
-	protected function _init($instanceViewer,$contentKey,$content,$edition){
66
+	protected function _init($instanceViewer, $contentKey, $content, $edition) {
67 67
 		$this->_instanceViewer=$instanceViewer;
68 68
 		$this->content=[$contentKey=>$content];
69 69
 		$this->_toolbarPosition=PositionInTable::BEFORETABLE;
@@ -74,26 +74,26 @@  discard block
 block discarded – undo
74 74
 	 * @param int|string $fieldName
75 75
 	 * @return int|string
76 76
 	 */
77
-	protected function _getIndex($fieldName){
77
+	protected function _getIndex($fieldName) {
78 78
 		return $fieldName;
79 79
 	}
80 80
 
81
-	protected function _getFieldIdentifier($prefix,$name=""){
81
+	protected function _getFieldIdentifier($prefix, $name="") {
82 82
 		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
83 83
 	}
84 84
 
85
-	protected function _getFieldName($index){
85
+	protected function _getFieldName($index) {
86 86
 		return $this->_instanceViewer->getFieldName($index);
87 87
 	}
88 88
 
89
-	protected function _getFieldCaption($index){
89
+	protected function _getFieldCaption($index) {
90 90
 		return $this->_instanceViewer->getCaption($index);
91 91
 	}
92 92
 
93
-	abstract protected  function _setToolbarPosition($table,$captions=NULL);
93
+	abstract protected  function _setToolbarPosition($table, $captions=NULL);
94 94
 
95
-	public function show($modelInstance){
96
-		if(\is_array($modelInstance)){
95
+	public function show($modelInstance) {
96
+		if (\is_array($modelInstance)) {
97 97
 			$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
98 98
 		}
99 99
 		$this->_modelInstance=$modelInstance;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
 	abstract public function getHtmlComponent();
121 121
 
122
-	public function setAttached($value=true){
122
+	public function setAttached($value=true) {
123 123
 		return $this->getHtmlComponent()->setAttached($value);
124 124
 	}
125 125
 
@@ -130,66 +130,66 @@  discard block
 block discarded – undo
130 130
 	 * @param callable $callback function called after the field compilation
131 131
 	 * @return Widget
132 132
 	 */
133
-	public function afterCompile($index,$callback){
133
+	public function afterCompile($index, $callback) {
134 134
 		$index=$this->_getIndex($index);
135 135
 		$this->_instanceViewer->afterCompile($index, $callback);
136 136
 		return $this;
137 137
 	}
138 138
 
139
-	public function setColor($color){
139
+	public function setColor($color) {
140 140
 		return $this->getHtmlComponent()->setColor($color);
141 141
 	}
142 142
 
143 143
 
144
-	public function setCaptions($captions){
144
+	public function setCaptions($captions) {
145 145
 		$this->_instanceViewer->setCaptions($captions);
146 146
 		return $this;
147 147
 	}
148 148
 
149
-	public function setCaption($index,$caption){
149
+	public function setCaption($index, $caption) {
150 150
 		$this->_instanceViewer->setCaption($this->_getIndex($index), $caption);
151 151
 		return $this;
152 152
 	}
153 153
 
154
-	public function setFields($fields){
154
+	public function setFields($fields) {
155 155
 		$this->_instanceViewer->setVisibleProperties($fields);
156 156
 		return $this;
157 157
 	}
158 158
 
159
-	public function addField($field){
159
+	public function addField($field) {
160 160
 		$this->_instanceViewer->addField($field);
161 161
 		return $this;
162 162
 	}
163 163
 
164
-	public function addMessage($attributes=NULL,$fieldName="message"){
164
+	public function addMessage($attributes=NULL, $fieldName="message") {
165 165
 		$this->_instanceViewer->addField($fieldName);
166 166
 		$count=$this->_instanceViewer->visiblePropertiesCount();
167
-		return $this->fieldAsMessage($count-1,$attributes);
167
+		return $this->fieldAsMessage($count-1, $attributes);
168 168
 	}
169 169
 
170
-	public function addErrorMessage(){
171
-		return $this->addMessage(["error"=>true],"message");
170
+	public function addErrorMessage() {
171
+		return $this->addMessage(["error"=>true], "message");
172 172
 	}
173 173
 
174
-	public function insertField($index,$field){
174
+	public function insertField($index, $field) {
175 175
 		$index=$this->_getIndex($index);
176 176
 		$this->_instanceViewer->insertField($index, $field);
177 177
 		return $this;
178 178
 	}
179 179
 
180
-	public function insertInField($index,$field){
180
+	public function insertInField($index, $field) {
181 181
 		$index=$this->_getIndex($index);
182 182
 		$this->_instanceViewer->insertInField($index, $field);
183 183
 		return $this;
184 184
 	}
185 185
 
186
-	public function setValueFunction($index,$callback){
186
+	public function setValueFunction($index, $callback) {
187 187
 		$index=$this->_getIndex($index);
188 188
 		$this->_instanceViewer->setValueFunction($index, $callback);
189 189
 		return $this;
190 190
 	}
191 191
 
192
-	public function setIdentifierFunction($callback){
192
+	public function setIdentifierFunction($callback) {
193 193
 		$this->_instanceViewer->setIdentifierFunction($callback);
194 194
 		return $this;
195 195
 	}
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	/**
198 198
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
199 199
 	 */
200
-	public function getToolbar(){
201
-		if(isset($this->_toolbar)===false){
200
+	public function getToolbar() {
201
+		if (isset($this->_toolbar)===false) {
202 202
 			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
203 203
 		}
204 204
 		return $this->_toolbar;
@@ -210,15 +210,15 @@  discard block
 block discarded – undo
210 210
 	 * @param callable $callback function to call on $element
211 211
 	 * @return \Ajax\common\html\HtmlDoubleElement
212 212
 	 */
213
-	public function addInToolbar($element,$callback=NULL){
213
+	public function addInToolbar($element, $callback=NULL) {
214 214
 		$tb=$this->getToolbar();
215
-		if($element instanceof BaseWidget){
216
-			if($element->getIdentifier()===""){
215
+		if ($element instanceof BaseWidget) {
216
+			if ($element->getIdentifier()==="") {
217 217
 				$element->setIdentifier("tb-item-".$this->identifier."-".$tb->count());
218 218
 			}
219 219
 		}
220
-		if(isset($callback)){
221
-			if(\is_callable($callback)){
220
+		if (isset($callback)) {
221
+			if (\is_callable($callback)) {
222 222
 				$callback($element);
223 223
 			}
224 224
 		}
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 	 * @param callable $callback function($element)
232 232
 	 * @return \Ajax\common\html\HtmlDoubleElement
233 233
 	 */
234
-	public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){
235
-		$result=$this->addInToolbar($caption,$callback);
236
-		if(isset($icon))
234
+	public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) {
235
+		$result=$this->addInToolbar($caption, $callback);
236
+		if (isset($icon))
237 237
 			$result->addIcon($icon);
238 238
 		return $result;
239 239
 	}
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
 	 * @param callable $callback function($element)
244 244
 	 * @return \Ajax\common\Widget
245 245
 	 */
246
-	public function addItemsInToolbar(array $items,$callback=NULL){
247
-		if(JArray::isAssociative($items)){
248
-			foreach ($items as $icon=>$item){
249
-				$this->addItemInToolbar($item,$icon,$callback);
246
+	public function addItemsInToolbar(array $items, $callback=NULL) {
247
+		if (JArray::isAssociative($items)) {
248
+			foreach ($items as $icon=>$item) {
249
+				$this->addItemInToolbar($item, $icon, $callback);
250 250
 			}
251
-		}else{
252
-			foreach ($items as $item){
253
-				$this->addItemInToolbar($item,null,$callback);
251
+		} else {
252
+			foreach ($items as $item) {
253
+				$this->addItemInToolbar($item, null, $callback);
254 254
 			}
255 255
 		}
256 256
 		return $this;
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
 	 * @param callable $callback function($element)
263 263
 	 * @return \Ajax\common\html\HtmlDoubleElement
264 264
 	 */
265
-	public function addDropdownInToolbar($value,$items,$callback=NULL){
265
+	public function addDropdownInToolbar($value, $items, $callback=NULL) {
266 266
 		$dd=$value;
267 267
 		if (\is_string($value)) {
268
-			$dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items);
268
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items);
269 269
 		}
270
-		return $this->addInToolbar($dd,$callback);
270
+		return $this->addInToolbar($dd, $callback);
271 271
 	}
272 272
 
273 273
 	/**
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 	 * @param callable $callback function($element)
277 277
 	 * @return \Ajax\common\html\HtmlDoubleElement
278 278
 	 */
279
-	public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){
280
-		$bt=new HtmlButton("bt-".$caption,$caption,$cssStyle);
281
-		return $this->addInToolbar($bt,$callback);
279
+	public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) {
280
+		$bt=new HtmlButton("bt-".$caption, $caption, $cssStyle);
281
+		return $this->addInToolbar($bt, $callback);
282 282
 	}
283 283
 
284 284
 	/**
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 	 * @param callable $callback function($element)
288 288
 	 * @return \Ajax\common\html\HtmlDoubleElement
289 289
 	 */
290
-	public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){
291
-		$bts=new HtmlButtonGroups("",$captions,$asIcon);
292
-		return $this->addInToolbar($bts,$callback);
290
+	public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) {
291
+		$bts=new HtmlButtonGroups("", $captions, $asIcon);
292
+		return $this->addInToolbar($bts, $callback);
293 293
 	}
294 294
 
295 295
 	/**
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 	 * @param boolean $labeled
300 300
 	 * @return \Ajax\common\html\HtmlDoubleElement
301 301
 	 */
302
-	public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){
303
-		$bt=new HtmlButton("",$caption);
304
-		$bt->addIcon($icon,$before,$labeled);
302
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
303
+		$bt=new HtmlButton("", $caption);
304
+		$bt->addIcon($icon, $before, $labeled);
305 305
 		return $this->addInToolbar($bt);
306 306
 	}
307 307
 
308
-	public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){
309
-		$button=new HtmlButton($identifier,$value,$cssStyle);
310
-		$this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters);
308
+	public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) {
309
+		$button=new HtmlButton($identifier, $value, $cssStyle);
310
+		$this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters);
311 311
 		return $this->addInToolbar($button);
312 312
 	}
313 313
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model
338 338
 	 * @return \Ajax\common\Widget
339 339
 	 */
340
-	public function setDefaultValueFunction($defaultValueFunction){
340
+	public function setDefaultValueFunction($defaultValueFunction) {
341 341
 		$this->_instanceViewer->setDefaultValueFunction($defaultValueFunction);
342 342
 		return $this;
343 343
 	}
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	 * @param string|boolean $disable
347 347
 	 * @return string
348 348
 	 */
349
-	public function jsDisabled($disable=true){
349
+	public function jsDisabled($disable=true) {
350 350
 		return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");";
351 351
 	}
352 352
 
@@ -355,12 +355,12 @@  discard block
 block discarded – undo
355 355
 	 * @param callable $callback function($element)
356 356
 	 * @return \Ajax\common\html\HtmlDoubleElement
357 357
 	 */
358
-	public function addEditButtonInToolbar($caption,$callback=NULL){
359
-		$bt=new HtmlButton($this->identifier."-editBtn",$caption);
358
+	public function addEditButtonInToolbar($caption, $callback=NULL) {
359
+		$bt=new HtmlButton($this->identifier."-editBtn", $caption);
360 360
 		$bt->setToggle();
361 361
 		$bt->setActive($this->_edition);
362 362
 		$bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')")));
363
-		return $this->addInToolbar($bt,$callback);
363
+		return $this->addInToolbar($bt, $callback);
364 364
 	}
365 365
 
366 366
 	public function setToolbar(HtmlMenu $_toolbar) {
@@ -374,35 +374,35 @@  discard block
 block discarded – undo
374 374
 	}
375 375
 
376 376
 	public function getForm() {
377
-		if(!isset($this->_form)){
377
+		if (!isset($this->_form)) {
378 378
 			$this->_form=new HtmlForm("frm-".$this->identifier);
379 379
 			$this->setEdition(true);
380 380
 		}
381 381
 		return $this->_form;
382 382
 	}
383 383
 
384
-	public function run(JsUtils $js){
384
+	public function run(JsUtils $js) {
385 385
 		$result=parent::run($js);
386
-		if(isset($this->_form)){
386
+		if (isset($this->_form)) {
387 387
 			$result=$this->runForm($js);
388 388
 		}
389 389
 		return $result;
390 390
 	}
391 391
 
392
-	protected function runForm(JsUtils $js){
392
+	protected function runForm(JsUtils $js) {
393 393
 		$fields=$this->getContentInstances(HtmlFormField::class);
394
-		foreach ($fields as $field){
394
+		foreach ($fields as $field) {
395 395
 			$this->_form->addField($field);
396 396
 		}
397 397
 		return $this->_form->run($js);
398 398
 	}
399 399
 
400
-	protected function _compileForm(){
401
-		if(isset($this->_form)){
400
+	protected function _compileForm() {
401
+		if (isset($this->_form)) {
402 402
 			$noValidate="";
403
-			if(\sizeof($this->_form->getValidationParams())>0)
403
+			if (\sizeof($this->_form->getValidationParams())>0)
404 404
 				$noValidate="novalidate";
405
-			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>");
405
+			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>");
406 406
 		}
407 407
 	}
408 408
 
@@ -411,26 +411,26 @@  discard block
 block discarded – undo
411 411
 		return $this;
412 412
 	}
413 413
 
414
-	public function moveFieldTo($from,$to){
414
+	public function moveFieldTo($from, $to) {
415 415
 		return $this->_instanceViewer->moveFieldTo($from, $to);
416 416
 	}
417 417
 
418
-	public function swapFields($index1,$index2){
418
+	public function swapFields($index1, $index2) {
419 419
 		$index1=$this->_getIndex($index1);
420 420
 		$index2=$this->_getIndex($index2);
421 421
 		return $this->_instanceViewer->swapFields($index1, $index2);
422 422
 	}
423 423
 
424
-	public function removeField($index){
424
+	public function removeField($index) {
425 425
 		$index=$this->_getIndex($index);
426 426
 		$this->_instanceViewer->removeField($index);
427 427
 		return $this;
428 428
 	}
429 429
 
430
-	public function asModal($header){
431
-		$modal=new HtmlModal("modal-".$this->identifier,$header);
430
+	public function asModal($header) {
431
+		$modal=new HtmlModal("modal-".$this->identifier, $header);
432 432
 		$modal->setContent($this);
433
-		if(isset($this->_form)){
433
+		if (isset($this->_form)) {
434 434
 			$this->_form->onSuccess($modal->jsHide());
435 435
 		}
436 436
 		return $modal;
Please login to merge, or discard this patch.
Ajax/common/traits/JqueryAjaxTrait.php 2 patches
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	protected $ajaxTransition;
18 18
 	protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>';
19 19
 
20
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
20
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
21 21
 	protected function addLoading(&$retour, $responseElement) {
22 22
 		$loading_notifier='<div class="ajax-loader">';
23 23
 		if ($this->ajaxLoader=='') {
@@ -30,66 +30,66 @@  discard block
 block discarded – undo
30 30
 		$retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n";
31 31
 	}
32 32
 
33
-	public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
34
-		return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly);
33
+	public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
34
+		return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly);
35 35
 	}
36
-	public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
37
-		return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly);
36
+	public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
37
+		return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly);
38 38
 	}
39 39
 
40
-	protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
41
-		if(JString::isNull($params)){$params="{}";}
40
+	protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
41
+		if (JString::isNull($params)) {$params="{}"; }
42 42
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
43 43
 		$retour=$this->_getAjaxUrl($url, $attr);
44 44
 		$responseElement=$this->_getResponseElement($responseElement);
45 45
 		$retour.="var self=this;\n";
46
-		if($hasLoader===true){
46
+		if ($hasLoader===true) {
47 47
 			$this->addLoading($retour, $responseElement);
48 48
 		}
49 49
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
50
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
50
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
51 51
 		if ($immediatly)
52 52
 			$this->jquery_code_for_compile[]=$retour;
53 53
 		return $retour;
54 54
 	}
55 55
 
56
-	protected function setAjaxDataCall($params){
56
+	protected function setAjaxDataCall($params) {
57 57
 		$result=null;
58
-		if(!\is_callable($params)){
59
-			$result=function ($responseElement,$jqueryDone="html") use($params){
60
-				return AjaxTransition::{$params}($responseElement,$jqueryDone);
58
+		if (!\is_callable($params)) {
59
+			$result=function($responseElement, $jqueryDone="html") use($params){
60
+				return AjaxTransition::{$params}($responseElement, $jqueryDone);
61 61
 			};
62 62
 		}
63 63
 		return $result;
64 64
 	}
65 65
 
66
-	protected function _getAjaxUrl($url,$attr){
66
+	protected function _getAjaxUrl($url, $attr) {
67 67
 		$url=$this->_correctAjaxUrl($url);
68 68
 		$retour="url='".$url."';";
69 69
 		$slash="/";
70
-		if(JString::endswith($url, "/")===true)
70
+		if (JString::endswith($url, "/")===true)
71 71
 			$slash="";
72
-		if(JString::isNotNull($attr)){
72
+		if (JString::isNotNull($attr)) {
73 73
 			if ($attr==="value")
74 74
 				$retour.="url=url+'".$slash."'+$(this).val();\n";
75 75
 			elseif ($attr==="html")
76 76
 			$retour.="url=url+'".$slash."'+$(this).html();\n";
77
-			elseif($attr!=null && $attr!=="")
77
+			elseif ($attr!=null && $attr!=="")
78 78
 					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
79 79
 		}
80 80
 		return $retour;
81 81
 	}
82 82
 
83
-	protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){
84
-		$retour="";$call=null;
83
+	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) {
84
+		$retour=""; $call=null;
85 85
 		if ($responseElement!=="") {
86
-			if(isset($ajaxTransition)){
86
+			if (isset($ajaxTransition)) {
87 87
 				$call=$this->setAjaxDataCall($ajaxTransition);
88
-			}elseif(isset($this->ajaxTransition)){
88
+			}elseif (isset($this->ajaxTransition)) {
89 89
 				$call=$this->ajaxTransition;
90 90
 			}
91
-			if(\is_callable($call))
92
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
91
+			if (\is_callable($call))
92
+				$retour="\t".$call($responseElement, $jqueryDone).";\n";
93 93
 			else
94 94
 				$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
95 95
 		}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		return $retour;
98 98
 	}
99 99
 
100
-	protected function _getResponseElement($responseElement){
100
+	protected function _getResponseElement($responseElement) {
101 101
 		if ($responseElement!=="") {
102 102
 			$responseElement=Javascript::prep_value($responseElement);
103 103
 		}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	protected function _correctAjaxUrl($url) {
108 108
 		if ($url!=="/" && JString::endsWith($url, "/")===true)
109 109
 			$url=substr($url, 0, strlen($url)-1);
110
-		if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
110
+		if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
111 111
 			$url=$this->jsUtils->getUrl($url);
112 112
 		}
113 113
 		return $url;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @param string $jsCallback javascript code to execute after the request
122 122
 	 * @param boolean $immediatly
123 123
 	 */
124
-	public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) {
124
+	public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) {
125 125
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
126 126
 		$retour=$this->_getAjaxUrl($url, $attr);
127 127
 		$retour.="$.{$method}(url,".$params.").done(function( data ) {\n";
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @param string $url the request address
143 143
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
144 144
 	 */
145
-	public function _jsonOn($event,$element, $url,$parameters=array()) {
145
+	public function _jsonOn($event, $element, $url, $parameters=array()) {
146 146
 		$preventDefault=true;
147 147
 		$stopPropagation=true;
148 148
 		$jsCallback=null;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		$params="{}";
153 153
 		$immediatly=true;
154 154
 		extract($parameters);
155
-		return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly);
155
+		return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
156 156
 	}
157 157
 
158 158
 	/**
@@ -164,22 +164,22 @@  discard block
 block discarded – undo
164 164
 	 * @param string $context jquery DOM element, array container.
165 165
 	 * @param boolean $immediatly
166 166
 	 */
167
-	public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) {
167
+	public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) {
168 168
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
169 169
 		$retour=$this->_getAjaxUrl($url, $attr);
170
-		if($context===null){
170
+		if ($context===null) {
171 171
 			$parent="$('".$maskSelector."').parent()";
172
-			$newElm = "$('#'+newId)";
173
-		}else{
172
+			$newElm="$('#'+newId)";
173
+		} else {
174 174
 			$parent=$context;
175
-			$newElm = $context.".find('#'+newId)";
175
+			$newElm=$context.".find('#'+newId)";
176 176
 		}
177 177
 		$appendTo="\t\tnewElm.appendTo(".$parent.");\n";
178 178
 		$retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n";
179 179
 		$retour.=$parent.".find('._json').remove();";
180 180
 		$retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();
181 181
 				newElm.attr('id',newId);\n;newElm.addClass('_json').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n";
182
-		$retour.= $appendTo;
182
+		$retour.=$appendTo;
183 183
 		$retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n";
184 184
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
185 185
 		$retour.="\t".$jsCallback."\n"."});\n";
@@ -194,30 +194,30 @@  discard block
 block discarded – undo
194 194
 	 * @param string $url the request address
195 195
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null)
196 196
 	 */
197
-	public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) {
197
+	public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) {
198 198
 		$preventDefault=true;
199 199
 		$stopPropagation=true;
200 200
 		$jsCallback=null;
201 201
 		$attr="id";
202 202
 		$method="get";
203
-		$context = null;
203
+		$context=null;
204 204
 		$params="{}";
205 205
 		$immediatly=true;
206 206
 		extract($parameters);
207
-		return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly);
207
+		return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
208 208
 	}
209 209
 
210
-	public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
210
+	public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
211 211
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
212 212
 		$retour=$this->_getAjaxUrl($url, $attr);
213 213
 		$retour.="\nvar params=$('#".$form."').serialize();\n";
214 214
 		$responseElement=$this->_getResponseElement($responseElement);
215 215
 		$retour.="var self=this;\n";
216
-		if($hasLoader===true){
216
+		if ($hasLoader===true) {
217 217
 			$this->addLoading($retour, $responseElement);
218 218
 		}
219 219
 		$retour.="$.post(url,params).done(function( data ) {\n";
220
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
220
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
221 221
 
222 222
 		if ($validation) {
223 223
 			$retour="$('#".$form."').validate({submitHandler: function(form) {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * @param string $responseElement
241 241
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null,"jqueryDone"=>"html")
242 242
 	 */
243
-	public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) {
243
+	public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
244 244
 		$preventDefault=true;
245 245
 		$stopPropagation=true;
246 246
 		$jsCallback=null;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		$jqueryDone="html";
251 251
 		$ajaxTransition=null;
252 252
 		extract($parameters);
253
-		return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
253
+		return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
254 254
 	}
255 255
 
256 256
 	/**
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @param string $responseElement
264 264
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null)
265 265
 	 */
266
-	public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) {
266
+	public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
267 267
 		$preventDefault=true;
268 268
 		$stopPropagation=true;
269 269
 		$jsCallback=null;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		$jqueryDone="html";
274 274
 		$ajaxTransition=null;
275 275
 		extract($parameters);
276
-		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
276
+		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
277 277
 	}
278 278
 
279 279
 	/**
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * @param string $responseElement
287 287
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null,"immediatly"=>true)
288 288
 	 */
289
-	public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) {
289
+	public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
290 290
 		$preventDefault=true;
291 291
 		$stopPropagation=true;
292 292
 		$validation=false;
@@ -297,6 +297,6 @@  discard block
 block discarded – undo
297 297
 		$jqueryDone="html";
298 298
 		$ajaxTransition=null;
299 299
 		extract($parameters);
300
-		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
300
+		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
301 301
 	}
302 302
 }
303 303
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 		}
49 49
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
50 50
 		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
51
-		if ($immediatly)
52
-			$this->jquery_code_for_compile[]=$retour;
51
+		if ($immediatly) {
52
+					$this->jquery_code_for_compile[]=$retour;
53
+		}
53 54
 		return $retour;
54 55
 	}
55 56
 
@@ -67,15 +68,17 @@  discard block
 block discarded – undo
67 68
 		$url=$this->_correctAjaxUrl($url);
68 69
 		$retour="url='".$url."';";
69 70
 		$slash="/";
70
-		if(JString::endswith($url, "/")===true)
71
-			$slash="";
71
+		if(JString::endswith($url, "/")===true) {
72
+					$slash="";
73
+		}
72 74
 		if(JString::isNotNull($attr)){
73
-			if ($attr==="value")
74
-				$retour.="url=url+'".$slash."'+$(this).val();\n";
75
-			elseif ($attr==="html")
76
-			$retour.="url=url+'".$slash."'+$(this).html();\n";
77
-			elseif($attr!=null && $attr!=="")
78
-					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
75
+			if ($attr==="value") {
76
+							$retour.="url=url+'".$slash."'+$(this).val();\n";
77
+			} elseif ($attr==="html") {
78
+						$retour.="url=url+'".$slash."'+$(this).html();\n";
79
+			} elseif($attr!=null && $attr!=="") {
80
+								$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
81
+			}
79 82
 		}
80 83
 		return $retour;
81 84
 	}
@@ -85,13 +88,14 @@  discard block
 block discarded – undo
85 88
 		if ($responseElement!=="") {
86 89
 			if(isset($ajaxTransition)){
87 90
 				$call=$this->setAjaxDataCall($ajaxTransition);
88
-			}elseif(isset($this->ajaxTransition)){
91
+			} elseif(isset($this->ajaxTransition)){
89 92
 				$call=$this->ajaxTransition;
90 93
 			}
91
-			if(\is_callable($call))
92
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
93
-			else
94
-				$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
94
+			if(\is_callable($call)) {
95
+							$retour="\t".$call($responseElement,$jqueryDone).";\n";
96
+			} else {
97
+							$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
98
+			}
95 99
 		}
96 100
 		$retour.="\t".$jsCallback."\n";
97 101
 		return $retour;
@@ -105,8 +109,9 @@  discard block
 block discarded – undo
105 109
 	}
106 110
 
107 111
 	protected function _correctAjaxUrl($url) {
108
-		if ($url!=="/" && JString::endsWith($url, "/")===true)
109
-			$url=substr($url, 0, strlen($url)-1);
112
+		if ($url!=="/" && JString::endsWith($url, "/")===true) {
113
+					$url=substr($url, 0, strlen($url)-1);
114
+		}
110 115
 		if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
111 116
 			$url=$this->jsUtils->getUrl($url);
112 117
 		}
@@ -130,8 +135,9 @@  discard block
 block discarded – undo
130 135
 				$retour.="\t".$jsCallback."\n".
131 136
 						"\t$(document).trigger('jsonReady',[data]);\n".
132 137
 						"});\n";
133
-				if ($immediatly)
134
-					$this->jquery_code_for_compile[]=$retour;
138
+				if ($immediatly) {
139
+									$this->jquery_code_for_compile[]=$retour;
140
+				}
135 141
 					return $retour;
136 142
 	}
137 143
 
@@ -170,7 +176,7 @@  discard block
 block discarded – undo
170 176
 		if($context===null){
171 177
 			$parent="$('".$maskSelector."').parent()";
172 178
 			$newElm = "$('#'+newId)";
173
-		}else{
179
+		} else{
174 180
 			$parent=$context;
175 181
 			$newElm = $context.".find('#'+newId)";
176 182
 		}
@@ -183,8 +189,9 @@  discard block
 block discarded – undo
183 189
 		$retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n";
184 190
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
185 191
 		$retour.="\t".$jsCallback."\n"."});\n";
186
-		if ($immediatly)
187
-			$this->jquery_code_for_compile[]=$retour;
192
+		if ($immediatly) {
193
+					$this->jquery_code_for_compile[]=$retour;
194
+		}
188 195
 			return $retour;
189 196
 	}
190 197
 	/**
@@ -225,8 +232,9 @@  discard block
 block discarded – undo
225 232
 			}});\n";
226 233
 			$retour.="$('#".$form."').submit();\n";
227 234
 		}
228
-		if ($immediatly)
229
-			$this->jquery_code_for_compile[]=$retour;
235
+		if ($immediatly) {
236
+					$this->jquery_code_for_compile[]=$retour;
237
+		}
230 238
 			return $retour;
231 239
 	}
232 240
 
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsAjaxTrait.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
26 26
 	 * @param string|callable $ajaxTransition
27 27
 	 */
28
-	public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
29
-		return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
28
+	public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
29
+		return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
30 30
 	}
31 31
 
32 32
 	/**
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	 * @param string $jsCallback javascript code to execute after the request
38 38
 	 * @param boolean $immediatly
39 39
 	 */
40
-	public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) {
41
-		return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context,$immediatly);
40
+	public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) {
41
+		return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context, $immediatly);
42 42
 	}
43 43
 
44 44
 	/**
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 * @param string $url the request address
49 49
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
50 50
 	 */
51
-	public function jsonOn($event,$element, $url,$parameters=array()) {
52
-		return $this->js->_jsonOn($event, $element, $url,$parameters);
51
+	public function jsonOn($event, $element, $url, $parameters=array()) {
52
+		return $this->js->_jsonOn($event, $element, $url, $parameters);
53 53
 	}
54 54
 
55 55
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @param string $jsCallback javascript code to execute after the request
72 72
 	 */
73 73
 	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) {
74
-		return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback,"id", NULL,true);
74
+		return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, "id", NULL, true);
75 75
 	}
76 76
 
77 77
 	/**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param string $jsCallback javascript code to execute after the request
84 84
 	 */
85 85
 	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) {
86
-		return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback,"id", NULL, false);
86
+		return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, "id", NULL, false);
87 87
 	}
88 88
 
89 89
 	/**
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 	 * @param string $url the request url
94 94
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
95 95
 	 */
96
-	public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) {
97
-		return $this->js->_jsonArrayOn($event,$element,$maskSelector, $url, $parameters);
96
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) {
97
+		return $this->js->_jsonArrayOn($event, $element, $maskSelector, $url, $parameters);
98 98
 	}
99 99
 
100 100
 	/**
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
109 109
 	 * @param string|callable $ajaxTransition
110 110
 	 */
111
-	public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) {
112
-		return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false,$jqueryDone,$ajaxTransition);
111
+	public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) {
112
+		return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition);
113 113
 	}
114 114
 
115 115
 	/**
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
149 149
 	 * @param string|callable $ajaxTransition
150 150
 	 */
151
-	public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
152
-		return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
151
+	public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
152
+		return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
153 153
 	}
154 154
 
155 155
 	/**
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
165 165
 	 * @param string|callable $ajaxTransition
166 166
 	 */
167
-	public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
168
-		return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false);
167
+	public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
168
+		return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false);
169 169
 	}
170 170
 
171 171
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null)
180 180
 	 */
181 181
 	public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
182
-		return $this->js->_postOn($event, $element,  $url, $params, $responseElement, $parameters);
182
+		return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters);
183 183
 	}
184 184
 
185 185
 	/**
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
206 206
 	 * @param string|callable $ajaxTransition
207 207
 	 */
208
-	public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
209
-		return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
208
+	public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
209
+		return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
210 210
 	}
211 211
 
212 212
 	/**
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
222 222
 	 * @param string|callable $ajaxTransition
223 223
 	 */
224
-	public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
225
-		return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false);
224
+	public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
225
+		return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false);
226 226
 	}
227 227
 
228 228
 	/**
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null)
237 237
 	 */
238 238
 	public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
239
-		return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters);
239
+		return $this->js->_postFormOn($event, $element, $url, $form, $responseElement, $parameters);
240 240
 	}
241 241
 
242 242
 	/**
Please login to merge, or discard this patch.
Ajax/service/AjaxCall.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@
 block discarded – undo
34 34
 		if ($stopPropagation===true) {
35 35
 			$result.=Javascript::$stopPropagation;
36 36
 		}
37
-		switch($this->method) {
37
+		switch ($this->method) {
38 38
 			case "get":
39
-				$result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr,$jqueryDone,$ajaxTransition);
39
+				$result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr, $jqueryDone, $ajaxTransition);
40 40
 				break;
41 41
 			case "post":
42
-				$result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition);
42
+				$result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition);
43 43
 				break;
44 44
 			case "postForm":
45
-				$result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition);
45
+				$result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition);
46 46
 				break;
47 47
 			case "json":
48
-				$result.=$js->jsonDeferred($url,$method,$params,$jsCallback);
48
+				$result.=$js->jsonDeferred($url, $method, $params, $jsCallback);
49 49
 				break;
50 50
 			case "jsonArray":
51
-				$result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback);
51
+				$result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback);
52 52
 				break;
53 53
 		}
54 54
 		return $result;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function compile(JsUtils $js=null) {
17
-		if ($js==null)
18
-			return;
17
+		if ($js==null) {
18
+					return;
19
+		}
19 20
 		$result="";
20 21
 		$params="{}";
21 22
 		$jsCallback=NULL;
Please login to merge, or discard this patch.
Ajax/Jquery.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
  * @license Apache 2 http://www.apache.org/licenses/
16 16
  **/
17 17
 class Jquery {
18
-	use JqueryEventsTrait,JqueryAjaxTrait,JqueryActionsTrait;
18
+	use JqueryEventsTrait, JqueryAjaxTrait, JqueryActionsTrait;
19 19
 	protected $_ui;
20 20
 	protected $_bootstrap;
21 21
 	protected $_semantic;
22
-	protected $jquery_code_for_compile=array ();
22
+	protected $jquery_code_for_compile=array();
23 23
 	protected $jsUtils;
24 24
 	protected $params;
25 25
 
26
-	protected $jquery_events=array (
27
-			"bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload"
26
+	protected $jquery_events=array(
27
+			"bind", "blur", "change", "click", "dblclick", "delegate", "die", "error", "focus", "focusin", "focusout", "hover", "keydown", "keypress", "keyup", "live", "load", "mousedown", "mousseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "off", "on", "one", "ready", "resize", "scroll", "select", "submit", "toggle", "trigger", "triggerHandler", "undind", "undelegate", "unload"
28 28
 	);
29 29
 
30 30
 	public function ui($ui=NULL) {
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 		return $this->_semantic;
49 49
 	}
50 50
 
51
-	public function __construct($params,$jsUtils) {
51
+	public function __construct($params, $jsUtils) {
52 52
 		$this->params=array();
53
-		foreach ( $params as $key => $val ) {
53
+		foreach ($params as $key => $val) {
54 54
 				$this->params[$key]=$params[$key];
55 55
 		}
56 56
 		$this->jsUtils=$jsUtils;
57
-		if(isset($params["ajaxTransition"]))
57
+		if (isset($params["ajaxTransition"]))
58 58
 			$this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]);
59 59
 	}
60 60
 
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function _output($array_js='') {
118 118
 		if (!is_array($array_js)) {
119
-			$array_js=array (
119
+			$array_js=array(
120 120
 					$array_js
121 121
 			);
122 122
 		}
123 123
 
124
-		foreach ( $array_js as $js ) {
124
+		foreach ($array_js as $js) {
125 125
 			$this->jquery_code_for_compile[]="\t$js\n";
126 126
 		}
127 127
 	}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @param string $param
134 134
 	 * @param boolean $immediatly delayed if false
135 135
 	 */
136
-	public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) {
136
+	public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) {
137 137
 		$element=Javascript::prep_element($element);
138 138
 		if (isset($param)) {
139 139
 			$param=Javascript::prep_value($param);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @param boolean $immediatly delayed if false
153 153
 	 * @return string
154 154
 	 */
155
-	public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) {
155
+	public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) {
156 156
 		$to=Javascript::prep_element($to);
157 157
 		$element=Javascript::prep_element($element);
158 158
 		$str="$({$to}).{$jQueryCall}({$element});";
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	public function sortable($element, $options=array()) {
172 172
 		if (count($options)>0) {
173
-			$sort_options=array ();
174
-			foreach ( $options as $k => $v ) {
173
+			$sort_options=array();
174
+			foreach ($options as $k => $v) {
175 175
 				$sort_options[]="\n\t\t".$k.': '.$v."";
176 176
 			}
177 177
 			$sort_options=implode(",", $sort_options);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.
204 204
 	 * @return string
205 205
 	 */
206
-	public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) {
206
+	public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) {
207 207
 		if (\is_array($js)) {
208 208
 			$js=implode("\n\t\t", $js);
209 209
 		}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n";
218 218
 		else
219 219
 			$event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n";
220
-		if($immediatly)
220
+		if ($immediatly)
221 221
 			$this->jquery_code_for_compile[]=$event;
222 222
 		return $event;
223 223
 	}
@@ -243,40 +243,40 @@  discard block
 block discarded – undo
243 243
 		$script='$(document).ready(function() {'."\n";
244 244
 		$script.=implode('', $this->jquery_code_for_compile);
245 245
 		$script.='})';
246
-		if($this->params["defer"]){
246
+		if ($this->params["defer"]) {
247 247
 			$script=$this->defer($script);
248 248
 		}
249 249
 		$script.=";";
250 250
 		$this->jquery_code_for_compile=array();
251
-		if($this->params["debug"]===false){
251
+		if ($this->params["debug"]===false) {
252 252
 			$script=$this->minify($script);
253 253
 		}
254 254
 		$output=($script_tags===FALSE) ? $script : $this->inline($script);
255 255
 
256
-		if ($view!==NULL){
257
-			$this->jsUtils->createScriptVariable($view,$view_var, $output);
256
+		if ($view!==NULL) {
257
+			$this->jsUtils->createScriptVariable($view, $view_var, $output);
258 258
 		}
259 259
 		return $output;
260 260
 	}
261 261
 
262
-	public function getScript($offset=0){
262
+	public function getScript($offset=0) {
263 263
 		$code=$this->jquery_code_for_compile;
264
-		if($offset>0)
264
+		if ($offset>0)
265 265
 			$code=\array_slice($code, $offset);
266 266
 		return implode('', $code);
267 267
 	}
268 268
 
269
-	public function scriptCount(){
269
+	public function scriptCount() {
270 270
 		return \sizeof($this->jquery_code_for_compile);
271 271
 	}
272 272
 
273
-	private function defer($script){
273
+	private function defer($script) {
274 274
 		$result="window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};";
275 275
 		$result.="window.defer(function(){".$script."})";
276 276
 		return $result;
277 277
 	}
278 278
 
279
-	private function _compileLibrary($library){
279
+	private function _compileLibrary($library) {
280 280
 		if ($library!=NULL) {
281 281
 			if ($library->isAutoCompile()) {
282 282
 				$library->compile(true);
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 * @return void
295 295
 	 */
296 296
 	public function _clear_compile() {
297
-		$this->jquery_code_for_compile=array ();
297
+		$this->jquery_code_for_compile=array();
298 298
 	}
299 299
 
300 300
 	/**
@@ -303,18 +303,18 @@  discard block
 block discarded – undo
303 303
 	 */
304 304
 	public function _document_ready($js) {
305 305
 		if (!is_array($js)) {
306
-			$js=array (
306
+			$js=array(
307 307
 					$js
308 308
 			);
309 309
 		}
310 310
 
311
-		foreach ( $js as $script ) {
311
+		foreach ($js as $script) {
312 312
 			$this->jquery_code_for_compile[]=$script;
313 313
 		}
314 314
 	}
315 315
 
316 316
 	private function minify($input) {
317
-	if(trim($input) === "") return $input;
317
+	if (trim($input)==="") return $input;
318 318
 	return preg_replace(
319 319
 			array(
320 320
 					// Remove comment(s)
Please login to merge, or discard this patch.
Braces   +26 added lines, -17 removed lines patch added patch discarded remove patch
@@ -54,8 +54,9 @@  discard block
 block discarded – undo
54 54
 				$this->params[$key]=$params[$key];
55 55
 		}
56 56
 		$this->jsUtils=$jsUtils;
57
-		if(isset($params["ajaxTransition"]))
58
-			$this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]);
57
+		if(isset($params["ajaxTransition"])) {
58
+					$this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]);
59
+		}
59 60
 	}
60 61
 
61 62
 	/**
@@ -138,10 +139,12 @@  discard block
 block discarded – undo
138 139
 		if (isset($param)) {
139 140
 			$param=Javascript::prep_value($param);
140 141
 			$str="$({$element}).{$jQueryCall}({$param});";
141
-		} else
142
-			$str="$({$element}).{$jQueryCall}();";
143
-			if ($immediatly)
144
-				$this->jquery_code_for_compile[]=$str;
142
+		} else {
143
+					$str="$({$element}).{$jQueryCall}();";
144
+		}
145
+			if ($immediatly) {
146
+							$this->jquery_code_for_compile[]=$str;
147
+			}
145 148
 			return $str;
146 149
 	}
147 150
 	/**
@@ -156,8 +159,9 @@  discard block
 block discarded – undo
156 159
 		$to=Javascript::prep_element($to);
157 160
 		$element=Javascript::prep_element($element);
158 161
 		$str="$({$to}).{$jQueryCall}({$element});";
159
-		if ($immediatly)
160
-			$this->jquery_code_for_compile[]=$str;
162
+		if ($immediatly) {
163
+					$this->jquery_code_for_compile[]=$str;
164
+		}
161 165
 			return $str;
162 166
 	}
163 167
 
@@ -213,12 +217,14 @@  discard block
 block discarded – undo
213 217
 		if ($stopPropagation===true) {
214 218
 			$js=Javascript::$stopPropagation.$js;
215 219
 		}
216
-		if (array_search($event, $this->jquery_events)===false)
217
-			$event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n";
218
-		else
219
-			$event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n";
220
-		if($immediatly)
221
-			$this->jquery_code_for_compile[]=$event;
220
+		if (array_search($event, $this->jquery_events)===false) {
221
+					$event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n";
222
+		} else {
223
+					$event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n";
224
+		}
225
+		if($immediatly) {
226
+					$this->jquery_code_for_compile[]=$event;
227
+		}
222 228
 		return $event;
223 229
 	}
224 230
 
@@ -261,8 +267,9 @@  discard block
 block discarded – undo
261 267
 
262 268
 	public function getScript($offset=0){
263 269
 		$code=$this->jquery_code_for_compile;
264
-		if($offset>0)
265
-			$code=\array_slice($code, $offset);
270
+		if($offset>0) {
271
+					$code=\array_slice($code, $offset);
272
+		}
266 273
 		return implode('', $code);
267 274
 	}
268 275
 
@@ -314,7 +321,9 @@  discard block
 block discarded – undo
314 321
 	}
315 322
 
316 323
 	private function minify($input) {
317
-	if(trim($input) === "") return $input;
324
+	if(trim($input) === "") {
325
+		return $input;
326
+	}
318 327
 	return preg_replace(
319 328
 			array(
320 329
 					// Remove comment(s)
Please login to merge, or discard this patch.