1<?php
2
3/**
4 * Originally written for docsearch
5 *
6 * @author Dominik Eckelmann
7 */
8class action_plugin_elasticsearch_confmanager extends DokuWiki_Action_Plugin
9{
10    /** @inheritDoc */
11    public function register(Doku_Event_Handler $controller)
12    {
13        $controller->register_hook(
14            'CONFMANAGER_CONFIGFILES_REGISTER',
15            'BEFORE',
16            $this,
17            'addConfigFile',
18            []
19        );
20    }
21
22    /** @inheritDoc */
23    public function addConfigFile(Doku_Event $event, $params)
24    {
25        if (!class_exists('ConfigManagerTwoLine')) return;
26
27        $config = new ConfigManagerTwoLine(
28            $this->getLang('confmanager title'),
29            $this->getDescription(),
30            helper_plugin_elasticsearch_docparser::CONFFILE
31        );
32        $event->data[] = $config;
33    }
34
35    /**
36     * Returns the description for the configuration
37     *
38     * @return string
39     */
40    protected function getDescription()
41    {
42        $fn = $this->localFN('confmanager_description');
43        return file_get_contents($fn);
44    }
45}
46