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
32 return _("InterWikiSearch");
35 function getDescription()
37 return _("Perform searches on InterWiki sites listed in InterWikiMap.");
40 function getDefaultArguments()
42 return array('s' => '',
47 function run($dbi, $argstr, &$request, $basepage)
49 $args = $this->getArgs($argstr, $request);
52 if (defined('DEBUG') && !DEBUG)
53 return $this->disabled("Sorry, this plugin is currently out of order.");
55 $page = $dbi->getPage($request->getArg('pagename'));
56 return new TransformedText($page, __('InterWikiMap'), array('markup' => 2),
57 'searchableInterWikiMap');
59 return new PageType($pagerevisionhandle,
60 $pagename = __('InterWikiMap'),
62 $overridePageType = 'PageType_searchableInterWikiMap');
70 if (defined('DEBUG') && DEBUG) {
71 class PageFormatter_searchableInterWikiMap
72 extends PageFormatter_interwikimap
76 class PageType_searchableInterWikiMap
77 extends PageType_interwikimap
79 function format($text)
81 return HTML::div(array('class' => 'wikitext'),
82 $this->_transform($this->_getHeader($text)),
84 $this->_transform($this->_getFooter($text)));
87 private function _formatMap()
89 return $this->_arrayToTable($this->_getMap(), $GLOBALS['request']);
92 private function _arrayToTable($array, &$request)
94 $thead = HTML::thead();
95 $label[0] = _("Wiki Name");
96 $label[1] = _("Search");
97 $thead->pushContent(HTML::tr(HTML::th($label[0]),
98 HTML::th($label[1])));
100 $tbody = HTML::tbody();
101 $dbi = $request->getDbh();
103 foreach ($array as $moniker => $interurl) {
104 $monikertd = HTML::td(array('class' => 'interwiki-moniker'),
105 $dbi->isWikiPage($moniker)
109 $w = new WikiPluginLoader;
110 $p = $w->getPlugin('ExternalSearch');
111 $argstr = sprintf('url="%s"', addslashes($interurl));
112 $searchtd = HTML::td($p->run($dbi, $argstr, $request, $basepage));
114 $tbody->pushContent(HTML::tr($monikertd, $searchtd));
117 $table = HTML::table();
118 $table->setAttr('class', 'interwiki-map');
119 $table->pushContent($thead);
120 $table->pushContent($tbody);
133 // c-hanging-comment-ender-p: nil
134 // indent-tabs-mode: nil