mirror of
https://github.com/Findus23/plugin-LanguageToogle.git
synced 2024-09-10 05:13:46 +02:00
replace multiselect with new multituple
This commit is contained in:
parent
f1171b7148
commit
573f6b677b
7 changed files with 25 additions and 12 deletions
|
@ -1,5 +1,9 @@
|
|||
## Changelog
|
||||
|
||||
0.2.0
|
||||
|
||||
- replace multiselect with new multituple (needs Matomo 3.5.0)
|
||||
|
||||
0.1.4
|
||||
|
||||
- performance improvements
|
||||
|
|
6
Menu.php
6
Menu.php
|
@ -19,14 +19,15 @@ class Menu extends \Piwik\Plugin\Menu
|
|||
if (Piwik::hasUserSuperUserAccess()) {
|
||||
$additionalParams = ["returnModule" => Piwik::getModule(), "returnAction" => Piwik::getAction()];
|
||||
$settings = new UserSettings();
|
||||
if (empty($settings->availableLanguages->getValue())) {
|
||||
if (empty($settings->availableLanguages)) {
|
||||
return false;
|
||||
}
|
||||
$languages = [];
|
||||
foreach (API::getInstance()->getAvailableLanguageNames() as $lang) {
|
||||
$languages[$lang["code"]] = $lang;
|
||||
}
|
||||
foreach ($settings->availableLanguages->getValue() as $code) {
|
||||
foreach ($settings->availableLanguages->getValue() as $setting) {
|
||||
$code=$setting["languageCode"];
|
||||
if (isset($languages[$code])) {
|
||||
$additionalParams["lang"] = $code;
|
||||
$menu->addItem($languages[$code]["name"], null, $this->urlForDefaultAction($additionalParams), $orderId = 30);
|
||||
|
@ -34,4 +35,5 @@ class Menu extends \Piwik\Plugin\Menu
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
namespace Piwik\Plugins\LanguageToogle;
|
||||
|
||||
use function PHPSTORM_META\type;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\LanguagesManager\API;
|
||||
use Piwik\Settings\FieldConfig;
|
||||
|
@ -20,20 +21,24 @@ class UserSettings extends \Piwik\Settings\Plugin\UserSettings
|
|||
|
||||
protected function init() {
|
||||
$this->availableLanguages = $this->createAvailableLanguagesSetting();
|
||||
if (!empty($this->availableLanguages->getValue()) && gettype($this->availableLanguages->getValue()[0]) == "string") {
|
||||
$this->availableLanguages->setValue([]);
|
||||
}
|
||||
}
|
||||
|
||||
private function createAvailableLanguagesSetting()
|
||||
{
|
||||
return $this->makeSetting('availableLanguages', $default = false, FieldConfig::TYPE_ARRAY, function (FieldConfig $field) {
|
||||
private function createAvailableLanguagesSetting() {
|
||||
return $this->makeSetting('availableLanguages', array(), FieldConfig::TYPE_ARRAY, function (FieldConfig $field) {
|
||||
$languageList = [];
|
||||
$languages = API::getInstance()->getAvailableLanguagesInfo();
|
||||
foreach ($languages as $language) {
|
||||
$languageList[$language['code']] = $language['name'] . ' (' . $language['english_name'] . ')';
|
||||
}
|
||||
$field->title = Piwik::translate('LanguageToogle_SettingsTitle');
|
||||
$field->inlineHelp = Piwik::translate('LanguageToogle_SelectLanguages');
|
||||
$field->uiControl = FieldConfig::UI_CONTROL_MULTI_SELECT;
|
||||
$field->availableValues = $languageList;
|
||||
$field->description = Piwik::translate('LanguageToogle_Description');
|
||||
$field->uiControl = FieldConfig::UI_CONTROL_MULTI_TUPLE;
|
||||
$field1 = new FieldConfig\MultiPair(Piwik::translate('LanguageToogle_Language'), 'languageCode', FieldConfig::UI_CONTROL_SINGLE_SELECT);
|
||||
$field1->availableValues = $languageList;
|
||||
$field->uiControlAttributes['field1'] = $field1->toArray();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"LanguageToogle": {
|
||||
"SettingsTitle": "Persönliche Sprachen",
|
||||
"SelectLanguages": "Wähle die Sprachen zwischen denen gewechselt werden soll."
|
||||
"Description": "Wähle die Sprachen zwischen denen gewechselt werden soll.",
|
||||
"Language": "Sprache"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"LanguageToogle": {
|
||||
"SettingsTitle": "Favorite Languages",
|
||||
"SelectLanguages": "Please choose the languages you would to toogle between."
|
||||
"Description": "Please choose the languages you would to toogle between.",
|
||||
"Language": "Language"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"name": "LanguageToogle",
|
||||
"description": "Quickly change the language of Matomo",
|
||||
"version": "0.1.4",
|
||||
"version": "0.2.0",
|
||||
"theme": false,
|
||||
"require": {
|
||||
"piwik": ">=3.4.0,<4.0.0-b1"
|
||||
"piwik": ">=3.5.0-rc,<4.0.0-b1"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 23 KiB |
Loading…
Reference in a new issue