phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
PropertyWrapper.php
Go to the documentation of this file.
1<?php
2
3namespace Ajax\common\html;
4
6
8
9 public static function wrap($input, $js=NULL, $view=null, $separator=' ', $valueQuote='"') {
10 if (is_string($input)) {
11 return $input;
12 }
13 $output="";
14 if (\is_array($input)) {
15 if (sizeof($input) > 0) {
16 if (self::containsElement($input) === false) {
17 $output=self::wrapStrings($input, $separator=' ', $valueQuote='"');
18 } else {
19 $output=self::wrapObjects($input, $js, $view, $separator, $valueQuote);
20 }
21 }
22 }
23 return $output;
24 }
25
26 private static function containsElement($input) {
27 foreach ( $input as $v ) {
28 if (\is_object($v) || \is_array($v))
29 return true;
30 }
31 return false;
32 }
33
34 public static function wrapStrings($input, $separator=' ', $valueQuote='"') {
35 if (JArray::isAssociative($input) === true) {
36 $result=implode($separator, array_map(function ($v, $k) use($valueQuote) {
37 return $k . '=' . $valueQuote . $v . $valueQuote;
38 }, $input, array_keys($input)));
39 } else {
40 $result=implode($separator, $input);
41 }
42 return $result;
43 }
44
45 public static function wrapObjects($input, $js=NULL, $view=null, $separator=' ', $valueQuote='"') {
46 return implode($separator, array_map(function ($v) use($js, $view,$separator, $valueQuote) {
47 if(\is_string($v)){
48 return $v;
49 }
50 if ($v instanceof BaseHtml){
51 return $v->compile($js,$view);
52 }
53 if (\is_array($v)) {
54 return self::wrap($v, $js, $view,$separator, $valueQuote);
55 }
56 if(!\is_callable($v)){
57 return $v;
58 }
59 }, $input));
60 }
61
62 protected static function wrapValue($value,$js=NULL, $separator=' ', $valueQuote='"'){
63 if (\is_array($value)) {
64 return self::wrap($value, $js, $separator, $valueQuote);
65 }
66 if ($value instanceof BaseHtml){
67 return $value->compile($js);
68 }
69 if(!\is_callable($value)){
70 return $value;
71 }
72 return '';
73 }
74}
BaseHtml for HTML components.
Definition BaseHtml.php:17
static wrap($input, $js=NULL, $view=null, $separator=' ', $valueQuote='"')
static wrapValue($value, $js=NULL, $separator=' ', $valueQuote='"')
static wrapStrings($input, $separator=' ', $valueQuote='"')
static wrapObjects($input, $js=NULL, $view=null, $separator=' ', $valueQuote='"')