phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
HtmlDropdownItem.php
Go to the documentation of this file.
1 <?php
2 
4 
13 
16  public function __construct($identifier, $content="",$value=NULL,$image=NULL,$description=NULL) {
17  parent::__construct($identifier, "a");
18  $this->setClass("item");
19  $this->setContent($content);
20  if($value!==NULL)
21  $this->setData($value);
22  if($image!==NULL)
23  $this->asMiniAvatar($image);
24  if($description!==NULL)
25  $this->setDescription($description);
26  }
27 
28  public function setDescription($description){
29  $descO=new HtmlDoubleElement("desc-".$this->identifier,"span");
30  $descO->setClass("description");
31  $descO->setContent($description);
32  return $this->addContent($descO,true);
33  }
34 
35  public function setData($value){
36  $this->setProperty("data-value", $value);
37  return $this;
38  }
39 
40  public function asOption(){
41  $this->tagName="option";
42  if($this->getProperty("data-value")!==null)
43  $this->setProperty("value", $this->getProperty("data-value"));
44  }
45 
50  public function asMiniAvatar($image){
51  $this->tagName="div";
52  $img=new HtmlImg("image-".$this->identifier,$image);
53  $img->setClass("ui mini avatar image");
54  $this->addContent($img,true);
55  return $this;
56  }
57 
63  public function asIcon($caption,$icon){
64  $this->setContent($caption);
65  $this->addContent(new HtmlIcon("", $icon),true);
66  return $this;
67  }
68 
74  public function asCircularLabel($caption,$color){
75  $this->setContent($caption);
76  $lbl=new HtmlLabel("");
77  $lbl->setCircular()->setColor($color)->setEmpty();
78  $this->addContent($lbl,true);
79  return $this;
80  }
81 
82 
83 
84  public function addMenuItem($items) {
85  $menu=new HtmlMenu("menu-" . $this->identifier, $items);
87  $this->setTagName("div");
88  $this->setProperty("class", "item");
89  $icon=new HtmlIcon("", "dropdown");
90  $this->content=[$icon,new HtmlSemDoubleElement("","span","text",$content),$menu];
91  return $menu;
92  }
93 
99  public static function searchInput($placeholder=NULL,$icon=NULL){
100  return (new HtmlDropdownItem(""))->asSearchInput($placeholder,$icon);
101  }
102 
106  public static function divider(){
107  return (new HtmlDropdownItem(""))->asDivider();
108  }
109 
115  public static function header($caption=NULL,$icon=NULL){
116  return (new HtmlDropdownItem(""))->asHeader($caption,$icon);
117  }
118 
124  public static function circular($caption,$color){
125  return (new HtmlDropdownItem(""))->asCircularLabel($caption,$color);
126  }
127 
133  public static function icon($caption,$icon){
134  return (new HtmlDropdownItem(""))->asIcon($caption,$icon);
135  }
136 
142  public static function avatar($caption,$image){
143  $dd=new HtmlDropdownItem("",$caption);
144  $dd->asMiniAvatar($image);
145  return $dd;
146  }
147 }
asCircularLabel($caption, $color)
Adds a circular label to the item.
static searchInput($placeholder=NULL, $icon=NULL)
Semantic Label component.
Definition: HtmlLabel.php:20
addContent($content, $before=false)
Semantic Icon component.
Definition: HtmlIcon.php:14
static header($caption=NULL, $icon=NULL)
Base class for Semantic double elements.
__construct($identifier, $content="", $value=NULL, $image=NULL, $description=NULL)