6 * Portions Copyright 1999-2001 (c) VA Linux Systems
7 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
14 require_once('www/search/include/renderers/HtmlSearchRenderer.class');
15 require_once('common/search/ProjectSearchQuery.class');
17 class ProjectHtmlSearchRenderer extends HtmlSearchRenderer {
22 * @param string $words words we are searching for
23 * @param int $offset offset
24 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
26 function ProjectHtmlSearchRenderer($words, $offset, $isExact) {
28 $searchQuery = new ProjectSearchQuery($words, $offset, $isExact);
30 $this->HtmlSearchRenderer(SEARCH__TYPE_IS_SOFTWARE, $words, $isExact, $searchQuery);
32 $this->tableHeaders = array(
33 $this->Language->getText('search', 'group_name'),
34 $this->Language->getText('search', 'group_description')
39 * writeHeader - write the header of the output
41 function writeHeader() {
42 $GLOBALS['HTML']->header(array('title'=>$this->Language->getText('search', 'title'), 'pagename'=>'search'));
43 parent::writeHeader();
47 * getRows - get the html output for result rows
49 * @return string html output
52 $rowsCount = $this->searchQuery->getRowsCount();
53 $result =& $this->searchQuery->getResult();
57 for($i = 0; $i < $rowsCount; $i++) {
58 if (db_result($result, $i, 'type') == 2) {
63 $return .= '<tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i).'>'
64 .'<td width="30%"><a href="'.$GLOBALS['sys_urlprefix'].'/'.$what.'/'
65 .db_result($result, $i, 'unix_group_name').'/">'
66 .html_image('ic/msg.png', '10', '12', array('border'=>'0'))
67 .' '.$this->highlightTargetWords(db_result($result, $i, 'group_name')).'</a></td>'
68 .'<td width="70%">'.$this->highlightTargetWords(db_result($result, $i, 'short_description')).'</td></tr>';
75 * redirectToResult - redirect the user directly to the result when there is only one matching result
77 function redirectToResult() {
80 $project_name = $this->getResultId('unix_group_name');
83 // If FTI is being used, the project name returned by the query will be "<b>projectname</b>", so
84 // we remove the HTML code (otherwise we'd get an error)
85 $project_name = str_replace('<b>', '', $project_name);
86 $project_name = str_replace('</b>', '', $project_name);
89 header('Location: /'.($this->getResultId('type') == 2 ? 'foundry' : 'projects').'/'.$project_name.'/');