5 * Copyright 2004 (c) Dominik Haas, GForge Team
6 * http://fusionforge.org
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once $gfwww.'search/include/renderers/HtmlGroupSearchRenderer.class.php';
25 require_once $gfcommon.'search/DocsSearchQuery.class.php';
26 require_once $gfcommon.'docman/Document.class.php';
28 class DocsHtmlSearchRenderer extends HtmlGroupSearchRenderer {
33 * @param string $words words we are searching for
34 * @param int $offset offset
35 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
36 * @param int $groupId group id
37 * @param array $sections array of all sections to search in (array of strings)
40 function DocsHtmlSearchRenderer($words, $offset, $isExact, $groupId, $sections=SEARCH__ALL_SECTIONS) {
42 $userIsGroupMember = $this->isGroupMember($groupId);
44 $searchQuery = new DocsSearchQuery($words, $offset, $isExact, $groupId, $sections, $userIsGroupMember);
46 $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_DOCS, $words, $isExact, $searchQuery, $groupId, 'docman');
48 $this->tableHeaders = array(
57 * getRows - get the html output for result rows
59 * @return string html output
62 $rowsCount = $this->searchQuery->getRowsCount();
63 $result =& $this->searchQuery->getResult();
64 $dateFormat = _('Y-m-d H:i');
66 if (!forge_check_perm('docman', $this->groupId, 'read')) {
75 for($i = 0; $i < $rowsCount; $i++) {
77 $currentDocGroup = db_result($result, $i, 'groupname');
78 $groupObject = group_get_object($this->groupId);
79 $document = new Document($groupObject, db_result($result, $i, 'docid'));
80 if ($lastDocGroup != $currentDocGroup) {
81 $return .= '<tr><td colspan="4">'.html_image('ic/cfolder15.png', '10', '12', array('border' => '0')).util_make_link('/docman/?group_id='.$this->groupId.'&view=listfile&dirid='.$document->getDocGroupID(),$currentDocGroup).'</td></tr>';
82 $lastDocGroup = $currentDocGroup;
85 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($rowColor) .'>'
86 . '<td width="5%"> </td>'
87 . '<td>'.db_result($result, $i, 'docid').'</td>'
88 . '<td><a href="'.util_make_url ('/docman/view.php/'.$this->groupId . '/'.db_result($result, $i, 'docid').'/'.db_result($result, $i, 'filename')).'">'
89 . html_image('ic/msg.png', '10', '12', array('border' => '0'))
90 . ' '.db_result($result, $i, 'title').'</a></td>'
91 . '<td>'.db_result($result, $i, 'description').'</td></tr>';
98 * getSections - get the array of possible sections to search in
100 * @return array sections
102 static function getSections($groupId) {
103 $userIsGroupMember = DocsHtmlSearchRenderer::isGroupMember($groupId);
105 return DocsSearchQuery::getSections($groupId, $userIsGroupMember);