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