@@ -9,26 +9,26 @@ discard block |
||
9 | 9 | use Ajax\semantic\html\collections\form\HtmlFormCheckbox; |
10 | 10 | use Ajax\semantic\html\collections\form\HtmlFormRadio; |
11 | 11 | trait FieldsTrait { |
12 | - public abstract function addFields($fields=NULL,$label=NULL); |
|
12 | + public abstract function addFields($fields=NULL, $label=NULL); |
|
13 | 13 | public abstract function addItem($item); |
14 | 14 | |
15 | - protected function createItem($value){ |
|
16 | - if(\is_array($value)){ |
|
17 | - $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
|
15 | + protected function createItem($value) { |
|
16 | + if (\is_array($value)) { |
|
17 | + $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null))); |
|
18 | 18 | return $itemO; |
19 | 19 | }else |
20 | 20 | return new HtmlFormInput($value); |
21 | 21 | } |
22 | 22 | |
23 | - public function addInputs($inputs,$fieldslabel=null){ |
|
23 | + public function addInputs($inputs, $fieldslabel=null) { |
|
24 | 24 | $fields=array(); |
25 | - foreach ($inputs as $input){ |
|
25 | + foreach ($inputs as $input) { |
|
26 | 26 | \extract($input); |
27 | - $f=new HtmlFormInput("",""); |
|
27 | + $f=new HtmlFormInput("", ""); |
|
28 | 28 | $f->fromArray($input); |
29 | 29 | $fields[]=$f; |
30 | 30 | } |
31 | - return $this->addFields($fields,$fieldslabel); |
|
31 | + return $this->addFields($fields, $fieldslabel); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,27 +39,27 @@ discard block |
||
39 | 39 | * @param boolean $multiple |
40 | 40 | * @return \Ajax\common\html\HtmlDoubleElement |
41 | 41 | */ |
42 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
43 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
42 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
43 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
47 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
46 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
47 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
48 | 48 | } |
49 | 49 | |
50 | - public function addPassword($identifier, $label=NULL){ |
|
51 | - return $this->addItem(new HtmlFormInput($identifier,$label,"password","","")); |
|
50 | + public function addPassword($identifier, $label=NULL) { |
|
51 | + return $this->addItem(new HtmlFormInput($identifier, $label, "password", "", "")); |
|
52 | 52 | } |
53 | 53 | |
54 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
55 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
54 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
55 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
56 | 56 | } |
57 | 57 | |
58 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
59 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
58 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
59 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
60 | 60 | } |
61 | 61 | |
62 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
63 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
62 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
63 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | \ No newline at end of file |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct($identifier, $elements=array()) { |
24 | 24 | parent::__construct($identifier, "form", "ui form"); |
25 | - $this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ]; |
|
25 | + $this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED]; |
|
26 | 26 | $this->setProperty("name", $this->identifier); |
27 | - $this->_fields=array (); |
|
27 | + $this->_fields=array(); |
|
28 | 28 | $this->addItems($elements); |
29 | 29 | } |
30 | 30 | |
@@ -35,29 +35,29 @@ discard block |
||
35 | 35 | return $this->addItem($header); |
36 | 36 | } |
37 | 37 | |
38 | - public function addDivider($caption=NULL){ |
|
39 | - return $this->addContent(new HtmlDivider("",$caption)); |
|
38 | + public function addDivider($caption=NULL) { |
|
39 | + return $this->addContent(new HtmlDivider("", $caption)); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function addFields($fields=NULL, $label=NULL) { |
43 | 43 | if (isset($fields)) { |
44 | 44 | if (!$fields instanceof HtmlFormFields) { |
45 | - if (\is_array($fields) === false) { |
|
45 | + if (\is_array($fields)===false) { |
|
46 | 46 | $fields=\func_get_args(); |
47 | 47 | $end=\end($fields); |
48 | 48 | if (\is_string($end)) { |
49 | 49 | $label=$end; |
50 | 50 | \array_pop($fields); |
51 | - } else |
|
51 | + }else |
|
52 | 52 | $label=NULL; |
53 | 53 | } |
54 | 54 | $this->_fields=\array_merge($this->_fields, $fields); |
55 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
|
55 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
56 | 56 | } |
57 | 57 | if (isset($label)) |
58 | 58 | $fields=new HtmlFormField("", $fields, $label); |
59 | - } else { |
|
60 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
|
59 | + }else { |
|
60 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
|
61 | 61 | } |
62 | 62 | $this->addItem($fields); |
63 | 63 | return $fields; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | public function addItem($item) { |
67 | 67 | $item=parent::addItem($item); |
68 | - if (\is_subclass_of($item, HtmlFormField::class) === true) { |
|
68 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
69 | 69 | $this->_fields[]=$item; |
70 | 70 | } |
71 | 71 | return $item; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function getField($index) { |
75 | 75 | if (\is_string($index)) { |
76 | 76 | $field=$this->getElementById($index, $this->_fields); |
77 | - } else { |
|
77 | + }else { |
|
78 | 78 | $field=$this->_fields[$index]; |
79 | 79 | } |
80 | 80 | return $field; |
@@ -7,19 +7,19 @@ |
||
7 | 7 | |
8 | 8 | use Ajax\semantic\html\elements\HtmlIcon; |
9 | 9 | |
10 | -class HtmlPaginationMenu extends HtmlMenu{ |
|
10 | +class HtmlPaginationMenu extends HtmlMenu { |
|
11 | 11 | |
12 | - public function __construct( $identifier, $items=array() ){ |
|
13 | - parent::__construct( $identifier,$items); |
|
12 | + public function __construct($identifier, $items=array()) { |
|
13 | + parent::__construct($identifier, $items); |
|
14 | 14 | } |
15 | 15 | /** |
16 | 16 | * {@inheritDoc} |
17 | 17 | * @see \Ajax\common\html\BaseHtml::compile() |
18 | 18 | */ |
19 | - public function compile(JsUtils $js=NULL,$view=NULL){ |
|
19 | + public function compile(JsUtils $js=NULL, $view=NULL) { |
|
20 | 20 | $this->insertItem(new HtmlIcon("", "left chevron")); |
21 | 21 | $this->addItem(new HtmlIcon("", "right chevron")); |
22 | 22 | $this->asPagination(); |
23 | - return parent::compile($js,$view); |
|
23 | + return parent::compile($js, $view); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -17,31 +17,31 @@ discard block |
||
17 | 17 | } |
18 | 18 | protected $mClass="menu"; |
19 | 19 | protected $mTagName="div"; |
20 | - protected $items=array (); |
|
21 | - protected $_params=array("action"=>"nothing","on"=>"hover"); |
|
20 | + protected $items=array(); |
|
21 | + protected $_params=array("action"=>"nothing", "on"=>"hover"); |
|
22 | 22 | protected $input; |
23 | 23 | |
24 | 24 | public function __construct($identifier, $value="", $items=array()) { |
25 | 25 | parent::__construct($identifier, "div"); |
26 | 26 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
27 | 27 | $this->setProperty("class", "ui dropdown"); |
28 | - $content=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
28 | + $content=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
29 | 29 | $content->setClass("text"); |
30 | 30 | $content->setContent($value); |
31 | - $content->wrap("",new HtmlIcon("", "dropdown")); |
|
31 | + $content->wrap("", new HtmlIcon("", "dropdown")); |
|
32 | 32 | $this->content=array($content); |
33 | 33 | $this->tagName="div"; |
34 | 34 | $this->addItems($items); |
35 | 35 | } |
36 | 36 | |
37 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
38 | - $itemO=$this->beforeAddItem($item,$value,$image); |
|
37 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
38 | + $itemO=$this->beforeAddItem($item, $value, $image); |
|
39 | 39 | $this->items[]=$itemO; |
40 | 40 | return $itemO; |
41 | 41 | } |
42 | 42 | |
43 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
44 | - $this->addIconP($icon,$before,$labeled); |
|
43 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
44 | + $this->addIconP($icon, $before, $labeled); |
|
45 | 45 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
46 | 46 | } |
47 | 47 | /** |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | * @param number $position |
51 | 51 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
52 | 52 | */ |
53 | - public function insertItem($item,$position=0){ |
|
53 | + public function insertItem($item, $position=0) { |
|
54 | 54 | $itemO=$this->beforeAddItem($item); |
55 | - $start = array_slice($this->items, 0, $position); |
|
56 | - $end = array_slice($this->items, $position); |
|
57 | - $start[] = $item; |
|
55 | + $start=array_slice($this->items, 0, $position); |
|
56 | + $end=array_slice($this->items, $position); |
|
57 | + $start[]=$item; |
|
58 | 58 | $this->items=array_merge($start, $end); |
59 | 59 | return $itemO; |
60 | 60 | } |
61 | 61 | |
62 | - protected function beforeAddItem($item,$value=NULL,$image=NULL){ |
|
62 | + protected function beforeAddItem($item, $value=NULL, $image=NULL) { |
|
63 | 63 | $itemO=$item; |
64 | - if(!$item instanceof HtmlDropdownItem){ |
|
65 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
|
66 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
64 | + if (!$item instanceof HtmlDropdownItem) { |
|
65 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image); |
|
66 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
67 | 67 | $this->addToProperty("class", "vertical"); |
68 | 68 | } |
69 | 69 | return $itemO; |
@@ -76,76 +76,76 @@ discard block |
||
76 | 76 | $this->addItem($function($object)); |
77 | 77 | } |
78 | 78 | |
79 | - public function addInput($name){ |
|
80 | - if(!isset($name)) |
|
79 | + public function addInput($name) { |
|
80 | + if (!isset($name)) |
|
81 | 81 | $name="input-".$this->identifier; |
82 | 82 | $this->setAction("activate"); |
83 | - $this->input=new HtmlInput($name,"hidden"); |
|
83 | + $this->input=new HtmlInput($name, "hidden"); |
|
84 | 84 | } |
85 | 85 | |
86 | - public function addItems($items){ |
|
87 | - if(JArray::isAssociative($items)){ |
|
88 | - foreach ($items as $k=>$v){ |
|
86 | + public function addItems($items) { |
|
87 | + if (JArray::isAssociative($items)) { |
|
88 | + foreach ($items as $k=>$v) { |
|
89 | 89 | $this->addItem($v)->setData($k); |
90 | 90 | } |
91 | - }else{ |
|
92 | - foreach ($items as $item){ |
|
91 | + }else { |
|
92 | + foreach ($items as $item) { |
|
93 | 93 | $this->addItem($item); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - public function count(){ |
|
98 | + public function count() { |
|
99 | 99 | return \sizeof($this->items); |
100 | 100 | } |
101 | 101 | /** |
102 | 102 | * @param boolean $dropdown |
103 | 103 | */ |
104 | - public function asDropdown($dropdown){ |
|
105 | - if($dropdown===false){ |
|
104 | + public function asDropdown($dropdown) { |
|
105 | + if ($dropdown===false) { |
|
106 | 106 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
107 | 107 | $dropdown="menu"; |
108 | - }else{ |
|
108 | + }else { |
|
109 | 109 | $dropdown="dropdown"; |
110 | 110 | $this->mClass="menu"; |
111 | 111 | } |
112 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
112 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
113 | 113 | } |
114 | 114 | |
115 | - public function setVertical(){ |
|
116 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
115 | + public function setVertical() { |
|
116 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
117 | 117 | } |
118 | 118 | |
119 | - public function setSimple(){ |
|
120 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
119 | + public function setSimple() { |
|
120 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
121 | 121 | } |
122 | 122 | |
123 | - public function asButton($floating=false){ |
|
124 | - if($floating) |
|
123 | + public function asButton($floating=false) { |
|
124 | + if ($floating) |
|
125 | 125 | $this->addToProperty("class", "floating"); |
126 | 126 | return $this->addToProperty("class", "button"); |
127 | 127 | } |
128 | 128 | |
129 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
130 | - if(isset($name)) |
|
129 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
130 | + if (isset($name)) |
|
131 | 131 | $this->addInput($name); |
132 | - if($multiple) |
|
132 | + if ($multiple) |
|
133 | 133 | $this->addToProperty("class", "multiple"); |
134 | 134 | if ($selection) |
135 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
135 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
139 | - public function asSearch($name=NULL,$multiple=false,$selection=false){ |
|
140 | - $this->asSelect($name,$multiple,$selection); |
|
139 | + public function asSearch($name=NULL, $multiple=false, $selection=false) { |
|
140 | + $this->asSelect($name, $multiple, $selection); |
|
141 | 141 | return $this->addToProperty("class", "search"); |
142 | 142 | } |
143 | 143 | |
144 | - public function setSelect($name=NULL,$multiple=false){ |
|
145 | - if(!isset($name)) |
|
144 | + public function setSelect($name=NULL, $multiple=false) { |
|
145 | + if (!isset($name)) |
|
146 | 146 | $name="select-".$this->identifier; |
147 | 147 | $this->input=null; |
148 | - if($multiple){ |
|
148 | + if ($multiple) { |
|
149 | 149 | $this->setProperty("multiple", true); |
150 | 150 | $this->addToProperty("class", "multiple"); |
151 | 151 | } |
@@ -153,32 +153,32 @@ discard block |
||
153 | 153 | $this->tagName="select"; |
154 | 154 | $this->setProperty("name", $name); |
155 | 155 | $this->content=null; |
156 | - foreach ($this->items as $item){ |
|
156 | + foreach ($this->items as $item) { |
|
157 | 157 | $item->asOption(); |
158 | 158 | } |
159 | 159 | return $this; |
160 | 160 | } |
161 | 161 | |
162 | - public function asSubmenu($pointing=NULL){ |
|
162 | + public function asSubmenu($pointing=NULL) { |
|
163 | 163 | $this->setClass("ui dropdown link item"); |
164 | - if(isset($pointing)){ |
|
164 | + if (isset($pointing)) { |
|
165 | 165 | $this->setPointing($pointing); |
166 | 166 | } |
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | - public function setPointing($value=Direction::NONE){ |
|
171 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
170 | + public function setPointing($value=Direction::NONE) { |
|
171 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function setValue($value){ |
|
175 | - if(isset($this->input)){ |
|
174 | + public function setValue($value) { |
|
175 | + if (isset($this->input)) { |
|
176 | 176 | $this->input->setProperty("value", $value); |
177 | - }else{ |
|
177 | + }else { |
|
178 | 178 | $this->setProperty("value", $value); |
179 | 179 | } |
180 | 180 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
181 | - if(isset($textElement)) |
|
181 | + if (isset($textElement)) |
|
182 | 182 | $textElement->setContent($value); |
183 | 183 | return $this; |
184 | 184 | } |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | * @see BaseHtml::run() |
189 | 189 | */ |
190 | 190 | public function run(JsUtils $js) { |
191 | - if($this->propertyContains("class", "simple")===false){ |
|
192 | - if(isset($this->_bsComponent)===false) |
|
193 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
191 | + if ($this->propertyContains("class", "simple")===false) { |
|
192 | + if (isset($this->_bsComponent)===false) |
|
193 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
194 | 194 | $this->addEventsOnRun($js); |
195 | 195 | return $this->_bsComponent; |
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - public function setCompact(){ |
|
199 | + public function setCompact() { |
|
200 | 200 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
201 | 201 | } |
202 | 202 | |
203 | - public function setAction($action){ |
|
203 | + public function setAction($action) { |
|
204 | 204 | $this->_params["action"]=$action; |
205 | 205 | } |
206 | 206 | |
207 | - public function setFullTextSearch($value){ |
|
207 | + public function setFullTextSearch($value) { |
|
208 | 208 | $this->_params["fullTextSearch"]=$value; |
209 | 209 | } |
210 | 210 | } |
211 | 211 | \ No newline at end of file |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * JsUtils Class : Service to be injected |
24 | 24 | */ |
25 | -abstract class JsUtils{ |
|
26 | - use JsUtilsEventsTrait,JsUtilsActionsTrait,JsUtilsAjaxTrait; |
|
25 | +abstract class JsUtils { |
|
26 | + use JsUtilsEventsTrait, JsUtilsActionsTrait, JsUtilsAjaxTrait; |
|
27 | 27 | |
28 | 28 | protected $js; |
29 | 29 | protected $cdns; |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | protected $config; |
51 | 51 | |
52 | 52 | protected function _setDi($di) { |
53 | - if ($this->js!=null&&$di!=null) |
|
53 | + if ($this->js!=null && $di!=null) |
|
54 | 54 | $this->js->setDi($di); |
55 | 55 | } |
56 | 56 | |
57 | 57 | public abstract function getUrl($url); |
58 | - public abstract function addViewElement($identifier,$content,$view); |
|
58 | + public abstract function addViewElement($identifier, $content, $view); |
|
59 | 59 | /** |
60 | 60 | * render the content of $controller::$action and set the response to the modal content |
61 | 61 | * @param Controller $initialController |
62 | 62 | * @param string $controller a Phalcon controller |
63 | 63 | * @param string $action a Phalcon action |
64 | 64 | */ |
65 | - public abstract function forward($initialController,$controller,$action); |
|
65 | + public abstract function forward($initialController, $controller, $action); |
|
66 | 66 | /** |
67 | 67 | * render the content of an existing view : $controller/$action and set the response to the modal content |
68 | 68 | * @param View $view |
@@ -162,18 +162,18 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | public function __construct($params=array()) { |
165 | - $defaults=array ( |
|
165 | + $defaults=array( |
|
166 | 166 | 'driver' => 'Jquery', |
167 | 167 | 'debug' => true |
168 | 168 | ); |
169 | - foreach ( $defaults as $key => $val ) { |
|
170 | - if (isset($params[$key])&&$params[$key]!=="") { |
|
169 | + foreach ($defaults as $key => $val) { |
|
170 | + if (isset($params[$key]) && $params[$key]!=="") { |
|
171 | 171 | $defaults[$key]=$params[$key]; |
172 | 172 | } |
173 | 173 | } |
174 | 174 | extract($defaults); |
175 | - $this->js=new Jquery($defaults,$this); |
|
176 | - $this->cdns=array (); |
|
175 | + $this->js=new Jquery($defaults, $this); |
|
176 | + $this->cdns=array(); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | public function addToCompile($jsScript) { |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function compile($view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
212 | 212 | $bs=$this->_bootstrap; |
213 | - if (isset($bs)&&isset($view)) { |
|
213 | + if (isset($bs) && isset($view)) { |
|
214 | 214 | $bs->compileHtml($this, $view); |
215 | 215 | } |
216 | 216 | $sem=$this->_semantic; |
217 | - if (isset($sem)&&isset($view)) { |
|
217 | + if (isset($sem) && isset($view)) { |
|
218 | 218 | $sem->compileHtml($this, $view); |
219 | 219 | } |
220 | 220 | return $this->js->_compile($view, $view_var, $script_tags); |
@@ -281,27 +281,27 @@ discard block |
||
281 | 281 | $json_result=$result->result_array(); |
282 | 282 | } elseif (is_array($result)) { |
283 | 283 | $json_result=$result; |
284 | - } else { |
|
284 | + }else { |
|
285 | 285 | return $this->_prep_args($result); |
286 | 286 | } |
287 | - } else { |
|
287 | + }else { |
|
288 | 288 | return 'null'; |
289 | 289 | } |
290 | 290 | return $this->_create_json($json_result, $match_array_type); |
291 | 291 | } |
292 | 292 | |
293 | 293 | private function _create_json($json_result, $match_array_type) { |
294 | - $json=array (); |
|
294 | + $json=array(); |
|
295 | 295 | $_is_assoc=TRUE; |
296 | - if (!is_array($json_result)&&empty($json_result)) { |
|
296 | + if (!is_array($json_result) && empty($json_result)) { |
|
297 | 297 | show_error("Generate JSON Failed - Illegal key, value pair."); |
298 | 298 | } elseif ($match_array_type) { |
299 | 299 | $_is_assoc=$this->_is_associative_array($json_result); |
300 | 300 | } |
301 | - foreach ( $json_result as $k => $v ) { |
|
301 | + foreach ($json_result as $k => $v) { |
|
302 | 302 | if ($_is_assoc) { |
303 | 303 | $json[]=$this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); |
304 | - } else { |
|
304 | + }else { |
|
305 | 305 | $json[]=$this->generate_json($v, $match_array_type); |
306 | 306 | } |
307 | 307 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @return type |
317 | 317 | */ |
318 | 318 | public function _is_associative_array($arr) { |
319 | - foreach ( array_keys($arr) as $key => $val ) { |
|
319 | + foreach (array_keys($arr) as $key => $val) { |
|
320 | 320 | if ($key!==$val) { |
321 | 321 | return TRUE; |
322 | 322 | } |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | return 'null'; |
336 | 336 | } elseif (is_bool($result)) { |
337 | 337 | return ($result===TRUE) ? 'true' : 'false'; |
338 | - } elseif (is_string($result)||$is_key) { |
|
339 | - return '"'.str_replace(array ( |
|
340 | - '\\',"\t","\n","\r",'"','/' |
|
341 | - ), array ( |
|
342 | - '\\\\','\\t','\\n',"\\r",'\"','\/' |
|
338 | + } elseif (is_string($result) || $is_key) { |
|
339 | + return '"'.str_replace(array( |
|
340 | + '\\', "\t", "\n", "\r", '"', '/' |
|
341 | + ), array( |
|
342 | + '\\\\', '\\t', '\\n', "\\r", '\"', '\/' |
|
343 | 343 | ), $result).'"'; |
344 | 344 | } elseif (is_scalar($result)) { |
345 | 345 | return $result; |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | public function setCDNs($cdns) { |
354 | 354 | if (is_array($cdns)===false) { |
355 | - $cdns=array ( |
|
355 | + $cdns=array( |
|
356 | 356 | $cdns |
357 | 357 | ); |
358 | 358 | } |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | $hasJQueryUI=false; |
365 | 365 | $hasBootstrap=false; |
366 | 366 | $hasSemantic=false; |
367 | - $result=array (); |
|
368 | - foreach ( $this->cdns as $cdn ) { |
|
369 | - switch(get_class($cdn)) { |
|
367 | + $result=array(); |
|
368 | + foreach ($this->cdns as $cdn) { |
|
369 | + switch (get_class($cdn)) { |
|
370 | 370 | case "Ajax\lib\CDNJQuery": |
371 | 371 | $hasJQuery=true; |
372 | 372 | $result[0]=$cdn; |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | $result[1]=$cdn; |
377 | 377 | break; |
378 | 378 | case "Ajax\lib\CDNCoreCss": |
379 | - if($cdn->getFramework()==="Bootstrap") |
|
379 | + if ($cdn->getFramework()==="Bootstrap") |
|
380 | 380 | $hasBootstrap=true; |
381 | - elseif($cdn->getFramework()==="Semantic") |
|
381 | + elseif ($cdn->getFramework()==="Semantic") |
|
382 | 382 | $hasSemantic=true; |
383 | - if($hasSemantic || $hasBootstrap) |
|
383 | + if ($hasSemantic || $hasBootstrap) |
|
384 | 384 | $result[2]=$cdn; |
385 | 385 | break; |
386 | 386 | } |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | if ($hasJQuery===false) { |
389 | 389 | $result[0]=new CDNJQuery("x"); |
390 | 390 | } |
391 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
391 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
392 | 392 | $result[1]=new CDNGuiGen("x", $template); |
393 | 393 | } |
394 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
395 | - $result[2]=new CDNCoreCss("Bootstrap","x"); |
|
394 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
395 | + $result[2]=new CDNCoreCss("Bootstrap", "x"); |
|
396 | 396 | } |
397 | - if ($hasSemantic===false&&isset($this->_semantic)) { |
|
398 | - $result[2]=new CDNCoreCss("Semantic","x"); |
|
397 | + if ($hasSemantic===false && isset($this->_semantic)) { |
|
398 | + $result[2]=new CDNCoreCss("Semantic", "x"); |
|
399 | 399 | } |
400 | 400 | ksort($result); |
401 | 401 | return implode("\n", $result); |
@@ -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(){ |
|
96 | - return (int)($this->countVisible/2); |
|
95 | + protected function half() { |
|
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 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | class HtmlModal extends BaseHtml { |
17 | 17 | protected $title="Titre de ma boîte"; |
18 | 18 | protected $content=""; |
19 | - protected $buttons=array (); |
|
19 | + protected $buttons=array(); |
|
20 | 20 | protected $showOnStartup=false; |
21 | 21 | protected $draggable=false; |
22 | 22 | protected $validCondition=NULL; |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | public function __construct($identifier, $title="", $content="", $buttonCaptions=array()) { |
30 | 30 | parent::__construct($identifier); |
31 | 31 | $this->_template=include 'templates/tplModal.php'; |
32 | - $this->buttons=array (); |
|
32 | + $this->buttons=array(); |
|
33 | 33 | $this->title=$title; |
34 | 34 | $this->content=$content; |
35 | - foreach ( $buttonCaptions as $button ) { |
|
35 | + foreach ($buttonCaptions as $button) { |
|
36 | 36 | $this->addButton($button); |
37 | 37 | } |
38 | 38 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param string $value |
68 | 68 | * @return HtmlButton |
69 | 69 | */ |
70 | - public function addOkayButton($value="Okay",$jsCode="") { |
|
70 | + public function addOkayButton($value="Okay", $jsCode="") { |
|
71 | 71 | $btn=$this->addButton($value, "btn-primary"); |
72 | 72 | $btn->onClick("if(".$this->getValidCondition()."){ ".$jsCode."$('#".$this->identifier."').modal('hide');}"); |
73 | 73 | return $btn; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | public function getValidCondition() { |
85 | 85 | if ($this->validCondition==NULL) { |
86 | 86 | return $this->getDefaultValidCondition(); |
87 | - } else { |
|
87 | + }else { |
|
88 | 88 | return $this->validCondition; |
89 | 89 | } |
90 | 90 | } |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * @param string $action a Phalcon action |
118 | 118 | * @param $params The parameters to pass to the view |
119 | 119 | */ |
120 | - public function renderContent($initialController,$view, $controller, $action, $params=NULL) { |
|
121 | - $this->content=$initialController->jquery->renderContent($view, $controller, $action,$params); |
|
120 | + public function renderContent($initialController, $view, $controller, $action, $params=NULL) { |
|
121 | + $this->content=$initialController->jquery->renderContent($view, $controller, $action, $params); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param string $controller a Phalcon controller |
128 | 128 | * @param string $action a Phalcon action |
129 | 129 | */ |
130 | - public function forward($initialController,$controller,$action){ |
|
130 | + public function forward($initialController, $controller, $action) { |
|
131 | 131 | $this->content=$initialController->jquery->forward($initialController, $controller, $action); |
132 | 132 | } |
133 | 133 | |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | * @see BaseHtml::run() |
137 | 137 | */ |
138 | 138 | public function run(JsUtils $js) { |
139 | - if($this->content instanceof BaseHtml){ |
|
139 | + if ($this->content instanceof BaseHtml) { |
|
140 | 140 | $this->content->run($js); |
141 | 141 | } |
142 | - $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array ( |
|
142 | + $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array( |
|
143 | 143 | "show" => $this->showOnStartup |
144 | 144 | )); |
145 | 145 | if ($this->draggable) |
@@ -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(JsUtils $js,$dispatcher,$startIndex=0); |
|
81 | + public abstract function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -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 |