xref: /dokuwiki/lib/plugins/config/core/Setting/SettingUndefined.php (revision 8c7c53b0321a3cd3116b8d3b2ad27863a38dece7)
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        return false;
19    }
20
21    /** @inheritdoc */
22    public function html(\admin_plugin_config $plugin, $echo = false) {
23        // determine the name the meta key would be called
24        if(preg_match(
25            '/^(?:plugin|tpl)' . Configuration::KEYMARKER . '.*?' . Configuration::KEYMARKER . '(.*)$/',
26            $this->getKey(),
27            $undefined_setting_match
28        )) {
29            $undefined_setting_key = $undefined_setting_match[1];
30        } else {
31            $undefined_setting_key = $this->getKey();
32        }
33
34        $label = '<span title="$meta[\'' . $undefined_setting_key . '\']">$' .
35            'conf' . '[\'' . $this->getArrayKey() . '\']</span>';
36        $input = $plugin->getLang($this->errorMessage);
37
38        return [$label, $input];
39    }
40}
41