123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <?php
- # 定义几个常用的选项
- $option = array
- (
- 1 => '发布',
- 2 => '未发布',
- );
- $channel = function()
- {
- $array = array();
- $channel = Dever::db('atom/channel')->parent();
- if ($channel) {
- $array += $channel;
- }
- return $array;
- };
- $channel_child = function()
- {
- $channel = Dever::db('atom/channel')->child();
- return $channel;
- };
- # 栏目
- $search_channel = function()
- {
- $array = array
- (
- -1 => array('id' => '-1', 'name' => '所有栏目'),
- );
- $channel = Dever::load('atom/service/article/channel.all');
- if ($channel) {
- $array += $channel;
- }
- return $array;
- };
- return array
- (
- # 表名
- 'name' => 'article',
- # 显示给用户看的名称
- 'lang' => '文章',
- 'order' => 20,
- # 数据结构
- 'struct' => array
- (
-
- 'id' => array
- (
- 'type' => 'int-11',
- 'name' => 'ID',
- 'default' => '',
- 'desc' => '',
- 'match' => 'is_numeric',
- 'search' => 'order',
- 'list' => true,
- ),
-
- 'name' => array
- (
- 'type' => 'varchar-80',
- 'name' => '标题',
- 'default' => '',
- 'desc' => '请输入主题标题',
- 'match' => 'is_string',
- 'update' => 'text',
- 'search' => 'fulltext',
- 'list' => true,
- ),
- 'author' => array
- (
- 'type' => 'varchar-80',
- 'name' => '作者-请填写用户id',
- 'default' => '1',
- 'desc' => '请填写作者',
- 'match' => 'is_string',
- 'update' => 'text',
- //'search' => 'select',
- 'list' => true,
- ),
-
- 'channel_id_parent' => array
- (
- 'type' => 'int-11',
- 'name' => '父级栏目',
- 'default' => '0',
- 'desc' => '请选择父级栏目',
- 'match' => 'is_numeric',
- 'update' => 'select',
- //'search' => 'order,select',
- //'list' => '{channel_id_parent} > 0 ? Dever::load("atom/channel-one#name", {channel_id_parent}) : "临时栏目"',
- 'option' => $channel,
- # 当值改变时,执行下一步操作
- 'child_name' => 'channel_id',
- 'child' => $channel_child,
- 'child_value' => '{channel_id}',
- ),
-
- 'channel_id' => array
- (
- 'type' => 'int-11',
- 'name' => '子栏目',
- 'default' => '0',
- 'desc' => '请选择子栏目',
- 'match' => 'is_numeric',
- //'search' => 'order',
- 'list_name' => '栏目',
- 'list' => '{channel_id} > 0 ? Dever::load("atom/channel-one#name", {channel_id}) : "无子栏目"',
- ),
-
- 'reorder' => array
- (
- 'type' => 'int-11',
- 'name' => '排序(数值越大越靠前)',
- 'default' => '1',
- 'desc' => '请输入排序',
- 'match' => 'option',
- 'update' => 'text',
- 'search' => 'order',
- 'list_name' => '排序',
- 'list' => true,
- 'order' => 'desc',
- 'edit' => true,
- ),
- 'pic' => array
- (
- 'type' => 'varchar-200',
- 'name' => '封面标准图-请上传等比例图片300X300',
- 'default' => '',
- 'desc' => '封面标准图',
- 'match' => 'is_string',
- 'update' => 'image',
- 'key' => 1
- ),
-
- 'content' => array
- (
- 'type' => 'text-255',
- 'name' => '内容',
- 'default' => '',
- 'desc' => '请输入内容',
- 'match' => 'is_string',
- 'update' => 'editor',
- 'key' => 1,
- ),
- 'status' => array
- (
- 'type' => 'tinyint-1',
- 'name' => '状态',
- 'default' => '1',
- 'desc' => '请选择状态',
- 'match' => 'is_numeric',
- 'option' => $option,
- 'update' => 'radio',
- 'list' => true,
- ),
- 'state' => array
- (
- 'type' => 'tinyint-1',
- 'name' => '状态',
- 'default' => '1',
- 'desc' => '请选择状态',
- 'match' => 'is_numeric',
- ),
-
- 'cdate' => array
- (
- 'type' => 'int-11',
- 'name' => '录入时间',
- 'match' => array('is_numeric', time()),
- 'desc' => '',
- # 只有insert时才生效
- 'insert' => true,
- 'list' => 'date("Y-m-d H:i:s", {cdate})',
- ),
- ),
-
- # 管理功能
- 'manage' => array
- (
- //'insert' => false,
- # 列表
- 'list' => array
- (
- array
- (
- 1 => array('分页', '"page&option_article_id={id}"')
- ),
- ),
- ),
-
- # request 请求接口定义
- 'request' => array
- (
- # 获取默认主题,按照置顶和时间排序的
- 'default' => array
- (
- # 匹配的正则或函数 选填项
- 'option' => array
- (
- 'cate_id' => 'yes',
- 'cate_id_parent' => 'yes',
- 'uid' => 'yes',
- ),
- 'type' => 'all',
- 'order' => array('top' => 'desc', 'reorder' => 'desc', 'id' => 'desc'),
- 'page' => array(15, 'list'),
- 'col' => '*',
- ),
- # 更新浏览量
- 'addView' => array
- (
- 'type' => 'update',
- 'where' => array
- (
- 'id' => 'yes',
- ),
- 'set' => array
- (
- 'num_view' => array('1', '+='),
- ),
- ),
-
- # 更新回复数
- 'addReview' => array
- (
- 'type' => 'update',
- 'where' => array
- (
- 'id' => 'yes',
- ),
- 'set' => array
- (
- 'num_review' => array('1', '+='),
- ),
- ),
-
- # 更新点赞数
- 'addUp' => array
- (
- 'type' => 'update',
- 'where' => array
- (
- 'id' => 'yes',
- ),
- 'set' => array
- (
- 'num_up' => array('1', '+='),
- ),
- ),
-
- # 更新点赞数
- 'desUp' => array
- (
- 'type' => 'update',
- 'where' => array
- (
- 'id' => 'yes',
- ),
- 'set' => array
- (
- 'num_up' => array('1', '-='),
- ),
- ),
- ),
- );
|