1
1
<?php
2
-
3
2
namespace Ajax \semantic \html \base ;
4
3
5
4
use Ajax \common \html \HtmlDoubleElement ;
6
5
use Ajax \semantic \html \content \InternalPopup ;
7
-
8
6
use Ajax \semantic \html \base \traits \BaseTrait ;
9
7
use Ajax \semantic \html \modules \HtmlDimmer ;
10
8
use Ajax \semantic \html \elements \HtmlLabel ;
14
12
use Ajax \common \html \html5 \HtmlList ;
15
13
use Ajax \common \html \BaseHtml ;
16
14
use Ajax \semantic \components \Toast ;
15
+ use Ajax \semantic \components \Sidebar ;
17
16
18
17
/**
19
18
* Base class for Semantic double elements
19
+ *
20
20
* @author jc
21
21
* @version 1.0.2
22
22
*/
23
23
class HtmlSemDoubleElement extends HtmlDoubleElement {
24
24
use BaseTrait;
25
- protected $ _popup =NULL ;
26
- protected $ _dimmer =NULL ;
27
- protected $ _toast =NULL ;
28
- protected $ _params =array ();
29
25
26
+ protected $ _popup = NULL ;
27
+
28
+ protected $ _dimmer = NULL ;
29
+
30
+ protected $ _toast = NULL ;
31
+
32
+ protected $ _sidebar = NULL ;
33
+
34
+ protected $ _params = array ();
30
35
31
- public function __construct ($ identifier , $ tagName= "p " , $ baseClass= "ui " , $ content= NULL ) {
36
+ public function __construct ($ identifier , $ tagName = "p " , $ baseClass = "ui " , $ content = NULL ) {
32
37
parent ::__construct ($ identifier , $ tagName );
33
- $ this ->_baseClass = $ baseClass ;
38
+ $ this ->_baseClass = $ baseClass ;
34
39
$ this ->setClass ($ baseClass );
35
40
if (isset ($ content )) {
36
- $ this ->content = $ content ;
41
+ $ this ->content = $ content ;
37
42
}
38
43
}
39
44
40
45
/**
41
46
* Defines the popup attributes
47
+ *
42
48
* @param string $variation
43
49
* @param string $popupEvent
44
50
*/
45
- public function setPopupAttributes ($ variation= NULL , $ popupEvent= NULL ) {
51
+ public function setPopupAttributes ($ variation = NULL , $ popupEvent = NULL ) {
46
52
if (isset ($ this ->_popup ))
47
53
$ this ->_popup ->setAttributes ($ variation , $ popupEvent );
48
54
}
49
55
50
56
/**
51
57
* Adds a popup to the element
58
+ *
52
59
* @param string $title
53
60
* @param string $content
54
61
* @param string $variation
55
62
* @param array $params
56
63
* @return HtmlSemDoubleElement
57
64
*/
58
- public function addPopup ($ title= "" , $ content= "" , $ variation= NULL , $ params= array ()) {
59
- $ this ->_popup = new InternalPopup ($ this , $ title , $ content , $ variation , $ params );
65
+ public function addPopup ($ title = "" , $ content = "" , $ variation = NULL , $ params = array ()) {
66
+ $ this ->_popup = new InternalPopup ($ this , $ title , $ content , $ variation , $ params );
60
67
return $ this ;
61
68
}
62
69
63
70
/**
64
71
* Adds an html popup to the element
72
+ *
65
73
* @param string $html
66
74
* @param string $variation
67
75
* @param array $params
68
76
* @return HtmlSemDoubleElement
69
77
*/
70
- public function addPopupHtml ($ html= "" , $ variation= NULL , $ params= array ()) {
71
- $ this ->_popup = new InternalPopup ($ this );
78
+ public function addPopupHtml ($ html = "" , $ variation = NULL , $ params = array ()) {
79
+ $ this ->_popup = new InternalPopup ($ this );
72
80
$ this ->_popup ->setHtml ($ html );
73
81
$ this ->_popup ->setAttributes ($ variation , $ params );
74
82
return $ this ;
75
83
}
76
84
77
85
/**
78
86
* Adds a Dimmer to the element
87
+ *
79
88
* @param array $params
80
89
* @param mixed $content
81
90
* @return HtmlDimmer
82
91
*/
83
- public function addDimmer ($ params= array (), $ content= NULL ) {
84
- $ dimmer= new HtmlDimmer ("dimmer- " . $ this ->identifier , $ content );
92
+ public function addDimmer ($ params = array (), $ content = NULL ) {
93
+ $ dimmer = new HtmlDimmer ("dimmer- " . $ this ->identifier , $ content );
85
94
$ dimmer ->setParams ($ params );
86
95
$ dimmer ->setContainer ($ this );
87
96
$ this ->addContent ($ dimmer );
@@ -90,79 +99,87 @@ public function addDimmer($params=array(), $content=NULL) {
90
99
91
100
/**
92
101
* Adds a label to the element
102
+ *
93
103
* @param mixed $label
94
104
* @param boolean $before
95
105
* @param string $icon
96
106
* @return mixed|HtmlLabel
97
107
*/
98
- public function addLabel ($ label , $ before= false , $ icon= NULL ) {
99
- $ labelO= $ label ;
108
+ public function addLabel ($ label , $ before = false , $ icon = NULL ) {
109
+ $ labelO = $ label ;
100
110
if (\is_object ($ label ) === false ) {
101
- $ labelO= new HtmlLabel ("label- " . $ this ->identifier , $ label );
111
+ $ labelO = new HtmlLabel ("label- " . $ this ->identifier , $ label );
102
112
if (isset ($ icon ))
103
113
$ labelO ->addIcon ($ icon );
104
114
} else {
105
- $ labelO ->addToPropertyCtrl ("class " , "label " , array ("label " ));
115
+ $ labelO ->addToPropertyCtrl ("class " , "label " , array (
116
+ "label "
117
+ ));
106
118
}
107
119
$ this ->addContent ($ labelO , $ before );
108
120
return $ labelO ;
109
121
}
110
122
111
123
/**
112
124
* Adds an attached label to the element
125
+ *
113
126
* @param mixed $label
114
127
* @param string $side
115
128
* @param string $direction
116
129
* @param string $icon
117
130
* @return HtmlSemDoubleElement
118
131
*/
119
- public function attachLabel ($ label ,$ side= Side::TOP ,$ direction= Direction::NONE ,$ icon= NULL ){
120
- $ label= $ this ->addLabel ($ label ,true ,$ icon );
121
- $ label ->setAttached ($ side ,$ direction );
132
+ public function attachLabel ($ label , $ side = Side::TOP , $ direction = Direction::NONE , $ icon = NULL ) {
133
+ $ label = $ this ->addLabel ($ label , true , $ icon );
134
+ $ label ->setAttached ($ side , $ direction );
122
135
return $ this ;
123
136
}
124
137
125
138
/**
126
139
* Transforms the element into a link
140
+ *
127
141
* @return HtmlSemDoubleElement
128
142
*/
129
- public function asLink ($ href= NULL ,$ target= NULL ) {
143
+ public function asLink ($ href = NULL , $ target = NULL ) {
130
144
if (isset ($ href ))
131
145
$ this ->setProperty ("href " , $ href );
132
- if (isset ($ target ))
146
+ if (isset ($ target ))
133
147
$ this ->setProperty ("target " , $ target );
134
148
return $ this ->setTagName ("a " );
135
149
}
136
150
137
151
/**
138
152
* Returns the script displaying the dimmer
153
+ *
139
154
* @param boolean $show
140
155
* @return string
141
156
*/
142
- public function jsShowDimmer ($ show= true ) {
143
- $ status= "hide " ;
157
+ public function jsShowDimmer ($ show = true ) {
158
+ $ status = "hide " ;
144
159
if ($ show === true )
145
- $ status= "show " ;
160
+ $ status = "show " ;
146
161
return '$("#. ' . $ this ->identifier . ').dimmer(" ' . $ status . '"); ' ;
147
162
}
148
163
149
164
/**
150
- * {@inheritDoc}
165
+ *
166
+ * {@inheritdoc}
151
167
* @see BaseHtml::compile()
152
168
*/
153
- public function compile (JsUtils $ js= NULL , &$ view= NULL ) {
154
- if (isset ($ this ->_popup )){
169
+ public function compile (JsUtils $ js = NULL , &$ view = NULL ) {
170
+ if (isset ($ this ->_popup )) {
155
171
$ this ->_popup ->compile ($ js );
156
172
}
157
173
return parent ::compile ($ js , $ view );
158
174
}
159
175
160
176
/**
161
- * {@inheritDoc}
177
+ *
178
+ * {@inheritdoc}
162
179
* @see HtmlDoubleElement::run()
163
180
*/
164
181
public function run (JsUtils $ js ) {
165
- $ this ->_bsComponent = $ js ->semantic ()->generic ("# " . $ this ->identifier );
182
+ $ this ->_bsComponent = $ js ->semantic ()->generic ("# " . $ this ->identifier );
166
183
parent ::run ($ js );
167
184
$ this ->addEventsOnRun ($ js );
168
185
if (isset ($ this ->_popup )) {
@@ -175,33 +192,46 @@ public function run(JsUtils $js) {
175
192
}
176
193
177
194
/**
195
+ *
178
196
* @param array $items
179
197
* @param boolean $ordered
180
198
* @return \Ajax\common\html\html5\HtmlList
181
199
*/
182
- public function addList ($ items ,$ ordered= false ){
183
- $ list= new HtmlList ("list- " . $ this ->identifier ,$ items );
200
+ public function addList ($ items , $ ordered = false ) {
201
+ $ list = new HtmlList ("list- " . $ this ->identifier , $ items );
184
202
$ list ->setOrdered ($ ordered );
185
203
$ list ->setClass ("ui list " );
186
204
$ this ->addContent ($ list );
187
205
return $ list ;
188
206
}
189
-
207
+
190
208
/**
209
+ *
191
210
* @param ?array $params
192
211
* @return \Ajax\semantic\components\Toast
193
212
*/
194
- public function asToast ($ params= NULL ){
195
- $ this ->_toast = new Toast ();
196
- $ this ->_toast ->attach ('# ' . $ this ->_identifier );
197
- $ this ->setProperty ('style ' ,'display:none; ' );
198
- if (isset ($ params )){
213
+ public function asToast ($ params = NULL ) {
214
+ $ this ->_toast = new Toast ();
215
+ $ this ->_toast ->attach ('# ' . $ this ->_identifier );
216
+ $ this ->setProperty ('style ' , 'display:none; ' );
217
+ if (isset ($ params )) {
199
218
$ this ->_toast ->setParams ($ params );
200
219
}
201
- $ this ->_toast ->setParam ('onShow ' ,'$(".toast-box *").show(); ' );
220
+ $ this ->_toast ->setParam ('onShow ' , '$(".toast-box *").show(); ' );
202
221
return $ this ->_toast ;
203
222
}
204
223
224
+ /**
225
+ *
226
+ * @param string $classes
227
+ * @return \Ajax\semantic\components\Sidebar
228
+ */
229
+ public function asSideBar ($ classes = '' ) {
230
+ $ this ->_sidebar = new Sidebar ();
231
+ $ this ->addToProperty ('class ' , 'sidebar ' );
232
+ return $ this ->_sidebar ;
233
+ }
234
+
205
235
/*
206
236
* public function __call($name, $arguments){
207
237
* $type=\substr($name, 0,3);
0 commit comments