PHP code example of quansitech / qscmf-adminlte-widgets

1. Go to this page and download the library: Download quansitech/qscmf-adminlte-widgets library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

quansitech / qscmf-adminlte-widgets example snippets


composer 

//$view 是 Think\View 对象
$content = new Content($view);
//设置面板标题
$content->title('网站概况');
//设置高亮的节点
$content->setNIDByNode('admin','dashboard', 'index');

//设置行组件
$row = new \AdminLTE\Row(new InfoBox('日活', 100, 'info', ['icon' => 'users']));
//\AdminLTE\Row 作为参数
$content->addRow($row);
//HTML字符串作为参数
$box = <<<html
<div style="width:100%;height:100px;background-color: red;"></div>
html;
//当非Row组件作为参数时,可设置第二个参数来设定行所占宽度(总共12)
$content->addRow($box, 6);

//渲染html页面
$content->display();

//实例化row
$row = new Row();
//也可以传入Column类型对象
$row = new Row(new Column(new InfoBox('日活', 100, 'info', 'users')));
//或者是html字符串, 此时可传入第二个参数来设定所占宽度(总共12)
$box = <<<html
<div style="width:100%;height:100px;background-color: red;"></div>
html;
$row = new Row($box, 6);

//实例化后,给已有row添加列内容
//例子中的column可以是Html字符串,或者Column对象
//Column对象无须传递第二个参数,传了也无效
$row->addColumn($column, 4);

$box = <<<html
<div style="width:100%;height:100px;background-color: red;"></div>
html;
//实例化column组件
//第一个参数为html字符串,或者是实现了__toString魔术函数的对象
//第二个参数为宽度,默认是12
$column = new Column($box, 12);
$box2 = <<<html
<div style="width:100%;height:100px;background-color: yellow;"></div>
html;
//向Column追加内容
//接受html字符串,或者实现了__toString魔术函数的对象
$column->append($box2);

//第一个参数,设定card body部分的html内容,或者是实现了__toString魔术函数的对象
//第二个参数,card的标题
//第三个参数,card header的背景色,见主题颜色说明
//第四个参数,是否启动折叠功能
//第五个参数,是否启动关闭功能
$card = new Card($card_row, '统计', 'danger', true, true);

//设置body内容
//参数类型,html字符串或者实现了__toString魔术函数的对象
$card->setBody($body);

//是否开启折叠功能
$card->setCollapse(true);

//是否开启关闭功能
$card->setRemove(true);

//设置标题
$card->setTitle('趋势图');

//设置header背景颜色
//参数是主题颜色,见主题颜色说明
$card->setBg($bg);

//实例化
//第一个参数,数据描述
//第二个参数,数据
//第三个参数,背景主题色,见主题颜色说明
//第四个参数,icon
$box = new InfoBox('参与人', 200, 'info', 'users');

//设置说明提示
$box->setTips('报名人数');

//设置icon
$box->setIcon('users');

//设置背景主题色
$box->setBg('info');

//设置点击跳转页面
//第一个参数,页面路径
//第二个参数,是否在新页面打开,默认为 false
$box->jumpTo($url,$is_blank);

// 参数为背景主题色,默认为primary,见主题颜色说明
$tab = new Tab('success');

// 第一个参数为tab项目的标题
// 第二个参数为tab项目的html内容,或者是实现了__toString魔术函数的对象
// 第三个参数为tab项目标题的提示,默认为空
$tab->addTab('title', 'body', 'tips');

// 多个tab则实现多个addTab方法
$tab->addTab('divider', new DividerBuilder('222'));

$list_box = new \AdminLTE\Widgets\ListBox\ListBox();

// 获取需要展示的数据
$list = [["id" => 1,"title" => "title","amount" => 100,"summary"=>"summary","date"=>date("Y-m-d", time())]];

foreach ($list as $v){
    $item = new \AdminLTE\Widgets\ListBox\ListItem();
    // 设置标题及字体颜色
    $item->setTitle($v['title'],"primary");
    // 设置标题右边标签项及其背景颜色
    $item->addRightTag("$".$v['amount'],"success");
    // 设置描述项    
    $item->addColumn($v['summary']);
    $item->addColumn($v['date']);
    // 设置点击标题跳转链接    
    $item->setUrl(U("admin/review/detail",['id'=>$v['id']]));
    // 添加列表项,为\AdminLTE\Widgets\UlListCard\LiItem 对象
    $list_box->addListItem($item);
}

echo (new \AdminLTE\Widgets\Card($list_box,"待处理数据","danger"))->addFooterMore(U("admin/review/index"));

//构造函数,20指间隔的高度,单位px
$gap = new Gap(20);


//或者
$gap = new Gap();
$gap->setHeight(20);