-<?php // -*-php-*-
-// $Id: ExternalSearch.php 8071 2011-05-18 14:56:14Z vargenau $
+<?php
+
/**
* Copyright 1999,2000,2001,2002,2006 $ThePhpWikiProgrammingTeam
*
*/
/**
- * Redirects to an external web site based on form input.
+ * Redirect to an external web site based on form input.
* See http://phpwiki.sourceforge.net/phpwiki/ExternalSearchPlugin
*
* useimage sample:
- ExternalSearch
- url="http://www.geourl.org/near/?xsize=2048&ysize=1024&xoffset=1650&yoffset=550"
- useimage="http://www.geourl.org/maps/au.png"
- name="Go Godzilla All Over It"
+ExternalSearch
+url="http://www.geourl.org/near/?xsize=2048&ysize=1024&xoffset=1650&yoffset=550"
+useimage="http://www.geourl.org/maps/au.png"
+name="Go Godzilla All Over It"
*/
if (!defined("EXTERNALSEARCH_DEFAULT_BUTTON_POSITION"))
define("EXTERNALSEARCH_DEFAULT_BUTTON_POSITION", "right");
class WikiPlugin_ExternalSearch
-extends WikiPlugin
+ extends WikiPlugin
{
- function getName () {
- return _("ExternalSearch");
- }
-
- function getDescription () {
- return _("Redirects to an external web site based on form input");
+ function getDescription()
+ {
+ return _("Redirect to an external web site based on form input.");
//fixme: better description
}
- function _getInterWikiUrl(&$request) {
+ private function getInterWikiUrl(&$request)
+ {
$intermap = getInterwikiMap();
$map = $intermap->_map;
$this->_name = $this->getName();
}
- function getDefaultArguments() {
- return array('s' => false,
- 'formsize' => 30,
- 'url' => false,
- 'name' => '',
- 'useimage' => false,
- 'width' => false,
- 'height' => false,
- 'debug' => false,
- 'button_position' => EXTERNALSEARCH_DEFAULT_BUTTON_POSITION,
- // 'left' or 'right'
- );
+ function getDefaultArguments()
+ {
+ return array('s' => false,
+ 'formsize' => 30,
+ 'url' => false,
+ 'name' => '',
+ 'useimage' => false,
+ 'width' => false,
+ 'height' => false,
+ 'debug' => false,
+ 'button_position' => EXTERNALSEARCH_DEFAULT_BUTTON_POSITION,
+ // 'left' or 'right'
+ );
}
- function run($dbi, $argstr, &$request, $basepage) {
+ function run($dbi, $argstr, &$request, $basepage)
+ {
$args = $this->getArgs($argstr, $request);
if (empty($args['url']))
return '';
if (in_array('url', array_keys($posted))) {
$s = $posted['s'];
$this->_url = $posted['url'];
- $this->_getInterWikiUrl($request);
+ $this->getInterWikiUrl($request);
if (strstr($this->_url, '%s')) {
$this->_url = sprintf($this->_url, $s);
} else
if ($formsize < 1)
$formsize = 30;
$this->_url = $url;
- $this->_getInterWikiUrl($request);
+ $this->getInterWikiUrl($request);
$form = HTML::form(array('action' => $request->getPostURL(),
- 'method' => 'post',
- //'class' => 'class', //fixme
- 'accept-charset' => $GLOBALS['charset']),
- HiddenInputs(array('pagename' => $basepage)));
+ 'method' => 'post',
+ //'class' => 'class', //fixme
+ 'accept-charset' => 'UTF-8'),
+ HiddenInputs(array('pagename' => $basepage)));
$form->pushContent(HTML::input(array('type' => 'hidden',
- 'name' => 'url',
- 'value' => $this->_url)));
+ 'name' => 'url',
+ 'value' => $this->_url)));
$s = HTML::input(array('type' => 'text',
- 'value' => $this->_s,
- 'name' => 's',
- 'size' => $formsize));
+ 'value' => $this->_s,
+ 'name' => 's',
+ 'size' => $formsize));
if (!empty($args["useimage"])) {
//FIXME: This does not work with Gecko
$button = HTML::img(array('src' => $useimage, 'alt' => 'imagebutton'));
if (!empty($width))
- $button->setAttr('width',$width);
+ $button->setAttr('width', $width);
if (!empty($height))
- $button->setAttr('height',$height);
+ $button->setAttr('height', $height);
// on button_position => none display no input form
if ($button_position == 'right')
$form->pushContent($s);
$form->pushContent(HTML::button(array('type' => 'button',
- 'class' => 'button',
- 'value' => $this->_name,
- ),
- $button));
+ 'class' => 'button',
+ 'value' => $this->_name,
+ ),
+ $button));
if ($button_position == 'left')
$form->pushContent($s);
} else {
if ($button_position != 'left' and $button_position != 'right')
return $this->error(fmt("Invalid argument: %s=%s",
- 'button_position', $button_position));
+ 'button_position', $button_position));
$button = HTML::input(array('type' => 'submit',
- 'class' => 'button',
- 'value' => $this->_name));
+ 'class' => 'button',
+ 'value' => $this->_name));
if ($button_position == 'left') {
$form->pushContent($button);
$form->pushContent($s);
}
return $form;
}
-};
+}
// Local Variables:
// mode: php