gforge-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gforge-commits] gforge/www/search/include/renderers RssSearchRenderer.c


From: gsmet
Subject: [Gforge-commits] gforge/www/search/include/renderers RssSearchRenderer.class, NONE, 1.1 ForumsHtmlSearchRenderer.class, NONE, 1.1 TasksHtmlSearchRenderer.class, NONE, 1.1 HtmlGroupSearchRenderer.class, NONE, 1.1 HtmlSearchRenderer.class, NONE, 1.1 SkillHtmlSearchRenderer.class, NONE, 1.1 TrackersHtmlSearchRenderer.class, NONE, 1.1 NewsHtmlSearchRenderer.class, NONE, 1.1 DocsHtmlSearchRenderer.class, NONE, 1.1 PeopleHtmlSearchRenderer.class, NONE, 1.1 FrsHtmlSearchRenderer.class, NONE, 1.1 ForumHtmlSearchRenderer.class, NONE, 1.1 ProjectRssSearchRenderer.class, NONE, 1.1 ArtifactHtmlSearchRenderer.class, NONE, 1.1 ProjectHtmlSearchRenderer.class, NONE, 1.1 SearchRenderer.class, NONE, 1.1
Date: Sat, 16 Oct 2004 11:36:34 -0500

Update of /cvsroot/gforge/gforge/www/search/include/renderers
In directory db.perdue.net:/tmp/cvs-serv25456/www/search/include/renderers

Added Files:
        RssSearchRenderer.class ForumsHtmlSearchRenderer.class 
        TasksHtmlSearchRenderer.class HtmlGroupSearchRenderer.class 
        HtmlSearchRenderer.class SkillHtmlSearchRenderer.class 
        TrackersHtmlSearchRenderer.class NewsHtmlSearchRenderer.class 
        DocsHtmlSearchRenderer.class PeopleHtmlSearchRenderer.class 
        FrsHtmlSearchRenderer.class ForumHtmlSearchRenderer.class 
        ProjectRssSearchRenderer.class 
        ArtifactHtmlSearchRenderer.class 
        ProjectHtmlSearchRenderer.class SearchRenderer.class 
Log Message:
Search engine reorganisation

--- NEW FILE: RssSearchRenderer.class ---
<?php

/**
 * GForge Search Engine
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
 *
 * http://gforge.org
 *
 * @version $Id: RssSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet Exp $
 */

require_once('www/search/include/renderers/SearchRenderer.class');

class RssSearchRenderer extends SearchRenderer {
        
        /**
         * callback function name used during the RSS export
         *
         * @var string $callbackFunction
         */
        var $callbackFunction = '';

        /**
         * Constructor
         *
         * @param string $typeOfSearch type of the search (Software, Forum, 
People and so on)
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param object $searchQuery SearchQuery instance
         */
        function RssSearchRenderer($typeOfSearch, $words, $isExact, 
$searchQuery) {
                $this->SearchRenderer($typeOfSearch, $words, $isExact, 
$searchQuery);
        }

        /**
         * flush - flush the RSS output
         */
        function flush() {
                $searchQuery =& $this->searchQuery;

                header('Content-Type: text/plain');
                
                if($searchQuery->isError() || $this->isError()) {
                        echo '<channel></channel>';
                } else {                
                        $searchQuery->executeQuery();
                        include_once('www/export/rss_utils.inc');
        
                        rss_dump_project_result_set(
                                $searchQuery->getResult(),
                                'GForge Search Results',
                                'GForge Search Results for 
"'.$this->query['words'].'"',
                                $this->callbackFunction
                        );
                }
                exit();
        }

}

?>
--- NEW FILE: ForumsHtmlSearchRenderer.class ---
<?php
/**
 * GForge Search Engine
 *
 * Copyright 2004 (c) Dominik Haas, GForge Team
 *
 * http://gforge.org
 *
 * @version $Id: ForumsHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet 
Exp $
 */
 
require_once('www/search/include/renderers/HtmlGroupSearchRenderer.class');
require_once('common/search/ForumsSearchQuery.class');
        
class ForumsHtmlSearchRenderer extends HtmlGroupSearchRenderer {

        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param int $groupId group id
         * @param array $sections array of all sections to search in (array of 
strings)
         *
         */
        function ForumsHtmlSearchRenderer($words, $offset, $isExact, $groupId, 
$sections=SEARCH__ALL_SECTIONS) {
                $userIsGroupMember = $this->isGroupMember($groupId);
                
                $searchQuery = new ForumsSearchQuery($words, $offset, $isExact, 
$groupId, $sections, $userIsGroupMember);
                
                $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_FORUMS, $words, 
$isExact, $searchQuery, $groupId, 'forums');
                
                $this->tableHeaders = array(
                        '',
                        $this->Language->getText('search', 'forum_thread'),
                        $this->Language->getText('search', 'forum_author'),
                        $this->Language->getText('search', 'forum_date')
                );
        }

        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                $dateFormat = $GLOBALS['sys_datefmt'];

                $return = '';
                $rowColor = 0;
                $lastForumName = null;
                
                for($i = 0; $i < $rowsCount; $i++) {
                        //section changed
                        $currentForumName = db_result($result, $i, 
'forum_name');
                        if ($lastForumName != $currentForumName) {
                                $return .= '<tr><td 
colspan="4">'.$currentForumName.'</td></tr>';
                                $lastForumName = $currentForumName;
                                $rowColor = 0;
                        }
                        $return .= '<tr '. 
$GLOBALS['HTML']->boxGetAltRowStyle($rowColor) .'>'
                                                . '<td width="5%">&nbsp;</td>'
                                                . '<td><a 
href="/forum/message.php?msg_id='. db_result($result, $i, 'msg_id').'">'
                                                        . 
html_image('ic/msg.png', '10', '12', array('border' => '0')).' 
'.db_result($result, $i, 'subject')
                                                        .'</a></td>'            
        
                                                . '<td 
width="15%">'.db_result($result, $i, 'realname').'</td>'
                                                . '<td 
width="15%">'.date($dateFormat, db_result($result, $i, 
'post_date')).'</td></tr>';
                        $rowColor ++;
                }
                return $return;
        }
        
        /**
         * getSections - get the array of possible sections to search in
         * 
         * @return array sections
         */                             
        function getSections($groupId) {
                $userIsGroupMember = $this->isGroupMember($groupId);
                
                return $this->searchQuery->getSections($groupId, 
$userIsGroupMember);
        }
}

?>
--- NEW FILE: TasksHtmlSearchRenderer.class ---
<?php
/**
 * GForge Search Engine
 *
 * Copyright 2004 (c) Dominik Haas, GForge Team
 *
 * http://gforge.org
 *
 * @version $Id: TasksHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet 
Exp $
 */

require_once('www/search/include/renderers/HtmlGroupSearchRenderer.class');
require_once('common/search/TasksSearchQuery.class');
        
class TasksHtmlSearchRenderer extends HtmlGroupSearchRenderer {
        
        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param int $groupId group id
         * @param array $sections array of all sections to search in (array of 
strings)
         *
         */
        function TasksHtmlSearchRenderer($words, $offset, $isExact, $groupId, 
$sections=SEARCH__ALL_SECTIONS) {
                $userIsGroupMember = $this->isGroupMember($groupId);
                
                $searchQuery = new TasksSearchQuery($words, $offset, $isExact, 
$groupId, $sections, $userIsGroupMember);

                $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_TASKS, $words, 
$isExact, $searchQuery, $groupId, 'pm');
                
                $this->tableHeaders = array(
                        '&nbsp;',
                        $this->Language->getText('search', 'tasks_id'),
                        $this->Language->getText('search', 'tasks_summary'),
                        $this->Language->getText('search', 'tasks_start_date'),
                        $this->Language->getText('search', 'tasks_end_date'),
                        $this->Language->getText('search', 'tasks_created_by'),
                        $this->Language->getText('search', 'tasks_completed')
                );
        }

        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */     
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                $dateFormat = $GLOBALS['sys_datefmt'];
                
                $return = '';
                $rowColor = 0;
                $lastProjectName = null;
                
                for($i = 0; $i < $rowsCount; $i++) {
                        //section changed
                        $currentProjectName = db_result($result, $i, 
'project_name');
                        if ($lastProjectName != $currentProjectName) {
                                $return .= '<tr><td 
colspan="7">'.$currentProjectName.'</td></tr>';
                                $lastProjectName = $currentProjectName;
                                $rowColor = 0;
                        }
                        $return .= '<tr '. 
$GLOBALS['HTML']->boxGetAltRowStyle($rowColor) .'>'
                                                . ' <td width="5%">&nbsp;</td>'
                                                . ' <td>'.db_result($result, 
$i, 'project_task_id').'</td>'
                                                . ' <td>'
                                                        . '<a 
href="/pm/task.php?func=detailtask&project_task_id='
                                                        . db_result($result, 
$i, 'project_task_id').'&group_id='.$this->groupId
                                                        . 
'&group_project_id='.db_result($result, $i, 'group_project_id').'">'
                                                        . 
html_image('ic/msg.png', '10', '12', array('border'=>'0')).' '
                                                        . db_result($result, 
$i, 'summary').'</a></td>'
                                                . ' <td 
width="15%">'.date($dateFormat, db_result($result, $i, 'start_date')).'</td>'
                                                . ' <td 
width="15%">'.date($dateFormat, db_result($result, $i, 'end_date')).'</td>'
                                                . ' <td 
width="15%">'.db_result($result, $i, 'realname').'</td>'
                                                . ' <td 
width="8%">'.db_result($result, $i, 'percent_complete').' %</td></tr>';
                        $rowColor ++;
                }
                return $return;
        }
                
        /**
         * getSections - get the array of possible sections to search in
         * 
         * @return array sections
         */             
        function getSections($groupId) {
                $userIsGroupMember = $this->isGroupMember($groupId);
                
                return TasksSearchQuery::getSections($groupId, 
$userIsGroupMember);             
        }
}

?>
--- NEW FILE: HtmlGroupSearchRenderer.class ---
<?php

/**
 * GForge Search Engine
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
 *
 * http://gforge.org
 *
 * @version $Id: HtmlGroupSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet 
Exp $
 */
 
require_once('www/search/include/renderers/HtmlSearchRenderer.class');

class HtmlGroupSearchRenderer extends HtmlSearchRenderer {
        
        /**
         * group id
         *
         * @var int $groupId
         */
        var $groupId;
        
        /**
         * selected top tab
         * @var string $topTab
         */
        var $topTab;

        /**
         * Constructor
         *
         * @param string $typeOfSearch type of the search (Software, Forum, 
People and so on)
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param object $searchQuery SearchQuery instance
         * @param int $groupId group id
         */
        function HtmlGroupSearchRenderer($typeOfSearch, $words, $isExact, 
$searchQuery, $groupId, $topTab = '') {
                $this->HtmlSearchRenderer($typeOfSearch, $words, $isExact, 
$searchQuery);
                $this->groupId = $groupId;
                $this->topTab = $topTab;
        }
        
        /**
         * writeHeader - write the header of the output
         */
        function writeHeader() {
                site_project_header(array('title' => 
$this->Language->getText('search', 'title'), 'group' => $this->groupId, 
'pagename' => 'search', 'toptab' => $this->topTab));
                parent::writeHeader();
        }
        
        /**
         * getPreviousResultsUrl - get the url to go to see the previous results
         *
         * @return string url to previous results page
         */
        function getPreviousResultsUrl() {
                return 
parent::getPreviousResultsUrl().'&amp;group_id='.$this->groupId;
        }
        
        /**
         * getNextResultsUrl - get the url to go to see the next results
         *
         * @return string url to next results page
         */
        function getNextResultsUrl() {
                return 
parent::getNextResultsUrl().'&amp;group_id='.$this->groupId;
        }

        /**
         * isGroupMember - returns if the logged in user is member of the 
current group
         *
         * @param int $groupId group id
         */
        function isGroupMember($groupId) {
                $Group =& group_get_object($groupId);
                if($Group && is_object($Group) && !$Group->isError() && 
session_loggedin()) {
                        $perm =& $Group->getPermission(session_get_user());
                        if($perm && is_object($perm) && $perm->isMember()) {
                                return true;
                        }
                }
                return false;           
        }
}
?>
--- NEW FILE: HtmlSearchRenderer.class ---
<?php

/**
 * GForge Search Engine
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
 *
 * http://gforge.org
 *
 * @version $Id: HtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet Exp $
 */

require_once('www/search/include/renderers/SearchRenderer.class');

class HtmlSearchRenderer extends SearchRenderer {

        /**
         * Localization BaseLanguage object
         *
         * @var object $Language
         */
        var $Language;
        
        /**
         * Headers of the HTML results table
         *
         * @var array $tableHeaders
         */
        var $tableHeaders = array();

        /**
         * Constructor
         *
         * @param string $typeOfSearch type of the search (Software, Forum, 
People and so on)
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param object $searchQuery SearchQuery instance
         */
        function HtmlSearchRenderer($typeOfSearch, $words, $isExact, 
$searchQuery) {
                global $Language;
                $this->Language =& $GLOBALS['Language'];
                
                $this->SearchRenderer($typeOfSearch, $words, $isExact, 
$searchQuery);
        }

        /**
         * flush - flush the html output
         */
        function flush() {
                $searchQuery =& $this->searchQuery;
                if($searchQuery->isError()) {
                        $this->writeHeader();
                        echo '<h2>'.$this->Language->getText('search', 
$searchQuery->getErrorMessage()).'</h2>';
                        $this->writeFooter();
                } else {
                        $searchQuery->executeQuery();
                        if($searchQuery->getResult() && 
($searchQuery->getRowsTotalCount() == 1 && $searchQuery->getOffset() == 0) && 
$this->implementsRedirectToResult()) {
                                $this->redirectToResult();
                        } else {
                                $this->writeHeader();
                                $this->writeBody();
                                $this->writeFooter();
                        }
                }
        }

        /**
         * writeHeader - write the header of the output
         */
        function writeHeader() {
                echo '<div align="center">';
                echo $GLOBALS['HTML']->searchBox();
                echo '</div>';
        }

        /**
         * writeBody - write the body
         */
        function writeBody() {
                echo $this->writeResults();
        }

        /**
         * writeFooter - write the footer
         */
        function writeFooter() {
                $GLOBALS['HTML']->footer(array());
        }
        
        /**
         * getResults - get the html output which will display the search 
results
         *
         * @return string html output
         */
        function writeResults() {
                $searchQuery =& $this->searchQuery;
                $query =& $this->query;
                
                $html = '';
                
                if(!$searchQuery->getResult() || $searchQuery->getRowsCount() < 
1) {
                        $html .= '<h2>'.$this->Language->getText('search', 
'no_matches_found', array(htmlspecialchars($query['words']))).'</h2>';
                        $html .= db_error();
                } else {
                        $html .= '<h3>'.$this->Language->getText('search', 
'search_results', array(htmlspecialchars($query['words']))).'</h3>';
                
                        $html .= 
$GLOBALS['HTML']->listTableTop($this->tableHeaders);
                        $html .= $this->getRows();
                        $html .= $GLOBALS['HTML']->listTableBottom();
                }
                
                if($searchQuery->getRowsCount() > 0 && 
($searchQuery->getRowsTotalCount() > $searchQuery->getRowsCount() || 
$searchQuery->getOffset() != 0 )) {
                        $html .= $this->getNavigationPanel();
                }
                
                return $html;
        }

        /**
         * getNavigationPanel - get the html output for the navigation panel
         *
         * @return string html output
         */ 
        function getNavigationPanel() {
                $searchQuery =& $this->searchQuery;
                
                $html = '';
                $html .= '<br />';
                $html .= '<table 
style="background-color:'.$GLOBALS['HTML']->COLOR_LTBACK1.'" width="100%" 
cellpadding="5" cellspacing="0">';
                $html .= '<tr>';
                $html .= '<td>';
                if ($searchQuery->getOffset() != 0) {
                        $html .= '<a href="'.$this->getPreviousResultsUrl().'" 
style="text-decoration: none; font-weight:bold;">'
                                . html_image('t2.png', '15', '15', 
array('border'=>'0','align'=>'middle'))
                                . ' '.$this->Language->getText('search', 
'previous_results').'</a>';
                } else {
                        $html .= '&nbsp;';
                }
                $html .= '</td><td align="right">';
                if ($searchQuery->getRowsTotalCount() > 
$searchQuery->getRowsCount()) {
                        $html .= '<a href="'.$this->getNextResultsUrl().'" 
style="text-decoration: none; font-weight:bold;">'
                                .$this->Language->getText('search', 
'next_results').' '
                                . html_image('t.png', '15', '15', 
array('border'=>'0','align'=>'middle')) . '</a>';
                } else {
                        $html .= '&nbsp;';
                }
                $html .= '</td></tr>';
                $html .= '</table>';
                return $html;
        }
        
        /**
         * getPreviousResultsUrl - get the url to go to see the previous results
         *
         * @return string url to previous results page
         */
        function getPreviousResultsUrl() {
                $offset = $this->searchQuery->getOffset() - 
$this->searchQuery->getRowsPerPage();
                $query =& $this->query;
                
                $url = 
'/search/?type='.$query['typeOfSearch'].'&amp;exact='.$query['isExact'].'&amp;q='.urlencode($query['words']);
                if($offset > 0) {
                        $url .= '&amp;offset='.$offset;
                }
                return $url;
        }
        
        /**
         * getNextResultsUrl - get the url to go to see the next results
         *
         * @return string url to next results page
         */
        function getNextResultsUrl() {
                $query =& $this->query;
                return 
'/search/?type='.$query['typeOfSearch'].'&amp;exact='.$query['isExact'].'&amp;q='.urlencode($query['words']).'&amp;offset='.($this->searchQuery->getOffset()
 + $this->searchQuery->getRowsPerPage());
        }

        /**
         * highlightTargetWords - highlight the words we are looking for
         *
         * @param string $text text
         * @return string text with keywords highlighted
         */
        function highlightTargetWords($text) {
                if (empty($text)) {
                        return '&nbsp;';
                }
                $regexp = implode($this->searchQuery->getWords(), '|');
                return preg_replace('/('.str_replace('/', '\/', 
$regexp).')/i','<span style="background-color:pink">\1</span>', $text);
        }

        /**
         * implementsRedirectToResult - check if the current object implements 
the redirect to result feature by having a redirectToResult method
         *
         * @return boolean true if our object implements search by id, false 
otherwise.
         */
        function implementsRedirectToResult() {
                return method_exists($this, 'redirectToResult');
        }

        /**
         * getResultId - get the field value for the first row of a result 
handle
         *
         * @param string $fieldName field name
         * @return string value of the field
         */
        function getResultId($fieldName) {
                return db_result($this->searchQuery->getResult(), 0, 
$fieldName);
        }

}

?>
--- NEW FILE: SkillHtmlSearchRenderer.class ---
<?php

/**
 * GForge Search Engine
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
 *
 * http://gforge.org
 *
 * @version $Id: SkillHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet 
Exp $
 */

require_once('www/search/include/renderers/HtmlSearchRenderer.class');
require_once('common/search/SkillSearchQuery.class');

class SkillHtmlSearchRenderer extends HtmlSearchRenderer {

        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         */
        function SkillHtmlSearchRenderer($words, $offset, $isExact) {
                
                $searchQuery = new SkillSearchQuery($words, $offset, $isExact);
                
                $this->HtmlSearchRenderer(SEARCH__TYPE_IS_SKILL, $words, 
$isExact, $searchQuery);
                
                $this->tableHeaders = array(
                        $this->Language->getText('search', 'skill_name'),
                        $this->Language->getText('search', 'skill_type'),
                        $this->Language->getText('search', 'skill_title'),
                        $this->Language->getText('search', 'skill_keywords'),
                        $this->Language->getText('search', 'skill_from'),
                        $this->Language->getText('search', 'skill_to')
                );
        }

        /**
         * writeHeader - write the header of the output
         */
        function writeHeader() {
                
$GLOBALS['HTML']->header(array('title'=>$this->Language->getText('search', 
'title'), 'pagename'=>'search'));
                parent::writeHeader();
        }
        
        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                
                $monthArray = array();
                for($i = 1; $i <= 12; $i++) {
                        array_push($monthArray,date('M', mktime(0, 0, 0, $i, 
10, 1980)));
                }
                
                $return = '';
                
                for($i = 0; $i < $rowsCount; $i++) {
                        $start = db_result($result, $i, 'start');
                        $startYear = substr($start, 0, 4);
                        $startMonth = substr($start, 4, 2);

                        $finish = db_result($result, $i, 'finish');
                        $finishYear = substr($finish, 0, 4);
                        $finishMonth = substr($finish, 4, 2);
                                
                        $return .= '<tr 
'.$GLOBALS['HTML']->boxGetAltRowStyle($i).'>'
                                . '<td><a href="/users/'.db_result($result, $i, 
'user_name').'/">'
                                . db_result($result, $i, 'realname').'</a></td>'
                                . '<td>'.db_result($result, $i, 
'type_name').'</td>'
                                . '<td>'.db_result($result, $i, 'title').'</td>'
                                . '<td>'.db_result($result, $i, 
'keywords').'</td>'
                                . '<td>'.$monthArray[$startMonth - 1].' 
'.$startYear.'</td>'
                                . '<td>'.$monthArray[$finishMonth - 1].' 
'.$finishYear.'</td>'
                                . '<tr>';
                }
                
                return $return;
        }
        
        /**
         * redirectToResult - redirect the user  directly to the result when 
there is only one matching result
         */
        function redirectToResult() {
                header('Location: /users/'.$this->getResultId('user_name').'/');
                exit();
        }
}

?>
--- NEW FILE: TrackersHtmlSearchRenderer.class ---
<?php
/**
 * GForge Search Engine
 *
 * Copyright 2004 (c) Dominik Haas, GForge Team
 *
 * http://gforge.org
 *
 * @version $Id: TrackersHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 
gsmet Exp $
 */

require_once('www/search/include/renderers/HtmlGroupSearchRenderer.class');
require_once('common/search/TrackersSearchQuery.class');
        
class TrackersHtmlSearchRenderer extends HtmlGroupSearchRenderer {

        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param int $groupId group id
         * @param array $sections array of all sections to search in (array of 
strings)
         *
         */
        function TrackersHtmlSearchRenderer($words, $offset, $isExact, 
$groupId, $sections=SEARCH__ALL_SECTIONS) {
                $userIsGroupMember = $this->isGroupMember($groupId);
                        
                $searchQuery = new TrackersSearchQuery($words, $offset, 
$isExact, $groupId, $sections, $userIsGroupMember);
                
                $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_TRACKERS, 
$words, $isExact, $searchQuery, $groupId, 'tracker');
                
                $this->tableHeaders = array(
                        '&nbsp;',
                        $this->Language->getText('search', 'artifact_id'),
                        $this->Language->getText('search', 'artifact_summary'),
                        $this->Language->getText('search', 'artifact_author'),
                        $this->Language->getText('search', 'artifact_date')
                );
        }

        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                $dateFormat = $GLOBALS['sys_datefmt'];
                        
                $return = '';
                $rowColor = 0;
                $lastTracker = null;
                
                for($i = 0; $i < $rowsCount; $i++) {
                        //section changed
                        $currentTracker = db_result($result, $i, 'name');
                        if ($lastTracker != $currentTracker) {
                                $return .= '<tr><td 
colspan="5">'.$currentTracker.'</td></tr>';
                                $lastTracker = $currentTracker;
                                $rowColor = 0;
                        }
                        $return .= '<tr '. 
$GLOBALS['HTML']->boxGetAltRowStyle($rowColor) .'>'
                                                . '<td width="5%">&nbsp;</td>'
                                                . '<td>'.db_result($result, $i, 
'artifact_id').'</td>'
                                                . '<td>'
                                                        . '<a 
href="/tracker/?func=detail&group_id='.$this->groupId.'&aid='.db_result($result,
 $i, 'artifact_id')
                                                        . 
'&atid='.db_result($result, $i, 'group_artifact_id').'">'
                                                        . 
html_image('ic/msg.png', '10', '12', array('border'=>'0')).' 
'.db_result($result, $i, 'summary')
                                                        . '</a></td>'           
                                                . '<td 
width="15%">'.db_result($result, $i, 'realname').'</td>'
                                                . '<td 
width="15%">'.date($dateFormat, db_result($result, $i, 
'open_date')).'</td></tr>';
                        $rowColor ++;
                }
                return $return;
        }

        /**
         * getSections - get the array of possible sections to search in
         * 
         * @return array sections
         */             
        function getSections($groupId) {
                $userIsGroupMember = $this->isGroupMember($groupId);
                
                return $this->searchQuery->getSections($groupId, 
$userIsGroupMember);
        }
}

?>
--- NEW FILE: NewsHtmlSearchRenderer.class ---
<?php
/**
 * GForge Search Engine
 *
 * Copyright 2004 (c) Dominik Haas, GForge Team
 *
 * http://gforge.org
 *
 * @version $Id: NewsHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet 
Exp $
 */
 
require_once('www/search/include/renderers/HtmlGroupSearchRenderer.class');
require_once('common/search/NewsSearchQuery.class');

class NewsHtmlSearchRenderer extends HtmlGroupSearchRenderer {
        
        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param int $groupId group id
         * @param array $sections array of all sections to search in (array of 
strings)
         *
         */
        function NewsHtmlSearchRenderer($words, $offset, $isExact, $groupId) {
                $this->groupId = $groupId;
        
                $searchQuery = new NewsSearchQuery($words, $offset, $isExact, 
$groupId);
                
                //init the searchrendererr
                $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_NEWS, $words, 
$isExact, $searchQuery, $groupId, 'news');
                
                $this->tableHeaders = array(
                        $this->Language->getText('search', 'news_summary'),
                        $this->Language->getText('search', 'news_posted_by'),
                        $this->Language->getText('search', 'news_post_date'),
                );
        }
        
        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                $dateFormat = $GLOBALS['sys_datefmt'];
                
                $return = '';
                for($i = 0; $i < $rowsCount; $i++) {
                        $return .= '<tr '. 
$GLOBALS['HTML']->boxGetAltRowStyle($i) .'>'
                                . '<td><a href="/forum/forum.php?forum_id='. 
db_result($result, $i, 'forum_id').'">'
                                . html_image('ic/msg.png', '10', '12', 
array('border' => '0'))
                                . ' '.db_result($result, $i, 
'summary').'</a></td>
                                <td width="15%">'.db_result($result, $i, 
'realname').'</td>
                                <td width="15%">'.date($dateFormat, 
db_result($result, $i, 'post_date')).'</td></tr>';
                }
                return $return;
        }
}

?>
--- NEW FILE: DocsHtmlSearchRenderer.class ---
<?php
/**
 * GForge Search Engine
 *
 * Copyright 2004 (c) Dominik Haas, GForge Team
 *
 * http://gforge.org
 *
 * @version $Id: DocsHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet 
Exp $
 */
 
require_once('www/search/include/renderers/HtmlGroupSearchRenderer.class');
require_once('common/search/DocsSearchQuery.class');
                          
class DocsHtmlSearchRenderer extends HtmlGroupSearchRenderer {
        
        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param int $groupId group id
         * @param array $sections array of all sections to search in (array of 
strings)
         *
         */
        function DocsHtmlSearchRenderer($words, $offset, $isExact, $groupId, 
$sections=SEARCH__ALL_SECTIONS) {
        
                $userIsGroupMember = $this->isGroupMember($groupId);
                                        
                $searchQuery = new DocsSearchQuery($words, $offset, $isExact, 
$groupId, $sections, $userIsGroupMember);
                
                $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_DOCS, $words, 
$isExact, $searchQuery, $groupId, 'docman');
                
                $this->tableHeaders = array(
                        '&nbsp;',
                        $this->Language->getText('search', 'docs_id'),
                        $this->Language->getText('search', 'docs_title'),
                        $this->Language->getText('search', 'docs_description'),
                );
        }

        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                $dateFormat = $GLOBALS['sys_datefmt'];
                
                $return = '';
                
                $lastDocGroup = null;
                
                $rowColor = 0;
                for($i = 0; $i < $rowsCount; $i++) {
                        //section changed
                        $currentDocGroup = db_result($result, $i, 'groupname');
                        if ($lastDocGroup != $currentDocGroup) {
                                $return .= '<tr><td 
colspan="4">'.$currentDocGroup.'</td></tr>';
                                $lastDocGroup = $currentDocGroup;
                                $rowColor = 0;
                        }
                        $return .= '<tr '. 
$GLOBALS['HTML']->boxGetAltRowStyle($rowColor) .'>'
                                . '<td width="5%">&nbsp;</td>'
                                . '<td>'.db_result($result, $i, 'docid').'</td>'
                                . '<td><a 
href="/docman/view.php/'.$this->groupId
                                . '/'.db_result($result, $i, 
'docid').'/'.db_result($result, $i, 'title').'">'
                                . html_image('ic/msg.png', '10', '12', 
array('border' => '0'))
                                . ' '.db_result($result, $i, 
'title').'</a></td>'
                                . '<td>'.db_result($result, $i, 
'description').'</td></tr>';
                        $rowColor++;
                }
                return $return;
        }

        /**
         * getSections - get the array of possible sections to search in
         * 
         * @return array sections
         */             
        function getSections($groupId) {
                $userIsGroupMember = $this->isGroupMember($groupId);
                
                return $this->searchQuery->getSections($groupId, 
$userIsGroupMember);
        }
}

?>
--- NEW FILE: PeopleHtmlSearchRenderer.class ---
<?php

/**
 * GForge Search Engine
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
 *
 * http://gforge.org
 *
 * @version $Id: PeopleHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet 
Exp $
 */

require_once('www/search/include/renderers/HtmlSearchRenderer.class');
require_once('common/search/PeopleSearchQuery.class');

class PeopleHtmlSearchRenderer extends HtmlSearchRenderer {

        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         */
        function PeopleHtmlSearchRenderer($words, $offset, $isExact) {
                
                $searchQuery = new PeopleSearchQuery($words, $offset, $isExact);
                
                $this->HtmlSearchRenderer(SEARCH__TYPE_IS_PEOPLE, $words, 
$isExact, $searchQuery);
                
                $this->tableHeaders = array(
                        $this->Language->getText('search', 'people_user_name'),
                        $this->Language->getText('search', 'people_real_name')
                );
        }

        /**
         * writeHeader - write the header of the output
         */
        function writeHeader() {
                
$GLOBALS['HTML']->header(array('title'=>$this->Language->getText('search', 
'title'), 'pagename'=>'search'));
                parent::writeHeader();
        }
        
        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                
                $return = '';
                for($i = 0; $i < $rowsCount; $i++) {
                        $return .= '<tr '. 
$GLOBALS['HTML']->boxGetAltRowStyle($i) .'>'.
                                '<td width="40%"><a 
href="/users/'.db_result($result, $i, 
'user_name').'/">'.html_image('ic/msg.png', '10', '12', array('border'=>'0')).' 
'.db_result($result, $i, 'user_name').'</a></td>'.
                                '<td width="60%">'.db_result($result, $i, 
'realname').'</td>'.
                                '</tr>';
                }
                return $return;
        }
        
        /**
         * redirectToResult - redirect the user  directly to the result when 
there is only one matching result
         */
        function redirectToResult() {
                header('Location: /users/'.$this->getResultId('user_name').'/');
                exit();
        }
}

?>
--- NEW FILE: FrsHtmlSearchRenderer.class ---
<?php
/**
 * GForge Search Engine
 *
 * Copyright 2004 (c) Dominik Haas, GForge Team
 *
 * http://gforge.org
 *
 * @version $Id: FrsHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet 
Exp $
 */
 
require_once('www/search/include/renderers/HtmlGroupSearchRenderer.class');
require_once('common/search/FrsSearchQuery.class');
                          
class FrsHtmlSearchRenderer extends HtmlGroupSearchRenderer {
        
        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param int $groupId group id
         * @param array $sections array of all sections to search in (array of 
strings)
         *
         */
        function FrsHtmlSearchRenderer($words, $offset, $isExact, $groupId, 
$sections=SEARCH__ALL_SECTIONS) {
                $userIsGroupMember = $this->isGroupMember($groupId);
                
                $searchQuery = new FrsSearchQuery($words, $offset, $isExact, 
$groupId, $sections, $userIsGroupMember);
                
                $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_FRS, $words, 
$isExact, $searchQuery, $groupId, 'frs');
                
                $this->tableHeaders = array(
                        '&nbsp;',
                        $this->Language->getText('search', 'frs_release_name'),
                        $this->Language->getText('search', 'frs_posted_by'),
                        $this->Language->getText('search', 'frs_post_date'),
                );
        }

        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                $dateFormat = $GLOBALS['sys_datefmt'];
                
                $return = '';
                $rowColor = 0;
                $lastPackage = null;
                
                for($i = 0; $i < $rowsCount; $i++) {
                        //section changed
                        $currentPackage = db_result($result, $i, 
'package_name');
                        if ($lastPackage != $currentPackage) {
                                $return .= '<tr><td 
colspan="4">'.$currentPackage.'</td></tr>';
                                $lastPackage = $currentPackage;
                                $rowColor = 0;
                        }
                        $return .= '<tr '. 
$GLOBALS['HTML']->boxGetAltRowStyle($rowColor) .'>'
                                . '<td width="5%">&nbsp;</td>'
                                . '<td><a 
href="/frs/shownotes.php?release_id='.db_result($result, $i, 'release_id').'">'
                                . db_result($result, $i, 
'release_name').'</a></td>'
                                . '<td width="15%">'.db_result($result, $i, 
'realname').'</td>'
                                . '<td 
width="15%">'.date($dateFormat,db_result($result,$i, 
'release_date')).'</td></tr>';
                        $rowColor ++;
                }
                return $return;
        }
        
        /**
         * getSections - get the array of possible sections to search in
         * 
         * @return array sections
         */             
        function getSections($groupId) {
                $userIsGroupMember = $this->isGroupMember($groupId);
        
                return FilesSearchQuery::getSections($groupId, 
$userIsGroupMember);     
        }
}

?>
--- NEW FILE: ForumHtmlSearchRenderer.class ---
<?php

/**
 * GForge Search Engine
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
 *
 * http://gforge.org
 *
 * @version $Id: ForumHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet 
Exp $
 */

require_once('www/search/include/renderers/HtmlGroupSearchRenderer.class');
require_once('common/search/ForumSearchQuery.class');

class ForumHtmlSearchRenderer extends HtmlGroupSearchRenderer {
        
        /**
         * forum id
         *
         * @var int $groupId
         */
        var $forumId;
        
        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param int $groupId group id
         * @param int $forumId forum id
         */
        function ForumHtmlSearchRenderer($words, $offset, $isExact, $groupId, 
$forumId) {
                $this->forumId = $forumId;
                
                $searchQuery = new ForumSearchQuery($words, $offset, $isExact, 
$groupId, $forumId);
                
                $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_FORUM, $words, 
$isExact, $searchQuery, $groupId, 'forums');
                
                $this->tableHeaders = array(
                        $this->Language->getText('search', 'forum_thread'),
                        $this->Language->getText('search', 'forum_author'),
                        $this->Language->getText('search', 'forum_date')
                );
        }
        
        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                $dateFormat = $GLOBALS['sys_datefmt'];
                
                $return = '';
                for($i = 0; $i < $rowsCount; $i++) {
                        $return .= '<tr '. 
$GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td width="50%"><a 
href="/forum/message.php?msg_id='
                                . db_result($result, $i, 'msg_id').'">'
                                . html_image('ic/msg.png', '10', '12', 
array('border' => '0'))
                                . ' '.db_result($result, $i, 
'subject').'</a></td>'
                                . '<td width="30%">'.db_result($result, $i, 
'realname').'</td>'
                                . '<td width="20%">'.date($dateFormat, 
db_result($result, $i, 'post_date')).'</td></tr>';
                }
                return $return;
        }

        /**
         * getPreviousResultsUrl - get the url to go to see the previous results
         *
         * @return string url to previous results page
         */
        function getPreviousResultsUrl() {
                return 
parent::getPreviousResultsUrl().'&amp;forum_id='.$this->forumId;
        }
        
        /**
         * getNextResultsUrl - get the url to go to see the next results
         *
         * @return string url to next results page
         */
        function getNextResultsUrl() {
                return 
parent::getNextResultsUrl().'&amp;forum_id='.$this->forumId;
        }

        /**
         * redirectToResult - redirect the user  directly to the result when 
there is only one matching result
         */
        function redirectToResult() {
                header('Location: 
/forum/message.php?msg_id='.$this->getResultId('msg_id'));
                exit();
        }
}

?>
--- NEW FILE: ProjectRssSearchRenderer.class ---
<?php

/**
 * GForge Search Engine
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
 *
 * http://gforge.org
 *
 * @version $Id: ProjectRssSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet 
Exp $
 */

require_once('www/search/include/renderers/RssSearchRenderer.class');
require_once('common/search/ExportProjectSearchQuery.class');

/**
 * callback function used during the RSS export
 *
 * @param array $dataRow array containing data for the current row
 * @return string additionnal information added in the RSS document
 */
function rssProjectCallback($dataRow) {
        // $default_trove_cat defined in local.inc
        $result = db_query('SELECT trove_cat.fullpath '
                .'FROM trove_group_link, trove_cat '
                .'WHERE 
trove_group_link.trove_cat_root='.$GLOBALS['default_trove_cat'].' '
                .'AND trove_group_link.trove_cat_id=trove_cat.trove_cat_id '
                .'AND group_id=\''.$dataRow['group_id'].'\'');
        
        $return = '';
        $return .= ' | date registered: '.date('M jS Y', 
$dataRow['register_time']);
        $return .= ' | category: '.str_replace(' ', '', implode(',', 
util_result_column_to_array($result)));
        $return .= ' | license: '.$dataRow['license'];
        
        return $return;
}

class ProjectRssSearchRenderer extends RssSearchRenderer {

        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         */
        function ProjectRssSearchRenderer($words, $offset, $isExact) {
                
                $this->callbackFunction = 'rssProjectCallback';
                
                $searchQuery = new ExportProjectSearchQuery($words, $offset, 
$isExact);
                
                $this->RssSearchRenderer(SEARCH__TYPE_IS_SOFTWARE, $words, 
$isExact, $searchQuery);
        }
}

?>
--- NEW FILE: ArtifactHtmlSearchRenderer.class ---
<?php

/**
 * GForge Search Engine
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
 *
 * http://gforge.org
 *
 * @version $Id: ArtifactHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 
gsmet Exp $
 */

require_once('www/search/include/renderers/HtmlGroupSearchRenderer.class');
require_once('common/search/ArtifactSearchQuery.class');

class ArtifactHtmlSearchRenderer extends HtmlGroupSearchRenderer {
        
        /**
         * artifact id
         *
         * @var int $artifactId
         */
        var $artifactId;
        
        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         * @param int $groupId group id
         * @param int $artifactId artifact id
         */
        function ArtifactHtmlSearchRenderer($words, $offset, $isExact, 
$groupId, $artifactId) {
                $this->groupId = $groupId;
                $this->artifactId = $artifactId;
                
                $searchQuery = new ArtifactSearchQuery($words, $offset, 
$isExact, $groupId, $artifactId);
                
                $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_ARTIFACT, 
$words, $isExact, $searchQuery, $groupId, 'tracker');
                
                $this->tableHeaders = array(
                        $this->Language->getText('search', 'artifact_id'),
                        $this->Language->getText('search', 'artifact_summary'),
                        $this->Language->getText('search', 'artifact_author'),
                        $this->Language->getText('search', 'artifact_date')
                );
        }
        
        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                $groupId = $this->groupId;
                $dateFormat = $GLOBALS['sys_datefmt'];
                
                $return = '';
                for($i = 0; $i < $rowsCount; $i++) {
                        $return .= '<tr '. 
$GLOBALS['HTML']->boxGetAltRowStyle($i) .'>'
                                .'<td>'.db_result($result, $i, 
'artifact_id').'</td>'
                                .'<td><a 
href="/tracker/?group_id='.$groupId.'&amp;atid='
                                . db_result($result, $i, 'group_artifact_id') 
                                . '&amp;func=detail&aid='
                                . db_result($result, $i, 'artifact_id').'"> '
                                . html_image('ic/msg.png', '10', '12', 
array('border'=>'0'))
                                . ' '.db_result($result, $i, 
'summary').'</a></td>'
                                . '<td>'.db_result($result, $i, 
'realname')."</td>"
                                . '<td>'.date($dateFormat, db_result($result, 
$i, 'open_date')).'</td></tr>';
                }
                return $return;
        }
        
        /**
         * getPreviousResultsUrl - get the url to go to see the previous results
         *
         * @return string url to previous results page
         */
        function getPreviousResultsUrl() {
                return 
parent::getPreviousResultsUrl().'&amp;atid='.$this->artifactId;
        }
        
        /**
         * getNextResultsUrl - get the url to go to see the next results
         *
         * @return string url to next results page
         */
        function getNextResultsUrl() {
                return 
parent::getNextResultsUrl().'&amp;atid='.$this->artifactId;
        }
        
        /**
         * redirectToResult - redirect the user  directly to the result when 
there is only one matching result
         */
        function redirectToResult() {
                header('Location: 
/tracker/?group_id='.$this->groupId.'&atid='.$this->artifactId.'&func=detail&aid='.$this->getResultId('artifact_id'));
                exit();
        }
        
}

?>
--- NEW FILE: ProjectHtmlSearchRenderer.class ---
<?php

/**
 * GForge Search Engine
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
 *
 * http://gforge.org
 *
 * @version $Id: ProjectHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 
gsmet Exp $
 */

require_once('www/search/include/renderers/HtmlSearchRenderer.class');
require_once('common/search/ProjectSearchQuery.class');

class ProjectHtmlSearchRenderer extends HtmlSearchRenderer {

        /**
         * Constructor
         *
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         */
        function ProjectHtmlSearchRenderer($words, $offset, $isExact) {
                
                $searchQuery = new ProjectSearchQuery($words, $offset, 
$isExact);
                
                $this->HtmlSearchRenderer(SEARCH__TYPE_IS_SOFTWARE, $words, 
$isExact, $searchQuery);
                
                $this->tableHeaders = array(
                        $this->Language->getText('search', 'group_name'),
                        $this->Language->getText('search', 'group_description')
                );
        }

        /**
         * writeHeader - write the header of the output
         */
        function writeHeader() {
                
$GLOBALS['HTML']->header(array('title'=>$this->Language->getText('search', 
'title'), 'pagename'=>'search'));
                parent::writeHeader();
        }

        /**
         * getRows - get the html output for result rows
         *
         * @return string html output
         */
        function getRows() {
                $rowsCount = $this->searchQuery->getRowsCount();
                $result =& $this->searchQuery->getResult();
                
                $return = '';
                
                for($i = 0; $i < $rowsCount; $i++) {
                        if (db_result($result, $i, 'type') == 2) {
                                $what = 'foundry';
                        } else {
                                $what = 'projects';
                        }               
                        $return .= '<tr 
'.$GLOBALS['HTML']->boxGetAltRowStyle($i).'>'
                                .'<td width="30%"><a href="/'.$what.'/'
                                .db_result($result, $i, 'unix_group_name').'/">'
                                .html_image('ic/msg.png', '10', '12', 
array('border'=>'0'))
                                .' 
'.$this->highlightTargetWords(db_result($result, $i, 'group_name')).'</a></td>'
                                .'<td 
width="70%">'.$this->highlightTargetWords(db_result($result, $i, 
'short_description')).'</td></tr>';
                }
                
                return $return;
        }

        /**
         * redirectToResult - redirect the user  directly to the result when 
there is only one matching result
         */
        function redirectToResult() {
                header('Location: /'.($this->getResultId('type') == 2 ? 
'foundry' : 'projects').'/'.$this->getResultId('unix_group_name').'/');
                exit();
        }
        
}

?>
--- NEW FILE: SearchRenderer.class ---
<?php

class SearchRenderer extends Error {
        
        /**
         * This is not the SQL query but elements from the HTTP query
         *
         * @var array $query
         */
        var $query = array();

        /**
         * This is the searchQuery. It's a SearchQuery instance.
         *
         * @var object $searchQuery
         */
        var $searchQuery;

        /**
         * Constructor
         *
         * @param string $typeOfSearch type of search
         * @param string $words words we are searching for
         * @param int $offset offset
         * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
         */
        function SearchRenderer($typeOfSearch, $words, $isExact, $searchQuery) {
                $this->query['typeOfSearch'] = $typeOfSearch;
                $this->query['isExact'] = $isExact;
                $this->query['words'] = $words;
                
                $this->searchQuery = $searchQuery;
        }

        /**
         * flush - flush the output
         * This is an abstract method. It _MUST_ be implemented in children 
classes.
         */
        function flush() {}
        
}

?>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]