Plugin filenames must match class names
changed deprecated public values in ManiaControl.php to private
This commit is contained in:
parent
2e94928539
commit
1b110e5d17
@ -11,7 +11,7 @@
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Run configuration
|
||||
define('DEV_MODE', true); // Development mode to not send error reports etc.
|
||||
define('DEV_MODE', false); // Development mode to not send error reports etc.
|
||||
define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file name in logs folder
|
||||
define('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder
|
||||
|
||||
|
@ -123,7 +123,6 @@ class EchoManager implements CallbackListener, EchoListener, UsageInformationAbl
|
||||
$params = func_get_args();
|
||||
$params = array_slice($params, 1, null, true);
|
||||
|
||||
//var_dump($params);
|
||||
foreach ($this->echoListenings[$callbackName] as $listening) {
|
||||
/** @var Listening $listening */
|
||||
$listening->triggerCallbackWithParams($params);
|
||||
|
@ -120,12 +120,14 @@ class ErrorHandler {
|
||||
$report['FileLine'] = self::stripBaseDir($fileLine);
|
||||
}
|
||||
|
||||
|
||||
if ($sourceClass) {
|
||||
$report['SourceClass'] = $sourceClass;
|
||||
$pluginId = PluginManager::getPluginId($sourceClass);
|
||||
if ($pluginId > 0) {
|
||||
$report['PluginId'] = $pluginId;
|
||||
|
||||
|
||||
if ($isFatalError) {
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin($sourceClass);
|
||||
$this->maniaControl->getChat()->sendError("Plugin " . $sourceClass . " has an Error -> The Plugin will be deactivated and ManiaControl restarted");
|
||||
|
@ -4,6 +4,7 @@ namespace ManiaControl\Files;
|
||||
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
use ManiaControl\Utils\SystemUtil;
|
||||
use ManiaControl\Utils\WebReader;
|
||||
|
||||
/**
|
||||
@ -207,4 +208,23 @@ abstract class FileUtil {
|
||||
$extension = substr($fileName, -4);
|
||||
return (strtolower($extension) === '.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the file name of a path to a PHP file
|
||||
*
|
||||
* @param $path
|
||||
* @return string
|
||||
*/
|
||||
public static function getFileName($path) {
|
||||
$className = '';
|
||||
$splitNameSpace = explode(DIRECTORY_SEPARATOR, $path);
|
||||
if (is_array($splitNameSpace)) {
|
||||
$className = end($splitNameSpace);
|
||||
}
|
||||
|
||||
$className = str_replace('.php', '', $className);
|
||||
|
||||
return $className;
|
||||
}
|
||||
}
|
||||
|
@ -63,116 +63,95 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
|
||||
/*
|
||||
* Public properties
|
||||
*/
|
||||
/** @var ActionsMenu $actionsMenu
|
||||
* @deprecated
|
||||
* @see getActionsMenu()
|
||||
*/
|
||||
public $actionsMenu = null;
|
||||
/** @var AuthenticationManager $authenticationManager
|
||||
* @deprecated
|
||||
* @see getAuthenticationManager()
|
||||
*/
|
||||
public $authenticationManager = null;
|
||||
/** @var CallbackManager $callbackManager
|
||||
* @deprecated
|
||||
* @see getCallbackManager()
|
||||
*/
|
||||
public $callbackManager = null;
|
||||
/** @var Chat $chat
|
||||
* @deprecated
|
||||
* @see getChat()
|
||||
*/
|
||||
public $chat = null;
|
||||
/** @var \SimpleXMLElement $config
|
||||
* @deprecated
|
||||
* @see getConfig()
|
||||
*/
|
||||
public $config = null;
|
||||
/** @var Configurator $configurator
|
||||
* @deprecated
|
||||
* @see getConfigurator()
|
||||
*/
|
||||
public $configurator = null;
|
||||
/** @var Connection $client
|
||||
* @deprecated
|
||||
* @see getClient()
|
||||
*/
|
||||
public $client = null;
|
||||
/** @var CommandManager $commandManager
|
||||
* @deprecated
|
||||
* @see getCommandManager()
|
||||
*/
|
||||
public $commandManager = null;
|
||||
/** @var Database $database
|
||||
* @deprecated
|
||||
* @see getDatabase()
|
||||
*/
|
||||
public $database = null;
|
||||
/** @var ManialinkManager $manialinkManager
|
||||
* @deprecated
|
||||
* @see getManialinkManager
|
||||
*/
|
||||
public $manialinkManager = null;
|
||||
/** @var MapManager $mapManager
|
||||
* @deprecated
|
||||
* @see getMapManager()
|
||||
*/
|
||||
public $mapManager = null;
|
||||
/** @var PlayerManager $playerManager
|
||||
* @deprecated
|
||||
* @see getPlayerManager()
|
||||
*/
|
||||
public $playerManager = null;
|
||||
/** @var PluginManager $pluginManager
|
||||
* @deprecated
|
||||
* @see getPluginManager()
|
||||
*/
|
||||
public $pluginManager = null;
|
||||
/** @var Server $server
|
||||
* @deprecated
|
||||
* @see getServer()
|
||||
*/
|
||||
public $server = null;
|
||||
/** @var SettingManager $settingManager
|
||||
* @deprecated
|
||||
* @see getSettingManager()
|
||||
* @deprecated use getSettingManager()
|
||||
*/
|
||||
public $settingManager = null;
|
||||
/** @var StatisticManager $statisticManager
|
||||
* @deprecated
|
||||
* @see getStatisticManager()
|
||||
*/
|
||||
public $statisticManager = null;
|
||||
/** @var UpdateManager $updateManager
|
||||
* @deprecated
|
||||
* @see getUpdateManager()
|
||||
*/
|
||||
public $updateManager = null;
|
||||
/** @var ErrorHandler $errorHandler
|
||||
* @deprecated
|
||||
* @see getErrorHandler()
|
||||
*/
|
||||
public $errorHandler = null;
|
||||
/** @var TimerManager $timerManager
|
||||
* @deprecated
|
||||
* @see getTimerManager()
|
||||
*/
|
||||
public $timerManager = null;
|
||||
/** @var AsynchronousFileReader $fileReader
|
||||
* @deprecated
|
||||
* @see getFileReader()
|
||||
*/
|
||||
public $fileReader = null;
|
||||
/** @var BillManager $billManager
|
||||
* @deprecated
|
||||
* @see getBillManager()
|
||||
*/
|
||||
public $billManager = null;
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
*/
|
||||
private $requestQuitMessage = null;
|
||||
/** @var ActionsMenu $actionsMenu
|
||||
* @see getActionsMenu()
|
||||
*/
|
||||
private $actionsMenu = null;
|
||||
/** @var AuthenticationManager $authenticationManager
|
||||
* @see getAuthenticationManager()
|
||||
*/
|
||||
private $authenticationManager = null;
|
||||
/** @var CallbackManager $callbackManager
|
||||
* @see getCallbackManager()
|
||||
*/
|
||||
private $callbackManager = null;
|
||||
/** @var Chat $chat
|
||||
* @see getChat()
|
||||
*/
|
||||
private $chat = null;
|
||||
/** @var \SimpleXMLElement $config
|
||||
* @see getConfig()
|
||||
*/
|
||||
private $config = null;
|
||||
/** @var Configurator $configurator
|
||||
* @see getConfigurator()
|
||||
*/
|
||||
private $configurator = null;
|
||||
/** @var Connection $client
|
||||
* @see getClient()
|
||||
*/
|
||||
private $client = null;
|
||||
/** @var CommandManager $commandManager
|
||||
* @see getCommandManager()
|
||||
*/
|
||||
private $commandManager = null;
|
||||
/** @var Database $database
|
||||
* @see getDatabase()
|
||||
*/
|
||||
private $database = null;
|
||||
/** @var ManialinkManager $manialinkManager
|
||||
* @see getManialinkManager
|
||||
*/
|
||||
private $manialinkManager = null;
|
||||
/** @var MapManager $mapManager
|
||||
* @see getMapManager()
|
||||
*/
|
||||
private $mapManager = null;
|
||||
/** @var PlayerManager $playerManager
|
||||
* @see getPlayerManager()
|
||||
*/
|
||||
private $playerManager = null;
|
||||
/** @var PluginManager $pluginManager
|
||||
* @see getPluginManager()
|
||||
*/
|
||||
private $pluginManager = null;
|
||||
/** @var Server $server
|
||||
* @see getServer()
|
||||
*/
|
||||
private $server = null;
|
||||
/** @var StatisticManager $statisticManager
|
||||
* @see getStatisticManager()
|
||||
*/
|
||||
private $statisticManager = null;
|
||||
/** @var UpdateManager $updateManager
|
||||
* @see getUpdateManager()
|
||||
*/
|
||||
private $updateManager = null;
|
||||
/** @var ErrorHandler $errorHandler
|
||||
* @see getErrorHandler()
|
||||
*/
|
||||
private $errorHandler = null;
|
||||
/** @var TimerManager $timerManager
|
||||
* @see getTimerManager()
|
||||
*/
|
||||
private $timerManager = null;
|
||||
/** @var AsynchronousFileReader $fileReader
|
||||
* @see getFileReader()
|
||||
*/
|
||||
private $fileReader = null;
|
||||
/** @var BillManager $billManager
|
||||
* @see getBillManager()
|
||||
*/
|
||||
private $billManager = null;
|
||||
|
||||
/** @var EchoManager $echoManager */
|
||||
private $echoManager = null;
|
||||
@ -185,6 +164,8 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
|
||||
|
||||
private $dedicatedServerBuildVersion = "";
|
||||
|
||||
private $requestQuitMessage = null;
|
||||
|
||||
/**
|
||||
* Construct a new ManiaControl instance
|
||||
*/
|
||||
|
@ -35,7 +35,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
|
||||
const ACTION_CLOSEWIDGET = 'ManiaLinkManager.CloseWidget';
|
||||
const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed';
|
||||
const CB_MAIN_WINDOW_OPENED = 'ManialinkManagerCallback.MainWindowOpened';
|
||||
const MAIN_MANIALINK_Z_VALUE = 10;
|
||||
const MAIN_MANIALINK_Z_VALUE = 20;
|
||||
|
||||
/*
|
||||
* Public properties
|
||||
|
@ -227,7 +227,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
unset($this->queuedMaps[$map->uid]);
|
||||
}
|
||||
array_unshift($this->queuedMaps, array($player, $map, true));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $map));
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $map));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
$pageFrame = null;
|
||||
|
||||
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
||||
$response = WebReader::getUrl($url);
|
||||
$response = WebReader::getUrl($url); //TODO async webrequest
|
||||
$dataJson = $response->getContent();
|
||||
$pluginList = json_decode($dataJson);
|
||||
$index = 0;
|
||||
|
@ -12,6 +12,7 @@ use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Utils\ClassUtil;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Class managing Plugins
|
||||
@ -119,6 +120,18 @@ class PluginManager {
|
||||
if (!in_array(Plugin::PLUGIN_INTERFACE, $interfaces)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$reflector = new ReflectionClass($pluginClass);
|
||||
$className = $pluginClass;
|
||||
$splitNameSpace = explode('\\', $pluginClass);
|
||||
if (is_array($splitNameSpace)) {
|
||||
$className = end($splitNameSpace);
|
||||
}
|
||||
if (FileUtil::getFileName($reflector->getFileName()) != $className) {
|
||||
Logger::logError("Plugin ClassName does not match FileName; Plugin: " . $className);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -225,6 +238,7 @@ class PluginManager {
|
||||
return false;
|
||||
}
|
||||
$pluginStatement->close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -493,4 +507,12 @@ class PluginManager {
|
||||
|
||||
$asyncHttpRequest->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @return \ManiaControl\Plugins\InstallMenu
|
||||
*/
|
||||
public function getPluginInstallMenu() {
|
||||
return $this->pluginInstallMenu;
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
|
||||
}
|
||||
Logger::log($message);
|
||||
|
||||
$this->maniaControl->getConfigurator()->showMenu($player, InstallMenu::getTitle());
|
||||
$this->maniaControl->getConfigurator()->showMenu($player, $this->maniaControl->getPluginManager()->getPluginInstallMenu());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user