rabin 2 anos atrás
pai
commit
8777a70c94
7 arquivos alterados com 69 adições e 30 exclusões
  1. 13 14
      database/data.php
  2. 1 0
      database/func.php
  3. 17 5
      database/page.php
  4. 1 1
      database/page_module.php
  5. 22 9
      lib/Data.php
  6. 1 1
      lib/Manage.php
  7. 14 0
      src/Api.php

+ 13 - 14
database/data.php

@@ -33,24 +33,23 @@ $name = '内容管理';
 if ($info) {
     $info = Dever::db('page/module')->one($info);
 
-    if (!$info) {
-        return;
-    }
-    $function = explode(',', $info['func']);
+    if ($info) {
+        $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 && isset($v['type']) && $v['type'] == 1) {
-                $type_id[] = $v['id'];
+        $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 && isset($v['type']) && $v['type'] == 1) {
+                    $type_id[] = $v['id'];
+                }
             }
         }
-    }
 
-    $type_id = implode(',', $type_id);
+        $type_id = implode(',', $type_id);
+    }
 }
 
 $struct = array

+ 1 - 0
database/func.php

@@ -102,6 +102,7 @@ return array
             'desc'      => '关联字段',
             'match'     => 'is_string',
             'show'		=> 'type=1',
+            //'update_type' => 2,
             'update'    => array
             (
                 array

+ 17 - 5
database/page.php

@@ -86,6 +86,18 @@ return array
             'edit'        => true,
         ),
 
+        'pdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布时间',
+			'match' 	=> array('is_numeric', time()),
+			'default'	=> '',
+			'desc' 		=> '',
+			'update'	=> 'date',
+			'callback'	=> 'maketime',
+			'list'		=> 'date("Y-m-d H:i", {pdate})',
+		),
+
 		'state'		=> array
 		(
 			'type' 		=> 'tinyint-1',
@@ -103,7 +115,7 @@ return array
 			'desc' 		=> '',
 			# 只有insert时才生效
 			'insert'	=> true,
-			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+			'list'		=> 'date("Y-m-d H:i", {cdate})',
 		),
 	),
 
@@ -117,8 +129,8 @@ return array
 		'button' => array
 		(
 			'新增' => array('fast'),
-            '字段配置' => array('list', 'col&oper_parent=page'),
-            '功能配置' => array('list', 'func&oper_parent=page'),
+            '字段配置' => array('list', 'col&parent=page'),
+            '功能配置' => array('list', 'func&parent=page'),
 		),
 		# 快捷更新
 		'list_button' => array
@@ -129,10 +141,10 @@ return array
 
 	'default' => array
 	(
-		'col' => '`name`,`key`,`desc`,`state`,`cdate`',
+		'col' => '`name`,`key`,`desc`,`state`,`pdate`,`cdate`',
 		'value' => array
 		(
-			'"默认页面","home","默认页面", 1,' . DEVER_TIME,
+			'"默认页面","home","默认页面", 1,' . DEVER_TIME . ',' . DEVER_TIME,
 		),
 	),
 

+ 1 - 1
database/page_module.php

@@ -84,7 +84,7 @@ return array
 			),
 	        'type' => 'all',
 	        'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
-			'col' => 'id,t_2.*',
+			'col' => 'id,t_2.id,t_2.name,t_2.key,t_2.pic,t_2.desc,t_2.content,t_2.num|key',
 	    ),
 	)
 );

+ 22 - 9
lib/Data.php

@@ -44,13 +44,15 @@ class Data
         $data = $this->getPageData($uri, $cdate);
 
         $result = array();
-        if ($data && $data['module']) {
+        if ($data && $path && $data['module']) {
             foreach ($data['module'] as $k => $v) {
                 $v['config'] = $config;
                 $result[] = Dever::render($path . '/' . $v['key'], $v);
             }
+            return implode("\r\n", $result);
+        } else {
+            return $data;
         }
-        return implode("\r\n", $result);
     }
 
     # 获取某个页面的数据
@@ -64,6 +66,10 @@ class Data
         }
         $data = Dever::db('page/page')->find($where);
         if ($data) {
+            $data['pdate_string'] = date('Y.m.d', $data['pdate']);
+            unset($data['state']);
+            unset($data['reorder']);
+            unset($data['cdate']);
             $data['module'] = Dever::db('page/page_module')->getData(array('page_id' => $data['id']));
             if ($data['module']) {
                 foreach ($data['module'] as $k => $v) {
@@ -152,13 +158,7 @@ class Data
                 }
             }
         }
-        if ($state == 1) {
-            $result = array();
-        } else {
-            $result = $data;
-            $result['cdate_string'] = date($cdate, $result['cdate']);
-        }
-
+        $result = array();
         $lang = Dever::getLang();
         if ($lang) {
             $key = $lang . '_col_';
@@ -170,12 +170,25 @@ class Data
             if ($lang && strstr($k, 'col_') && !$s) {
                 $s = true;
                 $key = 'col_';
+            } elseif ($k == 'id') {
+                if ($state == 1) {
+                    $result[$k]['id'] = $v;
+                } else {
+                    $result['id'] = $v;
+                }
+            } elseif ($k == 'cdate') {
+                if ($state == 1) {
+                    $result[$k]['cdate_string'] = date($cdate, $v);
+                } else {
+                    $result['cdate_string'] = date($cdate, $v);
+                }
             }
             if ($s) {
                 $id = str_replace($key, '', $k);
                 $col_module = Dever::db('page/col')->one($id);
 
                 if (!$col_module) {
+                    
                     continue;
                 }
                 if (!$v && $source && $col) {

+ 1 - 1
lib/Manage.php

@@ -19,7 +19,7 @@ class Manage
         $func = Dever::db('page/module')->config['func'];
         $func = $func();
         $method = false;
-        if ($func && $type && isset($func[$type])) {
+        if ($func && $type && isset($func[$type]['search'])) {
             $method = $func[$type]['search'];
         }
 

+ 14 - 0
src/Api.php

@@ -6,6 +6,7 @@ use Dever;
 
 class Api
 {
+	/*
 	public function test()
 	{
 		return Dever::load('page/lib/data')->get('focus', '焦点图', 5);
@@ -14,5 +15,18 @@ class Api
 	public function test_1()
 	{
 		return Dever::load('page/lib/data')->getPage(1);
+	}*/
+
+	# 获取页面下的数据
+	public function page()
+	{
+		$path = Dever::input('path');
+		return Dever::load('page/lib/data')->getPage($path);
+	}
+
+	# 获取模块下的数据
+	public function module()
+	{
+		return Dever::load('page/lib/data')->get(Dever::input('key'), Dever::input('name'), Dever::input('num', 10));
 	}
 }