1<?php
2if(!defined('DOKU_INC')) die();
3
4class action_plugin_namespacesearch extends DokuWiki_Action_Plugin {
5
6    /**
7     * Register its handlers with the DokuWiki's event controller
8     */
9    function register(Doku_Event_Handler $controller) {
10        $controller->register_hook('DOKUWIKI_STARTED', 'AFTER',  $this, '_fixquery');
11    }
12
13    /**
14     * Put namespace into search
15     */
16    function _fixquery(Doku_Event &$event, $param) {
17        global $QUERY;
18        global $ACT;
19
20        if($ACT != 'search'){
21            $QUERY = '';
22            return;
23        }
24
25        if(trim($_REQUEST['namespace'])){
26            $QUERY .= ' @'.trim($_REQUEST['namespace']);
27        }
28    }
29}
30