* Search Engine
*
* Copyright 2004 (c) Dominik Haas, GForge Team
+ * Copyright 2012, Franck Villaume - TrivialDev
* http://fusionforge.org
*
- * This file is part of FusionForge.
- *
- * FusionForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
*
* FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with FusionForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
require_once $gfcommon.'include/pre.php';
require_once $gfwww.'search/include/renderers/NewsHtmlSearchRenderer.class.php';
class FullProjectHtmlSearchRenderer extends HtmlGroupSearchRenderer {
-
+
/**
* group id
*
* the words to search for
*
* @var string $words
- */
+ */
var $words;
/**
* @var boolean $isExact
*/
var $isExact;
-
+
/**
* Constructor
*
$this->groupId = $groupId;
$this->words = $words;
$this->isExact = $isExact;
-
+
$this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_ADVANCED, $words, $isExact, '', $groupId);
}
-
+
/**
* flush - overwrites the flush method from htmlrenderer
*/
*/
function writeBody() {
$title = _('Entire project search');
- site_project_header(array('title' => $title, 'group' => $this->groupId, 'toptab' => ''));
+ site_project_header(array('title' => $title, 'group' => $this->groupId, 'toptab' => 'home'));
echo $this->getResult();
}
-
+
/**
* getResult - returns the Body of the output
- *
+ *
* @return string result of all selected searches
*/
function getResult() {
}
if (! $html && ! $validLength) {
- $html .= '<div class="error">'._('Error: search query too short').'</div>';
+ $html .= '<p class="error">'._('Error: search query too short').'</p>';
}
- plugin_hook('full_search_engines', $this);
- $plugin = plugin_manager_get_object();
- $html .= $plugin->getReturnedValue('full_search_engines');
+ // This is quite complex but the goal is to extract all the
+ // registered plugins to the hook 'search_engines' and call
+ // them.
+ $pluginManager = plugin_manager_get_object();
+ $searchManager = getSearchManager();
+ $engines = $searchManager->getAvailableSearchEngines();
+
+ if (isset($pluginManager->hooks_to_plugins['full_search_engines'])) {
+ $p_list = $pluginManager->hooks_to_plugins['full_search_engines'];
+ foreach ($p_list as $p_name) {
+ $p_obj = $pluginManager->GetPluginObject($p_name);
+ $name = $p_obj->text;
+ reset($engines);
+ foreach($engines as $e) {
+ if ($e->type == $p_name) {
+ $renderer = $e->getSearchRenderer($this->words,
+ $this->offset, $this->isExact, $this->groupId);
+ $html .= $this->getPartResult($renderer, 'short_'.$p_name,
+ sprintf(_("%s Search Results"), $name));
+ }
+ }
+ }
+ }
-/*
+/*
$renderer = new ForumsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
$html .= $this->getPartResult($renderer, 'short_forum', _('Forum Search Results'));
-
+
$renderer = new TrackersHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
$html .= $this->getPartResult($renderer, 'short_tracker', _('Tracker Search Results'));
-
+
$renderer = new TasksHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
$html .= $this->getPartResult($renderer, 'short_pm', _('Task Search Results'));
$renderer = new FrsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
$html .= $this->getPartResult($renderer, 'short_files', _('Files Search Results'));
-
+
$renderer = new NewsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
$html .= $this->getPartResult($renderer, 'short_news', _('News Search Results'));
*/
- return $html.'<br />';
+ return $html.'<br />';
}
/**
- * getPartResult - returns the result of the given renderer
- *
+ * getPartResult - returns the result of the given renderer
+ *
* @return string result of the renderer
- */
+ */
function getPartResult($renderer, $section, $title='') {
$result = '';
$renderer->searchQuery->executeQuery();
-
+
if ($title === '')
$title = $section;
-
+
$result .= '<h2><a name="'.$section.'"></a>'.$title.'</h2>';
-
+
if ($renderer->searchQuery->getRowsCount() > 0) {
$result .= $GLOBALS['HTML']->listTabletop($renderer->tableHeaders);
- $result .= $renderer->getRows();
- $result .= $GLOBALS['HTML']->listTableBottom();
+ $result .= $renderer->getRows();
+ $result .= $GLOBALS['HTML']->listTableBottom();
} elseif(method_exists($renderer, 'getSections') && (count($renderer->getSections($this->groupId)) == 0)) {
$result .= '<p>'.sprintf(_('No matches found for <em>%s</em> - No sections available (check your permissions)'), $this->words).'</p>';
} else {
}
return $result;
}
-
}
// Local Variables: