]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/InterWikiSearch.php
New plugin which provides entry forms to search any site listed in the InterWikiMap.
[SourceForge/phpwiki.git] / lib / plugin / InterWikiSearch.php
1 <?php // -*-php-*-
2 rcs_id('$Id: InterWikiSearch.php,v 1.1 2003-01-31 22:56:21 carstenklapp Exp $');
3 /**
4  Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
5
6  This file is part of PhpWiki.
7
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.
12
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.
17
18  You should have received a copy of the GNU General Public License
19  along with PhpWiki; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22 /**
23  * @description
24  */
25 require_once('lib/PageType.php');
26
27 class WikiPlugin_InterWikiSearch
28 extends WikiPlugin
29 {
30     function getName() {
31         return _("InterWikiSearch");
32     }
33
34     function getDescription() {
35         return _("Perform searches on InterWiki sites listed in InterWikiMap.");
36     }
37
38     function getVersion() {
39         return preg_replace("/[Revision: $]/", '',
40                             "\$Revision: 1.1 $");
41     }
42
43     function getDefaultArguments() {
44         return array();
45     }
46
47     function run ($dbi, $argstr, $request) {
48         $args = $this->getArgs($argstr, $request);
49         extract($args);
50
51         return PageType($pagerevisionhandle,
52                         $pagename = _('InterWikiMap'),
53                         $markup = 2,
54                         $overridePageType = 'searcableInterWikiMapPageType');
55     }
56 };
57
58
59 /**
60  * @desc
61  */
62 class searcableInterWikiMapPageType
63 extends interWikiMapPageType
64 {
65     function _arrayToTable ($array, &$request) {
66         $thead = HTML::thead();
67         $label[0] = _("Wiki Name");
68         $label[1] = _("Search");
69         $thead->pushContent(HTML::tr(HTML::td($label[0]),
70                                      HTML::td($label[1])));
71
72         $tbody = HTML::tbody();
73         $dbi = $request->getDbh();
74         if ($array) {
75             foreach ($array as $moniker => $interurl) {
76                 $monikertd = HTML::td(array('class' => 'interwiki-moniker'),
77                                       $dbi->isWikiPage($moniker)
78                                       ? WikiLink($moniker)
79                                       : $moniker);
80
81                 $w = new WikiPluginLoader;
82                 $p = $w->getPlugin('ExternalSearch');
83                 $argstr = "url=" . $moniker; // is this the right way to pass args to a plugin?
84                 $searchtd = HTML::td($p->run(&$dbi, &$argstr, &$request));
85
86                 $tbody->pushContent(HTML::tr($monikertd, $searchtd));
87             }
88         }
89         $table = HTML::table();
90         $table->setAttr('class', 'interwiki-map');
91         $table->pushContent($thead);
92         $table->pushContent($tbody);
93
94         return $table;
95     }
96 };
97
98 // $Log: not supported by cvs2svn $
99
100 // (c-file-style: "gnu")
101 // Local Variables:
102 // mode: php
103 // tab-width: 8
104 // c-basic-offset: 4
105 // c-hanging-comment-ender-p: nil
106 // indent-tabs-mode: nil
107 // End:
108 ?>