<?php

/* ========================================================================
 * $Id: links.php 2049 2020-07-09 00:32:11Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# links
#请求数据
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('links')->delete("id='$id'");
      return $this->ok('删除成功','reload');
    }
    $data=array();
    $data['title']='链接管理';

    $data['btns'][]=array(
      'name'=>'添加链接',
      'href'=>'./edit.php',
      'args'=>'width=1200&height=600&title=添加链接',
    );
    $data['btns'][]=array(
      'name'=>'分类管理',
      'href'=>'/links/linkscategorys/linkscategorys.php',
      'args'=>'width=1200&height=600&title=友链分类管理',
    );
    
    $datatable=$this->load('datatable');
    


    
    $datatable->set('edit',array(
      'event'=>array(
        'option'=>array(
          'width'=>1200,
          'height'=>600,
        ),
      ),
    ));
    $datatable->set('del','1');
    $datatable->set('fields','id');

    $options=array();
    $T2=$G['this']->data()->open('links.categorys')->record("1 order by step desc,id");
    foreach($T2 as $rs){
      $options[$rs['id']]=$rs['name'];
    }
    $datatable->add('分类','upid',array('options'=>$options));
    
    $datatable->add('名称','name',array('function'=>function($rs){
      !$rs['icon'] && $rs['icon']='http://cdn.onez.cn/icons/2020/0627/2020062717291039510001.svg';
      return '<img src="'.$rs['icon'].'" style="width:16px;height:16px" /> '.$rs['name'];
    }));
    $datatable->add('链接地址','link');
    $datatable->add('描述','summary');
    $datatable->add('优先级','step');
    
    $datatable->output($data,array(
      'table'=>'links',

      'where'=>"1$xxx order by step desc,id",
      'pagesize'=>20,
    ));
    $A['pagedata']=$data;
  }
  return;
}
$this->add(array(
  'type'=>'breadcrumb',
  'name'=>'面包屑导航',
  'data'=>'pagedata',
));
$this->add(array(
  'type'=>'datatable',
  'name'=>'数据列表',
  'data'=>'pagedata',
));
?>