xref: /dokuwiki/lib/plugins/config/core/Setting/SettingUndefined.php (revision 316e3ee67cce340deac79a8c6f89d881b178d094)
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(preg_match(
27            '/^(?:plugin|tpl)' . Configuration::KEYMARKER . '.*?' . Configuration::KEYMARKER . '(.*)$/',
28            $this->getKey(),
29            $undefined_setting_match
30        )) {
31            $undefined_setting_key = $undefined_setting_match[1];
32        } else {
33            $undefined_setting_key = $this->getKey();
34        }
35
36        $label = '<span title="$meta[\'' . $undefined_setting_key . '\']">$' .
37            'conf' . '[\'' . $this->getArrayKey() . '\']</span>';
38        $input = $plugin->getLang($this->errorMessage);
39
40        return [$label, $input];
41    }
42}
43