ソースを参照

add mbspecial keywords

stanley-king 7 年 前
コミット
feea9b40e0
2 ファイル変更43 行追加11 行削除
  1. 38 9
      admin/control/mb_special.php
  2. 5 2
      admin/templates/default/mb_special.list.php

+ 38 - 9
admin/control/mb_special.php

@@ -103,6 +103,44 @@ class mb_specialControl extends SystemControl
         Tpl::showpage('mb_special.list');
     }
 
+    public function discoveryOp()
+    {
+        $special_id = intval($_REQUEST['search_special_id']);
+        $special_desc = trim($_REQUEST['special_desc']);
+
+        if($special_id > 0) {
+            $cond = array("special_id" => $special_id);
+        }
+        elseif(!empty($special_desc)) {
+            $cond = array("special_desc" => array('like', "%{$special_desc}%"));
+        } else {
+            $cond = [];
+        }
+        $cond['from_user'] = 0;
+
+        $model_mb_special = Model('mb_special');
+        $mb_special_list = $model_mb_special->getMbSpecialList(['from_user' => 1], 50);
+
+        Tpl::output('list', $mb_special_list);
+        Tpl::output('page', $model_mb_special->showpage(2));
+
+        $this->show_menu('special_list');
+        Tpl::showpage('mb_special.list');
+    }
+
+    public function search_keywordOp()
+    {
+        $keywords = trim($_POST['keyword']);
+        $special_id = intval($_POST['special_id']);
+
+        if($special_id > 0 && !empty($keywords)) {
+            $mod_special = Model('mb_special');
+            $mod_special->editMbSpecial(['keywords' => $keywords],$special_id);
+            echo json_encode(200);
+        } else {
+            echo json_encode(-1);
+        }
+    }
 
     public function tab_listOp()
     {
@@ -839,13 +877,4 @@ class mb_specialControl extends SystemControl
         }
         showMessage(L('nc_common_save_succ'), urlAdmin('mb_special', 'ugc_list'));
     }
-
-    public function discoveryOp(){
-        echo 'discovery';
-    }
-
-    public function search_keywordOp(){
-        $keyword = trim($_POST['keyword']);
-        echo json_encode('200');
-    }
 }

+ 5 - 2
admin/templates/default/mb_special.list.php

@@ -82,7 +82,9 @@ input {
         <tr class="hover">
           <td class="center"><?php echo $value['special_id'];?></td>
           <td class="center"><span nc_type="edit_special_desc" column_id="<?php echo $value['special_id'];?>" title="<?php echo $lang['nc_editable'];?>" class="alignleft editable tooltip w270"><?php echo $value['special_desc'];?></span></td>
-          <td class="center"><input type="text" name="search_keyword" placeholder="添加该专题的搜索关键字" value=""><a class="btn search_keyword"><span>添加</span></a></td>
+          <td class="center"><input type="hidden" name="special_id" value="<?php echo $value['special_id'];?>">
+              <input type="text" name="search_keyword" placeholder="添加该专题的搜索关键字" value="<?php echo $value['keywords'];?>">
+              <a class="btn search_keyword"><span>添加</span></a></td>
           <td class="nowrap align-center"><a href="<?php echo urlAdmin('mb_special', 'special_edit', array('special_id' => $value['special_id']));?>">编辑</a>&nbsp;|&nbsp; <a href="javascript:;" nctype="btn_del" data-special-id="<?php echo $value['special_id'];?>">删除</a></td>
         </tr>
         <?php } ?>
@@ -176,12 +178,13 @@ input {
 
         $('.search_keyword').on('click',function(){
             var keyword = $(this).siblings('input[name="search_keyword"]').val();
+            var special_id = $(this).siblings('input[name="special_id"]').val();
             if(!keyword){
                 alert('请输入关键字');
                 return;
             }
             if(confirm('确定提交?')) {
-                $.post('index.php?act=mb_special&op=search_keyword',{keyword:keyword},function(res){
+                $.post('index.php?act=mb_special&op=search_keyword',{keyword:keyword,special_id:special_id},function(res){
                     console.log(res);
                 });
             }