@@ -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 function $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 ($e){return $e->getContent();}; |
|
52 | - if(isset($hrefFunction)){ |
|
51 | + $this->_hrefFunction=function($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 Dispatcher $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 |
@@ -65,9 +65,9 @@ discard block |
||
65 | 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{ |
|
70 | + } else{ |
|
71 | 71 | $elm=new HtmlLink("lnk-".$this->identifier."-".$size,$href,$element); |
72 | 72 | if(isset($glyph)){ |
73 | 73 | $elm->wrapContentWithGlyph($glyph); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | if($this->absolutePaths===true){ |
116 | 116 | return $this->_hrefFunction($this->content[$index]); |
117 | - }else{ |
|
117 | + } else{ |
|
118 | 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 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | if (!isset($id)) |
36 | 36 | if ($this->element->getTagName()==="a") |
37 | 37 | $id=$this->element->getProperty("href"); |
38 | - if (!isset($id)||$id==="#") { |
|
38 | + if (!isset($id) || $id==="#") { |
|
39 | 39 | $id="collapse-".$this->element->getIdentifier(); |
40 | 40 | $this->attachTo($id); |
41 | 41 | } |
@@ -24,17 +24,19 @@ discard block |
||
24 | 24 | |
25 | 25 | public function attachTo($identifier) { |
26 | 26 | $this->element->setProperty("aria-controls", $identifier); |
27 | - if ($this->element->getTagName()==="a") |
|
28 | - $this->element->setProperty("href", "#".$identifier); |
|
29 | - else |
|
30 | - $this->element->setProperty("data-target", "#".$identifier); |
|
27 | + if ($this->element->getTagName()==="a") { |
|
28 | + $this->element->setProperty("href", "#".$identifier); |
|
29 | + } else { |
|
30 | + $this->element->setProperty("data-target", "#".$identifier); |
|
31 | + } |
|
31 | 32 | } |
32 | 33 | |
33 | 34 | public function getAttachedZone() { |
34 | 35 | $id=$this->element->getProperty("aria-controls"); |
35 | - if (!isset($id)) |
|
36 | - if ($this->element->getTagName()==="a") |
|
36 | + if (!isset($id)) { |
|
37 | + if ($this->element->getTagName()==="a") |
|
37 | 38 | $id=$this->element->getProperty("href"); |
39 | + } |
|
38 | 40 | if (!isset($id)||$id==="#") { |
39 | 41 | $id="collapse-".$this->element->getIdentifier(); |
40 | 42 | $this->attachTo($id); |
@@ -49,8 +51,9 @@ discard block |
||
49 | 51 | } |
50 | 52 | |
51 | 53 | public function createCollapsedZone($content="", $attachTo=NULL) { |
52 | - if (isset($attachTo)) |
|
53 | - $this->attachTo($attachTo); |
|
54 | + if (isset($attachTo)) { |
|
55 | + $this->attachTo($attachTo); |
|
56 | + } |
|
54 | 57 | $collapsedZone=new HtmlBsDoubleElement($this->getAttachedZone()); |
55 | 58 | $collapsedZone->setProperty("class", "collapse"); |
56 | 59 | $collapsedZone->setContent($content); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | |
18 | 18 | class HtmlTabs extends HtmlBsDoubleElement { |
19 | - protected $tabs=array (); |
|
19 | + protected $tabs=array(); |
|
20 | 20 | protected $_tabsType="tabs"; |
21 | 21 | protected $stacked=""; |
22 | 22 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | protected function addTab_($tab, $index=null) { |
30 | - if($tab instanceof HtmlDropdown){ |
|
30 | + if ($tab instanceof HtmlDropdown) { |
|
31 | 31 | $tab->setMTagName("li"); |
32 | 32 | } |
33 | 33 | if (isset($index)) { |
34 | - $inserted=array ( |
|
34 | + $inserted=array( |
|
35 | 35 | $tab |
36 | 36 | ); |
37 | 37 | array_splice($this->tabs, $index, 0, $inserted); |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | $this->tabs []=$tab; |
40 | 40 | } |
41 | 41 | |
42 | - public function setActive($index){ |
|
43 | - for ($i=0;$i<sizeof($this->tabs);$i++){ |
|
42 | + public function setActive($index) { |
|
43 | + for ($i=0; $i<sizeof($this->tabs); $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 | } |
@@ -35,8 +35,9 @@ discard block |
||
35 | 35 | $tab |
36 | 36 | ); |
37 | 37 | array_splice($this->tabs, $index, 0, $inserted); |
38 | - } else |
|
39 | - $this->tabs []=$tab; |
|
38 | + } else { |
|
39 | + $this->tabs []=$tab; |
|
40 | + } |
|
40 | 41 | } |
41 | 42 | |
42 | 43 | public function setActive($index){ |
@@ -116,9 +117,9 @@ discard block |
||
116 | 117 | public function createTabContents() { |
117 | 118 | $tabContent=new HtmlTabContent("tabcontent-".$this->identifier); |
118 | 119 | foreach ( $this->tabs as $tab ) { |
119 | - if ($tab instanceof HtmlTabItem) |
|
120 | - $tabContent->addTabItem($tab->getHref()); |
|
121 | - elseif ($tab instanceof HtmlDropdown) { |
|
120 | + if ($tab instanceof HtmlTabItem) { |
|
121 | + $tabContent->addTabItem($tab->getHref()); |
|
122 | + } elseif ($tab instanceof HtmlDropdown) { |
|
122 | 123 | foreach ( $tab->getItems() as $dropdownItem ) { |
123 | 124 | $tabContent->addTabItem($dropdownItem->getHref()); |
124 | 125 | } |
@@ -137,8 +138,9 @@ discard block |
||
137 | 138 | |
138 | 139 | public function setContentToTab($index, $text) { |
139 | 140 | $tabContentItem=$this->content->getTabItem($index); |
140 | - if (isset($tabContentItem)) |
|
141 | - $tabContentItem->setContent($text); |
|
141 | + if (isset($tabContentItem)) { |
|
142 | + $tabContentItem->setContent($text); |
|
143 | + } |
|
142 | 144 | } |
143 | 145 | |
144 | 146 | public function countTabs() { |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | } |
147 | 149 | |
148 | 150 | public function getTabItem($index) { |
149 | - if ($index<sizeof($this->content->get)) |
|
150 | - return $this->content; |
|
151 | + if ($index<sizeof($this->content->get)) { |
|
152 | + return $this->content; |
|
153 | + } |
|
151 | 154 | } |
152 | 155 | |
153 | 156 | public function fadeEffect() { |
@@ -168,9 +171,11 @@ discard block |
||
168 | 171 | } |
169 | 172 | |
170 | 173 | public function setStacked($stacked=true){ |
171 | - if($stacked) |
|
172 | - $this->stacked="nav-stacked"; |
|
173 | - else $this->stacked=""; |
|
174 | + if($stacked) { |
|
175 | + $this->stacked="nav-stacked"; |
|
176 | + } else { |
|
177 | + $this->stacked=""; |
|
178 | + } |
|
174 | 179 | } |
175 | 180 | |
176 | 181 | /* (non-PHPdoc) |
@@ -13,6 +13,9 @@ |
||
13 | 13 | */ |
14 | 14 | class HtmlIconGroups extends HtmlSemCollection { |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $identifier |
|
18 | + */ |
|
16 | 19 | public function __construct($identifier, $icons=array(), $size="") { |
17 | 20 | parent::__construct($identifier, "i", "icons"); |
18 | 21 | $this->addItems($icons); |
@@ -23,19 +23,19 @@ |
||
23 | 23 | return $this; |
24 | 24 | } |
25 | 25 | |
26 | - public function addGlyph($glyphicon,$before=true){ |
|
26 | + public function addGlyph($glyphicon, $before=true) { |
|
27 | 27 | $glyph=new HtmlGlyphicon(""); |
28 | 28 | $glyph->setGlyphicon($glyphicon); |
29 | - $this->addContent($glyph,$before); |
|
29 | + $this->addContent($glyph, $before); |
|
30 | 30 | return $this; |
31 | 31 | } |
32 | 32 | |
33 | - public function wrapContentWithGlyph($glyphBefore,$glyphAfter=""){ |
|
33 | + public function wrapContentWithGlyph($glyphBefore, $glyphAfter="") { |
|
34 | 34 | $before=HtmlGlyphicon::getGlyphicon($glyphBefore)." "; |
35 | 35 | $after=""; |
36 | - if($glyphAfter!==""){ |
|
36 | + if ($glyphAfter!=="") { |
|
37 | 37 | $after=" ".HtmlGlyphicon::getGlyphicon($glyphAfter); |
38 | 38 | } |
39 | - return $this->wrapContent($before,$after); |
|
39 | + return $this->wrapContent($before, $after); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | \ No newline at end of file |
@@ -32,11 +32,11 @@ |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | public function addBadge($caption, $leftSeparator=" ") { |
35 | - return $this->element->addBadge($caption,$leftSeparator); |
|
35 | + return $this->element->addBadge($caption, $leftSeparator); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function addLabel($caption, $style="label-default", $leftSeparator=" ") { |
39 | - return $this->element->addLabel($caption,$style,$leftSeparator); |
|
39 | + return $this->element->addLabel($caption, $style, $leftSeparator); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function run(JsUtils $js) { |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | const CSS_DEFAULT="-default", CSS_PRIMARY="-primary", CSS_SUCCESS="-success", CSS_INFO="-info", CSS_WARNING="-warning", CSS_DANGER="-danger", CSS_LINK="-link"; |
15 | 15 | |
16 | 16 | public static function buttonStyles() { |
17 | - return array ( |
|
17 | + return array( |
|
18 | 18 | "btn-default", |
19 | 19 | "btn-primary", |
20 | 20 | "btn-success", |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | public static function Styles($prefix="btn") { |
29 | - return array ( |
|
29 | + return array( |
|
30 | 30 | $prefix."-default", |
31 | 31 | $prefix."-primary", |
32 | 32 | $prefix."-success", |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | public static function sizes($prefix="btn") { |
40 | - return array ( |
|
40 | + return array( |
|
41 | 41 | $prefix."-lg", |
42 | 42 | "", |
43 | 43 | $prefix."-sm", |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | public static function position() { |
49 | - return array ( |
|
49 | + return array( |
|
50 | 50 | "top", |
51 | 51 | "left", |
52 | 52 | "right", |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | public static function alignment($prefix="") { |
59 | - return array ( |
|
59 | + return array( |
|
60 | 60 | $prefix."", |
61 | 61 | $prefix."left", |
62 | 62 | $prefix."right", |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public static function navbarZoneClasses() { |
69 | - return array ( |
|
69 | + return array( |
|
70 | 70 | "navbar-nav", |
71 | 71 | "navbar-left", |
72 | 72 | "navbar-right", |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | public static function glyphIcons() { |
78 | - return array ( |
|
78 | + return array( |
|
79 | 79 | "glyphicon-asterisk", |
80 | 80 | "glyphicon-plus", |
81 | 81 | "glyphicon-euro", |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | public static function getStyle($cssStyle, $prefix) { |
348 | 348 | if (is_int($cssStyle)) { |
349 | 349 | $styles=CssRef::Styles($prefix); |
350 | - if ($cssStyle<sizeof($styles)&&$cssStyle>=0) { |
|
350 | + if ($cssStyle<sizeof($styles) && $cssStyle>=0) { |
|
351 | 351 | return CssRef::styles($prefix)[$cssStyle]; |
352 | 352 | } else { |
353 | 353 | throw new \Exception("La valeur passée a propriété `Style` ne fait pas partie des valeurs possibles : index '".$cssStyle."' inexistant"); |
@@ -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 Dispatcher $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(!PhalconUtils::startsWith($size, "pagination-") && $size!=="") |
|
149 | + if (!PhalconUtils::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 | } |
@@ -52,10 +52,11 @@ discard block |
||
52 | 52 | $this->from=$from; |
53 | 53 | $this->to=$to; |
54 | 54 | $this->urlMask="%page%"; |
55 | - if(!isset($countVisible)) |
|
56 | - $this->countVisible=$to-$from+1; |
|
57 | - else |
|
58 | - $this->countVisible=$countVisible; |
|
55 | + if(!isset($countVisible)) { |
|
56 | + $this->countVisible=$to-$from+1; |
|
57 | + } else { |
|
58 | + $this->countVisible=$countVisible; |
|
59 | + } |
|
59 | 60 | $this->createContent(); |
60 | 61 | } |
61 | 62 | |
@@ -74,7 +75,7 @@ discard block |
||
74 | 75 | $href=new HtmlLink("a-".$this->identifier."-".$count,$url,$content); |
75 | 76 | $href->setProperty($this->attr, $url); |
76 | 77 | $elem->setContent($href); |
77 | - }else{ |
|
78 | + } else{ |
|
78 | 79 | $elem->setContent($content); |
79 | 80 | } |
80 | 81 | $this->content[]=$elem; |
@@ -107,8 +108,9 @@ discard block |
||
107 | 108 | public function _addEvent($event, $jsCode) { |
108 | 109 | foreach ($this->content as $li){ |
109 | 110 | $content=$li->getContent(); |
110 | - if($content instanceof BaseHtml) |
|
111 | - $content->_addEvent($event,$jsCode); |
|
111 | + if($content instanceof BaseHtml) { |
|
112 | + $content->_addEvent($event,$jsCode); |
|
113 | + } |
|
112 | 114 | } |
113 | 115 | } |
114 | 116 | /** |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | if (is_int($size)) { |
147 | 149 | return $this->addToPropertyUnique("class", CssRef::sizes("pagination")[$size], CssRef::sizes("pagination")); |
148 | 150 | } |
149 | - if(!PhalconUtils::startsWith($size, "pagination-") && $size!=="") |
|
150 | - $size="pagination-".$size; |
|
151 | + if(!PhalconUtils::startsWith($size, "pagination-") && $size!=="") { |
|
152 | + $size="pagination-".$size; |
|
153 | + } |
|
151 | 154 | return $this->addToPropertyCtrl("class", $size, CssRef::sizes("pagination")); |
152 | 155 | } |
153 | 156 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function __construct($identifier, $tagName="ul") { |
17 | 17 | parent::__construct($identifier, $tagName); |
18 | - $this->content=array (); |
|
18 | + $this->content=array(); |
|
19 | 19 | $this->_template='<%tagName% %properties%>%content%</%tagName%>'; |
20 | 20 | $this->setProperty("class", "list-group"); |
21 | 21 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | if (is_object($text)) { |
25 | 25 | $element=$text; |
26 | 26 | } else { |
27 | - switch($this->tagName) { |
|
27 | + switch ($this->tagName) { |
|
28 | 28 | case "ul": |
29 | 29 | $element=new HtmlBsDoubleElement("list-gi-".$this->identifier); |
30 | 30 | $element->setTagName("li"); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | public function addItems($items) { |
48 | - foreach ( $items as $item ) { |
|
48 | + foreach ($items as $item) { |
|
49 | 49 | if (is_string($item)) { |
50 | 50 | $this->addItem($item); |
51 | 51 | } else |
@@ -48,14 +48,16 @@ |
||
48 | 48 | foreach ( $items as $item ) { |
49 | 49 | if (is_string($item)) { |
50 | 50 | $this->addItem($item); |
51 | - } else |
|
52 | - $this->content []=$item; |
|
51 | + } else { |
|
52 | + $this->content []=$item; |
|
53 | + } |
|
53 | 54 | } |
54 | 55 | } |
55 | 56 | |
56 | 57 | public function getItem($index) { |
57 | - if ($index<sizeof($this->content)) |
|
58 | - return $this->content [$index]; |
|
58 | + if ($index<sizeof($this->content)) { |
|
59 | + return $this->content [$index]; |
|
60 | + } |
|
59 | 61 | } |
60 | 62 | |
61 | 63 | /* (non-PHPdoc) |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
31 | 31 | $result=""; |
32 | - foreach ( $this->_elements as $element ) { |
|
32 | + foreach ($this->_elements as $element) { |
|
33 | 33 | if ($element instanceof PhBsElement) |
34 | 34 | $result.=$element->compile($js, $view); |
35 | 35 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | public function run(JsUtils $js) { |
40 | - foreach ( $this->_elements as $element ) { |
|
40 | + foreach ($this->_elements as $element) { |
|
41 | 41 | if ($element instanceof PhBsElement) |
42 | 42 | $element->run($js); |
43 | 43 | } |
@@ -30,16 +30,18 @@ |
||
30 | 30 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
31 | 31 | $result=""; |
32 | 32 | foreach ( $this->_elements as $element ) { |
33 | - if ($element instanceof PhBsElement) |
|
34 | - $result.=$element->compile($js, $view); |
|
33 | + if ($element instanceof PhBsElement) { |
|
34 | + $result.=$element->compile($js, $view); |
|
35 | + } |
|
35 | 36 | } |
36 | 37 | return $result; |
37 | 38 | } |
38 | 39 | |
39 | 40 | public function run(JsUtils $js) { |
40 | 41 | foreach ( $this->_elements as $element ) { |
41 | - if ($element instanceof PhBsElement) |
|
42 | - $element->run($js); |
|
42 | + if ($element instanceof PhBsElement) { |
|
43 | + $element->run($js); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | } |
45 | 47 | } |
46 | 48 | \ No newline at end of file |