5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2004 (c) Guillaume Smet / Open Wide
7 * http://fusionforge.org
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once $gfwww.'search/include/renderers/HtmlGroupSearchRenderer.class.php';
26 require_once $gfcommon.'search/ForumSearchQuery.class.php';
28 class ForumHtmlSearchRenderer extends HtmlGroupSearchRenderer {
40 * @param string $words words we are searching for
41 * @param int $offset offset
42 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
43 * @param int $groupId group id
44 * @param int $forumId forum id
46 function ForumHtmlSearchRenderer($words, $offset, $isExact, $groupId, $forumId) {
47 $this->forumId = $forumId;
49 $searchQuery = new ForumSearchQuery($words, $offset, $isExact, $groupId, $forumId);
51 $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_FORUM, $words, $isExact, $searchQuery, $groupId, 'forums');
53 $this->tableHeaders = array(
60 function getFilteredRows() {
61 $rowsCount = $this->searchQuery->getRowsCount();
62 $result =& $this->searchQuery->getResult();
64 $fields = array ('group_forum_id',
71 for($i = 0; $i < $rowsCount; $i++) {
72 if (forge_check_perm('forum',
73 db_result($result, $i, 'group_forum_id'),
76 foreach ($fields as $f) {
77 $r[$f] = db_result($result, $i, $f);
86 * getRows - get the html output for result rows
88 * @return string html output
91 $fd = $this->getFilteredRows();
93 $dateFormat = _('Y-m-d H:i');
97 foreach ($fd as $row) {
98 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td class="halfwidth"><a href="'.util_make_url ('/forum/message.php?msg_id=' . $row['msg_id']).'">'
99 . html_image('ic/msg.png', '10', '12')
100 . ' '.$row['subject'].'</a></td>'
101 . '<td width="30%">'.$row['realname'].'</td>'
102 . '<td width="20%">'.date($dateFormat, $row['post_date']).'</td></tr>';
109 * getPreviousResultsUrl - get the url to go to see the previous results
111 * @return string url to previous results page
113 function getPreviousResultsUrl() {
114 return parent::getPreviousResultsUrl().'&forum_id='.$this->forumId;
118 * getNextResultsUrl - get the url to go to see the next results
120 * @return string url to next results page
122 function getNextResultsUrl() {
123 return parent::getNextResultsUrl().'&forum_id='.$this->forumId;
127 * redirectToResult - redirect the user directly to the result when there is only one matching result
129 function redirectToResult() {
130 session_redirect('/forum/message.php?msg_id='.$this->getResultId('msg_id'));