Completed
Push — master ( 69e9f4...3042e6 )
by Jean-Christophe
04:01
created

SemanticHtmlElementsTrait   B

Complexity

Total Complexity 18

Size/Duplication

Total Lines 163
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 16

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 18
c 6
b 0
f 0
lcom 1
cbo 16
dl 0
loc 163
rs 8.4614

16 Methods

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