dever 4 years ago
parent
commit
e6e790204d
4 changed files with 491 additions and 69 deletions
  1. 1 1
      database/col.php
  2. 242 0
      database/data.php
  3. 45 68
      database/func.php
  4. 203 0
      database/info.php

+ 1 - 1
database/col.php

@@ -166,7 +166,7 @@ return array
 			'option' => array
 			(
 				'state' => 1,
-				# 小程序去掉视频栏目
+				'id' => array('yes', 'in'),
 				'id_no' => array('yes-id', '!='),
 			),
 			'type' => 'all',

+ 242 - 0
database/data.php

@@ -0,0 +1,242 @@
+<?php
+
+# 定义几个常用的选项
+$option = array
+(
+    1 => '显示',
+    2 => '不显示',
+);
+
+$type = Dever::db('push/info')->config['func'];
+$type = $type();
+
+$list = function()
+{
+    return Dever::db('push/info')->state();
+};
+$info = Dever::input('search_option_info_id');
+$type_default = -1;
+
+$data = array
+(
+    1 => '内容自定义',
+);
+
+$data_update = array();
+
+if ($info) {
+    $info = Dever::db('push/info')->one($info);
+
+    if (!$info) {
+        echo 'error';die;
+    }
+    $function = explode(',', $info['func']);
+    
+    $type_id = array();
+    foreach ($type as $k => $v) {
+        if (!in_array($v['id'], $function)) {
+            unset($type[$k]);
+        } else {
+            $type_default = $v['id'];
+            if ($v['id'] > 0) {
+            	$type_id[] = $v['id'];
+            }
+        }
+    }
+
+    $type_id = implode(',', $type_id);
+
+    $info['name'] .= '下的推送数据管理';
+
+    $col = Dever::db('push/col')->getAll(array('id' => $info['col']));
+
+    if ($col) {
+    	foreach ($col as $k => $v) {
+
+    		$place = $v['pic'];
+    		if ($v['type'] == 1) {
+    			$update_type = 'text';
+    		} elseif ($v['type'] == 2) {
+    			$update_type = 'textarea';
+    		} elseif ($v['type'] == 3) {
+    			$update_type = 'editor';
+    		} elseif ($v['type'] == 4) {
+    			$update_type = 'image';
+    		} elseif ($v['type'] == 5) {
+    			$update_type = 'images';
+    		} elseif ($v['type'] == 6) {
+    			$update_type = 'radio';
+    		} elseif ($v['type'] == 7) {
+    			$update_type = 'checkbox';
+    		} elseif ($v['type'] == 8) {
+    			$update_type = 'day';
+    		}
+    		$data_update[] = array
+	        (
+	            'col'       => 'col_' . $v['id'],
+	            'name'      => $v['name'],
+	            'default'   => '',
+	            'desc'      => $v['name'],
+	            'match'     => 'is_string',
+	            'update'    => $update_type,
+	            'place'     => $place,
+	            'key'       => 1,
+	        );
+    	}
+    }
+
+} else {
+    $info = array();
+    $info['name'] = '推送数据管理';
+    $type_id = '0';
+}
+
+
+return array
+(
+    # 表名
+    'name' => 'data',
+    # 显示给用户看的名称
+    'lang' => $info['name'],
+    'order' => 20,
+    //'menu' => false,
+
+    //'desc' => '预览地址:<br /><iframe id="preview" height="'.$preview_height.'" width="100%"  frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes" src="'.$preview.'" ></iframe>',
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'  => 'order',
+            'order'     => 'desc',
+            //'list'        => true,
+        ),
+
+        'info_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属推送位',
+            'default'   => Dever::input('search_option_info_id', '1'),
+            'desc'      => '推送位',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'update'    => 'hidden',
+            'option'    => $list,
+            'list'      => true,
+            'value'     => Dever::input('search_option_info_id', '1'),
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '功能类型',
+            'default'   => ''.$type_default.'',
+            'desc'      => '请选择功能类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'search'    => 'select',
+            'option'    => $type,
+            'control'   => 'type',
+        ),
+
+        'type_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '关联数据',
+            'default'   => '',
+            'desc'      => '关联数据',
+            'match'     => 'option',
+            'update'    => 'select',
+            'show'      => 'type=' . $type_id,
+            'update_search' => 'push/lib/manage.search',
+        ),
+
+        'data'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '自定义数据项',
+            'default'   => '',
+            'desc'      => '自定义数据项',
+            'match'     => 'is_string',
+            'option'    => $data,
+            'update'    => $data_update,
+        ),
+        
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => 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})',
+        ),
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        # 获取列表页
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'type_no' => array('yes-type', '!='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'limit' => '0,10',
+            'col' => '*',
+        ),
+
+        # 获取列表页 带有分页的
+        'getAllPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'type_no' => array('yes-type', '!='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+    ),
+);

+ 45 - 68
database/func.php

@@ -1,16 +1,19 @@
 <?php
 
-$type = array
-(
-	1 => '普通文本',
-	2 => '长文本',
-	3 => '编辑器',
-	4 => '单张图片',
-	5 => '多张图片',
-	6 => '单项选择',
-	7 => '多项选择',
-	8 => '时间选择',
-);
+$col = function()
+{
+    $array = array
+    (
+        -1 => array('id' => '-1', 'name' => '请选择字段',),
+    );
+    $info = Dever::db('push/col')->state();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
 return array
 (
 	# 表名
@@ -47,52 +50,48 @@ return array
 			'list'		=> true,
 		),
 
-		'desc'		=> array
+		'api'		=> array
 		(
 			'type' 		=> 'varchar-200',
-			'name' 		=> '字段描述',
+			'name' 		=> '功能接口-可以直接输入http接口地址,也可以使用dever接口,如果接口返回一条数据,就为单条,如果是多条,就是列表',
 			'default' 	=> '',
-			'desc' 		=> '字段描述',
+			'desc' 		=> '功能接口',
 			'match' 	=> 'is_string',
-			'update'	=> 'text',
+			'update'	=> 'textarea',
 			'search'	=> 'fulltext',
 			'list'		=> true,
 		),
 
-		'type'        => array
+		'col'       => array
         (
-            'type'      => 'tinyint-1',
-            'name'      => '类型',
-            'default'   => '1',
-            'desc'      => '类型',
-            'match'     => 'is_numeric',
-            'update'  	=> 'select',
-            'option'    => $type,
-            'search'    => 'select',
-            'list'      => true,
-            'control'	=> 'type',
-        ),
-
-        'pic'       => array
-        (
-            'type'      => 'varchar-20',
-            'name'      => '图片尺寸提醒-请直接输入提醒的文字即可,如100*100',
+            'type'      => 'text-1000',
+            'name'      => '关联字段',
             'default'   => '',
-            'desc'      => '图片尺寸提醒',
+            'desc'      => '关联字段',
             'match'     => 'is_string',
-            'update'    => 'text',
-            'show'      => 'type=4,5',
-        ),
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'name',
+                    'name'      => '接口原始字段名-输入上述功能接口返回的原始字段的名字',
+                    'default'   => '',
+                    'desc'      => '接口原始字段名',
+                    'match'     => 'is_string',
+                    'update'    => 'text',
+                ),
 
-        'option'       => array
-        (
-            'type'      => 'varchar-1000',
-            'name'      => '可选项-每行一个选项,多个直接换行',
-            'default'   => '',
-            'desc'      => '可选项',
-            'match'     => 'is_string',
-            'update'    => 'text',
-            'show'      => 'type=6,7',
+                array
+                (
+                    'col'       => 'col_id',
+                    'name'      => '关联的字段',
+                    'default'   => '',
+                    'desc'      => '关联的字段',
+                    'match'     => 'is_numeric',
+                    'update'    => 'select',
+                    'option'    => $col,
+                ),
+            ),
         ),
 		
 		'reorder'		=> array
@@ -130,31 +129,9 @@ return array
 		),
 	),
 
-	# 默认值
-	'default' => array
-	(
-		'col' => 'name,state,cdate',
-		'value' => array
-		(
-			'"标题",1,' . time(),
-		),
-	),
-
 	'manage' => array
 	(
-		'insert' => false,
-		'edit' => false,
-
-		# 自定义快捷新增和编辑
-		'button' => array
-		(
-			'新增' => array('fast'),
-		),
-		# 快捷更新
-		'list_button' => array
-		(
-			'edit' => array('编辑'),
-		),
+		
 	),
 
 	'request' => array

+ 203 - 0
database/info.php

@@ -0,0 +1,203 @@
+<?php
+
+$func = function()
+{
+    $array = array
+    (
+        -1 => array('id' => '-1', 'name' => '自定义',),
+    );
+    $info = Dever::db('push/func')->state();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$col = function()
+{
+    $array = array
+    (
+        
+    );
+    $info = Dever::db('push/col')->state();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+return array
+(
+    # 表名
+    'name' => 'info',
+    # 显示给用户看的名称
+    'lang' => '推送位管理',
+    'order' => 10,
+    'check' => 'key',
+    'func' => $func,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '推送位ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'  => 'order',
+            'order'     => 'desc',
+            //'list'        => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '推送位标题',
+            'default'   => '',
+            'desc'      => '请输入推送位标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'key'       => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '推送位标识',
+            'default'   => '',
+            'desc'      => '推送位标识',
+            'match'     => 'is_string',
+            'update'    => Dever::input('where_id') ? 'hidden' : 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '数据显示条数-为空或小于0则取默认值10,只对前台有效,当有分页时,则为每页显示的条数',
+            'default'   => '10',
+            'desc'      => '数据显示条数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'func'       => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '功能类型',
+            'default'   => '',
+            'desc'      => '功能类型',
+            'match'     => 'is_string',
+            'option'    => $func,
+            'update'    => 'checkbox',
+        ),
+
+        'col'       => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '启用的字段',
+            'default'   => '',
+            'desc'      => '请选择启用的字段',
+            'match'     => 'is_string',
+            'option'    => $col,
+            'update'    => 'checkbox',
+        ),
+        
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'        => 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})',
+        ),
+    ),
+
+    # 权限精细控制 加入到该项目的详细权限中,注意与top的不同
+    /*
+    'auth' => array
+    (
+        # 数据来源
+        'data' => 'all',
+        # 所属项目
+        'project' => 'module',
+        # 项目名称
+        'project_name' => '推送位管理',
+    ),
+    */
+
+    'manage' => array
+    (
+        'delete' => false,
+        //'edit' => false,
+        //'insert' => $curPage ? true : false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            //'新增兑换码' => array('fast', 1, 'config&where_id=1'),
+            '字段配置' => array('list', 'col&project=push&oper_parent=info&oper_project=push'),
+            '功能配置' => array('list', 'func&project=push&oper_parent=info&oper_project=push'),
+        ),
+
+        'list_button' => array
+        (
+            'add' => array('新增数据', '"data&search_option_info_id={id}&oper_parent=info"'),
+
+            'list' => array('数据列表', '"data&search_option_info_id={id}&oper_parent=info"'),
+        ),
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        # 获取列表页
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'type' => 'yes',
+                //'page_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);