dever пре 4 година
родитељ
комит
28804d986e

+ 13 - 0
app/content/database/creater.php

@@ -206,5 +206,18 @@ return array
             'order' => array('shou' => 'asc', 'reorder' => 'desc', 'id' => 'desc'),
             'col' => '*|shou|',
         ),
+
+        'getAllByName' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'name' => array('yes', 'like'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*,name as value,name as label|id',
+        ),
     ),
 );

+ 16 - 6
app/content/database/xuniren.php

@@ -149,6 +149,21 @@ return array
             'search'    => 'select',
         ),
 
+        'creater_ids'       => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '关联造物主-直接输入造物主名称,将自动进行匹配出来,之后选择一个即可',
+            'default'   => '',
+            'desc'      => '关联造物主',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //如果要输入带有自动提示的,就打开这个,update=>'text'即可
+            'autocomplete' => array('content/lib/manage.getByCreaterName', 'id', 'content/creater-one#name'),
+            //'list'        => true,
+            //显示
+            //'show'  => 'cate=tag/manage.getByCate?cate=',
+        ),
+
         'waimao'      => array
         (
             'type'      => 'varchar-500',
@@ -339,12 +354,7 @@ return array
     # 更新表结构
     'alter' => array
     (
-        2 => array
-        (
-            array('update', 'birth', 'bdate', 'int-11  出生日期'),
-            //array('add', 'config', 'config', 'int-11 1 配置'),
-        ),
-        'version' => 2,
+        
     ),
 
     # request 请求接口定义

+ 20 - 0
app/content/lib/Manage.php

@@ -6,6 +6,26 @@ use Dever;
 
 class Manage
 {
+    /**
+     * 获取标签信息:根据名称获取多个标签,一般用于autocomplete
+     *
+     * @return mixed
+     */
+    public function getByCreaterName_api()
+    {
+        $data = Dever::db('content/creater')->getAllByName(array
+            (
+                'name' => Dever::input('term'))
+        );
+        if ($data) {
+            return $data;
+        }
+        return array
+            (
+            0 => array('id' => -1, 'value' => '没有找到您搜索的数据', 'label' => '没有找到您搜索的数据'),
+        );
+    }
+
     private function search($table = 'content/news', $type = false)
     {
         $keyword = Dever::input('keyword');

+ 15 - 0
app/content/lib/Xuniren.php

@@ -17,6 +17,7 @@ class Xuniren
         if ($data) {
             foreach ($data as $k => $v) {
                 $data[$k]['link'] = Dever::url('main/xnr-detail?id=' . $v['id']);
+                $data[$k] = $this->getPic($v);
             }
         }
 
@@ -35,17 +36,31 @@ class Xuniren
                 $data[$k]['sname'] = $v['name'] . ' / ' . $v['ename'];
                 $data[$k]['link'] = Dever::url('main/xnr-detail?id=' . $v['id']);
                 $data[$k]['info'] = '<span>简介</span> ' . $v['info'];
+                $data[$k] = $this->getPic($v);
             }
         }
 
         return $data;
     }
 
+    private function getPic($data)
+    {
+        if (strstr($data['pic'], ',')) {
+            $data['pic_list'] = explode(',', $data['pic']);
+            $data['pic'] = $data['pic_list'][0];
+        } else {
+            $data['pic_list'][] = $data['pic'];
+        }
+
+        return $data;
+    }
+
     public function getInfo($id)
     {
         $data = Dever::db('content/xuniren')->one(array('id' => $id));
 
         if ($data) {
+            $data = $this->getPic($data);
             $data['news'] = Dever::array_decode($data['news']);
             if ($data['bdate']) {
                 $data['age'] = $this->birthday($data['bdate']);