11<?php
2-
32namespace Ajax \semantic \html \base ;
43
54use Ajax \common \html \HtmlDoubleElement ;
65use Ajax \semantic \html \content \InternalPopup ;
7-
86use Ajax \semantic \html \base \traits \BaseTrait ;
97use Ajax \semantic \html \modules \HtmlDimmer ;
108use Ajax \semantic \html \elements \HtmlLabel ;
1412use Ajax \common \html \html5 \HtmlList ;
1513use Ajax \common \html \BaseHtml ;
1614use Ajax \semantic \components \Toast ;
15+ use Ajax \semantic \components \Sidebar ;
1716
1817/**
1918 * Base class for Semantic double elements
19+ *
2020 * @author jc
2121 * @version 1.0.2
2222 */
2323class HtmlSemDoubleElement extends HtmlDoubleElement {
2424 use BaseTrait;
25- protected $ _popup =NULL ;
26- protected $ _dimmer =NULL ;
27- protected $ _toast =NULL ;
28- protected $ _params =array ();
2925
26+ protected $ _popup = NULL ;
27+
28+ protected $ _dimmer = NULL ;
29+
30+ protected $ _toast = NULL ;
31+
32+ protected $ _sidebar = NULL ;
33+
34+ protected $ _params = array ();
3035
31- public function __construct ($ identifier , $ tagName= "p " , $ baseClass= "ui " , $ content= NULL ) {
36+ public function __construct ($ identifier , $ tagName = "p " , $ baseClass = "ui " , $ content = NULL ) {
3237 parent ::__construct ($ identifier , $ tagName );
33- $ this ->_baseClass = $ baseClass ;
38+ $ this ->_baseClass = $ baseClass ;
3439 $ this ->setClass ($ baseClass );
3540 if (isset ($ content )) {
36- $ this ->content = $ content ;
41+ $ this ->content = $ content ;
3742 }
3843 }
3944
4045 /**
4146 * Defines the popup attributes
47+ *
4248 * @param string $variation
4349 * @param string $popupEvent
4450 */
45- public function setPopupAttributes ($ variation= NULL , $ popupEvent= NULL ) {
51+ public function setPopupAttributes ($ variation = NULL , $ popupEvent = NULL ) {
4652 if (isset ($ this ->_popup ))
4753 $ this ->_popup ->setAttributes ($ variation , $ popupEvent );
4854 }
4955
5056 /**
5157 * Adds a popup to the element
58+ *
5259 * @param string $title
5360 * @param string $content
5461 * @param string $variation
5562 * @param array $params
5663 * @return HtmlSemDoubleElement
5764 */
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 );
6067 return $ this ;
6168 }
6269
6370 /**
6471 * Adds an html popup to the element
72+ *
6573 * @param string $html
6674 * @param string $variation
6775 * @param array $params
6876 * @return HtmlSemDoubleElement
6977 */
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 );
7280 $ this ->_popup ->setHtml ($ html );
7381 $ this ->_popup ->setAttributes ($ variation , $ params );
7482 return $ this ;
7583 }
7684
7785 /**
7886 * Adds a Dimmer to the element
87+ *
7988 * @param array $params
8089 * @param mixed $content
8190 * @return HtmlDimmer
8291 */
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 );
8594 $ dimmer ->setParams ($ params );
8695 $ dimmer ->setContainer ($ this );
8796 $ this ->addContent ($ dimmer );
@@ -90,79 +99,87 @@ public function addDimmer($params=array(), $content=NULL) {
9099
91100 /**
92101 * Adds a label to the element
102+ *
93103 * @param mixed $label
94104 * @param boolean $before
95105 * @param string $icon
96106 * @return mixed|HtmlLabel
97107 */
98- public function addLabel ($ label , $ before= false , $ icon= NULL ) {
99- $ labelO= $ label ;
108+ public function addLabel ($ label , $ before = false , $ icon = NULL ) {
109+ $ labelO = $ label ;
100110 if (\is_object ($ label ) === false ) {
101- $ labelO= new HtmlLabel ("label- " . $ this ->identifier , $ label );
111+ $ labelO = new HtmlLabel ("label- " . $ this ->identifier , $ label );
102112 if (isset ($ icon ))
103113 $ labelO ->addIcon ($ icon );
104114 } else {
105- $ labelO ->addToPropertyCtrl ("class " , "label " , array ("label " ));
115+ $ labelO ->addToPropertyCtrl ("class " , "label " , array (
116+ "label "
117+ ));
106118 }
107119 $ this ->addContent ($ labelO , $ before );
108120 return $ labelO ;
109121 }
110122
111123 /**
112124 * Adds an attached label to the element
125+ *
113126 * @param mixed $label
114127 * @param string $side
115128 * @param string $direction
116129 * @param string $icon
117130 * @return HtmlSemDoubleElement
118131 */
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 );
122135 return $ this ;
123136 }
124137
125138 /**
126139 * Transforms the element into a link
140+ *
127141 * @return HtmlSemDoubleElement
128142 */
129- public function asLink ($ href= NULL ,$ target= NULL ) {
143+ public function asLink ($ href = NULL , $ target = NULL ) {
130144 if (isset ($ href ))
131145 $ this ->setProperty ("href " , $ href );
132- if (isset ($ target ))
146+ if (isset ($ target ))
133147 $ this ->setProperty ("target " , $ target );
134148 return $ this ->setTagName ("a " );
135149 }
136150
137151 /**
138152 * Returns the script displaying the dimmer
153+ *
139154 * @param boolean $show
140155 * @return string
141156 */
142- public function jsShowDimmer ($ show= true ) {
143- $ status= "hide " ;
157+ public function jsShowDimmer ($ show = true ) {
158+ $ status = "hide " ;
144159 if ($ show === true )
145- $ status= "show " ;
160+ $ status = "show " ;
146161 return '$("#. ' . $ this ->identifier . ').dimmer(" ' . $ status . '"); ' ;
147162 }
148163
149164 /**
150- * {@inheritDoc}
165+ *
166+ * {@inheritdoc}
151167 * @see BaseHtml::compile()
152168 */
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 )) {
155171 $ this ->_popup ->compile ($ js );
156172 }
157173 return parent ::compile ($ js , $ view );
158174 }
159175
160176 /**
161- * {@inheritDoc}
177+ *
178+ * {@inheritdoc}
162179 * @see HtmlDoubleElement::run()
163180 */
164181 public function run (JsUtils $ js ) {
165- $ this ->_bsComponent = $ js ->semantic ()->generic ("# " . $ this ->identifier );
182+ $ this ->_bsComponent = $ js ->semantic ()->generic ("# " . $ this ->identifier );
166183 parent ::run ($ js );
167184 $ this ->addEventsOnRun ($ js );
168185 if (isset ($ this ->_popup )) {
@@ -175,33 +192,46 @@ public function run(JsUtils $js) {
175192 }
176193
177194 /**
195+ *
178196 * @param array $items
179197 * @param boolean $ordered
180198 * @return \Ajax\common\html\html5\HtmlList
181199 */
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 );
184202 $ list ->setOrdered ($ ordered );
185203 $ list ->setClass ("ui list " );
186204 $ this ->addContent ($ list );
187205 return $ list ;
188206 }
189-
207+
190208 /**
209+ *
191210 * @param ?array $params
192211 * @return \Ajax\semantic\components\Toast
193212 */
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 )) {
199218 $ this ->_toast ->setParams ($ params );
200219 }
201- $ this ->_toast ->setParam ('onShow ' ,'$(".toast-box *").show(); ' );
220+ $ this ->_toast ->setParam ('onShow ' , '$(".toast-box *").show(); ' );
202221 return $ this ->_toast ;
203222 }
204223
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+
205235 /*
206236 * public function __call($name, $arguments){
207237 * $type=\substr($name, 0,3);
0 commit comments