<?php

/* ========================================================================
 * $Id: plugins.php 2249 2020-06-02 16:06:12Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# index
$where=$G['this']->where();
#请求数据
if($MODE=='$post'){
  $action=onez()->gp('action');
  if($action=='data'){
    $action=onez()->gp('ac');
    if($action=='uninstall'){
      $id=(int)onez()->gp('id');
      $G['this']->data()->open('plugins')->delete("id='$id'$where");
      return $this->ok('卸载成功','reload');
    }
    $data=array();
    $data['title']='插件管理';
    $data['btns'][]=array(
      'name'=>'插件市场',
      'href' => '/design/plugins/plugins.php?from=develop',
      'args'=>'classname=&width=1600&height=760&maxmin=1&title=插件市场',
    );
    $datatable=$this->load('datatable');
    $datatable->set('fields','id,index1');
    $datatable->set('colFunc',function(&$rs,&$fields)use($myPluginIds,$buyPluginIds){
      global $G;
      $fields[]='icon';$rs['icon']=$rs['plugin']['icon'];
      $fields[]='name';$rs['name']=$rs['plugin']['name'];
    });

    $datatable->addBtn(array(
      'name'=>'卸载',
      'skin'=>'danger',
      'event'=>array(
        'token'=>'remote',
        'confirm'=>'您确定要卸载这个插件吗？',
        'postdata'=>array(
          'action'=>'data',
          'ac'=>'uninstall',
          'id'=>'${id}',
        ),
      ),
    ));
    
    $datatable->add('名称','name',array(
      'icon'=>'icon',
      'href' => '/onez/view.php?key=/page/plugins/view&id=${index1}&from=develop',
      'args'=>'classname=&width=1200&height=600&maxmin=1&title=查看详情',
    ));
    $x='';
    $siteId=(int)onez()->gp('siteId');
    if($siteId){
      $x=" and upid='$siteId'";
    }else{
      $datatable->add('所属网站','sitename',array('function'=>function($rs){
        global $G;
        return $G['this']->site($rs['upid'],'name');
      }));
    }
    
    $datatable->add('安装时间','addtime',array('type'=>'time'));
    $datatable->output($data,array(
      'table'=>'plugins',
      'where'=>"1$where order by id desc",
      'pagesize'=>20,
    ));
    $A['pagedata']=$data;
  }
  return;
}
$this->add(array(
  'type'=>'breadcrumb',
  'name'=>'面包屑导航',
  'data'=>'pagedata',
));
$this->add(array(
  'type'=>'datatable',
  'name'=>'数据列表',
  'data'=>'pagedata',
));

?>
