3 * MailingList Search Engine for GForge
5 * Copyright 2006 (c) Alain Peyrat
7 * @version $Id: NewsHtmlSearchRenderer.class,v 1.1 2004/10/16 16:36:31 gsmet Exp $
9 global $gfwww,$gfcommon;
10 require_once 'preplugins.php';
11 require_once $gfwww.'search/include/renderers/HtmlGroupSearchRenderer.class.php';
12 require_once(dirname(__FILE__).'/../include/ForumML_HTMLPurifier.class.php');
13 require_once(dirname(__FILE__).'/../include/ForumML_MessageDao.class.php');
14 require_once 'ForumMLSearchQuery.class.php';
16 class ForumMLHtmlSearchRenderer extends HtmlGroupSearchRenderer {
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
25 * @param int $groupId group id
26 * @param array $sections array of all sections to search in (array of strings)
29 function ForumMLHtmlSearchRenderer($words, $offset, $isExact, $groupId) {
30 $this->groupId = $groupId;
32 $searchQuery = new ForumMLSearchQuery($words, $offset, $isExact, $groupId);
34 //init the searchrendererr
35 $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_LIST, $words, $isExact,
36 $searchQuery, $groupId, 'list');
38 // $this->tableHeaders = array(_('Thread'),_('Submitted on'), _('Author'));
45 * getRows - get the html output for result rows
47 * @return string html output
50 $plugin_manager =& PluginManager::instance();
51 $p =& $plugin_manager->getPluginByName('forumml');
52 $rowsCount = $this->searchQuery->getRowsCount();
53 $result =& $this->searchQuery->getResult();
54 $dateFormat = _('Y-m-d H:i');
56 $group = group_get_object($this->groupId);
57 $group_name = $group->getUnixName();
59 $data = unserialize(db_result($result, 0, 'versiondata'));
61 $return = "<table width='100%'>
74 while ($rows = db_fetch_array($result)) {
77 $class="boxitemalt bgcolor-white";
79 $class="boxitem bgcolor-grey";
81 $subject=$rows['subject'];
83 $res2 = $this->getForumMLDao()->getHeaderValue($rows['id_message'],array(2,3));
85 while ($rows2 =$res2->getRow()) {
86 $header[$k] = $rows2['value'];
89 $from = mb_decode_mimeheader($header[1]);
91 // Replace '<' by '<' and '>' by '>'. Otherwise the email adress won't be displayed
92 // because it will be considered as an xhtml tag.
93 $from = preg_replace('/\</', '<', $from);
94 $from = preg_replace('/\>/', '>', $from);
95 $date = date("Y-m-d H:i",strtotime($header[2]));
96 // purify message subject (CODENDI_PURIFIER_FORUMML level)
97 $hp =& ForumML_HTMLPurifier::instance();
98 $subject = $hp->purify($subject,CODENDI_PURIFIER_FORUMML);
100 // display the resulting threads in rows
101 $return .= "<tr class='".$class."'>
103 <img src='".$p->getThemePath()."/images/ic/comment.png'/>
104 <a href='/plugins/forumml/message.php?group_id=".$this->groupId."&topic=".$rows['id_message']."&list=".$rows['id_list']."'><b>".$subject."</b></a>
107 <font class='info'>".$date."</font>
110 <font class='info'>".$from."</font>
114 $return .='</table>';
118 function getForumMLDao() {
119 return new ForumML_MessageDao(CodendiDataAccess::instance());