Completed
Push — master ( 8b7375...189ad5 )
by Jean-Christophe
03:49
created

SemanticHtmlElementsTrait::addState()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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