1<?php
2/**
3 * Searchformgoto Plugin
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Payton Swick <payton (at) foolord (dot) com>
7 */
8
9// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12class helper_plugin_searchformgoto extends DokuWiki_Plugin {
13
14    function getInfo() {
15        return array(
16                'author' => 'Payton Swick',
17                'email'  => 'payton@foolord.com',
18                'date'   => @file_get_contents(DOKU_PLUGIN . 'searchformgoto/VERSION'),
19                'name'   => 'SearchFormGoto Plugin',
20                'desc'   => 'The search form now has a "Go" button which will go to a page instead of searching.',
21                'url'    => 'http://wiki.splitbrain.org/plugin:searchformgoto',
22                );
23    }
24
25    function gotoform($ajax=true,$autocomplete=true) {
26        global $lang;
27        global $ACT;
28        global $ID;
29        // don't print the search form if search action has been disabled
30        if (!actionOk('search')) return false;
31
32        print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">';
33        print '<input type="hidden" name="do" value="goto" />';
34        print '<input type="hidden" name="current_ns" value="'.cleanID(getNS($ID)).'" />';
35        print '<input type="text" ';
36        if($ACT == 'search') print 'value="'.htmlspecialchars($_REQUEST['id']).'" ';
37        if(!$autocomplete) print 'autocomplete="off" ';
38        print 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" />';
39        print '<input type="submit" value="'.$this->getLang('btn_go').'" class="button" name="goto" title="'.$this->getLang('btn_go').'" />';
40        print '<input type="submit" value="'.$lang['btn_search'].'" class="button" name="goto" title="'.$lang['btn_search'].'" />';
41        if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>';
42        print '</div></form>';
43        return true;
44    }
45}