7
7
use Ajax \common \components \SimpleExtComponent ;
8
8
use Ajax \JsUtils ;
9
9
use Ajax \common \html \traits \BaseHtmlEventsTrait ;
10
+ use Ajax \common \html \traits \BaseHtmlPropertiesTrait ;
10
11
11
12
/**
12
13
* BaseHtml for HTML components
13
14
* @author jc
14
15
* @version 1.2
15
16
*/
16
17
abstract class BaseHtml extends BaseWidget {
17
- use BaseHtmlEventsTrait;
18
+ use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait ;
18
19
protected $ _template ;
19
20
protected $ tagName ;
20
- protected $ properties =array ();
21
21
protected $ _wrapBefore =array ();
22
22
protected $ _wrapAfter =array ();
23
23
protected $ _bsComponent ;
@@ -35,47 +35,6 @@ protected function getTemplate(JsUtils $js=NULL) {
35
35
return PropertyWrapper::wrap ($ this ->_wrapBefore , $ js ) . $ this ->_template . PropertyWrapper::wrap ($ this ->_wrapAfter , $ js );
36
36
}
37
37
38
- public function getProperties () {
39
- return $ this ->properties ;
40
- }
41
-
42
- public function setProperties ($ properties ) {
43
- $ this ->properties =$ properties ;
44
- return $ this ;
45
- }
46
-
47
- public function setProperty ($ name , $ value ) {
48
- $ this ->properties [$ name ]=$ value ;
49
- return $ this ;
50
- }
51
-
52
- public function getProperty ($ name ) {
53
- if (array_key_exists ($ name , $ this ->properties ))
54
- return $ this ->properties [$ name ];
55
- }
56
-
57
- public function addToProperty ($ name , $ value , $ separator =" " ) {
58
- if (\is_array ($ value )) {
59
- foreach ( $ value as $ v ) {
60
- $ this ->addToProperty ($ name , $ v , $ separator );
61
- }
62
- } else if ($ value !== "" && $ this ->propertyContains ($ name , $ value ) === false ) {
63
- $ v =@$ this ->properties [$ name ];
64
- if (isset ($ v ) && $ v !== "" )
65
- $ v =$ v . $ separator . $ value ;
66
- else
67
- $ v =$ value ;
68
-
69
- return $ this ->setProperty ($ name , $ v );
70
- }
71
- return $ this ;
72
- }
73
-
74
- public function addProperties ($ properties ) {
75
- $ this ->properties =array_merge ($ this ->properties , $ properties );
76
- return $ this ;
77
- }
78
-
79
38
public function compile (JsUtils $ js =NULL , &$ view =NULL ) {
80
39
$ result =$ this ->getTemplate ($ js );
81
40
foreach ( $ this as $ key => $ value ) {
@@ -110,19 +69,7 @@ protected function ctrl($name, $value, $typeCtrl) {
110
69
return true ;
111
70
}
112
71
113
- public function propertyContains ($ propertyName , $ value ) {
114
- $ values =$ this ->getProperty ($ propertyName );
115
- if (isset ($ values )) {
116
- return JString::contains ($ values , $ value );
117
- }
118
- return false ;
119
- }
120
72
121
- protected function setPropertyCtrl ($ name , $ value , $ typeCtrl ) {
122
- if ($ this ->ctrl ($ name , $ value , $ typeCtrl ) === true )
123
- return $ this ->setProperty ($ name , $ value );
124
- return $ this ;
125
- }
126
73
127
74
protected function setMemberCtrl (&$ name , $ value , $ typeCtrl ) {
128
75
if ($ this ->ctrl ($ name , $ value , $ typeCtrl ) === true ) {
@@ -139,21 +86,7 @@ protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ")
139
86
return $ this ;
140
87
}
141
88
142
- protected function removePropertyValue ($ name , $ value ) {
143
- $ this ->properties [$ name ]=\str_replace ($ value , "" , $ this ->properties [$ name ]);
144
- return $ this ;
145
- }
146
-
147
- protected function removePropertyValues ($ name , $ values ) {
148
- $ this ->removeOldValues ($ this ->properties [$ name ], $ values );
149
- return $ this ;
150
- }
151
89
152
- public function removeProperty ($ name ) {
153
- if (\array_key_exists ($ name , $ this ->properties ))
154
- unset($ this ->properties [$ name ]);
155
- return $ this ;
156
- }
157
90
158
91
protected function addToMemberCtrl (&$ name , $ value , $ typeCtrl , $ separator =" " ) {
159
92
if ($ this ->ctrl ($ name , $ value , $ typeCtrl ) === true ) {
@@ -170,25 +103,7 @@ protected function addToMember(&$name, $value, $separator=" ") {
170
103
return $ this ;
171
104
}
172
105
173
- protected function addToPropertyUnique ($ name , $ value , $ typeCtrl ) {
174
- if (@class_exists ($ typeCtrl , true ))
175
- $ typeCtrl =$ typeCtrl ::getConstants ();
176
- if (\is_array ($ typeCtrl )) {
177
- $ this ->removeOldValues ($ this ->properties [$ name ], $ typeCtrl );
178
- }
179
- return $ this ->addToProperty ($ name , $ value );
180
- }
181
106
182
- public function addToPropertyCtrl ($ name , $ value , $ typeCtrl ) {
183
- return $ this ->addToPropertyUnique ($ name , $ value , $ typeCtrl );
184
- }
185
-
186
- public function addToPropertyCtrlCheck ($ name , $ value , $ typeCtrl ) {
187
- if ($ this ->ctrl ($ name , $ value , $ typeCtrl ) === true ) {
188
- return $ this ->addToProperty ($ name , $ value );
189
- }
190
- return $ this ;
191
- }
192
107
193
108
protected function removeOldValues (&$ oldValue , $ allValues ) {
194
109
$ oldValue =str_ireplace ($ allValues , "" , $ oldValue );
@@ -278,24 +193,6 @@ public function getElementById($identifier, $elements) {
278
193
return null ;
279
194
}
280
195
281
- protected function getElementByPropertyValue ($ propertyName ,$ value , $ elements ) {
282
- if (\is_array ($ elements )) {
283
- $ flag =false ;
284
- $ index =0 ;
285
- while ( !$ flag && $ index < sizeof ($ elements ) ) {
286
- if ($ elements [$ index ] instanceof BaseHtml)
287
- $ flag =($ elements [$ index ]->propertyContains ($ propertyName , $ value ) === true );
288
- $ index ++;
289
- }
290
- if ($ flag === true )
291
- return $ elements [$ index - 1 ];
292
- } elseif ($ elements instanceof BaseHtml) {
293
- if ($ elements ->propertyContains ($ propertyName , $ value ) === true )
294
- return $ elements ;
295
- }
296
- return null ;
297
- }
298
-
299
196
public function __toString () {
300
197
return $ this ->compile ();
301
198
}
0 commit comments