Completed
Push — master ( 03d1b2...8466ff )
by Jean-Christophe
03:11
created

Semantic::htmlGrid()   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 3
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\common\html\HtmlDoubleElement;
22
use Ajax\semantic\html\modules\HtmlPopup;
23
use Ajax\common\html\BaseHtml;
24
use Ajax\semantic\html\collections\HtmlGrid;
25
26
class Semantic extends BaseGui {
27
28
	public function __construct($autoCompile=true) {
29
		parent::__construct($autoCompile=true);
30
	}
31
32
	/**
33
	 *
34
	 * @param string $attachTo
35
	 * @param string|array $params
36
	 * @return $this
37
	 */
38
	public function popup($attachTo=NULL, $params=NULL) {
39
		return $this->addComponent(new Popup($this->js), $attachTo, $params);
40
	}
41
42
	public function dropdown($attachTo=NULL, $params=NULL) {
43
		return $this->addComponent(new Dropdown($this->js), $attachTo, $params);
44
	}
45
46
	/**
47
	 * Return a new Semantic Html Button
48
	 * @param string $identifier
49
	 * @param string $value
50
	 * @param string $cssStyle
51
	 * @param string $onClick
52
	 * @return HtmlButton
53
	 */
54
	public function htmlButton($identifier, $value="", $cssStyle=null, $onClick=null) {
55
		return $this->addHtmlComponent(new HtmlButton($identifier, $value, $cssStyle, $onClick));
56
	}
57
58
	/**
59
	 * @param string $identifier
60
	 * @param string $icon
61
	 */
62
	public function htmlIcon($identifier,$icon){
63
		return $this->addHtmlComponent(new HtmlIcon($identifier, $icon));
64
	}
65
66
	/**
67
	 * @param string $identifier
68
	 * @param string $size
69
	 * @param array $icons
70
	 */
71
	public function htmlIconGroups($identifier,$size="",$icons=array()){
72
		$group=new HtmlIconGroups($identifier,$size);
73
		if(JArray::isAssociative($icons)){
74
			foreach ($icons as $icon=>$size){
75
				$group->add($icon,$size);
76
			}
77
		}else{
78
			foreach ($icons as $icon){
79
				$group->add($icon);
80
			}
81
		}
82
		return $this->addHtmlComponent($group);
83
	}
84
85
	/**
86
	 * @param string $identifier
87
	 * @param array $elements
88
	 * @param boolean $asIcons
89
	 */
90
	public function htmlButtonGroups($identifier,$elements=array(),$asIcons=false){
91
		return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements,$asIcons));
92
	}
93
94
	/**
95
	 * Creates an html container
96
	 * @param string $identifier
97
	 * @param string $content
98
	 */
99
	public function htmlContainer($identifier,$content=""){
100
		return $this->addHtmlComponent(new HtmlContainer($identifier, $content));
101
	}
102
103
	/**
104
	 * @param string $identifier
105
	 * @param string $content
106
	 */
107
	public function htmlDivider($identifier,$content="",$tagName="div"){
108
		return $this->addHtmlComponent(new HtmlDivider($identifier, $content,$tagName));
109
	}
110
111
	/**
112
	 * @param string $identifier
113
	 * @param string $content
114
	 * @param string $tagName
115
	 */
116
	public function htmlLabel($identifier,$content="",$tagName="div"){
117
		return $this->addHtmlComponent(new HtmlLabel($identifier, $content,$tagName));
118
	}
119
120
	/**
121
	 * @param string $identifier
122
	 * @param array $items
123
	 */
124
	public function htmlMenu($identifier,$items=array()){
125
		return $this->addHtmlComponent(new HtmlMenu($identifier,$items));
126
	}
127
128
	/**
129
	 * @param string $identifier
130
	 * @param string $value
131
	 * @param array $items
132
	 */
133
	public function htmlDropdown($identifier, $value="", $items=array()){
134
		return $this->addHtmlComponent(new HtmlDropdown($identifier,$value,$items));
135
	}
136
137
	/**
138
	 * Adds a new message
139
	 * @param string $identifier
140
	 * @param string $content
141
	 */
142
	public function htmlMessage($identifier, $content=""){
143
		return $this->addHtmlComponent(new HtmlMessage($identifier,$content));
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
	 */
151
	public function htmlSegment($identifier, $content=""){
152
		return $this->addHtmlComponent(new HtmlSegment($identifier,$content));
153
	}
154
155
	/**
156
	 * Adds a group of segments
157
	 * @param string $identifier
158
	 * @param array $items the segments
159
	 */
160
	public function htmlSegmentGroups($identifier, $items=array()){
161
		return $this->addHtmlComponent(new HtmlSegmentGroups($identifier,$items));
162
	}
163
164
	/**
165
	 * @param string $identifier
166
	 * @param mixed $content
167
	 */
168
	public function htmlPopup(BaseHtml $container,$identifier,$content){
169
		return $this->addHtmlComponent(new HtmlPopup($container,$identifier,$content));
170
	}
171
172
	public function htmlGrid($identifier,$numRows=1,$numCols=NULL){
173
		return $this->addHtmlComponent(new HtmlGrid($identifier,$numRows,$numCols));
174
	}
175
}