<?php

/* ========================================================================
 * $Id: slide.php 1646 2020-07-09 00:27:30Z 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=='del'){
      $id=(int)onez()->gp('id');
      $G['this']->data()->open('slide')->delete("id='$id'$where");
      return $this->ok('删除成功','reload');
    }
    $data=array();
    $data['title']='幻灯片管理';
    $data['btns'][]=array(
      'name'=>'添加幻灯片',
      'href'=>'./edit.php',
      'args'=>'width=800&height=600&title=添加幻灯片',
    );
    
    $datatable=$this->load('datatable');
    
    
    $datatable->set('edit',array(
      'event'=>array(
        'option'=>array(
          'width'=>600,
          'height'=>500,
        ),
      ),
    ));
    $datatable->set('del','1');
    $datatable->set('fields','id');
    $options=array();
    $options['slide']='幻灯片';
    $options['link']='活动';
    $datatable->add('位置','key1',array('options'=>$options));

    $datatable->add('图片地址','pic',array('function'=>function($rs){
      return '<img src="'.$rs['pic'].'" style="width:80px;height:50px" />';
    },));
    $datatable->add('标题','subject');
    $datatable->add('链接地址','link');
    $datatable->output($data,array(
      'table'=>'slide',
      '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',
));
?>