phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlViewItem.php
Go to the documentation of this file.
1<?php
2
4
9
15
17
18 public function __construct($identifier,$baseClass,$content=NULL) {
19 parent::__construct($identifier, "div", $baseClass);
20 $this->content=["content"=>new HtmlViewContent("content-".$this->identifier)];
21 if(isset($content))
22 $this->setContent($content);
23 }
24
25 public function setContent($value){
26 if (\is_array($value)) {
27 $image=JArray::getValue($value, "image", 0);
28 $content=JArray::getValue($value, "content", 1);
29 $extra=JArray::getValue($value, "extra", 2);
30 if (isset($image)) {
31 $this->addImage($image);
32 }
33 if(isset($content))
34 $this->content["content"]->setContent($content);
35 if(isset($extra))
36 $this->addExtraContent($extra);
37 }
38 }
39
40 private function createContent($content, $baseClass="content") {
41 $count=\sizeof($this->content);
42 $result=new HtmlViewContent("content-" . $count . "-" . $this->identifier, $content);
43 $result->setClass($baseClass);
44 return $result;
45 }
46
47 private function addElementIn($key, $element) {
48 if (\array_key_exists($key, $this->content) === false) {
49 $this->content[$key]=[];
50 }
51 if($this->content[$key] instanceof HtmlViewContent)
52 $this->content[$key]->addElement($element);
53 else
54 $this->content[$key][]=$element;
55 return $element;
56 }
57
58 public function addIcon($icon,$before=true){
59 return $this->addElementIn("icon",new HtmlIcon("icon-" . $this->identifier, $icon));
60 }
61
62
63 public function addHeader($header, $niveau=4, $type="page") {
64 if (!$header instanceof HtmlHeader) {
65 $header=new HtmlHeader("header-" . $this->identifier, $niveau, $header, $type);
66 }
67 return $this->addElementIn("header",$this->createContent($header));
68 }
69
70 public function addImage($image, $title="") {
71 if (!$image instanceof HtmlImage) {
72 $image=new HtmlImage("image-" . $this->identifier, $image, $title);
73 }
74 $image->setClass("ui image");
75 return $this->content["image"]= $image;
76 }
77
78 public function addReveal($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL,$key="extra-content") {
79 $reveal=$visibleContent;
80 if (!$visibleContent instanceof HtmlReveal) {
81 $reveal=new HtmlReveal("reveral-" . $this->identifier, $visibleContent, $hiddenContent, $type, $attributeType);
82 }
83 return $this->content[$key]= $reveal;
84 }
85
86 public function addRevealImage($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL) {
87 $reveal=$visibleContent;
88 if (!$visibleContent instanceof HtmlReveal) {
89 return $this->addReveal(new HtmlImage("", $visibleContent), new HtmlImage("", $hiddenContent), $type, $attributeType);
90 }
91 return $this->content["image"]= $reveal;
92 }
93
94 public function addExtraContent($content=array()) {
95 return $this->content["extra-content"]= $this->createContent($content, "extra content");
96 }
97
105 public function addContentButtons($elements=array(), $asIcons=false,$part="extra",$before=false){
106 return $this->content["content"]->addContentButtons($elements,$asIcons,$part, $before);
107 }
108
109
110
111 public function addItemHeaderContent($header, $metas=array(), $description=NULL,$extra=NULL) {
112 return $this->content["content"]->addHeaderContent($header, $metas, $description,$extra);
113 }
114
115 public function addItemContent($content=array()) {
116 $count=\sizeof($this->content);
117 return $this->addElementIn("content", new HtmlViewContent("content-" . $count . "-" . $this->identifier, $content));
118 }
119
120 public function getItemContent() {
121 return $this->getPart("content",null,true);
122 }
123
124 public function getItemExtraContent() {
125 return $this->getPart("extra-content");
126 }
127
128 public function getItemImage() {
129 return $this->getPart("image");
130 }
131
132 public function getItemHeader() {
133 return $this->getPart("header");
134 }
135
142 public function compile(JsUtils $js=NULL, &$view=NULL) {
143 $this->content=JArray::sortAssociative($this->content, ["header","image","icon","content","extra-content"]);
144 return parent::compile($js, $view);
145 }
146
147 public function asLink($href="",$target=NULL) {
148 $this->addToProperty("class", "link");
149 if ($href !== "") {
150 $this->setProperty("href", $href);
151 if (isset($target))
152 $this->setProperty("target", $target);
153 }
154 return $this;
155 }
156}
JQuery PHP library.
Definition JsUtils.php:23
Base class for Semantic double elements.
addToProperty($name, $value, $separator=" ")
getPart($partKey, $index=NULL, $force=false)
asLink($href="", $target=NULL)
Transforms the element into a link.
createContent($content, $baseClass="content")
__construct($identifier, $baseClass, $content=NULL)
addItemHeaderContent($header, $metas=array(), $description=NULL, $extra=NULL)
addHeader($header, $niveau=4, $type="page")
compile(JsUtils $js=NULL, &$view=NULL)
{}BaseHtml::compile()
addRevealImage($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL)
addContentButtons($elements=array(), $asIcons=false, $part="extra", $before=false)
addReveal($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL, $key="extra-content")
Semantic UI Buttongroups component.
Semantic Header component.
Semantic Icon component.
Definition HtmlIcon.php:14
Semantic Image component.
Definition HtmlImage.php:16