phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
HtmlSemDoubleElement.php
Go to the documentation of this file.
1 <?php
3 
10 use Ajax\JsUtils;
16 
24  use BaseTrait;
25 
26  protected $_popup = NULL;
27 
28  protected $_dimmer = NULL;
29 
30  protected $_toast = NULL;
31 
32  protected $_sidebar = NULL;
33 
34  protected $_params = array();
35 
36  public function __construct($identifier, $tagName = "p", $baseClass = "ui", $content = NULL) {
37  parent::__construct($identifier, $tagName);
38  $this->_baseClass = $baseClass;
39  $this->setClass($baseClass);
40  if (isset($content)) {
41  $this->content = $content;
42  }
43  }
44 
51  public function setPopupAttributes($variation = NULL, $popupEvent = NULL) {
52  if (isset($this->_popup))
53  $this->_popup->setAttributes($variation, $popupEvent);
54  }
55 
65  public function addPopup($title = "", $content = "", $variation = NULL, $params = array()) {
66  $this->_popup = new InternalPopup($this, $title, $content, $variation, $params);
67  return $this;
68  }
69 
78  public function addPopupHtml($html = "", $variation = NULL, $params = array()) {
79  $this->_popup = new InternalPopup($this);
80  $this->_popup->setHtml($html);
81  $this->_popup->setAttributes($variation, $params);
82  return $this;
83  }
84 
92  public function addDimmer($params = array(), $content = NULL) {
93  $dimmer = new HtmlDimmer("dimmer-" . $this->identifier, $content);
94  $dimmer->setParams($params);
95  $dimmer->setContainer($this);
96  $this->addContent($dimmer);
97  return $dimmer;
98  }
99 
108  public function addLabel($label, $before = false, $icon = NULL) {
109  $labelO = $label;
110  if (\is_object($label) === false) {
111  $labelO = new HtmlLabel("label-" . $this->identifier, $label);
112  if (isset($icon))
113  $labelO->addIcon($icon);
114  } else {
115  $labelO->addToPropertyCtrl("class", "label", array(
116  "label"
117  ));
118  }
119  $this->addContent($labelO, $before);
120  return $labelO;
121  }
122 
132  public function attachLabel($label, $side = Side::TOP, $direction = Direction::NONE, $icon = NULL) {
133  $label = $this->addLabel($label, true, $icon);
134  $label->setAttached($side, $direction);
135  return $this;
136  }
137 
143  public function asLink($href = NULL, $target = NULL) {
144  if (isset($href))
145  $this->setProperty("href", $href);
146  if (isset($target))
147  $this->setProperty("target", $target);
148  return $this->setTagName("a");
149  }
150 
157  public function jsShowDimmer($show = true) {
158  $status = "hide";
159  if ($show === true)
160  $status = "show";
161  return '$("#.' . $this->identifier . ').dimmer("' . $status . '");';
162  }
163 
169  public function compile(JsUtils $js = NULL, &$view = NULL) {
170  if (isset($this->_popup)) {
171  $this->_popup->compile($js);
172  }
173  return parent::compile($js, $view);
174  }
175 
181  public function run(JsUtils $js) {
182  $this->_bsComponent = $js->semantic()->generic("#" . $this->identifier);
183  parent::run($js);
184  $this->addEventsOnRun($js);
185  if (isset($this->_popup)) {
186  $this->_popup->run($js);
187  }
188  if (isset($this->_toast)) {
189  $this->_toast->setJs($js);
190  }
191  return $this->_bsComponent;
192  }
193 
200  public function addList($items, $ordered = false) {
201  $list = new HtmlList("list-" . $this->identifier, $items);
202  $list->setOrdered($ordered);
203  $list->setClass("ui list");
204  $this->addContent($list);
205  return $list;
206  }
207 
213  public function asToast($params = NULL) {
214  $this->_toast = new Toast();
215  $this->_toast->attach('#' . $this->_identifier);
216  $this->setProperty('style', 'display:none;');
217  if (isset($params)) {
218  $this->_toast->setParams($params);
219  }
220  $this->_toast->setParam('onShow', '$(".toast-box *").show();');
221  return $this->_toast;
222  }
223 
229  public function asSideBar($classes = '') {
230  $this->_sidebar = new Sidebar();
231  $this->addToProperty('class', 'sidebar');
232  return $this->_sidebar;
233  }
234 
235  /*
236  * public function __call($name, $arguments){
237  * $type=\substr($name, 0,3);
238  * $name=\strtolower(\substr($name, 3));
239  * $names=\array_merge($this->_variations,$this->_states);
240  * $argument=@$arguments[0];
241  * if(\array_search($name, $names)!==FALSE){
242  * switch ($type){
243  * case "set":
244  * if($argument===false){
245  * $this->removePropertyValue("class", $name);
246  * }else {
247  * $this->setProperty("class", $this->_baseClass." ".$name);
248  * }
249  * break;
250  * case "add":
251  * $this->addToPropertyCtrl("class", $name,array($name));
252  * break;
253  * default:
254  * throw new \Exception("Méthode ".$type.$name." inexistante.");
255  * }
256  * }else{
257  * throw new \Exception("Propriété ".$name." inexistante.");
258  * }
259  * return $this;
260  * }
261  */
262 }
addDimmer($params=array(), $content=NULL)
Adds a Dimmer to the element.
addToProperty($name, $value, $separator=" ")
jsShowDimmer($show=true)
Returns the script displaying the dimmer.
Ajax$Sidebar This class is part of phpMv-ui.
Definition: Sidebar.php:15
addPopupHtml($html="", $variation=NULL, $params=array())
Adds an html popup to the element.
Semantic Label component.
Definition: HtmlLabel.php:20
addContent($content, $before=false)
addEventsOnRun(JsUtils $js=NULL)
asLink($href=NULL, $target=NULL)
Transforms the element into a link.
addPopup($title="", $content="", $variation=NULL, $params=array())
Adds a popup to the element.
attachLabel($label, $side=Side::TOP, $direction=Direction::NONE, $icon=NULL)
Adds an attached label to the element.
addLabel($label, $before=false, $icon=NULL)
Adds a label to the element.
semantic(Semantic $semantic=NULL)
getter or setter of the Semantic-UI variable
Definition: JsUtils.php:159
Base class for Semantic double elements.
JQuery PHP library.
Definition: JsUtils.php:23
__construct($identifier, $tagName="p", $baseClass="ui", $content=NULL)
Ajax$Toast This class is part of phpMv-ui.
Definition: Toast.php:15
Html list (ul or ol)
Definition: HtmlList.php:12
setPopupAttributes($variation=NULL, $popupEvent=NULL)
Defines the popup attributes.