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