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'));
43 * getRows - get the html output for result rows
45 * @return string html output
48 $plugin_manager =& PluginManager::instance();
49 $p =& $plugin_manager->getPluginByName('forumml');
50 $rowsCount = $this->searchQuery->getRowsCount();
51 $result =& $this->searchQuery->getResult();
52 $dateFormat = _('Y-m-d H:i');
54 $group = group_get_object($this->groupId);
55 $group_name = $group->getUnixName();
57 $data = unserialize(db_result($result, 0, 'versiondata'));
59 $return = "<table width='100%'>
72 while ($rows = db_fetch_array($result)) {
75 $class="boxitemalt bgcolor-white";
77 $class="boxitem bgcolor-grey";
79 $subject=$rows['subject'];
81 $res2 = $this->getForumMLDao()->getHeaderValue($rows['id_message'],array(2,3));
83 while ($rows2 =$res2->getRow()) {
84 $header[$k] = $rows2['value'];
87 $from = mb_decode_mimeheader($header[1]);
89 // Replace '<' by '<' and '>' by '>'. Otherwise the email adress won't be displayed
90 // because it will be considered as an xhtml tag.
91 $from = preg_replace('/\</', '<', $from);
92 $from = preg_replace('/\>/', '>', $from);
93 $date = date("Y-m-d H:i",strtotime($header[2]));
94 // purify message subject (CODENDI_PURIFIER_FORUMML level)
95 $hp =& ForumML_HTMLPurifier::instance();
96 $subject = $hp->purify($subject,CODENDI_PURIFIER_FORUMML);
98 // display the resulting threads in rows
99 $return .= "<tr class='".$class."'>
101 <img src='".$p->getThemePath()."/images/ic/comment.png'/>
102 <a href='/plugins/forumml/message.php?group_id=".$this->groupId."&topic=".$rows['id_message']."&list=".$rows['id_list']."'><b>".$subject."</b></a>
105 <font class='info'>".$date."</font>
108 <font class='info'>".$from."</font>
112 $return .='</table>';
116 function getForumMLDao() {
117 return new ForumML_MessageDao(CodendiDataAccess::instance());