1<?php
2/**
3 * Copyright (c) 2020. ComboStrap, Inc. and its affiliates. All Rights Reserved.
4 *
5 * This source code is licensed under the GPL license found in the
6 * COPYING  file in the root directory of this source tree.
7 *
8 * @license  GPL 3 (https://www.gnu.org/licenses/gpl-3.0.en.html)
9 * @author   ComboStrap <support@combostrap.com>
10 *
11 */
12
13namespace ComboStrap;
14
15
16class ConfUtility
17{
18
19    /**
20     * Return a plugin configuration
21     * @param $key
22     * @return mixed
23     */
24    public static function getConf($key)
25    {
26        global $conf;
27
28        if (isset($conf['plugin'][PluginUtility::PLUGIN_BASE_NAME][$key])) {
29
30            return $conf['plugin'][PluginUtility::PLUGIN_BASE_NAME][$key];
31
32        } else {
33
34            // May be not loaded
35            $path = DOKU_PLUGIN . PluginUtility::PLUGIN_BASE_NAME . '/conf/';
36            $conf = array();
37            if (file_exists($path . 'default.php')) {
38                include($path . 'default.php');
39            }
40
41            foreach ($conf as $key => $value) {
42                if (isset($conf['plugin'][PluginUtility::PLUGIN_BASE_NAME][$key])) continue;
43                $conf['plugin'][PluginUtility::PLUGIN_BASE_NAME][$key] = $value;
44            }
45
46        }
47
48        if (isset($conf['plugin'][PluginUtility::PLUGIN_BASE_NAME][$key])) {
49            return $conf['plugin'][PluginUtility::PLUGIN_BASE_NAME][$key];
50        } else {
51            LogUtility::msg("Unable to find the plugin configuration ($key)");
52            return false;
53        }
54
55
56    }
57}
58