1<?php 2/** 3 * DokuWiki Plugin searchdefaults (Action Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Michael Große <dokuwiki@cosmocode.de> 7 */ 8 9// must be run within Dokuwiki 10if(!defined('DOKU_INC')) die(); 11 12class action_plugin_searchdefaults extends DokuWiki_Action_Plugin { 13 14 /** 15 * Registers a callback function for a given event 16 * 17 * @param Doku_Event_Handler $controller DokuWiki's event controller object 18 * @return void 19 */ 20 public function register(Doku_Event_Handler $controller) { 21 $controller->register_hook('FORM_QUICKSEARCH_OUTPUT', 'BEFORE', $this, 'handle_form_quicksearch_output'); 22 } 23 24 /** 25 * Handles the FORM_QUICKSEARCH_OUTPUT event 26 * 27 * @param Doku_Event $event event object by reference 28 * @param mixed $param [the parameters passed as fifth argument to register_hook() when this 29 * handler was registered] 30 * @return void 31 */ 32 public function handle_form_quicksearch_output(Doku_Event $event, $param) { 33 /** @var \dokuwiki\Form\Form $qsearchForm */ 34 $qsearchForm = $event->data; 35 if ($this->getConf('default_sort') === 'mtime') { 36 $qsearchForm->setHiddenField('srt', 'mtime'); 37 } 38 if ($this->getConf('default_time_limit') !== 'any') { 39 $qsearchForm->setHiddenField('min', '1 ' . $this->getConf('default_time_limit') . ' ago'); 40 } 41 } 42 43} 44