1
|
|
|
<?php |
2
|
|
|
namespace Ajax\semantic\traits; |
3
|
|
|
|
4
|
|
|
use Ajax\semantic\html\elements\HtmlButtonGroups; |
5
|
|
|
use Ajax\semantic\html\elements\HtmlButton; |
6
|
|
|
use Ajax\semantic\html\elements\HtmlContainer; |
7
|
|
|
use Ajax\semantic\html\elements\HtmlDivider; |
8
|
|
|
use Ajax\semantic\html\elements\HtmlHeader; |
9
|
|
|
use Ajax\semantic\html\elements\HtmlIcon; |
10
|
|
|
use Ajax\semantic\html\elements\HtmlIconGroups; |
11
|
|
|
use Ajax\semantic\html\elements\HtmlInput; |
12
|
|
|
use Ajax\semantic\html\elements\HtmlLabel; |
13
|
|
|
use Ajax\semantic\html\elements\HtmlList; |
14
|
|
|
use Ajax\semantic\html\elements\HtmlSegment; |
15
|
|
|
use Ajax\semantic\html\elements\HtmlSegmentGroups; |
16
|
|
|
use Ajax\service\JArray; |
17
|
|
|
use Ajax\semantic\html\collections\form\HtmlFormCheckbox; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
trait SemanticHtmlElementsTrait { |
21
|
|
|
|
22
|
|
|
public abstract function addHtmlComponent($htmlComponent); |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Return a new Semantic Html Button |
26
|
|
|
* @param string $identifier |
27
|
|
|
* @param string $value |
28
|
|
|
* @param string $cssStyle |
29
|
|
|
* @param string $onClick |
30
|
|
|
* @return HtmlButton |
31
|
|
|
*/ |
32
|
|
|
public function htmlButton($identifier, $value="", $cssStyle=null, $onClick=null) { |
33
|
|
|
return $this->addHtmlComponent(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param string $identifier |
38
|
|
|
* @param array $elements |
39
|
|
|
* @param boolean $asIcons |
40
|
|
|
* @return HtmlButtonGroups |
41
|
|
|
*/ |
42
|
|
|
public function htmlButtonGroups($identifier,$elements=array(),$asIcons=false){ |
43
|
|
|
return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements,$asIcons)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Creates an html container |
48
|
|
|
* @param string $identifier |
49
|
|
|
* @param string $content |
50
|
|
|
* @return HtmlContainer |
51
|
|
|
*/ |
52
|
|
|
public function htmlContainer($identifier,$content=""){ |
53
|
|
|
return $this->addHtmlComponent(new HtmlContainer($identifier, $content)); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $identifier |
58
|
|
|
* @param string $content |
59
|
|
|
* @return HtmlDivider |
60
|
|
|
*/ |
61
|
|
|
public function htmlDivider($identifier,$content="",$tagName="div"){ |
62
|
|
|
return $this->addHtmlComponent(new HtmlDivider($identifier, $content,$tagName)); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param string $identifier |
67
|
|
|
* @param number $niveau |
68
|
|
|
* @param mixed $content |
69
|
|
|
* @param string $type |
70
|
|
|
* @return HtmlHeader |
71
|
|
|
*/ |
72
|
|
|
public function htmlHeader($identifier,$niveau=1,$content=NULL,$type="page"){ |
73
|
|
|
return $this->addHtmlComponent(new HtmlHeader($identifier,$niveau,$content,$type)); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $identifier |
78
|
|
|
* @param string $icon |
79
|
|
|
* @return HtmlIcon |
80
|
|
|
*/ |
81
|
|
|
public function htmlIcon($identifier,$icon){ |
82
|
|
|
return $this->addHtmlComponent(new HtmlIcon($identifier, $icon)); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param string $identifier |
87
|
|
|
* @param string $size |
88
|
|
|
* @param array $icons |
89
|
|
|
* @return HtmlIconGroups |
90
|
|
|
*/ |
91
|
|
|
public function htmlIconGroups($identifier,$size="",$icons=array()){ |
92
|
|
|
$group=new HtmlIconGroups($identifier,$size); |
93
|
|
|
if(JArray::isAssociative($icons)){ |
94
|
|
|
foreach ($icons as $icon=>$size){ |
95
|
|
|
$group->add($icon,$size); |
96
|
|
|
} |
97
|
|
|
}else{ |
98
|
|
|
foreach ($icons as $icon){ |
99
|
|
|
$group->add($icon); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
return $this->addHtmlComponent($group); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* |
107
|
|
|
* @param string $identifier |
108
|
|
|
* @param string $type |
109
|
|
|
* @param string $value |
110
|
|
|
* @param string $placeholder |
111
|
|
|
* @return HtmlInput |
112
|
|
|
*/ |
113
|
|
|
public function htmlInput($identifier,$type="text",$value="",$placeholder=""){ |
114
|
|
|
return $this->addHtmlComponent(new HtmlInput($identifier,$type,$value,$placeholder)); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param string $identifier |
119
|
|
|
* @param string $content |
120
|
|
|
* @param string $tagName |
121
|
|
|
* @return HtmlLabel |
122
|
|
|
*/ |
123
|
|
|
public function htmlLabel($identifier,$content="",$tagName="div"){ |
124
|
|
|
return $this->addHtmlComponent(new HtmlLabel($identifier, $content,$tagName)); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* |
129
|
|
|
* @param string $identifier |
130
|
|
|
* @param array $items |
131
|
|
|
* @return HtmlList |
132
|
|
|
*/ |
133
|
|
|
public function htmlList($identifier,$items=array()){ |
134
|
|
|
return $this->addHtmlComponent(new HtmlList($identifier,$items)); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Adds a new segment, used to create a grouping of related content |
139
|
|
|
* @param string $identifier |
140
|
|
|
* @param string $content |
141
|
|
|
* @return HtmlSegment |
142
|
|
|
*/ |
143
|
|
|
public function htmlSegment($identifier, $content=""){ |
144
|
|
|
return $this->addHtmlComponent(new HtmlSegment($identifier,$content)); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Adds a group of segments |
149
|
|
|
* @param string $identifier |
150
|
|
|
* @param array $items the segments |
151
|
|
|
* @return HtmlSegmentGroups |
152
|
|
|
*/ |
153
|
|
|
public function htmlSegmentGroups($identifier, $items=array()){ |
154
|
|
|
return $this->addHtmlComponent(new HtmlSegmentGroups($identifier,$items)); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function htmlCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
158
|
|
|
return $this->addHtmlComponent(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
159
|
|
|
} |
160
|
|
|
} |