xref: /dokuwiki/lib/plugins/config/core/Setting/SettingUndefined.php (revision 26dfc2323f8f70cb69aac4c8c51bf7997809f2ca)
1<?php
2
3namespace dokuwiki\plugin\config\core\Setting;
4
5use dokuwiki\plugin\config\core\Configuration;
6
7/**
8 * A do-nothing class used to detect settings with no metadata entry.
9 * Used internaly to hide undefined settings, and generate the undefined settings list.
10 */
11class SettingUndefined extends SettingHidden
12{
13
14    protected $errorMessage = '_msg_setting_undefined';
15
16    /** @inheritdoc */
17    public function shouldHaveDefault()
18    {
19        return false;
20    }
21
22    /** @inheritdoc */
23    public function html(\admin_plugin_config $plugin, $echo = false)
24    {
25        // determine the name the meta key would be called
26        if (
27            preg_match(
28                '/^(?:plugin|tpl)' . Configuration::KEYMARKER . '.*?' . Configuration::KEYMARKER . '(.*)$/',
29                $this->getKey(),
30                $undefined_setting_match
31            )
32        ) {
33            $undefined_setting_key = $undefined_setting_match[1];
34        } else {
35            $undefined_setting_key = $this->getKey();
36        }
37
38        $label = '<span title="$meta[\'' . $undefined_setting_key . '\']">$' .
39            'conf' . '[\'' . $this->getArrayKey() . '\']</span>';
40        $input = $plugin->getLang($this->errorMessage);
41
42        return [$label, $input];
43    }
44}
45