Skip to content
Permalink
Browse files

fix language and TOC handling

  • Loading branch information...
splitbrain committed May 25, 2018
1 parent 303ffdf commit d6fc72e108cb01b3391b9bea360e77ca03fbad2e
@@ -68,6 +68,8 @@ public function testLangs() {
$this->assertArrayNotHasKey('title', $lang);
// plugin strings
$this->assertArrayHasKey('plugin____testing____plugin_settings_name', $lang);
$this->assertEquals('Testing', $lang['plugin____testing____plugin_settings_name']);
$this->assertArrayHasKey('plugin____testing____schnibble', $lang);
$this->assertEquals(
'Turns on the schnibble before the frobble is used',
@@ -64,10 +64,10 @@ public function testPrettyKey() {
public function testType() {
/** @var Setting $setting */
$setting = new $this->class('test');
$this->assertEquals('conf', $setting->getType());
$this->assertEquals('dokuwiki', $setting->getType());
$setting = new $this->class('test_foo');
$this->assertEquals('conf', $setting->getType());
$this->assertEquals('dokuwiki', $setting->getType());
$setting = new $this->class('plugin____test');
$this->assertEquals('plugin', $setting->getType());
@@ -187,8 +187,7 @@ function settingNaturalComparison($a, $b) {
echo '<tr>';
echo
'<td class="label"><span title="$meta[\'' . $undefined_setting_key . '\']">$' .
'conf' . '[\'' . $setting->getArrayKey() . '\']</span></td>'
;
'conf' . '[\'' . $setting->getArrayKey() . '\']</span></td>';
echo '<td>' . $this->getLang('_msg_' . get_class($setting)) . '</td>';
echo '</tr>';
}
@@ -220,7 +219,7 @@ function settingNaturalComparison($a, $b) {
public function setupLocale($prompts = false) {
parent::setupLocale();
if(!$prompts || $this->promptsLocalized) return;
$this->configuration->getLangs();
$this->lang = array_merge($this->lang, $this->configuration->getLangs());
$this->promptsLocalized = true;
}
@@ -235,45 +234,46 @@ public function getTOC() {
$this->setupLocale(true);
$allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here.
$toc = array();
$check = false;
// gather settings data into three sub arrays
$toc = array('conf' => array(), 'plugin' => array(), 'template' => null);
$labels = ['dokuwiki' => [], 'plugin' => [], 'template' => []];
foreach($this->configuration->getSettings() as $setting) {
if(is_a($setting, 'setting_fieldset')) {
$toc[$setting->getType()][] = $setting;
if(is_a($setting, SettingFieldset::class)) {
$labels[$setting->getType()][] = $setting;
}
}
// build toc
$t = array();
$check = false;
// top header
$title = $this->getLang('_configuration_manager');
$t[] = html_mktocitem(sectionID($title, $check), $title, 1);
$t[] = html_mktocitem('dokuwiki_settings', $this->getLang('_header_dokuwiki'), 1);
/** @var Setting $setting */
foreach($toc['conf'] as $setting) {
$name = $setting->prompt($this);
$t[] = html_mktocitem($setting->getKey(), $name, 2);
}
if(!empty($toc['plugin'])) {
$t[] = html_mktocitem('plugin_settings', $this->getLang('_header_plugin'), 1);
}
foreach($toc['plugin'] as $setting) {
$name = $setting->prompt($this);
$t[] = html_mktocitem($setting->getKey(), $name, 2);
}
if(isset($toc['template'])) {
$t[] = html_mktocitem('template_settings', $this->getLang('_header_template'), 1);
$setting = $toc['template'];
$name = $setting->prompt($this);
$t[] = html_mktocitem($setting->getKey(), $name, 2);
$toc[] = html_mktocitem(sectionID($title, $check), $title, 1);
// main entries
foreach(['dokuwiki', 'plugin', 'template'] as $section) {
if(empty($labels[$section])) continue; // no entries, skip
// create main header
$toc[] = html_mktocitem(
$section . '_settings',
$this->getLang('_header_'.$section),
1
);
// create sub headers
foreach($labels[$section] as $setting) {
/** @var SettingFieldset $setting */
$name = $setting->prompt($this);
$toc[] = html_mktocitem($setting->getKey(), $name, 2);
}
}
// undefined settings if allowed
if(count($this->configuration->getUndefined()) && $allow_debug) {
$t[] = html_mktocitem('undefined_settings', $this->getLang('_header_undefined'), 1);
$toc[] = html_mktocitem('undefined_settings', $this->getLang('_header_undefined'), 1);
}
return $t;
return $toc;
}
/**
@@ -257,7 +257,7 @@ protected function loadExtensionLang($dir, $type, $extname) {
}
// add fieldset key
$strings[$prefix . $type . '_settings_name'] = ucwords(str_replace('_', ' ', $type));
$strings[$prefix . $type . '_settings_name'] = ucwords(str_replace('_', ' ', $extname));
return $strings;
}
@@ -143,7 +143,7 @@ public function getArrayKey() {
*
* 'plugin' for plugin configuration
* 'template' for template configuration
* 'conf' for core configuration
* 'dokuwiki' for core configuration
*
* @return string
*/
@@ -153,7 +153,7 @@ public function getType() {
} else if(substr($this->getKey(), 0, 7) == 'tpl' . Configuration::KEYMARKER) {
return 'template';
} else {
return 'conf';
return 'dokuwiki';
}
}

0 comments on commit d6fc72e

Please sign in to comment.
You can’t perform that action at this time.