@@ -9,17 +9,17 @@ |
||
9 | 9 | class HtmlFormTextarea extends HtmlFormField { |
10 | 10 | use TextFieldsTrait; |
11 | 11 | |
12 | - public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
13 | - if(!isset($placeholder)) |
|
12 | + public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
13 | + if (!isset($placeholder)) |
|
14 | 14 | $placeholder=$label; |
15 | - parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
|
15 | + parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Defines the textarea row count |
20 | 20 | * @param int $count |
21 | 21 | */ |
22 | - public function setRows($count){ |
|
22 | + public function setRows($count) { |
|
23 | 23 | $this->getField()->setRows($count); |
24 | 24 | } |
25 | 25 |
@@ -7,17 +7,17 @@ |
||
7 | 7 | use Ajax\semantic\html\elements\HtmlInput; |
8 | 8 | |
9 | 9 | class HtmlFormInput extends HtmlFormField { |
10 | - use TextFieldsTrait,FieldTrait; |
|
10 | + use TextFieldsTrait, FieldTrait; |
|
11 | 11 | |
12 | - public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
|
13 | - if(!isset($placeholder) && $type==="text") |
|
12 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
13 | + if (!isset($placeholder) && $type==="text") |
|
14 | 14 | $placeholder=$label; |
15 | - parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
|
15 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
16 | 16 | } |
17 | 17 | |
18 | - public function getDataField(){ |
|
19 | - $field= $this->getField(); |
|
20 | - if($field instanceof HtmlInput) |
|
18 | + public function getDataField() { |
|
19 | + $field=$this->getField(); |
|
20 | + if ($field instanceof HtmlInput) |
|
21 | 21 | $field=$field->getField(); |
22 | 22 | return $field; |
23 | 23 | } |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | * @return \Ajax\semantic\html\collections\HtmlMenu |
38 | 38 | */ |
39 | 39 | public function setType($type="") { |
40 | - return $this->addToPropertyCtrl("class", $type, array ("","item","text" )); |
|
40 | + return $this->addToPropertyCtrl("class", $type, array("", "item", "text")); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function setActiveItem($index) { |
44 | 44 | $item=$this->getItem($index); |
45 | - if ($item !== null) { |
|
45 | + if ($item!==null) { |
|
46 | 46 | $item->addToProperty("class", "active"); |
47 | 47 | } |
48 | 48 | return $this; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | private function getItemToInsert($item) { |
52 | 52 | if ($item instanceof HtmlInput || $item instanceof HtmlImg || $item instanceof HtmlIcon || $item instanceof HtmlButton || ($item instanceof HtmlDropdown && $this->propertyContains("class", "vertical")===false)) { |
53 | - $itemO=new HtmlMenuItem("item-" . $this->identifier . "-" . \sizeof($this->content) , $item); |
|
53 | + $itemO=new HtmlMenuItem("item-".$this->identifier."-".\sizeof($this->content), $item); |
|
54 | 54 | $item=$itemO; |
55 | 55 | } |
56 | 56 | return $item; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | private function afterInsert($item) { |
60 | 60 | if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false) |
61 | - $item->addToPropertyCtrl("class", "item", array ("item" )); |
|
61 | + $item->addToPropertyCtrl("class", "item", array("item")); |
|
62 | 62 | else { |
63 | 63 | $this->setSecondary(); |
64 | 64 | } |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | |
90 | 90 | public function generateMenuAsItem($menu, $header=null) { |
91 | 91 | $count=$this->count(); |
92 | - $item=new HtmlSemDoubleElement("item-" . $this->identifier . "-" . $count, "div"); |
|
92 | + $item=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "div"); |
|
93 | 93 | if (isset($header)) { |
94 | - $headerItem=new HtmlSemDoubleElement("item-header-" . $this->identifier . "-" . $count, "div", "header"); |
|
94 | + $headerItem=new HtmlSemDoubleElement("item-header-".$this->identifier."-".$count, "div", "header"); |
|
95 | 95 | $headerItem->setContent($header); |
96 | 96 | $item->addContent($headerItem); |
97 | 97 | $this->_itemHeader=$headerItem; |
98 | 98 | } |
99 | - if(\is_array($menu)){ |
|
100 | - $menu=new HtmlMenu("menu-" . $this->identifier . "-" . $count,$menu); |
|
99 | + if (\is_array($menu)) { |
|
100 | + $menu=new HtmlMenu("menu-".$this->identifier."-".$count, $menu); |
|
101 | 101 | } |
102 | 102 | $menu->setClass("menu"); |
103 | 103 | $item->addContent($menu); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $value=new HtmlSemDoubleElement($identifier, "a", "browse item", $value); |
113 | 113 | $value->addContent(new HtmlIcon("", "dropdown")); |
114 | 114 | $value=$this->addItem($value); |
115 | - $popup=new HtmlPopup($value, "popup-" . $this->identifier . "-" . $this->count(), $content); |
|
115 | + $popup=new HtmlPopup($value, "popup-".$this->identifier."-".$this->count(), $content); |
|
116 | 116 | $popup->setFlowing()->setPosition("bottom left")->setOn("click"); |
117 | 117 | $this->wrap("", $popup); |
118 | 118 | return $popup; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | public function addDropdownAsItem($value, $items=NULL) { |
122 | 122 | $dd=$value; |
123 | 123 | if (\is_string($value)) { |
124 | - $dd=new HtmlDropdown("dropdown-" . $this->identifier . "-" . $this->count(), $value, $items); |
|
124 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$this->count(), $value, $items); |
|
125 | 125 | } |
126 | 126 | $this->addItem($dd); |
127 | 127 | return $dd; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
135 | 135 | */ |
136 | 136 | protected function createItem($value) { |
137 | - $itemO=new HtmlMenuItem($this->identifier."-item-" . \sizeof($this->content),""); |
|
137 | + $itemO=new HtmlMenuItem($this->identifier."-item-".\sizeof($this->content), ""); |
|
138 | 138 | $itemO->setTagName("a"); |
139 | 139 | $itemO->setContent($value); |
140 | 140 | return $itemO; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | public function setSecondary($value=true) { |
148 | - if($value) |
|
148 | + if ($value) |
|
149 | 149 | $this->addToProperty("class", "secondary"); |
150 | 150 | else |
151 | 151 | $this->removePropertyValue("class", "secondary"); |
@@ -153,28 +153,28 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | public function setVertical() { |
156 | - return $this->addToPropertyCtrl("class", "vertical", array ("vertical" )); |
|
156 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | public function setPosition($value="right") { |
160 | - return $this->addToPropertyCtrl("class", $value, array ("right","left" )); |
|
160 | + return $this->addToPropertyCtrl("class", $value, array("right", "left")); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | public function setPointing($value=Direction::NONE) { |
164 | - return $this->addToPropertyCtrl("class", $value . " pointing", Direction::getConstantValues("pointing")); |
|
164 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | public function asTab($vertical=false) { |
168 | - $this->apply(function (HtmlDoubleElement &$item) { |
|
168 | + $this->apply(function(HtmlDoubleElement&$item) { |
|
169 | 169 | $item->setTagName("a"); |
170 | 170 | }); |
171 | - if ($vertical === true) |
|
171 | + if ($vertical===true) |
|
172 | 172 | $this->setVertical(); |
173 | 173 | return $this->addToProperty("class", "tabular"); |
174 | 174 | } |
175 | 175 | |
176 | 176 | public function asPagination() { |
177 | - $this->apply(function (HtmlDoubleElement &$item) { |
|
177 | + $this->apply(function(HtmlDoubleElement&$item) { |
|
178 | 178 | $item->setTagName("a"); |
179 | 179 | }); |
180 | 180 | return $this->addToProperty("class", "pagination"); |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function setWidth($width) { |
213 | 213 | if (\is_int($width)) { |
214 | - $width=Wide::getConstants()["W" . $width]; |
|
214 | + $width=Wide::getConstants()["W".$width]; |
|
215 | 215 | } |
216 | 216 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
217 | - return $this->addToPropertyCtrl("class", "item", array ("item" )); |
|
217 | + return $this->addToPropertyCtrl("class", "item", array("item")); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | public function addImage($identifier, $src="", $alt="") { |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | public function asSegment() { |
39 | - return $this->addToPropertyCtrl("class", "segment", array ("segment" )); |
|
39 | + return $this->addToPropertyCtrl("class", "segment", array("segment")); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function asContainer() { |
43 | - return $this->addToPropertyCtrl("class", "container", array ("container" )); |
|
43 | + return $this->addToPropertyCtrl("class", "container", array("container")); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @param int $wide |
49 | 49 | */ |
50 | 50 | public function setWide($wide) { |
51 | - if(isset(Wide::getConstants()["W" . $wide])){ |
|
52 | - $wide=Wide::getConstants()["W" . $wide]; |
|
51 | + if (isset(Wide::getConstants()["W".$wide])) { |
|
52 | + $wide=Wide::getConstants()["W".$wide]; |
|
53 | 53 | $this->addToPropertyCtrl("class", $wide, Wide::getConstants()); |
54 | - return $this->addToPropertyCtrl("class", "column", array ("column" )); |
|
54 | + return $this->addToPropertyCtrl("class", "column", array("column")); |
|
55 | 55 | } |
56 | 56 | return $this; |
57 | 57 | } |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * @return mixed |
72 | 72 | */ |
73 | 73 | public function addRow($colsCount=NULL) { |
74 | - $rowCount=$this->rowCount() + 1; |
|
74 | + $rowCount=$this->rowCount()+1; |
|
75 | 75 | $this->setRowsCount($rowCount, $colsCount, true); |
76 | - return $this->content[$rowCount - 1]; |
|
76 | + return $this->content[$rowCount-1]; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * @return mixed|\Ajax\semantic\html\collections\HtmlGrid |
83 | 83 | */ |
84 | 84 | public function addCol($width=NULL) { |
85 | - $colCount=$this->colCount() + 1; |
|
85 | + $colCount=$this->colCount()+1; |
|
86 | 86 | $this->setColsCount($colCount, true, $width); |
87 | 87 | if ($this->hasOnlyCols($this->count())) |
88 | - return $this->content[$colCount - 1]; |
|
88 | + return $this->content[$colCount-1]; |
|
89 | 89 | return $this; |
90 | 90 | } |
91 | 91 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return \Ajax\semantic\html\collections\HtmlGrid |
96 | 96 | */ |
97 | 97 | public function addCols($sizes=array()) { |
98 | - foreach ( $sizes as $size ) { |
|
98 | + foreach ($sizes as $size) { |
|
99 | 99 | $this->addCol($size); |
100 | 100 | } |
101 | 101 | return $this; |
@@ -109,19 +109,19 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function setRowsCount($rowsCount, $colsCount=NULL, $force=false) { |
111 | 111 | $count=$this->count(); |
112 | - if ($rowsCount < 2 && $force === false) { |
|
113 | - for($i=$count; $i < $colsCount; $i++) { |
|
114 | - $this->addItem(new HtmlGridCol("col-" . $this->identifier . "-" . $i)); |
|
112 | + if ($rowsCount<2 && $force===false) { |
|
113 | + for ($i=$count; $i<$colsCount; $i++) { |
|
114 | + $this->addItem(new HtmlGridCol("col-".$this->identifier."-".$i)); |
|
115 | 115 | } |
116 | 116 | } else { |
117 | 117 | if ($this->hasOnlyCols($count)) { |
118 | 118 | $tmpContent=$this->content; |
119 | 119 | $item=$this->addItem($colsCount); |
120 | 120 | $item->setContent($tmpContent); |
121 | - $this->content=array (); |
|
121 | + $this->content=array(); |
|
122 | 122 | $count=1; |
123 | 123 | } |
124 | - for($i=$count; $i < $rowsCount; $i++) { |
|
124 | + for ($i=$count; $i<$rowsCount; $i++) { |
|
125 | 125 | $this->addItem($colsCount); |
126 | 126 | } |
127 | 127 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | protected function hasOnlyCols($count) { |
132 | - return $count > 0 && $this->content[0] instanceof HtmlGridCol; |
|
132 | + return $count>0 && $this->content[0] instanceof HtmlGridCol; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | if (isset($width)==false) { |
144 | 144 | $this->setWide($numCols); |
145 | 145 | } |
146 | - if ($toCreate == true) { |
|
146 | + if ($toCreate==true) { |
|
147 | 147 | $count=$this->count(); |
148 | - if ($count == 0 || $this->hasOnlyCols($count)) { |
|
149 | - for($i=$count; $i < $numCols; $i++) { |
|
150 | - $this->addItem(new HtmlGridCol("col-" . $this->identifier . "-" . $i, $width)); |
|
148 | + if ($count==0 || $this->hasOnlyCols($count)) { |
|
149 | + for ($i=$count; $i<$numCols; $i++) { |
|
150 | + $this->addItem(new HtmlGridCol("col-".$this->identifier."-".$i, $width)); |
|
151 | 151 | } |
152 | 152 | } else { |
153 | - for($i=0; $i < $count; $i++) { |
|
153 | + for ($i=0; $i<$count; $i++) { |
|
154 | 154 | $this->getItem($i)->setColsCount($numCols); |
155 | 155 | } |
156 | 156 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $count=$this->count(); |
187 | 187 | if ($this->hasOnlyCols($count)) |
188 | 188 | return $count; |
189 | - if ($count > 0) |
|
189 | + if ($count>0) |
|
190 | 190 | return $this->getItem(0)->count(); |
191 | 191 | return 0; |
192 | 192 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return \Ajax\semantic\html\collections\HtmlGridCol |
199 | 199 | */ |
200 | 200 | public function getCell($row, $col) { |
201 | - if ($row < 2 && $this->hasOnlyCols($this->count())) |
|
201 | + if ($row<2 && $this->hasOnlyCols($this->count())) |
|
202 | 202 | return $this->getItem($col); |
203 | 203 | $row=$this->getItem($row); |
204 | 204 | if (isset($row)) { |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | * @return \Ajax\semantic\html\collections\HtmlGrid |
214 | 214 | */ |
215 | 215 | public function setDivided($vertically=false) { |
216 | - $value=($vertically === true) ? "vertically divided" : "divided"; |
|
217 | - return $this->addToPropertyCtrl("class", $value, array ("divided" )); |
|
216 | + $value=($vertically===true) ? "vertically divided" : "divided"; |
|
217 | + return $this->addToPropertyCtrl("class", $value, array("divided")); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | * @return \Ajax\semantic\html\collections\HtmlGrid |
224 | 224 | */ |
225 | 225 | public function setCelled($internally=false) { |
226 | - $value=($internally === true) ? "internally celled" : "celled"; |
|
227 | - return $this->addToPropertyCtrl("class", $value, array ("celled","internally celled" )); |
|
226 | + $value=($internally===true) ? "internally celled" : "celled"; |
|
227 | + return $this->addToPropertyCtrl("class", $value, array("celled", "internally celled")); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
231 | 231 | * A grid can have its columns centered |
232 | 232 | */ |
233 | 233 | public function setCentered() { |
234 | - return $this->addToPropertyCtrl("class", "centered", array ("centered" )); |
|
234 | + return $this->addToPropertyCtrl("class", "centered", array("centered")); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function setPadded($value=NULL) { |
251 | 251 | if (isset($value)) |
252 | - $this->addToPropertyCtrl("class", $value, array ("vertically","horizontally" )); |
|
252 | + $this->addToPropertyCtrl("class", $value, array("vertically", "horizontally")); |
|
253 | 253 | return $this->addToProperty("class", "padded"); |
254 | 254 | } |
255 | 255 | |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | * @return \Ajax\semantic\html\collections\HtmlGrid |
260 | 260 | */ |
261 | 261 | public function setRelaxed($very=false) { |
262 | - $value=($very === true) ? "very relaxed" : "relaxed"; |
|
263 | - return $this->addToPropertyCtrl("class", $value, array ("relaxed","very relaxed" )); |
|
262 | + $value=($very===true) ? "very relaxed" : "relaxed"; |
|
263 | + return $this->addToPropertyCtrl("class", $value, array("relaxed", "very relaxed")); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | public function setVerticalAlignment($value=VerticalAlignment::MIDDLE) { |
267 | - return $this->addToPropertyCtrl("class", $value . " aligned", VerticalAlignment::getConstantValues("aligned")); |
|
267 | + return $this->addToPropertyCtrl("class", $value." aligned", VerticalAlignment::getConstantValues("aligned")); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | * @see \Ajax\common\html\HtmlCollection::createItem() |
275 | 275 | */ |
276 | 276 | protected function createItem($value) { |
277 | - if ($this->_createCols === false) |
|
277 | + if ($this->_createCols===false) |
|
278 | 278 | $value=null; |
279 | - $item=new HtmlGridRow($this->identifier . "-row-" . ($this->count() + 1), $value, $this->_colSizing, $this->_implicitRows); |
|
279 | + $item=new HtmlGridRow($this->identifier."-row-".($this->count()+1), $value, $this->_colSizing, $this->_implicitRows); |
|
280 | 280 | return $item; |
281 | 281 | } |
282 | 282 | |
@@ -286,15 +286,15 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function setValues($values, $force=true) { |
288 | 288 | $count=$this->count(); |
289 | - if ($this->_createCols === false || $force === true) { |
|
290 | - for($i=$count; $i < \sizeof($values); $i++) { |
|
289 | + if ($this->_createCols===false || $force===true) { |
|
290 | + for ($i=$count; $i<\sizeof($values); $i++) { |
|
291 | 291 | $colSize=\sizeof($values[$i]); |
292 | - $this->addItem(new HtmlGridRow($this->identifier . "-row-" . ($this->count() + 1), $colSize, $this->_colSizing, $this->_implicitRows)); |
|
292 | + $this->addItem(new HtmlGridRow($this->identifier."-row-".($this->count()+1), $colSize, $this->_colSizing, $this->_implicitRows)); |
|
293 | 293 | } |
294 | 294 | } |
295 | - $count=\min(array ($this->count(),\sizeof($values) )); |
|
296 | - for($i=0; $i < $count; $i++) { |
|
297 | - $this->content[$i]->setValues($values[$i], $this->_createCols === false); |
|
295 | + $count=\min(array($this->count(), \sizeof($values))); |
|
296 | + for ($i=0; $i<$count; $i++) { |
|
297 | + $this->content[$i]->setValues($values[$i], $this->_createCols===false); |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 |
@@ -33,17 +33,17 @@ discard block |
||
33 | 33 | return $this->getHtmlCk()->attachEvents($events); |
34 | 34 | } |
35 | 35 | |
36 | - public function getField(){ |
|
36 | + public function getField() { |
|
37 | 37 | return $this->content["field"]->getField(); |
38 | 38 | } |
39 | 39 | |
40 | - public function getHtmlCk(){ |
|
40 | + public function getHtmlCk() { |
|
41 | 41 | return $this->content["field"]; |
42 | 42 | } |
43 | 43 | |
44 | - public function getDataField(){ |
|
45 | - $field= $this->getField(); |
|
46 | - if($field instanceof AbstractCheckbox) |
|
44 | + public function getDataField() { |
|
45 | + $field=$this->getField(); |
|
46 | + if ($field instanceof AbstractCheckbox) |
|
47 | 47 | $field=$field->getField(); |
48 | 48 | return $field; |
49 | 49 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @param boolean $value |
54 | 54 | * @return \Ajax\semantic\html\collections\form\traits\CheckboxTrait |
55 | 55 | */ |
56 | - public function setChecked($value=true){ |
|
57 | - if($value===true){ |
|
56 | + public function setChecked($value=true) { |
|
57 | + if ($value===true) { |
|
58 | 58 | $this->getDataField()->setProperty("checked", "checked"); |
59 | - }else{ |
|
59 | + } else { |
|
60 | 60 | $this->getDataField()->removeProperty("checked"); |
61 | 61 | } |
62 | 62 | return $this; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use Ajax\semantic\html\base\constants\CheckboxType; |
7 | 7 | |
8 | 8 | abstract class AbstractCheckbox extends HtmlSemDoubleElement { |
9 | - protected $_params=array (); |
|
9 | + protected $_params=array(); |
|
10 | 10 | |
11 | 11 | public function __construct($identifier, $name=NULL, $label=NULL, $value=NULL, $inputType="checkbox", $type="checkbox") { |
12 | 12 | parent::__construct("ck-".$identifier, "div", "ui ".$type); |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | $this->setLabel($label); |
18 | 18 | } |
19 | 19 | |
20 | - public function setChecked($value=true){ |
|
21 | - if($value===true){ |
|
20 | + public function setChecked($value=true) { |
|
21 | + if ($value===true) { |
|
22 | 22 | $this->getField()->setProperty("checked", "checked"); |
23 | - }else{ |
|
23 | + } else { |
|
24 | 24 | $this->getField()->removeProperty("checked"); |
25 | 25 | } |
26 | 26 | return $this; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return \Ajax\semantic\html\collections\form\AbstractHtmlFormRadioCheckbox |
83 | 83 | */ |
84 | 84 | public function attachEvent($selector, $action=NULL) { |
85 | - if (isset($action)!==false||\is_numeric($action)===true) { |
|
85 | + if (isset($action)!==false || \is_numeric($action)===true) { |
|
86 | 86 | $js='$("#%identifier%").checkbox("attach events", "'.$selector.'", "'.$action.'");'; |
87 | 87 | } else { |
88 | 88 | $js='$("#%identifier%").checkbox("attach events", "'.$selector.'");'; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function attachEvents($events=array()) { |
100 | 100 | if (\is_array($events)) { |
101 | - foreach ( $events as $action => $selector ) { |
|
101 | + foreach ($events as $action => $selector) { |
|
102 | 102 | $this->attachEvent($selector, $action); |
103 | 103 | } |
104 | 104 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public function setFocusable($value=true) { |
58 | - if ($value === true) |
|
58 | + if ($value===true) |
|
59 | 59 | $this->setProperty("tabindex", "0"); |
60 | 60 | else { |
61 | 61 | $this->removeProperty("tabindex"); |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | |
66 | 66 | public function setAnimated($content, $animation="") { |
67 | 67 | $this->setTagName("div"); |
68 | - $this->addToProperty("class", "animated " . $animation); |
|
69 | - $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
|
68 | + $this->addToProperty("class", "animated ".$animation); |
|
69 | + $visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div"); |
|
70 | 70 | $visible->setClass("visible content"); |
71 | 71 | $visible->setContent($this->content); |
72 | - $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
|
72 | + $hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div"); |
|
73 | 73 | $hidden->setClass("hidden content"); |
74 | 74 | $hidden->setContent($content); |
75 | - $this->content=array ($visible,$hidden ); |
|
75 | + $this->content=array($visible, $hidden); |
|
76 | 76 | return $hidden; |
77 | 77 | } |
78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | public function asIcon($icon) { |
85 | 85 | $iconO=$icon; |
86 | 86 | if (\is_string($icon)) { |
87 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
87 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
88 | 88 | } |
89 | 89 | $this->addToProperty("class", "icon"); |
90 | 90 | $this->content=$iconO; |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | public function addLabel($label, $before=false, $icon=NULL) { |
107 | 107 | $this->tagName="div"; |
108 | 108 | $this->addToProperty("class", "labeled"); |
109 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
109 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
110 | 110 | $this->content->setTagName("div"); |
111 | - $label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a"); |
|
111 | + $label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a"); |
|
112 | 112 | $label->setBasic(); |
113 | 113 | $this->addContent($label, $before); |
114 | 114 | return $label; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function fromArray($array) { |
122 | 122 | $array=parent::fromArray($array); |
123 | - foreach ( $array as $key => $value ) { |
|
123 | + foreach ($array as $key => $value) { |
|
124 | 124 | $this->setProperty($key, $value); |
125 | 125 | } |
126 | 126 | return $array; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | public static function social($identifier, $social, $value=NULL) { |
178 | - if ($value === NULL) |
|
178 | + if ($value===NULL) |
|
179 | 179 | $value=\ucfirst($social); |
180 | 180 | $return=new HtmlButton($identifier, $value); |
181 | 181 | $return->addIcon($social); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | public function asLink($href=NULL) { |
198 | - $lnk=new HtmlLink("lnk-".$this->identifier,$href,$this->content); |
|
198 | + $lnk=new HtmlLink("lnk-".$this->identifier, $href, $this->content); |
|
199 | 199 | $this->content=$lnk; |
200 | 200 | return $this; |
201 | 201 | } |
@@ -11,46 +11,46 @@ discard block |
||
11 | 11 | use Ajax\semantic\html\collections\form\HtmlFormField; |
12 | 12 | |
13 | 13 | trait FieldsTrait { |
14 | - public abstract function addFields($fields=NULL,$label=NULL); |
|
14 | + public abstract function addFields($fields=NULL, $label=NULL); |
|
15 | 15 | public abstract function addItem($item); |
16 | 16 | |
17 | - protected function createItem($value){ |
|
18 | - if(\is_array($value)){ |
|
19 | - $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
|
17 | + protected function createItem($value) { |
|
18 | + if (\is_array($value)) { |
|
19 | + $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null))); |
|
20 | 20 | return $itemO; |
21 | - }elseif(\is_object($value)){ |
|
21 | + }elseif (\is_object($value)) { |
|
22 | 22 | $itemO=new HtmlFormField("field-".$this->identifier, $value); |
23 | 23 | return $itemO; |
24 | - }else |
|
24 | + } else |
|
25 | 25 | return new HtmlFormInput($value); |
26 | 26 | } |
27 | 27 | |
28 | - protected function createCondition($value){ |
|
28 | + protected function createCondition($value) { |
|
29 | 29 | return \is_object($value)===false || $value instanceof \Ajax\semantic\html\elements\HtmlInput; |
30 | 30 | } |
31 | 31 | |
32 | - public function addInputs($inputs,$fieldslabel=null){ |
|
32 | + public function addInputs($inputs, $fieldslabel=null) { |
|
33 | 33 | $fields=array(); |
34 | - foreach ($inputs as $input){ |
|
34 | + foreach ($inputs as $input) { |
|
35 | 35 | \extract($input); |
36 | - $f=new HtmlFormInput("",""); |
|
36 | + $f=new HtmlFormInput("", ""); |
|
37 | 37 | $f->fromArray($input); |
38 | 38 | $fields[]=$f; |
39 | 39 | } |
40 | - return $this->addFields($fields,$fieldslabel); |
|
40 | + return $this->addFields($fields, $fieldslabel); |
|
41 | 41 | } |
42 | 42 | |
43 | - public function addFieldRule($index,$type,$prompt=NULL,$value=NULL){ |
|
43 | + public function addFieldRule($index, $type, $prompt=NULL, $value=NULL) { |
|
44 | 44 | $field=$this->getItem($index); |
45 | - if(isset($field)){ |
|
46 | - $field->addRule($type,$prompt,$value); |
|
45 | + if (isset($field)) { |
|
46 | + $field->addRule($type, $prompt, $value); |
|
47 | 47 | } |
48 | 48 | return $this; |
49 | 49 | } |
50 | 50 | |
51 | - public function addFieldRules($index,$rules){ |
|
51 | + public function addFieldRules($index, $rules) { |
|
52 | 52 | $field=$this->getItem($index); |
53 | - if(isset($field)){ |
|
53 | + if (isset($field)) { |
|
54 | 54 | $field->addRules($rules); |
55 | 55 | } |
56 | 56 | return $this; |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | * @param boolean $multiple |
65 | 65 | * @return \Ajax\common\html\HtmlDoubleElement |
66 | 66 | */ |
67 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
68 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
67 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
68 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -76,23 +76,23 @@ discard block |
||
76 | 76 | * @param string $placeholder |
77 | 77 | * @return HtmlFormInput |
78 | 78 | */ |
79 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
80 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
79 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
80 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
81 | 81 | } |
82 | 82 | |
83 | - public function addPassword($identifier, $label=NULL){ |
|
84 | - return $this->addItem(new HtmlFormInput($identifier,$label,"password","","")); |
|
83 | + public function addPassword($identifier, $label=NULL) { |
|
84 | + return $this->addItem(new HtmlFormInput($identifier, $label, "password", "", "")); |
|
85 | 85 | } |
86 | 86 | |
87 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
88 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
87 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
88 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
89 | 89 | } |
90 | 90 | |
91 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
92 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
91 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
92 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
93 | 93 | } |
94 | 94 | |
95 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
96 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
95 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
96 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | \ No newline at end of file |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | |
33 | 33 | public function __construct($identifier, $elements=array()) { |
34 | 34 | parent::__construct($identifier, "form", "ui form"); |
35 | - $this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ]; |
|
35 | + $this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED]; |
|
36 | 36 | $this->setProperty("name", $this->identifier); |
37 | - $this->_fields=array (); |
|
37 | + $this->_fields=array(); |
|
38 | 38 | $this->_validationParams=[]; |
39 | 39 | $this->addItems($elements); |
40 | 40 | } |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | * @param string $caption |
57 | 57 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
58 | 58 | */ |
59 | - public function addDivider($caption=NULL){ |
|
60 | - return $this->addContent(new HtmlDivider("",$caption)); |
|
59 | + public function addDivider($caption=NULL) { |
|
60 | + return $this->addContent(new HtmlDivider("", $caption)); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public function addFields($fields=NULL, $label=NULL) { |
64 | 64 | if (isset($fields)) { |
65 | 65 | if (!$fields instanceof HtmlFormFields) { |
66 | - if (\is_array($fields) === false) { |
|
66 | + if (\is_array($fields)===false) { |
|
67 | 67 | $fields=\func_get_args(); |
68 | 68 | $end=\end($fields); |
69 | 69 | if (\is_string($end)) { |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | $label=NULL; |
74 | 74 | } |
75 | 75 | $this->_fields=\array_merge($this->_fields, $fields); |
76 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
|
76 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
77 | 77 | } |
78 | 78 | if (isset($label)) |
79 | 79 | $fields=new HtmlFormField("", $fields, $label); |
80 | 80 | } else { |
81 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
|
81 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
|
82 | 82 | } |
83 | 83 | $this->addItem($fields); |
84 | 84 | return $fields; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | public function addItem($item) { |
88 | 88 | $item=parent::addItem($item); |
89 | - if (\is_subclass_of($item, HtmlFormField::class) === true) { |
|
89 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
90 | 90 | $this->_fields[]=$item; |
91 | 91 | } |
92 | 92 | return $item; |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | return $this->addItem($message); |
139 | 139 | } |
140 | 140 | |
141 | - private function addCompoValidation($js,$compo,$field){ |
|
141 | + private function addCompoValidation($js, $compo, $field) { |
|
142 | 142 | $validation=$field->getValidation(); |
143 | - if(isset($validation)){ |
|
144 | - if(isset($compo)===false){ |
|
143 | + if (isset($validation)) { |
|
144 | + if (isset($compo)===false) { |
|
145 | 145 | $compo=$js->semantic()->form("#".$this->identifier); |
146 | 146 | } |
147 | 147 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
@@ -152,26 +152,26 @@ discard block |
||
152 | 152 | |
153 | 153 | public function run(JsUtils $js) { |
154 | 154 | $compo=NULL; |
155 | - foreach ($this->_fields as $field){ |
|
156 | - if($field instanceof HtmlFormField) |
|
155 | + foreach ($this->_fields as $field) { |
|
156 | + if ($field instanceof HtmlFormField) |
|
157 | 157 | $compo=$this->addCompoValidation($js, $compo, $field); |
158 | 158 | } |
159 | - foreach ($this->content as $field){ |
|
160 | - if($field instanceof HtmlFormFields){ |
|
159 | + foreach ($this->content as $field) { |
|
160 | + if ($field instanceof HtmlFormFields) { |
|
161 | 161 | $items=$field->getItems(); |
162 | - foreach ($items as $_field){ |
|
163 | - if($_field instanceof HtmlFormField) |
|
162 | + foreach ($items as $_field) { |
|
163 | + if ($_field instanceof HtmlFormField) |
|
164 | 164 | $compo=$this->addCompoValidation($js, $compo, $_field); |
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
168 | - if(isset($compo)===false){ |
|
168 | + if (isset($compo)===false) { |
|
169 | 169 | return parent::run($js); |
170 | 170 | } |
171 | - if(isset($this->_validationParams["_ajaxSubmit"])){ |
|
172 | - if($this->_validationParams["_ajaxSubmit"] instanceof AjaxCall){ |
|
171 | + if (isset($this->_validationParams["_ajaxSubmit"])) { |
|
172 | + if ($this->_validationParams["_ajaxSubmit"] instanceof AjaxCall) { |
|
173 | 173 | $compilation=$this->_validationParams["_ajaxSubmit"]->compile($js); |
174 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
174 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
175 | 175 | $this->onSuccess($compilation); |
176 | 176 | unset($this->_validationParams["_ajaxSubmit"]); |
177 | 177 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | return $this->addToProperty("class", "loading"); |
187 | 187 | } |
188 | 188 | |
189 | - public function addErrorMessage(){ |
|
189 | + public function addErrorMessage() { |
|
190 | 190 | return $this->addContent((new HtmlMessage(""))->setError()); |
191 | 191 | } |
192 | 192 | |
@@ -199,22 +199,22 @@ discard block |
||
199 | 199 | return $this; |
200 | 200 | } |
201 | 201 | |
202 | - public function submitOn($event,$identifier,$url,$responseElement){ |
|
202 | + public function submitOn($event, $identifier, $url, $responseElement) { |
|
203 | 203 | $elem=$this->getElementById($identifier, $this->content); |
204 | - if(isset($elem)){ |
|
204 | + if (isset($elem)) { |
|
205 | 205 | $elem->addEvent($event, "$('#".$this->identifier."').form('validate form');"); |
206 | - $this->_validationParams["_ajaxSubmit"]=new AjaxCall("postForm", ["form"=>$this->identifier,"responseElement"=>$responseElement,"url"=>$url]); |
|
206 | + $this->_validationParams["_ajaxSubmit"]=new AjaxCall("postForm", ["form"=>$this->identifier, "responseElement"=>$responseElement, "url"=>$url]); |
|
207 | 207 | } |
208 | 208 | return $this; |
209 | 209 | } |
210 | 210 | |
211 | - public function submitOnClick($identifier,$url,$responseElement){ |
|
211 | + public function submitOnClick($identifier, $url, $responseElement) { |
|
212 | 212 | return $this->submitOn("click", $identifier, $url, $responseElement); |
213 | 213 | } |
214 | 214 | |
215 | - public function addSubmit($identifier,$value,$CssStyle=NULL,$url=NULL,$responseElement=NULL){ |
|
216 | - $bt=$this->addButton($identifier, $value,$CssStyle); |
|
217 | - if(isset($url) && isset($responseElement)) |
|
215 | + public function addSubmit($identifier, $value, $CssStyle=NULL, $url=NULL, $responseElement=NULL) { |
|
216 | + $bt=$this->addButton($identifier, $value, $CssStyle); |
|
217 | + if (isset($url) && isset($responseElement)) |
|
218 | 218 | $this->submitOnClick($identifier, $url, $responseElement); |
219 | 219 | return $bt; |
220 | 220 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @param string $jsCode |
225 | 225 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
226 | 226 | */ |
227 | - public function onValid($jsCode){ |
|
227 | + public function onValid($jsCode) { |
|
228 | 228 | $this->_validationParams["onValid"]="%function(){".$jsCode."}%"; |
229 | 229 | return $this; |
230 | 230 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @param string $jsCode can use event and fields parameters |
235 | 235 | * @return HtmlForm |
236 | 236 | */ |
237 | - public function onSuccess($jsCode){ |
|
237 | + public function onSuccess($jsCode) { |
|
238 | 238 | $this->_validationParams["onSuccess"]="%function(evt,fields){".$jsCode."}%"; |
239 | 239 | return $this; |
240 | 240 | } |