aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2018-05-25 10:31:56 +0200
committerAndreas Gohr <andi@splitbrain.org>2018-05-25 10:44:50 +0200
commitd6fc72e108cb01b3391b9bea360e77ca03fbad2e (patch)
treef2c6c5e67e73c969e9bedfb093d5b9da96242259
parent303ffdf75e8433a27c5567239253412d84b202a9 (diff)
downloaddokuwiki-d6fc72e108cb01b3391b9bea360e77ca03fbad2e.tar.gz
dokuwiki-d6fc72e108cb01b3391b9bea360e77ca03fbad2e.zip
fix language and TOC handling
-rw-r--r--lib/plugins/config/_test/LoaderTest.php2
-rw-r--r--lib/plugins/config/_test/Setting/AbstractSettingTest.php4
-rw-r--r--lib/plugins/config/admin.php62
-rw-r--r--lib/plugins/config/core/Loader.php2
-rw-r--r--lib/plugins/config/core/Setting/Setting.php4
5 files changed, 38 insertions, 36 deletions
diff --git a/lib/plugins/config/_test/LoaderTest.php b/lib/plugins/config/_test/LoaderTest.php
index ca8479cd2..0c315842d 100644
--- a/lib/plugins/config/_test/LoaderTest.php
+++ b/lib/plugins/config/_test/LoaderTest.php
@@ -68,6 +68,8 @@ class LoaderTest extends \DokuWikiTest {
$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',
diff --git a/lib/plugins/config/_test/Setting/AbstractSettingTest.php b/lib/plugins/config/_test/Setting/AbstractSettingTest.php
index 3b24efc37..5cb94964d 100644
--- a/lib/plugins/config/_test/Setting/AbstractSettingTest.php
+++ b/lib/plugins/config/_test/Setting/AbstractSettingTest.php
@@ -64,10 +64,10 @@ class AbstractSettingTest extends \DokuWikiTest {
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());
diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php
index 32b7f2950..ea3b8f1d9 100644
--- a/lib/plugins/config/admin.php
+++ b/lib/plugins/config/admin.php
@@ -187,8 +187,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
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 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
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 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
$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;
}
/**
diff --git a/lib/plugins/config/core/Loader.php b/lib/plugins/config/core/Loader.php
index 9b25ad5d8..77e01c06f 100644
--- a/lib/plugins/config/core/Loader.php
+++ b/lib/plugins/config/core/Loader.php
@@ -257,7 +257,7 @@ class Loader {
}
// add fieldset key
- $strings[$prefix . $type . '_settings_name'] = ucwords(str_replace('_', ' ', $type));
+ $strings[$prefix . $type . '_settings_name'] = ucwords(str_replace('_', ' ', $extname));
return $strings;
}
diff --git a/lib/plugins/config/core/Setting/Setting.php b/lib/plugins/config/core/Setting/Setting.php
index bd20a7cd0..21abc3251 100644
--- a/lib/plugins/config/core/Setting/Setting.php
+++ b/lib/plugins/config/core/Setting/Setting.php
@@ -143,7 +143,7 @@ class Setting {
*
* 'plugin' for plugin configuration
* 'template' for template configuration
- * 'conf' for core configuration
+ * 'dokuwiki' for core configuration
*
* @return string
*/
@@ -153,7 +153,7 @@ class Setting {
} else if(substr($this->getKey(), 0, 7) == 'tpl' . Configuration::KEYMARKER) {
return 'template';
} else {
- return 'conf';
+ return 'dokuwiki';
}
}