@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * |
12 | 12 | */ |
13 | 13 | class HtmlTableContent extends HtmlSemCollection { |
14 | - protected $_tdTagNames=[ "thead" => "th","tbody" => "td","tfoot" => "th" ]; |
|
14 | + protected $_tdTagNames=["thead" => "th", "tbody" => "td", "tfoot" => "th"]; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function setRowCount($rowCount, $colCount) { |
36 | 36 | $count=$this->count(); |
37 | - for($i=$count; $i < $rowCount; $i++) { |
|
37 | + for ($i=$count; $i<$rowCount; $i++) { |
|
38 | 38 | $this->addItem($colCount); |
39 | 39 | } |
40 | 40 | return $this; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $tr=new HtmlTR("", $value); |
57 | 57 | $tr->setContainer($this, $count); |
58 | 58 | $tr->setTdTagName($this->_tdTagNames[$this->tagName]); |
59 | - if (isset($value) === true) { |
|
59 | + if (isset($value)===true) { |
|
60 | 60 | $tr->setColCount($value); |
61 | 61 | } |
62 | 62 | return $tr; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function setCellValue($row, $col, $value="") { |
116 | 116 | $cell=$this->getCell($row, $col); |
117 | - if (isset($cell) === true) { |
|
117 | + if (isset($cell)===true) { |
|
118 | 118 | $cell->setValue($value); |
119 | 119 | } |
120 | 120 | return $this; |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | $values=\array_fill(0, $count, $values); |
132 | 132 | $isArray=false; |
133 | 133 | } |
134 | - if (JArray::dimension($values) == 1 && $isArray) |
|
135 | - $values=[ $values ]; |
|
134 | + if (JArray::dimension($values)==1 && $isArray) |
|
135 | + $values=[$values]; |
|
136 | 136 | |
137 | 137 | $count=\min(\sizeof($values), $count); |
138 | 138 | |
139 | - for($i=0; $i < $count; $i++) { |
|
139 | + for ($i=0; $i<$count; $i++) { |
|
140 | 140 | $row=$this->content[$i]; |
141 | 141 | $row->setValues($values[$i]); |
142 | 142 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $values=\array_fill(0, $count, $values); |
150 | 150 | } |
151 | 151 | $count=\min(\sizeof($values), $count); |
152 | - for($i=0; $i < $count; $i++) { |
|
152 | + for ($i=0; $i<$count; $i++) { |
|
153 | 153 | $this->getCell($i, $colIndex)->setValue($values[$i]); |
154 | 154 | } |
155 | 155 | return $this; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | public function addColVariations($colIndex, $variations=array()) { |
159 | 159 | $count=$this->count(); |
160 | - for($i=0; $i < $count; $i++) { |
|
160 | + for ($i=0; $i<$count; $i++) { |
|
161 | 161 | $this->getCell($i, $colIndex)->addVariations($variations); |
162 | 162 | } |
163 | 163 | return $this; |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | |
175 | 175 | private function colAlign($colIndex, $function) { |
176 | 176 | $count=$this->count(); |
177 | - for($i=0; $i < $count; $i++) { |
|
177 | + for ($i=0; $i<$count; $i++) { |
|
178 | 178 | $index=$this->content[$i]->getColPosition($colIndex); |
179 | - if ($index !== NULL) |
|
179 | + if ($index!==NULL) |
|
180 | 180 | $this->getCell($i, $index)->$function(); |
181 | 181 | } |
182 | 182 | return $this; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function getColCount() { |
210 | 210 | $result=0; |
211 | - if ($this->count() > 0) |
|
211 | + if ($this->count()>0) |
|
212 | 212 | $result=$this->getItem(0)->getColCount(); |
213 | 213 | return $result; |
214 | 214 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | public function delete($rowIndex, $colIndex=NULL) { |
223 | 223 | if (isset($colIndex)) { |
224 | 224 | $row=$this->getItem($rowIndex); |
225 | - if (isset($row) === true) { |
|
225 | + if (isset($row)===true) { |
|
226 | 226 | $row->delete($colIndex); |
227 | 227 | } |
228 | 228 | } else { |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function conditionalCellFormat($callback, $format) { |
256 | 256 | $rows=$this->content; |
257 | - foreach ( $rows as $row ) { |
|
257 | + foreach ($rows as $row) { |
|
258 | 258 | $row->conditionalCellFormat($callback, $format); |
259 | 259 | } |
260 | 260 | return $this; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public function conditionalRowFormat($callback, $format) { |
269 | 269 | $rows=$this->content; |
270 | - foreach ( $rows as $row ) { |
|
270 | + foreach ($rows as $row) { |
|
271 | 271 | $row->conditionalRowFormat($callback, $format); |
272 | 272 | } |
273 | 273 | return $this; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function applyCells($callback) { |
281 | 281 | $rows=$this->content; |
282 | - foreach ( $rows as $row ) { |
|
282 | + foreach ($rows as $row) { |
|
283 | 283 | $row->applyCells($callback); |
284 | 284 | } |
285 | 285 | return $this; |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function applyRows($callback) { |
293 | 293 | $rows=$this->content; |
294 | - foreach ( $rows as $row ) { |
|
294 | + foreach ($rows as $row) { |
|
295 | 295 | $row->apply($callback); |
296 | 296 | } |
297 | 297 | return $this; |
@@ -20,12 +20,12 @@ discard block |
||
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 | } |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | if (!\is_array($values)) { |
69 | 69 | $values=\array_fill(0, $count, $values); |
70 | 70 | } else { |
71 | - if (JArray::isAssociative($values) === true) { |
|
71 | + if (JArray::isAssociative($values)===true) { |
|
72 | 72 | $values=\array_values($values); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | $count=\min(\sizeof($values), $count); |
76 | 76 | |
77 | - for($i=0; $i < $count; $i++) { |
|
77 | + for ($i=0; $i<$count; $i++) { |
|
78 | 78 | $cell=$this->content[$i]; |
79 | 79 | $cell->setValue($values[$i]); |
80 | 80 | } |
@@ -101,20 +101,20 @@ discard block |
||
101 | 101 | public function getColPosition($colIndex) { |
102 | 102 | $pos=0; |
103 | 103 | $rows=$this->_container->getContent(); |
104 | - for($i=0; $i < $this->_row; $i++) { |
|
104 | + for ($i=0; $i<$this->_row; $i++) { |
|
105 | 105 | $max=\min($colIndex, $rows[$i]->count()); |
106 | - for($j=0; $j < $max; $j++) { |
|
106 | + for ($j=0; $j<$max; $j++) { |
|
107 | 107 | $rowspan=$rows[$i]->getItem($j)->getRowspan(); |
108 | - if ($rowspan + $i > $this->_row) |
|
108 | + if ($rowspan+$i>$this->_row) |
|
109 | 109 | $pos++; |
110 | 110 | } |
111 | 111 | } |
112 | - if ($pos > $colIndex) |
|
112 | + if ($pos>$colIndex) |
|
113 | 113 | return NULL; |
114 | 114 | $count=$this->count(); |
115 | - for($i=0; $i < $count; $i++) { |
|
115 | + for ($i=0; $i<$count; $i++) { |
|
116 | 116 | $pos+=$this->content[$i]->getColspan(); |
117 | - if ($pos >= $colIndex + 1) |
|
117 | + if ($pos>=$colIndex+1) |
|
118 | 118 | return $i; |
119 | 119 | } |
120 | 120 | return null; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | public function conditionalCellFormat($callback, $format) { |
124 | 124 | $cells=$this->content; |
125 | - foreach ( $cells as $cell ) { |
|
125 | + foreach ($cells as $cell) { |
|
126 | 126 | $cell->conditionalCellFormat($callback, $format); |
127 | 127 | } |
128 | 128 | return $this; |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | |
138 | 138 | public function containsStr($needle) { |
139 | 139 | $cells=$this->content; |
140 | - foreach ( $cells as $cell ) { |
|
141 | - if (\strpos($cell->getContent(), $needle) !== false) |
|
140 | + foreach ($cells as $cell) { |
|
141 | + if (\strpos($cell->getContent(), $needle)!==false) |
|
142 | 142 | return true; |
143 | 143 | } |
144 | 144 | return false; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | public function applyCells($callback) { |
153 | 153 | $cells=$this->content; |
154 | - foreach ( $cells as $cell ) { |
|
154 | + foreach ($cells as $cell) { |
|
155 | 155 | $cell->apply($callback); |
156 | 156 | } |
157 | 157 | return $this; |
@@ -17,17 +17,17 @@ discard block |
||
17 | 17 | $this->createBar(); |
18 | 18 | if (isset($label)) |
19 | 19 | $this->setLabel($label); |
20 | - $this->_states=[ State::SUCCESS,State::WARNING,State::ERROR,State::ACTIVE,State::DISABLED ]; |
|
20 | + $this->_states=[State::SUCCESS, State::WARNING, State::ERROR, State::ACTIVE, State::DISABLED]; |
|
21 | 21 | $this->addToProperty("class", $attributes); |
22 | 22 | } |
23 | 23 | |
24 | 24 | public function setLabel($label) { |
25 | - $this->content["label"]=new HtmlSemDoubleElement("lbl-" . $this->identifier, "div", "label", $label); |
|
25 | + $this->content["label"]=new HtmlSemDoubleElement("lbl-".$this->identifier, "div", "label", $label); |
|
26 | 26 | return $this; |
27 | 27 | } |
28 | 28 | |
29 | 29 | private function createBar() { |
30 | - $bar=new HtmlSemDoubleElement("bar-" . $this->identifier, "div", "bar", new HtmlSemDoubleElement("progress-" . $this->identifier, "div", "progress")); |
|
30 | + $bar=new HtmlSemDoubleElement("bar-".$this->identifier, "div", "bar", new HtmlSemDoubleElement("progress-".$this->identifier, "div", "progress")); |
|
31 | 31 | $this->content["bar"]=$bar; |
32 | 32 | return $this; |
33 | 33 | } |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
64 | 64 | */ |
65 | 65 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
66 | - $this->content=JArray::sortAssociative($this->content, [ "bar","label" ]); |
|
66 | + $this->content=JArray::sortAssociative($this->content, ["bar", "label"]); |
|
67 | 67 | return parent::compile($js, $view); |
68 | 68 | } |
69 | 69 | |
70 | 70 | public function jsSetValue($value) { |
71 | - return '$("#' . $this->identifier . '").progress({value:' . $value . '});'; |
|
71 | + return '$("#'.$this->identifier.'").progress({value:'.$value.'});'; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function jsIncValue() { |
75 | - return '$("#' . $this->identifier . '").progress("increment");'; |
|
75 | + return '$("#'.$this->identifier.'").progress("increment");'; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | public function jsDecValue() { |
79 | - return '$("#' . $this->identifier . '").progress("decrement");'; |
|
79 | + return '$("#'.$this->identifier.'").progress("decrement");'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | $percent=JArray::getDefaultValue($array, "percent", $percent); |
99 | 99 | $ratio=JArray::getDefaultValue($array, "ratio", $ratio); |
100 | 100 | } |
101 | - $this->_params["text"]="%{active : " . \var_export($active, true) . ",error: " . \var_export($error, true) . ",success : " . \var_export($success, true) . ",warning : " . \var_export($warning, true) . ",percent : " . \var_export($percent, true) . ",ratio : " . \var_export($ratio, true) . "}%"; |
|
101 | + $this->_params["text"]="%{active : ".\var_export($active, true).",error: ".\var_export($error, true).",success : ".\var_export($success, true).",warning : ".\var_export($warning, true).",percent : ".\var_export($percent, true).",ratio : ".\var_export($ratio, true)."}%"; |
|
102 | 102 | return $this; |
103 | 103 | } |
104 | 104 | |
105 | 105 | public function onChange($jsCode) { |
106 | - return $this->_params["onChange"]="%function(percent, value, total){" . $jsCode . "}%"; |
|
106 | + return $this->_params["onChange"]="%function(percent, value, total){".$jsCode."}%"; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /* |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @see BaseHtml::run() |
112 | 112 | */ |
113 | 113 | public function run(JsUtils $js) { |
114 | - if (isset($this->_bsComponent) === false) |
|
115 | - $this->_bsComponent=$js->semantic()->progress("#" . $this->identifier, $this->_params); |
|
114 | + if (isset($this->_bsComponent)===false) |
|
115 | + $this->_bsComponent=$js->semantic()->progress("#".$this->identifier, $this->_params); |
|
116 | 116 | $this->addEventsOnRun($js); |
117 | 117 | return $this->_bsComponent; |
118 | 118 | } |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | protected $_contentSeparator=""; |
26 | 26 | |
27 | 27 | |
28 | - public function __construct($identifier,$tagName,$baseClass){ |
|
29 | - parent::__construct($identifier,$tagName,$baseClass); |
|
28 | + public function __construct($identifier, $tagName, $baseClass) { |
|
29 | + parent::__construct($identifier, $tagName, $baseClass); |
|
30 | 30 | $this->root=""; |
31 | 31 | $this->attr="data-ajax"; |
32 | 32 | } |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | * @param string $targetSelector the target of the get |
37 | 37 | * @return HtmlNavElement |
38 | 38 | */ |
39 | - public function autoGetOnClick($targetSelector){ |
|
40 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
39 | + public function autoGetOnClick($targetSelector) { |
|
40 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
41 | 41 | } |
42 | 42 | |
43 | - public function contentAsString(){ |
|
43 | + public function contentAsString() { |
|
44 | 44 | return JArray::implode($this->_contentSeparator, $this->content); |
45 | 45 | } |
46 | 46 | |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | * Generate the jquery script to set the elements to the HtmlNavElement |
49 | 49 | * @param JsUtils $jsUtils |
50 | 50 | */ |
51 | - public function jsSetContent(JsUtils $jsUtils){ |
|
52 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
51 | + public function jsSetContent(JsUtils $jsUtils) { |
|
52 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | public function getRoot() { |
56 | 56 | return $this->root; |
57 | 57 | } |
58 | 58 | public function setRoot($root) { |
59 | - $this->root = $root; |
|
59 | + $this->root=$root; |
|
60 | 60 | return $this; |
61 | 61 | } |
62 | 62 | public function getAttr() { |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | * @return HtmlNavElement |
70 | 70 | */ |
71 | 71 | public function setAttr($attr) { |
72 | - $this->attr = $attr; |
|
72 | + $this->attr=$attr; |
|
73 | 73 | return $this; |
74 | 74 | } |
75 | 75 | |
76 | 76 | public function __call($method, $args) { |
77 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
77 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
78 | 78 | return call_user_func_array( |
79 | 79 | $this->$method, |
80 | 80 | $args |
@@ -82,32 +82,32 @@ discard block |
||
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | - abstract public function fromDispatcher(JsUtils $js,$dispatcher, $startIndex=0); |
|
85 | + abstract public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0); |
|
86 | 86 | |
87 | 87 | |
88 | - public function setContentDivider($divider,$index=NULL) { |
|
88 | + public function setContentDivider($divider, $index=NULL) { |
|
89 | 89 | $divider="<div class='divider'> {$divider} </div>"; |
90 | 90 | return $this->setDivider($divider, $index); |
91 | 91 | } |
92 | 92 | |
93 | - public function setIconContentDivider($iconContentDivider,$index=NULL) { |
|
93 | + public function setIconContentDivider($iconContentDivider, $index=NULL) { |
|
94 | 94 | $contentDivider="<i class='".$iconContentDivider." icon divider'></i>"; |
95 | 95 | return $this->setDivider($contentDivider, $index); |
96 | 96 | } |
97 | 97 | |
98 | - protected function setDivider($divider,$index){ |
|
99 | - if(isset($index)){ |
|
100 | - if(!\is_array($this->_contentSeparator)) |
|
101 | - $this->_contentSeparator=array_fill (0, $this->count()-1,$this->_contentSeparator); |
|
98 | + protected function setDivider($divider, $index) { |
|
99 | + if (isset($index)) { |
|
100 | + if (!\is_array($this->_contentSeparator)) |
|
101 | + $this->_contentSeparator=array_fill(0, $this->count()-1, $this->_contentSeparator); |
|
102 | 102 | $this->_contentSeparator[$index]=$divider; |
103 | - }else{ |
|
103 | + } else { |
|
104 | 104 | $this->_contentSeparator=$divider; |
105 | 105 | } |
106 | 106 | return $this; |
107 | 107 | } |
108 | 108 | |
109 | - protected function getContentDivider($index){ |
|
110 | - if(\is_array($this->_contentSeparator)){ |
|
109 | + protected function getContentDivider($index) { |
|
110 | + if (\is_array($this->_contentSeparator)) { |
|
111 | 111 | return @$this->_contentSeparator[$index]; |
112 | 112 | } |
113 | 113 | return $this->_contentSeparator; |
@@ -97,10 +97,11 @@ |
||
97 | 97 | |
98 | 98 | protected function setDivider($divider,$index){ |
99 | 99 | if(isset($index)){ |
100 | - if(!\is_array($this->_contentSeparator)) |
|
101 | - $this->_contentSeparator=array_fill (0, $this->count()-1,$this->_contentSeparator); |
|
100 | + if(!\is_array($this->_contentSeparator)) { |
|
101 | + $this->_contentSeparator=array_fill (0, $this->count()-1,$this->_contentSeparator); |
|
102 | + } |
|
102 | 103 | $this->_contentSeparator[$index]=$divider; |
103 | - }else{ |
|
104 | + } else{ |
|
104 | 105 | $this->_contentSeparator=$divider; |
105 | 106 | } |
106 | 107 | return $this; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | $state=\explode(" ", $state); |
14 | 14 | } |
15 | 15 | if (\is_array($elements)) { |
16 | - foreach ( $elements as $element ) { |
|
16 | + foreach ($elements as $element) { |
|
17 | 17 | if ($element instanceof BaseHtml) { |
18 | 18 | self::_add($state, $element); |
19 | 19 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | private static function _add($states, $element) { |
25 | - foreach ( $states as $state ) { |
|
26 | - $element->addToPropertyCtrl("class", $state, array ($state )); |
|
25 | + foreach ($states as $state) { |
|
26 | + $element->addToPropertyCtrl("class", $state, array($state)); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class HtmlForm extends HtmlSemCollection { |
22 | 22 | |
23 | - use FieldsTrait,FormTrait; |
|
23 | + use FieldsTrait, FormTrait; |
|
24 | 24 | /** |
25 | 25 | * @var array |
26 | 26 | */ |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct($identifier, $elements=array()) { |
35 | 35 | parent::__construct($identifier, "form", "ui form"); |
36 | - $this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ]; |
|
36 | + $this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED]; |
|
37 | 37 | $this->setProperty("name", $this->identifier); |
38 | - $this->_fields=array (); |
|
38 | + $this->_fields=array(); |
|
39 | 39 | $this->_validationParams=[]; |
40 | 40 | $this->addItems($elements); |
41 | 41 | } |
42 | 42 | |
43 | - protected function getForm(){ |
|
43 | + protected function getForm() { |
|
44 | 44 | return $this; |
45 | 45 | } |
46 | 46 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param string $caption |
62 | 62 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
63 | 63 | */ |
64 | - public function addDivider($caption=NULL){ |
|
65 | - return $this->addContent(new HtmlDivider("",$caption)); |
|
64 | + public function addDivider($caption=NULL) { |
|
65 | + return $this->addContent(new HtmlDivider("", $caption)); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | public function addFields($fields=NULL, $label=NULL) { |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $label=NULL; |
79 | 79 | } |
80 | 80 | $this->_fields=\array_merge($this->_fields, $fields); |
81 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
|
81 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
82 | 82 | } |
83 | 83 | if (isset($label)) |
84 | 84 | $fields=new HtmlFormField("", $fields, $label); |
85 | 85 | } else { |
86 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
|
86 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
|
87 | 87 | } |
88 | 88 | $this->addItem($fields); |
89 | 89 | return $fields; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | public function addItem($item) { |
93 | 93 | $item=parent::addItem($item); |
94 | - if (\is_subclass_of($item, HtmlFormField::class) === true) { |
|
94 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
95 | 95 | $this->_fields[]=$item; |
96 | 96 | } |
97 | 97 | return $item; |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | return $this->addItem($message); |
144 | 144 | } |
145 | 145 | |
146 | - private function addCompoValidation($js,$compo,$field){ |
|
146 | + private function addCompoValidation($js, $compo, $field) { |
|
147 | 147 | $validation=$field->getValidation(); |
148 | - if(isset($validation)){ |
|
149 | - if(isset($compo)===false){ |
|
148 | + if (isset($validation)) { |
|
149 | + if (isset($compo)===false) { |
|
150 | 150 | $compo=$js->semantic()->form("#".$this->identifier); |
151 | 151 | } |
152 | 152 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
@@ -155,38 +155,38 @@ discard block |
||
155 | 155 | return $compo; |
156 | 156 | } |
157 | 157 | |
158 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
159 | - if(\sizeof($this->_validationParams)>0) |
|
158 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
159 | + if (\sizeof($this->_validationParams)>0) |
|
160 | 160 | $this->setProperty("novalidate", ""); |
161 | - return parent::compile($js,$view); |
|
161 | + return parent::compile($js, $view); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | public function run(JsUtils $js) { |
165 | 165 | $compo=NULL; |
166 | - foreach ($this->_fields as $field){ |
|
167 | - if($field instanceof HtmlFormField) |
|
166 | + foreach ($this->_fields as $field) { |
|
167 | + if ($field instanceof HtmlFormField) |
|
168 | 168 | $compo=$this->addCompoValidation($js, $compo, $field); |
169 | 169 | } |
170 | - foreach ($this->content as $field){ |
|
171 | - if($field instanceof HtmlFormFields){ |
|
170 | + foreach ($this->content as $field) { |
|
171 | + if ($field instanceof HtmlFormFields) { |
|
172 | 172 | $items=$field->getItems(); |
173 | - foreach ($items as $_field){ |
|
174 | - if($_field instanceof HtmlFormField) |
|
173 | + foreach ($items as $_field) { |
|
174 | + if ($_field instanceof HtmlFormField) |
|
175 | 175 | $compo=$this->addCompoValidation($js, $compo, $_field); |
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
179 | - if(isset($compo)===false){ |
|
179 | + if (isset($compo)===false) { |
|
180 | 180 | return parent::run($js); |
181 | 181 | } |
182 | - $this->_runValidationParams($compo,$js); |
|
182 | + $this->_runValidationParams($compo, $js); |
|
183 | 183 | return $this->_bsComponent; |
184 | 184 | } |
185 | 185 | |
186 | - private function _runValidationParams(&$compo,JsUtils $js=NULL){ |
|
187 | - if(isset($this->_validationParams["_ajaxSubmit"]) && $this->_validationParams["_ajaxSubmit"] instanceof AjaxCall){ |
|
186 | + private function _runValidationParams(&$compo, JsUtils $js=NULL) { |
|
187 | + if (isset($this->_validationParams["_ajaxSubmit"]) && $this->_validationParams["_ajaxSubmit"] instanceof AjaxCall) { |
|
188 | 188 | $compilation=$this->_validationParams["_ajaxSubmit"]->compile($js); |
189 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
189 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
190 | 190 | $this->onSuccess($compilation); |
191 | 191 | unset($this->_validationParams["_ajaxSubmit"]); |
192 | 192 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $this->addEventsOnRun($js); |
196 | 196 | } |
197 | 197 | |
198 | - public function addValidationParam($paramName,$paramValue){ |
|
198 | + public function addValidationParam($paramName, $paramValue) { |
|
199 | 199 | $this->_validationParams[$paramName]=$paramValue; |
200 | 200 | return $this; |
201 | 201 | } |
@@ -18,43 +18,43 @@ discard block |
||
18 | 18 | * @property mixed _modelInstance |
19 | 19 | */ |
20 | 20 | |
21 | -trait FieldAsTrait{ |
|
21 | +trait FieldAsTrait { |
|
22 | 22 | |
23 | 23 | abstract protected function _getFieldIdentifier($prefix); |
24 | - abstract public function setValueFunction($index,$callback); |
|
24 | + abstract public function setValueFunction($index, $callback); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @param HtmlFormField $element |
28 | 28 | * @param array $attributes |
29 | 29 | */ |
30 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
30 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
31 | 31 | $this->_addRules($element, $attributes); |
32 | - if(isset($attributes["callback"])){ |
|
32 | + if (isset($attributes["callback"])) { |
|
33 | 33 | $callback=$attributes["callback"]; |
34 | - if(\is_callable($callback)){ |
|
35 | - $callback($element,$this->_modelInstance,$index); |
|
34 | + if (\is_callable($callback)) { |
|
35 | + $callback($element, $this->_modelInstance, $index); |
|
36 | 36 | unset($attributes["callback"]); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | $element->fromArray($attributes); |
40 | 40 | } |
41 | 41 | |
42 | - private function _getLabelField($caption,$icon=NULL){ |
|
43 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
42 | + private function _getLabelField($caption, $icon=NULL) { |
|
43 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
44 | 44 | return $label; |
45 | 45 | } |
46 | 46 | |
47 | - protected function _addRules($element,&$attributes){} |
|
47 | + protected function _addRules($element, &$attributes) {} |
|
48 | 48 | |
49 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
|
50 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
|
49 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) { |
|
50 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){ |
|
51 | 51 | $name=$this->_instanceViewer->getCaption($index)."[]"; |
52 | - if(isset($attributes["name"])){ |
|
52 | + if (isset($attributes["name"])) { |
|
53 | 53 | $name=$attributes["name"]; |
54 | 54 | } |
55 | - $element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,""); |
|
56 | - if(\is_array($attributes)) |
|
57 | - $this->_applyAttributes($element, $attributes,$index); |
|
55 | + $element=$elementCallback($this->_getFieldIdentifier($prefix), $name, $value, ""); |
|
56 | + if (\is_array($attributes)) |
|
57 | + $this->_applyAttributes($element, $attributes, $index); |
|
58 | 58 | $element->setDisabled(!$this->_edition); |
59 | 59 | return $element; |
60 | 60 | }); |
@@ -62,94 +62,94 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
66 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
67 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
65 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
66 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
67 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
68 | 68 | return $pb; |
69 | 69 | }); |
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
74 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
75 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
73 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
74 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
75 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
76 | 76 | return $rating; |
77 | 77 | }); |
78 | 78 | return $this; |
79 | 79 | } |
80 | 80 | |
81 | - public function fieldAsLabel($index,$icon=NULL){ |
|
82 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
83 | - $lbl=$this->_getLabelField($caption,$icon); |
|
81 | + public function fieldAsLabel($index, $icon=NULL) { |
|
82 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
83 | + $lbl=$this->_getLabelField($caption, $icon); |
|
84 | 84 | return $lbl; |
85 | 85 | }); |
86 | 86 | return $this; |
87 | 87 | } |
88 | 88 | |
89 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
90 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
91 | - $header=new HtmlHeader($id,$niveau,$value); |
|
92 | - if(isset($icon)) |
|
89 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
90 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
91 | + $header=new HtmlHeader($id, $niveau, $value); |
|
92 | + if (isset($icon)) |
|
93 | 93 | $header->asIcon($icon, $value); |
94 | 94 | return $header; |
95 | - }, $index,$attributes,"header"); |
|
95 | + }, $index, $attributes, "header"); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
99 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
100 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
101 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
99 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
100 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
101 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
102 | 102 | return $image; |
103 | 103 | }); |
104 | 104 | return $this; |
105 | 105 | } |
106 | 106 | |
107 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
108 | - return $this->_fieldAs(function($id,$name,$value){ |
|
109 | - $img=new HtmlImage($id,$value); |
|
107 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
108 | + return $this->_fieldAs(function($id, $name, $value) { |
|
109 | + $img=new HtmlImage($id, $value); |
|
110 | 110 | $img->asAvatar(); |
111 | 111 | return $img; |
112 | - }, $index,$attributes,"avatar"); |
|
112 | + }, $index, $attributes, "avatar"); |
|
113 | 113 | } |
114 | 114 | |
115 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
116 | - return $this->_fieldAs(function($id,$name,$value){ |
|
117 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
115 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
116 | + return $this->_fieldAs(function($id, $name, $value) { |
|
117 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
118 | 118 | return $input; |
119 | - }, $index,$attributes,"radio"); |
|
119 | + }, $index, $attributes, "radio"); |
|
120 | 120 | } |
121 | 121 | |
122 | - public function fieldAsInput($index,$attributes=NULL){ |
|
123 | - return $this->_fieldAs(function($id,$name,$value){ |
|
124 | - $input= new HtmlInput($id,"text",$value); |
|
122 | + public function fieldAsInput($index, $attributes=NULL) { |
|
123 | + return $this->_fieldAs(function($id, $name, $value) { |
|
124 | + $input=new HtmlInput($id, "text", $value); |
|
125 | 125 | //TODO check getField |
126 | 126 | $input->setName($name); |
127 | 127 | return $input; |
128 | - }, $index,$attributes,"input"); |
|
128 | + }, $index, $attributes, "input"); |
|
129 | 129 | } |
130 | 130 | |
131 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
132 | - if(!\is_array($attributes)){ |
|
131 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
132 | + if (!\is_array($attributes)) { |
|
133 | 133 | $attributes=[]; |
134 | 134 | } |
135 | 135 | $attributes["imputType"]="hidden"; |
136 | - return $this->fieldAsInput($index,$attributes); |
|
136 | + return $this->fieldAsInput($index, $attributes); |
|
137 | 137 | } |
138 | 138 | |
139 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
140 | - return $this->_fieldAs(function($id,$name,$value){ |
|
141 | - $input=new HtmlCheckbox($id,"",$this->_instanceViewer->getIdentifier()); |
|
139 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
140 | + return $this->_fieldAs(function($id, $name, $value) { |
|
141 | + $input=new HtmlCheckbox($id, "", $this->_instanceViewer->getIdentifier()); |
|
142 | 142 | $input->setChecked(JString::isBooleanTrue($value)); |
143 | 143 | $input->getField()->setProperty("name", $name); |
144 | 144 | return $input; |
145 | - }, $index,$attributes,"ck"); |
|
145 | + }, $index, $attributes, "ck"); |
|
146 | 146 | } |
147 | 147 | |
148 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
149 | - return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){ |
|
150 | - $dd=new HtmlDropdown($id,$value,$elements); |
|
151 | - $dd->asSelect($name,$multiple); |
|
148 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
149 | + return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){ |
|
150 | + $dd=new HtmlDropdown($id, $value, $elements); |
|
151 | + $dd->asSelect($name, $multiple); |
|
152 | 152 | return $dd; |
153 | - }, $index,$attributes,"dd"); |
|
153 | + }, $index, $attributes, "dd"); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | \ No newline at end of file |
@@ -8,34 +8,34 @@ discard block |
||
8 | 8 | private $page_count; |
9 | 9 | private $pages_visibles; |
10 | 10 | |
11 | - public function __construct($items_per_page=10,$pages_visibles=4,$page=1){ |
|
11 | + public function __construct($items_per_page=10, $pages_visibles=4, $page=1) { |
|
12 | 12 | $this->items_per_page=$items_per_page; |
13 | 13 | $this->page=$page; |
14 | 14 | $this->pages_visibles=$pages_visibles; |
15 | 15 | $this->visible=true; |
16 | 16 | } |
17 | 17 | |
18 | - public function getObjects($objects){ |
|
19 | - $offset = ($this->page - 1) * $this->items_per_page; |
|
18 | + public function getObjects($objects) { |
|
19 | + $offset=($this->page-1)*$this->items_per_page; |
|
20 | 20 | $os=$objects; |
21 | - if(!\is_array($os)){ |
|
21 | + if (!\is_array($os)) { |
|
22 | 22 | $os=[]; |
23 | - foreach ($objects as $o){ |
|
23 | + foreach ($objects as $o) { |
|
24 | 24 | $os[]=$o; |
25 | 25 | } |
26 | 26 | } |
27 | - $this->page_count = 0; |
|
27 | + $this->page_count=0; |
|
28 | 28 | $row_count=\sizeof($os); |
29 | - if (0 === $row_count) { |
|
29 | + if (0===$row_count) { |
|
30 | 30 | $this->visible=false; |
31 | 31 | } else { |
32 | 32 | $this->visible=true; |
33 | - $this->page_count = (int)ceil($row_count / $this->items_per_page); |
|
34 | - if($this->page > $this->page_count+1) { |
|
35 | - $this->page = 1; |
|
33 | + $this->page_count=(int)ceil($row_count/$this->items_per_page); |
|
34 | + if ($this->page>$this->page_count+1) { |
|
35 | + $this->page=1; |
|
36 | 36 | } |
37 | 37 | } |
38 | - return array_slice($os, $offset,$this->items_per_page); |
|
38 | + return array_slice($os, $offset, $this->items_per_page); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function getItemsPerPage() { |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | return $this->page_count; |
70 | 70 | } |
71 | 71 | |
72 | - public function getPagesNumbers(){ |
|
73 | - $middle= (int)ceil(($this->pages_visibles-1)/ 2); |
|
72 | + public function getPagesNumbers() { |
|
73 | + $middle=(int)ceil(($this->pages_visibles-1)/2); |
|
74 | 74 | $first=$this->page-$middle; |
75 | - if($first<1){ |
|
75 | + if ($first<1) { |
|
76 | 76 | $first=1; |
77 | 77 | } |
78 | 78 | $last=$first+$this->pages_visibles-1; |
79 | - if($last>$this->page_count){ |
|
79 | + if ($last>$this->page_count) { |
|
80 | 80 | $last=$this->page_count; |
81 | 81 | } |
82 | 82 | return \range($first, $last); |