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

Changeset 1965


Ignore:
Timestamp:
Feb 28, 2007, 2:06:54 AM (13 years ago)
Author:
ishida
Message:

#461 コミュニティの書き込み内容に対する検索機能
実装完了

Location:
OpenPNE/branches/ishida/prj_dev28/webapp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/ishida/prj_dev28/webapp/lib/db/commu.php

    r1856 r1965  
    803803    $hint = db_mysql_hint('USE INDEX (r_datetime_c_commu_id)');
    804804    $sql = 'SELECT c_commu_id, c_commu_topic_id, name AS c_commu_topic_name, r_datetime, c_member_id'.
    805         ' FROM c_commu_topic'. $hint . ' WHERE c_commu_id IN (' . $ids . ') ORDER BY r_datetime DESC';
     805        ' FROM c_commu_topic'. $hint . ' WHERE c_commu_id IN (' . $ids . ') ORDER BY r_datetime DESC';
    806806    $c_commu_topic_list = db_get_all_limit($sql, 0, $limit);
    807807
     
    840840    $hint = db_mysql_hint('USE INDEX (r_datetime_c_commu_id)');
    841841    $sql = 'SELECT c_commu_id, c_commu_topic_id, name AS c_commu_topic_name, r_datetime, c_member_id'.
    842         ' FROM c_commu_topic'. $hint . ' WHERE c_commu_id IN (' . $ids . ') ORDER BY r_datetime DESC';
     842        ' FROM c_commu_topic'. $hint . ' WHERE c_commu_id IN (' . $ids . ') ORDER BY r_datetime DESC';
    843843    $c_commu_topic_list = db_get_all_limit($sql, ($page-1)*$limit, $limit);
    844844
     
    14871487    $hint = db_mysql_hint('USE INDEX (r_datetime_c_commu_id)');
    14881488    $sql = 'SELECT c_commu_id, c_commu_topic_id, name AS c_commu_topic_name, r_datetime, c_member_id'.
    1489         ' FROM c_commu_topic'. $hint . ' WHERE c_commu_id IN (' . $ids . ') ORDER BY r_datetime DESC';
     1489        ' FROM c_commu_topic'. $hint . ' WHERE c_commu_id IN (' . $ids . ') ORDER BY r_datetime DESC';
    14901490    $c_commu_topic_list = db_get_all_page($sql, $page, $page_size);
    14911491
     
    26352635}
    26362636
     2637//トピックとトピックコメントの混在したリストを取得
     2638//keywordで検索
     2639//イベントはトピックと同列
     2640function db_commu_search_c_commu_topic($search_word, $category_id, $page, $page_size)
     2641{
     2642
     2643    if ($search_word) {
     2644
     2645        $params = array();
     2646        $from = ' FROM c_commu_topic_comment as ctc, c_commu_topic as ct';
     2647        $where = ' WHERE ct.c_commu_topic_id = ctc.c_commu_topic_id';
     2648
     2649        $words = explode(' ', $search_word);
     2650        foreach ($words as $word) {
     2651            $word = check_search_word($word);
     2652
     2653            $where .= ' AND (ct.name LIKE ? OR ctc.body LIKE ?)';
     2654            $params[] = '%'.$word.'%';
     2655            $params[] = '%'.$word.'%';
     2656        }
     2657
     2658        $sql = 'SELECT ctc.*' .
     2659               $from .
     2660               $where .
     2661               ' order by ctc.r_datetime DESC';
     2662    } else {
     2663        $from = ' FROM c_commu_topic_comment';
     2664        $where = '';
     2665        $sql = 'SELECT *' . $from . ' order by r_datetime DESC';
     2666    }
     2667
     2668    $result = db_get_all_page($sql, $page, $page_size, $params);
     2669    $sql = 'SELECT count(*)' .
     2670           $from .
     2671           $where;
     2672    $total_num = db_get_one($sql, $params);
     2673
     2674    foreach( $result as $key => $value ) {
     2675        $c_commu = db_commu_c_commu4c_commu_id(intval($value['c_commu_id']));
     2676        $c_commu_topic = db_commu_c_commu_topic4c_commu_topic_id(intval($value['c_commu_topic_id']));
     2677
     2678        if (!$category_id || $c_commu['c_commu_category_id'] == $category_id ) {
     2679            $result[$key]['commu_name'] = $c_commu['name'];
     2680            $result[$key]['image_filename'] = $c_commu['image_filename'];
     2681            $result[$key]['topic_name'] = $c_commu_topic['name'];
     2682            $result[$key]['c_commu_category'] = $c_commu['c_commu_category']['name'];
     2683        } else {
     2684            unset($result[$key]);
     2685            $total_num--;
     2686        }
     2687
     2688    }
     2689
     2690    if ($total_num > 0) {
     2691        $total_page_num =  ceil($total_num / $page_size);
     2692        if ($page >= $total_page_num) {
     2693            $next = false;
     2694        } else {
     2695            $next = true;
     2696        }
     2697        if ($page <= 1) {
     2698            $prev = false;
     2699        } else {
     2700            $prev = true;
     2701        }
     2702    }
     2703
     2704    $start_num = ($page - 1) * $page_size + 1;
     2705    $end_num   = $start_num + $page_size >= $total_num ? $total_num : $start_num + $page_size - 1;
     2706
     2707    return array($result, $prev, $next, $total_num, $start_num, $end_num);
     2708}
     2709
    26372710?>
  • OpenPNE/branches/ishida/prj_dev28/webapp/modules/pc/page/h_com_find_all.php

    r1856 r1965  
    2020        // ----------
    2121
    22         //バグ回避のため半角空白を全角に統一
    23         $keyword = str_replace(" ", " ", $keyword);
     22        //バグ回避のため全角空白を半角空白に統一
     23        $keyword = str_replace(" ", " ", $keyword);
    2424
    2525        do_common_insert_search_log($u, $keyword);
     
    4141                $category_id);
    4242
     43        //トピックの検索結果
     44        list($c_commu_topic_search_list, $topic_is_prev, $topic_is_next, $topic_total_num, $topic_start_num, $topic_end_num)
     45            = db_commu_search_c_commu_topic(
     46                $keyword,
     47                $category_id,
     48                $page,
     49                $page_size
     50              );
     51
    4352        $this->set('c_commu_search_list', $result);
    4453        $this->set('is_prev', $is_prev);
     
    4756        $this->set('start_num', $start_num);
    4857        $this->set('end_num', $end_num);
     58
     59        $this->set('c_commu_topic_search_list', $c_commu_topic_search_list);
     60        $this->set('topic_is_prev', $topic_is_prev);
     61        $this->set('topic_is_next', $topic_is_next);
     62        $this->set('topic_total_num', $topic_total_num);
     63        $this->set('topic_start_num', $topic_start_num);
     64        $this->set('topic_end_num', $topic_end_num);
     65
    4966
    5067        $this->set('keyword', $keyword);
  • OpenPNE/branches/ishida/prj_dev28/webapp/modules/pc/templates/h_com_find_all.tpl

    r1088 r1965  
    7373<input type="submit" class="submit" value=" 検 索 ">
    7474
    75 <a href="({t_url m=pc a=page_h_diary_list_all})&amp;keyword=({$smarty.capture.keyword_url|smarty:nodefaults})">日記検索</a>
    76 |
    77 <a href="http://www.google.com/search?hl=ja&amp;lr=lang_ja&amp;q=({$smarty.capture.keyword_url|smarty:nodefaults})" target="_blank">ウェブ検索</a>
    78 
    7975</form>
    8076
     
    153149<!-- ******ここまで:コミュニティ検索****** -->
    154150<!-- ************************************ -->
     151
     152({if $c_commu_search_list})
    155153
    156154<img src="./skin/dummy.gif" class="v_spacer_l">
     
    448446<!-- ************************************ -->
    449447
     448({/if})
     449
     450({if $c_commu_topic_search_list})
     451
     452<img src="./skin/dummy.gif" class="v_spacer_l">
     453
     454<!-- ************************************ -->
     455<!-- ******ここから:トピック一覧****** -->
     456<table border="0" cellspacing="0" cellpadding="0" style="width:650px;margin:0px auto;" class="border_07">
     457<tr>
     458<td style="width:7px;" class="bg_00"><img src="./skin/dummy.gif" style="width:7px;height:7px;" class="dummy"></td>
     459<td style="width:636px;" class="bg_00"><img src="./skin/dummy.gif" style="width:7px;height:7px;" class="dummy"></td>
     460<td style="width:7px;" class="bg_00"><img src="./skin/dummy.gif" style="width:7px;height:7px;" class="dummy"></td>
     461</tr>
     462<tr>
     463<td class="bg_00"><img src="./skin/dummy.gif" style="width:7px;height:7px;" class="dummy"></td>
     464<td class="bg_01" align="center">
     465<!-- *ここから:トピック一覧>内容* -->
     466({*ここから:header*})
     467<!-- ここから:小タイトル -->
     468<table border="0" cellspacing="0" cellpadding="0" style="width:636px;" class="border_01">
     469<tr>
     470<td style="width:36px;" class="bg_06"><img src="({t_img_url_skin filename=content_header_1})" style="width:30px;height:20px;" class="dummy"></td>
     471<td style="width:600px;padding:2px 0px;" class="bg_06"><span class="c_00"><span class="b_b">トピック一覧</span>&nbsp;&nbsp;***&nbsp;
     472
     473({if $topic_total_num})
     474    ({$topic_total_num})
     475({else})
     476    0
     477({/if})
     478
     479件&nbsp;が該当しました。</span></td>
     480</tr>
     481</table>
     482<!-- ここまで:小タイトル -->
     483({*ここまで:header*})
     484({*ここから:body*})
     485<!-- ここから:主内容 -->
     486({if $topic_start_num != $topic_end_num})
     487<!-- ここから:主内容>>トピック一覧件数表示タブ -->
     488<table border="0" cellspacing="0" cellpadding="0" style="width:634px;">
     489({*********})
     490<tr>
     491<td style="width:634px;height:1px;" class="bg_01" colspan="3"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     492</tr>
     493({*********})
     494<tr>
     495<td style="width:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     496<td style="width:632px;" class="bg_02" align="right" valign="middle">
     497<div style="padding:4px 3px;">
     498
     499({if $topic_is_prev})
     500<a href="({t_url m=pc a=page_h_com_find_all})&amp;direc=-1&amp;page=({$page})&amp;keyword=({$smarty.capture.keyword_url|smarty:nodefaults})&amp;val_order=({$search_val_list.val_order})&amp;category_id=({$search_val_list.category_id})">前を表示</a>&nbsp;&nbsp;
     501({/if})
     502({if $topic_total_num})
     503({$topic_start_num})件~({$topic_end_num})件を表示
     504({/if})
     505({if $topic_is_next})
     506&nbsp;&nbsp;<a href="({t_url m=pc a=page_h_com_find_all})&amp;direc=1&amp;page=({$page})&amp;keyword=({$smarty.capture.keyword_url|smarty:nodefaults})&amp;val_order=({$search_val_list.val_order})&amp;category_id=({$search_val_list.category_id})">次を表示</a>
     507({/if})
     508
     509</div>
     510</td>
     511<td style="width:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     512</tr>
     513({*********})
     514<tr>
     515<td style="width:634px;height:1px;" class="bg_01" colspan="3"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     516</tr>
     517({*********})
     518</table>
     519<!-- ここまで:主内容>>トピック一覧件数表示タブ -->
     520({/if})
     521<!-- ここから:主内容>>トピック一覧本体 -->
     522<div class="border_01 bg_05" align="center">
     523
     524<img src="./skin/dummy.gif" class="v_spacer_l">
     525
     526<!-- ここから:主内容>>トピック一覧本体>>のループ部分 -->
     527({foreach from=$c_commu_topic_search_list item=c_commu_topic_search})
     528<div class="border_01 bg_09" style="width:562px;margin:0px auto;" align="center">
     529<img src="./skin/dummy.gif" class="v_spacer_m">
     530<table border="0" cellspacing="0" cellpadding="0" style="width:550px;margin:0px auto;">
     531({*********})
     532<tr>
     533<td style="width:550px;height:1px;" class="bg_01" colspan="7"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     534</tr>
     535({*********})
     536<tr>
     537<td style="width:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     538<td style="width:90px;" class="bg_03" align="center" valign="middle" rowspan="7">
     539
     540<div class="padding_s">
     541
     542<a href="({t_url m=pc a=page_c_topic_detail})&amp;target_c_commu_topic_id=({$c_commu_topic_search.c_commu_topic_id})">
     543<img src="({t_img_url filename=$c_commu_topic_search.image_filename w=76 h=76 noimg=no_logo_small})"></a>
     544
     545</div>
     546
     547</td>
     548<td style="width:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     549<td style="width:85px;" class="bg_05" align="left" valign="middle">
     550
     551<div class="padding_s">
     552
     553トピック名
     554
     555</div>
     556
     557</td>
     558<td style="width:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     559<td style="width:371px;" class="bg_02" align="left" valign="middle">
     560
     561<div class="padding_s">
     562
     563({$c_commu_topic_search.topic_name})
     564
     565</div>
     566
     567</td>
     568<td style="width:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     569</tr>
     570({*********})
     571<tr>
     572<td style="width:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     573<td style="width:457px;" class="bg_01" align="center" colspan="5"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     574</tr>
     575({*********})
     576<tr>
     577<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     578<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     579<td class="bg_05" align="left" valign="middle">
     580
     581<div class="padding_s">
     582
     583コミュニティ名
     584
     585</div>
     586
     587</td>
     588<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     589<td class="bg_02" align="left" valign="middle">
     590
     591<div class="padding_s">
     592
     593({$c_commu_topic_search.commu_name})
     594
     595</div>
     596
     597</td>
     598<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     599</tr>
     600({*********})
     601<tr>
     602<td style="height:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     603<td style="height:1px;" class="bg_01" align="center" colspan="5"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     604</tr>
     605({*********})
     606<tr>
     607<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     608<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     609<td class="bg_05" align="left" valign="middle">
     610
     611<div class="padding_s">
     612
     613本文
     614
     615</div>
     616
     617</td>
     618<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     619<td class="bg_02" align="left" valign="middle">
     620
     621<div class="padding_s">
     622
     623({$c_commu_topic_search.body})
     624
     625</div>
     626
     627</td>
     628<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     629</tr>
     630({*********})
     631<tr>
     632<td style="height:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     633<td style="height:1px;" class="bg_01" align="center" colspan="5"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     634</tr>
     635({*********})
     636<tr>
     637<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     638<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     639<td class="bg_05" align="left" valign="middle">
     640
     641<div class="padding_s">
     642
     643カテゴリ
     644
     645</div>
     646
     647</td>
     648<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     649<td class="bg_02" align="center" valign="middle">
     650
     651<table border="0" cellspacing="0" cellpadding="0" style="width:371px;">
     652<tr>
     653<td style="width:99px;" class="bg_02" align="left">
     654
     655<div class="padding_s">
     656
     657({$c_commu_topic_search.c_commu_category})
     658
     659</div>
     660
     661</td>
     662<td style="width:1px;" class="bg_01"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     663<td style="width:271px;" class="bg_03" align="center">
     664
     665<div class="padding_s">
     666
     667<a href="({t_url m=pc a=page_c_topic_detail})&amp;target_c_commu_topic_id=({$c_commu_topic_search.c_commu_topic_id})"><img src="({t_img_url_skin filename=button_shosai})" class="icon"></a>
     668
     669</div>
     670
     671</td>
     672</tr>
     673</table>
     674
     675</td>
     676<td class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     677</tr>
     678({*********})
     679<tr>
     680<td style="height:1px;" class="bg_01" colspan="7"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     681</tr>
     682({*********})
     683</table>
     684<img src="./skin/dummy.gif" class="v_spacer_m">
     685</div>
     686
     687<img src="./skin/dummy.gif" class="v_spacer_l">
     688({/foreach})
     689<!-- ここまで:主内容>>トピック一覧本体>>のループ部分 -->
     690
     691</div>
     692<!-- ここまで:>>トピック一覧本体 -->
     693({if $topic_start_num != $topic_end_num})
     694<!-- ここから:主内容>>トピック一覧件数表示タブ -->
     695<table border="0" cellspacing="0" cellpadding="0" style="width:634px;">
     696({*********})
     697<tr>
     698<td style="width:634px;height:1px;" class="bg_01" colspan="3"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     699</tr>
     700({*********})
     701<tr>
     702<td style="width:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     703<td style="width:632px;" class="bg_02" align="right" valign="middle">
     704<div style="padding:4px 3px;">
     705
     706({if $topic_is_prev})
     707<a href="({t_url m=pc a=page_h_com_find_all})&amp;direc=-1&amp;page=({$page})&amp;val_order=({$search_val_list.val_order})&amp;keyword=({$smarty.capture.keyword_url|smarty:nodefaults})&amp;category_id=({$search_val_list.category_id})">前を表示</a>&nbsp;&nbsp;
     708({/if})
     709({if $topic_total_num})
     710({$topic_start_num})件~({$topic_end_num})件を表示
     711({/if})
     712({if $topic_is_next})
     713&nbsp;&nbsp;<a href="({t_url m=pc a=page_h_com_find_all})&amp;direc=1&amp;page=({$page})&amp;val_order=({$search_val_list.val_order})&amp;keyword=({$smarty.capture.keyword_url|smarty:nodefaults})&amp;category_id=({$search_val_list.category_id})">次を表示</a>
     714({/if})
     715
     716</div>
     717</td>
     718<td style="width:1px;" class="bg_01" align="center"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     719</tr>
     720({*********})
     721<tr>
     722<td style="width:634px;height:1px;" class="bg_01" colspan="3"><img src="./skin/dummy.gif" style="width:1px;height:1px;" class="dummy"></td>
     723</tr>
     724({*********})
     725</table>
     726<!-- ここまで:主内容>>トピック一覧件数表示タブ -->
     727({/if})
     728<!-- ここまで:主内容 -->
     729({*ここまで:body*})
     730({*ここから:footer*})
     731<!-- 無し -->
     732({*ここまで:footer*})
     733<!-- *ここまで:トピック一覧>>内容* -->
     734</td>
     735<td class="bg_00"><img src="./skin/dummy.gif" style="width:7px;height:7px;" class="dummy"></td>
     736</tr>
     737<tr>
     738<td style="width:7px;" class="bg_00"><img src="./skin/dummy.gif" style="width:7px;height:7px;" class="dummy"></td>
     739<td style="width:636px;" class="bg_00"><img src="./skin/dummy.gif" style="width:7px;height:7px;" class="dummy"></td>
     740<td style="width:7px;" class="bg_00"><img src="./skin/dummy.gif" style="width:7px;height:7px;" class="dummy"></td>
     741</tr>
     742</table>
     743<!-- ******ここまで:トピック一覧****** -->
     744<!-- ************************************ -->
     745
     746({/if})
     747
    450748<img src="./skin/dummy.gif" class="v_spacer_l">
    451749
Note: See TracChangeset for help on using the changeset viewer.