From 6152e7e2addede53d8d521ebea918563ab3a4e23 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Mon, 24 Sep 2018 18:35:43 -0600 Subject: ncp-web: put configuration in a separate file from available languages --- .gitignore | 1 + changelog.md | 6 ++++-- ncp-web/L10N.php | 36 +++++++++--------------------------- ncp-web/index.php | 26 +++++++++++++------------- ncp-web/langs.cfg | 5 +++++ ncp-web/ncp-web.cfg | 1 - 6 files changed, 32 insertions(+), 43 deletions(-) create mode 100644 ncp-web/langs.cfg delete mode 100644 ncp-web/ncp-web.cfg diff --git a/.gitignore b/.gitignore index 07637645..f5f622d8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ armbian/ raspbian_root raspbian_boot ncp-web/wizard.cfg +ncp-web/ncp-web.cfg docker-armhf/qemu-arm-static diff --git a/changelog.md b/changelog.md index 2d6ad8b2..c7ee6284 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,9 @@ -[v0.60.7](https://github.com/nextcloud/nextcloudpi/commit/bd464b2) (2018-09-24) docker: disable auto-upgrade until it is adapted to containers +[v0.60.8](https://github.com/nextcloud/nextcloudpi/commit/57999b6) (2018-09-24) ncp-web: put configuration in a separate file from available languages -[v0.60.6](https://github.com/nextcloud/nextcloudpi/commit/1150ed8) (2018-09-24) nc-format-USB: fix +[v0.60.7](https://github.com/nextcloud/nextcloudpi/commit/cdbb750) (2018-09-24) docker: disable auto-upgrade until it is adapted to containers + +[v0.60.6 ](https://github.com/nextcloud/nextcloudpi/commit/1150ed8) (2018-09-24) nc-format-USB: fix [v0.60.5 ](https://github.com/nextcloud/nextcloudpi/commit/3de5fe0) (2018-09-23) armbian: fix locales for ncp-config diff --git a/ncp-web/L10N.php b/ncp-web/L10N.php index 71a2ab18..2fdf5434 100644 --- a/ncp-web/L10N.php +++ b/ncp-web/L10N.php @@ -70,15 +70,7 @@ class L10N { $cfg = 'ncp-web.cfg'; $line = file_get_contents( $cfg ); - $str = ''; - if (preg_match('/^LANGUAGE_=\[(([_\w]+,)*[_\w]+)\]$/', $line, $matches)) { - $options = explode(',', $matches[1]); - foreach ($options as $option) { - $opt = trim( $option, "_" ); - $str .= $opt == $lang ? '_' . $opt . '_,' : $opt . ','; - } - } - $str = 'LANGUAGE_=[' . rtrim( $str, ',' ) . ']'; + $str = "LANGUAGE_=$lang"; return file_put_contents( $cfg , $str ); } @@ -147,25 +139,15 @@ class L10N return array_keys($langs)[0]; } - function load_language_setting($modules_path) + function load_language_setting() { $webui_config_file = 'ncp-web.cfg'; - $fh = fopen($webui_config_file, 'r') - or exit('{ "output": "' . $webui_config_file . ' read error" }'); - $lang = "auto"; - while ($line = fgets($fh)) { - // drop down menu - if (preg_match('/^LANGUAGE_=\[(([_\w]+,)*[_\w]+)\]$/', $line, $matches)) { - $options = explode(',', $matches[1]); - foreach ($options as $option) { - if ($option[0] == "_" && $option[count($option) - 1] == "_") { - fclose($fh); - $lang = trim($option, '_'); - } - } - fclose($fh); - return $lang; - } - } + $fh = fopen($webui_config_file, 'r'); + if ($fh === false) + return "auto"; + + $lang=file_get_contents($webui_config_file); + fclose($fh); + return ltrim($lang, 'LANGUAGE_='); } } diff --git a/ncp-web/index.php b/ncp-web/index.php index 9c8ca46c..a55bd69f 100644 --- a/ncp-web/index.php +++ b/ncp-web/index.php @@ -114,20 +114,20 @@ HTML; "; - foreach($options as $option) - { - echo ""; - } - echo ""; - echo ""; + $selected_lang=$l->load_language_setting(); + + $fh = fopen('langs.cfg', 'r'); + echo ""; + fclose($fh); ?>
diff --git a/ncp-web/langs.cfg b/ncp-web/langs.cfg new file mode 100644 index 00000000..d43309ff --- /dev/null +++ b/ncp-web/langs.cfg @@ -0,0 +1,5 @@ +auto +en +de +es +zh diff --git a/ncp-web/ncp-web.cfg b/ncp-web/ncp-web.cfg deleted file mode 100644 index 57888595..00000000 --- a/ncp-web/ncp-web.cfg +++ /dev/null @@ -1 +0,0 @@ -LANGUAGE_=[_auto_,en,de,es,zh] -- cgit v1.2.3