11<?php
22/**
33 * Plugin Search Form: Inserts a search form in any page
4- *
4+ *
55 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
66 * @author Adolfo González Blázquez <code@infinicode.org>
77 */
8-
8+
99// must be run within Dokuwiki
1010if (!defined ('DOKU_INC ' )) die ();
1111
@@ -21,32 +21,36 @@ class syntax_plugin_searchform extends DokuWiki_Syntax_Plugin {
2121 * Needs to return one of the mode types defined in $PARSER_MODES in parser.php
2222 * @return string
2323 */
24- public function getType () { return 'substition ' ; }
24+ public function getType () {
25+ return 'substition ' ;
26+ }
2527
2628 /**
2729 * Sort order when overlapping syntax
2830 * @return int
2931 */
30- public function getSort () { return 138 ; }
32+ public function getSort () {
33+ return 138 ;
34+ }
3135
3236 /**
3337 * @param $mode
3438 */
3539 public function connectTo ($ mode ) {
36- $ this ->Lexer ->addSpecialPattern ('\{searchform\} ' ,$ mode ,'plugin_searchform ' );
40+ $ this ->Lexer ->addSpecialPattern ('\{searchform\} ' , $ mode , 'plugin_searchform ' );
3741 }
3842
3943 /**
4044 * Handler to prepare matched data for the rendering process
4145 *
42- * @param string $match The text matched by the patterns
43- * @param int $state The lexer state for the match
44- * @param int $pos The character position of the matched text
46+ * @param string $match The text matched by the patterns
47+ * @param int $state The lexer state for the match
48+ * @param int $pos The character position of the matched text
4549 * @param Doku_Handler $handler Reference to the Doku_Handler object
4650 * @return array Return an array with all data you want to use in render
4751 */
4852 public function handle ($ match , $ state , $ pos , &$ handler ) {
49- return array ($ match , $ state , $ pos );
53+ return array ($ match , $ state , $ pos );
5054 }
5155
5256 /**
@@ -58,28 +62,28 @@ public function handle($match, $state, $pos, &$handler) {
5862 * @return boolean rendered correctly?
5963 */
6064 public function render ($ format , &$ renderer , $ data ) {
61- global $ lang , $ INFO , $ ACT , $ QUERY ;
62-
63- if ($ format == 'xhtml ' ) {
65+ global $ lang , $ INFO , $ ACT , $ QUERY ;
66+
67+ if ($ format == 'xhtml ' ) {
6468 // don't print the search form if search action has been disabled
6569 if (!actionOK ('search ' )) return true ;
6670
67- $ ns = $ INFO ['namespace ' ];
71+ $ ns = $ INFO ['namespace ' ];
6872 /** based on tpl_searchform() */
69- $ renderer ->doc .= '<div id="searchform_plugin"> ' . "\n" ;
70- $ renderer ->doc .= '<form action=" ' . wl (). '" accept-charset="utf-8" class="search" id="dw__search2" method="get" role="search"><div class="no"> ' . "\n" ;
71- $ renderer ->doc .= '<input type="hidden" name="do" value="search" /> ' . "\n" ;
72- $ renderer ->doc .= '<input type="hidden" id="dw__ns" name="ns" value=" ' . $ ns .'" /> ' ;
73- $ renderer ->doc .= '<input type="text" ' ;
74- if ($ ACT == 'search ' ) $ renderer ->doc .= 'value=" ' . htmlspecialchars ($ QUERY ). '" ' ;
75- $ renderer ->doc .= 'id="qsearch2__in" name="id" class="edit" /> ' . "\n" ;
76- $ renderer ->doc .= '<input type="submit" value=" ' . $ lang ['btn_search ' ]. '" class="button" title=" ' . $ lang ['btn_search ' ]. '" /> ' . "\n" ;
77- $ renderer ->doc .= '<div id="qsearch2__out" class="ajax_qsearch JSpopup"></div> ' . "\n" ;
78- $ renderer ->doc .= '</div></form> ' . "\n" ;
79- $ renderer ->doc .= '</div> ' . "\n" ;
73+ $ renderer ->doc .= '<div id="searchform_plugin"> ' . "\n" ;
74+ $ renderer ->doc .= '<form action=" ' . wl () . '" accept-charset="utf-8" class="search" id="dw__search2" method="get" role="search"><div class="no"> ' . "\n" ;
75+ $ renderer ->doc .= '<input type="hidden" name="do" value="search" /> ' . "\n" ;
76+ $ renderer ->doc .= '<input type="hidden" id="dw__ns" name="ns" value=" ' . $ ns . '" /> ' ;
77+ $ renderer ->doc .= '<input type="text" ' ;
78+ if ($ ACT == 'search ' ) $ renderer ->doc .= 'value=" ' . htmlspecialchars ($ QUERY ) . '" ' ;
79+ $ renderer ->doc .= 'id="qsearch2__in" name="id" class="edit" /> ' . "\n" ;
80+ $ renderer ->doc .= '<input type="submit" value=" ' . $ lang ['btn_search ' ] . '" class="button" title=" ' . $ lang ['btn_search ' ] . '" /> ' . "\n" ;
81+ $ renderer ->doc .= '<div id="qsearch2__out" class="ajax_qsearch JSpopup"></div> ' . "\n" ;
82+ $ renderer ->doc .= '</div></form> ' . "\n" ;
83+ $ renderer ->doc .= '</div> ' . "\n" ;
8084
81- return true ;
82- }
83- return false ;
84- }
85+ return true ;
86+ }
87+ return false ;
88+ }
8589}
0 commit comments