5 * Copyright 2004 (c) Dominik Haas, GForge Team
6 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
7 * http://fusionforge.org
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once $gfwww.'search/include/renderers/HtmlGroupSearchRenderer.class.php';
26 require_once $gfcommon.'search/DocsSearchQuery.class.php';
27 require_once $gfcommon.'docman/Document.class.php';
29 class DocsHtmlSearchRenderer extends HtmlGroupSearchRenderer {
34 * @param string $words words we are searching for
35 * @param int $offset offset
36 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
37 * @param int $groupId group id
38 * @param array $sections array of all sections to search in (array of strings)
41 function DocsHtmlSearchRenderer($words, $offset, $isExact, $groupId, $sections=SEARCH__ALL_SECTIONS) {
43 $userIsGroupMember = $this->isGroupMember($groupId);
45 $searchQuery = new DocsSearchQuery($words, $offset, $isExact, $groupId, $sections, $userIsGroupMember);
47 $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_DOCS, $words, $isExact, $searchQuery, $groupId, 'docman');
49 $this->tableHeaders = array(
58 * getRows - get the html output for result rows
60 * @return string html output
63 $rowsCount = $this->searchQuery->getRowsCount();
64 $result =& $this->searchQuery->getResult();
65 $dateFormat = _('Y-m-d H:i');
67 if (!forge_check_perm('docman', $this->groupId, 'read')) {
76 for($i = 0; $i < $rowsCount; $i++) {
78 $currentDocGroup = db_result($result, $i, 'groupname');
79 $groupObject = group_get_object($this->groupId);
80 $document = new Document($groupObject, db_result($result, $i, 'docid'));
81 if ($lastDocGroup != $currentDocGroup) {
82 $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>';
83 $lastDocGroup = $currentDocGroup;
86 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($rowColor) .'>'
87 . '<td width="5%"> </td>'
88 . '<td>'.db_result($result, $i, 'docid').'</td>'
89 . '<td><a href="'.util_make_url ('/docman/view.php/'.$this->groupId . '/'.db_result($result, $i, 'docid').'/'.db_result($result, $i, 'filename')).'">'
90 . html_image('ic/msg.png', '10', '12')
91 . ' '.db_result($result, $i, 'title').'</a></td>'
92 . '<td>'.db_result($result, $i, 'description').'</td></tr>';
99 * getSections - get the array of possible sections to search in
101 * @return array sections
103 static function getSections($groupId) {
104 $userIsGroupMember = DocsHtmlSearchRenderer::isGroupMember($groupId);
106 return DocsSearchQuery::getSections($groupId, $userIsGroupMember);