Fixed #170
This commit is contained in:
parent
39489f266f
commit
910d59a377
@ -11,6 +11,7 @@ use FML\Script\Features\Paging;
|
|||||||
use FML\Script\Script;
|
use FML\Script\Script;
|
||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Configurator\ConfiguratorMenu;
|
use ManiaControl\Configurator\ConfiguratorMenu;
|
||||||
|
use ManiaControl\Files\AsyncHttpRequest;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
@ -30,6 +31,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
|||||||
const SETTING_PERMISSION_INSTALL_PLUGINS = 'Install Plugins';
|
const SETTING_PERMISSION_INSTALL_PLUGINS = 'Install Plugins';
|
||||||
const ACTION_PREFIX_INSTALL_PLUGIN = 'PluginInstallMenu.Install.';
|
const ACTION_PREFIX_INSTALL_PLUGIN = 'PluginInstallMenu.Install.';
|
||||||
const ACTION_REFRESH_LIST = 'PluginInstallMenu.RefreshList';
|
const ACTION_REFRESH_LIST = 'PluginInstallMenu.RefreshList';
|
||||||
|
const SETTING_GAME_ONLY = 'Display only Plugins eligible for your game';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private properties
|
* Private properties
|
||||||
@ -48,6 +50,9 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
|||||||
// Permissions
|
// Permissions
|
||||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_INSTALL_PLUGINS, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_INSTALL_PLUGINS, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||||
|
|
||||||
|
//Settings
|
||||||
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_GAME_ONLY, true);
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_REFRESH_LIST, $this, 'handleRefreshListAction');
|
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_REFRESH_LIST, $this, 'handleRefreshListAction');
|
||||||
}
|
}
|
||||||
@ -63,6 +68,9 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
|||||||
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
|
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
|
||||||
*/
|
*/
|
||||||
public function getMenu($width, $height, Script $script, Player $player) {
|
public function getMenu($width, $height, Script $script, Player $player) {
|
||||||
|
|
||||||
|
$gameOnly = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_GAME_ONLY);
|
||||||
|
|
||||||
$paging = new Paging();
|
$paging = new Paging();
|
||||||
$script->addFeature($paging);
|
$script->addFeature($paging);
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
@ -74,6 +82,10 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
|||||||
$pageFrame = null;
|
$pageFrame = null;
|
||||||
|
|
||||||
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
||||||
|
if ($gameOnly) {
|
||||||
|
$game = $this->maniaControl->getMapManager()->getCurrentMap()->getGame();
|
||||||
|
$url .= '?game=' . $game;
|
||||||
|
}
|
||||||
$response = WebReader::getUrl($url); //TODO async webrequest
|
$response = WebReader::getUrl($url); //TODO async webrequest
|
||||||
$dataJson = $response->getContent();
|
$dataJson = $response->getContent();
|
||||||
$pluginList = json_decode($dataJson);
|
$pluginList = json_decode($dataJson);
|
||||||
|
Loading…
Reference in New Issue
Block a user