* @author @license GPL 2 (http://www.gnu.org/licenses/gpl.html) */ if(!defined('DOKU_INC')) die(); class action_plugin_docsearch_search extends DokuWiki_Action_Plugin { private $backupConfig; function register(Doku_Event_Handler $controller) { $controller->register_hook('TPL_CONTENT_DISPLAY', 'AFTER', $this, 'display', array()); } function display(Doku_Event &$event, $param) { global $ACT; global $conf; global $QUERY; global $lang; // only work with search if($ACT !== 'search') return; // backup the config array $this->backupConfig = $conf; // change index/pages folder for DocSearch $conf['indexdir'] = $conf['savedir'] . '/docsearch/index'; $conf['datadir'] = $conf['savedir'] . '/docsearch/pages'; $data = ft_pageSearch($QUERY, $regex); if(empty($data)) { $conf = $this->backupConfig; return; } $searchResults = array(); $runs = 0; foreach($data as $id => $hits) { $searchResults[$id] = array(); $searchResults[$id]['hits'] = $hits; if($runs++ < $this->getConf('showSnippets')) { $searchResults[$id]['snippet'] = ft_snippet($id, $regex); } } $conf = $this->backupConfig; echo '