diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 8d0b80d7..4783c3f6 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -32,7 +32,7 @@ require_once __DIR__ . '/Formatter.php'; require_once __DIR__ . '/GbxDataFetcher/gbxdatafetcher.inc.php'; require_once __DIR__ . '/ManiaExchange/mxinfofetcher.inc.php'; require_once __DIR__ . '/ManiaExchange/mxinfosearcher.inc.php'; -require_once __DIR__ . '/ManiaExchange/ManiaExchangeInfoSearcher.php'; +require_once __DIR__ . '/ManiaExchange/ManiaExchangeManager.php'; require_once __DIR__ . '/Manialinks/ManialinkManager.php'; require_once __DIR__ . '/Statistics/StatisticManager.php'; require_once __DIR__ . '/Maps/MapManager.php'; diff --git a/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php b/application/core/ManiaExchange/ManiaExchangeManager.php similarity index 96% rename from application/core/ManiaExchange/ManiaExchangeInfoSearcher.php rename to application/core/ManiaExchange/ManiaExchangeManager.php index 5f4a29fa..7c91006f 100644 --- a/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php +++ b/application/core/ManiaExchange/ManiaExchangeManager.php @@ -9,10 +9,11 @@ use ManiaControl\ManiaControl; * * @author steeffeen & kremsy */ -class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager +class ManiaExchangeManager { /** * Constants */ + //Search others const SEARCH_ORDER_NONE = -1; const SEARCH_ORDER_TRACK_NAME = 0; const SEARCH_ORDER_AUTHOR = 1; @@ -30,7 +31,9 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager const SEARCH_ORDER_DIFFICULTY_HARDEST = 13; const SEARCH_ORDER_LENGHT_SHORTEST = 14; const SEARCH_ORDER_LENGHT_LONGEST = 15; - const MAPS_PER_MX_FETCH = 50; + + //Maximum Maps per request + const MAPS_PER_MX_FETCH = 50; /** * Private Propertieswc @@ -151,6 +154,12 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager } + /** + * Get the Whole Maplist from MX by Mixed Uid and Id String fetch + * + * @param $string + * @return array|null + */ public function getMaplistByMixedUidIdString($string) { // Get Title Id $titleId = $this->maniaControl->server->titleId; @@ -259,6 +268,12 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager return $maps; } + /** + * Loads an file + * + * @param $url + * @return bool|int|string + */ private function get_file($url) { $url = parse_url($url); $port = isset($url['port']) ? $url['port'] : 80; @@ -289,6 +304,13 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager return trim($page[1]); } } // get_file + + /** + * Gets the Current Environemnt by String + * + * @param $env + * @return int + */ private function getEnvironment($env) { switch($env) { case 'TMCanyon': diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index 49a61766..b783d15e 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -114,7 +114,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { } // search for matching maps - $maps = $this->maniaControl->mapManager->mxInfoSearcher->getMaps($searchString, $author, $environment); + $maps = $this->maniaControl->mapManager->mxManager->getMaps($searchString, $author, $environment); // check if there are any results if($maps == null) { diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index a00a667b..cc9358f5 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -57,10 +57,10 @@ class MapManager implements CallbackListener { $this->initTables(); // Create map commands instance - $this->mapList = new MapList($this->maniaControl); - $this->mapCommands = new MapCommands($maniaControl); - $this->mapQueue = new MapQueue($this->maniaControl); - $this->mxInfoSearcher = new ManiaExchangeInfoSearcher($this->maniaControl); + $this->mapList = new MapList($this->maniaControl); + $this->mapCommands = new MapCommands($maniaControl); + $this->mapQueue = new MapQueue($this->maniaControl); + $this->mxManager = new ManiaExchangeManager($this->maniaControl); // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); @@ -292,7 +292,7 @@ class MapManager implements CallbackListener { public function handleOnInit(array $callback) { $this->updateFullMapList(); $this->fetchCurrentMap(); - $this->mxInfoSearcher->fetchManiaExchangeMapInformations(); + $this->mxManager->fetchManiaExchangeMapInformations(); } /** @@ -388,7 +388,7 @@ class MapManager implements CallbackListener { $title = strtolower(substr($serverInfo['TitleId'], 0, 2)); // Check if map exists - $mxMapInfos = $this->maniaControl->mapManager->mxInfoSearcher->getMaplistByMixedUidIdString($mapId); + $mxMapInfos = $this->maniaControl->mapManager->mxManager->getMaplistByMixedUidIdString($mapId); $mapInfo = $mxMapInfos[0]; /** @var MXMapInfo $mapInfo */ @@ -437,7 +437,7 @@ class MapManager implements CallbackListener { $this->updateFullMapList(); //Update Mx MapInfo - $this->maniaControl->mapManager->mxInfoSearcher->updateMapObjectsWithManiaExchangeIds($mxMapInfos); + $this->maniaControl->mapManager->mxManager->updateMapObjectsWithManiaExchangeIds($mxMapInfos); // Queue requested Map $this->maniaControl->mapManager->mapQueue->addMapToMapQueue($login, $mapInfo->uid);