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

Changeset 3468


Ignore:
Timestamp:
Jul 20, 2007, 8:26:33 PM (12 years ago)
Author:
ogawa
Message:

トピック検索PCの途中

Location:
OpenPNE/branches/work/ogawa/try-topic_search/webapp
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/work/ogawa/try-topic_search/webapp/lib/db/commu.php

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

    r2662 r3468  
    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_c_com_topic_find})
     68<input type="hidden" name="c_commu_id" value="({$c_commu.c_commu_id})">
     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="submit" class="submit" value=" 検 索 ">
     80
     81</td>
     82</tr>
     83</table>
     84
     85</form>
     86</div>
     87({*ここまで:本体*})
    6488({ext_include file="inc_layoutcolumn_top_270px.tpl"})
    6589
Note: See TracChangeset for help on using the changeset viewer.