1<?php
2
3require_once DOKU_PLUGIN . 'confmanager/configTypes/ConfigManagerConfigType.php';
4require_once DOKU_PLUGIN . 'confmanager/configTypes/ConfigManagerUploadable.php';
5require_once DOKU_PLUGIN . 'confmanager/configTypes/ConfigManagerAbstractCascadeConfig.php';
6require_once DOKU_PLUGIN . 'confmanager/configTypes/ConfigManagerSingleLineConfigCascade.php';
7require_once DOKU_PLUGIN . 'confmanager/configTypes/ConfigManagerTwoLineConfigCascade.php';
8require_once DOKU_PLUGIN . 'confmanager/configTypes/ConfigManagerTwoLineLeftImageConfigCascade.php';
9require_once DOKU_PLUGIN . 'confmanager/configTypes/ConfigManagerTwoLineRightImageConfigCascade.php';
10require_once DOKU_PLUGIN . 'confmanager/configTypes/ConfigManagerTwoLine.php';
11
12/**
13 * Class action_plugin_confmanager_registerconfig
14 */
15class action_plugin_confmanager_registerconfig extends DokuWiki_Action_Plugin {
16    var $helper;
17
18    /**
19     * Register its handlers with the dokuwiki's event controller
20     *
21     * @param Doku_Event_Handler $controller
22     */
23    public function register(Doku_Event_Handler $controller) {
24        $controller->register_hook('CONFMANAGER_CONFIGFILES_REGISTER', 'BEFORE',  $this, 'addCoreConfigFiles', []);
25    }
26
27    /**
28     * Add configs for different configuration files
29     *
30     * @param Doku_Event $event
31     */
32    public function addCoreConfigFiles(Doku_Event $event) {
33        /*
34        $event->data[] = ConfigManagerConfigFile::create('smileys')
35            ->setImageFolder(DOKU_INC . 'lib/images/smileys/')
36            ->setConfigName('Smileys');
37        */
38
39        $scheme = new ConfigManagerSingleLineCoreConfig('scheme');
40        $scheme->setName($this->getLang('URL Schemes'));
41        $scheme->setDescription($this->getDescription('scheme'));
42        $event->data[] = $scheme;
43
44        $wordBlock = new ConfigManagerSingleLineCoreConfig('wordblock');
45        $wordBlock->setName($this->getLang('Blacklisting'));
46        $wordBlock->setDescription($this->getDescription('wordblock'));
47        $event->data[] = $wordBlock;
48
49        $acronyms = new ConfigManagerTwoLineCascadeConfig('acronyms');
50        $acronyms->setName($this->getLang('Acronyms'));
51        $acronyms->setDescription($this->getDescription('acronyms'));
52        $event->data[] = $acronyms;
53
54        $entities = new ConfigManagerTwoLineCascadeConfig('entities');
55        $entities->setName($this->getLang('Entity replacements'));
56        $entities->setDescription($this->getDescription('entities'));
57        $event->data[] = $entities;
58
59        $mime = new ConfigManagerTwoLineLeftImageConfigCascade('mime', 'lib/images/fileicons/svg/', 'svg');
60        $mime->setName($this->getLang('MIME configuration'));
61        $mime->setDescription($this->getDescription('mime'));
62        $event->data[] = $mime;
63
64        $interWiki = new ConfigManagerTwoLineLeftImageConfigCascade('interwiki', 'lib/images/interwiki/', 'svg,gif,png');
65        $interWiki->setName($this->getLang('InterWiki Links'));
66        $interWiki->setDescription($this->getDescription('interwiki'));
67        $event->data[] = $interWiki;
68
69        $smileys = new ConfigManagerTwoLineRightImageConfigCascade('smileys', 'lib/images/smileys/', 'svg,png,jpg,gif');
70        $smileys->setName($this->getLang('Smileys'));
71        $smileys->setDescription($this->getDescription('smileys'));
72        $event->data[] = $smileys;
73    }
74
75    /**
76     * Retrieve localized description
77     *
78     * @param string $id
79     * @return string localized wikitext description
80     */
81    private function getDescription($id) {
82        $fn = $this->localFN($id);
83        if (!@file_exists($fn)) {
84            return '';
85        }
86        $content = file_get_contents($fn);
87        return $content;
88    }
89}
90