aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/config/core/Setting/SettingUndefined.php
blob: e70c90cd7d794ef117809e4d978690a96e7841e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

namespace dokuwiki\plugin\config\core\Setting;

use dokuwiki\plugin\config\core\Configuration;

/**
 * A do-nothing class used to detect settings with no metadata entry.
 * Used internaly to hide undefined settings, and generate the undefined settings list.
 */
class SettingUndefined extends SettingHidden
{
    protected $errorMessage = '_msg_setting_undefined';

    /** @inheritdoc */
    public function shouldHaveDefault()
    {
        return false;
    }

    /** @inheritdoc */
    public function html(\admin_plugin_config $plugin, $echo = false)
    {
        // determine the name the meta key would be called
        if (
            preg_match(
                '/^(?:plugin|tpl)' . Configuration::KEYMARKER . '.*?' . Configuration::KEYMARKER . '(.*)$/',
                $this->getKey(),
                $undefined_setting_match
            )
        ) {
            $undefined_setting_key = $undefined_setting_match[1];
        } else {
            $undefined_setting_key = $this->getKey();
        }

        $label = '<span title="$meta[\'' . $undefined_setting_key . '\']">$' .
            'conf' . '[\'' . $this->getArrayKey() . '\']</span>';
        $input = $plugin->getLang($this->errorMessage);

        return [$label, $input];
    }
}