<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>{$meta_title}-狂雨小说CMS</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <link rel="stylesheet" href="__ADMIN__/css/admin.css">
    </head>
    <body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <form class="layui-form" action="{:url('del')}">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <table class="layui-table">
                                <colgroup>
                                    <col width="200">
                                    <col width="150">
                                    <col>
                                    <col width="150">
                                    <col width="100">
                                    <col width="250">
                                </colgroup>
                                <thead>
                                    <tr>
                                        <th>名称</th>
                                        <th>标识</th>
                                        <th>描述</th>
                                        <th>版本</th>
                                        <th>状态</th>
                                        <th><div align="center">操作</div></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {notempty name="list"}
                                    {volist name="list" id="vo"}
                                    <tr>
                                        <td>{$vo['title']}</td>
                                        <td id="name">{$vo['name']}</td>
                                        <td>{$vo['description']}</td>
                                        <td id="version">{$vo['version']}</td>
                                        <td><input type="checkbox" name="status" value="{$vo.status}" lay-skin="switch" lay-text="正常|禁用" lay-filter="status" lay-url="{:url('status',['id'=>$vo['id']])}" {eq name="vo.status" value="1"}checked{/eq}></td>
                                        <td align="center">
                                            <?php
                                                $class  = get_addon_class($vo['name']);
                                                if(!class_exists($class)){
                                                    $has_config = 0;
                                                }else{
                                                    $addon = new $class();
                                                    if(is_array($addon->getConfig())){
                                                        $has_config = 1;
                                                    }else{
                                                        $has_config = 0;
                                                    }
                                                }
                                            ?>
                                            <?php if ($has_config): ?>
                                                <a onclick="admin_show('设置','{:url('config',['id'=>$vo['id']])}',0,0,1)" class="layui-btn layui-btn-normal layui-btn-xs" href="javascript:;"><i class="layui-icon layui-icon-edit"></i>设置</a>
                                            <?php endif ?>
                                            <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="admin_del(this,'{:url('uninstall',['id'=>$vo['id']])}')"><i class="layui-icon layui-icon-delete"></i>卸载</a>
                                        </td>
                                    </tr>
                                    {/volist}
                                    {else/}
                                        <td colspan="6"> aOh! 暂时还没有内容! </td>
                                    {/notempty}
                                </tbody>
                            </table>
                            <div class="page">
                                {$list|raw}
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="__STATIC__/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/admin.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('[id="version"]').each(function(index, el) {
                $.getJSON('{:url("upgrade/version")}', {version:$(el).text(),name:$(el).siblings('#name').text()}, function(json){
                    if(json['update']){
                        $(el).next().next().append('<a class="layui-btn layui-btn-danger layui-btn-xs" onclick="admin_show(\'在线升级\',\'{:url('upgrade/lists')}?id='+json['id']+'&type='+json['type']+'&name='+json['name']+'&version='+$(el).text()+'\',800,600,0,1)" href="javascript:;"><i class="layui-icon layui-icon-upload-drag"></i>升级模版</a>');
                    }
                });
            });
        });
    </script>
    </body>
</html>