* @code based on the plugin searchform from Adolfo González Blázquez */ // 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_confsearch extends DokuWiki_Syntax_Plugin { function getInfo(){ return array( 'author' => 'Sergio Merino', 'email' => 'sergio.merino@thecorpora.com', 'date' => '2011-11-24', 'name' => 'Configurable Search Form Plugin', 'desc' => 'Inserts a configurable search form in any page', 'url' => '', ); } function getType() { return 'substition'; } function getSort() { return 138; } function connectTo($mode) { $this->Lexer->addSpecialPattern('\{confsearch[^\}]*\}',$mode,'plugin_confsearch'); } function getLastCrumb() { $br = breadcrumbs(); $lastcrumb = ''; foreach ($br as $a=>$b) $lastcrumb=$a; return $lastcrumb; } function getBaseNs($id) { return getNS(cleanID($id)); } function handle($match, $state, $pos, &$handler) { return array($match, $state, $pos); } function buttonname($data) { $params=trim($data[0]," \{\}"); list($pluginname,$parameters,$button)=split(">",$params,3); $replacedparams = str_replace(array( '@NS@', '@USER@', ), array( $this->getBaseNs($this->getLastCrumb()), $_SERVER['REMOTE_USER'], ), $button); if ($replacedparams=="") $replacedparams="Search"; return $replacedparams; } function processparameters($data) { $params=trim($data[0]," \{\}"); list($pluginname,$parameters,$button)=split(">",$params,3); $replacedparams = str_replace(array( '@NS@', '@USER@', ), array( $this->getBaseNs($this->getLastCrumb()), $_SERVER['REMOTE_USER'], ), $parameters); return $replacedparams; } function render($mode, &$renderer, $data) { global $lang; if ($mode == 'xhtml') { $renderer->doc .= '
'."\n"; $renderer->doc .= ''."\n"; $renderer->doc .= '
'."\n"; return true; } else{ $renderer->doc .= 'Hola'; } return false; } } ?>