dever 4 năm trước cách đây
mục cha
commit
69a4bef674
3 tập tin đã thay đổi với 119 bổ sung2 xóa
  1. 2 1
      database/data.php
  2. 1 1
      database/func.php
  3. 116 0
      lib/Manage.php

+ 2 - 1
database/data.php

@@ -154,7 +154,7 @@ return array
             'match'     => 'option',
             'update'    => 'select',
             'show'      => 'type=' . $type_id,
-            'update_search' => 'push/lib/manage.search',
+            'update_search' => 'push/lib/manage.search?{type}',
         ),
 
         'data'       => array
@@ -166,6 +166,7 @@ return array
             'match'     => 'is_string',
             'option'    => $data,
             'update'    => $data_update,
+            'list'      => 'Dever::load("push/lib/manage.show", {id})',
         ),
         
         'reorder'       => array

+ 1 - 1
database/func.php

@@ -145,7 +145,7 @@ return array
 			),
 			'type' => 'all',
 			'order' => array('reorder' => 'desc','id' => 'desc'),
-			'col' => '*',
+			'col' => '*|id',
 		),
 		'getAll' => array
 		(

+ 116 - 0
lib/Manage.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace Push\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function search_api()
+    {
+        $keyword = Dever::input('keyword');
+
+        $yes = Dever::input('yes');
+
+        $where = array();
+
+        $type = Dever::input('type');
+
+        $func = Dever::db('push/info')->config['func'];
+        $func = $func();
+        $method = false;
+        if ($func && $type && isset($func[$type])) {
+            $method = $func[$type]['api'];
+        }
+
+        if (!$method) {
+            Dever::alert('暂无数据');
+        }
+
+        $temp = explode('.', $method);
+        $method = $temp[0];
+
+        if ($yes) {
+            $yes = Dever::db($method)->search(array('ids' => $yes));
+        }
+        if (!$keyword) {
+            $where['limit'] = '0,50';
+            $data = Dever::db($method)->search($where);
+        } else {
+            $where['name'] = $keyword;
+            $data = Dever::db($method)->search($where);
+        }
+
+        $result = array();
+        if ($yes) {
+            foreach ($yes as $k => $v) {
+                if (isset($data[$k])) {
+                    unset($data[$k]);
+                }
+                $yes[$k]['selected'] = 'selected';
+            }
+            $data = $yes + $data;
+
+            $data = array_merge($data, array());
+        } else {
+            $data = array_merge($data, array());
+        }
+
+        if (!$data) {
+            Dever::alert('暂无数据');
+        }
+
+        return $data;
+    }
+
+    # 查看图片
+    public function pic($pic)
+    {
+        $table = array();
+        $table[0] = '<img src="'.$pic.'" width=“150”/>';
+
+        return Dever::table($table);
+    }
+
+    public function show($id)
+    {
+        $data = Dever::db('push/data')->one($id);
+
+        $info = array();
+        if ($data['type'] > 0) {
+            $func = Dever::db('push/info')->config['func'];
+            $func = $func();
+            $method = false;
+            if ($func) {
+                foreach ($func as $k => $v) {
+                    if ($v['id'] == $data['type']) {
+                        $method = $v['api'];
+                        break;
+                    }
+                }
+            }
+
+            if ($method) {
+
+            }
+        }
+        $table = array();
+        $text = $data['data'];
+        $text = Dever::array_decode($text);
+        foreach ($text as $k => $v) {
+            $table[$k] = array();
+            foreach ($v as $k1 => $v1) {
+                if (strstr($k1, 'col_')) {
+                    $id = str_replace('col_', '', $k1);
+                    $col = Dever::db('push/col')->one($id);
+                    $table[$k][$col['name']] = $v1;
+                }
+            }
+        }
+
+        if (count($table) == 1) {
+            $table = $table[0];
+        }
+        return Dever::table($table);
+    }
+}