@@ -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 $values |
159 | 159 | * @return HtmlCollection |
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 | } |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
179 | 179 | $index=0; |
180 | 180 | $classname=\strtolower(JReflection::shortClassName($this)); |
181 | - foreach ($this->content as $item){ |
|
182 | - $this->setItemIdentifier($item,$classname,$index++); |
|
181 | + foreach ($this->content as $item) { |
|
182 | + $this->setItemIdentifier($item, $classname, $index++); |
|
183 | 183 | } |
184 | - return parent::compile($js,$view); |
|
184 | + return parent::compile($js, $view); |
|
185 | 185 | } |
186 | 186 | |
187 | - public function getItemById($identifier){ |
|
187 | + public function getItemById($identifier) { |
|
188 | 188 | return $this->getElementById($identifier, $this->content); |
189 | 189 | } |
190 | 190 | |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | * @param string $target |
194 | 194 | * @return HtmlCollection |
195 | 195 | */ |
196 | - public function asLinks($hrefs=[],$target=NUll) { |
|
197 | - foreach ( $this->content as $index=>$item ) { |
|
198 | - if($item instanceof HtmlDoubleElement){ |
|
196 | + public function asLinks($hrefs=[], $target=NUll) { |
|
197 | + foreach ($this->content as $index=>$item) { |
|
198 | + if ($item instanceof HtmlDoubleElement) { |
|
199 | 199 | $href=""; |
200 | - if(isset($hrefs[$index])) |
|
200 | + if (isset($hrefs[$index])) |
|
201 | 201 | $href=$hrefs[$index]; |
202 | - $item->asLink($href,$target); |
|
202 | + $item->asLink($href, $target); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | return $this; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | foreach ($items as $k=>$v){ |
25 | 25 | $this->addItem([$k,$v]); |
26 | 26 | } |
27 | - }else{ |
|
27 | + } else{ |
|
28 | 28 | foreach ($items as $item){ |
29 | 29 | $this->addItem($item); |
30 | 30 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @return \Ajax\common\html\HtmlDoubleElement |
81 | 81 | */ |
82 | 82 | public function getItem($index) { |
83 | - if (is_int($index)) |
|
84 | - return $this->content[$index]; |
|
85 | - else { |
|
83 | + if (is_int($index)) { |
|
84 | + return $this->content[$index]; |
|
85 | + } else { |
|
86 | 86 | $elm=$this->getElementById($index, $this->content); |
87 | 87 | return $elm; |
88 | 88 | } |
@@ -144,10 +144,11 @@ discard block |
||
144 | 144 | $i=0; |
145 | 145 | foreach ($properties as $k=>$v){ |
146 | 146 | $c=$this->content[$i++]; |
147 | - if(isset($c)) |
|
148 | - $c->setProperty($k,$v); |
|
149 | - else |
|
150 | - return $this; |
|
147 | + if(isset($c)) { |
|
148 | + $c->setProperty($k,$v); |
|
149 | + } else { |
|
150 | + return $this; |
|
151 | + } |
|
151 | 152 | } |
152 | 153 | return $this; |
153 | 154 | } |
@@ -167,8 +168,7 @@ discard block |
||
167 | 168 | $c=$this->content[$i++]; |
168 | 169 | if(isset($c)){ |
169 | 170 | $c->setProperty($property,$value); |
170 | - } |
|
171 | - else{ |
|
171 | + } else{ |
|
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | } |
@@ -197,8 +197,9 @@ discard block |
||
197 | 197 | foreach ( $this->content as $index=>$item ) { |
198 | 198 | if($item instanceof HtmlDoubleElement){ |
199 | 199 | $href=""; |
200 | - if(isset($hrefs[$index])) |
|
201 | - $href=$hrefs[$index]; |
|
200 | + if(isset($hrefs[$index])) { |
|
201 | + $href=$hrefs[$index]; |
|
202 | + } |
|
202 | 203 | $item->asLink($href,$target); |
203 | 204 | } |
204 | 205 | } |
@@ -9,12 +9,12 @@ 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 | protected $_startStep; |
15 | 15 | |
16 | - public function __construct( $identifier,$steps=array()){ |
|
17 | - parent::__construct( $identifier,"div", "ui steps"); |
|
16 | + public function __construct($identifier, $steps=array()) { |
|
17 | + parent::__construct($identifier, "div", "ui steps"); |
|
18 | 18 | $this->addItems($steps); |
19 | 19 | } |
20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
25 | 25 | */ |
26 | 26 | protected function createItem($value) { |
27 | - $itemO=new HtmlStepItem("item-".\sizeof($this->content),$value); |
|
27 | + $itemO=new HtmlStepItem("item-".\sizeof($this->content), $value); |
|
28 | 28 | return $itemO; |
29 | 29 | } |
30 | 30 | |
@@ -32,50 +32,50 @@ discard block |
||
32 | 32 | * @param string|array $step |
33 | 33 | * @return HtmlStepItem |
34 | 34 | */ |
35 | - public function addStep($step){ |
|
35 | + public function addStep($step) { |
|
36 | 36 | return $this->addItem($step); |
37 | 37 | } |
38 | 38 | |
39 | - public function setOrdered(){ |
|
39 | + public function setOrdered() { |
|
40 | 40 | return $this->addToProperty("class", "ordered"); |
41 | 41 | } |
42 | 42 | |
43 | - public function isOrdered(){ |
|
43 | + public function isOrdered() { |
|
44 | 44 | return $this->propertyContains("class", "ordered"); |
45 | 45 | } |
46 | 46 | |
47 | - public function setVertical(){ |
|
47 | + public function setVertical() { |
|
48 | 48 | return $this->addToProperty("class", "vertical"); |
49 | 49 | } |
50 | 50 | |
51 | - protected function defineActiveStep(){ |
|
51 | + protected function defineActiveStep() { |
|
52 | 52 | $activestep=$this->_activeStep; |
53 | 53 | $count=$this->count(); |
54 | - if(!$this->isOrdered()){ |
|
55 | - for($i=$this->_startStep;$i<$count;$i++){ |
|
54 | + if (!$this->isOrdered()) { |
|
55 | + for ($i=$this->_startStep; $i<$count; $i++) { |
|
56 | 56 | $step=$this->content[$i]; |
57 | 57 | $step->removeStatus(); |
58 | - if($i<$activestep) |
|
58 | + if ($i<$activestep) |
|
59 | 59 | $step->setCompleted(); |
60 | 60 | elseif ($i===$activestep) |
61 | 61 | $step->setActive(); |
62 | 62 | else |
63 | 63 | $step->setDisabled(); |
64 | 64 | } |
65 | - }else{ |
|
66 | - foreach ($this->content as $step){ |
|
65 | + } else { |
|
66 | + foreach ($this->content as $step) { |
|
67 | 67 | $step->removeStatus(); |
68 | 68 | } |
69 | - if($activestep<$count) |
|
69 | + if ($activestep<$count) |
|
70 | 70 | $this->content[$activestep]->setActive(); |
71 | 71 | } |
72 | 72 | return $this; |
73 | 73 | } |
74 | 74 | |
75 | 75 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
76 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
76 | + if (isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
77 | 77 | $this->defineActiveStep(); |
78 | - return parent::compile($js,$view); |
|
78 | + return parent::compile($js, $view); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function setActiveStep($_activeStep) { |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | return $this; |
84 | 84 | } |
85 | 85 | |
86 | - public function setAttached($side="",HtmlDoubleElement $toElement=NULL){ |
|
87 | - if(isset($toElement)){ |
|
88 | - $toElement->addToPropertyCtrl("class", "attached",array("attached")); |
|
86 | + public function setAttached($side="", HtmlDoubleElement $toElement=NULL) { |
|
87 | + if (isset($toElement)) { |
|
88 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
89 | 89 | } |
90 | - return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
90 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function setStartStep($_startStep) { |