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 
5 use Ajax\JsUtils;
11 
18  protected $_htmlDropdown;
19  protected $class;
20  protected $itemClass;
21  protected $href;
22  protected $role;
23  protected $itemRole;
24  protected $target;
25 
30  public function __construct($identifier) {
31  parent::__construct($identifier);
32  $this->class="";
33  $this->itemClass="";
34  $this->content="";
35  $this->href="#";
36  $this->role="menuitem";
37  $this->target="_self";
38  $this->_template='<li id="%identifier%" class="%class%" role="%role%"><a id="a-%identifier%" role="%itemRole%" class="%itemClass%" tabindex="-1" href="%href%" target="%target%">%content%</a></li>';
39  }
40 
41  public function setItemClass($itemClass) {
42  $this->itemClass=$itemClass;
43  return $this;
44  }
45 
46  public function setItemRole($itemRole) {
47  $this->itemRole=$itemRole;
48  return $this;
49  }
50 
56  public function setClass($value) {
57  $this->class=$value;
58  return $this;
59  }
60 
66  public function setCaption($value) {
67  if (JString::startswith($value, "-")) {
68  $this->class="dropdown-header";
69  $this->role="presentation";
70  $this->_template='<li id="%identifier%" class="%class%" role="%role%">%content%</li>';
71  if ($value==="-") {
72  $this->class="divider";
73  }
74  $value=substr($value, 1);
75  }
76  $this->content=$value;
77  return $this;
78  }
79 
80  public function disable() {
81  $this->role="presentation";
82  $this->class="disabled";
83  }
84 
85  public function active() {
86  $this->role="menuitem";
87  $this->class="active";
88  }
89 
95  public function setHref($value) {
96  $this->href=$value;
97  return $this;
98  }
99 
105  public function setRole($value) {
106  $this->role=$value;
107  return $this;
108  }
109 
110  public function isDivider() {
111  return $this->class==="divider";
112  }
113 
114  public function __toString() {
115  return $this->compile();
116  }
117 
123  public function fromArray($array) {
124  return parent::fromArray($array);
125  }
126 
127  public function run(JsUtils $js) {
128  $this->_bsComponent=$js->bootstrap()->generic("#".$this->identifier);
129  $this->addEventsOnRun($js);
130  return $this->_bsComponent;
131  }
132 
137  public function runNav(JsUtils $js) {
138  $js->bootstrap()->tab("#".$this->identifier);
139  }
140 
141  public function getHref() {
142  return $this->href;
143  }
144 
145  public function addBadge($caption, $leftSeparator="&nbsp;") {
146  $badge=new HtmlBadge("badge-".$this->identifier);
147  $badge->setContent($caption);
148  $this->content.=$leftSeparator.$badge->compile();
149  return $this;
150  }
151 
152  public function addGlyph($glyphicon, $left=true, $separator="&nbsp;") {
153  $glyph=new HtmlGlyphicon("glyph-".$this->identifier);
154  $glyph->setGlyphicon($glyphicon);
155  if ($left) {
156  $this->content=$glyph->compile().$separator.$this->content;
157  } else {
158  $this->content.=$separator.$glyph->compile();
159  }
160  return $this;
161  }
162 
163  public function getTarget() {
164  return $this->target;
165  }
166 
167  public function setTarget($target) {
168  $this->target=$target;
169  return $this;
170  }
171 }
addBadge($caption, $leftSeparator="&nbsp;")
Composant Twitter Bootstrap Glyphicon.
static startswith($hay, $needle)
Definition: JString.php:10
addEventsOnRun(JsUtils $js=NULL)
compile(JsUtils $js=NULL, &$view=NULL)
Definition: BaseHtml.php:208
addGlyph($glyphicon, $left=true, $separator="&nbsp;")
Inner element for Twitter Bootstrap HTML Dropdown component.
bootstrap(Bootstrap $bootstrap=NULL)
getter or setter of the Twitter Bootstrap variable
Definition: JsUtils.php:141
JQuery PHP library.
Definition: JsUtils.php:23
runNav(JsUtils $js)
Js component creation when dropdownItem is in Navs/Pills.
fromArray($array)
/* Initialise l&#39;objet à partir d&#39;un tableau associatif array("identifier"=>"id","caption"=>"","class"=>"","href"=>"","role"=>"")
setCaption($value)
Set the item caption.