phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlAbsractItem.php
Go to the documentation of this file.
1<?php
2
4
8
11
12abstract class HtmlAbsractItem extends HtmlSemDoubleElement {
13
14 public function __construct($identifier, $baseClass,$content=NULL) {
15 parent::__construct($identifier, "div", $baseClass);
16 $this->content=array();
17 $this->initContent($content);
18 }
19
20 abstract protected function initContent($content);
21
22 public function setIcon($icon){
23 $this->content["icon"]=new HtmlIcon("icon-".$this->identifier, $icon);
24 }
25
26 public function removeIcon(){
27 if(isset($this->content["icon"]))
28 unset($this->content["icon"]);
29 return $this;
30 }
31
32 public function setImage($image){
33 $image=new HtmlImg("icon-".$this->identifier, $image);
34 $image->asAvatar();
35 $this->content["image"]=$image;
36 }
37
38 private function _getContent($key="content",$baseClass="content"){
39 if(!is_array($this->content)){
40 $this->content=[$this->content];
41 }
42 if(\array_key_exists($key, $this->content)===false){
43 $this->content[$key]=new HtmlSemDoubleElement($key."-".$this->identifier,"div",$baseClass);
44 }
45 return $this->content[$key];
46 }
47
48 private function _getRightContent(){
49 return $this->_getContent("right-content","right floated content");
50 }
51
52 public function addContent($content,$before=false){
53 $this->_getContent("content")->addContent($content,$before);
54 return $this;
55 }
56
57 public function addRightContent($content,$before=false){
58 $this->_getRightContent()->addContent($content,$before);
59 return $this;
60 }
61
62 public function setTitle($title,$description=NULL,$baseClass="title"){
63 $title=new HtmlSemDoubleElement("","div",$baseClass,$title);
64 $content=$this->_getContent();
65 $content->addContent($title);
66 if(isset($description)){
67 $description=new HtmlSemDoubleElement("","div","description",$description);
68 $content->addContent($description);
69 }
70 return $this;
71 }
72
73 public function getPart($partName="header"){
74 $content=\array_merge($this->_getContent()->getContent(),array(@$this->content["icon"],@$this->content["image"]));
75 return $this->getElementByPropertyValue("class", $partName, $content);
76 }
77
78 public function setActive($value=true){
79 if($value){
80 $this->setTagName("div");
81 $this->removeProperty("href");
82 $this->addToPropertyCtrl("class", "active", array("active"));
83 }else{
84 $this->removePropertyValue("class", "active");
85 }
86 return $this;
87 }
88
89 public function asLink($href=NULL,$part=NULL){
90 $this->setTagName("a");
91 if(isset($href))
92 $this->setProperty("href", $href);
93 return $this;
94 }
95
102 public function compile(JsUtils $js=NULL, &$view=NULL) {
103 if(\is_array($this->content) && JArray::isAssociative($this->content))
104 $this->content=JArray::sortAssociative($this->content, [ "right-content","icon","image","content" ]);
105 return parent::compile($js, $view);
106 }
107}
JQuery PHP library.
Definition JsUtils.php:23
getElementByPropertyValue($propertyName, $value, $elements)
Base class for Semantic double elements.
addToPropertyCtrl($name, $value, $typeCtrl)
__construct($identifier, $baseClass, $content=NULL)
setActive($value=true)
show it is currently the active user selection
_getContent($key="content", $baseClass="content")
setTitle($title, $description=NULL, $baseClass="title")
compile(JsUtils $js=NULL, &$view=NULL)
{}BaseHtml::compile()
asLink($href=NULL, $part=NULL)
Transforms the element into a link.
Semantic Icon component.
Definition HtmlIcon.php:14