1<?php
2/**
3 * DokuWiki Plugin appendtoquery (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Melanger <plugins@melanger.cz>
7 */
8class action_plugin_appendtoquery extends \dokuwiki\Extension\ActionPlugin
9{
10
11    /** @inheritDoc */
12    public function register($controller)
13    {
14        $controller->register_hook('SEARCH_QUERY_FULLPAGE', 'BEFORE', $this, 'handle_search_query_fullpage');
15        $controller->register_hook('SEARCH_QUERY_PAGELOOKUP', 'BEFORE', $this, 'handle_search_query_pagelookup');
16
17    }
18
19    /**
20     * Append a string to search queries.
21     *
22     * @param Doku_Event $event  event object by reference
23     * @param mixed      $param  optional parameter passed when event was registered
24     * @return void
25     */
26    public function handle_search_query_fullpage($event, $param)
27    {
28        global $conf;
29        $event->data['query'] = $event->data['query'] . $this->getConf('queryappend');
30    }
31
32    /**
33     * Append a string to search queries.
34     *
35     * @param Doku_Event $event  event object by reference
36     * @param mixed      $param  optional parameter passed when event was registered
37     * @return void
38     */
39    public function handle_search_query_pagelookup($event, $param)
40    {
41        global $conf;
42        $event->data['id'] = $event->data['id'] . $this->getConf('queryappend');
43    }
44}
45