]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/InterWikiSearch.php
improved dumphtml and virgin setup
[SourceForge/phpwiki.git] / lib / plugin / InterWikiSearch.php
1 <?php // -*-php-*-
2 rcs_id('$Id: InterWikiSearch.php,v 1.8 2004-06-28 12:51:41 rurban 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.8 $");
41     }
42
43     function getDefaultArguments() {
44         return array();
45     }
46
47     function run($dbi, $argstr, &$request, $basepage) {
48         $args = $this->getArgs($argstr, $request);
49         extract($args);
50
51         if (defined('DEBUG') && !DEBUG)
52             return $this->disabled("Sorry, this plugin is currently out of order.");
53
54         $page = $dbi->getPage($request->getArg('pagename'));
55         return new TransformedText($page,_('InterWikiMap'),array('markup' => 2),
56                                    'searchableInterWikiMap');
57         /*
58         return new PageType($pagerevisionhandle,
59                             $pagename = _('InterWikiMap'),
60                             $markup = 2,
61                             $overridePageType = 'PageType_searchableInterWikiMap');
62         */
63     }
64 };
65
66
67 /**
68  * @desc
69  */
70 if (defined('DEBUG') && DEBUG) {
71 class PageFormatter_searchableInterWikiMap 
72 extends PageFormatter_interwikimap {}
73
74 class PageType_searchableInterWikiMap
75 extends PageType_interwikimap
76 {
77     function format($text) {
78         return HTML::div(array('class' => 'wikitext'),
79                          $this->_transform($this->_getHeader($text)),
80                          $this->_formatMap(),
81                          $this->_transform($this->_getFooter($text)));
82     }
83
84     function _formatMap() {
85         return $this->_arrayToTable ($this->_getMap(), $GLOBALS['request']);
86     }
87
88     function _arrayToTable ($array, &$request) {
89         $thead = HTML::thead();
90         $label[0] = _("Wiki Name");
91         $label[1] = _("Search");
92         $thead->pushContent(HTML::tr(HTML::th($label[0]),
93                                      HTML::th($label[1])));
94
95         $tbody = HTML::tbody();
96         $dbi = $request->getDbh();
97         if ($array) {
98             foreach ($array as $moniker => $interurl) {
99                 $monikertd = HTML::td(array('class' => 'interwiki-moniker'),
100                                       $dbi->isWikiPage($moniker)
101                                       ? WikiLink($moniker)
102                                       : $moniker);
103
104                 $w = new WikiPluginLoader;
105                 $p = $w->getPlugin('ExternalSearch');
106                 $argstr = sprintf('url="%s"', addslashes($interurl));
107                 $searchtd = HTML::td($p->run($dbi, $argstr, $request, $basepage));
108
109                 $tbody->pushContent(HTML::tr($monikertd, $searchtd));
110             }
111         }
112         $table = HTML::table();
113         $table->setAttr('class', 'interwiki-map');
114         $table->pushContent($thead);
115         $table->pushContent($tbody);
116
117         return $table;
118     }
119 };
120 }
121
122
123 // $Log: not supported by cvs2svn $
124 // Revision 1.7  2004/06/15 14:56:37  rurban
125 // more allow_call_time_pass_reference false fixes
126 //
127 // Revision 1.6  2004/04/19 23:13:03  zorloc
128 // Connect the rest of PhpWiki to the IniConfig system.  Also the keyword regular expression is not a config setting
129 //
130 // Revision 1.5  2004/02/19 22:06:53  rurban
131 // use new class, to be able to get rid of lib/interwiki.php
132 //
133 // Revision 1.4  2004/02/17 12:11:36  rurban
134 // added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...)
135 //
136 // Revision 1.3  2003/02/23 20:10:48  dairiki
137 // Disable currently broken plugin to prevent fatal PHP errors.
138 // (Sorry.)
139 //
140 // Revision 1.2  2003/02/22 20:49:56  dairiki
141 // Fixes for "Call-time pass by reference has been deprecated" errors.
142 //
143 // Revision 1.1  2003/01/31 22:56:21  carstenklapp
144 // New plugin which provides entry forms to search any site listed in the InterWikiMap.
145 //
146
147 // (c-file-style: "gnu")
148 // Local Variables:
149 // mode: php
150 // tab-width: 8
151 // c-basic-offset: 4
152 // c-hanging-comment-ender-p: nil
153 // indent-tabs-mode: nil
154 // End:
155 ?>