6 * Portions Copyright 1999-2001 (c) VA Linux Systems
7 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
13 require_once $gfwww.'search/include/renderers/HtmlSearchRenderer.class.php';
14 require_once $gfcommon.'search/ProjectSearchQuery.class.php';
16 class ProjectHtmlSearchRenderer extends HtmlSearchRenderer {
21 * @param string $words words we are searching for
22 * @param int $offset offset
23 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
25 function ProjectHtmlSearchRenderer($words, $offset, $isExact) {
27 $searchQuery = new ProjectSearchQuery($words, $offset, $isExact);
29 $this->HtmlSearchRenderer(SEARCH__TYPE_IS_SOFTWARE, $words, $isExact, $searchQuery);
31 $this->tableHeaders = array(
38 * writeHeader - write the header of the output
40 function writeHeader() {
41 $GLOBALS['HTML']->header(array('title'=>_('Search'), 'pagename'=>'search'));
42 parent::writeHeader();
46 * getRows - get the html output for result rows
48 * @return string html output
51 $rowsCount = $this->searchQuery->getRowsCount();
52 $result =& $this->searchQuery->getResult();
56 for($i = 0; $i < $rowsCount; $i++) {
57 if (db_result($result, $i, 'type') == 2) {
62 $return .= '<tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i).'>'
63 .'<td width="30%"><a href="'.util_make_url('/'.$what.'/'.db_result($result, $i, 'unix_group_name').'/').'">'
64 .html_image('ic/msg.png', '10', '12', array('border'=>'0'))
65 .' '.$this->highlightTargetWords(db_result($result, $i, 'group_name')).'</a></td>'
66 .'<td width="70%">'.$this->highlightTargetWords(db_result($result, $i, 'short_description')).'</td></tr>';
73 * redirectToResult - redirect the user directly to the result when there is only one matching result
75 function redirectToResult() {
78 $project_name = $this->getResultId('unix_group_name');
79 $project_id = $this->getResultId('group_id');
81 if (forge_get_config('use_fti')) {
82 // If FTI is being used, the project name returned by the query will be "<b>projectname</b>", so
83 // we remove the HTML code (otherwise we'd get an error)
84 $project_name = str_replace('<b>', '', $project_name);
85 $project_name = str_replace('</b>', '', $project_name);
88 if ($this->getResultId('type') == 2) {
89 header('Location: /foundry/'.$project_name.'/');
91 header('Location: '.util_make_url_g($project_name,$project_id));