DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:searchform

This is an old revision of the document!


searchform plugin

Compatible with DokuWiki

2008-05-05

plugin Adds the standard search form to any page

Last updated on
2008-10-10
Provides
Syntax

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to confsearch, datasearchform

Tagged with form, include, search

Download and Installation

Download and install the plugin using the Plugin Manager using the following URL. Refer to Plugins on how to install plugins manually.

You can also get the svn version using this command:

To install ither extract the downloaded zip file manually into ./lib/plugins/ or use the provided Download URL with the plugin manager.

Syntax

To use this plugin, just add {searchform} to any page you want.

More information

You can get more information on the plugin's website: http://www.infinicode.org/code/dw/ FIXME

Development

A fork is available at GitHub (zip-archive) by klap-in

Changes:

  • The searchform searches default in the namespace of the page where it is included
  • or searches the namespace given by syntax option ns=<your:namespace>
  • Multiple searchforms at one page are possible
  • Reformatting and refactoring of the code

Source

lib/plugins/searchform/syntax.php
<?php
/**
 * Plugin Search Form: Inserts a search form in any page
 * 
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Adolfo González Blázquez <code@infinicode.org>
 */
 
// must be run within Dokuwiki
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class syntax_plugin_searchform extends DokuWiki_Syntax_Plugin {
 
	function getInfo(){
		return array(
			'author' => 'Adolfo González Blázquez',
			'email'  => 'code@infinicode.org',
			'date'   => '2008-10-09',
			'name'   => 'Search Form Plugin',
			'desc'   => 'Inserts a search form in any page',
			'url'    => 'http://www.infinicode.org/code/dw/',
		);
    }
 
    function getType() { return 'substition'; }
    function getSort() { return 138; }
 
    function connectTo($mode) {
		$this->Lexer->addSpecialPattern('\{searchform\}',$mode,'plugin_searchform');
    }
 
    function handle($match, $state, $pos, &$handler) {  
    	return array($match, $state, $pos);
    }
 
    function render($mode, &$renderer, $data) {
 
 		global $lang;
 
		if ($mode == 'xhtml') {
 
			$renderer->doc .= '<div id="searchform_plugin">'."\n";
			$renderer->doc .= '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">'."\n";
			$renderer->doc .= '<input type="hidden" name="do" value="search" />'."\n";
			$renderer->doc .= '<input type="text" ';
			if($ACT == 'search') $renderer->doc .= 'value="'.htmlspecialchars($_REQUEST['id']).'" ';
			if(!$autocomplete) $renderer->doc .= 'autocomplete="off" ';
			$renderer->doc .= 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[ALT+F]" />'."\n";
			$renderer->doc .= '<input type="submit" value="'.$lang['btn_search'].'" class="button" title="'.$lang['btn_search'].'" />'."\n";
			if($ajax) $renderer->doc .= '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'."\n";
			$renderer->doc .= '</div></form>'."\n";
			$renderer->doc .= '</div>'."\n";
			return true;
		}
		return false;
	}
}
?>
plugin/searchform.1406727343.txt.gz · Last modified: 2014-07-30 15:35 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki