@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * @version 1.3 |
16 | 16 | */ |
17 | 17 | abstract class BaseHtml extends BaseWidget { |
18 | - use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait; |
|
18 | + use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait; |
|
19 | 19 | protected $_template; |
20 | 20 | protected $tagName; |
21 | - protected $_wrapBefore=array (); |
|
22 | - protected $_wrapAfter=array (); |
|
21 | + protected $_wrapBefore=array(); |
|
22 | + protected $_wrapAfter=array(); |
|
23 | 23 | protected $_bsComponent; |
24 | 24 | protected $_compiled=false; |
25 | 25 | protected $_postCompile; |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | */ |
33 | 33 | abstract public function run(JsUtils $js); |
34 | 34 | |
35 | - private function _callSetter($setter,$key,$value,&$array){ |
|
35 | + private function _callSetter($setter, $key, $value, &$array) { |
|
36 | 36 | $result=false; |
37 | - if (method_exists($this, $setter) && substr($setter, 0, 1) !== "_") { |
|
37 | + if (method_exists($this, $setter) && substr($setter, 0, 1)!=="_") { |
|
38 | 38 | try { |
39 | 39 | $this->$setter($value); |
40 | 40 | unset($array[$key]); |
41 | 41 | $result=true; |
42 | - } catch ( \Exception $e ) { |
|
42 | + }catch (\Exception $e) { |
|
43 | 43 | $result=false; |
44 | 44 | } |
45 | 45 | } |
@@ -47,17 +47,17 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | protected function getTemplate(JsUtils $js=NULL) { |
50 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
50 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | protected function ctrl($name, $value, $typeCtrl) { |
54 | 54 | if (\is_array($typeCtrl)) { |
55 | - if (array_search($value, $typeCtrl) === false) { |
|
56 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
55 | + if (array_search($value, $typeCtrl)===false) { |
|
56 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
57 | 57 | } |
58 | 58 | } else { |
59 | 59 | if (!$typeCtrl($value)) { |
60 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
60 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | return true; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
75 | 75 | if (\is_array($typeCtrl)) { |
76 | 76 | $this->removeOldValues($name, $typeCtrl); |
77 | - $name.=$separator . $value; |
|
77 | + $name.=$separator.$value; |
|
78 | 78 | } |
79 | 79 | return $this; |
80 | 80 | } |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | if (\is_array($typeCtrl)) { |
87 | 87 | $this->removeOldValues($name, $typeCtrl); |
88 | 88 | } |
89 | - $name.=$separator . $value; |
|
89 | + $name.=$separator.$value; |
|
90 | 90 | return $this; |
91 | 91 | } |
92 | 92 | |
93 | 93 | protected function addToMember(&$name, $value, $separator=" ") { |
94 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
94 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
@@ -102,18 +102,18 @@ discard block |
||
102 | 102 | $oldValue=trim($oldValue); |
103 | 103 | } |
104 | 104 | |
105 | - protected function _getElementBy($callback,$elements){ |
|
105 | + protected function _getElementBy($callback, $elements) { |
|
106 | 106 | if (\is_array($elements)) { |
107 | 107 | $elements=\array_values($elements); |
108 | 108 | $flag=false; |
109 | 109 | $index=0; |
110 | - while ( !$flag && $index < sizeof($elements) ) { |
|
110 | + while (!$flag && $index<sizeof($elements)) { |
|
111 | 111 | if ($elements[$index] instanceof BaseHtml) |
112 | 112 | $flag=($callback($elements[$index])); |
113 | 113 | $index++; |
114 | 114 | } |
115 | - if ($flag === true) |
|
116 | - return $elements[$index - 1]; |
|
115 | + if ($flag===true) |
|
116 | + return $elements[$index-1]; |
|
117 | 117 | } elseif ($elements instanceof BaseHtml) { |
118 | 118 | if ($callback($elements)) |
119 | 119 | return $elements; |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | public function fromArray($array) { |
144 | - foreach ( $this as $key => $value ) { |
|
145 | - if(array_key_exists($key, $array)===true) |
|
146 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
144 | + foreach ($this as $key => $value) { |
|
145 | + if (array_key_exists($key, $array)===true) |
|
146 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
147 | 147 | } |
148 | - foreach ( $array as $key => $value ) { |
|
149 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
150 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
148 | + foreach ($array as $key => $value) { |
|
149 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
150 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | return $array; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | public function fromDatabaseObjects($objects, $function) { |
157 | 157 | if (isset($objects)) { |
158 | - foreach ( $objects as $object ) { |
|
158 | + foreach ($objects as $object) { |
|
159 | 159 | $this->fromDatabaseObject($object, $function); |
160 | 160 | } |
161 | 161 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | |
178 | 178 | public function getElementById($identifier, $elements) { |
179 | - return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements); |
|
179 | + return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | public function getBsComponent() { |
@@ -189,14 +189,14 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
192 | - if(!$this->_compiled){ |
|
193 | - if(isset($js)){ |
|
192 | + if (!$this->_compiled) { |
|
193 | + if (isset($js)) { |
|
194 | 194 | $beforeCompile=$js->getParam("beforeCompileHtml"); |
195 | - if(\is_callable($beforeCompile)){ |
|
196 | - $beforeCompile($this,$js,$view); |
|
195 | + if (\is_callable($beforeCompile)) { |
|
196 | + $beforeCompile($this, $js, $view); |
|
197 | 197 | } |
198 | 198 | } |
199 | - if(\is_callable($this->_preCompile)){ |
|
199 | + if (\is_callable($this->_preCompile)) { |
|
200 | 200 | $pc=$this->_preCompile; |
201 | 201 | $pc($this); |
202 | 202 | } |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
209 | - $this->compile_once($js,$view); |
|
209 | + $this->compile_once($js, $view); |
|
210 | 210 | $result=$this->getTemplate($js); |
211 | - foreach ( $this as $key => $value ) { |
|
212 | - if(\strstr($result, "%{$key}%")!==false){ |
|
211 | + foreach ($this as $key => $value) { |
|
212 | + if (\strstr($result, "%{$key}%")!==false) { |
|
213 | 213 | if (\is_array($value)) { |
214 | 214 | $v=PropertyWrapper::wrap($value, $js); |
215 | - }elseif($value instanceof \stdClass){ |
|
216 | - $v=\print_r($value,true); |
|
217 | - }else{ |
|
215 | + }elseif ($value instanceof \stdClass) { |
|
216 | + $v=\print_r($value, true); |
|
217 | + } else { |
|
218 | 218 | $v=$value; |
219 | 219 | } |
220 | 220 | $result=str_replace("%{$key}%", $v, $result); |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | } |
223 | 223 | if (isset($js)===true) { |
224 | 224 | $this->run($js); |
225 | - if (isset($view) === true) { |
|
225 | + if (isset($view)===true) { |
|
226 | 226 | $js->addViewElement($this->_identifier, $result, $view); |
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | - if(\is_callable($this->_postCompile)){ |
|
230 | + if (\is_callable($this->_postCompile)) { |
|
231 | 231 | $pc=$this->_postCompile; |
232 | 232 | $pc($this); |
233 | 233 | } |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | * @param array $parameters default: ["jsCallback"=>"","jqueryDone"=>"append"] |
242 | 242 | * @return \Ajax\common\html\BaseHtml |
243 | 243 | */ |
244 | - public function setDraggable($attr="id",$dropZone=null,$parameters=[]){ |
|
244 | + public function setDraggable($attr="id", $dropZone=null, $parameters=[]) { |
|
245 | 245 | $this->setProperty("draggable", "true"); |
246 | - $this->addEvent("dragstart",Javascript::draggable($attr)); |
|
247 | - if(isset($dropZone)&& $dropZone instanceof BaseHtml){ |
|
248 | - $jqueryDone="append";$jsCallback=""; |
|
246 | + $this->addEvent("dragstart", Javascript::draggable($attr)); |
|
247 | + if (isset($dropZone) && $dropZone instanceof BaseHtml) { |
|
248 | + $jqueryDone="append"; $jsCallback=""; |
|
249 | 249 | extract($parameters); |
250 | - $dropZone->asDropZone($jsCallback,$jqueryDone,$parameters); |
|
250 | + $dropZone->asDropZone($jsCallback, $jqueryDone, $parameters); |
|
251 | 251 | } |
252 | 252 | return $this; |
253 | 253 | } |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | * @param array $parameters |
260 | 260 | * @return \Ajax\common\html\BaseHtml |
261 | 261 | */ |
262 | - public function asDropZone($jsCallback="",$jqueryDone="append",$parameters=[]){ |
|
262 | + public function asDropZone($jsCallback="", $jqueryDone="append", $parameters=[]) { |
|
263 | 263 | $stopPropagation=false; |
264 | - $this->addEvent("dragover", '', $stopPropagation,true); |
|
264 | + $this->addEvent("dragover", '', $stopPropagation, true); |
|
265 | 265 | extract($parameters); |
266 | - $this->addEvent("drop",Javascript::dropZone($jqueryDone,$jsCallback),$stopPropagation,true); |
|
266 | + $this->addEvent("drop", Javascript::dropZone($jqueryDone, $jsCallback), $stopPropagation, true); |
|
267 | 267 | return $this; |
268 | 268 | } |
269 | 269 | |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | return $this->compile(); |
272 | 272 | } |
273 | 273 | |
274 | - public function onPostCompile($callback){ |
|
274 | + public function onPostCompile($callback) { |
|
275 | 275 | $this->_postCompile=$callback; |
276 | 276 | } |
277 | 277 | |
278 | - public function onPreCompile($callback){ |
|
278 | + public function onPreCompile($callback) { |
|
279 | 279 | $this->_preCompile=$callback; |
280 | 280 | } |
281 | 281 | } |
@@ -14,44 +14,44 @@ discard block |
||
14 | 14 | */ |
15 | 15 | abstract class HtmlCollection extends HtmlDoubleElement { |
16 | 16 | |
17 | - public function __construct($identifier,$tagName="div"){ |
|
18 | - parent::__construct($identifier,$tagName); |
|
17 | + public function __construct($identifier, $tagName="div") { |
|
18 | + parent::__construct($identifier, $tagName); |
|
19 | 19 | $this->content=array(); |
20 | 20 | } |
21 | 21 | |
22 | - public function addItems($items){ |
|
23 | - if(JArray::isAssociative($items)){ |
|
24 | - foreach ($items as $k=>$v){ |
|
25 | - $this->addItem([$k,$v]); |
|
22 | + public function addItems($items) { |
|
23 | + if (JArray::isAssociative($items)) { |
|
24 | + foreach ($items as $k=>$v) { |
|
25 | + $this->addItem([$k, $v]); |
|
26 | 26 | } |
27 | - }else{ |
|
28 | - foreach ($items as $item){ |
|
27 | + } else { |
|
28 | + foreach ($items as $item) { |
|
29 | 29 | $this->addItem($item); |
30 | 30 | } |
31 | 31 | } |
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | - public function setItems($items){ |
|
35 | + public function setItems($items) { |
|
36 | 36 | $this->content=$items; |
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | - public function getItems(){ |
|
40 | + public function getItems() { |
|
41 | 41 | return $this->content; |
42 | 42 | } |
43 | 43 | |
44 | - protected function getItemToAdd($item){ |
|
44 | + protected function getItemToAdd($item) { |
|
45 | 45 | $itemO=$item; |
46 | - if($this->createCondition($item)===true){ |
|
46 | + if ($this->createCondition($item)===true) { |
|
47 | 47 | $itemO=$this->createItem($item); |
48 | 48 | } |
49 | 49 | return $itemO; |
50 | 50 | } |
51 | 51 | |
52 | - protected function setItemIdentifier($item,$classname,$index){ |
|
53 | - if($item instanceof BaseWidget){ |
|
54 | - if(JString::isNull($item->getIdentifier())){ |
|
52 | + protected function setItemIdentifier($item, $classname, $index) { |
|
53 | + if ($item instanceof BaseWidget) { |
|
54 | + if (JString::isNull($item->getIdentifier())) { |
|
55 | 55 | $item->setIdentifier($classname."-".$this->identifier."-".$index); |
56 | 56 | } |
57 | 57 | } |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | * @param HtmlDoubleElement|string|array $item |
63 | 63 | * @return \Ajax\common\html\HtmlDoubleElement |
64 | 64 | */ |
65 | - public function addItem($item){ |
|
65 | + public function addItem($item) { |
|
66 | 66 | $itemO=$this->getItemToAdd($item); |
67 | 67 | $this->addContent($itemO); |
68 | 68 | return $itemO; |
69 | 69 | } |
70 | 70 | |
71 | - public function insertItem($item,$position=0){ |
|
71 | + public function insertItem($item, $position=0) { |
|
72 | 72 | $itemO=$this->getItemToAdd($item); |
73 | - \array_splice( $this->content, $position, 0, array($itemO)); |
|
73 | + \array_splice($this->content, $position, 0, array($itemO)); |
|
74 | 74 | return $itemO; |
75 | 75 | } |
76 | 76 | |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | return $this; |
94 | 94 | } |
95 | 95 | |
96 | - public function removeItem($index){ |
|
96 | + public function removeItem($index) { |
|
97 | 97 | return array_splice($this->content, $index, 1); |
98 | 98 | } |
99 | 99 | |
100 | - public function count(){ |
|
100 | + public function count() { |
|
101 | 101 | return \sizeof($this->content); |
102 | 102 | } |
103 | 103 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | return $this->addItem($function($object)); |
109 | 109 | } |
110 | 110 | |
111 | - public function apply($callBack){ |
|
112 | - foreach ($this->content as $item){ |
|
111 | + public function apply($callBack) { |
|
112 | + foreach ($this->content as $item) { |
|
113 | 113 | $callBack($item); |
114 | 114 | } |
115 | 115 | return $this; |
@@ -129,23 +129,23 @@ discard block |
||
129 | 129 | */ |
130 | 130 | abstract protected function createItem($value); |
131 | 131 | |
132 | - protected function createCondition($value){ |
|
132 | + protected function createCondition($value) { |
|
133 | 133 | return \is_object($value)===false; |
134 | 134 | } |
135 | 135 | |
136 | - protected function contentAs($tagName){ |
|
137 | - foreach ($this->content as $item){ |
|
136 | + protected function contentAs($tagName) { |
|
137 | + foreach ($this->content as $item) { |
|
138 | 138 | $item->setTagName($tagName); |
139 | 139 | } |
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - public function setProperties($properties){ |
|
143 | + public function setProperties($properties) { |
|
144 | 144 | $i=0; |
145 | - foreach ($properties as $k=>$v){ |
|
145 | + foreach ($properties as $k=>$v) { |
|
146 | 146 | $c=$this->content[$i++]; |
147 | - if(isset($c)) |
|
148 | - $c->setProperty($k,$v); |
|
147 | + if (isset($c)) |
|
148 | + $c->setProperty($k, $v); |
|
149 | 149 | else |
150 | 150 | return $this; |
151 | 151 | } |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | * @param array|mixed $values |
159 | 159 | * @return $this |
160 | 160 | */ |
161 | - public function setPropertyValues($property,$values){ |
|
161 | + public function setPropertyValues($property, $values) { |
|
162 | 162 | $i=0; |
163 | - if(\is_array($values)===false){ |
|
164 | - $values=\array_fill(0, $this->count(),$values); |
|
163 | + if (\is_array($values)===false) { |
|
164 | + $values=\array_fill(0, $this->count(), $values); |
|
165 | 165 | } |
166 | - foreach ($values as $value){ |
|
166 | + foreach ($values as $value) { |
|
167 | 167 | $c=$this->content[$i++]; |
168 | - if(isset($c)){ |
|
169 | - $c->setProperty($property,$value); |
|
168 | + if (isset($c)) { |
|
169 | + $c->setProperty($property, $value); |
|
170 | 170 | } |
171 | - else{ |
|
171 | + else { |
|
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | } |
@@ -181,17 +181,17 @@ discard block |
||
181 | 181 | * @param array|mixed $values |
182 | 182 | * @return $this |
183 | 183 | */ |
184 | - public function addPropertyValues($property,$values){ |
|
184 | + public function addPropertyValues($property, $values) { |
|
185 | 185 | $i=0; |
186 | - if(\is_array($values)===false){ |
|
187 | - $values=\array_fill(0, $this->count(),$values); |
|
186 | + if (\is_array($values)===false) { |
|
187 | + $values=\array_fill(0, $this->count(), $values); |
|
188 | 188 | } |
189 | - foreach ($values as $value){ |
|
189 | + foreach ($values as $value) { |
|
190 | 190 | $c=$this->content[$i++]; |
191 | - if(isset($c)){ |
|
192 | - $c->addToProperty($property,$value); |
|
191 | + if (isset($c)) { |
|
192 | + $c->addToProperty($property, $value); |
|
193 | 193 | } |
194 | - else{ |
|
194 | + else { |
|
195 | 195 | return $this; |
196 | 196 | } |
197 | 197 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
202 | 202 | $index=0; |
203 | 203 | $classname=\strtolower(JReflection::shortClassName($this)); |
204 | - foreach ($this->content as $item){ |
|
205 | - $this->setItemIdentifier($item,$classname,$index++); |
|
204 | + foreach ($this->content as $item) { |
|
205 | + $this->setItemIdentifier($item, $classname, $index++); |
|
206 | 206 | } |
207 | - return parent::compile($js,$view); |
|
207 | + return parent::compile($js, $view); |
|
208 | 208 | } |
209 | 209 | |
210 | - public function getItemById($identifier){ |
|
210 | + public function getItemById($identifier) { |
|
211 | 211 | return $this->getElementById($identifier, $this->content); |
212 | 212 | } |
213 | 213 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * @param string $target |
217 | 217 | * @return HtmlCollection |
218 | 218 | */ |
219 | - public function asLinks($hrefs=[],$target=NUll) { |
|
220 | - foreach ( $this->content as $index=>$item ) { |
|
221 | - if($item instanceof HtmlDoubleElement){ |
|
219 | + public function asLinks($hrefs=[], $target=NUll) { |
|
220 | + foreach ($this->content as $index=>$item) { |
|
221 | + if ($item instanceof HtmlDoubleElement) { |
|
222 | 222 | $href=""; |
223 | - if(isset($hrefs[$index])) |
|
223 | + if (isset($hrefs[$index])) |
|
224 | 224 | $href=$hrefs[$index]; |
225 | - $item->asLink($href,$target); |
|
225 | + $item->asLink($href, $target); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | return $this; |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | abstract class HtmlViewItem extends HtmlSemDoubleElement { |
17 | 17 | use ContentPartTrait; |
18 | 18 | |
19 | - public function __construct($identifier,$baseClass,$content=NULL) { |
|
19 | + public function __construct($identifier, $baseClass, $content=NULL) { |
|
20 | 20 | parent::__construct($identifier, "div", $baseClass); |
21 | 21 | $this->content=["content"=>new HtmlViewContent("content-".$this->identifier)]; |
22 | - if(isset($content)) |
|
22 | + if (isset($content)) |
|
23 | 23 | $this->setContent($content); |
24 | 24 | } |
25 | 25 | |
26 | - public function setContent($value){ |
|
26 | + public function setContent($value) { |
|
27 | 27 | if (\is_array($value)) { |
28 | 28 | $image=JArray::getValue($value, "image", 0); |
29 | 29 | $content=JArray::getValue($value, "content", 1); |
@@ -31,57 +31,57 @@ discard block |
||
31 | 31 | if (isset($image)) { |
32 | 32 | $this->addImage($image); |
33 | 33 | } |
34 | - if(isset($content)) |
|
34 | + if (isset($content)) |
|
35 | 35 | $this->content["content"]->setContent($content); |
36 | - if(isset($extra)) |
|
36 | + if (isset($extra)) |
|
37 | 37 | $this->addExtraContent($extra); |
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | 41 | private function createContent($content, $baseClass="content") { |
42 | 42 | $count=\sizeof($this->content); |
43 | - $result=new HtmlViewContent("content-" . $count . "-" . $this->identifier, $content); |
|
43 | + $result=new HtmlViewContent("content-".$count."-".$this->identifier, $content); |
|
44 | 44 | $result->setClass($baseClass); |
45 | 45 | return $result; |
46 | 46 | } |
47 | 47 | |
48 | 48 | private function addElementIn($key, $element) { |
49 | - if (\array_key_exists($key, $this->content) === false) { |
|
49 | + if (\array_key_exists($key, $this->content)===false) { |
|
50 | 50 | $this->content[$key]=[]; |
51 | 51 | } |
52 | - if($this->content[$key] instanceof HtmlViewContent) |
|
52 | + if ($this->content[$key] instanceof HtmlViewContent) |
|
53 | 53 | $this->content[$key]->addElement($element); |
54 | 54 | else |
55 | 55 | $this->content[$key][]=$element; |
56 | 56 | return $element; |
57 | 57 | } |
58 | 58 | |
59 | - public function addIcon($icon,$before=true){ |
|
60 | - return $this->addElementIn("icon",new HtmlIcon("icon-" . $this->identifier, $icon)); |
|
59 | + public function addIcon($icon, $before=true) { |
|
60 | + return $this->addElementIn("icon", new HtmlIcon("icon-".$this->identifier, $icon)); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | public function addHeader($header, $niveau=4, $type="page") { |
65 | 65 | if (!$header instanceof HtmlHeader) { |
66 | - $header=new HtmlHeader("header-" . $this->identifier, $niveau, $header, $type); |
|
66 | + $header=new HtmlHeader("header-".$this->identifier, $niveau, $header, $type); |
|
67 | 67 | } |
68 | - return $this->addElementIn("header",$this->createContent($header)); |
|
68 | + return $this->addElementIn("header", $this->createContent($header)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | public function addImage($image, $title="") { |
72 | 72 | if (!$image instanceof HtmlImage) { |
73 | - $image=new HtmlImage("image-" . $this->identifier, $image, $title); |
|
73 | + $image=new HtmlImage("image-".$this->identifier, $image, $title); |
|
74 | 74 | } |
75 | 75 | $image->setClass("ui image"); |
76 | - return $this->content["image"]= $image; |
|
76 | + return $this->content["image"]=$image; |
|
77 | 77 | } |
78 | 78 | |
79 | - public function addReveal($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL,$key="extra-content") { |
|
79 | + public function addReveal($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL, $key="extra-content") { |
|
80 | 80 | $reveal=$visibleContent; |
81 | 81 | if (!$visibleContent instanceof HtmlReveal) { |
82 | - $reveal=new HtmlReveal("reveral-" . $this->identifier, $visibleContent, $hiddenContent, $type, $attributeType); |
|
82 | + $reveal=new HtmlReveal("reveral-".$this->identifier, $visibleContent, $hiddenContent, $type, $attributeType); |
|
83 | 83 | } |
84 | - return $this->content[$key]= $reveal; |
|
84 | + return $this->content[$key]=$reveal; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public function addRevealImage($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL) { |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | if (!$visibleContent instanceof HtmlReveal) { |
90 | 90 | return $this->addReveal(new HtmlImage("", $visibleContent), new HtmlImage("", $hiddenContent), $type, $attributeType); |
91 | 91 | } |
92 | - return $this->content["image"]= $reveal; |
|
92 | + return $this->content["image"]=$reveal; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | public function addExtraContent($content=array()) { |
96 | - return $this->content["extra-content"]= $this->createContent($content, "extra content"); |
|
96 | + return $this->content["extra-content"]=$this->createContent($content, "extra content"); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | * @param boolean $before |
104 | 104 | * @return HtmlButtonGroups |
105 | 105 | */ |
106 | - public function addContentButtons($elements=array(), $asIcons=false,$part="extra",$before=false){ |
|
107 | - return $this->content["content"]->addContentButtons($elements,$asIcons,$part, $before); |
|
106 | + public function addContentButtons($elements=array(), $asIcons=false, $part="extra", $before=false) { |
|
107 | + return $this->content["content"]->addContentButtons($elements, $asIcons, $part, $before); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | 111 | |
112 | - public function addItemHeaderContent($header, $metas=array(), $description=NULL,$extra=NULL) { |
|
113 | - return $this->content["content"]->addHeaderContent($header, $metas, $description,$extra); |
|
112 | + public function addItemHeaderContent($header, $metas=array(), $description=NULL, $extra=NULL) { |
|
113 | + return $this->content["content"]->addHeaderContent($header, $metas, $description, $extra); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | public function addItemContent($content=array()) { |
117 | 117 | $count=\sizeof($this->content); |
118 | - return $this->addElementIn("content", new HtmlViewContent("content-" . $count . "-" . $this->identifier, $content)); |
|
118 | + return $this->addElementIn("content", new HtmlViewContent("content-".$count."-".$this->identifier, $content)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | public function getItemContent() { |
122 | - return $this->getPart("content",null,true); |
|
122 | + return $this->getPart("content", null, true); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | public function getItemExtraContent() { |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | * @see HtmlSemDoubleElement::compile() |
142 | 142 | */ |
143 | 143 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
144 | - $this->content=JArray::sortAssociative($this->content, ["header","image","icon","content","extra-content"]); |
|
144 | + $this->content=JArray::sortAssociative($this->content, ["header", "image", "icon", "content", "extra-content"]); |
|
145 | 145 | return parent::compile($js, $view); |
146 | 146 | } |
147 | 147 | |
148 | - public function asLink($href="",$target=NULL) { |
|
148 | + public function asLink($href="", $target=NULL) { |
|
149 | 149 | $this->addToProperty("class", "link"); |
150 | - if ($href !== "") { |
|
150 | + if ($href!=="") { |
|
151 | 151 | $this->setProperty("href", $href); |
152 | 152 | if (isset($target)) |
153 | 153 | $this->setProperty("target", $target); |
@@ -9,27 +9,27 @@ |
||
9 | 9 | class HtmlMenuItem extends HtmlSemDoubleElement { |
10 | 10 | use MenuItemTrait; |
11 | 11 | public function __construct($identifier, $content) { |
12 | - parent::__construct($identifier,"div","item",$content); |
|
12 | + parent::__construct($identifier, "div", "item", $content); |
|
13 | 13 | } |
14 | 14 | |
15 | - protected function initContent($content){ |
|
16 | - if(\is_array($content)){ |
|
17 | - if(JArray::isAssociative($content)===false){ |
|
15 | + protected function initContent($content) { |
|
16 | + if (\is_array($content)) { |
|
17 | + if (JArray::isAssociative($content)===false) { |
|
18 | 18 | $icon=@$content[0]; |
19 | 19 | $title=@$content[1]; |
20 | 20 | $desc=@$content[2]; |
21 | - }else{ |
|
21 | + } else { |
|
22 | 22 | $icon=@$content["icon"]; |
23 | 23 | $title=@$content["title"]; |
24 | 24 | $desc=@$content["description"]; |
25 | 25 | } |
26 | - if(isset($icon)){ |
|
26 | + if (isset($icon)) { |
|
27 | 27 | $this->addIcon($icon); |
28 | 28 | } |
29 | - if(isset($title)){ |
|
29 | + if (isset($title)) { |
|
30 | 30 | $this->setTitle($title); |
31 | 31 | } |
32 | - }else{ |
|
32 | + } else { |
|
33 | 33 | $this->setContent($content); |
34 | 34 | } |
35 | 35 | } |
@@ -12,34 +12,34 @@ discard block |
||
12 | 12 | use Ajax\semantic\html\base\traits\MenuItemTrait; |
13 | 13 | |
14 | 14 | class HtmlDropdownItem extends HtmlSemDoubleElement { |
15 | - use IconTrait,MenuItemTrait; |
|
16 | - public function __construct($identifier, $content="",$value=NULL,$image=NULL,$description=NULL) { |
|
15 | + use IconTrait, MenuItemTrait; |
|
16 | + public function __construct($identifier, $content="", $value=NULL, $image=NULL, $description=NULL) { |
|
17 | 17 | parent::__construct($identifier, "a"); |
18 | 18 | $this->setClass("item"); |
19 | 19 | $this->setContent($content); |
20 | - if($value!==NULL) |
|
20 | + if ($value!==NULL) |
|
21 | 21 | $this->setData($value); |
22 | - if($image!==NULL) |
|
22 | + if ($image!==NULL) |
|
23 | 23 | $this->asMiniAvatar($image); |
24 | - if($description!==NULL) |
|
24 | + if ($description!==NULL) |
|
25 | 25 | $this->setDescription($description); |
26 | 26 | } |
27 | 27 | |
28 | - public function setDescription($description){ |
|
29 | - $descO=new HtmlDoubleElement("desc-".$this->identifier,"span"); |
|
28 | + public function setDescription($description) { |
|
29 | + $descO=new HtmlDoubleElement("desc-".$this->identifier, "span"); |
|
30 | 30 | $descO->setClass("description"); |
31 | 31 | $descO->setContent($description); |
32 | - return $this->addContent($descO,true); |
|
32 | + return $this->addContent($descO, true); |
|
33 | 33 | } |
34 | 34 | |
35 | - public function setData($value){ |
|
35 | + public function setData($value) { |
|
36 | 36 | $this->setProperty("data-value", $value); |
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | - public function asOption(){ |
|
40 | + public function asOption() { |
|
41 | 41 | $this->tagName="option"; |
42 | - if($this->getProperty("data-value")!==null) |
|
42 | + if ($this->getProperty("data-value")!==null) |
|
43 | 43 | $this->setProperty("value", $this->getProperty("data-value")); |
44 | 44 | } |
45 | 45 | |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param string $image the image src |
48 | 48 | * @return $this |
49 | 49 | */ |
50 | - public function asMiniAvatar($image){ |
|
50 | + public function asMiniAvatar($image) { |
|
51 | 51 | $this->tagName="div"; |
52 | - $img=new HtmlImg("image-".$this->identifier,$image); |
|
52 | + $img=new HtmlImg("image-".$this->identifier, $image); |
|
53 | 53 | $img->setClass("ui mini avatar image"); |
54 | - $this->addContent($img,true); |
|
54 | + $this->addContent($img, true); |
|
55 | 55 | return $this; |
56 | 56 | } |
57 | 57 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | * @param string $icon |
61 | 61 | * @return HtmlDropdownItem |
62 | 62 | */ |
63 | - public function asIcon($caption,$icon){ |
|
63 | + public function asIcon($caption, $icon) { |
|
64 | 64 | $this->setContent($caption); |
65 | - $this->addContent(new HtmlIcon("", $icon),true); |
|
65 | + $this->addContent(new HtmlIcon("", $icon), true); |
|
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
@@ -71,23 +71,23 @@ discard block |
||
71 | 71 | * @param string $color |
72 | 72 | * @return HtmlDropdownItem |
73 | 73 | */ |
74 | - public function asCircularLabel($caption,$color){ |
|
74 | + public function asCircularLabel($caption, $color) { |
|
75 | 75 | $this->setContent($caption); |
76 | 76 | $lbl=new HtmlLabel(""); |
77 | 77 | $lbl->setCircular()->setColor($color)->setEmpty(); |
78 | - $this->addContent($lbl,true); |
|
78 | + $this->addContent($lbl, true); |
|
79 | 79 | return $this; |
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | 83 | |
84 | 84 | public function addMenuItem($items) { |
85 | - $menu=new HtmlMenu("menu-" . $this->identifier, $items); |
|
85 | + $menu=new HtmlMenu("menu-".$this->identifier, $items); |
|
86 | 86 | $content=$this->content; |
87 | 87 | $this->setTagName("div"); |
88 | 88 | $this->setProperty("class", "item"); |
89 | 89 | $icon=new HtmlIcon("", "dropdown"); |
90 | - $this->content=[$icon,new HtmlSemDoubleElement("","span","text",$content),$menu]; |
|
90 | + $this->content=[$icon, new HtmlSemDoubleElement("", "span", "text", $content), $menu]; |
|
91 | 91 | return $menu; |
92 | 92 | } |
93 | 93 | |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | * @param string $icon |
97 | 97 | * @return HtmlDropdownItem |
98 | 98 | */ |
99 | - public static function searchInput($placeholder=NULL,$icon=NULL){ |
|
100 | - return (new HtmlDropdownItem(""))->asSearchInput($placeholder,$icon); |
|
99 | + public static function searchInput($placeholder=NULL, $icon=NULL) { |
|
100 | + return (new HtmlDropdownItem(""))->asSearchInput($placeholder, $icon); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @return HtmlDropdownItem |
105 | 105 | */ |
106 | - public static function divider(){ |
|
106 | + public static function divider() { |
|
107 | 107 | return (new HtmlDropdownItem(""))->asDivider(); |
108 | 108 | } |
109 | 109 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * @param string $icon |
113 | 113 | * @return HtmlDropdownItem |
114 | 114 | */ |
115 | - public static function header($caption=NULL,$icon=NULL){ |
|
116 | - return (new HtmlDropdownItem(""))->asHeader($caption,$icon); |
|
115 | + public static function header($caption=NULL, $icon=NULL) { |
|
116 | + return (new HtmlDropdownItem(""))->asHeader($caption, $icon); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param string $color |
122 | 122 | * @return HtmlDropdownItem |
123 | 123 | */ |
124 | - public static function circular($caption,$color){ |
|
125 | - return (new HtmlDropdownItem(""))->asCircularLabel($caption,$color); |
|
124 | + public static function circular($caption, $color) { |
|
125 | + return (new HtmlDropdownItem(""))->asCircularLabel($caption, $color); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | * @param string $icon |
131 | 131 | * @return HtmlDropdownItem |
132 | 132 | */ |
133 | - public static function icon($caption,$icon){ |
|
134 | - return (new HtmlDropdownItem(""))->asIcon($caption,$icon); |
|
133 | + public static function icon($caption, $icon) { |
|
134 | + return (new HtmlDropdownItem(""))->asIcon($caption, $icon); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $image |
140 | 140 | * @return HtmlDropdownItem |
141 | 141 | */ |
142 | - public static function avatar($caption,$image){ |
|
143 | - $dd=new HtmlDropdownItem("",$caption); |
|
142 | + public static function avatar($caption, $image) { |
|
143 | + $dd=new HtmlDropdownItem("", $caption); |
|
144 | 144 | $dd->asMiniAvatar($image); |
145 | 145 | return $dd; |
146 | 146 | } |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | |
22 | 22 | protected function createItem($value) { |
23 | 23 | $count=$this->count(); |
24 | - $item=new HtmlListItem("item-" . $this->identifier . "-" . $count, $value); |
|
24 | + $item=new HtmlListItem("item-".$this->identifier."-".$count, $value); |
|
25 | 25 | return $item; |
26 | 26 | } |
27 | 27 | |
28 | 28 | public function addHeader($niveau, $content) { |
29 | - $header=new HtmlHeader("header-" . $this->identifier, $niveau, $content, "page"); |
|
29 | + $header=new HtmlHeader("header-".$this->identifier, $niveau, $content, "page"); |
|
30 | 30 | $this->wrap($header); |
31 | 31 | return $header; |
32 | 32 | } |
33 | 33 | |
34 | - public function getItemPart($index,$partName="header"){ |
|
34 | + public function getItemPart($index, $partName="header") { |
|
35 | 35 | return $this->getItem($index)->getPart($partName); |
36 | 36 | } |
37 | 37 | |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | return $this->contentAs($tagName); |
40 | 40 | } |
41 | 41 | |
42 | - public function asLinks($hrefs=[],$target=NUll) { |
|
43 | - $this->addToPropertyCtrl("class", "link", array ("link" )); |
|
44 | - return parent::asLinks($hrefs,$target); |
|
42 | + public function asLinks($hrefs=[], $target=NUll) { |
|
43 | + $this->addToPropertyCtrl("class", "link", array("link")); |
|
44 | + return parent::asLinks($hrefs, $target); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public function addList($items=array()) { |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @return HtmlListItem |
55 | 55 | */ |
56 | - public function getItem($index){ |
|
56 | + public function getItem($index) { |
|
57 | 57 | return parent::getItem($index); |
58 | 58 | } |
59 | 59 | |
60 | - protected function getItemToAdd($item){ |
|
60 | + protected function getItemToAdd($item) { |
|
61 | 61 | $itemO=parent::getItemToAdd($item); |
62 | - if($itemO instanceof AbstractCheckbox) |
|
62 | + if ($itemO instanceof AbstractCheckbox) |
|
63 | 63 | $itemO->addClass("item"); |
64 | 64 | return $itemO; |
65 | 65 | } |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | public function run(JsUtils $js) { |
80 | - if ($this->_hasCheckedList === true) { |
|
81 | - $jsCode=include dirname(__FILE__) . '/../../components/jsTemplates/tplCheckedList.php'; |
|
82 | - $jsCode=\str_replace("%identifier%", "#" . $this->identifier, $jsCode); |
|
80 | + if ($this->_hasCheckedList===true) { |
|
81 | + $jsCode=include dirname(__FILE__).'/../../components/jsTemplates/tplCheckedList.php'; |
|
82 | + $jsCode=\str_replace("%identifier%", "#".$this->identifier, $jsCode); |
|
83 | 83 | $jsCode=\str_replace("%fireOnInit%", $this->_fireOnInit, $jsCode); |
84 | 84 | $jsCode=\str_replace("%onChange%", $this->_ckItemChange, $jsCode); |
85 | 85 | $this->executeOnRun($jsCode); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | return parent::run($js); |
88 | 88 | } |
89 | 89 | |
90 | - public function onCkItemChange($jsCode){ |
|
90 | + public function onCkItemChange($jsCode) { |
|
91 | 91 | $this->_ckItemChange=$jsCode; |
92 | 92 | } |
93 | 93 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param boolean $fireOnInit |
96 | 96 | */ |
97 | 97 | public function setFireOnInit($fireOnInit) { |
98 | - $this->_fireOnInit = $fireOnInit; |
|
98 | + $this->_fireOnInit=$fireOnInit; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | public function setRelaxed() { |
@@ -122,42 +122,42 @@ discard block |
||
122 | 122 | * @param string $notAllChecked |
123 | 123 | * @return HtmlList |
124 | 124 | */ |
125 | - public function addCheckedList($items=array(), $masterItem=NULL, $values=array(),$notAllChecked=false,$name=null) { |
|
125 | + public function addCheckedList($items=array(), $masterItem=NULL, $values=array(), $notAllChecked=false, $name=null) { |
|
126 | 126 | $count=$this->count(); |
127 | - $identifier=$this->identifier . "-" . $count; |
|
127 | + $identifier=$this->identifier."-".$count; |
|
128 | 128 | if (isset($masterItem)) { |
129 | - if(\is_array($masterItem)){ |
|
130 | - $masterO=new HtmlFormCheckbox("master-" . $identifier, @$masterItem[0],@$masterItem[1]); |
|
131 | - if(isset($name)) |
|
129 | + if (\is_array($masterItem)) { |
|
130 | + $masterO=new HtmlFormCheckbox("master-".$identifier, @$masterItem[0], @$masterItem[1]); |
|
131 | + if (isset($name)) |
|
132 | 132 | $masterO->setName($name); |
133 | - if(isset($masterItem[1])){ |
|
134 | - if(\array_search($masterItem[1], $values)!==false){ |
|
133 | + if (isset($masterItem[1])) { |
|
134 | + if (\array_search($masterItem[1], $values)!==false) { |
|
135 | 135 | $masterO->getDataField()->setProperty("checked", ""); |
136 | 136 | } |
137 | 137 | } |
138 | - }else{ |
|
139 | - $masterO=new HtmlFormCheckbox("master-" . $identifier, $masterItem); |
|
138 | + } else { |
|
139 | + $masterO=new HtmlFormCheckbox("master-".$identifier, $masterItem); |
|
140 | 140 | } |
141 | - if($notAllChecked){ |
|
141 | + if ($notAllChecked) { |
|
142 | 142 | $masterO->getDataField()->addClass("_notAllChecked"); |
143 | 143 | } |
144 | 144 | $masterO->getHtmlCk()->addToProperty("class", "master"); |
145 | 145 | $masterO->setClass("item"); |
146 | 146 | $this->addItem($masterO); |
147 | 147 | } |
148 | - $fields=array (); |
|
148 | + $fields=array(); |
|
149 | 149 | $i=0; |
150 | - foreach ( $items as $val => $caption ) { |
|
151 | - $itemO=new HtmlFormCheckbox($identifier . "-" . $i++, $caption, $val, "child"); |
|
152 | - if (\array_search($val, $values) !== false) { |
|
150 | + foreach ($items as $val => $caption) { |
|
151 | + $itemO=new HtmlFormCheckbox($identifier."-".$i++, $caption, $val, "child"); |
|
152 | + if (\array_search($val, $values)!==false) { |
|
153 | 153 | $itemO->getDataField()->setProperty("checked", ""); |
154 | 154 | } |
155 | - if(isset($name)) |
|
155 | + if (isset($name)) |
|
156 | 156 | $itemO->setName($name); |
157 | 157 | $itemO->setClass("item"); |
158 | 158 | $fields[]=$itemO; |
159 | 159 | } |
160 | - if (isset($masterO) === true) { |
|
160 | + if (isset($masterO)===true) { |
|
161 | 161 | $list=new HtmlList("", $fields); |
162 | 162 | $list->setClass("list"); |
163 | 163 | $masterO->addContent($list); |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | return $this; |
169 | 169 | } |
170 | 170 | |
171 | - public function setIcons($icons){ |
|
172 | - if(!\is_array($icons)){ |
|
171 | + public function setIcons($icons) { |
|
172 | + if (!\is_array($icons)) { |
|
173 | 173 | $icons=\array_fill(0, \sizeof($this->content), $icons); |
174 | 174 | } |
175 | - $max=\min(\sizeof($icons),\sizeof($this->content)); |
|
176 | - for($i=0;$i<$max;$i++){ |
|
175 | + $max=\min(\sizeof($icons), \sizeof($this->content)); |
|
176 | + for ($i=0; $i<$max; $i++) { |
|
177 | 177 | $this->content[$i]->addIcon($icons[$i]); |
178 | 178 | } |
179 | 179 | return $this; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } |
36 | 36 | if (isset($label)) |
37 | 37 | $this->setLabel($label); |
38 | - foreach ( $fields as $field ) { |
|
38 | + foreach ($fields as $field) { |
|
39 | 39 | $this->addItem($field); |
40 | 40 | } |
41 | 41 | return $this; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public function addItem($item) { |
59 | 59 | $item=parent::addItem($item); |
60 | - if($item instanceof HtmlFormField) |
|
60 | + if ($item instanceof HtmlFormField) |
|
61 | 61 | $item->setContainer($this); |
62 | 62 | return $item; |
63 | 63 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * @return HtmlFormField |
67 | 67 | */ |
68 | - public function getItem($index){ |
|
68 | + public function getItem($index) { |
|
69 | 69 | return parent::getItem($index); |
70 | 70 | } |
71 | 71 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | |
106 | 106 | |
107 | 107 | public static function radios($name, $items=array(), $label=NULL, $value=null, $type=NULL) { |
108 | - $fields=array (); |
|
108 | + $fields=array(); |
|
109 | 109 | $i=0; |
110 | - foreach ( $items as $val => $caption ) { |
|
110 | + foreach ($items as $val => $caption) { |
|
111 | 111 | $itemO=new HtmlFormRadio($name."-".$i++, $name, $caption, $val, $type); |
112 | 112 | if ($val===$value) { |
113 | 113 | $itemO->getDataField()->setProperty("checked", ""); |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | public static function checkeds($name, $items=array(), $label=NULL, $values=array(), $type=NULL) { |
124 | - $fields=array (); |
|
124 | + $fields=array(); |
|
125 | 125 | $i=0; |
126 | - foreach ( $items as $val => $caption ) { |
|
126 | + foreach ($items as $val => $caption) { |
|
127 | 127 | $itemO=new HtmlFormCheckbox($name."-".$i++, $caption, $val, $type); |
128 | 128 | $itemO->setName($name); |
129 | 129 | if (\array_search($val, $values)!==false) { |
@@ -20,34 +20,34 @@ discard block |
||
20 | 20 | * @property string $identifier |
21 | 21 | */ |
22 | 22 | trait FieldsTrait { |
23 | - abstract public function addFields($fields=NULL,$label=NULL); |
|
23 | + abstract public function addFields($fields=NULL, $label=NULL); |
|
24 | 24 | abstract public function addItem($item); |
25 | 25 | abstract public function getItem($index); |
26 | 26 | |
27 | - protected function createItem($value){ |
|
28 | - if(\is_array($value)){ |
|
29 | - $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))); |
|
27 | + protected function createItem($value) { |
|
28 | + if (\is_array($value)) { |
|
29 | + $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))); |
|
30 | 30 | return $itemO; |
31 | - }elseif(\is_object($value)){ |
|
31 | + }elseif (\is_object($value)) { |
|
32 | 32 | $itemO=new HtmlFormField("field-".$this->identifier, $value); |
33 | 33 | return $itemO; |
34 | - }else |
|
34 | + } else |
|
35 | 35 | return new HtmlFormInput($value); |
36 | 36 | } |
37 | 37 | |
38 | - protected function createCondition($value){ |
|
38 | + protected function createCondition($value) { |
|
39 | 39 | return \is_object($value)===false || $value instanceof \Ajax\semantic\html\elements\HtmlInput; |
40 | 40 | } |
41 | 41 | |
42 | - public function addInputs($inputs,$fieldslabel=null){ |
|
42 | + public function addInputs($inputs, $fieldslabel=null) { |
|
43 | 43 | $fields=array(); |
44 | - foreach ($inputs as $input){ |
|
44 | + foreach ($inputs as $input) { |
|
45 | 45 | \extract($input); |
46 | - $f=new HtmlFormInput("",""); |
|
46 | + $f=new HtmlFormInput("", ""); |
|
47 | 47 | $f->fromArray($input); |
48 | 48 | $fields[]=$f; |
49 | 49 | } |
50 | - return $this->addFields($fields,$fieldslabel); |
|
50 | + return $this->addFields($fields, $fieldslabel); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -56,35 +56,35 @@ discard block |
||
56 | 56 | * @param array|mixed $values |
57 | 57 | * @return HtmlFormFields |
58 | 58 | */ |
59 | - public function setFieldsPropertyValues($property,$values){ |
|
59 | + public function setFieldsPropertyValues($property, $values) { |
|
60 | 60 | $i=0; |
61 | - if(\is_array($values)===false){ |
|
62 | - $values=\array_fill(0, $this->count(),$values); |
|
61 | + if (\is_array($values)===false) { |
|
62 | + $values=\array_fill(0, $this->count(), $values); |
|
63 | 63 | } |
64 | - foreach ($values as $value){ |
|
64 | + foreach ($values as $value) { |
|
65 | 65 | $c=$this->content[$i++]; |
66 | - if(isset($c)){ |
|
66 | + if (isset($c)) { |
|
67 | 67 | $df=$c->getDataField(); |
68 | - $df->setProperty($property,$value); |
|
68 | + $df->setProperty($property, $value); |
|
69 | 69 | } |
70 | - else{ |
|
70 | + else { |
|
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | return $this; |
75 | 75 | } |
76 | 76 | |
77 | - public function addFieldRule($index,$type,$prompt=NULL,$value=NULL){ |
|
77 | + public function addFieldRule($index, $type, $prompt=NULL, $value=NULL) { |
|
78 | 78 | $field=$this->getItem($index); |
79 | - if(isset($field)){ |
|
80 | - $field->addRule($type,$prompt,$value); |
|
79 | + if (isset($field)) { |
|
80 | + $field->addRule($type, $prompt, $value); |
|
81 | 81 | } |
82 | 82 | return $this; |
83 | 83 | } |
84 | 84 | |
85 | - public function addFieldRules($index,$rules){ |
|
85 | + public function addFieldRules($index, $rules) { |
|
86 | 86 | $field=$this->getItem($index); |
87 | - if(isset($field)){ |
|
87 | + if (isset($field)) { |
|
88 | 88 | $field->addRules($rules); |
89 | 89 | } |
90 | 90 | return $this; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @param boolean $multiple |
100 | 100 | * @return HtmlFormDropdown |
101 | 101 | */ |
102 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
103 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
102 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
103 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @param boolean $asIcons |
111 | 111 | * @return HtmlButtonGroups |
112 | 112 | */ |
113 | - public function addButtonGroups($identifier,$elements=[],$asIcons=false){ |
|
114 | - return $this->addItem(new HtmlButtonGroups($identifier,$elements,$asIcons)); |
|
113 | + public function addButtonGroups($identifier, $elements=[], $asIcons=false) { |
|
114 | + return $this->addItem(new HtmlButtonGroups($identifier, $elements, $asIcons)); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @param string $icon |
124 | 124 | * @return HtmlButtonGroups |
125 | 125 | */ |
126 | - public function addDropdownButton($identifier,$value,$items=[],$asCombo=false,$icon=null){ |
|
127 | - return $this->addItem(HtmlButton::dropdown($identifier, $value,$items,$asCombo,$icon)); |
|
126 | + public function addDropdownButton($identifier, $value, $items=[], $asCombo=false, $icon=null) { |
|
127 | + return $this->addItem(HtmlButton::dropdown($identifier, $value, $items, $asCombo, $icon)); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * @param string $placeholder |
136 | 136 | * @return HtmlFormInput |
137 | 137 | */ |
138 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
139 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
138 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
139 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -147,16 +147,16 @@ discard block |
||
147 | 147 | * @param int $rows |
148 | 148 | * @return HtmlTextarea |
149 | 149 | */ |
150 | - public function addTextarea($identifier, $label,$value=NULL,$placeholder=NULL,$rows=5){ |
|
151 | - return $this->addItem(new HtmlFormTextarea($identifier,$label,$value,$placeholder,$rows)); |
|
150 | + public function addTextarea($identifier, $label, $value=NULL, $placeholder=NULL, $rows=5) { |
|
151 | + return $this->addItem(new HtmlFormTextarea($identifier, $label, $value, $placeholder, $rows)); |
|
152 | 152 | } |
153 | 153 | |
154 | - public function addPassword($identifier, $label=NULL){ |
|
155 | - return $this->addItem(new HtmlFormInput($identifier,$label,"password","","")); |
|
154 | + public function addPassword($identifier, $label=NULL) { |
|
155 | + return $this->addItem(new HtmlFormInput($identifier, $label, "password", "", "")); |
|
156 | 156 | } |
157 | 157 | |
158 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
159 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
158 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
159 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | * @param string $type |
167 | 167 | * @return HtmlFormCheckbox |
168 | 168 | */ |
169 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
170 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
169 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
170 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
171 | 171 | } |
172 | 172 | |
173 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
174 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
173 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
174 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
175 | 175 | } |
176 | 176 | |
177 | - public function addElement($identifier,$content,$label,$tagName="div",$baseClass=""){ |
|
178 | - $div=new HtmlSemDoubleElement($identifier,$tagName,$baseClass,$content); |
|
179 | - return $this->addItem(new HtmlFormField("field-".$identifier, $div,$label)); |
|
177 | + public function addElement($identifier, $content, $label, $tagName="div", $baseClass="") { |
|
178 | + $div=new HtmlSemDoubleElement($identifier, $tagName, $baseClass, $content); |
|
179 | + return $this->addItem(new HtmlFormField("field-".$identifier, $div, $label)); |
|
180 | 180 | } |
181 | 181 | } |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | return $this->getHtmlCk()->attachEvents($events); |
39 | 39 | } |
40 | 40 | |
41 | - public function getField(){ |
|
41 | + public function getField() { |
|
42 | 42 | return $this->content["field"]; |
43 | 43 | } |
44 | 44 | |
45 | - public function getHtmlCk(){ |
|
45 | + public function getHtmlCk() { |
|
46 | 46 | return $this->content["field"]; |
47 | 47 | } |
48 | 48 | |
49 | - public function setName($name){ |
|
49 | + public function setName($name) { |
|
50 | 50 | $this->getDataField()->setProperty("name", $name); |
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
54 | - public function getDataField(){ |
|
55 | - $field= $this->getField(); |
|
56 | - if($field instanceof AbstractCheckbox) |
|
54 | + public function getDataField() { |
|
55 | + $field=$this->getField(); |
|
56 | + if ($field instanceof AbstractCheckbox) |
|
57 | 57 | $field=$field->getField(); |
58 | 58 | return $field; |
59 | 59 | } |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | * @param boolean $value |
64 | 64 | * @return $this |
65 | 65 | */ |
66 | - public function setChecked($value=true){ |
|
67 | - if($value===true){ |
|
66 | + public function setChecked($value=true) { |
|
67 | + if ($value===true) { |
|
68 | 68 | $this->getDataField()->setProperty("checked", "checked"); |
69 | - }else{ |
|
69 | + } else { |
|
70 | 70 | $this->getDataField()->removeProperty("checked"); |
71 | 71 | } |
72 | 72 | return $this; |