Completed
Push — master ( cd0fd2...97e05d )
by Jean-Christophe
03:14
created

Semantic::htmlIconMenu()   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;
4
5
use Ajax\common\BaseGui;
6
use Ajax\semantic\html\elements\HtmlButton;
7
use Ajax\semantic\html\elements\HtmlIcon;
8
use Ajax\service\JArray;
9
use Ajax\semantic\html\elements\HtmlIconGroups;
10
use Ajax\semantic\html\elements\HtmlButtonGroups;
11
use Ajax\semantic\html\elements\HtmlContainer;
12
use Ajax\semantic\html\elements\HtmlDivider;
13
use Ajax\semantic\html\elements\HtmlLabel;
14
use Ajax\semantic\html\collections\HtmlMenu;
15
use Ajax\semantic\components\Popup;
16
use Ajax\semantic\html\modules\HtmlDropdown;
17
use Ajax\semantic\components\Dropdown;
18
use Ajax\semantic\html\collections\HtmlMessage;
19
use Ajax\semantic\html\elements\HtmlSegment;
20
use Ajax\semantic\html\elements\HtmlSegmentGroups;
21
use Ajax\semantic\html\modules\HtmlPopup;
22
use Ajax\common\html\BaseHtml;
23
use Ajax\semantic\html\collections\HtmlGrid;
24
use Ajax\semantic\html\collections\HtmlIconMenu;
25
use Ajax\semantic\html\collections\HtmlLabeledIconMenu;
26
use Ajax\semantic\html\elements\HtmlHeader;
27
28
class Semantic extends BaseGui {
29
30
	public function __construct($autoCompile=true) {
31
		parent::__construct($autoCompile=true);
32
	}
33
34
	/**
35
	 *
36
	 * @param string $attachTo
37
	 * @param string|array $params
38
	 * @return $this
39
	 */
40
	public function popup($attachTo=NULL, $params=NULL) {
41
		return $this->addComponent(new Popup($this->js), $attachTo, $params);
42
	}
43
44
	public function dropdown($attachTo=NULL, $params=NULL) {
45
		return $this->addComponent(new Dropdown($this->js), $attachTo, $params);
46
	}
47
48
	/**
49
	 * Return a new Semantic Html Button
50
	 * @param string $identifier
51
	 * @param string $value
52
	 * @param string $cssStyle
53
	 * @param string $onClick
54
	 * @return HtmlButton
55
	 */
56
	public function htmlButton($identifier, $value="", $cssStyle=null, $onClick=null) {
57
		return $this->addHtmlComponent(new HtmlButton($identifier, $value, $cssStyle, $onClick));
58
	}
59
60
	/**
61
	 * @param string $identifier
62
	 * @param string $icon
63
	 */
64
	public function htmlIcon($identifier,$icon){
65
		return $this->addHtmlComponent(new HtmlIcon($identifier, $icon));
66
	}
67
68
	/**
69
	 * @param string $identifier
70
	 * @param string $size
71
	 * @param array $icons
72
	 */
73
	public function htmlIconGroups($identifier,$size="",$icons=array()){
74
		$group=new HtmlIconGroups($identifier,$size);
75
		if(JArray::isAssociative($icons)){
76
			foreach ($icons as $icon=>$size){
77
				$group->add($icon,$size);
78
			}
79
		}else{
80
			foreach ($icons as $icon){
81
				$group->add($icon);
82
			}
83
		}
84
		return $this->addHtmlComponent($group);
85
	}
86
87
	/**
88
	 * @param string $identifier
89
	 * @param array $elements
90
	 * @param boolean $asIcons
91
	 */
92
	public function htmlButtonGroups($identifier,$elements=array(),$asIcons=false){
93
		return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements,$asIcons));
94
	}
95
96
	/**
97
	 * Creates an html container
98
	 * @param string $identifier
99
	 * @param string $content
100
	 */
101
	public function htmlContainer($identifier,$content=""){
102
		return $this->addHtmlComponent(new HtmlContainer($identifier, $content));
103
	}
104
105
	/**
106
	 * @param string $identifier
107
	 * @param string $content
108
	 */
109
	public function htmlDivider($identifier,$content="",$tagName="div"){
110
		return $this->addHtmlComponent(new HtmlDivider($identifier, $content,$tagName));
111
	}
112
113
	/**
114
	 * @param string $identifier
115
	 * @param string $content
116
	 * @param string $tagName
117
	 */
118
	public function htmlLabel($identifier,$content="",$tagName="div"){
119
		return $this->addHtmlComponent(new HtmlLabel($identifier, $content,$tagName));
120
	}
121
122
	/**
123
	 * @param string $identifier
124
	 * @param array $items
125
	 */
126
	public function htmlMenu($identifier,$items=array()){
127
		return $this->addHtmlComponent(new HtmlMenu($identifier,$items));
128
	}
129
130
	/**Adds an icon menu
131
	 * @param string $identifier
132
	 * @param array $items icons
133
	 */
134
	public function htmlIconMenu($identifier,$items=array()){
135
		return $this->addHtmlComponent(new HtmlIconMenu($identifier,$items));
136
	}
137
138
	/**Adds an labeled icon menu
139
	 * @param string $identifier
140
	 * @param array $items icons
141
	 */
142
	public function htmlLabeledIconMenu($identifier,$items=array()){
143
		return $this->addHtmlComponent(new HtmlLabeledIconMenu($identifier,$items));
144
	}
145
146
	/**
147
	 * @param string $identifier
148
	 * @param string $value
149
	 * @param array $items
150
	 */
151
	public function htmlDropdown($identifier, $value="", $items=array()){
152
		return $this->addHtmlComponent(new HtmlDropdown($identifier,$value,$items));
153
	}
154
155
	/**
156
	 * Adds a new message
157
	 * @param string $identifier
158
	 * @param string $content
159
	 */
160
	public function htmlMessage($identifier, $content=""){
161
		return $this->addHtmlComponent(new HtmlMessage($identifier,$content));
162
	}
163
164
	/**
165
	 * Adds a new segment, used to create a grouping of related content
166
	 * @param string $identifier
167
	 * @param string $content
168
	 */
169
	public function htmlSegment($identifier, $content=""){
170
		return $this->addHtmlComponent(new HtmlSegment($identifier,$content));
171
	}
172
173
	/**
174
	 * Adds a group of segments
175
	 * @param string $identifier
176
	 * @param array $items the segments
177
	 */
178
	public function htmlSegmentGroups($identifier, $items=array()){
179
		return $this->addHtmlComponent(new HtmlSegmentGroups($identifier,$items));
180
	}
181
182
	/**
183
	 * @param string $identifier
184
	 * @param mixed $content
185
	 */
186
	public function htmlPopup(BaseHtml $container,$identifier,$content){
187
		return $this->addHtmlComponent(new HtmlPopup($container,$identifier,$content));
188
	}
189
190
	/**
191
	 * @param string $identifier
192
	 * @param int $numRows
193
	 * @param int $numCols
194
	 * @param boolean $createCols
195
	 * @param boolean $implicitRows
196
	 */
197
	public function htmlGrid($identifier,$numRows=1,$numCols=NULL,$createCols=true,$implicitRows=false){
198
		return $this->addHtmlComponent(new HtmlGrid($identifier,$numRows,$numCols,$createCols,$implicitRows));
199
	}
200
201
	public function htmlHeader($identifier,$niveau=1,$content=NULL,$type="page"){
202
		return $this->addHtmlComponent(new HtmlHeader($identifier,$niveau,$content,$type));
203
	}
204
}