renamed mx class

This commit is contained in:
kremsy 2014-01-14 15:15:13 +01:00 committed by Steffen Schröder
parent 9c446c0a67
commit 1fed47ec20
4 changed files with 33 additions and 11 deletions

View File

@ -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';

View File

@ -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,6 +31,8 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager
const SEARCH_ORDER_DIFFICULTY_HARDEST = 13;
const SEARCH_ORDER_LENGHT_SHORTEST = 14;
const SEARCH_ORDER_LENGHT_LONGEST = 15;
//Maximum Maps per request
const MAPS_PER_MX_FETCH = 50;
/**
@ -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':

View File

@ -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) {

View File

@ -60,7 +60,7 @@ class MapManager implements CallbackListener {
$this->mapList = new MapList($this->maniaControl);
$this->mapCommands = new MapCommands($maniaControl);
$this->mapQueue = new MapQueue($this->maniaControl);
$this->mxInfoSearcher = new ManiaExchangeInfoSearcher($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);