6 * Copyright 2004 (c) Dominik Haas, GForge Team
12 require_once $gfwww.'include/pre.php';
13 require_once $gfwww.'search/include/renderers/HtmlGroupSearchRenderer.class.php';
14 require_once $gfwww.'search/include/renderers/ForumsHtmlSearchRenderer.class.php';
15 require_once $gfwww.'search/include/renderers/TrackersHtmlSearchRenderer.class.php';
16 require_once $gfwww.'search/include/renderers/TasksHtmlSearchRenderer.class.php';
17 require_once $gfwww.'search/include/renderers/DocsHtmlSearchRenderer.class.php';
18 require_once $gfwww.'search/include/renderers/FrsHtmlSearchRenderer.class.php';
19 require_once $gfwww.'search/include/renderers/NewsHtmlSearchRenderer.class.php';
21 class FullProjectHtmlSearchRenderer extends HtmlGroupSearchRenderer {
31 * the words to search for
38 * flag to define whether the result must contain all words or only one of them
40 * @var boolean $isExact
47 * @param string $words words we are searching for
48 * @param int $offset offset
49 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
50 * @param int $groupId group id
53 function FullProjectHtmlSearchRenderer($words, $offset, $isExact, $groupId) {
54 $this->groupId = $groupId;
55 $this->words = $words;
56 $this->isExact = $isExact;
58 $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_ADVANCED, $words, $isExact, $searchQuery, $groupId);
62 * flush - overwrites the flush method from htmlrenderer
70 * writeBody - write the Body of the output
72 function writeBody() {
73 $title = _('Entire project search');
74 site_project_header(array('title' => $title, 'group' => $this->groupId));
75 echo '<h1>' . $title . '</h1>';
76 echo $this->getResult();
80 * getResult - returns the Body of the output
82 * @return string result of all selected searches
84 function getResult() {
87 $group =& group_get_object($this->groupId);
89 if ($group->usesForum()) {
90 $forumsRenderer = new ForumsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
92 if ($group->usesTracker()) {
93 $trackersRenderer = new TrackersHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
95 if ($group->usesPM()) {
96 $tasksRenderer = new TasksHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
98 if ($group->usesDocman()) {
99 $docsRenderer = new DocsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
101 if ($group->usesFRS()) {
102 $frsRenderer = new FrsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
104 if ($group->usesNews()) {
105 $newsRenderer = new NewsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
108 $validLength = (strlen($this->words) >= 3);
110 if (isset($trackersRenderer) && ($validLength || (is_numeric($this->words) && $trackersRenderer->searchQuery->implementsSearchById()))) {
111 $html .= $this->getPartResult($trackersRenderer, 'short_tracker', _('Tracker Search Results'));
114 if (isset($forumsRenderer) && ($validLength || (is_numeric($this->words) && $forumsRenderer->searchQuery->implementsSearchById()))) {
115 $html .= $this->getPartResult($forumsRenderer, 'short_forum', _('Forum Search Results'));
118 if (isset($tasksRenderer) && ($validLength || (is_numeric($this->words) && $tasksRenderer->searchQuery->implementsSearchById()))) {
119 $html .= $this->getPartResult($tasksRenderer, 'short_pm', _('Task Search Results'));
122 if (isset($docsRenderer) && ($validLength || (is_numeric($this->words) && $docsRenderer->searchQuery->implementsSearchById()))) {
123 $html .= $this->getPartResult($docsRenderer, 'short_docman', _('Documentation Search Results'));
126 if (isset($frsRenderer) && ($validLength || (is_numeric($this->words) && $frsRenderer->searchQuery->implementsSearchById()))) {
127 $html .= $this->getPartResult($frsRenderer, 'short_files', _('Files Search Results'));
130 if (isset($newsRenderer) && ($validLength || (is_numeric($this->words) && $newsRenderer->searchQuery->implementsSearchById()))) {
131 $html .= $this->getPartResult($newsRenderer, 'short_news', _('News Search Results'));
134 if (! $html && ! $validLength) {
135 $html .= '<div class="error">'._('Error: search query too short').'</div>';
138 plugin_hook('full_search_engines', $this);
139 $plugin = plugin_manager_get_object();
140 $html .= $plugin->getReturnedValue('full_search_engines');
143 $renderer = new ForumsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
144 $html .= $this->getPartResult($renderer, 'short_forum', _('Forum Search Results'));
146 $renderer = new TrackersHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
147 $html .= $this->getPartResult($renderer, 'short_tracker', _('Tracker Search Results'));
149 $renderer = new TasksHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
150 $html .= $this->getPartResult($renderer, 'short_pm', _('Task Search Results'));
152 $renderer = new DocsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
153 $html .= $this->getPartResult($renderer, 'short_docman', _('Documentation Search Results'));
155 $renderer = new FrsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
156 $html .= $this->getPartResult($renderer, 'short_files', _('Files Search Results'));
158 $renderer = new NewsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
159 $html .= $this->getPartResult($renderer, 'short_news', _('News Search Results'));
162 return $html.'<br />';
166 * getPartResult - returns the result of the given renderer
168 * @return string result of the renderer
170 function getPartResult($renderer, $section, $title='') {
172 $renderer->searchQuery->executeQuery();
178 $result .= '<h2><a name="'.$section.'"></a>'.$title.'</h2>';
180 if ($renderer->searchQuery->getRowsCount() > 0) {
181 $result .= $GLOBALS['HTML']->listTabletop($renderer->tableHeaders);
182 $result .= $renderer->getRows();
183 $result .= $GLOBALS['HTML']->listTableBottom();
184 } elseif(method_exists($renderer, 'getSections') && (count($renderer->getSections($this->groupId)) == 0)) {
185 $result .= '<p>'.sprintf(_('No matches found for <em>%s</em> - No sections available (check your permissions)'), $query['words']).'</p>';
187 $result .= '<p>'.sprintf(_('No matches found for <em>%s</em> '), $query['words']).'</p>';
196 // c-file-style: "bsd"