@@ -14,89 +14,89 @@ |
||
14 | 14 | */ |
15 | 15 | class HtmlGridRow extends HtmlBsDoubleElement { |
16 | 16 | private $cols; |
17 | - public function __construct($identifier,$numCols=NULL){ |
|
18 | - parent::__construct($identifier,"div"); |
|
17 | + public function __construct($identifier, $numCols=NULL) { |
|
18 | + parent::__construct($identifier, "div"); |
|
19 | 19 | $this->setProperty("class", "row"); |
20 | 20 | $this->cols=array(); |
21 | - if(isset($numCols)){ |
|
22 | - $numCols=min(12,$numCols); |
|
23 | - $numCols=max(1,$numCols); |
|
21 | + if (isset($numCols)) { |
|
22 | + $numCols=min(12, $numCols); |
|
23 | + $numCols=max(1, $numCols); |
|
24 | 24 | $width=12/$numCols; |
25 | - for ($i=0;$i<$numCols;$i++){ |
|
26 | - $this->addCol(CssSize::SIZE_MD,$width); |
|
25 | + for ($i=0; $i<$numCols; $i++) { |
|
26 | + $this->addCol(CssSize::SIZE_MD, $width); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | - public function addCol($size=CssSize::SIZE_MD,$width=1){ |
|
32 | - $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1),$size,$width); |
|
31 | + public function addCol($size=CssSize::SIZE_MD, $width=1) { |
|
32 | + $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1), $size, $width); |
|
33 | 33 | $this->cols[]=$col; |
34 | 34 | return $col; |
35 | 35 | } |
36 | 36 | |
37 | - public function addColAt($size=CssSize::SIZE_MD,$width=1,$offset=1){ |
|
38 | - $col=$this->addCol($size,$width); |
|
39 | - return $col->setOffset($size, max($offset,sizeof($this->cols)+1)); |
|
37 | + public function addColAt($size=CssSize::SIZE_MD, $width=1, $offset=1) { |
|
38 | + $col=$this->addCol($size, $width); |
|
39 | + return $col->setOffset($size, max($offset, sizeof($this->cols)+1)); |
|
40 | 40 | } |
41 | 41 | |
42 | - public function getCol($index,$force=true){ |
|
42 | + public function getCol($index, $force=true) { |
|
43 | 43 | $result=null; |
44 | - if($index<sizeof($this->cols)+1){ |
|
44 | + if ($index<sizeof($this->cols)+1) { |
|
45 | 45 | $result=$this->cols[$index-1]; |
46 | - }else if ($force){ |
|
47 | - $result=$this->addColAt(CssSize::SIZE_MD,1,$index); |
|
46 | + } else if ($force) { |
|
47 | + $result=$this->addColAt(CssSize::SIZE_MD, 1, $index); |
|
48 | 48 | } |
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | - public function getColAt($offset,$force=true){ |
|
52 | + public function getColAt($offset, $force=true) { |
|
53 | 53 | $result=null; |
54 | - foreach ($this->cols as $col){ |
|
54 | + foreach ($this->cols as $col) { |
|
55 | 55 | $offsets=$col->getOffsets(); |
56 | - if($result=array_search($offset, $offsets)){ |
|
56 | + if ($result=array_search($offset, $offsets)) { |
|
57 | 57 | break; |
58 | 58 | } |
59 | 59 | } |
60 | - if(!$result || isset($result)===false){ |
|
61 | - $result=$this->getCol($offset,$force); |
|
60 | + if (!$result || isset($result)===false) { |
|
61 | + $result=$this->getCol($offset, $force); |
|
62 | 62 | } |
63 | 63 | return $result; |
64 | 64 | } |
65 | 65 | |
66 | 66 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
67 | 67 | |
68 | - foreach ($this->cols as $col){ |
|
68 | + foreach ($this->cols as $col) { |
|
69 | 69 | $this->addContent($col); |
70 | 70 | } |
71 | - return parent::compile($js,$view); |
|
71 | + return parent::compile($js, $view); |
|
72 | 72 | } |
73 | 73 | public function getCols() { |
74 | 74 | return $this->cols; |
75 | 75 | } |
76 | 76 | |
77 | - public function setContentForAll($content){ |
|
78 | - foreach ($this->cols as $col){ |
|
77 | + public function setContentForAll($content) { |
|
78 | + foreach ($this->cols as $col) { |
|
79 | 79 | $col->setContent($content); |
80 | 80 | } |
81 | 81 | } |
82 | - public function merge($size=CssSize::SIZE_MD,$start,$width){ |
|
83 | - $col=$this->getColAt($start,false); |
|
84 | - if(isset($col)){ |
|
85 | - $col->setWidth($size,$width+1); |
|
86 | - $this->delete($size,$start+1, $width); |
|
82 | + public function merge($size=CssSize::SIZE_MD, $start, $width) { |
|
83 | + $col=$this->getColAt($start, false); |
|
84 | + if (isset($col)) { |
|
85 | + $col->setWidth($size, $width+1); |
|
86 | + $this->delete($size, $start+1, $width); |
|
87 | 87 | } |
88 | 88 | } |
89 | - public function delete($size=CssSize::SIZE_MD,$start,$width){ |
|
90 | - while($start<sizeof($this->cols)+1 && $width>0){ |
|
91 | - $col=$this->getColAt($start,false); |
|
92 | - if(isset($col)){ |
|
89 | + public function delete($size=CssSize::SIZE_MD, $start, $width) { |
|
90 | + while ($start<sizeof($this->cols)+1 && $width>0) { |
|
91 | + $col=$this->getColAt($start, false); |
|
92 | + if (isset($col)) { |
|
93 | 93 | $widthCol=$col->getWidth($size); |
94 | - if($widthCol<=$width){ |
|
94 | + if ($widthCol<=$width) { |
|
95 | 95 | unset($this->cols[$start-1]); |
96 | - $this->cols = array_values($this->cols); |
|
96 | + $this->cols=array_values($this->cols); |
|
97 | 97 | $width=$width-$widthCol; |
98 | 98 | } |
99 | - }else{ |
|
99 | + } else { |
|
100 | 100 | $width=0; |
101 | 101 | } |
102 | 102 | } |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | public function setContent($content) { |
21 | - $this->content=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
21 | + $this->content=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
22 | 22 | return $this; |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function asIcon($icon, $title, $subHeader=NULL) { |
26 | - $header=new HtmlHeader("header-" . $this->identifier); |
|
26 | + $header=new HtmlHeader("header-".$this->identifier); |
|
27 | 27 | $header->asIcon($icon, $title, $subHeader); |
28 | - if ($this->_inverted === false) |
|
28 | + if ($this->_inverted===false) |
|
29 | 29 | $header->setInverted(); |
30 | 30 | return $this->setContent($header); |
31 | 31 | } |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | |
43 | 43 | public function run(JsUtils $js) { |
44 | 44 | if ($this->_container instanceof HtmlSingleElement) |
45 | - $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
45 | + $this->_bsComponent=$js->semantic()->dimmer("#".$this->_container->getIdentifier(), $this->_params); |
|
46 | 46 | return parent::run($js); |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function jsShow() { |
50 | 50 | if (isset($this->_container)) |
51 | - return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
51 | + return '$("#.'.$this->_container->getIdentifier().').dimmer("show");'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function setBlurring() { |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | use Ajax\semantic\html\base\constants\Direction; |
9 | 9 | |
10 | 10 | class HtmlSearch extends HtmlSemDoubleElement { |
11 | - private $_elements=array (); |
|
12 | - private $_searchFields=array ("title" ); |
|
11 | + private $_elements=array(); |
|
12 | + private $_searchFields=array("title"); |
|
13 | 13 | private $_local=false; |
14 | 14 | |
15 | 15 | public function __construct($identifier, $placeholder=NULL, $icon=NULL) { |
16 | - parent::__construct("search-" . $identifier, "div", "ui search", array ()); |
|
16 | + parent::__construct("search-".$identifier, "div", "ui search", array()); |
|
17 | 17 | $this->createField($placeholder, $icon); |
18 | 18 | $this->createResult(); |
19 | 19 | $this->_params["type"]="standard"; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | private function createResult() { |
35 | - $this->content["result"]=new HtmlSemDoubleElement("results-" . $this->identifier, "div", "results"); |
|
35 | + $this->content["result"]=new HtmlSemDoubleElement("results-".$this->identifier, "div", "results"); |
|
36 | 36 | return $this->content["result"]; |
37 | 37 | } |
38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | public function setUrl($url) { |
52 | - $this->_params["apiSettings"]="%{url: %quote%" . $url . "%quote%}%"; |
|
52 | + $this->_params["apiSettings"]="%{url: %quote%".$url."%quote%}%"; |
|
53 | 53 | return $this; |
54 | 54 | } |
55 | 55 | |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | public function run(JsUtils $js) { |
75 | - $this->_params["onSelect"]='%function(result,response){$(%quote%#' . $this->identifier . '%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
75 | + $this->_params["onSelect"]='%function(result,response){$(%quote%#'.$this->identifier.'%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
76 | 76 | $searchFields=\json_encode($this->_searchFields); |
77 | 77 | $searchFields=str_ireplace("\"", "%quote%", $searchFields); |
78 | - $this->_params["searchFields"]="%" . $searchFields . "%"; |
|
79 | - if ($this->_local === true) { |
|
78 | + $this->_params["searchFields"]="%".$searchFields."%"; |
|
79 | + if ($this->_local===true) { |
|
80 | 80 | $this->_params["source"]="%content%"; |
81 | - $this->addEvent("beforeExecute", "var content=" . $this->resultsToJson() . ";"); |
|
81 | + $this->addEvent("beforeExecute", "var content=".$this->resultsToJson().";"); |
|
82 | 82 | } |
83 | - if (isset($this->_bsComponent) === false) { |
|
84 | - $this->_bsComponent=$js->semantic()->search("#" . $this->identifier, $this->_params); |
|
83 | + if (isset($this->_bsComponent)===false) { |
|
84 | + $this->_bsComponent=$js->semantic()->search("#".$this->identifier, $this->_params); |
|
85 | 85 | } |
86 | 86 | $this->addEventsOnRun($js); |
87 | 87 | return $this->_bsComponent; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | trait JqueryEventsTrait { |
13 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
13 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Blur |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function _click($element='this', $js=array(), $ret_false=TRUE) { |
54 | 54 | if (!is_array($js)) { |
55 | - $js=array ( |
|
55 | + $js=array( |
|
56 | 56 | $js |
57 | 57 | ); |
58 | 58 | } |
@@ -15,18 +15,18 @@ discard block |
||
15 | 15 | private $_hasIcon=false; |
16 | 16 | |
17 | 17 | abstract protected function addToPropertyCtrl($name, $value, $typeCtrl); |
18 | - abstract public function addContent($content,$before=false); |
|
18 | + abstract public function addContent($content, $before=false); |
|
19 | 19 | |
20 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
21 | - if($this->_hasIcon===false){ |
|
20 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
21 | + if ($this->_hasIcon===false) { |
|
22 | 22 | $iconO=$icon; |
23 | - if(\is_string($icon)){ |
|
23 | + if (\is_string($icon)) { |
|
24 | 24 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
25 | 25 | } |
26 | 26 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
27 | - $this->addContent($iconO,$direction===Direction::LEFT); |
|
27 | + $this->addContent($iconO, $direction===Direction::LEFT); |
|
28 | 28 | $this->_hasIcon=true; |
29 | - }else{ |
|
29 | + } else { |
|
30 | 30 | $iconO=$this->getIcon(); |
31 | 31 | $iconO->setIcon($icon); |
32 | 32 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | return $iconO; |
35 | 35 | } |
36 | 36 | |
37 | - public function getIcon(){ |
|
38 | - if(\is_array($this->content)){ |
|
39 | - foreach ($this->content as $item){ |
|
40 | - if($item instanceof HtmlIcon) |
|
37 | + public function getIcon() { |
|
38 | + if (\is_array($this->content)) { |
|
39 | + foreach ($this->content as $item) { |
|
40 | + if ($item instanceof HtmlIcon) |
|
41 | 41 | return $item; |
42 | 42 | } |
43 | 43 | } |
@@ -15,46 +15,46 @@ discard block |
||
15 | 15 | * @property string $identifier |
16 | 16 | */ |
17 | 17 | trait FieldsTrait { |
18 | - abstract public function addFields($fields=NULL,$label=NULL); |
|
18 | + abstract public function addFields($fields=NULL, $label=NULL); |
|
19 | 19 | abstract public function addItem($item); |
20 | 20 | |
21 | - protected function createItem($value){ |
|
22 | - if(\is_array($value)){ |
|
23 | - $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))); |
|
21 | + protected function createItem($value) { |
|
22 | + if (\is_array($value)) { |
|
23 | + $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))); |
|
24 | 24 | return $itemO; |
25 | - }elseif(\is_object($value)){ |
|
25 | + }elseif (\is_object($value)) { |
|
26 | 26 | $itemO=new HtmlFormField("field-".$this->identifier, $value); |
27 | 27 | return $itemO; |
28 | - }else |
|
28 | + } else |
|
29 | 29 | return new HtmlFormInput($value); |
30 | 30 | } |
31 | 31 | |
32 | - protected function createCondition($value){ |
|
32 | + protected function createCondition($value) { |
|
33 | 33 | return \is_object($value)===false || $value instanceof \Ajax\semantic\html\elements\HtmlInput; |
34 | 34 | } |
35 | 35 | |
36 | - public function addInputs($inputs,$fieldslabel=null){ |
|
36 | + public function addInputs($inputs, $fieldslabel=null) { |
|
37 | 37 | $fields=array(); |
38 | - foreach ($inputs as $input){ |
|
38 | + foreach ($inputs as $input) { |
|
39 | 39 | \extract($input); |
40 | - $f=new HtmlFormInput("",""); |
|
40 | + $f=new HtmlFormInput("", ""); |
|
41 | 41 | $f->fromArray($input); |
42 | 42 | $fields[]=$f; |
43 | 43 | } |
44 | - return $this->addFields($fields,$fieldslabel); |
|
44 | + return $this->addFields($fields, $fieldslabel); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function addFieldRule($index,$type,$prompt=NULL,$value=NULL){ |
|
47 | + public function addFieldRule($index, $type, $prompt=NULL, $value=NULL) { |
|
48 | 48 | $field=$this->getItem($index); |
49 | - if(isset($field)){ |
|
50 | - $field->addRule($type,$prompt,$value); |
|
49 | + if (isset($field)) { |
|
50 | + $field->addRule($type, $prompt, $value); |
|
51 | 51 | } |
52 | 52 | return $this; |
53 | 53 | } |
54 | 54 | |
55 | - public function addFieldRules($index,$rules){ |
|
55 | + public function addFieldRules($index, $rules) { |
|
56 | 56 | $field=$this->getItem($index); |
57 | - if(isset($field)){ |
|
57 | + if (isset($field)) { |
|
58 | 58 | $field->addRules($rules); |
59 | 59 | } |
60 | 60 | return $this; |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @param boolean $multiple |
69 | 69 | * @return \Ajax\common\html\HtmlDoubleElement |
70 | 70 | */ |
71 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
72 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
71 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
72 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -80,23 +80,23 @@ discard block |
||
80 | 80 | * @param string $placeholder |
81 | 81 | * @return HtmlFormInput |
82 | 82 | */ |
83 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
84 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
83 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
84 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
85 | 85 | } |
86 | 86 | |
87 | - public function addPassword($identifier, $label=NULL){ |
|
88 | - return $this->addItem(new HtmlFormInput($identifier,$label,"password","","")); |
|
87 | + public function addPassword($identifier, $label=NULL) { |
|
88 | + return $this->addItem(new HtmlFormInput($identifier, $label, "password", "", "")); |
|
89 | 89 | } |
90 | 90 | |
91 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
92 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
91 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
92 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
93 | 93 | } |
94 | 94 | |
95 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
96 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
95 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
96 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
97 | 97 | } |
98 | 98 | |
99 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
100 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
99 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
100 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | \ No newline at end of file |
@@ -25,7 +25,7 @@ |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | public function setDisabled($disable=true) { |
28 | - if($disable) |
|
28 | + if ($disable) |
|
29 | 29 | $this->addState(State::DISABLED); |
30 | 30 | return $this; |
31 | 31 | } |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | protected $image; |
10 | 10 | |
11 | 11 | public function __construct($identifier, $content=NULL) { |
12 | - parent::__construct($identifier,"item",$content); |
|
12 | + parent::__construct($identifier, "item", $content); |
|
13 | 13 | } |
14 | - protected function initContent($content){ |
|
15 | - if(\is_array($content)){ |
|
16 | - if(JArray::isAssociative($content)===false){ |
|
14 | + protected function initContent($content) { |
|
15 | + if (\is_array($content)) { |
|
16 | + if (JArray::isAssociative($content)===false) { |
|
17 | 17 | $icon=@$content[0]; |
18 | 18 | $title=@$content[1]; |
19 | 19 | $desc=@$content[2]; |
20 | - }else{ |
|
20 | + } else { |
|
21 | 21 | $icon=@$content["icon"]; |
22 | 22 | $image=@$content["image"]; |
23 | 23 | $title=@$content["title"]; |
@@ -25,21 +25,21 @@ discard block |
||
25 | 25 | $desc=@$content["description"]; |
26 | 26 | $items=@$content["items"]; |
27 | 27 | } |
28 | - if(isset($icon)){ |
|
28 | + if (isset($icon)) { |
|
29 | 29 | $this->setIcon($icon); |
30 | 30 | } |
31 | - if(isset($image)){ |
|
31 | + if (isset($image)) { |
|
32 | 32 | $this->setImage($image); |
33 | 33 | } |
34 | - if(isset($title)){ |
|
35 | - $this->setTitle($title,$desc); |
|
36 | - }elseif (isset($header)){ |
|
37 | - $this->setTitle($header,$desc,"header"); |
|
34 | + if (isset($title)) { |
|
35 | + $this->setTitle($title, $desc); |
|
36 | + }elseif (isset($header)) { |
|
37 | + $this->setTitle($header, $desc, "header"); |
|
38 | 38 | } |
39 | - if(isset($items)){ |
|
39 | + if (isset($items)) { |
|
40 | 40 | $this->addList($items); |
41 | 41 | } |
42 | - }else{ |
|
42 | + } else { |
|
43 | 43 | $this->setContent($content); |
44 | 44 | } |
45 | 45 | } |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | return $list; |
51 | 51 | } |
52 | 52 | |
53 | - public function getList(){ |
|
53 | + public function getList() { |
|
54 | 54 | return $this->content["list"]; |
55 | 55 | } |
56 | 56 | |
57 | - public function getItem($index){ |
|
57 | + public function getItem($index) { |
|
58 | 58 | return $this->getList()->getItem($index); |
59 | 59 | } |
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -13,53 +13,53 @@ 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"); |
|
21 | + protected $items=array(); |
|
22 | + protected $_params=array("action"=>"nothing", "on"=>"hover"); |
|
23 | 23 | protected $input; |
24 | 24 | protected $value; |
25 | 25 | protected $_associative; |
26 | 26 | |
27 | - public function __construct($identifier, $value="", $items=array(),$associative=true) { |
|
27 | + public function __construct($identifier, $value="", $items=array(), $associative=true) { |
|
28 | 28 | parent::__construct($identifier, "div"); |
29 | 29 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
30 | 30 | $this->setProperty("class", "ui dropdown"); |
31 | - $content=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
31 | + $content=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
32 | 32 | $content->setClass("text"); |
33 | 33 | $this->setValue($value); |
34 | - $content->wrap("",new HtmlIcon("", "dropdown")); |
|
34 | + $content->wrap("", new HtmlIcon("", "dropdown")); |
|
35 | 35 | $this->content=array($content); |
36 | 36 | $this->tagName="div"; |
37 | 37 | $this->_associative=$associative; |
38 | 38 | $this->addItems($items); |
39 | 39 | } |
40 | 40 | |
41 | - public function getField(){ |
|
41 | + public function getField() { |
|
42 | 42 | return $this->input; |
43 | 43 | } |
44 | 44 | |
45 | - public function getDataField(){ |
|
45 | + public function getDataField() { |
|
46 | 46 | return $this->input; |
47 | 47 | } |
48 | 48 | |
49 | - public function addItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
50 | - $itemO=$this->beforeAddItem($item,$value,$image,$description); |
|
49 | + public function addItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
50 | + $itemO=$this->beforeAddItem($item, $value, $image, $description); |
|
51 | 51 | $this->items[]=$itemO; |
52 | 52 | return $itemO; |
53 | 53 | } |
54 | 54 | |
55 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
56 | - $this->addIconP($icon,$before,$labeled); |
|
55 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
56 | + $this->addIconP($icon, $before, $labeled); |
|
57 | 57 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
58 | 58 | } |
59 | 59 | |
60 | - public function addIcons($icons){ |
|
60 | + public function addIcons($icons) { |
|
61 | 61 | $count=$this->count(); |
62 | - for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){ |
|
62 | + for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) { |
|
63 | 63 | $this->getItem($i)->addIcon($icons[$i]); |
64 | 64 | } |
65 | 65 | } |
@@ -70,26 +70,26 @@ discard block |
||
70 | 70 | * @param number $position |
71 | 71 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
72 | 72 | */ |
73 | - public function insertItem($item,$position=0){ |
|
73 | + public function insertItem($item, $position=0) { |
|
74 | 74 | $itemO=$this->beforeAddItem($item); |
75 | - $start = array_slice($this->items, 0, $position); |
|
76 | - $end = array_slice($this->items, $position); |
|
77 | - $start[] = $item; |
|
75 | + $start=array_slice($this->items, 0, $position); |
|
76 | + $end=array_slice($this->items, $position); |
|
77 | + $start[]=$item; |
|
78 | 78 | $this->items=array_merge($start, $end); |
79 | 79 | return $itemO; |
80 | 80 | } |
81 | 81 | |
82 | - protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
82 | + protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
83 | 83 | $itemO=$item; |
84 | - if(\is_array($item)){ |
|
84 | + if (\is_array($item)) { |
|
85 | 85 | $description=JArray::getValue($item, "description", 3); |
86 | 86 | $value=JArray::getValue($item, "value", 1); |
87 | 87 | $image=JArray::getValue($item, "image", 2); |
88 | 88 | $item=JArray::getValue($item, "item", 0); |
89 | 89 | } |
90 | - if(!$item instanceof HtmlDropdownItem){ |
|
91 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
|
92 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
90 | + if (!$item instanceof HtmlDropdownItem) { |
|
91 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description); |
|
92 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
93 | 93 | $this->addToProperty("class", "vertical"); |
94 | 94 | } |
95 | 95 | return $itemO; |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | $this->addItem($function($object)); |
103 | 103 | } |
104 | 104 | |
105 | - public function addInput($name){ |
|
106 | - if(!isset($name)) |
|
105 | + public function addInput($name) { |
|
106 | + if (!isset($name)) |
|
107 | 107 | $name="input-".$this->identifier; |
108 | 108 | $this->setAction("activate"); |
109 | - $this->input=new HtmlInput($name,"hidden"); |
|
109 | + $this->input=new HtmlInput($name, "hidden"); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | * @param string $icon |
116 | 116 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
117 | 117 | */ |
118 | - public function addSearchInputItem($placeHolder=NULL,$icon=NULL){ |
|
119 | - return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon)); |
|
118 | + public function addSearchInputItem($placeHolder=NULL, $icon=NULL) { |
|
119 | + return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon)); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Adds a divider item |
124 | 124 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
125 | 125 | */ |
126 | - public function addDividerItem(){ |
|
126 | + public function addDividerItem() { |
|
127 | 127 | return $this->addItem(HtmlDropdownItem::divider()); |
128 | 128 | } |
129 | 129 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @param string $icon |
134 | 134 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
135 | 135 | */ |
136 | - public function addHeaderItem($caption=NULL,$icon=NULL){ |
|
137 | - return $this->addItem(HtmlDropdownItem::header($caption,$icon)); |
|
136 | + public function addHeaderItem($caption=NULL, $icon=NULL) { |
|
137 | + return $this->addItem(HtmlDropdownItem::header($caption, $icon)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param string $color |
144 | 144 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
145 | 145 | */ |
146 | - public function addCircularLabelItem($caption,$color){ |
|
146 | + public function addCircularLabelItem($caption, $color) { |
|
147 | 147 | return $this->addItem(HtmlDropdownItem::circular($caption, $color)); |
148 | 148 | } |
149 | 149 | |
@@ -152,87 +152,87 @@ discard block |
||
152 | 152 | * @param string $image |
153 | 153 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
154 | 154 | */ |
155 | - public function addMiniAvatarImageItem($caption,$image){ |
|
155 | + public function addMiniAvatarImageItem($caption, $image) { |
|
156 | 156 | return $this->addItem(HtmlDropdownItem::avatar($caption, $image)); |
157 | 157 | } |
158 | 158 | |
159 | - public function addItems($items){ |
|
160 | - if(\is_array($items) && $this->_associative){ |
|
161 | - foreach ($items as $k=>$v){ |
|
159 | + public function addItems($items) { |
|
160 | + if (\is_array($items) && $this->_associative) { |
|
161 | + foreach ($items as $k=>$v) { |
|
162 | 162 | $this->addItem($v)->setData($k); |
163 | 163 | } |
164 | - }else{ |
|
165 | - foreach ($items as $item){ |
|
164 | + } else { |
|
165 | + foreach ($items as $item) { |
|
166 | 166 | $this->addItem($item); |
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | - public function getItem($index){ |
|
171 | + public function getItem($index) { |
|
172 | 172 | return $this->items[$index]; |
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | 176 | * @return int |
177 | 177 | */ |
178 | - public function count(){ |
|
178 | + public function count() { |
|
179 | 179 | return \sizeof($this->items); |
180 | 180 | } |
181 | 181 | /** |
182 | 182 | * @param boolean $dropdown |
183 | 183 | */ |
184 | - public function asDropdown($dropdown){ |
|
185 | - if($dropdown===false){ |
|
184 | + public function asDropdown($dropdown) { |
|
185 | + if ($dropdown===false) { |
|
186 | 186 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
187 | 187 | $dropdown="menu"; |
188 | - }else{ |
|
188 | + } else { |
|
189 | 189 | $dropdown="dropdown"; |
190 | 190 | $this->mClass="menu"; |
191 | 191 | } |
192 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
192 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
193 | 193 | } |
194 | 194 | |
195 | - public function setVertical(){ |
|
196 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
195 | + public function setVertical() { |
|
196 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
197 | 197 | } |
198 | 198 | |
199 | - public function setInline(){ |
|
200 | - return $this->addToPropertyCtrl("class", "inline",["inline"]); |
|
199 | + public function setInline() { |
|
200 | + return $this->addToPropertyCtrl("class", "inline", ["inline"]); |
|
201 | 201 | } |
202 | 202 | |
203 | - public function setSimple(){ |
|
204 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
203 | + public function setSimple() { |
|
204 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
205 | 205 | } |
206 | 206 | |
207 | - public function asButton($floating=false){ |
|
208 | - if($floating) |
|
207 | + public function asButton($floating=false) { |
|
208 | + if ($floating) |
|
209 | 209 | $this->addToProperty("class", "floating"); |
210 | 210 | $this->removePropertyValue("class", "selection"); |
211 | 211 | return $this->addToProperty("class", "button"); |
212 | 212 | } |
213 | 213 | |
214 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
215 | - if(isset($name)) |
|
214 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
215 | + if (isset($name)) |
|
216 | 216 | $this->addInput($name); |
217 | - if($multiple) |
|
217 | + if ($multiple) |
|
218 | 218 | $this->addToProperty("class", "multiple"); |
219 | - if ($selection){ |
|
220 | - if($this->propertyContains("class", "button")===false) |
|
221 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
219 | + if ($selection) { |
|
220 | + if ($this->propertyContains("class", "button")===false) |
|
221 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
222 | 222 | } |
223 | 223 | return $this; |
224 | 224 | } |
225 | 225 | |
226 | - public function asSearch($name=NULL,$multiple=false,$selection=true){ |
|
227 | - $this->asSelect($name,$multiple,$selection); |
|
226 | + public function asSearch($name=NULL, $multiple=false, $selection=true) { |
|
227 | + $this->asSelect($name, $multiple, $selection); |
|
228 | 228 | return $this->addToProperty("class", "search"); |
229 | 229 | } |
230 | 230 | |
231 | - public function setSelect($name=NULL,$multiple=false){ |
|
232 | - if(!isset($name)) |
|
231 | + public function setSelect($name=NULL, $multiple=false) { |
|
232 | + if (!isset($name)) |
|
233 | 233 | $name="select-".$this->identifier; |
234 | 234 | $this->input=null; |
235 | - if($multiple){ |
|
235 | + if ($multiple) { |
|
236 | 236 | $this->setProperty("multiple", true); |
237 | 237 | $this->addToProperty("class", "multiple"); |
238 | 238 | } |
@@ -240,37 +240,37 @@ discard block |
||
240 | 240 | $this->tagName="select"; |
241 | 241 | $this->setProperty("name", $name); |
242 | 242 | $this->content=null; |
243 | - foreach ($this->items as $item){ |
|
243 | + foreach ($this->items as $item) { |
|
244 | 244 | $item->asOption(); |
245 | 245 | } |
246 | 246 | return $this; |
247 | 247 | } |
248 | 248 | |
249 | - public function asSubmenu($pointing=NULL){ |
|
249 | + public function asSubmenu($pointing=NULL) { |
|
250 | 250 | $this->setClass("ui dropdown link item"); |
251 | - if(isset($pointing)){ |
|
251 | + if (isset($pointing)) { |
|
252 | 252 | $this->setPointing($pointing); |
253 | 253 | } |
254 | 254 | return $this; |
255 | 255 | } |
256 | 256 | |
257 | - public function setPointing($value=Direction::NONE){ |
|
258 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
257 | + public function setPointing($value=Direction::NONE) { |
|
258 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
259 | 259 | } |
260 | 260 | |
261 | - public function setValue($value){ |
|
261 | + public function setValue($value) { |
|
262 | 262 | $this->value=$value; |
263 | 263 | return $this; |
264 | 264 | } |
265 | - private function applyValue(){ |
|
265 | + private function applyValue() { |
|
266 | 266 | $value=$this->value; |
267 | - if(isset($this->input) && isset($value)){ |
|
267 | + if (isset($this->input) && isset($value)) { |
|
268 | 268 | $this->input->setProperty("value", $value); |
269 | - }else{ |
|
269 | + } else { |
|
270 | 270 | $this->setProperty("value", $value); |
271 | 271 | } |
272 | 272 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
273 | - if(isset($textElement)) |
|
273 | + if (isset($textElement)) |
|
274 | 274 | $textElement->setContent($value); |
275 | 275 | return $this; |
276 | 276 | } |
@@ -280,29 +280,29 @@ discard block |
||
280 | 280 | * @see BaseHtml::run() |
281 | 281 | */ |
282 | 282 | public function run(JsUtils $js) { |
283 | - if($this->propertyContains("class", "simple")===false){ |
|
284 | - if(isset($this->_bsComponent)===false) |
|
285 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
283 | + if ($this->propertyContains("class", "simple")===false) { |
|
284 | + if (isset($this->_bsComponent)===false) |
|
285 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
286 | 286 | $this->addEventsOnRun($js); |
287 | 287 | return $this->_bsComponent; |
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
291 | - public function setCompact(){ |
|
291 | + public function setCompact() { |
|
292 | 292 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
293 | 293 | } |
294 | 294 | |
295 | - public function setAction($action){ |
|
295 | + public function setAction($action) { |
|
296 | 296 | $this->_params["action"]=$action; |
297 | 297 | } |
298 | 298 | |
299 | - public function setFullTextSearch($value){ |
|
299 | + public function setFullTextSearch($value) { |
|
300 | 300 | $this->_params["fullTextSearch"]=$value; |
301 | 301 | } |
302 | 302 | |
303 | 303 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
304 | 304 | $this->applyValue(); |
305 | - return parent::compile($js,$view); |
|
305 | + return parent::compile($js, $view); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | public function getInput() { |