From eade9d466c9e3be2be4753ee4367356b356d2dc4 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Wed, 22 Mar 2017 17:12:52 +0100 Subject: Backend credentials translation added. Bugfix: Checkboxes instead of bs switches were shown in the server settings --- .../inc/coursebackend/coursebackend_dummy.inc.php | 5 ++--- modules-available/locationinfo/lang/de/dummy.json | 14 ++++++++++++++ modules-available/locationinfo/lang/en/dummy.json | 14 ++++++++++++++ modules-available/locationinfo/page.inc.php | 10 ++++++---- .../locationinfo/templates/server-settings.html | 13 ++++++++++--- 5 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 modules-available/locationinfo/lang/de/dummy.json create mode 100644 modules-available/locationinfo/lang/en/dummy.json diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php index 725b4436..b8aa44a0 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php @@ -4,7 +4,7 @@ class Coursebackend_Dummy extends CourseBackend { public function setCredentials($json,$location,$serverID) { $x = $json; - $this->pw = $x['password_str']; + $this->pw = $x['password']; if ($this->pw == "mfg") { $this->error = false; @@ -29,8 +29,7 @@ class Coursebackend_Dummy extends CourseBackend { public function getCredentials(){ $options = ["opt1", "opt2", "opt3", "opt4", "opt5", "opt6", "opt7", "opt8"]; - $credentials = ["username" => ["string", "This is a helptext.", false],"password_str"=>["string", "SOME SECRET PW U WILL NEVER KNOW!", true],"password int"=>["int", "INT PW", true],"option"=>[$options, "OMG WHAT THE", false], "CheckTheBox" => ["bool", "Test with a cb", false], - "CB2 t" => ["bool", "Second checkbox test", false]]; + $credentials = ["username" => "string","password"=>"password","integer"=>"int","option"=>$options,"CheckTheBox" =>"bool","CB2 t" =>"bool"]; return $credentials; } diff --git a/modules-available/locationinfo/lang/de/dummy.json b/modules-available/locationinfo/lang/de/dummy.json new file mode 100644 index 00000000..f68fb869 --- /dev/null +++ b/modules-available/locationinfo/lang/de/dummy.json @@ -0,0 +1,14 @@ +{ + "username": "Benutzer", + "username_title": "Das ist halt ein Username feld..", + "password": "Passwort 1", + "password_title": "Bla passwort bla bla", + "integer": "Zahl", + "integer_title": "Ein Zahlen felde?!", + "option": "Irgendein Array", + "option_title": "LALALA Hilfs- Text bla bla", + "CheckTheBox": "CheckBox", + "CheckTheBox_title": "Die checkbox ist ein wenig nutzlos", + "CB2 t": "Eine andere cb", + "CB2 t_title": ":P Diese checkbox ist super secret." +} diff --git a/modules-available/locationinfo/lang/en/dummy.json b/modules-available/locationinfo/lang/en/dummy.json new file mode 100644 index 00000000..800fd80b --- /dev/null +++ b/modules-available/locationinfo/lang/en/dummy.json @@ -0,0 +1,14 @@ +{ + "username": "Username", + "username_title": "A fkn username field", + "password": "Password 1", + "password_title": "Password 1 title alalala :D", + "integer": "A integer value", + "integer_title": "What is this for?!", + "option": "Option Array", + "option_title": "LALALA OPtion title bla bla", + "CheckTheBox": "CheckBox", + "CheckTheBox_title": "Check this if you are bored", + "CB2 t": "Another cb", + "CB2 t_title": "meeh fk it. This cb does nothing. :P" +} diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 6490e722..df11f8a9 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -517,14 +517,16 @@ class Page_LocationInfo extends Page $counter = 0; foreach ($credentials as $key => $value) { $credential['uid'] = $counter; - $credential['name'] = $key; - $credential['type'] = $value[0]; - $credential['title'] = $value[1]; + $credential['name'] = Dictionary::translateFile($s, $key);; + $credential['type'] = $value; + $credential['title'] = Dictionary::translateFile($s, $key."_title"); if (Property::getPasswordFieldType() === 'text') { $credential['mask'] = false; } else { - $credential['mask'] = $value[2]; + if ($value == "password") { + $credential['mask'] = true; + } } if ($backend['typ'] == $dbresult['servertype']) { diff --git a/modules-available/locationinfo/templates/server-settings.html b/modules-available/locationinfo/templates/server-settings.html index 641873ef..a2bbdf8f 100644 --- a/modules-available/locationinfo/templates/server-settings.html +++ b/modules-available/locationinfo/templates/server-settings.html @@ -107,14 +107,21 @@ $("#credentials-list").append('
\
\
\ -
\ +
\
\
'); } else if ("{{type}}" == "int") { $("#credentials-list").append('
\
\
\ -
\ +
\ +
\ +
'); + } else if ("{{type}}" == "password") { + $("#credentials-list").append('
\ +
\ +
\ +
\
\
'); } else if ("{{type}}" == "bool") { @@ -124,7 +131,7 @@ \
\ '); - $('#bs-{{uid}}').bootstrapSwitch({ + $('#input-{{uid}}').bootstrapSwitch({ size: "small" }); } else if ("{{type}}" == "array") { -- cgit v1.2.3-55-g7522