rabin 1 jaar geleden
bovenliggende
commit
9354cacdc7
5 gewijzigde bestanden met toevoegingen van 193 en 21 verwijderingen
  1. 31 7
      database/col.php
  2. 110 0
      database/col_option.php
  3. 12 1
      database/data.php
  4. 2 3
      lib/Data.php
  5. 38 10
      lib/Manage.php

+ 31 - 7
database/col.php

@@ -7,7 +7,7 @@ $type = array
 	3 => '编辑器',
 	4 => '单张图片',
 	5 => '多张图片',
-	//6 => '单项选择',
+	6 => '单项选择',
 	//7 => '多项选择',
 	8 => '时间选择',
 );
@@ -17,6 +17,12 @@ $is_option = array
 	1 => '必填',
 	2 => '选填',
 );
+
+$list_show = array
+(
+	1 => '展示',
+	2 => '不展示',
+);
 return array
 (
 	# 表名
@@ -106,6 +112,17 @@ return array
             'edit'		=> true,
         ),
 
+        'list_show'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '列表页是否展示',
+            'default'   => '1',
+            'desc'      => '列表页是否展示',
+            'match'     => 'is_numeric',
+            'update'  	=> 'radio',
+            'option'    => $list_show,
+        ),
+
         'pic'       => array
         (
             'type'      => 'varchar-20',
@@ -117,15 +134,22 @@ return array
             'show'      => 'type=4,5',
         ),
 
-        'option'       => array
+        'page/col_option'       => array
         (
-            'type'      => 'varchar-1000',
-            'name'      => '可选项-每行一个选项,多个直接换行',
+            'name'      => '可选项',
             'default'   => '',
             'desc'      => '可选项',
-            'match'     => 'is_string',
-            'update'    => 'textarea',
-            'show'      => 'type=6,7',
+            'sync'		=> array('col_id' => 'id'),
+            'update'    => array(1),
+            'update_type'      => 2,
+            /*
+            'option'	=> array(0 => array
+            (
+            	//'id' => 1,
+            	'name' => '商品列表页112',
+            	//'value' => 'shoplist11',
+            )),*/
+            'show'		=> 'type=6,7',
         ),
 		
 		'reorder'		=> array

+ 110 - 0
database/col_option.php

@@ -0,0 +1,110 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'col_option',
+	# 显示给用户看的名称
+	'lang' => '字段选项',
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'col_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '字段id',
+			'default' 	=> '',
+			'desc' 		=> '字段id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_col_id'),
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '选项名称',
+			'default' 	=> '',
+			'desc' 		=> '选项名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'value'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '选项值',
+			'default' 	=> '',
+			'desc' 		=> '选项值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+		
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'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' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'col_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc','id' => 'asc'),
+			'col' => 'value as id, name|id',
+		),
+	),
+);

+ 12 - 1
database/data.php

@@ -132,6 +132,7 @@ if ($info) {
         }
     	foreach ($col as $k => $v) {
 
+            $option = false;
             $place = $v['pic'];
             if ($info['col_pic'] && isset($pic_temp[$pic_index]) && $pic_temp[$pic_index]) {
                 $place = $pic_temp[$pic_index];
@@ -157,17 +158,25 @@ if ($info) {
             } elseif ($v['type'] == 4) {
                 $update_type = 'image';
                 $pic_index++;
-                $list = 'Dever::load("page/lib/manage.pic", "{'.$key.'}")';
+                $list = 'Dever::load("page/lib/manage.getPic", "'.$v['id'].'", {id})';
             } elseif ($v['type'] == 5) {
                 $update_type = 'images';
                 $pic_index++;
             } elseif ($v['type'] == 6) {
                 $update_type = 'radio';
+                $option = Dever::db('page/col_option')->getAll(array('col_id' => $v['id']));
+                $list = true;
             } elseif ($v['type'] == 7) {
                 $update_type = 'checkbox';
+                $option = Dever::db('page/col_option')->getAll(array('col_id' => $v['id']));
+                $list = true;
             } elseif ($v['type'] == 8) {
                 $update_type = 'day';
             }
+
+            if ($v['list_show'] == 2) {
+                $list = false;
+            }
             if (!in_array($v['id'], $info['col'])) {
                 $update_type = 'hidden';
                 $list = false;
@@ -188,9 +197,11 @@ if ($info) {
 	            'desc'      => $v['name'],
 	            'match'     => $match,
 	            'update'    => $update_type,
+                'update_bak'    => $update_type,
 	            'place'     => $place,
 	            'key'       => 1,
                 'list'      => $list,
+                'option'    => $option,
 	        );
     	}
     }

+ 2 - 3
lib/Data.php

@@ -140,9 +140,9 @@ class Data
     }
 
     # 获取某条推送位的数据
-    public function getOne($module, $state = 2, $cdate = 'Y-m-d H:i')
+    public function getOne($data, $state = 2, $cdate = 'Y-m-d H:i')
     {
-        $data = is_array($module) ? $module : Dever::db('page/data')->one($module);
+        $data = is_array($data) ? $data : Dever::db('page/data')->one($data);
         $source = array();
         $module = array();
         $col = array();
@@ -188,7 +188,6 @@ class Data
                 $col_module = Dever::db('page/col')->one($id);
 
                 if (!$col_module) {
-                    
                     continue;
                 }
                 if (!$v && $source && $col) {

+ 38 - 10
lib/Manage.php

@@ -9,11 +9,10 @@ class Manage
     public function search_api()
     {
         $type = Dever::input('type');
-        $func = Dever::db('page/module')->config['func'];
-        $func = $func();
+        $func = Dever::db('page/func')->find($type);
         $method = false;
-        if ($func && $type && isset($func[$type]['search'])) {
-            $method = $func[$type]['search'];
+        if ($func && $func['search']) {
+            $method = $func['search'];
         }
 
         if (!$method) {
@@ -27,18 +26,41 @@ class Manage
     {
         $value = Dever::input('value');
         $data = array();
-        $config['type_id'] = Dever::db('page/data')->config['struct']['type_id'];
+        $id = Dever::input('id');
+        if ($id) {
+            $data = Dever::db('page/data')->find($id);
+        }
+
+        $struct = Dever::db('page/data')->config['struct'];
+        $config['type_id'] = $struct['type_id'];
         $config['type_id']['name'] = '关联数据';
         if ($value == -1) {
             $config['type_id']['update'] = 'hidden';
+            foreach ($struct as $k => $v) {
+                if (strstr($k, 'col_')) {
+                    $config[$k] = $v;
+                    $config[$k]['update'] = $v['update_bak'];
+                }
+            }
         } else {
             $config['type_id']['update'] = 'select';
             $config['type_id']['update_search'] = 'page/lib/manage.search?type=' . $value;
-            $id = Dever::input('id');
-            if ($id) {
-                $info = Dever::db('page/data')->find($id);
-                if ($info && $info['type_id']) {
-                    $config['type_id']['update_search_value'] = $info['type_id'];
+            if ($data && $data['type_id']) {
+                $config['type_id']['update_search_value'] = $info['type_id'];
+            }
+
+            $func = Dever::db('page/func')->find($value);
+            if ($func && $func['col']) {
+                $func['col'] = Dever::array_decode($func['col']);
+                $col = array();
+                foreach ($func['col'] as $v) {
+                    $col['col_' . $v['col_id']] = 1;
+                }
+                foreach ($struct as $k => $v) {
+                    if (strstr($k, 'col_') && !isset($col[$k])) {
+                        $config[$k] = $v;
+                        $config[$k]['update'] = 'hidden';
+                    }
                 }
             }
         }
@@ -80,6 +102,12 @@ class Manage
         return $data;
     }
 
+    public function getPic($col, $id)
+    {
+        $info = $this->getData($col, $id);
+        return $this->pic($info);
+    }
+
     public function getData($col, $id)
     {
         $data = Dever::db('page/data')->find($id);