phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
HtmlViewContent.php
Go to the documentation of this file.
1 <?php
2 
4 
9 use Ajax\JsUtils;
12 
14  use ContentPartTrait;
15  public function __construct($identifier, $content=array()) {
16  parent::__construct($identifier, "div", "content",[]);
17  $this->setContent($content);
18  }
19 
20  public function setContent($value){
21  if (\is_array($value)) {
22  $header=JArray::getValue($value, "header", 0);
23  $metas=JArray::getValue($value, "metas", 1);
24  $description=JArray::getValue($value, "description", 2);
25  $image=JArray::getValue($value, "image", 3);
26  $extra=JArray::getValue($value, "extra", 4);
27  if (isset($image)) {
28  $this->addImage($image);
29  }
30  $this->addHeaderContent($header, $metas, $description,$extra);
31  } else
32  $this->addContent($value);
33  }
34 
35  public function addElement($content, $baseClass="") {
36  $count=\sizeof($this->content);
37  $result=new HtmlViewContent("element-" . $count . "-" . $this->identifier, $content);
38  $result->setClass($baseClass);
39  $this->addContent($result);
40  return $result;
41  }
42 
43  public function addMeta($value, $direction=Direction::LEFT) {
44  if (\array_key_exists("meta", $this->content) === false) {
45  $this->content["meta"]=new HtmlSemDoubleElement("meta-" . $this->identifier, "div", "meta", array ());
46  }
47  if ($direction === Direction::RIGHT) {
48  $value=new HtmlSemDoubleElement("", "span", "", $value);
49  $value->setFloated($direction);
50  }
51  $this->content["meta"]->addContent($value);
52  return $this->content["meta"];
53  }
54 
55  public function addExtra($value) {
56  if (\array_key_exists("extra", $this->content) === false) {
57  $this->content["extra"]=new HtmlSemDoubleElement("extra-" . $this->identifier, "div", "extra", array ());
58  }
59  $this->content["extra"]->addContent($value);
60  return $this->content["extra"];
61  }
62 
63  public function addImage($src="", $alt="", $size=NULL) {
64  $image=new HtmlImg("img-", $src, $alt);
65  if (isset($size))
66  $image->setSize($size);
67  $this->content['image']=$image;
68  return $image;
69  }
70 
78  public function addContentButtons($elements=array(), $asIcons=false,$part="extra",$before=false){
79  $buttons=new HtmlButtonGroups("buttons-".$this->identifier,$elements,$asIcons);
80  $this->addElementInPart($buttons,$part, $before,true);
81  return $buttons;
82  }
83 
84  public function addMetas($metas) {
85  if (\is_array($metas)) {
86  foreach ( $metas as $meta ) {
87  $this->addMeta($meta);
88  }
89  } else
90  $this->addMeta($metas);
91  return $this;
92  }
93 
94  public function addContentIcon($icon, $caption=NULL, $direction=Direction::LEFT) {
95  if ($direction === Direction::RIGHT) {
96  if (isset($caption)) {
97  $result=new HtmlSemDoubleElement("", "span", "", $caption);
98  $result->addIcon($icon);
99  $this->addContent($result);
100  } else {
101  $result=new HtmlIcon("", $icon);
102  $this->addContent($result);
103  }
104  $result->setFloated($direction);
105  } else {
106  $this->addIcon($icon);
107  $result=$this->addContent($caption);
108  }
109  return $result;
110  }
111 
112  public function addContentText($caption, $direction=Direction::LEFT) {
113  if ($direction === Direction::RIGHT) {
114  $result=new HtmlSemDoubleElement("", "span", "", $caption);
115  $this->addContent($result);
116  $result->setFloated($direction);
117  } else
118  $result=$this->addContent($caption);
119  return $result;
120  }
121 
122  public function addContentIcons($icons, $direction=Direction::LEFT) {
123  foreach ( $icons as $icon ) {
124  $this->addContentIcon($icon, NULL, $direction);
125  }
126  return $this;
127  }
128 
129  public function addHeaderContent($header, $metas=array(), $description=NULL,$extra=NULL) {
130  if(isset($header))
131  $this->addElement($header, "header");
132  $this->addMetas($metas);
133  if (isset($description)) {
134  $this->addElement($description, "description");
135  }
136  if(isset($extra)){
137  $this->addExtra($extra);
138  }
139  return $this;
140  }
141 
142  public function compile(JsUtils $js=NULL, &$view=NULL) {
143  return parent::compile($js, $view);
144  }
145 }
static getValue($array, $key, $pos)
Definition: JArray.php:10
addContentIcon($icon, $caption=NULL, $direction=Direction::LEFT)
__construct($identifier, $content=array())
addHeaderContent($header, $metas=array(), $description=NULL, $extra=NULL)
addContent($content, $before=false)
addContentText($caption, $direction=Direction::LEFT)
Semantic Icon component.
Definition: HtmlIcon.php:14
addMeta($value, $direction=Direction::LEFT)
addContentButtons($elements=array(), $asIcons=false, $part="extra", $before=false)
Base class for Semantic double elements.
addContentIcons($icons, $direction=Direction::LEFT)
JQuery PHP library.
Definition: JsUtils.php:23
addIcon($icon, $before=true)
Definition: BaseTrait.php:92
Semantic UI Buttongroups component.