log method improvement

This commit is contained in:
Steffen Schröder 2014-01-05 14:13:18 +01:00
parent 5f27ab3e4a
commit 7c2508a0af
2 changed files with 58 additions and 50 deletions

View File

@ -130,7 +130,10 @@ class ManiaControl implements CommandListener {
*
* @param string $message
*/
public function log($message) {
public function log($message, $stripCodes = false) {
if ($stripCodes) {
$message = Formatter::stripCodes($message);
}
logMessage($message);
}
@ -364,8 +367,7 @@ class ManiaControl implements CommandListener {
// Set api version
if (!$this->client->query('SetApiVersion', self::API_VERSION)) {
trigger_error(
"Couldn't set API version '" . self::API_VERSION . "'! This might cause problems. " . $this->getClientErrorText());
trigger_error("Couldn't set API version '" . self::API_VERSION . "'! This might cause problems. " . $this->getClientErrorText());
}
// Connect finished

View File

@ -12,9 +12,8 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use MXInfoFetcher;
/**
* Manager for maps
* Manager for Maps
*
* @author kremsy & steeffeen
*/
@ -24,8 +23,9 @@ class MapManager implements CallbackListener {
*/
const TABLE_MAPS = 'mc_maps';
const CB_MAPLIST_UPDATED = 'MapManager.MapListUpdated';
/**
* Private properties
* Private Properties
*/
private $maniaControl = null;
private $mapCommands = null;
@ -57,7 +57,6 @@ class MapManager implements CallbackListener {
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleBeginMap');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapListModified');
}
/**
@ -136,24 +135,24 @@ class MapManager implements CallbackListener {
return true;
}
/**
* Erases a Map
*
* @param $id
* @param $uid
*/
public function eraseMap($id, $uid) {
$map = $this->mapListUids[$uid];
$this->maniaControl->client->query('RemoveMap', $map->fileName);
$this->maniaControl->chat->sendSuccess('Map $<' . $map->name . '$> removed!'); //TODO specified message, who done it?
$this->maniaControl->log(Formatter::stripCodes('Map $<' . $map->name . '$> removed!'));
$this->maniaControl->chat->sendSuccess('Map $<' . $map->name . '$> removed!');
// TODO specified message, who done it?
$this->maniaControl->log('Map $<' . $map->name . '$> removed!', true);
unset($this->mapListUids[$uid]);
unset($this->mapList[$id]);
}
/**
* Updates the full Map list, needed on Init, addMap and on ShuffleMaps
* @return null
*/
private function updateFullMapList() {
if (!$this->maniaControl->client->query('GetMapList', 100, 0)) { // fetch 100 Maps
@ -167,7 +166,8 @@ class MapManager implements CallbackListener {
foreach ($mapList as $rpcMap) {
if (array_key_exists($rpcMap["UId"], $this->mapListUids)) { // Map already exists, only update index
$tempList[] = $this->mapListUids[$rpcMap["UId"]];
}else{ //Insert Map Object
}
else { // Insert Map Object
$map = new Map($this->maniaControl, $rpcMap);
$this->saveMap($map);
$tempList[] = $map;
@ -212,6 +212,8 @@ class MapManager implements CallbackListener {
}
/**
* Get Current Map
*
* @return Map currentMap
*/
public function getCurrentMap() {
@ -220,6 +222,7 @@ class MapManager implements CallbackListener {
/**
* Returns map By UID
*
* @param $uid
* @return mixed
*/
@ -227,7 +230,6 @@ class MapManager implements CallbackListener {
return $this->mapListUids[$uid];
}
/**
* Handle BeginMap callback
*
@ -236,13 +238,15 @@ class MapManager implements CallbackListener {
public function handleBeginMap(array $callback) {
if (array_key_exists($callback[1][0]["UId"], $this->mapListUids)) { // Map already exists, only update index
$this->currentMap = $this->mapListUids[$callback[1][0]["UId"]];
}else{ //can this ever happen?
}
else { // can this ever happen?
$this->currentMap = $this->fetchCurrentMapInfo();
}
}
/**
* MapList modified by other controller or web panels
*
* @param array $callback
*/
public function mapListModified(array $callback) {
@ -250,6 +254,7 @@ class MapManager implements CallbackListener {
}
/**
*
* @return array
*/
public function getMapList() {
@ -258,6 +263,7 @@ class MapManager implements CallbackListener {
/**
* Adds a Map from Mania Exchange
*
* @param $mapId
* @param $login
*/