@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | parent::__construct($identifier, "div","field"); |
15 | 15 | $this->content=array(); |
16 | 16 | $this->_states=[State::ERROR,State::DISABLED]; |
17 | - if(isset($label)) |
|
18 | - $this->setLabel($label); |
|
17 | + if(isset($label)) { |
|
18 | + $this->setLabel($label); |
|
19 | + } |
|
19 | 20 | $this->setField($field); |
20 | 21 | } |
21 | 22 | |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | * @return mixed |
46 | 47 | */ |
47 | 48 | public function getLabel(){ |
48 | - if(\array_key_exists("label", $this->content)) |
|
49 | - return $this->content["label"]; |
|
49 | + if(\array_key_exists("label", $this->content)) { |
|
50 | + return $this->content["label"]; |
|
51 | + } |
|
50 | 52 | } |
51 | 53 | |
52 | 54 | /** |
@@ -14,34 +14,34 @@ discard block |
||
14 | 14 | use FieldTrait; |
15 | 15 | protected $_container; |
16 | 16 | protected $_validation; |
17 | - public function __construct($identifier, $field,$label=NULL) { |
|
18 | - parent::__construct($identifier, "div","field"); |
|
17 | + public function __construct($identifier, $field, $label=NULL) { |
|
18 | + parent::__construct($identifier, "div", "field"); |
|
19 | 19 | $this->content=array(); |
20 | - $this->_states=[State::ERROR,State::DISABLED]; |
|
21 | - if(isset($label)) |
|
20 | + $this->_states=[State::ERROR, State::DISABLED]; |
|
21 | + if (isset($label)) |
|
22 | 22 | $this->setLabel($label); |
23 | 23 | $this->setField($field); |
24 | 24 | $this->_validation=NULL; |
25 | 25 | } |
26 | 26 | |
27 | - public function addPointingLabel($label,$pointing=Direction::NONE){ |
|
28 | - $labelO=new HtmlLabel("",$label); |
|
27 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
28 | + $labelO=new HtmlLabel("", $label); |
|
29 | 29 | $labelO->setPointing($pointing); |
30 | - $this->addContent($labelO,$pointing==="below" || $pointing==="right"); |
|
30 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
31 | 31 | return $labelO; |
32 | 32 | } |
33 | 33 | |
34 | - public function setLabel($label){ |
|
34 | + public function setLabel($label) { |
|
35 | 35 | $labelO=$label; |
36 | - if(\is_string($label)){ |
|
37 | - $labelO=new HtmlSemDoubleElement("","label",""); |
|
36 | + if (\is_string($label)) { |
|
37 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
38 | 38 | $labelO->setContent($label); |
39 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
39 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
40 | 40 | } |
41 | 41 | $this->content["label"]=$labelO; |
42 | 42 | } |
43 | 43 | |
44 | - public function setField($field){ |
|
44 | + public function setField($field) { |
|
45 | 45 | $this->content["field"]=$field; |
46 | 46 | } |
47 | 47 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * Returns the label or null |
50 | 50 | * @return mixed |
51 | 51 | */ |
52 | - public function getLabel(){ |
|
53 | - if(\array_key_exists("label", $this->content)) |
|
52 | + public function getLabel() { |
|
53 | + if (\array_key_exists("label", $this->content)) |
|
54 | 54 | return $this->content["label"]; |
55 | 55 | } |
56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * Return the field |
59 | 59 | * @return mixed |
60 | 60 | */ |
61 | - public function getField(){ |
|
61 | + public function getField() { |
|
62 | 62 | return $this->content["field"]; |
63 | 63 | } |
64 | 64 | |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * Return the field with data |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | - public function getDataField(){ |
|
69 | + public function getDataField() { |
|
70 | 70 | return $this->content["field"]; |
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | 74 | * puts the label before or behind |
75 | 75 | */ |
76 | - public function swapLabel(){ |
|
76 | + public function swapLabel() { |
|
77 | 77 | $label=$this->getLabel(); |
78 | 78 | unset($this->content["label"]); |
79 | 79 | $this->content["label"]=$label; |
@@ -84,31 +84,31 @@ discard block |
||
84 | 84 | * @param int $width |
85 | 85 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
86 | 86 | */ |
87 | - public function setWidth($width){ |
|
88 | - if(\is_int($width)){ |
|
87 | + public function setWidth($width) { |
|
88 | + if (\is_int($width)) { |
|
89 | 89 | $width=Wide::getConstants()["W".$width]; |
90 | 90 | } |
91 | 91 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
92 | - if(isset($this->_container)){ |
|
92 | + if (isset($this->_container)) { |
|
93 | 93 | $this->_container->setEqualWidth(false); |
94 | 94 | } |
95 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
95 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Field displays an error state |
100 | 100 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
101 | 101 | */ |
102 | - public function setError(){ |
|
102 | + public function setError() { |
|
103 | 103 | return $this->addToProperty("class", "error"); |
104 | 104 | } |
105 | 105 | |
106 | - public function setInline(){ |
|
106 | + public function setInline() { |
|
107 | 107 | return $this->addToProperty("class", "inline"); |
108 | 108 | } |
109 | 109 | |
110 | - public function jsState($state){ |
|
111 | - return $this->jsDoJquery("addClass",$state); |
|
110 | + public function jsState($state) { |
|
111 | + return $this->jsDoJquery("addClass", $state); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | public function setContainer($_container) { |
@@ -116,26 +116,26 @@ discard block |
||
116 | 116 | return $this; |
117 | 117 | } |
118 | 118 | |
119 | - public function setReadonly(){ |
|
119 | + public function setReadonly() { |
|
120 | 120 | $this->getField()->setProperty("readonly", ""); |
121 | 121 | } |
122 | 122 | |
123 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
123 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
124 | 124 | $field=$this->getDataField(); |
125 | - if(isset($field)){ |
|
126 | - if(!isset($this->_validation)){ |
|
125 | + if (isset($field)) { |
|
126 | + if (!isset($this->_validation)) { |
|
127 | 127 | $this->_validation=new FieldValidation($field->getIdentifier()); |
128 | 128 | } |
129 | - if($type==="empty"){ |
|
130 | - $this->addToProperty("class","required"); |
|
129 | + if ($type==="empty") { |
|
130 | + $this->addToProperty("class", "required"); |
|
131 | 131 | } |
132 | - $this->_validation->addRule($type,$prompt,$value); |
|
132 | + $this->_validation->addRule($type, $prompt, $value); |
|
133 | 133 | } |
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - public function addRules(array $rules){ |
|
138 | - foreach ($rules as $rule){ |
|
137 | + public function addRules(array $rules) { |
|
138 | + foreach ($rules as $rule) { |
|
139 | 139 | $this->addRule($rule); |
140 | 140 | } |
141 | 141 | return $this; |
@@ -50,8 +50,9 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | public function getProperty($name) { |
53 | - if (array_key_exists($name, $this->properties)) |
|
54 | - return $this->properties[$name]; |
|
53 | + if (array_key_exists($name, $this->properties)) { |
|
54 | + return $this->properties[$name]; |
|
55 | + } |
|
55 | 56 | } |
56 | 57 | |
57 | 58 | public function addToProperty($name, $value, $separator=" ") { |
@@ -61,10 +62,11 @@ discard block |
||
61 | 62 | } |
62 | 63 | } else if ($value !== "" && $this->propertyContains($name, $value) === false) { |
63 | 64 | $v=@$this->properties[$name]; |
64 | - if (isset($v) && $v !== "") |
|
65 | - $v=$v . $separator . $value; |
|
66 | - else |
|
67 | - $v=$value; |
|
65 | + if (isset($v) && $v !== "") { |
|
66 | + $v=$v . $separator . $value; |
|
67 | + } else { |
|
68 | + $v=$value; |
|
69 | + } |
|
68 | 70 | |
69 | 71 | return $this->setProperty($name, $v); |
70 | 72 | } |
@@ -119,8 +121,9 @@ discard block |
||
119 | 121 | } |
120 | 122 | |
121 | 123 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
122 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
123 | - return $this->setProperty($name, $value); |
|
124 | + if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
125 | + return $this->setProperty($name, $value); |
|
126 | + } |
|
124 | 127 | return $this; |
125 | 128 | } |
126 | 129 | |
@@ -150,8 +153,9 @@ discard block |
||
150 | 153 | } |
151 | 154 | |
152 | 155 | public function removeProperty($name) { |
153 | - if (\array_key_exists($name, $this->properties)) |
|
154 | - unset($this->properties[$name]); |
|
156 | + if (\array_key_exists($name, $this->properties)) { |
|
157 | + unset($this->properties[$name]); |
|
158 | + } |
|
155 | 159 | return $this; |
156 | 160 | } |
157 | 161 | |
@@ -171,8 +175,9 @@ discard block |
||
171 | 175 | } |
172 | 176 | |
173 | 177 | protected function addToPropertyUnique($name, $value, $typeCtrl) { |
174 | - if (@class_exists($typeCtrl, true)) |
|
175 | - $typeCtrl=$typeCtrl::getConstants(); |
|
178 | + if (@class_exists($typeCtrl, true)) { |
|
179 | + $typeCtrl=$typeCtrl::getConstants(); |
|
180 | + } |
|
176 | 181 | if (is_array($typeCtrl)) { |
177 | 182 | $this->removeOldValues($this->properties[$name], $typeCtrl); |
178 | 183 | } |
@@ -358,15 +363,18 @@ discard block |
||
358 | 363 | $flag=false; |
359 | 364 | $index=0; |
360 | 365 | while ( !$flag && $index < sizeof($elements) ) { |
361 | - if ($elements[$index] instanceof BaseHtml) |
|
362 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
366 | + if ($elements[$index] instanceof BaseHtml) { |
|
367 | + $flag=($elements[$index]->getIdentifier() === $identifier); |
|
368 | + } |
|
363 | 369 | $index++; |
364 | 370 | } |
365 | - if ($flag === true) |
|
366 | - return $elements[$index - 1]; |
|
371 | + if ($flag === true) { |
|
372 | + return $elements[$index - 1]; |
|
373 | + } |
|
367 | 374 | } elseif ($elements instanceof BaseHtml) { |
368 | - if ($elements->getIdentifier() === $identifier) |
|
369 | - return $elements; |
|
375 | + if ($elements->getIdentifier() === $identifier) { |
|
376 | + return $elements; |
|
377 | + } |
|
370 | 378 | } |
371 | 379 | return null; |
372 | 380 | } |
@@ -376,15 +384,18 @@ discard block |
||
376 | 384 | $flag=false; |
377 | 385 | $index=0; |
378 | 386 | while ( !$flag && $index < sizeof($elements) ) { |
379 | - if ($elements[$index] instanceof BaseHtml) |
|
380 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
387 | + if ($elements[$index] instanceof BaseHtml) { |
|
388 | + $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
389 | + } |
|
381 | 390 | $index++; |
382 | 391 | } |
383 | - if ($flag === true) |
|
384 | - return $elements[$index - 1]; |
|
392 | + if ($flag === true) { |
|
393 | + return $elements[$index - 1]; |
|
394 | + } |
|
385 | 395 | } elseif ($elements instanceof BaseHtml) { |
386 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
387 | - return $elements; |
|
396 | + if ($elements->propertyContains($propertyName, $value) === true) { |
|
397 | + return $elements; |
|
398 | + } |
|
388 | 399 | } |
389 | 400 | return null; |
390 | 401 | } |
@@ -124,6 +124,10 @@ discard block |
||
124 | 124 | return $this; |
125 | 125 | } |
126 | 126 | |
127 | + /** |
|
128 | + * @param string $name |
|
129 | + * @param string[] $typeCtrl |
|
130 | + */ |
|
127 | 131 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
128 | 132 | if ($this->ctrl($name, $value, $typeCtrl) === true) { |
129 | 133 | return $name=$value; |
@@ -139,22 +143,35 @@ discard block |
||
139 | 143 | return $this; |
140 | 144 | } |
141 | 145 | |
146 | + /** |
|
147 | + * @param string $name |
|
148 | + */ |
|
142 | 149 | protected function removePropertyValue($name, $value) { |
143 | 150 | $this->properties[$name]=\str_replace($value, "", $this->properties[$name]); |
144 | 151 | return $this; |
145 | 152 | } |
146 | 153 | |
154 | + /** |
|
155 | + * @param string $name |
|
156 | + */ |
|
147 | 157 | protected function removePropertyValues($name, $values) { |
148 | 158 | $this->removeOldValues($this->properties[$name], $values); |
149 | 159 | return $this; |
150 | 160 | } |
151 | 161 | |
162 | + /** |
|
163 | + * @param string $name |
|
164 | + */ |
|
152 | 165 | public function removeProperty($name) { |
153 | 166 | if (\array_key_exists($name, $this->properties)) |
154 | 167 | unset($this->properties[$name]); |
155 | 168 | return $this; |
156 | 169 | } |
157 | 170 | |
171 | + /** |
|
172 | + * @param string $name |
|
173 | + * @param string[] $typeCtrl |
|
174 | + */ |
|
158 | 175 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
159 | 176 | if ($this->ctrl($name, $value, $typeCtrl) === true) { |
160 | 177 | if (is_array($typeCtrl)) { |
@@ -165,6 +182,9 @@ discard block |
||
165 | 182 | return $this; |
166 | 183 | } |
167 | 184 | |
185 | + /** |
|
186 | + * @param string $name |
|
187 | + */ |
|
168 | 188 | protected function addToMember(&$name, $value, $separator=" ") { |
169 | 189 | $name=str_ireplace($value, "", $name) . $separator . $value; |
170 | 190 | return $this; |
@@ -179,6 +199,9 @@ discard block |
||
179 | 199 | return $this->addToProperty($name, $value); |
180 | 200 | } |
181 | 201 | |
202 | + /** |
|
203 | + * @param string $name |
|
204 | + */ |
|
182 | 205 | public function addToPropertyCtrl($name, $value, $typeCtrl) { |
183 | 206 | return $this->addToPropertyUnique($name, $value, $typeCtrl); |
184 | 207 | } |
@@ -283,6 +306,10 @@ discard block |
||
283 | 306 | return null; |
284 | 307 | } |
285 | 308 | |
309 | + /** |
|
310 | + * @param string $propertyName |
|
311 | + * @param string $value |
|
312 | + */ |
|
286 | 313 | protected function getElementByPropertyValue($propertyName,$value, $elements) { |
287 | 314 | if (is_array($elements)) { |
288 | 315 | $flag=false; |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | use BaseHtmlEventsTrait; |
18 | 18 | protected $_template; |
19 | 19 | protected $tagName; |
20 | - protected $properties=array (); |
|
21 | - protected $_wrapBefore=array (); |
|
22 | - protected $_wrapAfter=array (); |
|
20 | + protected $properties=array(); |
|
21 | + protected $_wrapBefore=array(); |
|
22 | + protected $_wrapAfter=array(); |
|
23 | 23 | protected $_bsComponent; |
24 | 24 | |
25 | 25 | public function getBsComponent() { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | protected function getTemplate(JsUtils $js=NULL) { |
35 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
35 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getProperties() { |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | |
57 | 57 | public function addToProperty($name, $value, $separator=" ") { |
58 | 58 | if (\is_array($value)) { |
59 | - foreach ( $value as $v ) { |
|
59 | + foreach ($value as $v) { |
|
60 | 60 | $this->addToProperty($name, $v, $separator); |
61 | 61 | } |
62 | - } else if ($value !== "" && $this->propertyContains($name, $value) === false) { |
|
62 | + } else if ($value!=="" && $this->propertyContains($name, $value)===false) { |
|
63 | 63 | $v=@$this->properties[$name]; |
64 | - if (isset($v) && $v !== "") |
|
65 | - $v=$v . $separator . $value; |
|
64 | + if (isset($v) && $v!=="") |
|
65 | + $v=$v.$separator.$value; |
|
66 | 66 | else |
67 | 67 | $v=$value; |
68 | 68 | |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | |
79 | 79 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
80 | 80 | $result=$this->getTemplate($js); |
81 | - foreach ( $this as $key => $value ) { |
|
82 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
81 | + foreach ($this as $key => $value) { |
|
82 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
83 | 83 | if (is_array($value)) { |
84 | 84 | $v=PropertyWrapper::wrap($value, $js); |
85 | 85 | } else { |
86 | 86 | $v=$value; |
87 | 87 | } |
88 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
88 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | if (isset($js)===true) { |
92 | 92 | $this->run($js); |
93 | - if (isset($view) === true) { |
|
93 | + if (isset($view)===true) { |
|
94 | 94 | $js->addViewElement($this->identifier, $result, $view); |
95 | 95 | } |
96 | 96 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | |
100 | 100 | protected function ctrl($name, $value, $typeCtrl) { |
101 | 101 | if (is_array($typeCtrl)) { |
102 | - if (array_search($value, $typeCtrl) === false) { |
|
103 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
102 | + if (array_search($value, $typeCtrl)===false) { |
|
103 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
104 | 104 | } |
105 | 105 | } else { |
106 | 106 | if (!$typeCtrl($value)) { |
107 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
107 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | return true; |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
122 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
122 | + if ($this->ctrl($name, $value, $typeCtrl)===true) |
|
123 | 123 | return $this->setProperty($name, $value); |
124 | 124 | return $this; |
125 | 125 | } |
126 | 126 | |
127 | 127 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
128 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
128 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
129 | 129 | return $name=$value; |
130 | 130 | } |
131 | 131 | return $this; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
135 | 135 | if (is_array($typeCtrl)) { |
136 | 136 | $this->removeOldValues($name, $typeCtrl); |
137 | - $name.=$separator . $value; |
|
137 | + $name.=$separator.$value; |
|
138 | 138 | } |
139 | 139 | return $this; |
140 | 140 | } |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
159 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
159 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
160 | 160 | if (is_array($typeCtrl)) { |
161 | 161 | $this->removeOldValues($name, $typeCtrl); |
162 | 162 | } |
163 | - $name.=$separator . $value; |
|
163 | + $name.=$separator.$value; |
|
164 | 164 | } |
165 | 165 | return $this; |
166 | 166 | } |
167 | 167 | |
168 | 168 | protected function addToMember(&$name, $value, $separator=" ") { |
169 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
169 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
170 | 170 | return $this; |
171 | 171 | } |
172 | 172 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | public function addToPropertyCtrlCheck($name, $value, $typeCtrl) { |
187 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
187 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
188 | 188 | return $this->addToProperty($name, $value); |
189 | 189 | } |
190 | 190 | return $this; |
@@ -212,28 +212,28 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | public function fromArray($array) { |
215 | - foreach ( $this as $key => $value ) { |
|
215 | + foreach ($this as $key => $value) { |
|
216 | 216 | if (array_key_exists($key, $array) && !JString::startswith($key, "_")) { |
217 | - $setter="set" . ucfirst($key); |
|
217 | + $setter="set".ucfirst($key); |
|
218 | 218 | $this->$setter($array[$key]); |
219 | 219 | unset($array[$key]); |
220 | 220 | } |
221 | 221 | } |
222 | - foreach ( $array as $key => $value ) { |
|
222 | + foreach ($array as $key => $value) { |
|
223 | 223 | if (method_exists($this, $key)) { |
224 | 224 | try { |
225 | 225 | $this->$key($value); |
226 | 226 | unset($array[$key]); |
227 | - } catch ( \Exception $e ) { |
|
227 | + }catch (\Exception $e) { |
|
228 | 228 | // Nothing to do |
229 | 229 | } |
230 | 230 | } else { |
231 | - $setter="set" . ucfirst($key); |
|
231 | + $setter="set".ucfirst($key); |
|
232 | 232 | if (method_exists($this, $setter)) { |
233 | 233 | try { |
234 | 234 | $this->$setter($value); |
235 | 235 | unset($array[$key]); |
236 | - } catch ( \Exception $e ) { |
|
236 | + }catch (\Exception $e) { |
|
237 | 237 | // Nothing to do |
238 | 238 | } |
239 | 239 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | public function fromDatabaseObjects($objects, $function) { |
246 | 246 | if (isset($objects)) { |
247 | - foreach ( $objects as $object ) { |
|
247 | + foreach ($objects as $object) { |
|
248 | 248 | $this->fromDatabaseObject($object, $function); |
249 | 249 | } |
250 | 250 | } |
@@ -269,33 +269,33 @@ discard block |
||
269 | 269 | if (is_array($elements)) { |
270 | 270 | $flag=false; |
271 | 271 | $index=0; |
272 | - while ( !$flag && $index < sizeof($elements) ) { |
|
272 | + while (!$flag && $index<sizeof($elements)) { |
|
273 | 273 | if ($elements[$index] instanceof BaseHtml) |
274 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
274 | + $flag=($elements[$index]->getIdentifier()===$identifier); |
|
275 | 275 | $index++; |
276 | 276 | } |
277 | - if ($flag === true) |
|
278 | - return $elements[$index - 1]; |
|
277 | + if ($flag===true) |
|
278 | + return $elements[$index-1]; |
|
279 | 279 | } elseif ($elements instanceof BaseHtml) { |
280 | - if ($elements->getIdentifier() === $identifier) |
|
280 | + if ($elements->getIdentifier()===$identifier) |
|
281 | 281 | return $elements; |
282 | 282 | } |
283 | 283 | return null; |
284 | 284 | } |
285 | 285 | |
286 | - protected function getElementByPropertyValue($propertyName,$value, $elements) { |
|
286 | + protected function getElementByPropertyValue($propertyName, $value, $elements) { |
|
287 | 287 | if (is_array($elements)) { |
288 | 288 | $flag=false; |
289 | 289 | $index=0; |
290 | - while ( !$flag && $index < sizeof($elements) ) { |
|
290 | + while (!$flag && $index<sizeof($elements)) { |
|
291 | 291 | if ($elements[$index] instanceof BaseHtml) |
292 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
292 | + $flag=($elements[$index]->propertyContains($propertyName, $value)===true); |
|
293 | 293 | $index++; |
294 | 294 | } |
295 | - if ($flag === true) |
|
296 | - return $elements[$index - 1]; |
|
295 | + if ($flag===true) |
|
296 | + return $elements[$index-1]; |
|
297 | 297 | } elseif ($elements instanceof BaseHtml) { |
298 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
298 | + if ($elements->propertyContains($propertyName, $value)===true) |
|
299 | 299 | return $elements; |
300 | 300 | } |
301 | 301 | return null; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * Insert an item at a position |
65 | 65 | * @param mixed $item |
66 | - * @param number $position |
|
66 | + * @param integer $position |
|
67 | 67 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
68 | 68 | */ |
69 | 69 | public function insertItem($item,$position=0){ |
@@ -164,6 +164,9 @@ discard block |
||
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | + /** |
|
168 | + * @param integer $index |
|
169 | + */ |
|
167 | 170 | public function getItem($index){ |
168 | 171 | return $this->items[$index]; |
169 | 172 | } |
@@ -254,6 +257,9 @@ discard block |
||
254 | 257 | return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
255 | 258 | } |
256 | 259 | |
260 | + /** |
|
261 | + * @param string $value |
|
262 | + */ |
|
257 | 263 | public function setValue($value){ |
258 | 264 | $this->value=$value; |
259 | 265 | return $this; |
@@ -288,6 +294,9 @@ discard block |
||
288 | 294 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
289 | 295 | } |
290 | 296 | |
297 | + /** |
|
298 | + * @param string $action |
|
299 | + */ |
|
291 | 300 | public function setAction($action){ |
292 | 301 | $this->_params["action"]=$action; |
293 | 302 | } |
@@ -13,49 +13,49 @@ discard block |
||
13 | 13 | use Ajax\semantic\html\collections\form\traits\FieldTrait; |
14 | 14 | |
15 | 15 | class HtmlDropdown extends HtmlSemDoubleElement { |
16 | - use FieldTrait,LabeledIconTrait { |
|
16 | + use FieldTrait, LabeledIconTrait { |
|
17 | 17 | addIcon as addIconP; |
18 | 18 | } |
19 | 19 | protected $mClass="menu"; |
20 | 20 | protected $mTagName="div"; |
21 | - protected $items=array (); |
|
22 | - protected $_params=array("action"=>"nothing","on"=>"hover"); |
|
21 | + protected $items=array(); |
|
22 | + protected $_params=array("action"=>"nothing", "on"=>"hover"); |
|
23 | 23 | protected $input; |
24 | 24 | protected $value; |
25 | 25 | protected $_associative; |
26 | 26 | |
27 | - public function __construct($identifier, $value="", $items=array(),$associative=true) { |
|
27 | + public function __construct($identifier, $value="", $items=array(), $associative=true) { |
|
28 | 28 | parent::__construct($identifier, "div"); |
29 | 29 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
30 | 30 | $this->setProperty("class", "ui dropdown"); |
31 | - $content=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
31 | + $content=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
32 | 32 | $content->setClass("text"); |
33 | 33 | $this->setValue($value); |
34 | - $content->wrap("",new HtmlIcon("", "dropdown")); |
|
34 | + $content->wrap("", new HtmlIcon("", "dropdown")); |
|
35 | 35 | $this->content=array($content); |
36 | 36 | $this->tagName="div"; |
37 | 37 | $this->_associative=$associative; |
38 | 38 | $this->addItems($items); |
39 | 39 | } |
40 | 40 | |
41 | - public function getField(){ |
|
41 | + public function getField() { |
|
42 | 42 | return $this->input; |
43 | 43 | } |
44 | 44 | |
45 | - public function addItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
46 | - $itemO=$this->beforeAddItem($item,$value,$image,$description); |
|
45 | + public function addItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
46 | + $itemO=$this->beforeAddItem($item, $value, $image, $description); |
|
47 | 47 | $this->items[]=$itemO; |
48 | 48 | return $itemO; |
49 | 49 | } |
50 | 50 | |
51 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
52 | - $this->addIconP($icon,$before,$labeled); |
|
51 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
52 | + $this->addIconP($icon, $before, $labeled); |
|
53 | 53 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
54 | 54 | } |
55 | 55 | |
56 | - public function addIcons($icons){ |
|
56 | + public function addIcons($icons) { |
|
57 | 57 | $count=$this->count(); |
58 | - for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){ |
|
58 | + for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) { |
|
59 | 59 | $this->getItem($i)->addIcon($icons[$i]); |
60 | 60 | } |
61 | 61 | } |
@@ -66,26 +66,26 @@ discard block |
||
66 | 66 | * @param number $position |
67 | 67 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
68 | 68 | */ |
69 | - public function insertItem($item,$position=0){ |
|
69 | + public function insertItem($item, $position=0) { |
|
70 | 70 | $itemO=$this->beforeAddItem($item); |
71 | - $start = array_slice($this->items, 0, $position); |
|
72 | - $end = array_slice($this->items, $position); |
|
73 | - $start[] = $item; |
|
71 | + $start=array_slice($this->items, 0, $position); |
|
72 | + $end=array_slice($this->items, $position); |
|
73 | + $start[]=$item; |
|
74 | 74 | $this->items=array_merge($start, $end); |
75 | 75 | return $itemO; |
76 | 76 | } |
77 | 77 | |
78 | - protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
78 | + protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
79 | 79 | $itemO=$item; |
80 | - if(\is_array($item)){ |
|
80 | + if (\is_array($item)) { |
|
81 | 81 | $description=JArray::getValue($item, "description", 3); |
82 | 82 | $value=JArray::getValue($item, "value", 1); |
83 | 83 | $image=JArray::getValue($item, "image", 2); |
84 | 84 | $item=JArray::getValue($item, "item", 0); |
85 | 85 | } |
86 | - if(!$item instanceof HtmlDropdownItem){ |
|
87 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
|
88 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
86 | + if (!$item instanceof HtmlDropdownItem) { |
|
87 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description); |
|
88 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
89 | 89 | $this->addToProperty("class", "vertical"); |
90 | 90 | } |
91 | 91 | return $itemO; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | $this->addItem($function($object)); |
99 | 99 | } |
100 | 100 | |
101 | - public function addInput($name){ |
|
102 | - if(!isset($name)) |
|
101 | + public function addInput($name) { |
|
102 | + if (!isset($name)) |
|
103 | 103 | $name="input-".$this->identifier; |
104 | 104 | $this->setAction("activate"); |
105 | - $this->input=new HtmlInput($name,"hidden"); |
|
105 | + $this->input=new HtmlInput($name, "hidden"); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | * @param string $icon |
112 | 112 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
113 | 113 | */ |
114 | - public function addSearchInputItem($placeHolder=NULL,$icon=NULL){ |
|
115 | - return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon)); |
|
114 | + public function addSearchInputItem($placeHolder=NULL, $icon=NULL) { |
|
115 | + return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Adds a divider item |
120 | 120 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
121 | 121 | */ |
122 | - public function addDividerItem(){ |
|
122 | + public function addDividerItem() { |
|
123 | 123 | return $this->addItem(HtmlDropdownItem::divider()); |
124 | 124 | } |
125 | 125 | |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @param string $icon |
130 | 130 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
131 | 131 | */ |
132 | - public function addHeaderItem($caption=NULL,$icon=NULL){ |
|
133 | - return $this->addItem(HtmlDropdownItem::header($caption,$icon)); |
|
132 | + public function addHeaderItem($caption=NULL, $icon=NULL) { |
|
133 | + return $this->addItem(HtmlDropdownItem::header($caption, $icon)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param string $color |
140 | 140 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
141 | 141 | */ |
142 | - public function addCircularLabelItem($caption,$color){ |
|
142 | + public function addCircularLabelItem($caption, $color) { |
|
143 | 143 | return $this->addItem(HtmlDropdownItem::circular($caption, $color)); |
144 | 144 | } |
145 | 145 | |
@@ -148,87 +148,87 @@ discard block |
||
148 | 148 | * @param string $image |
149 | 149 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
150 | 150 | */ |
151 | - public function addMiniAvatarImageItem($caption,$image){ |
|
151 | + public function addMiniAvatarImageItem($caption, $image) { |
|
152 | 152 | return $this->addItem(HtmlDropdownItem::avatar($caption, $image)); |
153 | 153 | } |
154 | 154 | |
155 | - public function addItems($items){ |
|
156 | - if(\is_array($items) && $this->_associative){ |
|
157 | - foreach ($items as $k=>$v){ |
|
155 | + public function addItems($items) { |
|
156 | + if (\is_array($items) && $this->_associative) { |
|
157 | + foreach ($items as $k=>$v) { |
|
158 | 158 | $this->addItem($v)->setData($k); |
159 | 159 | } |
160 | - }else{ |
|
161 | - foreach ($items as $item){ |
|
160 | + } else { |
|
161 | + foreach ($items as $item) { |
|
162 | 162 | $this->addItem($item); |
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | - public function getItem($index){ |
|
167 | + public function getItem($index) { |
|
168 | 168 | return $this->items[$index]; |
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | 172 | * @return int |
173 | 173 | */ |
174 | - public function count(){ |
|
174 | + public function count() { |
|
175 | 175 | return \sizeof($this->items); |
176 | 176 | } |
177 | 177 | /** |
178 | 178 | * @param boolean $dropdown |
179 | 179 | */ |
180 | - public function asDropdown($dropdown){ |
|
181 | - if($dropdown===false){ |
|
180 | + public function asDropdown($dropdown) { |
|
181 | + if ($dropdown===false) { |
|
182 | 182 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
183 | 183 | $dropdown="menu"; |
184 | - }else{ |
|
184 | + } else { |
|
185 | 185 | $dropdown="dropdown"; |
186 | 186 | $this->mClass="menu"; |
187 | 187 | } |
188 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
188 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
189 | 189 | } |
190 | 190 | |
191 | - public function setVertical(){ |
|
192 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
191 | + public function setVertical() { |
|
192 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
193 | 193 | } |
194 | 194 | |
195 | - public function setInline(){ |
|
196 | - return $this->addToPropertyCtrl("class", "inline",["inline"]); |
|
195 | + public function setInline() { |
|
196 | + return $this->addToPropertyCtrl("class", "inline", ["inline"]); |
|
197 | 197 | } |
198 | 198 | |
199 | - public function setSimple(){ |
|
200 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
199 | + public function setSimple() { |
|
200 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
201 | 201 | } |
202 | 202 | |
203 | - public function asButton($floating=false){ |
|
204 | - if($floating) |
|
203 | + public function asButton($floating=false) { |
|
204 | + if ($floating) |
|
205 | 205 | $this->addToProperty("class", "floating"); |
206 | 206 | $this->removePropertyValue("class", "selection"); |
207 | 207 | return $this->addToProperty("class", "button"); |
208 | 208 | } |
209 | 209 | |
210 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
211 | - if(isset($name)) |
|
210 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
211 | + if (isset($name)) |
|
212 | 212 | $this->addInput($name); |
213 | - if($multiple) |
|
213 | + if ($multiple) |
|
214 | 214 | $this->addToProperty("class", "multiple"); |
215 | - if ($selection){ |
|
216 | - if($this->propertyContains("class", "button")===false) |
|
217 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
215 | + if ($selection) { |
|
216 | + if ($this->propertyContains("class", "button")===false) |
|
217 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
218 | 218 | } |
219 | 219 | return $this; |
220 | 220 | } |
221 | 221 | |
222 | - public function asSearch($name=NULL,$multiple=false,$selection=true){ |
|
223 | - $this->asSelect($name,$multiple,$selection); |
|
222 | + public function asSearch($name=NULL, $multiple=false, $selection=true) { |
|
223 | + $this->asSelect($name, $multiple, $selection); |
|
224 | 224 | return $this->addToProperty("class", "search"); |
225 | 225 | } |
226 | 226 | |
227 | - public function setSelect($name=NULL,$multiple=false){ |
|
228 | - if(!isset($name)) |
|
227 | + public function setSelect($name=NULL, $multiple=false) { |
|
228 | + if (!isset($name)) |
|
229 | 229 | $name="select-".$this->identifier; |
230 | 230 | $this->input=null; |
231 | - if($multiple){ |
|
231 | + if ($multiple) { |
|
232 | 232 | $this->setProperty("multiple", true); |
233 | 233 | $this->addToProperty("class", "multiple"); |
234 | 234 | } |
@@ -236,37 +236,37 @@ discard block |
||
236 | 236 | $this->tagName="select"; |
237 | 237 | $this->setProperty("name", $name); |
238 | 238 | $this->content=null; |
239 | - foreach ($this->items as $item){ |
|
239 | + foreach ($this->items as $item) { |
|
240 | 240 | $item->asOption(); |
241 | 241 | } |
242 | 242 | return $this; |
243 | 243 | } |
244 | 244 | |
245 | - public function asSubmenu($pointing=NULL){ |
|
245 | + public function asSubmenu($pointing=NULL) { |
|
246 | 246 | $this->setClass("ui dropdown link item"); |
247 | - if(isset($pointing)){ |
|
247 | + if (isset($pointing)) { |
|
248 | 248 | $this->setPointing($pointing); |
249 | 249 | } |
250 | 250 | return $this; |
251 | 251 | } |
252 | 252 | |
253 | - public function setPointing($value=Direction::NONE){ |
|
254 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
253 | + public function setPointing($value=Direction::NONE) { |
|
254 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
255 | 255 | } |
256 | 256 | |
257 | - public function setValue($value){ |
|
257 | + public function setValue($value) { |
|
258 | 258 | $this->value=$value; |
259 | 259 | return $this; |
260 | 260 | } |
261 | - private function applyValue(){ |
|
261 | + private function applyValue() { |
|
262 | 262 | $value=$this->value; |
263 | - if(isset($this->input) && isset($value)){ |
|
263 | + if (isset($this->input) && isset($value)) { |
|
264 | 264 | $this->input->setProperty("value", $value); |
265 | - }else{ |
|
265 | + } else { |
|
266 | 266 | $this->setProperty("value", $value); |
267 | 267 | } |
268 | 268 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
269 | - if(isset($textElement)) |
|
269 | + if (isset($textElement)) |
|
270 | 270 | $textElement->setContent($value); |
271 | 271 | return $this; |
272 | 272 | } |
@@ -276,29 +276,29 @@ discard block |
||
276 | 276 | * @see BaseHtml::run() |
277 | 277 | */ |
278 | 278 | public function run(JsUtils $js) { |
279 | - if($this->propertyContains("class", "simple")===false){ |
|
280 | - if(isset($this->_bsComponent)===false) |
|
281 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
279 | + if ($this->propertyContains("class", "simple")===false) { |
|
280 | + if (isset($this->_bsComponent)===false) |
|
281 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
282 | 282 | $this->addEventsOnRun($js); |
283 | 283 | return $this->_bsComponent; |
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - public function setCompact(){ |
|
287 | + public function setCompact() { |
|
288 | 288 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
289 | 289 | } |
290 | 290 | |
291 | - public function setAction($action){ |
|
291 | + public function setAction($action) { |
|
292 | 292 | $this->_params["action"]=$action; |
293 | 293 | } |
294 | 294 | |
295 | - public function setFullTextSearch($value){ |
|
295 | + public function setFullTextSearch($value) { |
|
296 | 296 | $this->_params["fullTextSearch"]=$value; |
297 | 297 | } |
298 | 298 | |
299 | 299 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
300 | 300 | $this->applyValue(); |
301 | - return parent::compile($js,$view); |
|
301 | + return parent::compile($js, $view); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | public function getInput() { |
@@ -3,8 +3,8 @@ |
||
3 | 3 | namespace Ajax\service; |
4 | 4 | |
5 | 5 | class Javascript { |
6 | - public static function containsCode($expression){ |
|
7 | - return strrpos($expression, 'this')!==false||strrpos($expression, 'event')!==false||strrpos($expression, 'self')!==false; |
|
6 | + public static function containsCode($expression) { |
|
7 | + return strrpos($expression, 'this')!==false || strrpos($expression, 'event')!==false || strrpos($expression, 'self')!==false; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
@@ -12,36 +12,36 @@ discard block |
||
12 | 12 | */ |
13 | 13 | abstract class HtmlCollection extends HtmlDoubleElement { |
14 | 14 | |
15 | - public function __construct($identifier,$tagName="div"){ |
|
16 | - parent::__construct($identifier,$tagName); |
|
15 | + public function __construct($identifier, $tagName="div") { |
|
16 | + parent::__construct($identifier, $tagName); |
|
17 | 17 | $this->content=array(); |
18 | 18 | } |
19 | 19 | |
20 | - public function addItems($items){ |
|
21 | - if(JArray::isAssociative($items)){ |
|
22 | - foreach ($items as $k=>$v){ |
|
23 | - $this->addItem([$k,$v]); |
|
20 | + public function addItems($items) { |
|
21 | + if (JArray::isAssociative($items)) { |
|
22 | + foreach ($items as $k=>$v) { |
|
23 | + $this->addItem([$k, $v]); |
|
24 | 24 | } |
25 | - }else{ |
|
26 | - foreach ($items as $item){ |
|
25 | + } else { |
|
26 | + foreach ($items as $item) { |
|
27 | 27 | $this->addItem($item); |
28 | 28 | } |
29 | 29 | } |
30 | 30 | return $this; |
31 | 31 | } |
32 | 32 | |
33 | - public function setItems($items){ |
|
33 | + public function setItems($items) { |
|
34 | 34 | $this->content=$items; |
35 | 35 | return $this; |
36 | 36 | } |
37 | 37 | |
38 | - public function getItems(){ |
|
38 | + public function getItems() { |
|
39 | 39 | return $this->content; |
40 | 40 | } |
41 | 41 | |
42 | - protected function getItemToAdd($item){ |
|
42 | + protected function getItemToAdd($item) { |
|
43 | 43 | $itemO=$item; |
44 | - if($this->createCondition($item)===true){ |
|
44 | + if ($this->createCondition($item)===true) { |
|
45 | 45 | $itemO=$this->createItem($item); |
46 | 46 | } |
47 | 47 | return $itemO; |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | * @param HtmlDoubleElement|string|array $item |
53 | 53 | * @return \Ajax\common\html\HtmlDoubleElement |
54 | 54 | */ |
55 | - public function addItem($item){ |
|
55 | + public function addItem($item) { |
|
56 | 56 | $itemO=$this->getItemToAdd($item); |
57 | 57 | $this->addContent($itemO); |
58 | 58 | return $itemO; |
59 | 59 | } |
60 | 60 | |
61 | - public function insertItem($item,$position=0){ |
|
61 | + public function insertItem($item, $position=0) { |
|
62 | 62 | $itemO=$this->getItemToAdd($item); |
63 | - \array_splice( $this->content, $position, 0, array($itemO)); |
|
63 | + \array_splice($this->content, $position, 0, array($itemO)); |
|
64 | 64 | return $itemO; |
65 | 65 | } |
66 | 66 | |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | return $this; |
84 | 84 | } |
85 | 85 | |
86 | - public function removeItem($index){ |
|
86 | + public function removeItem($index) { |
|
87 | 87 | return array_splice($this->content, $index, 1); |
88 | 88 | } |
89 | 89 | |
90 | - public function count(){ |
|
90 | + public function count() { |
|
91 | 91 | return \sizeof($this->content); |
92 | 92 | } |
93 | 93 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | return $this->addItem($function($object)); |
99 | 99 | } |
100 | 100 | |
101 | - public function apply($callBack){ |
|
102 | - foreach ($this->content as $item){ |
|
101 | + public function apply($callBack) { |
|
102 | + foreach ($this->content as $item) { |
|
103 | 103 | $callBack($item); |
104 | 104 | } |
105 | 105 | return $this; |
@@ -119,40 +119,40 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected abstract function createItem($value); |
121 | 121 | |
122 | - protected function createCondition($value){ |
|
122 | + protected function createCondition($value) { |
|
123 | 123 | return \is_object($value)===false; |
124 | 124 | } |
125 | 125 | |
126 | - protected function contentAs($tagName){ |
|
127 | - foreach ($this->content as $item){ |
|
126 | + protected function contentAs($tagName) { |
|
127 | + foreach ($this->content as $item) { |
|
128 | 128 | $item->setTagName($tagName); |
129 | 129 | } |
130 | 130 | return $this; |
131 | 131 | } |
132 | 132 | |
133 | - public function setProperties($properties){ |
|
133 | + public function setProperties($properties) { |
|
134 | 134 | $i=0; |
135 | - foreach ($properties as $k=>$v){ |
|
135 | + foreach ($properties as $k=>$v) { |
|
136 | 136 | $c=$this->content[$i++]; |
137 | - if(isset($c)) |
|
138 | - $c->setProperty($k,$v); |
|
137 | + if (isset($c)) |
|
138 | + $c->setProperty($k, $v); |
|
139 | 139 | else |
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - public function setPropertyValues($property,$values){ |
|
145 | + public function setPropertyValues($property, $values) { |
|
146 | 146 | $i=0; |
147 | - if(\is_array($values)===false){ |
|
148 | - $values=\array_fill(0, $this->count(),$values); |
|
147 | + if (\is_array($values)===false) { |
|
148 | + $values=\array_fill(0, $this->count(), $values); |
|
149 | 149 | } |
150 | - foreach ($values as $value){ |
|
150 | + foreach ($values as $value) { |
|
151 | 151 | $c=$this->content[$i++]; |
152 | - if(isset($c)){ |
|
153 | - $c->setProperty($property,$value); |
|
152 | + if (isset($c)) { |
|
153 | + $c->setProperty($property, $value); |
|
154 | 154 | } |
155 | - else{ |
|
155 | + else { |
|
156 | 156 | return $this; |
157 | 157 | } |
158 | 158 | } |
@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | * @property SimpleExtComponent $_bsComponent |
11 | 11 | * @property string identifier |
12 | 12 | */ |
13 | -trait BaseHtmlEventsTrait{ |
|
13 | +trait BaseHtmlEventsTrait { |
|
14 | 14 | |
15 | - protected $_events=array (); |
|
15 | + protected $_events=array(); |
|
16 | 16 | |
17 | 17 | public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
18 | - if ($stopPropagation === true) { |
|
19 | - $jsCode="event.stopPropagation();" . $jsCode; |
|
18 | + if ($stopPropagation===true) { |
|
19 | + $jsCode="event.stopPropagation();".$jsCode; |
|
20 | 20 | } |
21 | - if ($preventDefault === true) { |
|
22 | - $jsCode="event.preventDefault();" . $jsCode; |
|
21 | + if ($preventDefault===true) { |
|
22 | + $jsCode="event.preventDefault();".$jsCode; |
|
23 | 23 | } |
24 | 24 | return $this->_addEvent($event, $jsCode); |
25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | if (is_array($this->_events[$event])) { |
30 | 30 | $this->_events[$event][]=$jsCode; |
31 | 31 | } else { |
32 | - $this->_events[$event]=array ($this->_events[$event],$jsCode ); |
|
32 | + $this->_events[$event]=array($this->_events[$event], $jsCode); |
|
33 | 33 | } |
34 | 34 | } else { |
35 | 35 | $this->_events[$event]=$jsCode; |
@@ -49,35 +49,35 @@ discard block |
||
49 | 49 | return $this->onClick($jsCode); |
50 | 50 | } |
51 | 51 | |
52 | - public function onCreate($jsCode){ |
|
53 | - if(isset($this->_events["_create"])){ |
|
52 | + public function onCreate($jsCode) { |
|
53 | + if (isset($this->_events["_create"])) { |
|
54 | 54 | $this->_events["_create"][]=$jsCode; |
55 | - }else{ |
|
55 | + } else { |
|
56 | 56 | $this->_events["_create"]=[$jsCode]; |
57 | 57 | } |
58 | 58 | return $this; |
59 | 59 | } |
60 | 60 | |
61 | 61 | public function addEventsOnRun(JsUtils $js) { |
62 | - if(isset($this->_events["_create"])){ |
|
62 | + if (isset($this->_events["_create"])) { |
|
63 | 63 | $create=$this->_events["_create"]; |
64 | - if(\is_array($create)){ |
|
64 | + if (\is_array($create)) { |
|
65 | 65 | $create=\implode("", $create); |
66 | 66 | } |
67 | - if($create!=="") |
|
68 | - $js->exec($create,true); |
|
67 | + if ($create!=="") |
|
68 | + $js->exec($create, true); |
|
69 | 69 | unset($this->_events["_create"]); |
70 | 70 | } |
71 | 71 | if (isset($this->_bsComponent)) { |
72 | - foreach ( $this->_events as $event => $jsCode ) { |
|
72 | + foreach ($this->_events as $event => $jsCode) { |
|
73 | 73 | $code=$jsCode; |
74 | 74 | if (is_array($jsCode)) { |
75 | 75 | $code=""; |
76 | - foreach ( $jsCode as $jsC ) { |
|
76 | + foreach ($jsCode as $jsC) { |
|
77 | 77 | if ($jsC instanceof AjaxCall) { |
78 | - $code.="\n" . $jsC->compile($js); |
|
78 | + $code.="\n".$jsC->compile($js); |
|
79 | 79 | } else { |
80 | - $code.="\n" . $jsC; |
|
80 | + $code.="\n".$jsC; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } elseif ($jsCode instanceof AjaxCall) { |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | } |
86 | 86 | $this->_bsComponent->addEvent($event, $code); |
87 | 87 | } |
88 | - $this->_events=array (); |
|
88 | + $this->_events=array(); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
93 | - $params=array ("url" => $url,"responseElement" => $responseElement ); |
|
93 | + $params=array("url" => $url, "responseElement" => $responseElement); |
|
94 | 94 | $params=array_merge($params, $parameters); |
95 | 95 | $this->_addEvent($event, new AjaxCall($operation, $params)); |
96 | 96 | return $this; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | public function jsDoJquery($jqueryCall, $param="") { |
126 | - return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . Javascript::prep_value($param) . ");"; |
|
126 | + return "$('#".$this->identifier."').".$jqueryCall."(".Javascript::prep_value($param).");"; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | public function executeOnRun($jsCode) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function onCreate($jsCode){ |
53 | 53 | if(isset($this->_events["_create"])){ |
54 | 54 | $this->_events["_create"][]=$jsCode; |
55 | - }else{ |
|
55 | + } else{ |
|
56 | 56 | $this->_events["_create"]=[$jsCode]; |
57 | 57 | } |
58 | 58 | return $this; |
@@ -64,8 +64,9 @@ discard block |
||
64 | 64 | if(\is_array($create)){ |
65 | 65 | $create=\implode("", $create); |
66 | 66 | } |
67 | - if($create!=="") |
|
68 | - $js->exec($create,true); |
|
67 | + if($create!=="") { |
|
68 | + $js->exec($create,true); |
|
69 | + } |
|
69 | 70 | unset($this->_events["_create"]); |
70 | 71 | } |
71 | 72 | if (isset($this->_bsComponent)) { |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | protected $_toolbarPosition; |
35 | 35 | |
36 | 36 | |
37 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
37 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
38 | 38 | parent::__construct($identifier); |
39 | 39 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
40 | 40 | $this->setModel($model); |
41 | - if(isset($modelInstance)); |
|
41 | + if (isset($modelInstance)); |
|
42 | 42 | $this->show($modelInstance); |
43 | 43 | } |
44 | 44 | |
45 | - protected function _getFieldIdentifier($prefix){ |
|
45 | + protected function _getFieldIdentifier($prefix) { |
|
46 | 46 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
47 | 47 | } |
48 | 48 | |
49 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
49 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
50 | 50 | |
51 | - public function show($modelInstance){ |
|
51 | + public function show($modelInstance) { |
|
52 | 52 | $this->_modelInstance=$modelInstance; |
53 | 53 | } |
54 | 54 | |
@@ -72,42 +72,42 @@ discard block |
||
72 | 72 | |
73 | 73 | public abstract function getHtmlComponent(); |
74 | 74 | |
75 | - public function setColor($color){ |
|
75 | + public function setColor($color) { |
|
76 | 76 | return $this->getHtmlComponent()->setColor($color); |
77 | 77 | } |
78 | 78 | |
79 | 79 | |
80 | - public function setCaptions($captions){ |
|
80 | + public function setCaptions($captions) { |
|
81 | 81 | $this->_instanceViewer->setCaptions($captions); |
82 | 82 | return $this; |
83 | 83 | } |
84 | 84 | |
85 | - public function setFields($fields){ |
|
85 | + public function setFields($fields) { |
|
86 | 86 | $this->_instanceViewer->setVisibleProperties($fields); |
87 | 87 | return $this; |
88 | 88 | } |
89 | 89 | |
90 | - public function addField($field){ |
|
90 | + public function addField($field) { |
|
91 | 91 | $this->_instanceViewer->addField($field); |
92 | 92 | return $this; |
93 | 93 | } |
94 | 94 | |
95 | - public function insertField($index,$field){ |
|
95 | + public function insertField($index, $field) { |
|
96 | 96 | $this->_instanceViewer->insertField($index, $field); |
97 | 97 | return $this; |
98 | 98 | } |
99 | 99 | |
100 | - public function insertInField($index,$field){ |
|
100 | + public function insertInField($index, $field) { |
|
101 | 101 | $this->_instanceViewer->insertInField($index, $field); |
102 | 102 | return $this; |
103 | 103 | } |
104 | 104 | |
105 | - public function setValueFunction($index,$callback){ |
|
105 | + public function setValueFunction($index, $callback) { |
|
106 | 106 | $this->_instanceViewer->setValueFunction($index, $callback); |
107 | 107 | return $this; |
108 | 108 | } |
109 | 109 | |
110 | - public function setIdentifierFunction($callback){ |
|
110 | + public function setIdentifierFunction($callback) { |
|
111 | 111 | $this->_instanceViewer->setIdentifierFunction($callback); |
112 | 112 | return $this; |
113 | 113 | } |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | /** |
116 | 116 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
117 | 117 | */ |
118 | - public function getToolbar(){ |
|
119 | - if(isset($this->_toolbar)===false){ |
|
118 | + public function getToolbar() { |
|
119 | + if (isset($this->_toolbar)===false) { |
|
120 | 120 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
121 | 121 | //$this->_toolbar->setSecondary(); |
122 | 122 | } |
@@ -129,57 +129,57 @@ discard block |
||
129 | 129 | * @param callable $callback function to call on $element |
130 | 130 | * @return \Ajax\common\html\HtmlDoubleElement |
131 | 131 | */ |
132 | - public function addInToolbar($element,$callback=NULL){ |
|
132 | + public function addInToolbar($element, $callback=NULL) { |
|
133 | 133 | $tb=$this->getToolbar(); |
134 | - if(isset($callback)){ |
|
135 | - if(\is_callable($callback)){ |
|
134 | + if (isset($callback)) { |
|
135 | + if (\is_callable($callback)) { |
|
136 | 136 | $callback($element); |
137 | 137 | } |
138 | 138 | } |
139 | 139 | return $tb->addItem($element); |
140 | 140 | } |
141 | 141 | |
142 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
143 | - $result=$this->addInToolbar($caption,$callback); |
|
144 | - if(isset($icon)) |
|
142 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
143 | + $result=$this->addInToolbar($caption, $callback); |
|
144 | + if (isset($icon)) |
|
145 | 145 | $result->addIcon($icon); |
146 | 146 | return $result; |
147 | 147 | } |
148 | 148 | |
149 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
150 | - if(JArray::isAssociative($items)){ |
|
151 | - foreach ($items as $icon=>$item){ |
|
152 | - $this->addItemInToolbar($item,$icon,$callback); |
|
149 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
150 | + if (JArray::isAssociative($items)) { |
|
151 | + foreach ($items as $icon=>$item) { |
|
152 | + $this->addItemInToolbar($item, $icon, $callback); |
|
153 | 153 | } |
154 | - }else{ |
|
155 | - foreach ($items as $item){ |
|
156 | - $this->addItemInToolbar($item,null,$callback); |
|
154 | + } else { |
|
155 | + foreach ($items as $item) { |
|
156 | + $this->addItemInToolbar($item, null, $callback); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | return $this; |
160 | 160 | } |
161 | 161 | |
162 | - public function addDropdownInToolbar($value,$items=NULL,$callback=NULL){ |
|
162 | + public function addDropdownInToolbar($value, $items=NULL, $callback=NULL) { |
|
163 | 163 | $dd=$value; |
164 | 164 | if (\is_string($value)) { |
165 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
165 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
166 | 166 | } |
167 | - return $this->addInToolbar($dd,$callback); |
|
167 | + return $this->addInToolbar($dd, $callback); |
|
168 | 168 | } |
169 | 169 | |
170 | - public function addButtonInToolbar($caption,$callback=NULL){ |
|
171 | - $bt=new HtmlButton("",$caption); |
|
172 | - return $this->addInToolbar($bt,$callback); |
|
170 | + public function addButtonInToolbar($caption, $callback=NULL) { |
|
171 | + $bt=new HtmlButton("", $caption); |
|
172 | + return $this->addInToolbar($bt, $callback); |
|
173 | 173 | } |
174 | 174 | |
175 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
176 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
177 | - return $this->addInToolbar($bts,$callback); |
|
175 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
176 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
177 | + return $this->addInToolbar($bts, $callback); |
|
178 | 178 | } |
179 | 179 | |
180 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
181 | - $bt=new HtmlButton("",$caption); |
|
182 | - $bt->addIcon($icon,$before,$labeled); |
|
180 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
181 | + $bt=new HtmlButton("", $caption); |
|
182 | + $bt->addIcon($icon, $before, $labeled); |
|
183 | 183 | return $this->addInToolbar($bt); |
184 | 184 | } |
185 | 185 |
@@ -141,8 +141,9 @@ discard block |
||
141 | 141 | |
142 | 142 | public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
143 | 143 | $result=$this->addInToolbar($caption,$callback); |
144 | - if(isset($icon)) |
|
145 | - $result->addIcon($icon); |
|
144 | + if(isset($icon)) { |
|
145 | + $result->addIcon($icon); |
|
146 | + } |
|
146 | 147 | return $result; |
147 | 148 | } |
148 | 149 | |
@@ -151,7 +152,7 @@ discard block |
||
151 | 152 | foreach ($items as $icon=>$item){ |
152 | 153 | $this->addItemInToolbar($item,$icon,$callback); |
153 | 154 | } |
154 | - }else{ |
|
155 | + } else{ |
|
155 | 156 | foreach ($items as $item){ |
156 | 157 | $this->addItemInToolbar($item,null,$callback); |
157 | 158 | } |
@@ -6,27 +6,27 @@ discard block |
||
6 | 6 | use Symfony\Component\HttpFoundation\Request; |
7 | 7 | use Symfony\Component\HttpKernel\HttpKernelInterface; |
8 | 8 | use Ajax\service\JString; |
9 | -class JsUtils extends \Ajax\JsUtils{ |
|
10 | - public function getUrl($url){ |
|
9 | +class JsUtils extends \Ajax\JsUtils { |
|
10 | + public function getUrl($url) { |
|
11 | 11 | //$request = Request::createFromGlobals(); |
12 | 12 | $router=$this->getInjected(); |
13 | - if(isset($router)){ |
|
13 | + if (isset($router)) { |
|
14 | 14 | try { |
15 | 15 | $url=$router->generate($url); |
16 | - }catch (\Exception $e){ |
|
16 | + }catch (\Exception $e) { |
|
17 | 17 | return $router->getContext()->getBaseUrl(); |
18 | 18 | } |
19 | 19 | } |
20 | 20 | return $url; |
21 | 21 | } |
22 | - public function addViewElement($identifier,$content,&$view){ |
|
23 | - if(\array_key_exists("q", $view)===false){ |
|
22 | + public function addViewElement($identifier, $content, &$view) { |
|
23 | + if (\array_key_exists("q", $view)===false) { |
|
24 | 24 | $view["q"]=array(); |
25 | 25 | } |
26 | 26 | $view["q"][$identifier]=$content; |
27 | 27 | } |
28 | 28 | |
29 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
29 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
30 | 30 | $view[$view_var]=$output; |
31 | 31 | } |
32 | 32 | |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | * @param array $params |
38 | 38 | * @see \Ajax\JsUtils::forward() |
39 | 39 | */ |
40 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=array()){ |
|
40 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=array()) { |
|
41 | 41 | $path=$params; |
42 | - $request = $initialControllerInstance->get('request_stack')->getCurrentRequest(); |
|
43 | - $path['_forwarded'] = $request->attributes; |
|
44 | - $path['_controller'] = $controllerName.":".$actionName; |
|
45 | - $subRequest = $request->duplicate([], null, $path); |
|
46 | - $response= $initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); |
|
42 | + $request=$initialControllerInstance->get('request_stack')->getCurrentRequest(); |
|
43 | + $path['_forwarded']=$request->attributes; |
|
44 | + $path['_controller']=$controllerName.":".$actionName; |
|
45 | + $subRequest=$request->duplicate([], null, $path); |
|
46 | + $response=$initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); |
|
47 | 47 | return $response->getContent(); |
48 | 48 | } |
49 | 49 | |
50 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
50 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
51 | 51 | if ($initialControllerInstance->has('templating')) { |
52 | 52 | return $initialControllerInstance->get('templating')->render($viewName, $params); |
53 | 53 | } |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | return $initialControllerInstance->get('twig')->render($viewName, $params); |
60 | 60 | } |
61 | 61 | |
62 | - public function fromDispatcher($dispatcher){ |
|
63 | - $request = $dispatcher->get('request_stack')->getCurrentRequest(); |
|
62 | + public function fromDispatcher($dispatcher) { |
|
63 | + $request=$dispatcher->get('request_stack')->getCurrentRequest(); |
|
64 | 64 | $uri=$request->getPathInfo(); |
65 | - if(JString::startswith($uri, "/")){ |
|
65 | + if (JString::startswith($uri, "/")) { |
|
66 | 66 | $uri=\substr($uri, 1); |
67 | 67 | } |
68 | 68 | return \explode("/", $uri); |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | use Ajax\common\html\HtmlDoubleElement; |
10 | 10 | use Ajax\semantic\html\base\constants\Side; |
11 | 11 | |
12 | -class HtmlStep extends HtmlSemCollection{ |
|
12 | +class HtmlStep extends HtmlSemCollection { |
|
13 | 13 | protected $_activeStep; |
14 | 14 | |
15 | - public function __construct( $identifier,$steps=array()){ |
|
16 | - parent::__construct( $identifier,"div", "ui steps"); |
|
15 | + public function __construct($identifier, $steps=array()) { |
|
16 | + parent::__construct($identifier, "div", "ui steps"); |
|
17 | 17 | $this->addItems($steps); |
18 | 18 | } |
19 | 19 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
24 | 24 | */ |
25 | 25 | protected function createItem($value) { |
26 | - $itemO=new HtmlStepItem("item-".\sizeof($this->content),$value); |
|
26 | + $itemO=new HtmlStepItem("item-".\sizeof($this->content), $value); |
|
27 | 27 | return $itemO; |
28 | 28 | } |
29 | 29 | |
@@ -31,50 +31,50 @@ discard block |
||
31 | 31 | * @param string|array $step |
32 | 32 | * @return HtmlStepItem |
33 | 33 | */ |
34 | - public function addStep($step){ |
|
34 | + public function addStep($step) { |
|
35 | 35 | return $this->addItem($step); |
36 | 36 | } |
37 | 37 | |
38 | - public function setOrdered(){ |
|
38 | + public function setOrdered() { |
|
39 | 39 | return $this->addToProperty("class", "ordered"); |
40 | 40 | } |
41 | 41 | |
42 | - public function isOrdered(){ |
|
42 | + public function isOrdered() { |
|
43 | 43 | return $this->propertyContains("class", "ordered"); |
44 | 44 | } |
45 | 45 | |
46 | - public function setVertical(){ |
|
46 | + public function setVertical() { |
|
47 | 47 | return $this->addToProperty("class", "vertical"); |
48 | 48 | } |
49 | 49 | |
50 | - protected function defineActiveStep(){ |
|
50 | + protected function defineActiveStep() { |
|
51 | 51 | $activestep=$this->_activeStep; |
52 | 52 | $count=$this->count(); |
53 | - if($this->isOrdered()){ |
|
54 | - for($i=0;$i<$count;$i++){ |
|
53 | + if ($this->isOrdered()) { |
|
54 | + for ($i=0; $i<$count; $i++) { |
|
55 | 55 | $step=$this->content[$i]; |
56 | 56 | $step->removeStatus(); |
57 | - if($i<$activestep) |
|
57 | + if ($i<$activestep) |
|
58 | 58 | $step->setCompleted(); |
59 | 59 | elseif ($i===$activestep) |
60 | 60 | $step->setActive(); |
61 | 61 | else |
62 | 62 | $step->setDisabled(); |
63 | 63 | } |
64 | - }else{ |
|
65 | - foreach ($this->content as $step){ |
|
64 | + } else { |
|
65 | + foreach ($this->content as $step) { |
|
66 | 66 | $step->removeStatus(); |
67 | 67 | } |
68 | - if($activestep<$count) |
|
68 | + if ($activestep<$count) |
|
69 | 69 | $this->content[$activestep]->setActive(); |
70 | 70 | } |
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | 74 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
75 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
75 | + if (isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
76 | 76 | $this->defineActiveStep(); |
77 | - return parent::compile($js,$view); |
|
77 | + return parent::compile($js, $view); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public function setActiveStep($_activeStep) { |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | return $this; |
83 | 83 | } |
84 | 84 | |
85 | - public function setAttached($side="",HtmlDoubleElement $toElement=NULL){ |
|
86 | - if(isset($toElement)){ |
|
87 | - $toElement->addToPropertyCtrl("class", "attached",array("attached")); |
|
85 | + public function setAttached($side="", HtmlDoubleElement $toElement=NULL) { |
|
86 | + if (isset($toElement)) { |
|
87 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
88 | 88 | } |
89 | - return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
89 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
90 | 90 | } |
91 | 91 | |
92 | - public function asLink(){ |
|
93 | - foreach ($this->content as $step){ |
|
92 | + public function asLink() { |
|
93 | + foreach ($this->content as $step) { |
|
94 | 94 | $step->asLink(); |
95 | 95 | } |
96 | 96 | return $this; |
@@ -54,26 +54,29 @@ |
||
54 | 54 | for($i=0;$i<$count;$i++){ |
55 | 55 | $step=$this->content[$i]; |
56 | 56 | $step->removeStatus(); |
57 | - if($i<$activestep) |
|
58 | - $step->setCompleted(); |
|
59 | - elseif ($i===$activestep) |
|
60 | - $step->setActive(); |
|
61 | - else |
|
62 | - $step->setDisabled(); |
|
57 | + if($i<$activestep) { |
|
58 | + $step->setCompleted(); |
|
59 | + } elseif ($i===$activestep) { |
|
60 | + $step->setActive(); |
|
61 | + } else { |
|
62 | + $step->setDisabled(); |
|
63 | + } |
|
63 | 64 | } |
64 | - }else{ |
|
65 | + } else{ |
|
65 | 66 | foreach ($this->content as $step){ |
66 | 67 | $step->removeStatus(); |
67 | 68 | } |
68 | - if($activestep<$count) |
|
69 | - $this->content[$activestep]->setActive(); |
|
69 | + if($activestep<$count) { |
|
70 | + $this->content[$activestep]->setActive(); |
|
71 | + } |
|
70 | 72 | } |
71 | 73 | return $this; |
72 | 74 | } |
73 | 75 | |
74 | 76 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
75 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
76 | - $this->defineActiveStep(); |
|
77 | + if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) { |
|
78 | + $this->defineActiveStep(); |
|
79 | + } |
|
77 | 80 | return parent::compile($js,$view); |
78 | 81 | } |
79 | 82 |