mirror of
https://github.com/Findus23/plugin-LanguageToogle.git
synced 2024-09-10 05:13:46 +02:00
init
This commit is contained in:
commit
ff77a9e6c8
11 changed files with 158 additions and 0 deletions
5
CHANGELOG.md
Normal file
5
CHANGELOG.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
## Changelog
|
||||
|
||||
0.1.0
|
||||
|
||||
- Initial Release
|
23
Controller.php
Normal file
23
Controller.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace Piwik\Plugins\LanguageToogle;
|
||||
|
||||
use Piwik\Common;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\LanguagesManager\LanguagesManager;
|
||||
|
||||
class Controller extends \Piwik\Plugin\Controller
|
||||
{
|
||||
public function index() {
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
$lang = Common::getRequestVar("lang");
|
||||
LanguagesManager::setLanguageForSession($lang);
|
||||
$this->redirectToIndex("CoreHome", "index");
|
||||
}
|
||||
}
|
13
LanguageToogle.php
Normal file
13
LanguageToogle.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace Piwik\Plugins\LanguageToogle;
|
||||
|
||||
class LanguageToogle extends \Piwik\Plugin
|
||||
{
|
||||
}
|
35
Menu.php
Normal file
35
Menu.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace Piwik\Plugins\LanguageToogle;
|
||||
|
||||
use Piwik\Menu\MenuTop;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\LanguagesManager\API;
|
||||
|
||||
|
||||
class Menu extends \Piwik\Plugin\Menu
|
||||
{
|
||||
public function configureTopMenu(MenuTop $menu) {
|
||||
if (Piwik::hasUserSuperUserAccess()) {
|
||||
$settings = new UserSettings();
|
||||
if (empty($settings->availableLanguages->getValue())) {
|
||||
return false;
|
||||
}
|
||||
$languages = API::getInstance()->getAvailableLanguageNames();
|
||||
|
||||
foreach ($settings->availableLanguages->getValue() as $code) {
|
||||
foreach ($languages as $lang) {
|
||||
if ($lang["code"] == $code) {
|
||||
$menu->addItem($lang["name"], null, $this->urlForDefaultAction(["lang" => $code]), $orderId = 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
6
README.md
Normal file
6
README.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Matomo LanguageToogle Plugin
|
||||
|
||||
## Description
|
||||
|
||||
Add your plugin description here.
|
||||
|
39
UserSettings.php
Normal file
39
UserSettings.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace Piwik\Plugins\LanguageToogle;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\LanguagesManager\API;
|
||||
use Piwik\Settings\FieldConfig;
|
||||
use Piwik\Settings\Setting;
|
||||
|
||||
class UserSettings extends \Piwik\Settings\Plugin\UserSettings
|
||||
{
|
||||
/** @var Setting */
|
||||
public $availableLanguages;
|
||||
|
||||
protected function init() {
|
||||
$this->availableLanguages = $this->createAvailableLanguagesSetting();
|
||||
}
|
||||
|
||||
private function createAvailableLanguagesSetting()
|
||||
{
|
||||
return $this->makeSetting('availableLanguages', $default = false, 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;
|
||||
});
|
||||
}
|
||||
}
|
5
docs/faq.md
Normal file
5
docs/faq.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
## FAQ
|
||||
|
||||
__My question?__
|
||||
|
||||
My answer
|
1
docs/index.md
Normal file
1
docs/index.md
Normal file
|
@ -0,0 +1 @@
|
|||
## Documentation
|
6
lang/en.json
Normal file
6
lang/en.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"LanguageToogle": {
|
||||
"SettingsTitle": "Favorite Languages",
|
||||
"SelectLanguages": "Please choose the languages you would to toogle between."
|
||||
}
|
||||
}
|
25
plugin.json
Normal file
25
plugin.json
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "LanguageToogle",
|
||||
"description": "Quickly change the language of Matomo",
|
||||
"version": "0.1.0",
|
||||
"theme": false,
|
||||
"require": {
|
||||
"piwik": ">=3.4.0,<4.0.0-b1"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Lukas Winkler",
|
||||
"email": "lukas@matomo.org",
|
||||
"homepage": "https://lw1.at"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"email": "lukas@matomo.org",
|
||||
"issues": "https://github.com/Findus23/plugin-LanguageToogle/issues",
|
||||
"forum": "https://forum.piwik.org",
|
||||
"source": "https://github.com/Findus23/plugin-LanguageToogle"
|
||||
},
|
||||
"homepage": "https://lw1.at",
|
||||
"license": "GPL v3+",
|
||||
"keywords": ["language"]
|
||||
}
|
0
screenshots/.gitkeep
Normal file
0
screenshots/.gitkeep
Normal file
Loading…
Reference in a new issue