|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Plugin Search Form: Inserts a search form in any page |
| 4 | + * |
| 5 | + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) |
| 6 | + * @author Adolfo González Blázquez <code@infinicode.org> |
| 7 | + */ |
| 8 | + |
| 9 | +// must be run within Dokuwiki |
| 10 | +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); |
| 11 | +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); |
| 12 | +require_once(DOKU_PLUGIN.'syntax.php'); |
| 13 | + |
| 14 | +/** |
| 15 | + * All DokuWiki plugins to extend the parser/rendering mechanism |
| 16 | + * need to inherit from this class |
| 17 | + */ |
| 18 | +class syntax_plugin_searchform extends DokuWiki_Syntax_Plugin { |
| 19 | + |
| 20 | +function getInfo(){ |
| 21 | +return array( |
| 22 | +'author' => 'Adolfo González Blázquez', |
| 23 | +'email' => 'code@infinicode.org', |
| 24 | +'date' => '2008-10-09', |
| 25 | +'name' => 'Search Form Plugin', |
| 26 | +'desc' => 'Inserts a search form in any page', |
| 27 | +'url' => 'http://www.infinicode.org/code/dw/', |
| 28 | +); |
| 29 | + } |
| 30 | + |
| 31 | + function getType() { return 'substition'; } |
| 32 | + function getSort() { return 138; } |
| 33 | + |
| 34 | + function connectTo($mode) { |
| 35 | +$this->Lexer->addSpecialPattern('\{searchform\}',$mode,'plugin_searchform'); |
| 36 | + } |
| 37 | + |
| 38 | + function handle($match, $state, $pos, &$handler) { |
| 39 | + return array($match, $state, $pos); |
| 40 | + } |
| 41 | + |
| 42 | + function render($mode, &$renderer, $data) { |
| 43 | + |
| 44 | + global $lang; |
| 45 | + |
| 46 | +if ($mode == 'xhtml') { |
| 47 | + |
| 48 | +$renderer->doc .= '<div id="searchform_plugin">'."\n"; |
| 49 | +$renderer->doc .= '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">'."\n"; |
| 50 | +$renderer->doc .= '<input type="hidden" name="do" value="search" />'."\n"; |
| 51 | +$renderer->doc .= '<input type="text" '; |
| 52 | +if($ACT == 'search') $renderer->doc .= 'value="'.htmlspecialchars($_REQUEST['id']).'" '; |
| 53 | +if(!$autocomplete) $renderer->doc .= 'autocomplete="off" '; |
| 54 | +$renderer->doc .= 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[ALT+F]" />'."\n"; |
| 55 | +$renderer->doc .= '<input type="submit" value="'.$lang['btn_search'].'" class="button" title="'.$lang['btn_search'].'" />'."\n"; |
| 56 | +if($ajax) $renderer->doc .= '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'."\n"; |
| 57 | +$renderer->doc .= '</div></form>'."\n"; |
| 58 | +$renderer->doc .= '</div>'."\n"; |
| 59 | +return true; |
| 60 | +} |
| 61 | +return false; |
| 62 | +} |
| 63 | +} |
| 64 | +?> |
0 commit comments