2 rcs_id('$Id: ExternalSearch.php,v 1.2 2002-02-28 01:01:14 carstenklapp Exp $');
4 require_once("lib/interwiki.php");
8 class WikiPlugin_ExternalSearch
12 return _("ExternalSearch");
15 function getDescription () {
16 return _("Redirects to an external web site based on form input"); //fixme: better description
19 function _getInterWikiUrl(&$request) {
20 $intermap = InterWikiMap::GetMap($request);
21 $map = $intermap->_map;
23 if (in_array($this->_url, array_keys($map))) {
24 if (empty($this->_name))
25 $this->_name = $this->_url;
26 $this->_url = sprintf($map[$this->_url],'%s');
28 if (empty($this->_name))
29 $this->_name = $this->getName();
32 function getDefaultArguments() {
33 return array('s' => false,
41 function run($dbi, $argstr, $request) {
42 $args = $this->getArgs($argstr, $request);
43 if (empty($args['url']))
48 $posted = $GLOBALS['HTTP_POST_VARS'];
49 if (in_array('url', array_keys($posted))) {
51 $this->_url = $posted['url'];
52 $this->_getInterWikiUrl($request);
53 if (strstr($this->_url, '%s')) {
54 $this->_url = sprintf($this->_url, $s);
59 trigger_error("redirect url: ".$this->_url);
61 $request->redirect($this->_url); //no return!
71 $this->_getInterWikiUrl($request);
73 $form = HTML::form(array('action' => $this->getname(),
75 //'class' => 'class', //fixme
76 'accept-charset' => CHARSET));
78 $form->pushContent(HTML::input(array('type' => 'text',
81 'size' => $formsize)));
83 $form->pushContent(HTML::input(array('type' => 'hidden',
85 'value' => $this->_url)));
87 $form->pushContent(HTML::input(array('type' => 'submit',
89 'value' => $this->_name)));
98 // c-hanging-comment-ender-p: nil
99 // indent-tabs-mode: nil