123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <?php
- # 定义几个常用的选项
- $option = array
- (
- 1 => '正常',
- 2 => '删除',
- );
- $cate = function () {
- $array = array();
- $cate = Dever::load('doc/cate-mainAll');
- if ($cate) {
- $array += $cate;
- }
- return $array;
- };
- $cate_child = function () {
- $cate = Dever::load('doc/cate-childAll');
- return $cate;
- };
- # 分类
- $search_cate = function () {
- $array = array
- (
- -1 => array('id' => '-1', 'name' => '所有分类'),
- );
- $cate = Dever::load('doc/cate.all');
- if ($cate) {
- $array += $cate;
- }
- return $array;
- };
- return array
- (
- # 表名
- 'name' => 'posts',
- # 显示给用户看的名称
- 'lang' => '文档',
- 'order' => 9,
- # 数据结构
- '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' => '"<a href=\"".Dever::url("doc/view?id={id}","main")."\" target=\"_blank\" >{name}</a>"',
- ),
- 'author' => array
- (
- 'type' => 'varchar-100',
- 'name' => '作者',
- 'default' => Dever::load('manage/auth.info#username'),
- 'desc' => '请填写作者',
- 'match' => 'is_string',
- 'update' => 'text',
- 'search' => 'fulltext',
- 'list' => true,
- ),
- 'cate_id_parent' => array
- (
- 'type' => 'int-11',
- 'name' => '父级分类',
- 'default' => '0',
- 'desc' => '请选择父级分类',
- 'match' => 'is_numeric',
- 'update' => 'select',
- //'search' => 'order,select',
- 'option' => $cate,
- # 当值改变时,执行下一步操作
- 'child_name' => 'cate_id',
- 'child' => $cate_child,
- 'child_value' => '{cate_id}',
- ),
- 'cate_id' => array
- (
- 'type' => 'int-11',
- 'name' => '子分类',
- 'default' => '0',
- 'desc' => '请选择子分类',
- 'match' => 'is_numeric',
- //'search' => 'order',
- 'list_name' => '分类',
- 'list' => '{cate_id} > 0 ? Dever::load("doc/cate-one#name", {cate_id}) : "无子分类"',
- ),
- 'num_view' => array
- (
- 'type' => 'int-11',
- 'name' => '浏览量',
- 'default' => '0',
- 'desc' => '请填写浏览量',
- 'match' => 'option',
- 'search' => 'order',
- 'list' => true,
- ),
- 'info' => array
- (
- 'type' => 'varchar-500',
- 'name' => '简介',
- 'default' => '',
- 'desc' => '请输入简介',
- 'match' => 'is_string',
- 'update' => 'textarea',
- ),
- //使用请直接$data['content'] = json_decode(base64_decode($data['content']), true);
- 'content' => array
- (
- 'type' => 'text-255',
- 'name' => '内容',
- 'default' => '',
- 'desc' => '请输入内容',
- 'match' => 'is_string',
- 'update' => array
- (
- array
- (
- 'col' => 'title',
- 'name' => '标题',
- 'default' => '',
- 'desc' => '请输入标题',
- 'match' => 'is_string',
- 'update' => 'text',
- ),
- array
- (
- 'col' => 'content',
- 'name' => '内容',
- 'default' => '',
- 'desc' => '请输入内容',
- 'match' => 'is_string',
- 'update' => 'editor',
- ),
- ),
- ),
- 'state' => array
- (
- 'type' => 'tinyint-1',
- 'name' => '状态',
- 'default' => '1',
- 'desc' => '请选择状态',
- 'match' => 'is_numeric',
- 'option' => $option,
- 'update' => 'radio',
- 'list' => true,
- ),
- 'cdate' => array
- (
- 'type' => 'int-11',
- 'name' => '录入时间',
- 'match' => array('is_numeric', time()),
- 'desc' => '',
- # 只有insert时才生效
- 'insert' => true,
- 'list' => 'date("Y-m-d H:i:s", {cdate})',
- ),
- ),
- # request 请求接口定义
- 'request' => array
- (
- # 更新浏览量
- 'addView' => array
- (
- 'type' => 'update',
- 'where' => array
- (
- 'id' => 'yes',
- ),
- 'set' => array
- (
- 'num_view' => array('1', '+='),
- ),
- ),
- ),
- );
|