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    protected $errorMessage = '_msg_setting_undefined';
14
15    /** @inheritdoc */
16    public function shouldHaveDefault()
17    {
18        return false;
19    }
20
21    /** @inheritdoc */
22    public function html(\admin_plugin_config $plugin, $echo = false)
23    {
24        // determine the name the meta key would be called
25        if (
26            preg_match(
27                '/^(?:plugin|tpl)' . Configuration::KEYMARKER . '.*?' . Configuration::KEYMARKER . '(.*)$/',
28                $this->getKey(),
29                $undefined_setting_match
30            )
31        ) {
32            $undefined_setting_key = $undefined_setting_match[1];
33        } else {
34            $undefined_setting_key = $this->getKey();
35        }
36
37        $label = '<span title="$meta[\'' . $undefined_setting_key . '\']">$' .
38            'conf' . '[\'' . $this->getArrayKey() . '\']</span>';
39        $input = $plugin->getLang($this->errorMessage);
40
41        return [$label, $input];
42    }
43}
44