1<?php
2
3
4require_once(__DIR__ . '/../ComboStrap/PluginUtility.php');
5
6use ComboStrap\DirectoryLayout;
7use ComboStrap\Site;
8
9if (!defined('DOKU_INC')) exit;
10if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
11
12/**
13 * Add the txt type has an authorized type
14 */
15class action_plugin_combo_txt extends DokuWiki_Action_Plugin
16{
17
18
19
20
21    public function register(Doku_Event_Handler $controller)
22    {
23
24
25
26        /**
27         * Hack the upload done via the ajax.php file
28         * {@link media_upload()}
29         */
30        $controller->register_hook('AUTH_ACL_CHECK', 'BEFORE', $this, 'txt_mime');
31
32        /**
33         * When the parsing of a page starts
34         */
35        $controller->register_hook('PARSER_WIKITEXT_PREPROCESS', 'BEFORE', $this, 'txt_mime');
36
37    }
38
39
40    /**
41     * @param Doku_Event $event
42     * {@link media_save} is checking the authorized mime type
43     * Txt is not by default, we add it here if the user is admin or
44     * in a specified group
45     */
46    public function txt_mime(Doku_Event &$event)
47    {
48
49        /**
50         * Enhance the txt mime type
51         * {@link getMimeTypes()}
52         */
53        global $config_cascade;
54        $svgMimeConf = DirectoryLayout::getComboResourcesDirectory()->resolve("conf")->resolve("txt.mime.conf")->toAbsoluteId();
55        $config_cascade['mime']['local'][] = $svgMimeConf;
56
57    }
58
59
60
61}
62