Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2018-04-09 14:13:12 +0300
committernachoparker <nacho@ownyourbits.com>2018-04-09 20:52:03 +0300
commit20c0d8098d2ed03ae7e0758c907899c2c7930b6b (patch)
tree01e4d1cfd6c023ebd472821d20f6cd80fd9789b7
parenta9b37ab6c6faf6862e61eaf061349eb2aa805fe7 (diff)
ncp-web: added language dropdown selectorv0.53.27
-rw-r--r--changelog.md4
-rw-r--r--etc/nextcloudpi-config.d/nc-webui.sh1
-rw-r--r--ncp-web/L10N.php19
-rw-r--r--ncp-web/index.php22
-rw-r--r--ncp-web/l10n/index.html0
-rw-r--r--ncp-web/l10n/index.php1
-rw-r--r--ncp-web/ncp-launcher.php8
-rw-r--r--ncp-web/ncp-web.cfg1
-rw-r--r--ncp-web/ncp.css5
-rw-r--r--ncp-web/ncp.js29
-rwxr-xr-xupdate.sh1
11 files changed, 84 insertions, 7 deletions
diff --git a/changelog.md b/changelog.md
index c8d81157..1b1adeb1 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,7 @@
-[v0.53.26](https://github.com/nextcloud/nextcloudpi/commit/ca66f50) (2018-04-06) nc-automount: remove directories left from unclean shutdown
+[v0.53.27](https://github.com/nextcloud/nextcloudpi/commit/f5defaf) (2018-04-09) ncp-web: added language dropdown selector
+
+[v0.53.26](https://github.com/nextcloud/nextcloudpi/commit/d4340a0) (2018-04-06) nc-automount: remove directories left from unclean shutdown
[v0.53.25](https://github.com/nextcloud/nextcloudpi/commit/c5bbeb8) (2018-04-09) build: clean docker-env
diff --git a/etc/nextcloudpi-config.d/nc-webui.sh b/etc/nextcloudpi-config.d/nc-webui.sh
index 6bd28579..4a1f7e5e 100644
--- a/etc/nextcloudpi-config.d/nc-webui.sh
+++ b/etc/nextcloudpi-config.d/nc-webui.sh
@@ -14,7 +14,6 @@
#
ACTIVE_=no
-LANGUAGE_=[_auto_,en,de]
DESCRIPTION="Enable or disable the NCP web interface"
is_active()
diff --git a/ncp-web/L10N.php b/ncp-web/L10N.php
index 5c0e1881..e00a7909 100644
--- a/ncp-web/L10N.php
+++ b/ncp-web/L10N.php
@@ -66,6 +66,22 @@ class L10N
return ($jsonError == null);
}
+ function save($lang)
+ {
+ $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, ',' ) . ']';
+ return file_put_contents( $cfg , $str );
+ }
+
function load_template($module)
{
if (is_file("./l10n_templates/$module.json")) {
@@ -130,7 +146,7 @@ class L10N
function load_language_setting($modules_path)
{
- $webui_config_file = join('/', [rtrim($modules_path, '/'), 'nc-webui.sh']);
+ $webui_config_file = 'ncp-web.cfg';
$fh = fopen($webui_config_file, 'r')
or exit('{ "output": "' . $webui_config_file . ' read error" }');
$lang = "auto";
@@ -148,6 +164,5 @@ class L10N
return $lang;
}
}
-
}
}
diff --git a/ncp-web/index.php b/ncp-web/index.php
index b3ec641f..861c5c0c 100644
--- a/ncp-web/index.php
+++ b/ncp-web/index.php
@@ -112,6 +112,23 @@ HTML;
<a id=versionlink target="_blank" href="https://github.com/nextcloud/nextcloudpi/blob/master/changelog.md">
<?php echo file_get_contents( "/usr/local/etc/ncp-version" ) ?>
</a>
+<?php
+ // language selection drop
+ if( preg_match('/^(\w+)_=\[(([_\w]+,)*[_\w]+)\]$/', file_get_contents( 'ncp-web.cfg') , $matches) )
+ {
+ $options = explode(",", $matches[2]);
+ echo "<select id=\"language-selection\" name=\"$matches[1]\">";
+ foreach($options as $option)
+ {
+ echo "<option value='". trim($option, "_") ."' ";
+ if( $option[0] == "_" && $option[count($option) - 1] == "_" )
+ echo "selected='selected'";
+ echo ">". trim($option, "_") ."</option>";
+ }
+ echo "<option value=\"[new]\">new..</option>";
+ echo "</select>";
+ }
+?>
</div>
<div id="header-right">
<a href="https://ownyourbits.com" id="nextcloud-btn" target="_blank" tabindex="1">
@@ -237,8 +254,9 @@ HTML;
<?php
include('csrf.php');
- echo '<input type="hidden" id="csrf-token" name="csrf-token" value="' . getCSRFToken() . '"/>';
- echo '<input type="hidden" id="csrf-token-ui" name="csrf-token-ui" value="' . getCSRFToken() . '"/>';
+ echo '<input type="hidden" id="csrf-token" name="csrf-token" value="' . getCSRFToken() . '"/>';
+ echo '<input type="hidden" id="csrf-token-ui" name="csrf-token-ui" value="' . getCSRFToken() . '"/>';
+ echo '<input type="hidden" id="csrf-token-cfg" name="csrf-token-cfg" value="' . getCSRFToken() . '"/>';
?>
<script src="minified.js"></script>
<script src="ncp.js"></script>
diff --git a/ncp-web/l10n/index.html b/ncp-web/l10n/index.html
deleted file mode 100644
index e69de29b..00000000
--- a/ncp-web/l10n/index.html
+++ /dev/null
diff --git a/ncp-web/l10n/index.php b/ncp-web/l10n/index.php
deleted file mode 100644
index a8143662..00000000
--- a/ncp-web/l10n/index.php
+++ /dev/null
@@ -1 +0,0 @@
-<?php \ No newline at end of file
diff --git a/ncp-web/ncp-launcher.php b/ncp-web/ncp-launcher.php
index 3fe1690d..ad1ce062 100644
--- a/ncp-web/ncp-launcher.php
+++ b/ncp-web/ncp-launcher.php
@@ -202,6 +202,14 @@ else
echo ' "output": ' . json_encode( print_sidebar( $l, true ) ) . ' , ';
echo ' "ret": "0" }';
}
+ else if ( $_POST['action'] == "cfg-ui" )
+ {
+ $ret = $l->save( $_POST['value'] );
+ $ret = $ret !== FALSE ? 0 : 1;
+ // return JSON
+ echo '{ "token": "' . getCSRFToken() . '",'; // Get new token
+ echo ' "ret": "' . $ret . '" }';
+ }
}
// License
diff --git a/ncp-web/ncp-web.cfg b/ncp-web/ncp-web.cfg
new file mode 100644
index 00000000..a2b972b1
--- /dev/null
+++ b/ncp-web/ncp-web.cfg
@@ -0,0 +1 @@
+LANGUAGE_=[_auto_,en,de]
diff --git a/ncp-web/ncp.css b/ncp-web/ncp.css
index de91fc9c..957a2a5c 100644
--- a/ncp-web/ncp.css
+++ b/ncp-web/ncp.css
@@ -1317,3 +1317,8 @@ a#versionlink:hover {
color: #565656;
overflow: auto;
}
+
+#language-selection {
+ border: none;
+ color: white;
+}
diff --git a/ncp-web/ncp.js b/ncp-web/ncp.js
index 733753ec..51f139f9 100644
--- a/ncp-web/ncp.js
+++ b/ncp-web/ncp.js
@@ -371,6 +371,35 @@ $(function()
switch_to_section( 'nc-config' );
} );
+ // language selection
+ var langold = $( '#language-selection' ).get( '.value' );
+ $( '#language-selection' ).on( 'change', function(e)
+ {
+ if( '[new]' == this.get( '.value' ) )
+ {
+ this.set( '.value', langold );
+ var url = 'https://github.com/nextcloud/nextcloudpi/wiki/Add-a-new-language-to-ncp-web';
+ if ( !window.open( url, '_blank' ) ) // try to open in a new tab first
+ window.location.href = url;
+ return;
+ }
+ // request
+ $.request('post', 'ncp-launcher.php', { action:'cfg-ui',
+ value: this.get( '.value' ),
+ csrf_token: $( '#csrf-token-cfg' ).get( '.value' ) }).then(
+ function success( result )
+ {
+ var ret = $.parseJSON( result );
+ if ( ret.token )
+ $('#csrf-token-cfg').set( { value: ret.token } );
+ if ( ret.ret && ret.ret == '0' ) // means that the process was launched
+ window.location.reload( true );
+ else
+ this.set( '.value', langold );
+ }
+ ).error( errorMsg )
+ } );
+
// load dashboard info
print_dashboard();
} );
diff --git a/update.sh b/update.sh
index 82a26d5f..3a24ef9a 100755
--- a/update.sh
+++ b/update.sh
@@ -103,6 +103,7 @@ cp -rT etc/nextcloudpi-config.d/l10n "$CONFDIR"/l10n
# these files can contain sensitive information, such as passwords
chown -R root:www-data "$CONFDIR"
chmod 660 "$CONFDIR"/*
+chmod 750 "$CONFDIR"/l10n
# install web interface
cp -r ncp-web /var/www/