Example #1
0
/**
 * 控制生成表格
 * @param array $theads 抬头
 * @param array $rows 内容行
 * @param string $page_html 分页代码
 * @param array $tbody_attrs tbody标签的属性
 * @return string
 */
function table_format($theads, $rows = array(), $page_html = '', $tbody_attrs = array())
{
    $html = '<div class="widget-box">';
    $html .= '<div class="widget-content">';
    $html .= '<table class="table table-bordered table-striped table-hover">';
    $html .= '<thead>';
    $html .= '<tr>';
    //显示抬头
    foreach ($theads as $thead) {
        $html .= '<th ' . _parse_remove_attributes($thead, 'text') . '>' . $thead['text'] . '</th>';
    }
    $html .= '</tr>';
    $html .= '</thead>';
    $html .= '<tbody ' . _parse_remove_attributes($tbody_attrs) . '>';
    //显示内容
    foreach ($rows as $tr) {
        if (!empty($tr['attrs'])) {
            $html .= '<tr ' . _parse_remove_attributes($tr['attrs']) . '>';
        } else {
            $html .= '<tr>';
        }
        foreach ($tr['tr'] as $td) {
            $html .= '<td ' . _parse_remove_attributes($td['attrs']) . '>' . $td['td'] . '</td>';
        }
        $html .= '</tr>';
    }
    $html .= '</tbody>';
    $html .= '</table>';
    if (empty($rows)) {
        $html .= '<div class="alert alert-info alert-nolist"><h4 class="alert-heading">暂无数据</h4></div>';
    }
    if (!empty($page_html) && !empty($rows)) {
        $html .= $page_html;
    }
    $html .= '</div>';
    $html .= '</div>';
    return $html;
}
Example #2
0
/**
 * 生成img标签
 * @param string $data
 * @param string $extra
 * @return string
 */
function form_img($data = '', $extra = '')
{
    $defaults = array();
    return "<img " . _parse_remove_attributes($data) . $extra . "/>";
}