6 * Copyright 2004 (c) Dominik Haas, GForge Team
13 require_once('pre.php');
14 require_once('www/search/include/renderers/HtmlGroupSearchRenderer.class');
15 require_once('www/search/include/renderers/ForumsHtmlSearchRenderer.class');
16 require_once('www/search/include/renderers/TrackersHtmlSearchRenderer.class');
17 require_once('www/search/include/renderers/TasksHtmlSearchRenderer.class');
18 require_once('www/search/include/renderers/DocsHtmlSearchRenderer.class');
19 require_once('www/search/include/renderers/FrsHtmlSearchRenderer.class');
20 require_once('www/search/include/renderers/NewsHtmlSearchRenderer.class');
22 class FullProjectHtmlSearchRenderer extends HtmlGroupSearchRenderer {
32 * the words to search for
39 * flag to define whether the result must contain all words or only one of them
41 * @var boolean $isExact
48 * @param string $words words we are searching for
49 * @param int $offset offset
50 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
51 * @param int $groupId group id
54 function FullProjectHtmlSearchRenderer($words, $offset, $isExact, $groupId) {
55 $this->groupId = $groupId;
56 $this->words = $words;
57 $this->isExact = $isExact;
59 $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_ADVANCED, $words, $isExact, $searchQuery, $groupId);
63 * flush - overwrites the flush method from htmlrenderer
71 * writeBody - write the Body of the output
73 function writeBody() {
74 site_project_header(array('title' => _('Advanced project search'), 'group' => $this->groupId, ));
75 echo $this->getResult();
79 * getResult - returns the Body of the output
81 * @return string result of all selected searches
83 function getResult() {
86 $forumsRenderer = new ForumsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
87 $trackersRenderer = new TrackersHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
88 $tasksRenderer = new TasksHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
89 $docsRenderer = new DocsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
90 $frsRenderer = new FrsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
91 $newsRenderer = new NewsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
93 $validLength = (strlen($this->words) >= 3);
95 if ($validLength || (is_numeric($this->words) && $trackersRenderer->searchQuery->implementsSearchById())) {
96 $html .= $this->getPartResult($trackersRenderer, 'short_tracker');
99 if ($validLength || (is_numeric($this->words) && $forumsRenderer->searchQuery->implementsSearchById())) {
100 $html .= $this->getPartResult($forumsRenderer, 'short_forum');
103 if ($validLength || (is_numeric($this->words) && $tasksRenderer->searchQuery->implementsSearchById())) {
104 $html .= $this->getPartResult($tasksRenderer, 'short_pm');
107 if ($validLength || (is_numeric($this->words) && $docsRenderer->searchQuery->implementsSearchById())) {
108 $html .= $this->getPartResult($docsRenderer, 'short_docman');
111 if ($validLength || (is_numeric($this->words) && $frsRenderer->searchQuery->implementsSearchById())) {
112 $html .= $this->getPartResult($newsRenderer, 'short_files');
115 if ($validLength || (is_numeric($this->words) && $newsRenderer->searchQuery->implementsSearchById())) {
116 $html .= $this->getPartResult($newsRenderer, 'short_news');
120 $renderer = new ForumsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
121 $html .= $this->getPartResult($renderer, 'short_forum');
123 $renderer = new TrackersHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
124 $html .= $this->getPartResult($renderer, 'short_tracker');
126 $renderer = new TasksHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
127 $html .= $this->getPartResult($renderer, 'short_pm');
129 $renderer = new DocsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
130 $html .= $this->getPartResult($renderer, 'short_docman');
132 $renderer = new FrsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
133 $html .= $this->getPartResult($renderer, 'short_files');
135 $renderer = new NewsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
136 $html .= $this->getPartResult($renderer, 'short_news');
139 return $html.'<br />';
143 * getPartResult - returns the result of the given renderer
145 * @return string result of the renderer
147 function getPartResult($renderer, $section) {
149 $renderer->searchQuery->executeQuery();
151 $result .= '<h3><a name="'.$section.'"></a>'.sprintf(_('%1$s Search Result'), $Language->getText('group', $section)).'</h3>';
153 if ($renderer->searchQuery->getRowsCount() > 0) {
154 $result .= $GLOBALS['HTML']->listTabletop($renderer->tableHeaders);
155 $result .= $renderer->getRows();
156 $result .= $GLOBALS['HTML']->listTableBottom();
157 } elseif(method_exists($renderer, 'getSections') && (count($renderer->getSections($this->groupId)) == 0)) {
158 $result .= '<p>'.sprintf(_('No matches found - No sections available (check your permissions)'), htmlspecialchars($query['words'])).'</p>';
160 $result .= '<p>'.sprintf(_('No matches found'), htmlspecialchars($query['words'])).'</p>';