@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | * @param boolean $autoActive sets the last element's class to <b>active</b> if true |
42 | 42 | * @param callable $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
43 | 43 | */ |
44 | - public function __construct($identifier,$elements=array(),$autoActive=true,$startIndex=0,$hrefFunction=NULL){ |
|
45 | - parent::__construct($identifier,"ol"); |
|
44 | + public function __construct($identifier, $elements=array(), $autoActive=true, $startIndex=0, $hrefFunction=NULL) { |
|
45 | + parent::__construct($identifier, "ol"); |
|
46 | 46 | $this->startIndex=$startIndex; |
47 | 47 | $this->setProperty("class", "breadcrumb"); |
48 | 48 | $this->content=array(); |
49 | 49 | $this->autoActive=$autoActive; |
50 | 50 | $this->absolutePaths; |
51 | - $this->_hrefFunction=function (HtmlDoubleElement $e){return $e->getContent();}; |
|
52 | - if(isset($hrefFunction)){ |
|
51 | + $this->_hrefFunction=function(HtmlDoubleElement $e) {return $e->getContent(); }; |
|
52 | + if (isset($hrefFunction)) { |
|
53 | 53 | $this->_hrefFunction=$hrefFunction; |
54 | 54 | } |
55 | 55 | $this->addElements($elements); |
@@ -60,43 +60,43 @@ discard block |
||
60 | 60 | * @param string $href |
61 | 61 | * @return \Ajax\bootstrap\html\HtmlLink |
62 | 62 | */ |
63 | - public function addElement($element,$href="",$glyph=NULL){ |
|
63 | + public function addElement($element, $href="", $glyph=NULL) { |
|
64 | 64 | $size=sizeof($this->content); |
65 | - if(\is_array($element)){ |
|
65 | + if (\is_array($element)) { |
|
66 | 66 | $elm=new HtmlLink("lnk-".$this->identifier."-".$size); |
67 | 67 | $elm->fromArray($element); |
68 | - }else if($element instanceof HtmlLink){ |
|
68 | + } else if ($element instanceof HtmlLink) { |
|
69 | 69 | $elm=$element; |
70 | - }else{ |
|
71 | - $elm=new HtmlLink("lnk-".$this->identifier."-".$size,$href,$element); |
|
72 | - if(isset($glyph)){ |
|
70 | + } else { |
|
71 | + $elm=new HtmlLink("lnk-".$this->identifier."-".$size, $href, $element); |
|
72 | + if (isset($glyph)) { |
|
73 | 73 | $elm->wrapContentWithGlyph($glyph); |
74 | 74 | } |
75 | 75 | } |
76 | - $elm->wrap("<li>","</li>"); |
|
76 | + $elm->wrap("<li>", "</li>"); |
|
77 | 77 | $this->content[]=$elm; |
78 | 78 | $elm->setProperty($this->attr, $this->getHref($size)); |
79 | 79 | return $elm; |
80 | 80 | } |
81 | 81 | |
82 | - public function setActive($index=null){ |
|
83 | - if(!isset($index)){ |
|
82 | + public function setActive($index=null) { |
|
83 | + if (!isset($index)) { |
|
84 | 84 | $index=sizeof($this->content)-1; |
85 | 85 | } |
86 | - $li=new HtmlBsDoubleElement("","li"); |
|
86 | + $li=new HtmlBsDoubleElement("", "li"); |
|
87 | 87 | $li->setClass("active"); |
88 | 88 | $li->setContent($this->content[$index]->getContent()); |
89 | 89 | $this->content[$index]=$li; |
90 | 90 | } |
91 | 91 | |
92 | - public function addElements($elements){ |
|
93 | - foreach ( $elements as $element ) { |
|
92 | + public function addElements($elements) { |
|
93 | + foreach ($elements as $element) { |
|
94 | 94 | $this->addElement($element); |
95 | 95 | } |
96 | 96 | return $this; |
97 | 97 | } |
98 | 98 | |
99 | - public function fromArray($array){ |
|
99 | + public function fromArray($array) { |
|
100 | 100 | $array=parent::fromArray($array); |
101 | 101 | $this->addElements($array); |
102 | 102 | return $array; |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | * @param string $separator |
109 | 109 | * @return string |
110 | 110 | */ |
111 | - public function getHref($index=null,$separator="/"){ |
|
112 | - if(!isset($index)){ |
|
111 | + public function getHref($index=null, $separator="/") { |
|
112 | + if (!isset($index)) { |
|
113 | 113 | $index=sizeof($this->content); |
114 | 114 | } |
115 | - if($this->absolutePaths===true){ |
|
115 | + if ($this->absolutePaths===true) { |
|
116 | 116 | return $this->_hrefFunction($this->content[$index]); |
117 | - }else{ |
|
118 | - return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),$this->startIndex,$index+1)); |
|
117 | + } else { |
|
118 | + return $this->root.implode($separator, array_slice(array_map(function($e) {return $this->_hrefFunction($e); }, $this->content), $this->startIndex, $index+1)); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @see \Ajax\bootstrap\html\BaseHtml::compile() |
125 | 125 | */ |
126 | 126 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
127 | - if($this->autoActive){ |
|
127 | + if ($this->autoActive) { |
|
128 | 128 | $this->setActive(); |
129 | 129 | } |
130 | 130 | return parent::compile($js, $view); |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
143 | 143 | */ |
144 | 144 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
145 | - foreach ($this->content as $element){ |
|
146 | - $element->on($event,$jsCode,$stopPropagation,$preventDefault); |
|
145 | + foreach ($this->content as $element) { |
|
146 | + $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
147 | 147 | } |
148 | 148 | return $this; |
149 | 149 | } |
150 | 150 | |
151 | 151 | public function setAutoActive($autoActive) { |
152 | - $this->autoActive = $autoActive; |
|
152 | + $this->autoActive=$autoActive; |
|
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
156 | 156 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
157 | - foreach ($this->content as $element){ |
|
157 | + foreach ($this->content as $element) { |
|
158 | 158 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
159 | 159 | } |
160 | 160 | return $this; |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | * @param string $targetSelector the target of the get |
167 | 167 | * @return HtmlBreadcrumbs |
168 | 168 | */ |
169 | - public function autoGetOnClick($targetSelector){ |
|
170 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
169 | + public function autoGetOnClick($targetSelector) { |
|
170 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
171 | 171 | } |
172 | 172 | |
173 | - public function contentAsString(){ |
|
174 | - if($this->autoActive){ |
|
173 | + public function contentAsString() { |
|
174 | + if ($this->autoActive) { |
|
175 | 175 | $this->setActive(); |
176 | 176 | } |
177 | 177 | return parent::contentAsString(); |
178 | 178 | } |
179 | 179 | |
180 | - public function getElement($index){ |
|
180 | + public function getElement($index) { |
|
181 | 181 | return $this->content[$index]; |
182 | 182 | } |
183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param mixed $glyph |
187 | 187 | * @param int $index |
188 | 188 | */ |
189 | - public function addGlyph($glyph,$index=0){ |
|
189 | + public function addGlyph($glyph, $index=0) { |
|
190 | 190 | $elm=$this->getElement($index); |
191 | 191 | return $elm->wrapContentWithGlyph($glyph); |
192 | 192 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param object $dispatcher the request dispatcher |
198 | 198 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
199 | 199 | */ |
200 | - public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0){ |
|
200 | + public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0) { |
|
201 | 201 | $this->startIndex=$startIndex; |
202 | 202 | return $this->addElements($js->fromDispatcher($dispatcher)); |
203 | 203 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
210 | 210 | */ |
211 | 211 | public function setHrefFunction($_hrefFunction) { |
212 | - $this->_hrefFunction = $_hrefFunction; |
|
212 | + $this->_hrefFunction=$_hrefFunction; |
|
213 | 213 | return $this; |
214 | 214 | } |
215 | 215 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | use Ajax\bootstrap\html\content\HtmlTabContent; |
16 | 16 | |
17 | 17 | class HtmlTabs extends HtmlBsDoubleElement { |
18 | - protected $tabs=array (); |
|
18 | + protected $tabs=array(); |
|
19 | 19 | protected $_tabsType="tabs"; |
20 | 20 | protected $stacked=""; |
21 | 21 | |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | protected function addTab_($tab, $index=null) { |
29 | - if($tab instanceof HtmlDropdown){ |
|
29 | + if ($tab instanceof HtmlDropdown) { |
|
30 | 30 | $tab->setMTagName("li"); |
31 | 31 | } |
32 | 32 | if (isset($index)) { |
33 | - $inserted=array ( |
|
33 | + $inserted=array( |
|
34 | 34 | $tab |
35 | 35 | ); |
36 | 36 | array_splice($this->tabs, $index, 0, $inserted); |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | $this->tabs []=$tab; |
39 | 39 | } |
40 | 40 | |
41 | - public function setActive($index){ |
|
41 | + public function setActive($index) { |
|
42 | 42 | $size=\sizeof($this->tabs); |
43 | - for ($i=0;$i<$size;$i++){ |
|
43 | + for ($i=0; $i<$size; $i++) { |
|
44 | 44 | $this->tabs[$i]->setActive($i==$index); |
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | - public function disable($index){ |
|
48 | + public function disable($index) { |
|
49 | 49 | $this->tabs[$index]->disable(); |
50 | 50 | } |
51 | 51 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | public function addTabs($tabs) { |
79 | - foreach ( $tabs as $tab ) { |
|
79 | + foreach ($tabs as $tab) { |
|
80 | 80 | $this->addTab($tab); |
81 | 81 | } |
82 | 82 | return $this; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function run(JsUtils $js) { |
108 | 108 | $this->_bsComponent=new Tabs($js); |
109 | - foreach ( $this->tabs as $tab ) { |
|
109 | + foreach ($this->tabs as $tab) { |
|
110 | 110 | $this->_bsComponent->addTab($tab->run($js)); |
111 | 111 | } |
112 | 112 | $this->addEventsOnRun($js); |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | |
116 | 116 | public function createTabContents() { |
117 | 117 | $tabContent=new HtmlTabContent("tabcontent-".$this->identifier); |
118 | - foreach ( $this->tabs as $tab ) { |
|
118 | + foreach ($this->tabs as $tab) { |
|
119 | 119 | if ($tab instanceof HtmlTabItem) |
120 | 120 | $tabContent->addTabItem($tab->getHref()); |
121 | 121 | elseif ($tab instanceof HtmlDropdown) { |
122 | - foreach ( $tab->getItems() as $dropdownItem ) { |
|
122 | + foreach ($tab->getItems() as $dropdownItem) { |
|
123 | 123 | $tabContent->addTabItem($dropdownItem->getHref()); |
124 | 124 | } |
125 | 125 | } |
@@ -154,21 +154,21 @@ discard block |
||
154 | 154 | if (sizeof($this->content->getTabItems())>0) { |
155 | 155 | $this->content->getTabItem(0)->addToProperty("class", "fade in"); |
156 | 156 | $size=sizeof($this->tabs); |
157 | - for($index=0; $index<$size; $index++) { |
|
157 | + for ($index=0; $index<$size; $index++) { |
|
158 | 158 | $this->content->getTabItem($index)->addToProperty("class", "fade"); |
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - public function on($event, $jsCode,$stopPropagation=false,$preventDefault=false){ |
|
164 | - foreach ($this->tabs as $tab){ |
|
165 | - $tab->on($event,$jsCode,$stopPropagation,$preventDefault); |
|
163 | + public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
|
164 | + foreach ($this->tabs as $tab) { |
|
165 | + $tab->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
166 | 166 | } |
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | - public function setStacked($stacked=true){ |
|
171 | - if($stacked) |
|
170 | + public function setStacked($stacked=true) { |
|
171 | + if ($stacked) |
|
172 | 172 | $this->stacked="nav-stacked"; |
173 | 173 | else $this->stacked=""; |
174 | 174 | } |
@@ -45,70 +45,70 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @param string $identifier |
47 | 47 | */ |
48 | - public function __construct($identifier,$from=1,$to=1,$active=NULL,$countVisible=NULL){ |
|
49 | - parent::__construct($identifier,"ul"); |
|
48 | + public function __construct($identifier, $from=1, $to=1, $active=NULL, $countVisible=NULL) { |
|
49 | + parent::__construct($identifier, "ul"); |
|
50 | 50 | $this->setProperty("class", "pagination"); |
51 | 51 | $this->active=$active; |
52 | 52 | $this->from=$from; |
53 | 53 | $this->to=$to; |
54 | 54 | $this->urlMask="%page%"; |
55 | - if(!isset($countVisible)) |
|
55 | + if (!isset($countVisible)) |
|
56 | 56 | $this->countVisible=$to-$from+1; |
57 | 57 | else |
58 | 58 | $this->countVisible=$countVisible; |
59 | 59 | $this->createContent(); |
60 | 60 | } |
61 | 61 | |
62 | - private function createElement($num,$content,$disabled=false,$current=false){ |
|
62 | + private function createElement($num, $content, $disabled=false, $current=false) { |
|
63 | 63 | $count=sizeof($this->content)+1; |
64 | - $elem=new HtmlBsDoubleElement("li-".$this->identifier."-".$count,"li"); |
|
65 | - if($disabled){ |
|
64 | + $elem=new HtmlBsDoubleElement("li-".$this->identifier."-".$count, "li"); |
|
65 | + if ($disabled) { |
|
66 | 66 | $elem->setProperty("class", "disabled"); |
67 | 67 | } |
68 | - if($current){ |
|
68 | + if ($current) { |
|
69 | 69 | $content.="<span class='sr-only'>(current)</span>"; |
70 | 70 | $elem->setProperty("class", "active"); |
71 | 71 | } |
72 | - if(!$disabled){ |
|
72 | + if (!$disabled) { |
|
73 | 73 | $url=$this->getUrl($num); |
74 | - $href=new HtmlLink("a-".$this->identifier."-".$count,$url,$content); |
|
74 | + $href=new HtmlLink("a-".$this->identifier."-".$count, $url, $content); |
|
75 | 75 | $href->setProperty($this->attr, $url); |
76 | 76 | $elem->setContent($href); |
77 | - }else{ |
|
77 | + } else { |
|
78 | 78 | $elem->setContent($content); |
79 | 79 | } |
80 | 80 | $this->content[]=$elem; |
81 | 81 | return $this; |
82 | 82 | } |
83 | 83 | |
84 | - protected function createContent(){ |
|
84 | + protected function createContent() { |
|
85 | 85 | $this->content=array(); |
86 | - $this->createElement($this->active-1,"<span aria-hidden='true'>«</span>",$this->active===1); |
|
86 | + $this->createElement($this->active-1, "<span aria-hidden='true'>«</span>", $this->active===1); |
|
87 | 87 | $start=$this->getStart(); |
88 | - $end=min($start+$this->countVisible-1,$this->to); |
|
89 | - for($index=$start;$index<=$end;$index++){ |
|
90 | - $this->createElement($index,$index,false,$index===$this->active); |
|
88 | + $end=min($start+$this->countVisible-1, $this->to); |
|
89 | + for ($index=$start; $index<=$end; $index++) { |
|
90 | + $this->createElement($index, $index, false, $index===$this->active); |
|
91 | 91 | } |
92 | - $this->createElement($this->active+1,"<span aria-hidden='true'>»</span>",$this->active===$this->to); |
|
92 | + $this->createElement($this->active+1, "<span aria-hidden='true'>»</span>", $this->active===$this->to); |
|
93 | 93 | } |
94 | 94 | |
95 | - protected function half(){ |
|
95 | + protected function half() { |
|
96 | 96 | return (int)($this->countVisible/2); |
97 | 97 | } |
98 | 98 | |
99 | - protected function getStart(){ |
|
99 | + protected function getStart() { |
|
100 | 100 | $result=1; |
101 | - if($this->countVisible!==$this->to-$this->from+1){ |
|
102 | - $result=max($this->active-$this->half(),$result); |
|
101 | + if ($this->countVisible!==$this->to-$this->from+1) { |
|
102 | + $result=max($this->active-$this->half(), $result); |
|
103 | 103 | } |
104 | 104 | return $result; |
105 | 105 | } |
106 | 106 | |
107 | 107 | public function _addEvent($event, $jsCode) { |
108 | - foreach ($this->content as $li){ |
|
108 | + foreach ($this->content as $li) { |
|
109 | 109 | $content=$li->getContent(); |
110 | - if($content instanceof BaseHtml) |
|
111 | - $content->_addEvent($event,$jsCode); |
|
110 | + if ($content instanceof BaseHtml) |
|
111 | + $content->_addEvent($event, $jsCode); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | /** |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | * @param object $dispatcher the request dispatcher |
118 | 118 | * @return \Ajax\bootstrap\html\HtmlPagination |
119 | 119 | */ |
120 | - public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0){ |
|
120 | + public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0) { |
|
121 | 121 | $items=$js->fromDispatcher($dispatcher); |
122 | 122 | $url=implode("/", $items); |
123 | - if($this->urlMask==="%page%"){ |
|
123 | + if ($this->urlMask==="%page%") { |
|
124 | 124 | $this->urlMask=preg_replace("/[0-9]/", "%page%", $url); |
125 | 125 | } |
126 | - for($index=$this->from;$index<=$this->to;$index++){ |
|
127 | - if($this->getUrl($index)==$url){ |
|
126 | + for ($index=$this->from; $index<=$this->to; $index++) { |
|
127 | + if ($this->getUrl($index)==$url) { |
|
128 | 128 | $this->setActive($index); |
129 | 129 | break; |
130 | 130 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | return $this; |
133 | 133 | } |
134 | 134 | |
135 | - public function getUrl($index){ |
|
135 | + public function getUrl($index) { |
|
136 | 136 | return str_ireplace("%page%", $index, $this->urlMask); |
137 | 137 | } |
138 | 138 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | if (is_int($size)) { |
147 | 147 | return $this->addToPropertyUnique("class", CssRef::sizes("pagination")[$size], CssRef::sizes("pagination")); |
148 | 148 | } |
149 | - if(!JString::startsWith($size, "pagination-") && $size!=="") |
|
149 | + if (!JString::startsWith($size, "pagination-") && $size!=="") |
|
150 | 150 | $size="pagination-".$size; |
151 | 151 | return $this->addToPropertyCtrl("class", $size, CssRef::sizes("pagination")); |
152 | 152 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | return $this->from; |
156 | 156 | } |
157 | 157 | public function setFrom($from) { |
158 | - $this->from = $from; |
|
158 | + $this->from=$from; |
|
159 | 159 | $this->createContent(); |
160 | 160 | return $this; |
161 | 161 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return $this->to; |
164 | 164 | } |
165 | 165 | public function setTo($to) { |
166 | - $this->to = $to; |
|
166 | + $this->to=$to; |
|
167 | 167 | $this->createContent(); |
168 | 168 | return $this; |
169 | 169 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | return $this->active; |
172 | 172 | } |
173 | 173 | public function setActive($active) { |
174 | - $this->active = $active; |
|
174 | + $this->active=$active; |
|
175 | 175 | $this->createContent(); |
176 | 176 | return $this; |
177 | 177 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | return $this->urlMask; |
180 | 180 | } |
181 | 181 | public function setUrlMask($urlMask) { |
182 | - $this->urlMask = $urlMask; |
|
182 | + $this->urlMask=$urlMask; |
|
183 | 183 | $this->createContent(); |
184 | 184 | return $this; |
185 | 185 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | return $this->countVisible; |
188 | 188 | } |
189 | 189 | public function setCountVisible($countVisible) { |
190 | - $this->countVisible = $countVisible; |
|
190 | + $this->countVisible=$countVisible; |
|
191 | 191 | $this->createContent(); |
192 | 192 | return $this; |
193 | 193 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $this->setClass("panel-group"); |
20 | 20 | $this->setRole("tablist"); |
21 | 21 | $this->setProperty("aria-multiselectable", "true"); |
22 | - $this->content=array (); |
|
22 | + $this->content=array(); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function addPanel($title, $content) { |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @param string $viewName |
46 | 46 | * @param array $params The parameters to pass to the view |
47 | 47 | */ |
48 | - public function renderViewPanel(JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
|
49 | - return $this->addPanel($title, $js->renderContent($initialController, $viewName,$params)); |
|
48 | + public function renderViewPanel(JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
49 | + return $this->addPanel($title, $js->renderContent($initialController, $viewName, $params)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * @param string $action a Phalcon action |
59 | 59 | * @param array $params |
60 | 60 | */ |
61 | - public function forwardPanel(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
|
62 | - return $this->addPanel($title, $js->forward($initialController, $controller, $action,$params)); |
|
61 | + public function forwardPanel(JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
62 | + return $this->addPanel($title, $js->forward($initialController, $controller, $action, $params)); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function run(JsUtils $js) { |
66 | - foreach ( $this->content as $content ) { |
|
66 | + foreach ($this->content as $content) { |
|
67 | 67 | $content->run($js); |
68 | 68 | } |
69 | 69 | } |
@@ -3,11 +3,11 @@ |
||
3 | 3 | namespace Ajax\common\html\html5; |
4 | 4 | |
5 | 5 | class HtmlUtils { |
6 | - public static function javascriptInclude($url){ |
|
6 | + public static function javascriptInclude($url) { |
|
7 | 7 | return '<script src="'.$url.'"></script>'; |
8 | 8 | } |
9 | 9 | |
10 | - public static function stylesheetInclude($url){ |
|
10 | + public static function stylesheetInclude($url) { |
|
11 | 11 | return '<link rel="stylesheet" type="text/css" href="'.$url.'">'; |
12 | 12 | } |
13 | 13 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function __construct($identifier, $brand="Brand", $brandHref="#") { |
33 | 33 | parent::__construct($identifier); |
34 | 34 | $this->_template=include 'templates/tplNavbar.php'; |
35 | - $this->navZones=array (); |
|
35 | + $this->navZones=array(); |
|
36 | 36 | $this->class="navbar-default"; |
37 | 37 | $this->brand=$brand; |
38 | 38 | $this->brandHref=$brandHref; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | public function setBrandImage($imageSrc) { |
63 | - $this->brandImage=new HtmlImg("brand-img-".$this->_identifier,$imageSrc,$this->brand); |
|
63 | + $this->brandImage=new HtmlImg("brand-img-".$this->_identifier, $imageSrc, $this->brand); |
|
64 | 64 | $this->brand=""; |
65 | 65 | return $this; |
66 | 66 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | public function setNavZones($navZones) { |
106 | 106 | if (\is_array($navZones)) { |
107 | - foreach ( $navZones as $zoneType => $zoneArray ) { |
|
107 | + foreach ($navZones as $zoneType => $zoneArray) { |
|
108 | 108 | if (is_string($zoneType)) { |
109 | 109 | $zone=$this->addZone($zoneType); |
110 | 110 | $zone->fromArray($zoneArray); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | if ($index<$nb) |
145 | 145 | $zone=$this->navZones [$index]; |
146 | 146 | } else { |
147 | - for($i=0; $i<$nb; $i++) { |
|
147 | + for ($i=0; $i<$nb; $i++) { |
|
148 | 148 | if ($this->navZones [$i]->getIdentifier()===$index) { |
149 | 149 | $zone=$this->navZones [$i]; |
150 | 150 | break; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | public function run(JsUtils $js) { |
158 | - foreach ( $this->navZones as $zone ) { |
|
158 | + foreach ($this->navZones as $zone) { |
|
159 | 159 | $zone->run($js); |
160 | 160 | } |
161 | 161 | if ($this->hasScrollspy) { |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | public function setFluid($fluid) { |
180 | - if($fluid===true){ |
|
180 | + if ($fluid===true) { |
|
181 | 181 | $this->fluid="container-fluid"; |
182 | - }else{ |
|
182 | + } else { |
|
183 | 183 | $this->fluid="container"; |
184 | 184 | } |
185 | 185 | 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); |
@@ -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 | } |
@@ -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; |