33
44use Ajax \service \JString ;
55use Ajax \common \html \BaseHtml ;
6+ use Ajax \common \html \BaseWidget ;
67
78/**
89 * @author jc
9- *
10+ * @property BaseWidget $_self
1011 */
1112trait BaseHtmlPropertiesTrait{
1213
@@ -15,101 +16,101 @@ abstract protected function ctrl($name, $value, $typeCtrl);
1516 abstract protected function removeOldValues (&$ oldValue , $ allValues );
1617 abstract protected function _getElementBy ($ callback ,$ elements );
1718 public function getProperties () {
18- return $ this ->properties ;
19+ return $ this ->_self -> properties ;
1920 }
2021
2122 /**
2223 * @param array $properties
2324 * @return BaseHtml
2425 */
2526 public function setProperties ($ properties ) {
26- $ this ->properties =$ properties ;
27+ $ this ->_self -> properties =$ properties ;
2728 return $ this ;
2829 }
2930
3031 public function setProperty ($ name , $ value ) {
31- $ this ->properties [$ name ]=$ value ;
32+ $ this ->_self -> properties [$ name ]=$ value ;
3233 return $ this ;
3334 }
3435
3536 public function getProperty ($ name ) {
36- if (array_key_exists ($ name , $ this ->properties ))
37- return $ this ->properties [$ name ];
37+ if (array_key_exists ($ name , $ this ->_self -> properties ))
38+ return $ this ->_self -> properties [$ name ];
3839 }
3940
4041 public function addToProperty ($ name , $ value , $ separator =" " ) {
4142 if (\is_array ($ value )) {
4243 foreach ( $ value as $ v ) {
43- $ this ->addToProperty ($ name , $ v , $ separator );
44+ $ this ->_self -> addToProperty ($ name , $ v , $ separator );
4445 }
45- } else if ($ value !== "" && $ this ->propertyContains ($ name , $ value ) === false ) {
46- $ v =@$ this ->properties [$ name ];
46+ } else if ($ value !== "" && $ this ->_self -> propertyContains ($ name , $ value ) === false ) {
47+ $ v =@$ this ->_self -> properties [$ name ];
4748 if (isset ($ v ) && $ v !== "" )
4849 $ v =$ v . $ separator . $ value ;
4950 else
5051 $ v =$ value ;
5152
52- return $ this ->setProperty ($ name , $ v );
53+ return $ this ->_self -> setProperty ($ name , $ v );
5354 }
5455 return $ this ;
5556 }
5657
5758 public function addProperties ($ properties ) {
58- $ this ->properties =array_merge ($ this ->properties , $ properties );
59+ $ this ->_self -> properties =array_merge ($ this -> _self ->properties , $ properties );
5960 return $ this ;
6061 }
6162
6263 protected function removePropertyValue ($ name , $ value ) {
63- $ this ->properties [$ name ]=\str_replace ($ value , "" , $ this ->properties [$ name ]);
64+ $ this ->_self -> properties [$ name ]=\str_replace ($ value , "" , $ this -> _self ->properties [$ name ]);
6465 return $ this ;
6566 }
6667
6768 protected function removePropertyValues ($ name , $ values ) {
68- $ this ->removeOldValues ($ this ->properties [$ name ], $ values );
69+ $ this ->_self -> removeOldValues ($ this -> _self ->properties [$ name ], $ values );
6970 return $ this ;
7071 }
7172
7273 protected function addToPropertyUnique ($ name , $ value , $ typeCtrl ) {
7374 if (@class_exists ($ typeCtrl , true ))
7475 $ typeCtrl =$ typeCtrl ::getConstants ();
7576 if (\is_array ($ typeCtrl )) {
76- $ this ->removeOldValues ($ this ->properties [$ name ], $ typeCtrl );
77+ $ this ->_self -> removeOldValues ($ this -> _self ->properties [$ name ], $ typeCtrl );
7778 }
78- return $ this ->addToProperty ($ name , $ value );
79+ return $ this ->_self -> addToProperty ($ name , $ value );
7980 }
8081
8182 public function addToPropertyCtrl ($ name , $ value , $ typeCtrl ) {
82- return $ this ->addToPropertyUnique ($ name , $ value , $ typeCtrl );
83+ return $ this ->_self -> addToPropertyUnique ($ name , $ value , $ typeCtrl );
8384 }
8485
8586 public function addToPropertyCtrlCheck ($ name , $ value , $ typeCtrl ) {
86- if ($ this ->ctrl ($ name , $ value , $ typeCtrl ) === true ) {
87- return $ this ->addToProperty ($ name , $ value );
87+ if ($ this ->_self -> ctrl ($ name , $ value , $ typeCtrl ) === true ) {
88+ return $ this ->_self -> addToProperty ($ name , $ value );
8889 }
8990 return $ this ;
9091 }
9192
9293 public function removeProperty ($ name ) {
93- if (\array_key_exists ($ name , $ this ->properties ))
94- unset($ this ->properties [$ name ]);
94+ if (\array_key_exists ($ name , $ this ->_self -> properties ))
95+ unset($ this ->_self -> properties [$ name ]);
9596 return $ this ;
9697 }
9798
9899 public function propertyContains ($ propertyName , $ value ) {
99- $ values =$ this ->getProperty ($ propertyName );
100+ $ values =$ this ->_self -> getProperty ($ propertyName );
100101 if (isset ($ values )) {
101102 return JString::contains ($ values , $ value );
102103 }
103104 return false ;
104105 }
105106
106107 protected function setPropertyCtrl ($ name , $ value , $ typeCtrl ) {
107- if ($ this ->ctrl ($ name , $ value , $ typeCtrl ) === true )
108- return $ this ->setProperty ($ name , $ value );
108+ if ($ this ->_self -> ctrl ($ name , $ value , $ typeCtrl ) === true )
109+ return $ this ->_self -> setProperty ($ name , $ value );
109110 return $ this ;
110111 }
111112
112113 protected function getElementByPropertyValue ($ propertyName ,$ value , $ elements ) {
113- return $ this ->_getElementBy (function ($ element ) use ($ propertyName ,$ value ){return $ element ->propertyContains ($ propertyName , $ value ) === true ;}, $ elements );
114+ return $ this ->_self -> _getElementBy (function ($ element ) use ($ propertyName ,$ value ){return $ element ->propertyContains ($ propertyName , $ value ) === true ;}, $ elements );
114115 }
115116}
0 commit comments