<?php if(!defined('IN_SDCMS')) exit;?><!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<title>插件管理</title>
<link rel="stylesheet" href="{WEB_ROOT}public/css/ui.css">
<link rel="stylesheet" href="{WEB_ROOT}public/admin/css/layout.css">
<script src="{WEB_ROOT}public/js/jquery.js"></script>
<script src="{WEB_ROOT}public/js/ui.js"></script>
</head>

<body>
    <div class="position">当前位置：模板插件 > <a href="{THIS_LOCAL}">插件管理</a></div>
    <div class="border">
        <!---->
        <table class="table table-border table-hover table-striped mb">
            <thead class="thead-gray">
                <tr>
                    <th>插件名称</th>
                    <th width="120">作者</th>
                    <th width="120">状态</th>
                    <th width="120">管理</th>
                </tr>
            </thead>
            <tbody>
            {if count($folder)==0}
            <tr>
                <td colspan="4">暂无插件</td>
            </tr>
            {/if}
            {foreach $folder as $key=>$val}
            {php list($name,$info)=$val}
            <tr>
                <td class="text-left">{$info['title']}</td>
                <td><a href="{$info['url']}" target="_blank">{$info['author']}</a></td>
                <td>{if C('plug_'.$name)}已安装{else}<em>未安装</em>{/if}</td>
                <td>{if C('plug_'.$name)}{if $info['admin']}<a href="{U("plug/".$name."/admin")}">管理</a>　{/if}<a href="javascript:;" class="delete" data-url="{U('delete','name='.$name.'')}">卸载</a>{else}<a href="javascript:;" class="install" data-url="{U('install','name='.$name.'')}">安装</a>{/if}</td>
            </tr>
            {/foreach}
            </tbody>
        </table>
        <!---->
    </div>
<script>
$(function()
{
	$(".install").click(function()
	{
		var url=$(this).attr("data-url");
		$.dialog(
		{
			'title':"操作提示",
			'text':"确定要安装此插件？",
			'oktheme':'btn-info',
			'ok':function(e)
			{
				$.ajax(
				{
					url:url,
					type:'post',
					dataType:'json',
					error:function(e){alert(e.responseText);},
					success:function(d)
					{
						e.close();
						if(d.state=='success')
						{
							sdcms.success(d.msg);
							setTimeout(function(){location.href='{THIS_LOCAL}';},1000);
						}
						else
						{
							sdcms.error(d.msg);
						}
					}
				});
			}
		});
    });
	$(".delete").click(function()
	{
		var url=$(this).attr("data-url");
		$.dialog(
		{
			'title':"操作提示",
			'text':"确定要卸载此插件？",
			'oktheme':'btn-info',
			'ok':function(e)
			{
				$.ajax(
				{
					url:url,
					type:'post',
					dataType:'json',
					error:function(e){alert(e.responseText);},
					success:function(d)
					{
						e.close();
						if(d.state=='success')
						{
							sdcms.success(d.msg);
							setTimeout(function(){location.href='{THIS_LOCAL}';},1000);
						}
						else
						{
							sdcms.error(d.msg);
						}
					}
				});
			}
		});
    });
})
</script>
</body>
</html>