5 * Copyright 2004 (c) Dominik Haas, GForge Team
12 require_once $gfwww.'search/include/renderers/HtmlGroupSearchRenderer.class.php';
13 require_once $gfcommon.'search/ForumsSearchQuery.class.php';
15 class ForumsHtmlSearchRenderer extends HtmlGroupSearchRenderer {
20 * @param string $words words we are searching for
21 * @param int $offset offset
22 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
23 * @param int $groupId group id
24 * @param array $sections array of all sections to search in (array of strings)
27 function ForumsHtmlSearchRenderer($words, $offset, $isExact, $groupId, $sections=SEARCH__ALL_SECTIONS) {
28 $userIsGroupMember = $this->isGroupMember($groupId);
30 $searchQuery = new ForumsSearchQuery($words, $offset, $isExact, $groupId, $sections, $userIsGroupMember);
32 $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_FORUMS, $words, $isExact, $searchQuery, $groupId, 'forums');
34 $this->tableHeaders = array(
43 * getRows - get the html output for result rows
45 * @return string html output
48 $rowsCount = $this->searchQuery->getRowsCount();
49 $result =& $this->searchQuery->getResult();
50 $dateFormat = _('Y-m-d H:i');
54 $lastForumName = null;
56 for($i = 0; $i < $rowsCount; $i++) {
58 $currentForumName = db_result($result, $i, 'forum_name');
59 if ($lastForumName != $currentForumName) {
60 $return .= '<tr><td colspan="4">'.$currentForumName.'</td></tr>';
61 $lastForumName = $currentForumName;
64 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($rowColor) .'>'
65 . '<td width="5%"> </td>'
66 . '<td><a href="'.util_make_url ('/forum/message.php?msg_id='. db_result($result, $i, 'msg_id')).'">'
67 . html_image('ic/msg.png', '10', '12', array('border' => '0')).' '.db_result($result, $i, 'subject')
69 . '<td width="15%">'.db_result($result, $i, 'realname').'</td>'
70 . '<td width="15%">'.date($dateFormat, db_result($result, $i, 'post_date')).'</td></tr>';
77 * getSections - get the array of possible sections to search in
79 * @return array sections
81 function getSections($groupId) {
82 $userIsGroupMember = $this->isGroupMember($groupId);
84 return ForumsSearchQuery::getSections($groupId, $userIsGroupMember);