@@ -10,61 +10,61 @@ |
||
10 | 10 | * @param string $identifier |
11 | 11 | * @param object $modelInstance |
12 | 12 | */ |
13 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) { |
|
14 | - parent::__construct($identifier,$modelInstance,$fieldsOrder,$fieldsDefinition,$fields,$captions,$separators); |
|
13 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder=[], $fieldsDefinition=[], $fields=[], $captions=[], $separators=[]) { |
|
14 | + parent::__construct($identifier, $modelInstance, $fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
15 | 15 | } |
16 | 16 | |
17 | - protected function getDefaultModelInstance(){ |
|
17 | + protected function getDefaultModelInstance() { |
|
18 | 18 | return new UserModel(); |
19 | 19 | } |
20 | 20 | |
21 | - public static function regular($identifier,$modelInstance=null){ |
|
22 | - return new FormAccount($identifier,$modelInstance, |
|
23 | - ["message","login","password","passwordConf","email","submit","error"], |
|
21 | + public static function regular($identifier, $modelInstance=null) { |
|
22 | + return new FormAccount($identifier, $modelInstance, |
|
23 | + ["message", "login", "password", "passwordConf", "email", "submit", "error"], |
|
24 | 24 | ["message"=>[["icon"=>"sign in"]], |
25 | 25 | "input0"=>[["rules"=>"empty"]], |
26 | - "input1"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty']]], |
|
27 | - "input2"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
26 | + "input1"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty']]], |
|
27 | + "input2"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
28 | 28 | "input3"=>[["rules"=>"email"]], |
29 | 29 | "submit"=>["green fluid"], |
30 | 30 | "message2"=>[["error"=>true]]], |
31 | - ["Account","login","password","passwordConf","email","submit","error"], |
|
32 | - ["Please enter your account informations","Login","Password","Password confirmation","Email address","Creation"], |
|
33 | - [0,1,3,4,5,6]); |
|
31 | + ["Account", "login", "password", "passwordConf", "email", "submit", "error"], |
|
32 | + ["Please enter your account informations", "Login", "Password", "Password confirmation", "Email address", "Creation"], |
|
33 | + [0, 1, 3, 4, 5, 6]); |
|
34 | 34 | } |
35 | 35 | |
36 | - public static function smallInline($identifier,$modelInstance=null){ |
|
37 | - $result=new FormAccount($identifier,$modelInstance, |
|
38 | - ["login","password","submit"], |
|
39 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
40 | - ["login","password","submit"], |
|
41 | - ["","","Connection"], |
|
36 | + public static function smallInline($identifier, $modelInstance=null) { |
|
37 | + $result=new FormAccount($identifier, $modelInstance, |
|
38 | + ["login", "password", "submit"], |
|
39 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
40 | + ["login", "password", "submit"], |
|
41 | + ["", "", "Connection"], |
|
42 | 42 | [2]); |
43 | 43 | $result->addDividerBefore(0, "Connection"); |
44 | 44 | return $result; |
45 | 45 | } |
46 | 46 | |
47 | - public static function small($identifier,$modelInstance=null){ |
|
48 | - $result=new FormAccount($identifier,$modelInstance, |
|
49 | - ["login","password","passwordConf","email","submit"], |
|
47 | + public static function small($identifier, $modelInstance=null) { |
|
48 | + $result=new FormAccount($identifier, $modelInstance, |
|
49 | + ["login", "password", "passwordConf", "email", "submit"], |
|
50 | 50 | [ |
51 | 51 | "input0"=>[["rules"=>"empty"]], |
52 | - "input1"=>[["inputType"=>"password","rules"=>['minLength[6]', 'empty']]], |
|
53 | - "input2"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
52 | + "input1"=>[["inputType"=>"password", "rules"=>['minLength[6]', 'empty']]], |
|
53 | + "input2"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
54 | 54 | "input3"=>[["rules"=>"email"]], |
55 | 55 | "submit"=>["green basic"]], |
56 | - ["login","password","passwordConf","email","submit"], |
|
57 | - ["Login","Password","Password confirmation","Email address","Creation"], |
|
58 | - [1,2]); |
|
56 | + ["login", "password", "passwordConf", "email", "submit"], |
|
57 | + ["Login", "Password", "Password confirmation", "Email address", "Creation"], |
|
58 | + [1, 2]); |
|
59 | 59 | $result->addDividerBefore(0, "Creation"); |
60 | 60 | return $result; |
61 | 61 | } |
62 | 62 | |
63 | - public static function attachedSegment($identifier,$modelInstance=null){ |
|
64 | - $result=self::regular($identifier,$modelInstance); |
|
65 | - $result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]); |
|
66 | - $result->addWrapper("message",null,"<div class='ui attached segment'>"); |
|
67 | - $result->addWrapper("error", null,"</div>"); |
|
63 | + public static function attachedSegment($identifier, $modelInstance=null) { |
|
64 | + $result=self::regular($identifier, $modelInstance); |
|
65 | + $result->fieldAsMessage("message", ["icon"=>"sign in", "attached"=>true]); |
|
66 | + $result->addWrapper("message", null, "<div class='ui attached segment'>"); |
|
67 | + $result->addWrapper("error", null, "</div>"); |
|
68 | 68 | return $result; |
69 | 69 | } |
70 | 70 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | trait LabeledIconTrait { |
14 | 14 | |
15 | 15 | abstract public function addToProperty($name, $value, $separator=" "); |
16 | - abstract public function addContent($content,$before=false); |
|
16 | + abstract public function addContent($content, $before=false); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Adds an icon before or after |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | * @param boolean $labeled |
23 | 23 | * @return \Ajax\semantic\html\elements\HtmlIcon |
24 | 24 | */ |
25 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
25 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
26 | 26 | $iconO=$icon; |
27 | - if(\is_string($icon)){ |
|
27 | + if (\is_string($icon)) { |
|
28 | 28 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
29 | 29 | } |
30 | - if($labeled!==false){ |
|
31 | - $direction=($before===true)?Direction::LEFT:Direction::RIGHT; |
|
30 | + if ($labeled!==false) { |
|
31 | + $direction=($before===true) ?Direction::LEFT : Direction::RIGHT; |
|
32 | 32 | $this->addToProperty("class", $direction." labeled icon"); |
33 | 33 | $this->tagName="div"; |
34 | 34 | } |
35 | - $this->addContent($iconO,$before); |
|
35 | + $this->addContent($iconO, $before); |
|
36 | 36 | return $iconO; |
37 | 37 | } |
38 | 38 | } |
@@ -16,16 +16,16 @@ |
||
16 | 16 | return $this; |
17 | 17 | } |
18 | 18 | |
19 | - public function showDimmer(){ |
|
19 | + public function showDimmer() { |
|
20 | 20 | return $this->setBehavior("hide dimmer"); |
21 | 21 | } |
22 | 22 | |
23 | - public function setInverted(){ |
|
23 | + public function setInverted() { |
|
24 | 24 | $this->params["inverted"]=true; |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function setOnHidden($jsCode) { |
28 | - $jsCode=str_ireplace("\"","%quote%", $jsCode); |
|
28 | + $jsCode=str_ireplace("\"", "%quote%", $jsCode); |
|
29 | 29 | return $this->setParam("onHidden", "%function(){".$jsCode."}%"); |
30 | 30 | } |
31 | 31 | } |
@@ -84,15 +84,17 @@ discard block |
||
84 | 84 | |
85 | 85 | public function getColspan() { |
86 | 86 | $colspan=1; |
87 | - if (\array_key_exists("colspan", $this->properties)) |
|
88 | - $colspan=$this->getProperty("colspan"); |
|
87 | + if (\array_key_exists("colspan", $this->properties)) { |
|
88 | + $colspan=$this->getProperty("colspan"); |
|
89 | + } |
|
89 | 90 | return $colspan; |
90 | 91 | } |
91 | 92 | |
92 | 93 | public function getRowspan() { |
93 | 94 | $rowspan=1; |
94 | - if (\array_key_exists("rowspan", $this->properties)) |
|
95 | - $rowspan=$this->getProperty("rowspan"); |
|
95 | + if (\array_key_exists("rowspan", $this->properties)) { |
|
96 | + $rowspan=$this->getProperty("rowspan"); |
|
97 | + } |
|
96 | 98 | return $rowspan; |
97 | 99 | } |
98 | 100 | |
@@ -129,8 +131,9 @@ discard block |
||
129 | 131 | } |
130 | 132 | |
131 | 133 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
132 | - if(!$this->_deleted) |
|
133 | - return parent::compile(); |
|
134 | + if(!$this->_deleted) { |
|
135 | + return parent::compile(); |
|
136 | + } |
|
134 | 137 | return; |
135 | 138 | } |
136 | 139 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use Ajax\JsUtils; |
13 | 13 | |
14 | 14 | class HtmlTD extends HtmlSemDoubleElement { |
15 | - use TextAlignmentTrait,TableElementTrait; |
|
15 | + use TextAlignmentTrait, TableElementTrait; |
|
16 | 16 | private $_container; |
17 | 17 | private $_row; |
18 | 18 | private $_col; |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct($identifier, $content=NULL, $tagName="td") { |
30 | 30 | parent::__construct($identifier, $tagName, "", $content); |
31 | - $this->_variations=[ Variation::COLLAPSING ]; |
|
32 | - $this->_states=[ State::ACTIVE,State::POSITIVE,State::NEGATIVE,State::WARNING,State::ERROR,State::DISABLED ]; |
|
31 | + $this->_variations=[Variation::COLLAPSING]; |
|
32 | + $this->_states=[State::ACTIVE, State::POSITIVE, State::NEGATIVE, State::WARNING, State::ERROR, State::DISABLED]; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setContainer($container, $row, $col) { |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | public function setRowspan($rowspan) { |
52 | - $to=min($this->_container->count(), $this->_row + $rowspan - 1); |
|
53 | - for($i=$to; $i > $this->_row; $i--) { |
|
52 | + $to=min($this->_container->count(), $this->_row+$rowspan-1); |
|
53 | + for ($i=$to; $i>$this->_row; $i--) { |
|
54 | 54 | $this->_container->toDelete($i, $this->_col); |
55 | 55 | } |
56 | 56 | $this->setProperty("rowspan", $rowspan); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | public function mergeRow() { |
61 | - if(!$this->_rowMerged){ |
|
61 | + if (!$this->_rowMerged) { |
|
62 | 62 | $this->_rowMerged=true; |
63 | 63 | return $this->setRowspan($this->_container->count()); |
64 | 64 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public function mergeCol() { |
69 | - if(!$this->_colMerged){ |
|
69 | + if (!$this->_colMerged) { |
|
70 | 70 | $this->_colMerged=true; |
71 | 71 | return $this->setColspan($this->_container->getRow($this->_row)->count()); |
72 | 72 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | public function setColspan($colspan) { |
77 | - $to=min($this->_container->getRow($this->_row)->count(), $this->_col + $colspan - 1); |
|
78 | - for($i=$to; $i > $this->_col; $i--) { |
|
79 | - $this->_container->toDelete($this->_row, $this->_col + 1); |
|
77 | + $to=min($this->_container->getRow($this->_row)->count(), $this->_col+$colspan-1); |
|
78 | + for ($i=$to; $i>$this->_col; $i--) { |
|
79 | + $this->_container->toDelete($this->_row, $this->_col+1); |
|
80 | 80 | } |
81 | 81 | $this->setProperty("colspan", $colspan); |
82 | 82 | return $this->_container->_setMerged(true); |
@@ -115,21 +115,21 @@ discard block |
||
115 | 115 | return $this->addToProperty("class", "selectable"); |
116 | 116 | } |
117 | 117 | |
118 | - public function setWidth($width){ |
|
118 | + public function setWidth($width) { |
|
119 | 119 | if (\is_int($width)) { |
120 | - $width=Wide::getConstants()["W" . $width]; |
|
120 | + $width=Wide::getConstants()["W".$width]; |
|
121 | 121 | } |
122 | 122 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
123 | - return $this->addToPropertyCtrl("class", "wide", array ("wide" )); |
|
123 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
124 | 124 | } |
125 | 125 | |
126 | - public function toDelete(){ |
|
126 | + public function toDelete() { |
|
127 | 127 | $this->_deleted=true; |
128 | 128 | return $this; |
129 | 129 | } |
130 | 130 | |
131 | 131 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
132 | - if(!$this->_deleted) |
|
132 | + if (!$this->_deleted) |
|
133 | 133 | return parent::compile(); |
134 | 134 | return; |
135 | 135 | } |
@@ -25,6 +25,9 @@ discard block |
||
25 | 25 | protected $_associative; |
26 | 26 | protected $_multiple; |
27 | 27 | |
28 | + /** |
|
29 | + * @param string $identifier |
|
30 | + */ |
|
28 | 31 | public function __construct($identifier, $value="", $items=array(),$associative=true) { |
29 | 32 | parent::__construct($identifier, "div"); |
30 | 33 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
@@ -78,7 +81,7 @@ discard block |
||
78 | 81 | /** |
79 | 82 | * Insert an item at a position |
80 | 83 | * @param mixed $item |
81 | - * @param number $position |
|
84 | + * @param integer $position |
|
82 | 85 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
83 | 86 | */ |
84 | 87 | public function insertItem($item,$position=0){ |
@@ -190,7 +193,7 @@ discard block |
||
190 | 193 | * Sets the values of a property for each item in the collection |
191 | 194 | * @param string $property |
192 | 195 | * @param array $values |
193 | - * @return HtmlCollection |
|
196 | + * @return HtmlDropdown |
|
194 | 197 | */ |
195 | 198 | public function setPropertyValues($property,$values){ |
196 | 199 | $i=0; |
@@ -209,6 +212,9 @@ discard block |
||
209 | 212 | return $this; |
210 | 213 | } |
211 | 214 | |
215 | + /** |
|
216 | + * @param integer $index |
|
217 | + */ |
|
212 | 218 | public function getItem($index){ |
213 | 219 | return $this->items[$index]; |
214 | 220 | } |
@@ -302,6 +308,9 @@ discard block |
||
302 | 308 | return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
303 | 309 | } |
304 | 310 | |
311 | + /** |
|
312 | + * @param string $value |
|
313 | + */ |
|
305 | 314 | public function setValue($value){ |
306 | 315 | $this->value=$value; |
307 | 316 | return $this; |
@@ -338,6 +347,9 @@ discard block |
||
338 | 347 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
339 | 348 | } |
340 | 349 | |
350 | + /** |
|
351 | + * @param string $action |
|
352 | + */ |
|
341 | 353 | public function setAction($action){ |
342 | 354 | $this->_params["action"]=$action; |
343 | 355 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | if(isset($value)){ |
35 | 35 | if($value instanceof HtmlSemDoubleElement){ |
36 | 36 | $text=$value; |
37 | - }else{ |
|
37 | + } else{ |
|
38 | 38 | $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
39 | 39 | $text->setClass("text"); |
40 | 40 | $this->setValue($value); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | if(!$item instanceof HtmlDropdownItem){ |
109 | 109 | $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
110 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
110 | + } elseif($itemO instanceof HtmlDropdownItem){ |
|
111 | 111 | $this->addToProperty("class", "vertical"); |
112 | 112 | } |
113 | 113 | return $itemO; |
@@ -121,8 +121,9 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | public function addInput($name){ |
124 | - if(!isset($name)) |
|
125 | - $name="input-".$this->identifier; |
|
124 | + if(!isset($name)) { |
|
125 | + $name="input-".$this->identifier; |
|
126 | + } |
|
126 | 127 | $this->setAction("activate"); |
127 | 128 | $this->input=new HtmlInput($name,"hidden"); |
128 | 129 | } |
@@ -179,7 +180,7 @@ discard block |
||
179 | 180 | foreach ($items as $k=>$v){ |
180 | 181 | $this->addItem($v)->setData($k); |
181 | 182 | } |
182 | - }else{ |
|
183 | + } else{ |
|
183 | 184 | foreach ($items as $item){ |
184 | 185 | $this->addItem($item); |
185 | 186 | } |
@@ -201,8 +202,7 @@ discard block |
||
201 | 202 | $c=$this->items[$i++]; |
202 | 203 | if(isset($c)){ |
203 | 204 | $c->setProperty($property,$value); |
204 | - } |
|
205 | - else{ |
|
205 | + } else{ |
|
206 | 206 | return $this; |
207 | 207 | } |
208 | 208 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | if($dropdown===false){ |
227 | 227 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
228 | 228 | $dropdown="menu"; |
229 | - }else{ |
|
229 | + } else{ |
|
230 | 230 | $dropdown="dropdown"; |
231 | 231 | $this->mClass="menu"; |
232 | 232 | } |
@@ -247,22 +247,25 @@ discard block |
||
247 | 247 | |
248 | 248 | public function asButton($floating=false){ |
249 | 249 | $this->removeArrow(); |
250 | - if($floating) |
|
251 | - $this->addToProperty("class", "floating"); |
|
250 | + if($floating) { |
|
251 | + $this->addToProperty("class", "floating"); |
|
252 | + } |
|
252 | 253 | $this->removePropertyValue("class", "selection"); |
253 | 254 | return $this->addToProperty("class", "button"); |
254 | 255 | } |
255 | 256 | |
256 | 257 | public function asSelect($name=NULL,$multiple=false,$selection=true){ |
257 | 258 | $this->_multiple=$multiple; |
258 | - if(isset($name)) |
|
259 | - $this->addInput($name); |
|
259 | + if(isset($name)) { |
|
260 | + $this->addInput($name); |
|
261 | + } |
|
260 | 262 | if($multiple){ |
261 | 263 | $this->addToProperty("class", "multiple"); |
262 | 264 | } |
263 | 265 | if ($selection){ |
264 | - if($this->propertyContains("class", "button")===false) |
|
265 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
266 | + if($this->propertyContains("class", "button")===false) { |
|
267 | + $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
268 | + } |
|
266 | 269 | } |
267 | 270 | return $this; |
268 | 271 | } |
@@ -273,8 +276,9 @@ discard block |
||
273 | 276 | } |
274 | 277 | |
275 | 278 | public function setSelect($name=NULL,$multiple=false){ |
276 | - if(!isset($name)) |
|
277 | - $name="select-".$this->identifier; |
|
279 | + if(!isset($name)) { |
|
280 | + $name="select-".$this->identifier; |
|
281 | + } |
|
278 | 282 | $this->input=null; |
279 | 283 | if($multiple){ |
280 | 284 | $this->setProperty("multiple", true); |
@@ -310,12 +314,13 @@ discard block |
||
310 | 314 | $value=$this->value; |
311 | 315 | if(isset($this->input) && isset($value)){ |
312 | 316 | $this->input->setProperty("value", $value); |
313 | - }else{ |
|
317 | + } else{ |
|
314 | 318 | $this->setProperty("value", $value); |
315 | 319 | } |
316 | 320 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
317 | - if(isset($textElement) && !$this->_multiple) |
|
318 | - $textElement->setContent($value); |
|
321 | + if(isset($textElement) && !$this->_multiple) { |
|
322 | + $textElement->setContent($value); |
|
323 | + } |
|
319 | 324 | return $this; |
320 | 325 | } |
321 | 326 |
@@ -13,29 +13,29 @@ discard block |
||
13 | 13 | use Ajax\semantic\html\collections\form\traits\FieldTrait; |
14 | 14 | |
15 | 15 | class HtmlDropdown extends HtmlSemDoubleElement { |
16 | - use FieldTrait,LabeledIconTrait { |
|
16 | + use FieldTrait, LabeledIconTrait { |
|
17 | 17 | addIcon as addIconP; |
18 | 18 | } |
19 | 19 | protected $mClass="menu"; |
20 | 20 | protected $mTagName="div"; |
21 | - protected $items=array (); |
|
22 | - protected $_params=array("action"=>"nothing","on"=>"hover","showOnFocus"=>false); |
|
21 | + protected $items=array(); |
|
22 | + protected $_params=array("action"=>"nothing", "on"=>"hover", "showOnFocus"=>false); |
|
23 | 23 | protected $input; |
24 | 24 | protected $value; |
25 | 25 | protected $_associative; |
26 | 26 | protected $_multiple; |
27 | 27 | |
28 | - public function __construct($identifier, $value="", $items=array(),$associative=true) { |
|
28 | + public function __construct($identifier, $value="", $items=array(), $associative=true) { |
|
29 | 29 | parent::__construct($identifier, "div"); |
30 | 30 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
31 | 31 | $this->setProperty("class", "ui dropdown"); |
32 | 32 | $this->_multiple=false; |
33 | 33 | $content=[]; |
34 | - if(isset($value)){ |
|
35 | - if($value instanceof HtmlSemDoubleElement){ |
|
34 | + if (isset($value)) { |
|
35 | + if ($value instanceof HtmlSemDoubleElement) { |
|
36 | 36 | $text=$value; |
37 | - }else{ |
|
38 | - $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
37 | + } else { |
|
38 | + $text=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
39 | 39 | $text->setClass("text"); |
40 | 40 | $this->setValue($value); |
41 | 41 | } |
@@ -48,29 +48,29 @@ discard block |
||
48 | 48 | $this->addItems($items); |
49 | 49 | } |
50 | 50 | |
51 | - public function getField(){ |
|
51 | + public function getField() { |
|
52 | 52 | return $this->input; |
53 | 53 | } |
54 | 54 | |
55 | - public function getDataField(){ |
|
55 | + public function getDataField() { |
|
56 | 56 | return $this->input; |
57 | 57 | } |
58 | 58 | |
59 | - public function addItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
60 | - $itemO=$this->beforeAddItem($item,$value,$image,$description); |
|
59 | + public function addItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
60 | + $itemO=$this->beforeAddItem($item, $value, $image, $description); |
|
61 | 61 | $this->items[]=$itemO; |
62 | 62 | return $itemO; |
63 | 63 | } |
64 | 64 | |
65 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
65 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
66 | 66 | $this->removeArrow(); |
67 | - $this->addIconP($icon,$before,$labeled); |
|
67 | + $this->addIconP($icon, $before, $labeled); |
|
68 | 68 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
69 | 69 | } |
70 | 70 | |
71 | - public function addIcons($icons){ |
|
71 | + public function addIcons($icons) { |
|
72 | 72 | $count=$this->count(); |
73 | - for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){ |
|
73 | + for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) { |
|
74 | 74 | $this->getItem($i)->addIcon($icons[$i]); |
75 | 75 | } |
76 | 76 | } |
@@ -81,33 +81,33 @@ discard block |
||
81 | 81 | * @param number $position |
82 | 82 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
83 | 83 | */ |
84 | - public function insertItem($item,$position=0){ |
|
84 | + public function insertItem($item, $position=0) { |
|
85 | 85 | $itemO=$this->beforeAddItem($item); |
86 | - $start = array_slice($this->items, 0, $position); |
|
87 | - $end = array_slice($this->items, $position); |
|
88 | - $start[] = $item; |
|
86 | + $start=array_slice($this->items, 0, $position); |
|
87 | + $end=array_slice($this->items, $position); |
|
88 | + $start[]=$item; |
|
89 | 89 | $this->items=array_merge($start, $end); |
90 | 90 | return $itemO; |
91 | 91 | } |
92 | 92 | |
93 | - protected function removeArrow(){ |
|
94 | - if(\sizeof($this->content)>1){ |
|
93 | + protected function removeArrow() { |
|
94 | + if (\sizeof($this->content)>1) { |
|
95 | 95 | unset($this->content["arrow"]); |
96 | 96 | $this->content=\array_values($this->content); |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
100 | + protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
101 | 101 | $itemO=$item; |
102 | - if(\is_array($item)){ |
|
102 | + if (\is_array($item)) { |
|
103 | 103 | $description=JArray::getValue($item, "description", 3); |
104 | 104 | $value=JArray::getValue($item, "value", 1); |
105 | 105 | $image=JArray::getValue($item, "image", 2); |
106 | 106 | $item=JArray::getValue($item, "item", 0); |
107 | 107 | } |
108 | - if(!$item instanceof HtmlDropdownItem){ |
|
109 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
|
110 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
108 | + if (!$item instanceof HtmlDropdownItem) { |
|
109 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description); |
|
110 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
111 | 111 | $this->addToProperty("class", "vertical"); |
112 | 112 | } |
113 | 113 | return $itemO; |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | $this->addItem($function($object)); |
121 | 121 | } |
122 | 122 | |
123 | - public function addInput($name){ |
|
124 | - if(!isset($name)) |
|
123 | + public function addInput($name) { |
|
124 | + if (!isset($name)) |
|
125 | 125 | $name="input-".$this->identifier; |
126 | 126 | $this->setAction("activate"); |
127 | - $this->input=new HtmlInput($name,"hidden"); |
|
127 | + $this->input=new HtmlInput($name, "hidden"); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | * @param string $icon |
134 | 134 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
135 | 135 | */ |
136 | - public function addSearchInputItem($placeHolder=NULL,$icon=NULL){ |
|
137 | - return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon)); |
|
136 | + public function addSearchInputItem($placeHolder=NULL, $icon=NULL) { |
|
137 | + return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Adds a divider item |
142 | 142 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
143 | 143 | */ |
144 | - public function addDividerItem(){ |
|
144 | + public function addDividerItem() { |
|
145 | 145 | return $this->addItem(HtmlDropdownItem::divider()); |
146 | 146 | } |
147 | 147 | |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * @param string $icon |
152 | 152 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
153 | 153 | */ |
154 | - public function addHeaderItem($caption=NULL,$icon=NULL){ |
|
155 | - return $this->addItem(HtmlDropdownItem::header($caption,$icon)); |
|
154 | + public function addHeaderItem($caption=NULL, $icon=NULL) { |
|
155 | + return $this->addItem(HtmlDropdownItem::header($caption, $icon)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param string $color |
162 | 162 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
163 | 163 | */ |
164 | - public function addCircularLabelItem($caption,$color){ |
|
164 | + public function addCircularLabelItem($caption, $color) { |
|
165 | 165 | return $this->addItem(HtmlDropdownItem::circular($caption, $color)); |
166 | 166 | } |
167 | 167 | |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | * @param string $image |
171 | 171 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
172 | 172 | */ |
173 | - public function addMiniAvatarImageItem($caption,$image){ |
|
173 | + public function addMiniAvatarImageItem($caption, $image) { |
|
174 | 174 | return $this->addItem(HtmlDropdownItem::avatar($caption, $image)); |
175 | 175 | } |
176 | 176 | |
177 | - public function addItems($items){ |
|
178 | - if(\is_array($items) && $this->_associative){ |
|
179 | - foreach ($items as $k=>$v){ |
|
177 | + public function addItems($items) { |
|
178 | + if (\is_array($items) && $this->_associative) { |
|
179 | + foreach ($items as $k=>$v) { |
|
180 | 180 | $this->addItem($v)->setData($k); |
181 | 181 | } |
182 | - }else{ |
|
183 | - foreach ($items as $item){ |
|
182 | + } else { |
|
183 | + foreach ($items as $item) { |
|
184 | 184 | $this->addItem($item); |
185 | 185 | } |
186 | 186 | } |
@@ -192,98 +192,98 @@ discard block |
||
192 | 192 | * @param array $values |
193 | 193 | * @return HtmlCollection |
194 | 194 | */ |
195 | - public function setPropertyValues($property,$values){ |
|
195 | + public function setPropertyValues($property, $values) { |
|
196 | 196 | $i=0; |
197 | - if(\is_array($values)===false){ |
|
198 | - $values=\array_fill(0, $this->count(),$values); |
|
197 | + if (\is_array($values)===false) { |
|
198 | + $values=\array_fill(0, $this->count(), $values); |
|
199 | 199 | } |
200 | - foreach ($values as $value){ |
|
200 | + foreach ($values as $value) { |
|
201 | 201 | $c=$this->items[$i++]; |
202 | - if(isset($c)){ |
|
203 | - $c->setProperty($property,$value); |
|
202 | + if (isset($c)) { |
|
203 | + $c->setProperty($property, $value); |
|
204 | 204 | } |
205 | - else{ |
|
205 | + else { |
|
206 | 206 | return $this; |
207 | 207 | } |
208 | 208 | } |
209 | 209 | return $this; |
210 | 210 | } |
211 | 211 | |
212 | - public function each($callBack){ |
|
213 | - foreach ($this->items as $index=>$value){ |
|
214 | - $callBack($index,$value); |
|
212 | + public function each($callBack) { |
|
213 | + foreach ($this->items as $index=>$value) { |
|
214 | + $callBack($index, $value); |
|
215 | 215 | } |
216 | 216 | return $this; |
217 | 217 | } |
218 | 218 | |
219 | - public function getItem($index){ |
|
219 | + public function getItem($index) { |
|
220 | 220 | return $this->items[$index]; |
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | 224 | * @return int |
225 | 225 | */ |
226 | - public function count(){ |
|
226 | + public function count() { |
|
227 | 227 | return \sizeof($this->items); |
228 | 228 | } |
229 | 229 | /** |
230 | 230 | * @param boolean $dropdown |
231 | 231 | */ |
232 | - public function asDropdown($dropdown){ |
|
233 | - if($dropdown===false){ |
|
232 | + public function asDropdown($dropdown) { |
|
233 | + if ($dropdown===false) { |
|
234 | 234 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
235 | 235 | $dropdown="menu"; |
236 | - }else{ |
|
236 | + } else { |
|
237 | 237 | $dropdown="dropdown"; |
238 | 238 | $this->mClass="menu"; |
239 | 239 | } |
240 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
240 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
241 | 241 | } |
242 | 242 | |
243 | - public function setVertical(){ |
|
244 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
243 | + public function setVertical() { |
|
244 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
245 | 245 | } |
246 | 246 | |
247 | - public function setInline(){ |
|
248 | - return $this->addToPropertyCtrl("class", "inline",["inline"]); |
|
247 | + public function setInline() { |
|
248 | + return $this->addToPropertyCtrl("class", "inline", ["inline"]); |
|
249 | 249 | } |
250 | 250 | |
251 | - public function setSimple(){ |
|
252 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
251 | + public function setSimple() { |
|
252 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
253 | 253 | } |
254 | 254 | |
255 | - public function asButton($floating=false){ |
|
255 | + public function asButton($floating=false) { |
|
256 | 256 | $this->removeArrow(); |
257 | - if($floating) |
|
257 | + if ($floating) |
|
258 | 258 | $this->addToProperty("class", "floating"); |
259 | 259 | $this->removePropertyValue("class", "selection"); |
260 | 260 | return $this->addToProperty("class", "button"); |
261 | 261 | } |
262 | 262 | |
263 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
263 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
264 | 264 | $this->_multiple=$multiple; |
265 | - if(isset($name)) |
|
265 | + if (isset($name)) |
|
266 | 266 | $this->addInput($name); |
267 | - if($multiple){ |
|
267 | + if ($multiple) { |
|
268 | 268 | $this->addToProperty("class", "multiple"); |
269 | 269 | } |
270 | - if ($selection){ |
|
271 | - if($this->propertyContains("class", "button")===false) |
|
272 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
270 | + if ($selection) { |
|
271 | + if ($this->propertyContains("class", "button")===false) |
|
272 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
273 | 273 | } |
274 | 274 | return $this; |
275 | 275 | } |
276 | 276 | |
277 | - public function asSearch($name=NULL,$multiple=false,$selection=true){ |
|
278 | - $this->asSelect($name,$multiple,$selection); |
|
277 | + public function asSearch($name=NULL, $multiple=false, $selection=true) { |
|
278 | + $this->asSelect($name, $multiple, $selection); |
|
279 | 279 | return $this->addToProperty("class", "search"); |
280 | 280 | } |
281 | 281 | |
282 | - public function setSelect($name=NULL,$multiple=false){ |
|
283 | - if(!isset($name)) |
|
282 | + public function setSelect($name=NULL, $multiple=false) { |
|
283 | + if (!isset($name)) |
|
284 | 284 | $name="select-".$this->identifier; |
285 | 285 | $this->input=null; |
286 | - if($multiple){ |
|
286 | + if ($multiple) { |
|
287 | 287 | $this->setProperty("multiple", true); |
288 | 288 | $this->addToProperty("class", "multiple"); |
289 | 289 | } |
@@ -291,37 +291,37 @@ discard block |
||
291 | 291 | $this->tagName="select"; |
292 | 292 | $this->setProperty("name", $name); |
293 | 293 | $this->content=null; |
294 | - foreach ($this->items as $item){ |
|
294 | + foreach ($this->items as $item) { |
|
295 | 295 | $item->asOption(); |
296 | 296 | } |
297 | 297 | return $this; |
298 | 298 | } |
299 | 299 | |
300 | - public function asSubmenu($pointing=NULL){ |
|
300 | + public function asSubmenu($pointing=NULL) { |
|
301 | 301 | $this->setClass("ui dropdown link item"); |
302 | - if(isset($pointing)){ |
|
302 | + if (isset($pointing)) { |
|
303 | 303 | $this->setPointing($pointing); |
304 | 304 | } |
305 | 305 | return $this; |
306 | 306 | } |
307 | 307 | |
308 | - public function setPointing($value=Direction::NONE){ |
|
309 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
308 | + public function setPointing($value=Direction::NONE) { |
|
309 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
310 | 310 | } |
311 | 311 | |
312 | - public function setValue($value){ |
|
312 | + public function setValue($value) { |
|
313 | 313 | $this->value=$value; |
314 | 314 | return $this; |
315 | 315 | } |
316 | - private function applyValue(){ |
|
316 | + private function applyValue() { |
|
317 | 317 | $value=$this->value; |
318 | - if(isset($this->input) && isset($value)){ |
|
318 | + if (isset($this->input) && isset($value)) { |
|
319 | 319 | $this->input->setProperty("value", $value); |
320 | - }else{ |
|
320 | + } else { |
|
321 | 321 | $this->setProperty("value", $value); |
322 | 322 | } |
323 | 323 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
324 | - if(isset($textElement) && !$this->_multiple) |
|
324 | + if (isset($textElement) && !$this->_multiple) |
|
325 | 325 | $textElement->setContent($value); |
326 | 326 | return $this; |
327 | 327 | } |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | * @see BaseHtml::run() |
332 | 332 | */ |
333 | 333 | public function run(JsUtils $js) { |
334 | - if($this->propertyContains("class", "simple")===false){ |
|
335 | - if(isset($this->_bsComponent)===false){ |
|
336 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
334 | + if ($this->propertyContains("class", "simple")===false) { |
|
335 | + if (isset($this->_bsComponent)===false) { |
|
336 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
337 | 337 | $this->_bsComponent->setItemSelector(".item"); |
338 | 338 | } |
339 | 339 | $this->addEventsOnRun($js); |
@@ -341,44 +341,44 @@ discard block |
||
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
344 | - public function setCompact(){ |
|
344 | + public function setCompact() { |
|
345 | 345 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
346 | 346 | } |
347 | 347 | |
348 | - public function setAction($action){ |
|
348 | + public function setAction($action) { |
|
349 | 349 | $this->_params["action"]=$action; |
350 | 350 | } |
351 | 351 | |
352 | - public function setOn($on){ |
|
352 | + public function setOn($on) { |
|
353 | 353 | $this->_params["on"]=$on; |
354 | 354 | } |
355 | 355 | |
356 | - public function setShowOnFocus($value){ |
|
356 | + public function setShowOnFocus($value) { |
|
357 | 357 | $this->_params["showOnFocus"]=$value; |
358 | 358 | } |
359 | 359 | |
360 | - public function setFullTextSearch($value){ |
|
360 | + public function setFullTextSearch($value) { |
|
361 | 361 | $this->_params["fullTextSearch"]=$value; |
362 | 362 | } |
363 | 363 | |
364 | 364 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
365 | 365 | $this->applyValue(); |
366 | - return parent::compile($js,$view); |
|
366 | + return parent::compile($js, $view); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | public function getInput() { |
370 | 370 | return $this->input; |
371 | 371 | } |
372 | 372 | public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
373 | - return $this->_addAction($this, $action,$direction,$icon,$labeled); |
|
373 | + return $this->_addAction($this, $action, $direction, $icon, $labeled); |
|
374 | 374 | } |
375 | 375 | |
376 | - public function setIcon($icon="dropdown"){ |
|
376 | + public function setIcon($icon="dropdown") { |
|
377 | 377 | $this->content["arrow"]=new HtmlIcon($this->identifier."-icon", $icon); |
378 | 378 | return $this; |
379 | 379 | } |
380 | 380 | |
381 | - public function jsAddItem($caption){ |
|
381 | + public function jsAddItem($caption) { |
|
382 | 382 | $js="var first=$('#{$this->identifier} .item').first();if(first!=undefined){var new =first.clone();first.parent().append(new);first.html('{$caption}};')"; |
383 | 383 | return $js; |
384 | 384 | } |
@@ -43,8 +43,7 @@ discard block |
||
43 | 43 | foreach ($actions as $action){ |
44 | 44 | $this->addAction($action); |
45 | 45 | } |
46 | - } |
|
47 | - else{ |
|
46 | + } else{ |
|
48 | 47 | $this->addAction($actions); |
49 | 48 | } |
50 | 49 | return $this; |
@@ -64,8 +63,9 @@ discard block |
||
64 | 63 | $class="cancel"; |
65 | 64 | } |
66 | 65 | $action=new HtmlButton("action-".$this->identifier."-".\sizeof($this->content["actions"]->getContent()),$action); |
67 | - if($class!=="") |
|
68 | - $action->addToProperty("class", $class); |
|
66 | + if($class!=="") { |
|
67 | + $action->addToProperty("class", $class); |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | return $this->addElementInPart($action, "actions"); |
71 | 71 | } |
@@ -174,8 +174,9 @@ discard block |
||
174 | 174 | * @see BaseHtml::run() |
175 | 175 | */ |
176 | 176 | public function run(JsUtils $js) { |
177 | - if(isset($this->_bsComponent)===false) |
|
178 | - $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
177 | + if(isset($this->_bsComponent)===false) { |
|
178 | + $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
179 | + } |
|
179 | 180 | $this->addEventsOnRun($js); |
180 | 181 | return $this->_bsComponent; |
181 | 182 | } |
@@ -15,36 +15,36 @@ discard block |
||
15 | 15 | protected $_paramParts=array(); |
16 | 16 | |
17 | 17 | public function __construct($identifier, $header="", $content="", $actions=null) { |
18 | - parent::__construct($identifier, "div","ui modal"); |
|
19 | - if(isset($header)){ |
|
18 | + parent::__construct($identifier, "div", "ui modal"); |
|
19 | + if (isset($header)) { |
|
20 | 20 | $this->setHeader($header); |
21 | 21 | } |
22 | - if(isset($content)){ |
|
22 | + if (isset($content)) { |
|
23 | 23 | $this->setContent($content); |
24 | 24 | } |
25 | - if(isset($actions)){ |
|
25 | + if (isset($actions)) { |
|
26 | 26 | $this->setActions($actions); |
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function setHeader($value) { |
31 | - $this->content["header"]=new HtmlSemDoubleElement("header-" . $this->identifier, "a", "header", $value); |
|
31 | + $this->content["header"]=new HtmlSemDoubleElement("header-".$this->identifier, "a", "header", $value); |
|
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setContent($value) { |
36 | - $this->content["content"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", $value); |
|
36 | + $this->content["content"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", $value); |
|
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | 40 | public function setActions($actions) { |
41 | - $this->content["actions"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "actions"); |
|
42 | - if(\is_array($actions)){ |
|
43 | - foreach ($actions as $action){ |
|
41 | + $this->content["actions"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "actions"); |
|
42 | + if (\is_array($actions)) { |
|
43 | + foreach ($actions as $action) { |
|
44 | 44 | $this->addAction($action); |
45 | 45 | } |
46 | 46 | } |
47 | - else{ |
|
47 | + else { |
|
48 | 48 | $this->addAction($actions); |
49 | 49 | } |
50 | 50 | return $this; |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | * @param string|BaseHtml $action |
55 | 55 | * @return HtmlButton |
56 | 56 | */ |
57 | - public function addAction($action){ |
|
58 | - if(!$action instanceof BaseHtml){ |
|
57 | + public function addAction($action) { |
|
58 | + if (!$action instanceof BaseHtml) { |
|
59 | 59 | $class=""; |
60 | - if(\array_search($action, ["Okay","Yes","Validate"])!==false){ |
|
60 | + if (\array_search($action, ["Okay", "Yes", "Validate"])!==false) { |
|
61 | 61 | $class="approve"; |
62 | 62 | } |
63 | - if(\array_search($action, ["Close","Cancel","No"])!==false){ |
|
63 | + if (\array_search($action, ["Close", "Cancel", "No"])!==false) { |
|
64 | 64 | $class="cancel"; |
65 | 65 | } |
66 | - $action=new HtmlButton("action-".$this->identifier."-".\sizeof($this->content["actions"]->getContent()),$action); |
|
67 | - if($class!=="") |
|
66 | + $action=new HtmlButton("action-".$this->identifier."-".\sizeof($this->content["actions"]->getContent()), $action); |
|
67 | + if ($class!=="") |
|
68 | 68 | $action->addToProperty("class", $class); |
69 | 69 | } |
70 | 70 | return $this->addElementInPart($action, "actions"); |
@@ -74,66 +74,66 @@ discard block |
||
74 | 74 | * @param int $index |
75 | 75 | * @return HtmlButton |
76 | 76 | */ |
77 | - public function getAction($index){ |
|
77 | + public function getAction($index) { |
|
78 | 78 | return $this->content["actions"]->getContent()[$index]; |
79 | 79 | } |
80 | 80 | |
81 | - public function addContent($content,$before=false){ |
|
82 | - $this->content["content"]->addContent($content,$before); |
|
81 | + public function addContent($content, $before=false) { |
|
82 | + $this->content["content"]->addContent($content, $before); |
|
83 | 83 | return $this; |
84 | 84 | } |
85 | 85 | |
86 | - public function addImageContent($image,$description=NULL){ |
|
86 | + public function addImageContent($image, $description=NULL) { |
|
87 | 87 | $content=$this->content["content"]; |
88 | - if(isset($description)){ |
|
89 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
90 | - $content->addContent($description,true); |
|
88 | + if (isset($description)) { |
|
89 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
90 | + $content->addContent($description, true); |
|
91 | 91 | } |
92 | - if($image!==""){ |
|
93 | - $img=new HtmlImage("image-".$this->identifier,$image,"","medium"); |
|
94 | - $content->addContent($img,true); |
|
95 | - $content->addToProperty("class","image"); |
|
92 | + if ($image!=="") { |
|
93 | + $img=new HtmlImage("image-".$this->identifier, $image, "", "medium"); |
|
94 | + $content->addContent($img, true); |
|
95 | + $content->addToProperty("class", "image"); |
|
96 | 96 | } |
97 | 97 | return $this; |
98 | 98 | } |
99 | 99 | |
100 | - public function addIconContent($icon,$description=NULL){ |
|
100 | + public function addIconContent($icon, $description=NULL) { |
|
101 | 101 | $content=$this->content["content"]; |
102 | - if(isset($description)){ |
|
103 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
104 | - $content->addContent($description,true); |
|
102 | + if (isset($description)) { |
|
103 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
104 | + $content->addContent($description, true); |
|
105 | 105 | } |
106 | - if($icon!==""){ |
|
107 | - $img=new HtmlIcon("image-".$this->identifier,$icon); |
|
108 | - $content->addContent($img,true); |
|
109 | - $content->addToProperty("class","image"); |
|
106 | + if ($icon!=="") { |
|
107 | + $img=new HtmlIcon("image-".$this->identifier, $icon); |
|
108 | + $content->addContent($img, true); |
|
109 | + $content->addToProperty("class", "image"); |
|
110 | 110 | } |
111 | 111 | return $this; |
112 | 112 | } |
113 | 113 | |
114 | - private function addElementInPart($element,$part) { |
|
114 | + private function addElementInPart($element, $part) { |
|
115 | 115 | $this->content[$part]->addContent($element); |
116 | 116 | return $element; |
117 | 117 | } |
118 | 118 | |
119 | - public function showDimmer($value){ |
|
120 | - $value=$value?"show":"hide"; |
|
119 | + public function showDimmer($value) { |
|
120 | + $value=$value ? "show" : "hide"; |
|
121 | 121 | $this->_paramParts[]=["'".$value." dimmer'"]; |
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
125 | - public function setInverted($recursive=true){ |
|
125 | + public function setInverted($recursive=true) { |
|
126 | 126 | $this->_params["inverted"]=true; |
127 | 127 | return $this; |
128 | 128 | } |
129 | 129 | |
130 | - public function setBasic(){ |
|
130 | + public function setBasic() { |
|
131 | 131 | return $this->addToProperty("class", "basic"); |
132 | 132 | } |
133 | 133 | |
134 | 134 | |
135 | - public function setTransition($value){ |
|
136 | - $this->_paramParts[]=["'setting'","'transition'","'".$value."'"]; |
|
135 | + public function setTransition($value) { |
|
136 | + $this->_paramParts[]=["'setting'", "'transition'", "'".$value."'"]; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @param string $viewName |
144 | 144 | * @param $params The parameters to pass to the view |
145 | 145 | */ |
146 | - public function renderView(JsUtils $js,$initialController,$viewName, $params=array()) { |
|
147 | - return $this->setContent($js->renderContent($initialController, $viewName,$params)); |
|
146 | + public function renderView(JsUtils $js, $initialController, $viewName, $params=array()) { |
|
147 | + return $this->setContent($js->renderContent($initialController, $viewName, $params)); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @param string $actionName the action name |
156 | 156 | * @param array $params |
157 | 157 | */ |
158 | - public function forward(JsUtils $js,$initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
159 | - return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName,$params)); |
|
158 | + public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
159 | + return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName, $params)); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
167 | 167 | */ |
168 | 168 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
169 | - $this->content=JArray::sortAssociative($this->content, ["header","content","actions" ]); |
|
169 | + $this->content=JArray::sortAssociative($this->content, ["header", "content", "actions"]); |
|
170 | 170 | return parent::compile($js, $view); |
171 | 171 | } |
172 | 172 | /* |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @see BaseHtml::run() |
175 | 175 | */ |
176 | 176 | public function run(JsUtils $js) { |
177 | - if(isset($this->_bsComponent)===false) |
|
178 | - $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
177 | + if (isset($this->_bsComponent)===false) |
|
178 | + $this->_bsComponent=$js->semantic()->modal("#".$this->identifier, $this->_params, $this->_paramParts); |
|
179 | 179 | $this->addEventsOnRun($js); |
180 | 180 | return $this->_bsComponent; |
181 | 181 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | return $this->jsDo("hide"); |
189 | 189 | } |
190 | 190 | |
191 | - public function onHidden($js){ |
|
191 | + public function onHidden($js) { |
|
192 | 192 | $this->_params["onHidden"]=$js; |
193 | 193 | } |
194 | 194 | } |
@@ -15,15 +15,28 @@ discard block |
||
15 | 15 | * @property InstanceViewer $_instanceViewer |
16 | 16 | */ |
17 | 17 | trait DataTableFieldAsTrait{ |
18 | + |
|
19 | + /** |
|
20 | + * @param \Closure $field |
|
21 | + */ |
|
18 | 22 | abstract public function addField($field); |
23 | + |
|
24 | + /** |
|
25 | + * @param integer $index |
|
26 | + * @param \Closure $field |
|
27 | + */ |
|
19 | 28 | abstract public function insertField($index,$field); |
29 | + |
|
30 | + /** |
|
31 | + * @param \Closure $field |
|
32 | + */ |
|
20 | 33 | abstract public function insertInField($index,$field); |
21 | 34 | abstract public function fieldAs($index,$type,$attributes=NULL); |
22 | 35 | /** |
23 | 36 | * @param string $caption |
24 | 37 | * @param callable $callback |
25 | 38 | * @param boolean $visibleHover |
26 | - * @return callable |
|
39 | + * @return \Closure |
|
27 | 40 | */ |
28 | 41 | private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
29 | 42 | return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
@@ -33,7 +46,7 @@ discard block |
||
33 | 46 | * @param callable $thisCallback |
34 | 47 | * @param array $parameters |
35 | 48 | * @param callable $callback |
36 | - * @return callable |
|
49 | + * @return \Closure |
|
37 | 50 | */ |
38 | 51 | private function getCallable($thisCallback,$parameters,$callback=null){ |
39 | 52 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -103,7 +116,7 @@ discard block |
||
103 | 116 | * @param string $caption |
104 | 117 | * @param callable $callback |
105 | 118 | * @param boolean $visibleHover |
106 | - * @return DataTable |
|
119 | + * @return DataTableFieldAsTrait |
|
107 | 120 | */ |
108 | 121 | public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
109 | 122 | $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
@@ -115,7 +128,7 @@ discard block |
||
115 | 128 | * @param array $buttons |
116 | 129 | * @param callable $callback |
117 | 130 | * @param boolean $visibleHover |
118 | - * @return DataTable |
|
131 | + * @return DataTableFieldAsTrait |
|
119 | 132 | */ |
120 | 133 | public function addFieldButtons($buttons,$visibleHover=true,$callback=null){ |
121 | 134 | $this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback)); |
@@ -127,7 +140,7 @@ discard block |
||
127 | 140 | * @param int $index |
128 | 141 | * @param string $caption |
129 | 142 | * @param callable $callback |
130 | - * @return DataTable |
|
143 | + * @return DataTableFieldAsTrait |
|
131 | 144 | */ |
132 | 145 | public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
133 | 146 | $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
@@ -139,18 +152,27 @@ discard block |
||
139 | 152 | * @param int $index |
140 | 153 | * @param string $caption |
141 | 154 | * @param callable $callback |
142 | - * @return DataTable |
|
155 | + * @return DataTableFieldAsTrait |
|
143 | 156 | */ |
144 | 157 | public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
145 | 158 | $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
146 | 159 | return $this; |
147 | 160 | } |
148 | 161 | |
162 | + /** |
|
163 | + * @param string $icon |
|
164 | + * @param string $class |
|
165 | + * @param callable $callback |
|
166 | + */ |
|
149 | 167 | private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
150 | 168 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
151 | 169 | return $this; |
152 | 170 | } |
153 | 171 | |
172 | + /** |
|
173 | + * @param string $icon |
|
174 | + * @param string $class |
|
175 | + */ |
|
154 | 176 | private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
155 | 177 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
156 | 178 | return $this; |
@@ -169,7 +191,7 @@ discard block |
||
169 | 191 | * @param boolean $visibleHover |
170 | 192 | * @param array $deleteBehavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get") |
171 | 193 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
172 | - * @return DataTable |
|
194 | + * @return DataTableFieldAsTrait |
|
173 | 195 | */ |
174 | 196 | public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
175 | 197 | $this->_deleteBehavior=$deleteBehavior; |
@@ -181,7 +203,7 @@ discard block |
||
181 | 203 | * @param string $visibleHover |
182 | 204 | * @param array $editBehavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get") |
183 | 205 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
184 | - * @return DataTable |
|
206 | + * @return DataTableFieldAsTrait |
|
185 | 207 | */ |
186 | 208 | public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){ |
187 | 209 | $this->_editBehavior=$editBehavior; |
@@ -194,7 +216,7 @@ discard block |
||
194 | 216 | * @param array $behavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get") |
195 | 217 | * @param callable $callbackEdit this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
196 | 218 | * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
197 | - * @return DataTable |
|
219 | + * @return DataTableFieldAsTrait |
|
198 | 220 | */ |
199 | 221 | public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){ |
200 | 222 | $this->addEditButton($visibleHover,$behavior,$callbackEdit); |
@@ -203,6 +225,9 @@ discard block |
||
203 | 225 | return $this; |
204 | 226 | } |
205 | 227 | |
228 | + /** |
|
229 | + * @param callable $callback |
|
230 | + */ |
|
206 | 231 | public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){ |
207 | 232 | $this->_deleteBehavior=$deleteBehavior; |
208 | 233 | return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback); |
@@ -14,19 +14,19 @@ discard block |
||
14 | 14 | * @property boolean $_visibleHover |
15 | 15 | * @property InstanceViewer $_instanceViewer |
16 | 16 | */ |
17 | -trait DataTableFieldAsTrait{ |
|
17 | +trait DataTableFieldAsTrait { |
|
18 | 18 | abstract public function addField($field); |
19 | - abstract public function insertField($index,$field); |
|
20 | - abstract public function insertInField($index,$field); |
|
21 | - abstract public function fieldAs($index,$type,$attributes=NULL); |
|
19 | + abstract public function insertField($index, $field); |
|
20 | + abstract public function insertInField($index, $field); |
|
21 | + abstract public function fieldAs($index, $type, $attributes=NULL); |
|
22 | 22 | /** |
23 | 23 | * @param string $caption |
24 | 24 | * @param callable $callback |
25 | 25 | * @param boolean $visibleHover |
26 | 26 | * @return callable |
27 | 27 | */ |
28 | - private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
|
29 | - return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
|
28 | + private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) { |
|
29 | + return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -35,20 +35,20 @@ discard block |
||
35 | 35 | * @param callable $callback |
36 | 36 | * @return callable |
37 | 37 | */ |
38 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
39 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
40 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
41 | - if(isset($callback)){ |
|
42 | - if(\is_callable($callback)){ |
|
43 | - $callback($object,$instance,$this->_instanceViewer->count()+1); |
|
38 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
39 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
40 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
41 | + if (isset($callback)) { |
|
42 | + if (\is_callable($callback)) { |
|
43 | + $callback($object, $instance, $this->_instanceViewer->count()+1); |
|
44 | 44 | } |
45 | 45 | } |
46 | - if($object instanceof HtmlSemDoubleElement){ |
|
46 | + if ($object instanceof HtmlSemDoubleElement) { |
|
47 | 47 | $id=$this->_instanceViewer->getIdentifier(); |
48 | - $object->setProperty("data-ajax",$id); |
|
49 | - if($object->propertyContains("class","visibleover")){ |
|
48 | + $object->setProperty("data-ajax", $id); |
|
49 | + if ($object->propertyContains("class", "visibleover")) { |
|
50 | 50 | $this->_visibleHover=true; |
51 | - $object->setProperty("style","visibility:hidden;"); |
|
51 | + $object->setProperty("style", "visibility:hidden;"); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | return $object; |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | * @param string $caption |
61 | 61 | * @return HtmlButton |
62 | 62 | */ |
63 | - private function getFieldButton($caption,$visibleHover=true){ |
|
64 | - $bt= new HtmlButton($this->cleanIdentifier($caption),$caption); |
|
65 | - if($visibleHover) |
|
63 | + private function getFieldButton($caption, $visibleHover=true) { |
|
64 | + $bt=new HtmlButton($this->cleanIdentifier($caption), $caption); |
|
65 | + if ($visibleHover) |
|
66 | 66 | $this->_visibleOver($bt); |
67 | 67 | return $bt; |
68 | 68 | } |
69 | 69 | |
70 | - private function getFieldButtons($buttons,$visibleHover=true){ |
|
71 | - $bts=new HtmlButtonGroups("",$buttons); |
|
72 | - if($visibleHover) |
|
70 | + private function getFieldButtons($buttons, $visibleHover=true) { |
|
71 | + $bts=new HtmlButtonGroups("", $buttons); |
|
72 | + if ($visibleHover) |
|
73 | 73 | $this->_visibleOver($bts); |
74 | 74 | return $bts; |
75 | 75 | } |
@@ -83,19 +83,19 @@ discard block |
||
83 | 83 | * @param array $attributes associative array (<b>ajax</b> key is for ajax post) |
84 | 84 | * @return DataTable |
85 | 85 | */ |
86 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
87 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
|
88 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
89 | - $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
|
90 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
86 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
87 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){ |
|
88 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
89 | + $button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]); |
|
90 | + if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
91 | 91 | $this->_visibleOver($button); |
92 | 92 | return $button; |
93 | - }, $index,$attributes); |
|
93 | + }, $index, $attributes); |
|
94 | 94 | } |
95 | 95 | |
96 | - protected function _visibleOver(BaseHtml $element){ |
|
96 | + protected function _visibleOver(BaseHtml $element) { |
|
97 | 97 | $this->_visibleHover=true; |
98 | - return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
|
98 | + return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;"); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @param boolean $visibleHover |
106 | 106 | * @return DataTable |
107 | 107 | */ |
108 | - public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
|
109 | - $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
|
108 | + public function addFieldButton($caption, $visibleHover=true, $callback=null) { |
|
109 | + $this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback)); |
|
110 | 110 | return $this; |
111 | 111 | } |
112 | 112 | |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * @param boolean $visibleHover |
118 | 118 | * @return DataTable |
119 | 119 | */ |
120 | - public function addFieldButtons($buttons,$visibleHover=true,$callback=null){ |
|
121 | - $this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback)); |
|
120 | + public function addFieldButtons($buttons, $visibleHover=true, $callback=null) { |
|
121 | + $this->addField($this->getCallable("getFieldButtons", [$buttons, $visibleHover], $callback)); |
|
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @param callable $callback |
130 | 130 | * @return DataTable |
131 | 131 | */ |
132 | - public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
133 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
132 | + public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
133 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
@@ -141,25 +141,25 @@ discard block |
||
141 | 141 | * @param callable $callback |
142 | 142 | * @return DataTable |
143 | 143 | */ |
144 | - public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
145 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
144 | + public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
145 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
146 | 146 | return $this; |
147 | 147 | } |
148 | 148 | |
149 | - private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
|
150 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
149 | + private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) { |
|
150 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
151 | 151 | return $this; |
152 | 152 | } |
153 | 153 | |
154 | - private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
|
155 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
154 | + private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) { |
|
155 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
156 | 156 | return $this; |
157 | 157 | } |
158 | 158 | |
159 | - private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
|
160 | - $bt=$this->getFieldButton("",$visibleHover); |
|
159 | + private function getDefaultButton($icon, $class=null, $visibleHover=true) { |
|
160 | + $bt=$this->getFieldButton("", $visibleHover); |
|
161 | 161 | $bt->asIcon($icon); |
162 | - if(isset($class)) |
|
162 | + if (isset($class)) |
|
163 | 163 | $bt->addClass($class); |
164 | 164 | return $bt; |
165 | 165 | } |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
172 | 172 | * @return DataTable |
173 | 173 | */ |
174 | - public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
174 | + public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
175 | 175 | $this->_deleteBehavior=$deleteBehavior; |
176 | - return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback); |
|
176 | + return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
184 | 184 | * @return DataTable |
185 | 185 | */ |
186 | - public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){ |
|
186 | + public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) { |
|
187 | 187 | $this->_editBehavior=$editBehavior; |
188 | - return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback); |
|
188 | + return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -196,20 +196,20 @@ discard block |
||
196 | 196 | * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
197 | 197 | * @return DataTable |
198 | 198 | */ |
199 | - public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){ |
|
200 | - $this->addEditButton($visibleHover,$behavior,$callbackEdit); |
|
199 | + public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) { |
|
200 | + $this->addEditButton($visibleHover, $behavior, $callbackEdit); |
|
201 | 201 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
202 | - $this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete); |
|
202 | + $this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete); |
|
203 | 203 | return $this; |
204 | 204 | } |
205 | 205 | |
206 | - public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
206 | + public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
207 | 207 | $this->_deleteBehavior=$deleteBehavior; |
208 | - return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback); |
|
208 | + return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback); |
|
209 | 209 | } |
210 | 210 | |
211 | - public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){ |
|
211 | + public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) { |
|
212 | 212 | $this->_editBehavior=$editBehavior; |
213 | - return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback); |
|
213 | + return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback); |
|
214 | 214 | } |
215 | 215 | } |
@@ -62,15 +62,17 @@ discard block |
||
62 | 62 | */ |
63 | 63 | private function getFieldButton($caption,$visibleHover=true){ |
64 | 64 | $bt= new HtmlButton($this->cleanIdentifier($caption),$caption); |
65 | - if($visibleHover) |
|
66 | - $this->_visibleOver($bt); |
|
65 | + if($visibleHover) { |
|
66 | + $this->_visibleOver($bt); |
|
67 | + } |
|
67 | 68 | return $bt; |
68 | 69 | } |
69 | 70 | |
70 | 71 | private function getFieldButtons($buttons,$visibleHover=true){ |
71 | 72 | $bts=new HtmlButtonGroups("",$buttons); |
72 | - if($visibleHover) |
|
73 | - $this->_visibleOver($bts); |
|
73 | + if($visibleHover) { |
|
74 | + $this->_visibleOver($bts); |
|
75 | + } |
|
74 | 76 | return $bts; |
75 | 77 | } |
76 | 78 | |
@@ -87,8 +89,9 @@ discard block |
||
87 | 89 | return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
88 | 90 | $button=new HtmlButton($id,$value,$cssStyle); |
89 | 91 | $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
90 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
91 | - $this->_visibleOver($button); |
|
92 | + if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) { |
|
93 | + $this->_visibleOver($button); |
|
94 | + } |
|
92 | 95 | return $button; |
93 | 96 | }, $index,$attributes); |
94 | 97 | } |
@@ -159,8 +162,9 @@ discard block |
||
159 | 162 | private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
160 | 163 | $bt=$this->getFieldButton("",$visibleHover); |
161 | 164 | $bt->asIcon($icon); |
162 | - if(isset($class)) |
|
163 | - $bt->addClass($class); |
|
165 | + if(isset($class)) { |
|
166 | + $bt->addClass($class); |
|
167 | + } |
|
164 | 168 | return $bt; |
165 | 169 | } |
166 | 170 |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | /** |
49 | 49 | * define the button style |
50 | - * @param string|int $cssStyle |
|
50 | + * @param string $cssStyle |
|
51 | 51 | * @return HtmlButton default : "" |
52 | 52 | */ |
53 | 53 | public function setStyle($cssStyle) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public function setFocusable($value=true) { |
58 | - if ($value === true) |
|
58 | + if ($value===true) |
|
59 | 59 | $this->setProperty("tabindex", "0"); |
60 | 60 | else { |
61 | 61 | $this->removeProperty("tabindex"); |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | |
66 | 66 | public function setAnimated($content, $animation="") { |
67 | 67 | $this->setTagName("div"); |
68 | - $this->addToProperty("class", "animated " . $animation); |
|
69 | - $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
|
68 | + $this->addToProperty("class", "animated ".$animation); |
|
69 | + $visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div"); |
|
70 | 70 | $visible->setClass("visible content"); |
71 | 71 | $visible->setContent($this->content); |
72 | - $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
|
72 | + $hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div"); |
|
73 | 73 | $hidden->setClass("hidden content"); |
74 | 74 | $hidden->setContent($content); |
75 | - $this->content=array ($visible,$hidden ); |
|
75 | + $this->content=array($visible, $hidden); |
|
76 | 76 | return $hidden; |
77 | 77 | } |
78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | public function asIcon($icon) { |
85 | 85 | $iconO=$icon; |
86 | 86 | if (\is_string($icon)) { |
87 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
87 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
88 | 88 | } |
89 | 89 | $this->addToProperty("class", "icon"); |
90 | 90 | $this->content=$iconO; |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | * @return HtmlLabel |
105 | 105 | */ |
106 | 106 | public function addLabel($label, $before=false, $icon=NULL) { |
107 | - $this->tagName="div";$prefix=""; |
|
108 | - if($before) |
|
107 | + $this->tagName="div"; $prefix=""; |
|
108 | + if ($before) |
|
109 | 109 | $prefix="left "; |
110 | 110 | $this->addToProperty("class", $prefix."labeled"); |
111 | 111 | $isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon); |
112 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
113 | - if($isIcon){ |
|
112 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
113 | + if ($isIcon) { |
|
114 | 114 | $this->content->addClass("icon"); |
115 | 115 | } |
116 | 116 | $this->content->setTagName("div"); |
117 | - $label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a"); |
|
117 | + $label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a"); |
|
118 | 118 | $label->setBasic(); |
119 | 119 | $this->addContent($label, $before); |
120 | 120 | return $label; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function fromArray($array) { |
128 | 128 | $array=parent::fromArray($array); |
129 | - foreach ( $array as $key => $value ) { |
|
129 | + foreach ($array as $key => $value) { |
|
130 | 130 | $this->setProperty($key, $value); |
131 | 131 | } |
132 | 132 | return $array; |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | return $this->addToProperty("class", "positive"); |
141 | 141 | } |
142 | 142 | |
143 | - public function setColor($color){ |
|
144 | - if(\is_array($this->content)){ |
|
145 | - foreach ($this->content as $content){ |
|
146 | - if($content instanceof HtmlButton) |
|
143 | + public function setColor($color) { |
|
144 | + if (\is_array($this->content)) { |
|
145 | + foreach ($this->content as $content) { |
|
146 | + if ($content instanceof HtmlButton) |
|
147 | 147 | $content->setColor($color); |
148 | 148 | } |
149 | 149 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @return HtmlButton |
202 | 202 | */ |
203 | 203 | public static function social($identifier, $social, $value=NULL) { |
204 | - if ($value === NULL) |
|
204 | + if ($value===NULL) |
|
205 | 205 | $value=\ucfirst($social); |
206 | 206 | $return=new HtmlButton($identifier, $value); |
207 | 207 | $return->addIcon($social); |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | * {@inheritDoc} |
239 | 239 | * @see HtmlSemDoubleElement::asLink() |
240 | 240 | */ |
241 | - public function asLink($href=NULL,$target=NULL) { |
|
242 | - parent::asLink($href,$target); |
|
241 | + public function asLink($href=NULL, $target=NULL) { |
|
242 | + parent::asLink($href, $target); |
|
243 | 243 | return $this; |
244 | 244 | } |
245 | 245 | |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | * @param string $icon |
253 | 253 | * @return HtmlButtonGroups |
254 | 254 | */ |
255 | - public static function dropdown($identifier,$value,$items=[],$asCombo=false,$icon=null){ |
|
256 | - $result=new HtmlButtonGroups($identifier,[$value]); |
|
257 | - $result->addDropdown($items,$asCombo); |
|
258 | - if(isset($icon)) |
|
255 | + public static function dropdown($identifier, $value, $items=[], $asCombo=false, $icon=null) { |
|
256 | + $result=new HtmlButtonGroups($identifier, [$value]); |
|
257 | + $result->addDropdown($items, $asCombo); |
|
258 | + if (isset($icon)) |
|
259 | 259 | $result->setIcon($icon); |
260 | 260 | return $result; |
261 | 261 | } |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public function setFocusable($value=true) { |
58 | - if ($value === true) |
|
59 | - $this->setProperty("tabindex", "0"); |
|
60 | - else { |
|
58 | + if ($value === true) { |
|
59 | + $this->setProperty("tabindex", "0"); |
|
60 | + } else { |
|
61 | 61 | $this->removeProperty("tabindex"); |
62 | 62 | } |
63 | 63 | return $this; |
@@ -105,8 +105,9 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function addLabel($label, $before=false, $icon=NULL) { |
107 | 107 | $this->tagName="div";$prefix=""; |
108 | - if($before) |
|
109 | - $prefix="left "; |
|
108 | + if($before) { |
|
109 | + $prefix="left "; |
|
110 | + } |
|
110 | 111 | $this->addToProperty("class", $prefix."labeled"); |
111 | 112 | $isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon); |
112 | 113 | $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
@@ -143,12 +144,13 @@ discard block |
||
143 | 144 | public function setColor($color){ |
144 | 145 | if(\is_array($this->content)){ |
145 | 146 | foreach ($this->content as $content){ |
146 | - if($content instanceof HtmlButton) |
|
147 | - $content->setColor($color); |
|
147 | + if($content instanceof HtmlButton) { |
|
148 | + $content->setColor($color); |
|
149 | + } |
|
148 | 150 | } |
151 | + } else { |
|
152 | + parent::setColor($color); |
|
149 | 153 | } |
150 | - else |
|
151 | - parent::setColor($color); |
|
152 | 154 | return $this; |
153 | 155 | } |
154 | 156 | |
@@ -201,8 +203,9 @@ discard block |
||
201 | 203 | * @return HtmlButton |
202 | 204 | */ |
203 | 205 | public static function social($identifier, $social, $value=NULL) { |
204 | - if ($value === NULL) |
|
205 | - $value=\ucfirst($social); |
|
206 | + if ($value === NULL) { |
|
207 | + $value=\ucfirst($social); |
|
208 | + } |
|
206 | 209 | $return=new HtmlButton($identifier, $value); |
207 | 210 | $return->addIcon($social); |
208 | 211 | return $return->addToPropertyCtrl("class", $social, Social::getConstants()); |
@@ -255,8 +258,9 @@ discard block |
||
255 | 258 | public static function dropdown($identifier,$value,$items=[],$asCombo=false,$icon=null){ |
256 | 259 | $result=new HtmlButtonGroups($identifier,[$value]); |
257 | 260 | $result->addDropdown($items,$asCombo); |
258 | - if(isset($icon)) |
|
259 | - $result->setIcon($icon); |
|
261 | + if(isset($icon)) { |
|
262 | + $result->setIcon($icon); |
|
263 | + } |
|
260 | 264 | return $result; |
261 | 265 | } |
262 | 266 | } |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | use Ajax\common\html\HtmlDoubleElement; |
10 | 10 | use Ajax\semantic\html\base\constants\Side; |
11 | 11 | |
12 | -class HtmlStep extends HtmlSemCollection{ |
|
12 | +class HtmlStep extends HtmlSemCollection { |
|
13 | 13 | protected $_activeStep; |
14 | 14 | protected $_startStep; |
15 | 15 | |
16 | - public function __construct( $identifier,$steps=array()){ |
|
17 | - parent::__construct( $identifier,"div", "ui steps"); |
|
16 | + public function __construct($identifier, $steps=array()) { |
|
17 | + parent::__construct($identifier, "div", "ui steps"); |
|
18 | 18 | $this->addItems($steps); |
19 | 19 | } |
20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
25 | 25 | */ |
26 | 26 | protected function createItem($value) { |
27 | - $itemO=new HtmlStepItem("item-".\sizeof($this->content),$value); |
|
27 | + $itemO=new HtmlStepItem("item-".\sizeof($this->content), $value); |
|
28 | 28 | return $itemO; |
29 | 29 | } |
30 | 30 | |
@@ -32,50 +32,50 @@ discard block |
||
32 | 32 | * @param string|array $step |
33 | 33 | * @return HtmlStepItem |
34 | 34 | */ |
35 | - public function addStep($step){ |
|
35 | + public function addStep($step) { |
|
36 | 36 | return $this->addItem($step); |
37 | 37 | } |
38 | 38 | |
39 | - public function setOrdered(){ |
|
39 | + public function setOrdered() { |
|
40 | 40 | return $this->addToProperty("class", "ordered"); |
41 | 41 | } |
42 | 42 | |
43 | - public function isOrdered(){ |
|
43 | + public function isOrdered() { |
|
44 | 44 | return $this->propertyContains("class", "ordered"); |
45 | 45 | } |
46 | 46 | |
47 | - public function setVertical(){ |
|
47 | + public function setVertical() { |
|
48 | 48 | return $this->addToProperty("class", "vertical"); |
49 | 49 | } |
50 | 50 | |
51 | - protected function defineActiveStep(){ |
|
51 | + protected function defineActiveStep() { |
|
52 | 52 | $activestep=$this->_activeStep; |
53 | 53 | $count=$this->count(); |
54 | - if(!$this->isOrdered()){ |
|
55 | - for($i=$this->_startStep;$i<$count;$i++){ |
|
54 | + if (!$this->isOrdered()) { |
|
55 | + for ($i=$this->_startStep; $i<$count; $i++) { |
|
56 | 56 | $step=$this->content[$i]; |
57 | 57 | $step->removeStatus(); |
58 | - if($i<$activestep) |
|
58 | + if ($i<$activestep) |
|
59 | 59 | $step->setCompleted(); |
60 | 60 | elseif ($i===$activestep) |
61 | 61 | $step->setActive(); |
62 | 62 | else |
63 | 63 | $step->setDisabled(); |
64 | 64 | } |
65 | - }else{ |
|
66 | - foreach ($this->content as $step){ |
|
65 | + } else { |
|
66 | + foreach ($this->content as $step) { |
|
67 | 67 | $step->removeStatus(); |
68 | 68 | } |
69 | - if($activestep<$count) |
|
69 | + if ($activestep<$count) |
|
70 | 70 | $this->content[$activestep]->setActive(); |
71 | 71 | } |
72 | 72 | return $this; |
73 | 73 | } |
74 | 74 | |
75 | 75 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
76 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
76 | + if (isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
77 | 77 | $this->defineActiveStep(); |
78 | - return parent::compile($js,$view); |
|
78 | + return parent::compile($js, $view); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function setActiveStep($_activeStep) { |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | return $this; |
84 | 84 | } |
85 | 85 | |
86 | - public function setAttached($side="",HtmlDoubleElement $toElement=NULL){ |
|
87 | - if(isset($toElement)){ |
|
88 | - $toElement->addToPropertyCtrl("class", "attached",array("attached")); |
|
86 | + public function setAttached($side="", HtmlDoubleElement $toElement=NULL) { |
|
87 | + if (isset($toElement)) { |
|
88 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
89 | 89 | } |
90 | - return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
90 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
91 | 91 | } |
92 | 92 | |
93 | - public function asLink(){ |
|
94 | - foreach ($this->content as $step){ |
|
93 | + public function asLink() { |
|
94 | + foreach ($this->content as $step) { |
|
95 | 95 | $step->asLink(); |
96 | 96 | } |
97 | 97 | return $this; |
@@ -55,26 +55,29 @@ |
||
55 | 55 | for($i=$this->_startStep;$i<$count;$i++){ |
56 | 56 | $step=$this->content[$i]; |
57 | 57 | $step->removeStatus(); |
58 | - if($i<$activestep) |
|
59 | - $step->setCompleted(); |
|
60 | - elseif ($i===$activestep) |
|
61 | - $step->setActive(); |
|
62 | - else |
|
63 | - $step->setDisabled(); |
|
58 | + if($i<$activestep) { |
|
59 | + $step->setCompleted(); |
|
60 | + } elseif ($i===$activestep) { |
|
61 | + $step->setActive(); |
|
62 | + } else { |
|
63 | + $step->setDisabled(); |
|
64 | + } |
|
64 | 65 | } |
65 | - }else{ |
|
66 | + } else{ |
|
66 | 67 | foreach ($this->content as $step){ |
67 | 68 | $step->removeStatus(); |
68 | 69 | } |
69 | - if($activestep<$count) |
|
70 | - $this->content[$activestep]->setActive(); |
|
70 | + if($activestep<$count) { |
|
71 | + $this->content[$activestep]->setActive(); |
|
72 | + } |
|
71 | 73 | } |
72 | 74 | return $this; |
73 | 75 | } |
74 | 76 | |
75 | 77 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
76 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
77 | - $this->defineActiveStep(); |
|
78 | + if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) { |
|
79 | + $this->defineActiveStep(); |
|
80 | + } |
|
78 | 81 | return parent::compile($js,$view); |
79 | 82 | } |
80 | 83 |