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/HtmlSearchRenderer.class.php';
26 require_once $gfcommon.'search/PeopleSearchQuery.class.php';
28 class PeopleHtmlSearchRenderer extends HtmlSearchRenderer {
31 * @param string $words words we are searching for
32 * @param int $offset offset
33 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
35 function __construct($words, $offset, $isExact) {
37 $searchQuery = new PeopleSearchQuery($words, $offset, $isExact);
39 parent::__construct(SEARCH__TYPE_IS_PEOPLE, $words, $isExact, $searchQuery);
41 $this->tableHeaders = array(
48 * writeHeader - write the header of the output
50 function writeHeader() {
51 $GLOBALS['HTML']->header(array('title'=>_('People Search')));
52 parent::writeHeader();
56 * getRows - get the html output for result rows
58 * @return string html output
61 $result = $this->searchQuery->getData($this->searchQuery->getRowsPerPage(),$this->searchQuery->getOffset());
65 foreach ($result as $row) {
67 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>'.
68 '<td style="width: 40%"><a href="'.util_make_url_u ($row['user_name'],$row['user_id']).'">'.html_image('ic/msg.png', '10', '12').' '.$row['user_name'].'</a></td>'.
69 '<td style="width: 60%">'.$row['realname'].'</td>'.
76 * redirectToResult - redirect the user directly to the result when there is only one matching result
78 function redirectToResult() {
79 $result = $this->searchQuery->getData(1)[0];
80 $user_name = $result['user_name'];
82 session_redirect('/users/'.$user_name.'/');
88 // c-file-style: "bsd"