{include file="head.html"}
<div id="maincontent">
  <div class="wrap">
    <div class="crumbs"> <a href="__APP__/index/home">{lang='插件'}</a> <a href="__URL__">{lang='插件管理器'}</a> </div>
    <hr /><br />

    <table class="list_table table_style">
      <thead>
         <tr>
            <th width="30%"><div align="center">{lang='插件名称'}</div></th>
            <th width="20%"><div align="center">{lang='开发者'}</div></th>
            <th width="20%"><div align="center">{lang='说明'}</div></th>
            <th width="10%"><div align="center">{lang='状态'}</div></th>
            <th width="20%"><div align="center">{lang='管理操作'}</div></th>
          </tr>
      </thead>      
      <?php if(is_array($list)) foreach ($list as $vo) { ?>
        <?php
        $condition['PLUS_NAME'] = $vo['PLUS_NAME'];
        $module_list = module('common')->model->table('extend')->where($condition)->select();
        if (!empty($module_list)) foreach ($module_list as $mod_vo) { ?>
        <tr>
        <td align="center">{$mod_vo['NAME']} - {$mod_vo['VER']}</td>
        <td align="center">{$mod_vo['AUTHOR']}</td>
        <td align="center"><a href="#" onClick="help('__URL__/info-{$mod_vo['PLUS_NAME']}')">{lang='查看说明'}</a></td>
        <td align="center">
        <?php if($mod_vo['OPEN']){?>
        <a href="#" onClick="open_extend('{$mod_vo['PLUS_NAME']}')">{lang='开启'}</a>
        <?php }else{?>
        <a href="#" onClick="close_extend('{$mod_vo['PLUS_NAME']}')">{lang='关闭'}</a>
        <?php }?>
        </td>
        <td align="center">
        <a href="#" onClick="uninstall('{$mod_vo['PLUS_NAME']}')">{lang='卸载插件'}</a>
        </td>
        </tr>
        <?php }else{ ?>
        <tr>
        <td align="center">{$vo['NAME']} - {$vo['VER']}</td>
        <td align="center">{$vo['AUTHOR']}</td>
        <td align="center">{lang='未安装'}</td>
        <td align="center">
        {lang='关闭'}
        </td>
        <td align="center">
        <a href="#" style="color:#F00" onClick="install('{$vo['PLUS_NAME']}')">{lang='安装插件'}</a>
        </td>
        </tr>        
        <?php }} ?>
    </table>
  </div>
</div>
<script>
//开启
function open_extend(name)
{
$.ajax({
  type: 'POST',
  url: '__URL__/open',
  data: {
			name: name
		},
  dataType: "json",
  success: function(json) {
	window.location.href='__URL__';
  }
});
}
</script>
<script>
//关闭
function close_extend(name)
{
$.ajax({
  type: 'POST',
  url: '__URL__/close',
  data: {
			name: name
		},
  dataType: "json",
  success: function(json) {
	window.location.href='__URL__';
  }
});
}
</script>
<script>
function install(name)
{
  parent.asyncbox.confirm('{lang='是否安装该插件?'}', '{lang='操作提示'}',
	function(action) {　　　　
	if (action == 'ok') {
	$.ajax({
	type: 'POST',
	url: '__URL__/install',
	data: {
			name: name
		},
	dataType: "json",
	success: function(json) {
	window.location.href='__URL__';
	}
	});　
	}	　　
  });
}
</script>
<script>
function uninstall(name)
{
  parent.asyncbox.confirm('{lang='是否安装该插件?'}', '{lang='操作提示'}',
	function(action) {　　　　
	if (action == 'ok') {
	$.ajax({
	type: 'POST',
	url: '__URL__/uninstall',
	data: {
			name: name
		},
	dataType: "json",
	success: function(json) {
	window.location.href='__URL__';
	}
    });
	}	　　
  });
}
</script>
<script>
function help(url){ 
  parent.asyncbox.open({
	 title: "{lang='插件说明'}",
　　　url : url,
　　　width : 500,
　　　height : 340
　});
};
</script> 
</body></html>