@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | protected $attr; |
20 | 20 | |
21 | 21 | |
22 | - public function __construct($identifier,$tagName){ |
|
23 | - parent::__construct($identifier,$tagName); |
|
22 | + public function __construct($identifier, $tagName) { |
|
23 | + parent::__construct($identifier, $tagName); |
|
24 | 24 | $this->root=""; |
25 | 25 | $this->attr="data-ajax"; |
26 | 26 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | * @param string $attr the html attribute used to build the elements url |
33 | 33 | * @return HtmlNavElement |
34 | 34 | */ |
35 | - public function autoGetOnClick($targetSelector){ |
|
36 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
35 | + public function autoGetOnClick($targetSelector) { |
|
36 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
37 | 37 | } |
38 | 38 | |
39 | - public function contentAsString(){ |
|
39 | + public function contentAsString() { |
|
40 | 40 | return implode("", $this->content); |
41 | 41 | } |
42 | 42 | |
@@ -44,15 +44,15 @@ discard block |
||
44 | 44 | * Generate the jquery script to set the elements to the HtmlNavElement |
45 | 45 | * @param JsUtils $jsUtils |
46 | 46 | */ |
47 | - public function jsSetContent(JsUtils $jsUtils){ |
|
48 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
47 | + public function jsSetContent(JsUtils $jsUtils) { |
|
48 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | public function getRoot() { |
52 | 52 | return $this->root; |
53 | 53 | } |
54 | 54 | public function setRoot($root) { |
55 | - $this->root = $root; |
|
55 | + $this->root=$root; |
|
56 | 56 | return $this; |
57 | 57 | } |
58 | 58 | public function getAttr() { |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | * @return HtmlNavElement |
66 | 66 | */ |
67 | 67 | public function setAttr($attr) { |
68 | - $this->attr = $attr; |
|
68 | + $this->attr=$attr; |
|
69 | 69 | return $this; |
70 | 70 | } |
71 | 71 | |
72 | 72 | public function __call($method, $args) { |
73 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
73 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
74 | 74 | return call_user_func_array( |
75 | 75 | $this->$method, |
76 | 76 | $args |
@@ -78,6 +78,6 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | - public abstract function fromDispatcher($dispatcher,$startIndex=0); |
|
81 | + public abstract function fromDispatcher($dispatcher, $startIndex=0); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -44,70 +44,70 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * @param string $identifier |
46 | 46 | */ |
47 | - public function __construct($identifier,$from=1,$to=1,$active=NULL,$countVisible=NULL){ |
|
48 | - parent::__construct($identifier,"ul"); |
|
47 | + public function __construct($identifier, $from=1, $to=1, $active=NULL, $countVisible=NULL) { |
|
48 | + parent::__construct($identifier, "ul"); |
|
49 | 49 | $this->setProperty("class", "pagination"); |
50 | 50 | $this->active=$active; |
51 | 51 | $this->from=$from; |
52 | 52 | $this->to=$to; |
53 | 53 | $this->urlMask="%page%"; |
54 | - if(!isset($countVisible)) |
|
54 | + if (!isset($countVisible)) |
|
55 | 55 | $this->countVisible=$to-$from+1; |
56 | 56 | else |
57 | 57 | $this->countVisible=$countVisible; |
58 | 58 | $this->createContent(); |
59 | 59 | } |
60 | 60 | |
61 | - private function createElement($num,$content,$disabled=false,$current=false){ |
|
61 | + private function createElement($num, $content, $disabled=false, $current=false) { |
|
62 | 62 | $count=sizeof($this->content)+1; |
63 | - $elem=new HtmlBsDoubleElement("li-".$this->identifier."-".$count,"li"); |
|
64 | - if($disabled){ |
|
63 | + $elem=new HtmlBsDoubleElement("li-".$this->identifier."-".$count, "li"); |
|
64 | + if ($disabled) { |
|
65 | 65 | $elem->setProperty("class", "disabled"); |
66 | 66 | } |
67 | - if($current){ |
|
67 | + if ($current) { |
|
68 | 68 | $content.="<span class='sr-only'>(current)</span>"; |
69 | 69 | $elem->setProperty("class", "active"); |
70 | 70 | } |
71 | - if(!$disabled){ |
|
71 | + if (!$disabled) { |
|
72 | 72 | $url=$this->getUrl($num); |
73 | - $href=new HtmlLink("a-".$this->identifier."-".$count,$url,$content); |
|
73 | + $href=new HtmlLink("a-".$this->identifier."-".$count, $url, $content); |
|
74 | 74 | $href->setProperty($this->attr, $url); |
75 | 75 | $elem->setContent($href); |
76 | - }else{ |
|
76 | + }else { |
|
77 | 77 | $elem->setContent($content); |
78 | 78 | } |
79 | 79 | $this->content[]=$elem; |
80 | 80 | return $this; |
81 | 81 | } |
82 | 82 | |
83 | - protected function createContent(){ |
|
83 | + protected function createContent() { |
|
84 | 84 | $this->content=array(); |
85 | - $this->createElement($this->active-1,"<span aria-hidden='true'>«</span>",$this->active===1); |
|
85 | + $this->createElement($this->active-1, "<span aria-hidden='true'>«</span>", $this->active===1); |
|
86 | 86 | $start=$this->getStart(); |
87 | - $end=min($start+$this->countVisible-1,$this->to); |
|
88 | - for($index=$start;$index<=$end;$index++){ |
|
89 | - $this->createElement($index,$index,false,$index===$this->active); |
|
87 | + $end=min($start+$this->countVisible-1, $this->to); |
|
88 | + for ($index=$start; $index<=$end; $index++) { |
|
89 | + $this->createElement($index, $index, false, $index===$this->active); |
|
90 | 90 | } |
91 | - $this->createElement($this->active+1,"<span aria-hidden='true'>»</span>",$this->active===$this->to); |
|
91 | + $this->createElement($this->active+1, "<span aria-hidden='true'>»</span>", $this->active===$this->to); |
|
92 | 92 | } |
93 | 93 | |
94 | - protected function half(){ |
|
95 | - return (int)($this->countVisible/2); |
|
94 | + protected function half() { |
|
95 | + return (int) ($this->countVisible / 2); |
|
96 | 96 | } |
97 | 97 | |
98 | - protected function getStart(){ |
|
98 | + protected function getStart() { |
|
99 | 99 | $result=1; |
100 | - if($this->countVisible!==$this->to-$this->from+1){ |
|
101 | - $result=max($this->active-$this->half(),$result); |
|
100 | + if ($this->countVisible!==$this->to-$this->from+1) { |
|
101 | + $result=max($this->active-$this->half(), $result); |
|
102 | 102 | } |
103 | 103 | return $result; |
104 | 104 | } |
105 | 105 | |
106 | 106 | public function _addEvent($event, $jsCode) { |
107 | - foreach ($this->content as $li){ |
|
107 | + foreach ($this->content as $li) { |
|
108 | 108 | $content=$li->getContent(); |
109 | - if($content instanceof BaseHtml) |
|
110 | - $content->_addEvent($event,$jsCode); |
|
109 | + if ($content instanceof BaseHtml) |
|
110 | + $content->_addEvent($event, $jsCode); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | /** |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | * @param Dispatcher $dispatcher the request dispatcher |
116 | 116 | * @return \Ajax\bootstrap\html\HtmlPagination |
117 | 117 | */ |
118 | - public function fromDispatcher($dispatcher,$startIndex=0){ |
|
119 | - $items=array($dispatcher->getControllerName(),$dispatcher->getActionName()); |
|
120 | - $items=array_merge($items,$dispatcher->getParams()); |
|
118 | + public function fromDispatcher($dispatcher, $startIndex=0) { |
|
119 | + $items=array($dispatcher->getControllerName(), $dispatcher->getActionName()); |
|
120 | + $items=array_merge($items, $dispatcher->getParams()); |
|
121 | 121 | $url=implode("/", $items); |
122 | - if($this->urlMask==="%page%"){ |
|
122 | + if ($this->urlMask==="%page%") { |
|
123 | 123 | $this->urlMask=preg_replace("/[0-9]/", "%page%", $url); |
124 | 124 | } |
125 | - for($index=$this->from;$index<=$this->to;$index++){ |
|
126 | - if($this->getUrl($index)==$url){ |
|
125 | + for ($index=$this->from; $index<=$this->to; $index++) { |
|
126 | + if ($this->getUrl($index)==$url) { |
|
127 | 127 | $this->setActive($index); |
128 | 128 | break; |
129 | 129 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | return $this; |
132 | 132 | } |
133 | 133 | |
134 | - public function getUrl($index){ |
|
134 | + public function getUrl($index) { |
|
135 | 135 | return str_ireplace("%page%", $index, $this->urlMask); |
136 | 136 | } |
137 | 137 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | if (is_int($size)) { |
146 | 146 | return $this->addToPropertyUnique("class", CssRef::sizes("pagination")[$size], CssRef::sizes("pagination")); |
147 | 147 | } |
148 | - if(!PhalconUtils::startsWith($size, "pagination-") && $size!=="") |
|
148 | + if (!PhalconUtils::startsWith($size, "pagination-") && $size!=="") |
|
149 | 149 | $size="pagination-".$size; |
150 | 150 | return $this->addToPropertyCtrl("class", $size, CssRef::sizes("pagination")); |
151 | 151 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | return $this->from; |
155 | 155 | } |
156 | 156 | public function setFrom($from) { |
157 | - $this->from = $from; |
|
157 | + $this->from=$from; |
|
158 | 158 | $this->createContent(); |
159 | 159 | return $this; |
160 | 160 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | return $this->to; |
163 | 163 | } |
164 | 164 | public function setTo($to) { |
165 | - $this->to = $to; |
|
165 | + $this->to=$to; |
|
166 | 166 | $this->createContent(); |
167 | 167 | return $this; |
168 | 168 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | return $this->active; |
171 | 171 | } |
172 | 172 | public function setActive($active) { |
173 | - $this->active = $active; |
|
173 | + $this->active=$active; |
|
174 | 174 | $this->createContent(); |
175 | 175 | return $this; |
176 | 176 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | return $this->urlMask; |
179 | 179 | } |
180 | 180 | public function setUrlMask($urlMask) { |
181 | - $this->urlMask = $urlMask; |
|
181 | + $this->urlMask=$urlMask; |
|
182 | 182 | $this->createContent(); |
183 | 183 | return $this; |
184 | 184 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | return $this->countVisible; |
187 | 187 | } |
188 | 188 | public function setCountVisible($countVisible) { |
189 | - $this->countVisible = $countVisible; |
|
189 | + $this->countVisible=$countVisible; |
|
190 | 190 | $this->createContent(); |
191 | 191 | return $this; |
192 | 192 | } |
@@ -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 $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; |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | * @param string $attr the html attribute used to build the elements url |
168 | 168 | * @return HtmlBreadcrumbs |
169 | 169 | */ |
170 | - public function autoGetOnClick($targetSelector){ |
|
171 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
170 | + public function autoGetOnClick($targetSelector) { |
|
171 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function contentAsString(){ |
|
175 | - if($this->autoActive){ |
|
174 | + public function contentAsString() { |
|
175 | + if ($this->autoActive) { |
|
176 | 176 | $this->setActive(); |
177 | 177 | } |
178 | 178 | return parent::contentAsString(); |
179 | 179 | } |
180 | 180 | |
181 | - public function getElement($index){ |
|
181 | + public function getElement($index) { |
|
182 | 182 | return $this->content[$index]; |
183 | 183 | } |
184 | 184 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param mixed $glyph |
188 | 188 | * @param int $index |
189 | 189 | */ |
190 | - public function addGlyph($glyph,$index=0){ |
|
190 | + public function addGlyph($glyph, $index=0) { |
|
191 | 191 | $elm=$this->getElement($index); |
192 | 192 | return $elm->wrapContentWithGlyph($glyph); |
193 | 193 | } |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | * @param Dispatcher $dispatcher the request dispatcher |
198 | 198 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
199 | 199 | */ |
200 | - public function fromDispatcher($dispatcher,$startIndex=0){ |
|
200 | + public function fromDispatcher($dispatcher, $startIndex=0) { |
|
201 | 201 | $this->startIndex=$startIndex; |
202 | 202 | $params=$dispatcher->getParams(); |
203 | 203 | $action=$dispatcher->getActionName(); |
204 | 204 | $items=array($dispatcher->getControllerName()); |
205 | - if(\sizeof($params)>0 || \strtolower($action)!="index" ){ |
|
205 | + if (\sizeof($params)>0 || \strtolower($action)!="index") { |
|
206 | 206 | $items[]=$action; |
207 | - foreach ($params as $p){ |
|
208 | - if(\is_object($p)===false) |
|
207 | + foreach ($params as $p) { |
|
208 | + if (\is_object($p)===false) |
|
209 | 209 | $items[]=$p; |
210 | 210 | } |
211 | 211 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
220 | 220 | */ |
221 | 221 | public function setHrefFunction($_hrefFunction) { |
222 | - $this->_hrefFunction = $_hrefFunction; |
|
222 | + $this->_hrefFunction=$_hrefFunction; |
|
223 | 223 | return $this; |
224 | 224 | } |
225 | 225 |