4 * Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
6 * This file is part of PhpWiki.
8 * PhpWiki is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * PhpWiki is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once 'lib/PageType.php';
27 class WikiPlugin_InterWikiSearch
31 return _("InterWikiSearch");
34 function getDescription() {
35 return _("Perform searches on InterWiki sites listed in InterWikiMap.");
38 function getDefaultArguments() {
39 return array('s' => '',
44 function run($dbi, $argstr, &$request, $basepage) {
45 $args = $this->getArgs($argstr, $request);
48 if (defined('DEBUG') && !DEBUG)
49 return $this->disabled("Sorry, this plugin is currently out of order.");
51 $page = $dbi->getPage($request->getArg('pagename'));
52 return new TransformedText($page,_('InterWikiMap'),array('markup' => 2),
53 'searchableInterWikiMap');
55 return new PageType($pagerevisionhandle,
56 $pagename = _('InterWikiMap'),
58 $overridePageType = 'PageType_searchableInterWikiMap');
66 if (defined('DEBUG') && DEBUG) {
67 class PageFormatter_searchableInterWikiMap
68 extends PageFormatter_interwikimap {}
70 class PageType_searchableInterWikiMap
71 extends PageType_interwikimap
73 function format($text) {
74 return HTML::div(array('class' => 'wikitext'),
75 $this->_transform($this->_getHeader($text)),
77 $this->_transform($this->_getFooter($text)));
80 function _formatMap() {
81 return $this->_arrayToTable ($this->_getMap(), $GLOBALS['request']);
84 function _arrayToTable ($array, &$request) {
85 $thead = HTML::thead();
86 $label[0] = _("Wiki Name");
87 $label[1] = _("Search");
88 $thead->pushContent(HTML::tr(HTML::th($label[0]),
89 HTML::th($label[1])));
91 $tbody = HTML::tbody();
92 $dbi = $request->getDbh();
94 foreach ($array as $moniker => $interurl) {
95 $monikertd = HTML::td(array('class' => 'interwiki-moniker'),
96 $dbi->isWikiPage($moniker)
100 $w = new WikiPluginLoader;
101 $p = $w->getPlugin('ExternalSearch');
102 $argstr = sprintf('url="%s"', addslashes($interurl));
103 $searchtd = HTML::td($p->run($dbi, $argstr, $request, $basepage));
105 $tbody->pushContent(HTML::tr($monikertd, $searchtd));
108 $table = HTML::table();
109 $table->setAttr('class', 'interwiki-map');
110 $table->pushContent($thead);
111 $table->pushContent($tbody);
122 // c-hanging-comment-ender-p: nil
123 // indent-tabs-mode: nil