<?php

$audit = Dever::config('base')->audit;


$copyright = array
(
    1 => '原创',
    2 => '非原创',
);

$wechat = function()
{
    $array = array();
    $info = Dever::db('spider/wechat')->state();
    if($info)
    {
        $array += $info;
    }
    return $array;
};

return array
(
    # 表名
    'name' => 'data',
    # 显示给用户看的名称
    'lang' => '文章列表',
    'order' => 100,
    'end' => array
    (
        'update' => 'spider/lib/get.up',
        'update_audit' => 'spider/lib/get.up',
    ),

    # 同步更新另外一个或多个表的数据
    /*
    'syncone' => array
    (
        'audit/data' => array
        (
            # 更新另外一个表的字段 => 本表的字段
            'where' => array('data_id' => 'id', 'type' => 1),
            # 要更新的数据
            'update' => array('data_id' => 'id', 'type' => 1, 'pdate' => 'pdate', 'reorder' => 'reorder', 'name' => 'name', 'audit' => 'audit', 'status' => 'status', 'cate_id' => 'cate_id'),
        )
    ),
    */
    # 数据结构
    'struct' => array
    (
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            //'list'        => true,
        ),

        'wechat_id'     => array
        (
            'type'      => 'int-11',
            'name'      => '所属公众号',
            'default'   => '1',
            'desc'      => '所属公众号',
            'match'     => 'is_numeric',
            //'update'    => 'select',
            'option'    => $wechat,
            'search'    => 'select',
            'list'      => true,
        ),
        
        'name'      => array
        (
            'type'      => 'varchar-180',
            'name'      => '标题',
            'default'   => '',
            'desc'      => '标题',
            'match'     => 'is_string',
            'update'    => 'text',
            'list'      => true,
            //增加预览
            'preview'   => true,
        ),

        'copyright'     => array
        (
            'type'      => 'int-11',
            'name'      => '原创',
            'default'   => '1',
            'desc'      => '原创',
            'match'     => 'is_numeric',
            'update'    => 'select',
            'option'    => $copyright,
            'search'    => 'select',
            'list'      => true,
        ),

        'cover'      => array
        (
            'type'      => 'varchar-150',
            'name'      => '封面图',
            'default'   => '',
            'desc'      => '封面图',
            'match'     => 'option',
            'update'    => 'image',
            'key'       => '1',
            'place'     => '150',
        ),

        'state'     => array
        (
            'type'      => 'tinyint-1',
            'name'      => '状态',
            'default'   => '1',
            'desc'      => '请选择状态',
            'match'     => 'is_numeric',
        ),

        'content'       => array
        (
            'type'      => 'text-255',
            'name'      => '内容',
            'default'   => '',
            'desc'      => '请输入内容',
            'match'     => 'is_string',
            'update'    => 'editor',
        ),

        'pdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '发布时间',
            'match'     => 'is_numeric',
            'default'   => '',
            'desc'      => '',
            'update'    => 'date',
            'callback'  => 'maketime',
            'order'     => 'desc',
            'list'      => 'date("Y-m-d H:i:s", {pdate})',
        ),

        'audit'     => array
        (
            'type'      => 'int-11',
            'name'      => '审核状态',
            'default'   => '1',
            'desc'      => '审核',
            'match'     => 'is_numeric',
            'update'  => 'select',
            'option'    => $audit,
            'search'    => 'select',
            'list'      => true,
            'edit'      => true,
        ),

        'cdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '录入时间',
            'match'     => array('is_numeric', time()),
            'desc'      => '',
            # 只有insert时才生效
            'insert'    => true,
        ),
    ),
    
    # 管理功能
    'manage' => array
    (
        'insert' => false,
    ),

    # request 请求接口定义
    'request' => array
    (
        
    ),
);