4 * Wiki Search Engine for Fusionforge
6 * Copyright 2006 (c) Alain Peyrat
8 * This file is part of Fusionforge.
10 * Fusionforge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
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 this program; 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 'WikiSearchQuery.class.php';
28 class WikiHtmlSearchRenderer extends HtmlGroupSearchRenderer {
33 * @param string $words words we are searching for
34 * @param int $offset offset
35 * @param bool $isExact if we want to search for all the words or if only one matching the query is sufficient
36 * @param int $groupId group id
38 function __construct($words, $offset, $isExact, $groupId) {
39 $this->groupId = $groupId;
41 $searchQuery = new WikiSearchQuery($words, $offset, $isExact, $groupId);
43 // init the search renderer
44 parent::__construct(SEARCH__TYPE_IS_WIKI, $words, $isExact,
45 $searchQuery, $groupId, 'wiki');
47 $this->tableHeaders = array(_('Page'),_('Author'), _('Date'));
51 * getRows - get the html output for result rows
53 * @return string html output
56 $result = $this->searchQuery->getData($this->searchQuery->getRowsPerPage(),$this->searchQuery->getOffset());
58 $group = group_get_object($this->groupId);
59 $group_name = $group->getUnixName();
63 foreach ($result as $row) {
64 $data = unserialize($row['versiondata']);
65 $page_name = preg_replace('/%2f/i', '/', rawurlencode($row['pagename']));
66 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>'
67 . '<td><a href="/wiki/g/'. $group_name.'/'. $page_name .'">'
68 . html_image('ic/msg.png', 10, 12)
69 . ' '.$row['pagename'].'</a></td>
70 <td style="width: 15%">'.$data['author'].'</td>
71 <td style="width: 15%">'.relative_date($row['mtime']).'</td></tr>';