renamed+changed methods to better reflect functionality
This commit is contained in:
parent
c59b5ac9cd
commit
dab0db49aa
@ -131,7 +131,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// search for matching maps
|
// search for matching maps
|
||||||
$this->maniaControl->mapManager->mxManager->getMapsAsync(function (array $maps) use (&$player) {
|
$this->maniaControl->mapManager->mxManager->fetchMapsAsync(function (array $maps) use (&$player) {
|
||||||
if (!$maps) {
|
if (!$maps) {
|
||||||
$this->maniaControl->chat->sendError('No maps found, or MX is down!', $player->login);
|
$this->maniaControl->chat->sendError('No maps found, or MX is down!', $player->login);
|
||||||
return;
|
return;
|
||||||
|
@ -130,7 +130,7 @@ class ManiaExchangeManager {
|
|||||||
//If Max Maplimit is reached, or string gets too long send the request
|
//If Max Maplimit is reached, or string gets too long send the request
|
||||||
if ($index % self::MAPS_PER_MX_FETCH === 0) {
|
if ($index % self::MAPS_PER_MX_FETCH === 0) {
|
||||||
$mapIdString = substr($mapIdString, 0, -1);
|
$mapIdString = substr($mapIdString, 0, -1);
|
||||||
$this->getMaplistByMixedUidIdString($mapIdString);
|
$this->fetchMaplistByMixedUidIdString($mapIdString);
|
||||||
$mapIdString = '';
|
$mapIdString = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,27 +139,25 @@ class ManiaExchangeManager {
|
|||||||
|
|
||||||
if ($mapIdString) {
|
if ($mapIdString) {
|
||||||
$mapIdString = substr($mapIdString, 0, -1);
|
$mapIdString = substr($mapIdString, 0, -1);
|
||||||
$this->getMaplistByMixedUidIdString($mapIdString);
|
$this->fetchMaplistByMixedUidIdString($mapIdString);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fetchMapStatement->close();
|
$fetchMapStatement->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Whole MapList from MX by Mixed Uid and Id String fetch
|
* Fetch the whole Map List from MX via mixed Uid and Id Strings
|
||||||
*
|
*
|
||||||
* @param string $string
|
* @param string $string
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function getMaplistByMixedUidIdString($string) {
|
public function fetchMaplistByMixedUidIdString($string) {
|
||||||
// Get Title Prefix
|
// Get Title Prefix
|
||||||
$titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame();
|
$titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame();
|
||||||
|
|
||||||
// compile search URL
|
// compile search URL
|
||||||
$url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $string;
|
$url = "http://api.mania-exchange.com/{$titlePrefix}/maps/?ids={$string}";
|
||||||
|
|
||||||
$thisRef = $this;
|
$this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use ($titlePrefix, $url) {
|
||||||
$success = $this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use ($thisRef, $titlePrefix, $url) {
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
trigger_error("Error: '{$error}' for Url '{$url}'");
|
trigger_error("Error: '{$error}' for Url '{$url}'");
|
||||||
return;
|
return;
|
||||||
@ -184,10 +182,8 @@ class ManiaExchangeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$thisRef->updateMapObjectsWithManiaExchangeIds($maps);
|
$this->updateMapObjectsWithManiaExchangeIds($maps);
|
||||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||||
|
|
||||||
return $success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -232,6 +228,15 @@ class ManiaExchangeManager {
|
|||||||
$saveMapStatement->close();
|
$saveMapStatement->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see \ManiaControl\ManiaExchange\ManiaExchangeManager::fetchMaplistByMixedUidIdString()
|
||||||
|
*/
|
||||||
|
public function getMaplistByMixedUidIdString($string) {
|
||||||
|
$this->fetchMaplistByMixedUidIdString($string);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch Map Info asynchronously
|
* Fetch Map Info asynchronously
|
||||||
*
|
*
|
||||||
@ -262,6 +267,15 @@ class ManiaExchangeManager {
|
|||||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see \ManiaControl\ManiaExchange\ManiaExchangeManager::fetchMapsAsync()
|
||||||
|
*/
|
||||||
|
public function getMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = self::SEARCH_ORDER_UPDATED_NEWEST) {
|
||||||
|
$this->fetchMapsAsync($function, $name, $author, $env, $maxMapsReturned, $searchOrder);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a MapList Asynchronously
|
* Fetch a MapList Asynchronously
|
||||||
*
|
*
|
||||||
@ -271,9 +285,8 @@ class ManiaExchangeManager {
|
|||||||
* @param string $env
|
* @param string $env
|
||||||
* @param int $maxMapsReturned
|
* @param int $maxMapsReturned
|
||||||
* @param int $searchOrder
|
* @param int $searchOrder
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function getMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = self::SEARCH_ORDER_UPDATED_NEWEST) {
|
public function fetchMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = self::SEARCH_ORDER_UPDATED_NEWEST) {
|
||||||
// TODO: remove $env because it's not really used?
|
// TODO: remove $env because it's not really used?
|
||||||
|
|
||||||
// Get Title Id
|
// Get Title Id
|
||||||
@ -310,7 +323,7 @@ class ManiaExchangeManager {
|
|||||||
} catch (GameModeException $e) {
|
} catch (GameModeException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$success = $this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix) {
|
$this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix) {
|
||||||
if ($error) {
|
if ($error) {
|
||||||
trigger_error($error);
|
trigger_error($error);
|
||||||
return;
|
return;
|
||||||
@ -339,8 +352,6 @@ class ManiaExchangeManager {
|
|||||||
|
|
||||||
call_user_func($function, $maps);
|
call_user_func($function, $maps);
|
||||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||||
|
|
||||||
return $success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user