123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?php
- $category = Dever::input('search_option_category');
- $table = '';
- $attr = array();
- $create = Dever::config('database')->create;
- if ($category) {
- $where['category'] = $category;
- $attr = Dever::db('category/attr')->one($where);
- if ($attr) {
- $table = '_' . str_replace(',', '_', $category);
- # 自动建表开启并且自动添加字段
- $create = false;
- $attr = Dever::load('attr/api')->getValue($attr['attr'], $attr['attr_input']);
- }
- }
- $config = array
- (
- # 表名
- 'name' => 'info_attr' . $table,
- # 显示给用户看的名称
- 'lang' => '需求属性',
- 'order' => 100,
- 'menu' => false,
- 'create' => $create,
- 'attr' => $attr,
- 'end' => array
- (
- //'insert' => 'demand/lib/manage.attrUpdate',
- //'update' => 'demand/lib/manage.attrUpdate',
- ),
- # 数据结构 不同的字段放这里
- 'struct' => array
- (
- 'id' => array
- (
- 'type' => 'int-11',
- 'name' => 'ID',
- 'default' => '',
- 'desc' => '',
- 'match' => 'is_numeric',
- //'list' => true,
- ),
- ),
-
- # 管理功能
- 'manage' => array
- (
- ),
- # request 请求接口定义
- 'request' => array
- (
-
- ),
- );
- # 属性完全自定义吧。这种情况用dever就是方便了。其他框架都需要自己实现
- if ($attr) {
- foreach ($attr as $k => $v) {
- $k = 'attr_' . $v['id'];
- $config['struct'][$k] = array();
- $option = array();
- if ($v['type_option']) {
- $v['type_option'] = explode("\n", $v['type_option']);
- foreach ($v['type_option'] as $k1 => $v1) {
- $option[$k1+1] = $v1;
- }
- }
- $config['struct'][$k]['name'] = $v['name'];
- $config['struct'][$k]['default'] = '';
- $config['struct'][$k]['desc'] = $v['name'];
- switch ($v['type']) {
- case 2:
- $config['struct'][$k]['update'] = 'textarea';
- $config['struct'][$k]['search'] = 'fulltext';
- $config['struct'][$k]['type'] = 'varchar-800';
- $config['struct'][$k]['match'] = 'is_string';
- break;
- case 3:
- $config['struct'][$k]['type'] = 'text-255';
- $config['struct'][$k]['update'] = 'editor';
- $config['struct'][$k]['match'] = 'is_string';
- $config['struct'][$k]['key'] = 1;
- case 4:
- $config['struct'][$k]['update'] = 'image';
- $config['struct'][$k]['type'] = 'varchar-150';
- $config['struct'][$k]['match'] = 'is_string';
- $config['struct'][$k]['key'] = 1;
- break;
- case 5:
- $config['struct'][$k]['update'] = 'images';
- $config['struct'][$k]['type'] = 'text-255';
- $config['struct'][$k]['match'] = 'is_string';
- $config['struct'][$k]['key'] = 1;
- break;
- case 6:
- $config['struct'][$k]['type'] = 'varchar-800';
- $config['struct'][$k]['match'] = 'is_string';
- $config['struct'][$k]['update'] = 'linkage';
- $config['struct'][$k]['search'] = 'linkage';
- $config['struct'][$k]['option'] = Dever::url('area/api.get');
- //$config['struct'][$k]['list'] = 'Dever::load("area/api.string", "{area}")';
- break;
- case 10:
- $config['struct'][$k]['update'] = 'radio';
- $config['struct'][$k]['type'] = 'int-11';
- $config['struct'][$k]['match'] = 'is_numeric';
- $config['struct'][$k]['option'] = $option;
- $config['struct'][$k]['search'] = 'select';
- $config['struct'][$k]['default'] = 1;
- break;
- case 11:
- $config['struct'][$k]['update'] = 'checkbox';
- $config['struct'][$k]['type'] = 'varchar-150';
- $config['struct'][$k]['match'] = 'is_string';
- $config['struct'][$k]['option'] = $option;
- $config['struct'][$k]['search'] = 'select';
- $config['struct'][$k]['default'] = 1;
- break;
- case 12:
- $config['struct'][$k]['update'] = 'select';
- $config['struct'][$k]['type'] = 'int-11';
- $config['struct'][$k]['match'] = 'is_numeric';
- $config['struct'][$k]['option'] = $option;
- $config['struct'][$k]['search'] = 'select';
- $config['struct'][$k]['default'] = 1;
- break;
-
- default:
- $config['struct'][$k]['update'] = 'text';
- $config['struct'][$k]['search'] = 'fulltext';
- if ($v['data_type'] == 1) {
- $config['struct'][$k]['type'] = 'int-11';
- $config['struct'][$k]['match'] = 'is_numeric';
- } else {
- $config['struct'][$k]['type'] = 'varchar-800';
- $config['struct'][$k]['match'] = 'is_string';
- }
- }
- if ($v['option_type'] && $v['option_type'] == 2) {
- $config['struct'][$k]['match'] = 'option';
- }
- }
- }
- return $config;
|