77class PropertyWrapper {
88
99 public static function wrap ($ input , $ js =NULL , $ separator =' ' , $ valueQuote ='" ' ) {
10- $ output ="" ;
1110 if (is_string ($ input )) {
12- $ output = $ input ;
11+ return $ input ;
1312 }
13+ $ output ="" ;
1414 if (\is_array ($ input )) {
1515 if (sizeof ($ input ) > 0 ) {
1616 if (self ::containsElement ($ input ) === false ) {
@@ -37,19 +37,50 @@ public static function wrapStrings($input, $separator=' ', $valueQuote='"') {
3737 return $ k . '= ' . $ valueQuote . $ v . $ valueQuote ;
3838 }, $ input , array_keys ($ input )));
3939 } else {
40- $ result =implode ($ separator , array_values ( $ input) );
40+ $ result =implode ($ separator , $ input );
4141 }
4242 return $ result ;
4343 }
4444
4545 public static function wrapObjects ($ input , $ js =NULL , $ separator =' ' , $ valueQuote ='" ' ) {
4646 return implode ($ separator , array_map (function ($ v ) use ($ js , $ separator , $ valueQuote ) {
47- if ($ v instanceof BaseHtml)
47+ if (\is_string ($ v )){
48+ return $ v ;
49+ }
50+ if ($ v instanceof BaseHtml){
4851 return $ v ->compile ($ js );
49- elseif (\is_array ($ v )) {
52+ }
53+ if (\is_array ($ v )) {
5054 return self ::wrap ($ v , $ js , $ separator , $ valueQuote );
51- } elseif (!\is_callable ($ v ))
55+ }
56+ if (!\is_callable ($ v )){
5257 return $ v ;
58+ }
5359 }, $ input ));
60+ /*$result='';
61+ foreach ($input as $value) {
62+ if($result!==''){
63+ $result.=$separator;
64+ }
65+ if(\is_string($value)){
66+ $result.=$value;
67+ }else{
68+ $result.=self::wrapValue($value,$js,$separator,$valueQuote);
69+ }
70+ }
71+ return $result;*/
72+ }
73+
74+ protected static function wrapValue ($ value ,$ js =NULL , $ separator =' ' , $ valueQuote ='" ' ){
75+ if (\is_array ($ value )) {
76+ return self ::wrap ($ value , $ js , $ separator , $ valueQuote );
77+ }
78+ if ($ value instanceof BaseHtml){
79+ return $ value ->compile ($ js );
80+ }
81+ if (!\is_callable ($ value )){
82+ return $ value ;
83+ }
84+ return '' ;
5485 }
5586}
0 commit comments