生成ul格式的html数据
@param array $data 支持多维数组
@param array $attributes array('id'=>'', 'class'=>'')
@return string
764576
public static function ul($data, $attributes = array())
    {
        if (! is_array($data)) {
            return '';
        }
        $attributes = $attributes + array('id'=>'', 'class'=>'');

        $str="<ul id=\"". $attributes['id'] ."\" class=\"". $attributes['class'] ."\">\n";
        foreach ($data as $k => $v) {
            $str .= "\t<li>";
            $str .= is_array($v) ? $k.self::ul($v) : $v;
            $str .= "</li>\n";
        }
        $str .= "</ul>\n";
        return $str;
    }
400668
public static function get_attribute_html( $attributes = array() ) {
		$html = '';

		if ( ! $attributes ) {
			return $html;
		}

		foreach ( $attributes as $key => $attribute ) {
			$html .= ' ' . esc_attr( $key ) . '="' . esc_attr( $attribute ) . '"';
		}

		return $html;
	}
1219527
public function buildTagAttributes(array $attributes)
	{
		$html = array();

		foreach ($attributes as $key => $value)
		{
			if (is_null($value))
				continue;

			if (is_numeric($key))
				$key = $value;

			$html[] = $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
		}

		return (count($html) > 0) ? ' ' . implode(' ', $html) : '';
	}
259882
public static function autolink(string $string, array $attributes = []): string
	{
		return preg_replace_callback('#\b(?<!href="|">)[a-z]+://\S+(?:/|\b)#i', function($matches) use ($attributes)
		{
			return (new HTML())->tag('a', ['href' => $matches[0]] + $attributes, $matches[0]);
		}, $string);
	}
146571
public static function buildHtmlScript($script, array $attributes = []): string
    {
        $scriptCleaned = trim($script);
        if ($scriptCleaned !== '') {
            return self::buildHtmlElement('script', $attributes, "\n" . $scriptCleaned . "\n");
        }
        return '';
    }
431725
protected function stripAttributeMarker(array $data)
    {
        foreach ($data as $key => $value) {
            if (substr($key, 0, 5) == '@xml:') {
                $data[substr($key, 5)] = $value;
                unset ($data[$key]);
            } elseif (substr($key, 0, 1) == '@') {
                $data[substr($key, 1)] = $value;
                unset ($data[$key]);
            }

            if (is_array($value)) {
                $data[$key] = $this->stripAttributeMarker($value);
            }
        }

        return $data;
    }
1065775
public function pdf(array $data)
    {
        if (!defined('DOMPDF_ENABLE_AUTOLOAD')) {
            define('DOMPDF_ENABLE_AUTOLOAD', false);
        }

        if (file_exists($configPath = Yii::getAlias('@app') . '/vendor/dompdf/dompdf/dompdf_config.inc.php')) {
            require_once $configPath;
        }

        $dompdf = new Dompdf();

        $dompdf->load_html($this->renderInvoiceHtml($data));

        $dompdf->render();

        return $dompdf->output();
    }
725929
public static function table($data, $title = array(), $attributes = array())
    {
        // 必须是二维数组
        if (is_string($data)) {
            return $data;
        } elseif (is_array($data) && ! is_array(reset($data))) {
            return implode(' ', $data);
        }

        $attributes = $attributes + array('id'=>'', 'class'=>'');

        $str="<table id=\"". $attributes['id'] ."\" class=\"". $attributes['class'] ."\">\n";

        //table th
        if (!empty($title)) {
            $str .= "\t<tr>\n";
            foreach ($title as $v) {
                $str .= "\t\t<th>{$v}</th>\n";
            }
            $str .= "\t</tr>\n";
        }
        foreach ($data as $v1) {
            $str .= "\t<tr>\n";
            foreach ($v1 as $k2 => $v2) {
                //非数字主键作为td的id
                if (is_numeric($k2)) {
                    $str .= "\t\t<td>";
                } else {
                    $str .= "\t\t<td id=\"tb_{$k2}\">";
                }
                $str .= is_array($v2) ? self::table($v2) : $v2;
                $str .= "</td>\n";
            }
            $str .= "\t</tr>\n";
        }
        $str .= "</table>\n";
        return $str;
    }
418918
public static function attributes(array $attributes): string
    {
        $html = [];
        foreach ($attributes as $key => $value) {
            if (is_string($value)) {
                $html[] = e($key) . '="' . e($value) . '"';
            } elseif (is_int($value)) {
                $html[] = e($key) . '="' . $value . '"';
            } elseif ($value !== false) {
                $html[] = e($key);
            }
        }

        return implode(' ', $html);
    }
1287816
public static function renderAttributes(array $attributes)
    {
        $html = [];
        foreach ($attributes as $key => $value) {
            $escaped = htmlentities($value, ENT_QUOTES, 'UTF-8', false);
            $html[] = is_numeric($key) ?
                ($escaped . '="' . $escaped . '""')
                :
                ("$key=\"$escaped\"");
        }
        return count($html) > 0 ? ' ' . implode(' ', $html) : '';
    }
548229
protected static function data_prepare ($data, $tag, &$in, &$attributes) {
		if (isset($data['in'])) {
			if ($data['in'] === false) {
				return false;
			}
			$in = trim($data['in']);
			unset($data['in']);
		}
		if ($tag == 'img' && !isset($data['alt'])) {
			$data['alt'] = '';
		}
		if (isset($data['src'])) {
			$data['src'] = static::prepare_url($data['src']);
		}
		if (isset($data['href'])) {
			if ($tag != 'a') {
				$data['href'] = static::prepare_url($data['href']);
			} elseif ($data['href'][0] == '#') {
				$data['href'] = static::url_with_hash($data['href']);
			}
		}
		static::data_prepare_normalize_attributes($data);
		ksort($data);
		foreach ($data as $key => $value) {
			if ($value === false) {
				continue;
			}
			if ($value === true) {
				$attributes .= " $key";
			} else {
				$value      = static::prepare_attr_value($value);
				$attributes .= " $key=\"$value\"";
			}
		}
		return true;
	}
568816
private function HtmlAttributes($attributes)
    {
        $formatted = join(' ', array_map(function ($key) use ($attributes) {
            if (is_bool($attributes[$key])) {
                return $attributes[$key] ? $key : '';
            }
            return $key . '="' . $attributes[$key] . '"';
        }, array_keys($attributes)));
        return $formatted;
    }
1301896
public static function unorderedList( $items, $level = 0, $attributes = array() )
	{
		$depth1		= 2 * abs( (int) $level );
		$depth2		= $level ? 2 * abs( (int) $level - 1 ) + 1 : 0;
		$indent1	= str_repeat( "  ", $depth1 );
		$indent2	= str_repeat( "  ", $depth2 );
		$content	= "\n".implode( "\n", $items )."\n".$indent1;
		$tag		= UI_HTML_Tag::create( "ul", $content, $attributes );
		$code		= $indent1.$tag."\n".$indent2;
		return $code;
	}
627618
public function attr(array $attributes)
    {
        $result = '';

        foreach ($attributes as $attribute => $value) {
            $result .= ' '.(is_int($attribute) ? $value : $attribute.'="'.str_replace('"', '&quot;', $value).'"');
        }

        return $result;
    }
204418
public function CreateElementHtml($data){
		PhpWsdl::Debug('CreateElementHtml for '.$data['element']->Name);
		$res=&$data['res'];
		$e=&$data['element'];
		if(in_array($e->Type,PhpWsdl::$BasicTypes)){
			$res[]='<li><span class="blue">'.$e->Type.'</span> <span class="bold">'.$e->Name.'</span>';
		}else{
			$res[]='<li><a href="#'.$e->Type.'"><span class="lightBlue">'.$e->Type.'</span></a> <span class="bold">'.$e->Name.'</span>';
		}
		$o=sizeof($res)-1;
		$temp=Array(
			'nillable = <span class="blue">'.(($e->NillAble)?'true':'false').'</span>',
			'minoccurs = <span class="blue">'.$e->MinOccurs.'</span>',
			'maxoccurs = <span class="blue">'.$e->MaxOccurs.'</span>',
		);
		$res[$o].=' ('.implode(', ',$temp).')';
		if(!is_null($e->Docs))
			$res[$o].='<br><span class="normal">'.nl2br(htmlentities($e->Docs)).'</span>';
		$res[$o].='</li>';
		PhpWsdl::CallHook(
			'CreateElementHtmlHook',
			$data
		);
	}
1172089
private function getHTMLAttributes($attributes)
    {
        $attr = '';
        foreach($attributes as $key => $value) {
            $attr .= $key.'="'.$value.'" ';
        }
        return $attr;
    }
1238378
public function html($group, $source, $attributes)
    {
        $result = substr($source, 0, 7);
        if($result=='/public') $source = substr($source, 7);

        $source = url($source);
        
        switch ($group)
        {
            case 'script' :
                $attributes['src'] = $source;

                return '<script'.$this->attributes($attributes).'></script>'.PHP_EOL;
            case 'style' :

                $defaults = array('media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet');

                $attributes = $attributes + $defaults;

                $attributes['href'] = $source;

                return '<link'.$this->attributes($attributes).'>'.PHP_EOL;
        }
    }