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/ProjectSearchQuery.class.php';
28 class ProjectHtmlSearchRenderer extends HtmlSearchRenderer {
33 * @param string $words words we are searching for
34 * @param int $offset offset
35 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
37 function ProjectHtmlSearchRenderer($words, $offset, $isExact) {
39 $searchQuery = new ProjectSearchQuery($words, $offset, $isExact);
41 $this->HtmlSearchRenderer(SEARCH__TYPE_IS_SOFTWARE, $words, $isExact, $searchQuery);
43 $this->tableHeaders = array(
50 * writeHeader - write the header of the output
52 function writeHeader() {
53 $GLOBALS['HTML']->header(array('title'=>_('Project Search'), 'pagename'=>'search'));
54 parent::writeHeader();
58 * getRows - get the html output for result rows
60 * @return string html output
63 $result =& $this->searchQuery->getResult();
68 while ($row = db_fetch_array($result)) {
69 if (!forge_check_perm ('project_read', $row_top['group_id'])) {
73 if ($row['type'] == 2) {
78 $return .= '<tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i).'>'
79 .'<td width="30%"><a href="'.util_make_url('/'.$what.'/'.$row['unix_group_name'].'/').'">'
80 .html_image('ic/msg.png', '10', '12')
81 .' '.$this->highlightTargetWords($row['group_name']).'</a></td>'
82 .'<td width="70%">'.$this->highlightTargetWords($row['short_description']).'</td></tr>';
89 * redirectToResult - redirect the user directly to the result when there is only one matching result
91 function redirectToResult() {
94 $project_name = $this->getResultId('unix_group_name');
95 $project_id = $this->getResultId('group_id');
97 if (forge_get_config('use_fti')) {
98 // If FTI is being used, the project name returned by the query will be "<b>projectname</b>", so
99 // we remove the HTML code (otherwise we'd get an error)
100 $project_name = str_replace('<b>', '', $project_name);
101 $project_name = str_replace('</b>', '', $project_name);
104 if ($this->getResultId('type') == 2) {
105 session_redirect('/foundry/'.$project_name.'/');
107 header('Location: '.util_make_url_g($project_name,$project_id));