ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 3394


Ignore:
Timestamp:
Jul 5, 2007, 4:19:33 PM (12 years ago)
Author:
maruyama
Message:

トピック検索機能PC版とりあえず実装

Location:
OpenPNE/branches/work/maruyama/prj_topic_search/webapp
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/work/maruyama/prj_topic_search/webapp/lib/db/commu.php

    r3057 r3394  
    27822782}
    27832783
     2784/**
     2785 * トピック検索
     2786 */
     2787function db_commu_search_c_commu_topic(
     2788            $search_word,
     2789            $page_size,
     2790            $page,
     2791            $val_order = 'r_datetime',
     2792            $type = 'all',
     2793            $c_commu_id = 0)
     2794{
     2795    $select = 'SELECT c.name AS commu_name,ct.*,ctc.body,ctc.image_filename1,ctc.image_filename2,ctc.image_filename3,MAX(ctc2.r_datetime) AS last_datetime,(count(*)-1) AS comment_count';
     2796
     2797    $params = array();
     2798    $where = ' WHERE 1 ';
     2799    if ($c_commu_id) {
     2800        $where .= ' AND ct.c_commu_id = ? ';
     2801        $params[] = $c_commu_id;
     2802    }
     2803   
     2804    if ($search_word) {
     2805        $words = explode(' ', $search_word);
     2806        foreach ($words as $word) {
     2807            $word = check_search_word($word);
     2808
     2809            $where .= ' AND ((ct.name LIKE ?) ';
     2810            $where .= ' OR (ctc.body LIKE ?)) ';
     2811            $params[] = '%'.$word.'%';
     2812            $params[] = '%'.$word.'%';
     2813        }
     2814    }
     2815
     2816    $from = ' FROM c_commu AS c,c_commu_topic AS ct,c_commu_topic_comment AS ctc,c_commu_topic_comment AS ctc2';
     2817    switch ($val_order) {
     2818    case 'last_datetime':
     2819        $order = ' ORDER BY last_datetime DESC';
     2820        break;
     2821    case 'count':
     2822        $order = ' ORDER BY comment_count DESC';
     2823        break;
     2824    case 'r_datetime':
     2825    default:
     2826        $order = ' ORDER BY ctc.r_datetime DESC';
     2827        break;
     2828    }
     2829    switch ($type) {
     2830    case 'topic':
     2831        $where .= ' AND event_flag = 0 ';
     2832        break;
     2833    case 'event':
     2834        $where .= ' AND event_flag = 1 ';
     2835        break;
     2836    case 'all':
     2837    default:
     2838        break;
     2839    }
     2840    $sql = $select.$from.$where." AND c.c_commu_id = ct.c_commu_id AND ctc.number = 0 AND ct.c_commu_topic_id = ctc.c_commu_topic_id AND ct.c_commu_topic_id = ctc2.c_commu_topic_id GROUP BY ct.c_commu_topic_id ".$order;
     2841
     2842    $list = db_get_all_page($sql, $page, $page_size, $params);
     2843
     2844    $sql = 'SELECT COUNT(*) FROM c_commu_topic AS ct,c_commu_topic_comment AS ctc '.$where." AND ctc.number = 0 AND ct.c_commu_topic_id = ctc.c_commu_topic_id";
     2845    $total_num = db_get_one($sql, $params);
     2846
     2847    if ($total_num != 0) {
     2848        $total_page_num =  ceil($total_num / $page_size);
     2849        $next = ($page < $total_page_num);
     2850        $prev = ($page > 1);
     2851    }
     2852
     2853    $start_num = ($page - 1) * $page_size + 1;
     2854    $end_num   = $start_num + $page_size - 1 >= $total_num ? $total_num : $start_num + $page_size - 1;
     2855
     2856    return array($list, $prev, $next, $total_num, $start_num, $end_num);
     2857}
     2858
    27842859?>
  • OpenPNE/branches/work/maruyama/prj_topic_search/webapp/modules/pc/templates/c_home.tpl

    r2662 r3394  
    6262</tr>
    6363({/if})
     64<tr><td>
     65({*ここから:本体*})
     66<div class="bg_09" style="width:680px;height:24px;border-left:none 0px;border-right:none 0px;border-top:none 0px;">
     67({t_form _method=get m=pc a=page_ch_topic_find_all})
     68<input type="hidden" name="sessid" value="({$PHPSESSID})">
     69
     70<table border="0" cellspacing="0" cellpadding="0" class="search_bar" style="width:680px;height:24px;">
     71<tr>
     72<td align="center" style="height:24px;">
     73<img src="({t_img_url_skin filename=icon_search})" alt="search" style="width:62px;height:20px;" class="icon">
     74<input type="text" size="30" name="keyword" class="text border_01" value="" style="width:180px;">
     75<select name="target_commu">
     76<option value="in_commu">コミュニティ内</option>
     77<option value="all">コミュニティ全体</option>
     78</select>
     79<input type="hidden" name="c_commu_id" value="({$c_commu.c_commu_id})">
     80<input type="submit" class="submit" value=" 検 索 ">
     81
     82</td>
     83</tr>
     84</table>
     85
     86</form>
     87</div>
     88({*ここまで:本体*})
    6489({ext_include file="inc_layoutcolumn_top_270px.tpl"})
    6590
Note: See TracChangeset for help on using the changeset viewer.