xref: /dokuwiki/lib/plugins/config/admin.php (revision 64159a61e94d0ce680071c8890e144982c3a8cbe)
110449332Schris<?php
210449332Schris/**
310449332Schris * Configuration Manager admin plugin
410449332Schris *
510449332Schris * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
610449332Schris * @author     Christopher Smith <chris@jalakai.co.uk>
7685bdd2eSBen Coburn * @author     Ben Coburn <btcoburn@silicodon.net>
810449332Schris */
910449332Schris
1010449332Schrisdefine('CM_KEYMARKER','____');            // used for settings with multiple dimensions of array indices
1110449332Schris
1210449332Schrisdefine('PLUGIN_SELF',dirname(__FILE__).'/');
1310449332Schrisdefine('PLUGIN_METADATA',PLUGIN_SELF.'settings/config.metadata.php');
147ed33b2aSAnika Henkeif(!defined('DOKU_PLUGIN_IMAGES')) define('DOKU_PLUGIN_IMAGES',DOKU_BASE.'lib/plugins/config/images/');
1510449332Schris
1610449332Schrisrequire_once(PLUGIN_SELF.'settings/config.class.php');  // main configuration class and generic settings classes
1710449332Schrisrequire_once(PLUGIN_SELF.'settings/extra.class.php');   // settings classes specific to these settings
1810449332Schris
1910449332Schris/**
2010449332Schris * All DokuWiki plugins to extend the admin function
2110449332Schris * need to inherit from this class
2210449332Schris */
2310449332Schrisclass admin_plugin_config extends DokuWiki_Admin_Plugin {
2410449332Schris
2561e35c35SAndreas Gohr    protected $_file = PLUGIN_METADATA;
2661e35c35SAndreas Gohr    protected $_config = null;
2761e35c35SAndreas Gohr    protected $_input = null;
2861e35c35SAndreas Gohr    protected $_changed = false;          // set to true if configuration has altered
2961e35c35SAndreas Gohr    protected $_error = false;
3061e35c35SAndreas Gohr    protected $_session_started = false;
3161e35c35SAndreas Gohr    protected $_localised_prompts = false;
3210449332Schris
33253d4b48SGerrit Uitslag    /**
34253d4b48SGerrit Uitslag     * @return int
35253d4b48SGerrit Uitslag     */
3661e35c35SAndreas Gohr    public function getMenuSort() { return 100; }
3710449332Schris
3810449332Schris    /**
3910449332Schris     * handle user request
4010449332Schris     */
4161e35c35SAndreas Gohr    public function handle() {
42392c9b52SHakan Sandell        global $ID, $INPUT;
4310449332Schris
44253d4b48SGerrit Uitslag        if(!$this->_restore_session() || $INPUT->int('save') != 1 || !checkSecurityToken()) {
45253d4b48SGerrit Uitslag            $this->_close_session();
46253d4b48SGerrit Uitslag            return;
47253d4b48SGerrit Uitslag        }
4810449332Schris
49253d4b48SGerrit Uitslag        if(is_null($this->_config)) {
50253d4b48SGerrit Uitslag            $this->_config = new configuration($this->_file);
51253d4b48SGerrit Uitslag        }
5210449332Schris
5310449332Schris        // don't go any further if the configuration is locked
54253d4b48SGerrit Uitslag        if($this->_config->locked) {
55253d4b48SGerrit Uitslag            $this->_close_session();
56253d4b48SGerrit Uitslag            return;
57253d4b48SGerrit Uitslag        }
5810449332Schris
59392c9b52SHakan Sandell        $this->_input = $INPUT->arr('config');
6010449332Schris
618f1011e8SPhy        foreach ($this->_config->setting as $key => $value){
620ea51e63SMatt Perry            $input = isset($this->_input[$key]) ? $this->_input[$key] : null;
6310449332Schris            if ($this->_config->setting[$key]->update($input)) {
6410449332Schris                $this->_changed = true;
6510449332Schris            }
6610449332Schris            if ($this->_config->setting[$key]->error()) $this->_error = true;
6710449332Schris        }
6810449332Schris
6910449332Schris        if ($this->_changed  && !$this->_error) {
7010449332Schris            $this->_config->save_settings($this->getPluginName());
7110449332Schris
7210449332Schris            // save state & force a page reload to get the new settings to take effect
7310449332Schris            $_SESSION['PLUGIN_CONFIG'] = array('state' => 'updated', 'time' => time());
7410449332Schris            $this->_close_session();
753295f40aSAndreas Gohr            send_redirect(wl($ID,array('do'=>'admin','page'=>'config'),true,'&'));
7610449332Schris            exit();
77e0e514e1SAndreas Gohr        } elseif(!$this->_error) {
78e0e514e1SAndreas Gohr            $this->_config->touch_settings(); // just touch to refresh cache
7910449332Schris        }
8010449332Schris
8110449332Schris        $this->_close_session();
8210449332Schris    }
8310449332Schris
8410449332Schris    /**
8510449332Schris     * output appropriate html
8610449332Schris     */
8761e35c35SAndreas Gohr    public function html() {
88685bdd2eSBen Coburn        $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here.
8910449332Schris        global $lang;
90400497e1Schris        global $ID;
9110449332Schris
9210449332Schris        if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
9389d74a2fSchris        $this->setupLocale(true);
9410449332Schris
9510449332Schris        print $this->locale_xhtml('intro');
9610449332Schris
9724a33b42SAndreas Gohr        ptln('<div id="config__manager">');
9810449332Schris
9910449332Schris        if ($this->_config->locked)
100e4a98f5cSAnika Henke            ptln('<div class="info">'.$this->getLang('locked').'</div>');
10110449332Schris        elseif ($this->_error)
102e4a98f5cSAnika Henke            ptln('<div class="error">'.$this->getLang('error').'</div>');
10310449332Schris        elseif ($this->_changed)
104e4a98f5cSAnika Henke            ptln('<div class="success">'.$this->getLang('updated').'</div>');
10510449332Schris
1065d85efc6SAdrian Lang        // POST to script() instead of wl($ID) so config manager still works if
1075d85efc6SAdrian Lang        // rewrite config is broken. Add $ID as hidden field to remember
1085d85efc6SAdrian Lang        // current ID in most cases.
109f338aa80SAndreas Gohr        ptln('<form action="'.script().'" method="post">');
110f24af591SAnika Henke        ptln('<div class="no"><input type="hidden" name="id" value="'.$ID.'" /></div>');
111634d7150SAndreas Gohr        formSecurityToken();
1124fa2dffcSBen Coburn        $this->_print_h1('dokuwiki_settings', $this->getLang('_header_dokuwiki'));
11310449332Schris
114253d4b48SGerrit Uitslag        /** @var setting[] $undefined_settings */
115685bdd2eSBen Coburn        $undefined_settings = array();
1164fa2dffcSBen Coburn        $in_fieldset = false;
1174fa2dffcSBen Coburn        $first_plugin_fieldset = true;
1184fa2dffcSBen Coburn        $first_template_fieldset = true;
11910449332Schris        foreach($this->_config->setting as $setting) {
120685bdd2eSBen Coburn            if (is_a($setting, 'setting_hidden')) {
121685bdd2eSBen Coburn                // skip hidden (and undefined) settings
122685bdd2eSBen Coburn                if ($allow_debug && is_a($setting, 'setting_undefined')) {
123685bdd2eSBen Coburn                    $undefined_settings[] = $setting;
124685bdd2eSBen Coburn                } else {
125685bdd2eSBen Coburn                    continue;
126685bdd2eSBen Coburn                }
127685bdd2eSBen Coburn            } else if (is_a($setting, 'setting_fieldset')) {
1284fa2dffcSBen Coburn                // config setting group
1294fa2dffcSBen Coburn                if ($in_fieldset) {
1304fa2dffcSBen Coburn                    ptln('  </table>');
131e260f93bSAnika Henke                    ptln('  </div>');
1324fa2dffcSBen Coburn                    ptln('  </fieldset>');
1334fa2dffcSBen Coburn                } else {
1344fa2dffcSBen Coburn                    $in_fieldset = true;
1354fa2dffcSBen Coburn                }
1364fa2dffcSBen Coburn                if ($first_plugin_fieldset && substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) {
1374fa2dffcSBen Coburn                    $this->_print_h1('plugin_settings', $this->getLang('_header_plugin'));
1384fa2dffcSBen Coburn                    $first_plugin_fieldset = false;
1394fa2dffcSBen Coburn                } else if ($first_template_fieldset && substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) {
1404fa2dffcSBen Coburn                    $this->_print_h1('template_settings', $this->getLang('_header_template'));
1414fa2dffcSBen Coburn                    $first_template_fieldset = false;
1424fa2dffcSBen Coburn                }
143685bdd2eSBen Coburn                ptln('  <fieldset id="'.$setting->_key.'">');
1444fa2dffcSBen Coburn                ptln('  <legend>'.$setting->prompt($this).'</legend>');
145c7b28ffdSAnika Henke                ptln('  <div class="table">');
1464fa2dffcSBen Coburn                ptln('  <table class="inline">');
1474fa2dffcSBen Coburn            } else {
1484fa2dffcSBen Coburn                // config settings
14910449332Schris                list($label,$input) = $setting->html($this, $this->_error);
15010449332Schris
151*64159a61SAndreas Gohr                $class = $setting->is_default()
152*64159a61SAndreas Gohr                    ? ' class="default"'
153*64159a61SAndreas Gohr                    : ($setting->is_protected() ? ' class="protected"' : '');
154*64159a61SAndreas Gohr                $error = $setting->error()
155*64159a61SAndreas Gohr                    ? ' class="value error"'
156*64159a61SAndreas Gohr                    : ' class="value"';
157*64159a61SAndreas Gohr                $icon = $setting->caution()
158*64159a61SAndreas Gohr                    ? '<img src="'.DOKU_PLUGIN_IMAGES.$setting->caution().'.png" '.
159*64159a61SAndreas Gohr                      'alt="'.$setting->caution().'" title="'.$this->getLang($setting->caution()).'" />'
160*64159a61SAndreas Gohr                    : '';
16110449332Schris
16210449332Schris                ptln('    <tr'.$class.'>');
163dde31035SAndreas Gohr                ptln('      <td class="label">');
1647ed33b2aSAnika Henke                ptln('        <span class="outkey">'.$setting->_out_key(true, true).'</span>');
165bccdba06SAndreas Gohr                ptln('        '.$icon.$label);
166dde31035SAndreas Gohr                ptln('      </td>');
16710449332Schris                ptln('      <td'.$error.'>'.$input.'</td>');
16810449332Schris                ptln('    </tr>');
16910449332Schris            }
1704fa2dffcSBen Coburn        }
17110449332Schris
17210449332Schris        ptln('  </table>');
173c7b28ffdSAnika Henke        ptln('  </div>');
1744fa2dffcSBen Coburn        if ($in_fieldset) {
1754fa2dffcSBen Coburn            ptln('  </fieldset>');
1764fa2dffcSBen Coburn        }
17710449332Schris
178685bdd2eSBen Coburn        // show undefined settings list
179685bdd2eSBen Coburn        if ($allow_debug && !empty($undefined_settings)) {
180253d4b48SGerrit Uitslag            /**
181253d4b48SGerrit Uitslag             * Callback for sorting settings
182253d4b48SGerrit Uitslag             *
183253d4b48SGerrit Uitslag             * @param setting $a
184253d4b48SGerrit Uitslag             * @param setting $b
185253d4b48SGerrit Uitslag             * @return int if $a is lower/equal/higher than $b
186253d4b48SGerrit Uitslag             */
187253d4b48SGerrit Uitslag            function _setting_natural_comparison($a, $b) {
188253d4b48SGerrit Uitslag                return strnatcmp($a->_key, $b->_key);
189253d4b48SGerrit Uitslag            }
190253d4b48SGerrit Uitslag
191685bdd2eSBen Coburn            usort($undefined_settings, '_setting_natural_comparison');
192685bdd2eSBen Coburn            $this->_print_h1('undefined_settings', $this->getLang('_header_undefined'));
193685bdd2eSBen Coburn            ptln('<fieldset>');
194c7b28ffdSAnika Henke            ptln('<div class="table">');
195685bdd2eSBen Coburn            ptln('<table class="inline">');
196685bdd2eSBen Coburn            $undefined_setting_match = array();
197685bdd2eSBen Coburn            foreach($undefined_settings as $setting) {
198*64159a61SAndreas Gohr                if (
199*64159a61SAndreas Gohr                    preg_match(
200*64159a61SAndreas Gohr                        '/^(?:plugin|tpl)'.CM_KEYMARKER.'.*?'.CM_KEYMARKER.'(.*)$/',
201*64159a61SAndreas Gohr                        $setting->_key,
202*64159a61SAndreas Gohr                        $undefined_setting_match
203*64159a61SAndreas Gohr                    )
204*64159a61SAndreas Gohr                ) {
205685bdd2eSBen Coburn                    $undefined_setting_key = $undefined_setting_match[1];
206685bdd2eSBen Coburn                } else {
207685bdd2eSBen Coburn                    $undefined_setting_key = $setting->_key;
208685bdd2eSBen Coburn                }
209685bdd2eSBen Coburn                ptln('  <tr>');
210*64159a61SAndreas Gohr                ptln('    <td class="label"><span title="$meta[\''.$undefined_setting_key.'\']">$'.
211*64159a61SAndreas Gohr                     $this->_config->_name.'[\''.$setting->_out_key().'\']</span></td>');
212685bdd2eSBen Coburn                ptln('    <td>'.$this->getLang('_msg_'.get_class($setting)).'</td>');
213685bdd2eSBen Coburn                ptln('  </tr>');
214685bdd2eSBen Coburn            }
215685bdd2eSBen Coburn            ptln('</table>');
216c7b28ffdSAnika Henke            ptln('</div>');
217685bdd2eSBen Coburn            ptln('</fieldset>');
218685bdd2eSBen Coburn        }
219685bdd2eSBen Coburn
220685bdd2eSBen Coburn        // finish up form
22110449332Schris        ptln('<p>');
22210449332Schris        ptln('  <input type="hidden" name="do"     value="admin" />');
22310449332Schris        ptln('  <input type="hidden" name="page"   value="config" />');
22410449332Schris
22510449332Schris        if (!$this->_config->locked) {
22610449332Schris            ptln('  <input type="hidden" name="save"   value="1" />');
227ae614416SAnika Henke            ptln('  <button type="submit" name="submit" accesskey="s">'.$lang['btn_save'].'</button>');
228ae614416SAnika Henke            ptln('  <button type="reset">'.$lang['btn_reset'].'</button>');
22910449332Schris        }
23010449332Schris
23110449332Schris        ptln('</p>');
23210449332Schris
23310449332Schris        ptln('</form>');
23410449332Schris        ptln('</div>');
23510449332Schris    }
23610449332Schris
23710449332Schris    /**
23810449332Schris     * @return boolean   true - proceed with handle, false - don't proceed
23910449332Schris     */
24061e35c35SAndreas Gohr    protected function _restore_session() {
24110449332Schris
24210449332Schris        // dokuwiki closes the session before act_dispatch. $_SESSION variables are all set,
24310449332Schris        // however they can't be changed without starting the session again
24410449332Schris        if (!headers_sent()) {
24510449332Schris            session_start();
24610449332Schris            $this->_session_started = true;
24710449332Schris        }
24810449332Schris
24910449332Schris        if (!isset($_SESSION['PLUGIN_CONFIG'])) return true;
25010449332Schris
25110449332Schris        $session = $_SESSION['PLUGIN_CONFIG'];
25210449332Schris        unset($_SESSION['PLUGIN_CONFIG']);
25310449332Schris
25410449332Schris        // still valid?
25510449332Schris        if (time() - $session['time'] > 120) return true;
25610449332Schris
25710449332Schris        switch ($session['state']) {
25810449332Schris            case 'updated' :
25910449332Schris                $this->_changed = true;
26010449332Schris                return false;
26110449332Schris        }
26210449332Schris
26310449332Schris        return true;
26410449332Schris    }
26510449332Schris
26661e35c35SAndreas Gohr    protected function _close_session() {
26710449332Schris      if ($this->_session_started) session_write_close();
26810449332Schris    }
26910449332Schris
270253d4b48SGerrit Uitslag    /**
271253d4b48SGerrit Uitslag     * @param bool $prompts
272253d4b48SGerrit Uitslag     */
27361e35c35SAndreas Gohr    public function setupLocale($prompts=false) {
27489d74a2fSchris
27589d74a2fSchris        parent::setupLocale();
27689d74a2fSchris        if (!$prompts || $this->_localised_prompts) return;
27789d74a2fSchris
27889d74a2fSchris        $this->_setup_localised_plugin_prompts();
27989d74a2fSchris        $this->_localised_prompts = true;
28089d74a2fSchris
28189d74a2fSchris    }
28289d74a2fSchris
283253d4b48SGerrit Uitslag    /**
284253d4b48SGerrit Uitslag     * @return bool
285253d4b48SGerrit Uitslag     */
28661e35c35SAndreas Gohr    protected function _setup_localised_plugin_prompts() {
28789d74a2fSchris        global $conf;
28889d74a2fSchris
289746855cfSBen Coburn        $langfile   = '/lang/'.$conf['lang'].'/settings.php';
29089d74a2fSchris        $enlangfile = '/lang/en/settings.php';
29189d74a2fSchris
29289d74a2fSchris        if ($dh = opendir(DOKU_PLUGIN)) {
29389d74a2fSchris            while (false !== ($plugin = readdir($dh))) {
29489d74a2fSchris                if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp' || $plugin == 'config') continue;
29589d74a2fSchris                if (is_file(DOKU_PLUGIN.$plugin)) continue;
29689d74a2fSchris
29779e79377SAndreas Gohr                if (file_exists(DOKU_PLUGIN.$plugin.$enlangfile)){
298f1f77134SEsther Brunner                    $lang = array();
29989d74a2fSchris                    @include(DOKU_PLUGIN.$plugin.$enlangfile);
30089d74a2fSchris                    if ($conf['lang'] != 'en') @include(DOKU_PLUGIN.$plugin.$langfile);
301f1f77134SEsther Brunner                    foreach ($lang as $key => $value){
302f1f77134SEsther Brunner                        $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value;
303f1f77134SEsther Brunner                    }
30489d74a2fSchris                }
3054fa2dffcSBen Coburn
3064fa2dffcSBen Coburn                // fill in the plugin name if missing (should exist for plugins with settings)
3074fa2dffcSBen Coburn                if (!isset($this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'])) {
3084fa2dffcSBen Coburn                    $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] =
309cd3ed83cSMatthias Schulte                      ucwords(str_replace('_', ' ', $plugin));
3104fa2dffcSBen Coburn                }
31189d74a2fSchris            }
31289d74a2fSchris            closedir($dh);
31389d74a2fSchris      }
31489d74a2fSchris
3154a778400SEsther Brunner        // the same for the active template
3164a778400SEsther Brunner        $tpl = $conf['template'];
3174a778400SEsther Brunner
31879e79377SAndreas Gohr        if (file_exists(tpl_incdir().$enlangfile)){
3194a778400SEsther Brunner            $lang = array();
320bc9d46afSAndreas Gohr            @include(tpl_incdir().$enlangfile);
321bc9d46afSAndreas Gohr            if ($conf['lang'] != 'en') @include(tpl_incdir().$langfile);
3224a778400SEsther Brunner            foreach ($lang as $key => $value){
3234a778400SEsther Brunner                $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value;
3244a778400SEsther Brunner            }
3254a778400SEsther Brunner        }
3264a778400SEsther Brunner
3274fa2dffcSBen Coburn        // fill in the template name if missing (should exist for templates with settings)
3284fa2dffcSBen Coburn        if (!isset($this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'])) {
3294fa2dffcSBen Coburn            $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] =
330cd3ed83cSMatthias Schulte              ucwords(str_replace('_', ' ', $tpl));
3314fa2dffcSBen Coburn        }
3324fa2dffcSBen Coburn
33389d74a2fSchris        return true;
33489d74a2fSchris    }
33589d74a2fSchris
3364fa2dffcSBen Coburn    /**
3374fa2dffcSBen Coburn     * Generates a two-level table of contents for the config plugin.
3384fa2dffcSBen Coburn     *
3394fa2dffcSBen Coburn     * @author Ben Coburn <btcoburn@silicodon.net>
340253d4b48SGerrit Uitslag     *
341253d4b48SGerrit Uitslag     * @return array
3424fa2dffcSBen Coburn     */
34361e35c35SAndreas Gohr    public function getTOC() {
344b8595a66SAndreas Gohr        if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
345b8595a66SAndreas Gohr        $this->setupLocale(true);
346b8595a66SAndreas Gohr
347685bdd2eSBen Coburn        $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here.
348685bdd2eSBen Coburn
3494fa2dffcSBen Coburn        // gather toc data
350685bdd2eSBen Coburn        $has_undefined = false;
3514fa2dffcSBen Coburn        $toc = array('conf'=>array(), 'plugin'=>array(), 'template'=>null);
3524fa2dffcSBen Coburn        foreach($this->_config->setting as $setting) {
3534fa2dffcSBen Coburn            if (is_a($setting, 'setting_fieldset')) {
3544fa2dffcSBen Coburn                if (substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) {
3554fa2dffcSBen Coburn                    $toc['plugin'][] = $setting;
3564fa2dffcSBen Coburn                } else if (substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) {
3574fa2dffcSBen Coburn                    $toc['template'] = $setting;
3584fa2dffcSBen Coburn                } else {
3594fa2dffcSBen Coburn                    $toc['conf'][] = $setting;
3604fa2dffcSBen Coburn                }
361685bdd2eSBen Coburn            } else if (!$has_undefined && is_a($setting, 'setting_undefined')) {
362685bdd2eSBen Coburn                $has_undefined = true;
3634fa2dffcSBen Coburn            }
3644fa2dffcSBen Coburn        }
3654fa2dffcSBen Coburn
366e1b31a95SBen Coburn        // build toc
367b8595a66SAndreas Gohr        $t = array();
368b8595a66SAndreas Gohr
369cbfba956SMichael Hamann        $check = false;
370cbfba956SMichael Hamann        $title = $this->getLang('_configuration_manager');
371cbfba956SMichael Hamann        $t[] = html_mktocitem(sectionID($title, $check), $title, 1);
372b8595a66SAndreas Gohr        $t[] = html_mktocitem('dokuwiki_settings', $this->getLang('_header_dokuwiki'), 1);
373253d4b48SGerrit Uitslag        /** @var setting $setting */
374e1b31a95SBen Coburn        foreach($toc['conf'] as $setting) {
375e1b31a95SBen Coburn            $name = $setting->prompt($this);
376b8595a66SAndreas Gohr            $t[] = html_mktocitem($setting->_key, $name, 2);
377e1b31a95SBen Coburn        }
378e1b31a95SBen Coburn        if (!empty($toc['plugin'])) {
379b8595a66SAndreas Gohr            $t[] = html_mktocitem('plugin_settings', $this->getLang('_header_plugin'), 1);
380e1b31a95SBen Coburn        }
381e1b31a95SBen Coburn        foreach($toc['plugin'] as $setting) {
382e1b31a95SBen Coburn            $name = $setting->prompt($this);
383b8595a66SAndreas Gohr            $t[] = html_mktocitem($setting->_key, $name, 2);
384e1b31a95SBen Coburn        }
385e1b31a95SBen Coburn        if (isset($toc['template'])) {
386b8595a66SAndreas Gohr            $t[] = html_mktocitem('template_settings', $this->getLang('_header_template'), 1);
387e1b31a95SBen Coburn            $setting = $toc['template'];
388e1b31a95SBen Coburn            $name = $setting->prompt($this);
389b8595a66SAndreas Gohr            $t[] = html_mktocitem($setting->_key, $name, 2);
390e1b31a95SBen Coburn        }
391e1b31a95SBen Coburn        if ($has_undefined && $allow_debug) {
392b8595a66SAndreas Gohr            $t[] = html_mktocitem('undefined_settings', $this->getLang('_header_undefined'), 1);
393e1b31a95SBen Coburn        }
394e1b31a95SBen Coburn
395b8595a66SAndreas Gohr        return $t;
3964fa2dffcSBen Coburn    }
3974fa2dffcSBen Coburn
398253d4b48SGerrit Uitslag    /**
399253d4b48SGerrit Uitslag     * @param string $id
400253d4b48SGerrit Uitslag     * @param string $text
401253d4b48SGerrit Uitslag     */
40261e35c35SAndreas Gohr    protected function _print_h1($id, $text) {
40363e967bdSAnika Henke        ptln('<h1 id="'.$id.'">'.$text.'</h1>');
4044fa2dffcSBen Coburn    }
4054fa2dffcSBen Coburn
40661e35c35SAndreas Gohr    /**
40761e35c35SAndreas Gohr     * Adds a translation to this plugin's language array
40861e35c35SAndreas Gohr     *
40961e35c35SAndreas Gohr     * @param string $key
41061e35c35SAndreas Gohr     * @param string $value
41161e35c35SAndreas Gohr     */
41261e35c35SAndreas Gohr    public function addLang($key, $value) {
41361e35c35SAndreas Gohr        if (!$this->localised) $this->setupLocale();
41461e35c35SAndreas Gohr        $this->lang[$key] = $value;
41561e35c35SAndreas Gohr    }
41610449332Schris}
417