3 * External search plugin
5 * Copyright 2004 (c) Guillaume Smet
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.
25 require_once $gfwww.'search/include/SearchManager.class.php';
27 require_once $gfplugins.'externalsearch/common/ExternalSearchEngine.class.php';
29 forge_define_config_item('engines_file','externalsearch',
30 '$core/source_path/plugins/externalsearch/etc/engines.json'
33 class ExternalSearchPlugin extends Plugin {
34 function __construct() {
35 parent::__construct();
36 $this->name = 'externalsearch';
37 $this->text = _('External Search');
39 _("This plugin adds a new search engine to your FusionForge site. It allows
40 your users to search your FusionForge site through external search engines
41 which have indexed it. You can define search engines you want to use in
42 the configuration file.");
43 $this->hooks[] = 'search_engines';
46 function CallHook($hookname, & $searchManager) {
49 case 'search_engines':
50 if (is_file(forge_get_config('engines', 'externalsearch'))) {
51 $externalSearchEngines = json_decode (file_get_contents(forge_get_config ('engines', 'externalsearch'))) ;
52 foreach($externalSearchEngines AS $name => $url) {
53 $type = SEARCH__TYPE_IS_EXTERNAL.'_'.$name;
54 $searchManager->addSearchEngine(
56 new ExternalSearchEngine($type, $name, str_replace('%web_host%',forge_get_config('web_host'),$url)
67 // c-file-style: "bsd"