<?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="borders">
        <!---->
        <div class="tabs tabs-white" data-href="1">
            <ul class="tabs-nav">
              <li class="active"><a href="{THIS_LOCAL}">插件管理</a></li>
            </ul>
            <div class="tabs-content">
                <div class="tabs-pane active">
                    <!--loop-->
                    <div class="piclist piclist-col-4 piclist-4-3">
                        {foreach $folder as $key=>$val}
                        {php list($name,$info)=$val}
                        <div class="piclist-item">
                            <div class="piclist-image">{if C('plug_'.$name)}{if $info['admin']}<a href="{U("plug/".$name."/admin")}">{/if}{/if}<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect width="100%" height="100%" fill="#F7F7F7" /><text x="50%" y="50%" fill="#555" dy=".3em">{$info['title']}</text></svg>{if C('plug_'.$name)}{if $info['admin']}</a>{/if}{/if}{if C('plug_'.$name)}<em>已安装</em>{/if}</div>
                            <div class="piclist-body">
                                <div class="piclist-flex">
                                    <div class="piclist-price"><a href="{$info['url']}" target="_blank" class="text-gray">作者：{$info['author']}</a></div>
                                    <div class="action">{if C('plug_'.$name)}<a href="javascript:;" class="delete btn" data-url="{U('delete','name='.$name.'')}">卸载</a>{else}<a href="javascript:;" class="install btn btn-blue" data-url="{U('install','name='.$name.'')}">安装</a>{/if}</div>
                                </div>
                            </div>
                        </div>
                        {/foreach}
                    </div>
                    <!--loop-->
                </div>
            </div>
        </div>
        <!---->
    </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>