mx object cleanup

This commit is contained in:
kremsy 2014-05-11 19:57:33 +02:00
parent 2650db54e3
commit 7627546baa

View File

@ -25,93 +25,95 @@ class MXMapInfo {
* *
* @param String $prefix MX URL prefix * @param String $prefix MX URL prefix
* @param $mx * @param $mx
* @internal param Object $map The MX map data from MXInfoSearcher
* @return MXMapInfo * @return MXMapInfo
*/ */
public function __construct($prefix, $mx) { public function __construct($prefix, $mx) {
$this->prefix = $prefix; $this->prefix = $prefix;
if ($mx) {
if ($this->prefix == 'tm') {
$this->dir = 'tracks';
$this->id = $mx->TrackID;
$this->uid = isset($mx->TrackUID) ? $mx->TrackUID : '';
} else {
$this->dir = 'maps';
$this->id = $mx->MapID;
$this->uid = isset($mx->MapUID) ? $mx->MapUID : '';
}
if (!isset($mx->GbxMapName) || $mx->GbxMapName == '?') { if (!$mx) {
$this->name = $mx->Name; return;
} else { }
$this->name = Formatter::stripDirtyCodes($mx->GbxMapName);
}
$this->userid = $mx->UserID; if ($this->prefix == 'tm') {
$this->author = $mx->Username; $this->dir = 'tracks';
$this->uploaded = $mx->UploadedAt; $this->id = $mx->TrackID;
$this->updated = $mx->UpdatedAt; $this->uid = isset($mx->TrackUID) ? $mx->TrackUID : '';
$this->type = $mx->TypeName; } else {
$this->maptype = isset($mx->MapType) ? $mx->MapType : ''; $this->dir = 'maps';
$this->titlepack = isset($mx->TitlePack) ? $mx->TitlePack : ''; $this->id = $mx->MapID;
$this->style = isset($mx->StyleName) ? $mx->StyleName : ''; $this->uid = isset($mx->MapUID) ? $mx->MapUID : '';
$this->envir = $mx->EnvironmentName; }
$this->mood = $mx->Mood;
$this->dispcost = $mx->DisplayCost;
$this->lightmap = $mx->Lightmap;
$this->modname = isset($mx->ModName) ? $mx->ModName : '';
$this->exever = $mx->ExeVersion;
$this->exebld = $mx->ExeBuild;
$this->routes = isset($mx->RouteName) ? $mx->RouteName : '';
$this->length = isset($mx->LengthName) ? $mx->LengthName : '';
$this->unlimiter = isset($mx->UnlimiterRequired) ? $mx->UnlimiterRequired : false;
$this->laps = isset($mx->Laps) ? $mx->Laps : 0;
$this->difficulty = $mx->DifficultyName;
$this->lbrating = isset($mx->LBRating) ? $mx->LBRating : 0;
$this->trkvalue = isset($mx->TrackValue) ? $mx->TrackValue : 0;
$this->replaytyp = isset($mx->ReplayTypeName) ? $mx->ReplayTypeName : '';
$this->replayid = isset($mx->ReplayWRID) ? $mx->ReplayWRID : 0;
$this->replaycnt = isset($mx->ReplayCount) ? $mx->ReplayCount : 0;
$this->acomment = $mx->Comments;
$this->awards = isset($mx->AwardCount) ? $mx->AwardCount : 0;
$this->comments = $mx->CommentCount;
$this->vehicleName = isset($mx->VehicleName) ? $mx->VehicleName : '';
$this->ratingVoteCount = isset($mx->RatingVoteCount) ? $mx->RatingVoteCount : 0; if (!isset($mx->GbxMapName) || $mx->GbxMapName == '?') {
$this->ratingVoteAverage = isset($mx->RatingVoteAverage) ? $mx->RatingVoteAverage : 0; $this->name = $mx->Name;
} else {
$this->name = Formatter::stripDirtyCodes($mx->GbxMapName);
}
if ($this->trkvalue == 0 && $this->lbrating > 0) { $this->userid = $mx->UserID;
$this->trkvalue = $this->lbrating; $this->author = $mx->Username;
} elseif ($this->lbrating == 0 && $this->trkvalue > 0) { $this->uploaded = $mx->UploadedAt;
$this->lbrating = $this->trkvalue; $this->updated = $mx->UpdatedAt;
} $this->type = $mx->TypeName;
$this->maptype = isset($mx->MapType) ? $mx->MapType : '';
$this->titlepack = isset($mx->TitlePack) ? $mx->TitlePack : '';
$this->style = isset($mx->StyleName) ? $mx->StyleName : '';
$this->envir = $mx->EnvironmentName;
$this->mood = $mx->Mood;
$this->dispcost = $mx->DisplayCost;
$this->lightmap = $mx->Lightmap;
$this->modname = isset($mx->ModName) ? $mx->ModName : '';
$this->exever = $mx->ExeVersion;
$this->exebld = $mx->ExeBuild;
$this->routes = isset($mx->RouteName) ? $mx->RouteName : '';
$this->length = isset($mx->LengthName) ? $mx->LengthName : '';
$this->unlimiter = isset($mx->UnlimiterRequired) ? $mx->UnlimiterRequired : false;
$this->laps = isset($mx->Laps) ? $mx->Laps : 0;
$this->difficulty = $mx->DifficultyName;
$this->lbrating = isset($mx->LBRating) ? $mx->LBRating : 0;
$this->trkvalue = isset($mx->TrackValue) ? $mx->TrackValue : 0;
$this->replaytyp = isset($mx->ReplayTypeName) ? $mx->ReplayTypeName : '';
$this->replayid = isset($mx->ReplayWRID) ? $mx->ReplayWRID : 0;
$this->replaycnt = isset($mx->ReplayCount) ? $mx->ReplayCount : 0;
$this->acomment = $mx->Comments;
$this->awards = isset($mx->AwardCount) ? $mx->AwardCount : 0;
$this->comments = $mx->CommentCount;
$this->vehicleName = isset($mx->VehicleName) ? $mx->VehicleName : '';
$search = array(chr(31), '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[url]', '[/url]'); $this->ratingVoteCount = isset($mx->RatingVoteCount) ? $mx->RatingVoteCount : 0;
$replace = array('<br/>', '<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<i>', '</i>'); $this->ratingVoteAverage = isset($mx->RatingVoteAverage) ? $mx->RatingVoteAverage : 0;
$this->acomment = str_ireplace($search, $replace, $this->acomment);
$this->acomment = preg_replace('/\[url=.*\]/', '<i>', $this->acomment);
$this->pageurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/view/' . $this->id; if ($this->trkvalue == 0 && $this->lbrating > 0) {
$this->downloadurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/download/' . $this->id; $this->trkvalue = $this->lbrating;
} elseif ($this->lbrating == 0 && $this->trkvalue > 0) {
$this->lbrating = $this->trkvalue;
}
$search = array(chr(31), '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[url]', '[/url]');
$replace = array('<br/>', '<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<i>', '</i>');
$this->acomment = str_ireplace($search, $replace, $this->acomment);
$this->acomment = preg_replace('/\[url=.*\]/', '<i>', $this->acomment);
$this->pageurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/view/' . $this->id;
$this->downloadurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/download/' . $this->id;
if ($mx->HasScreenshot) { if ($mx->HasScreenshot) {
$this->imageurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/screenshot/normal/' . $this->id; $this->imageurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/screenshot/normal/' . $this->id;
} else { } else {
$this->imageurl = ''; $this->imageurl = '';
} }
if ($mx->HasThumbnail) { if ($mx->HasThumbnail) {
$this->thumburl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/screenshot/small/' . $this->id; $this->thumburl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/screenshot/small/' . $this->id;
} else { } else {
$this->thumburl = ''; $this->thumburl = '';
} }
if ($this->prefix == 'tm' && $this->replayid > 0) { if ($this->prefix == 'tm' && $this->replayid > 0) {
$this->replayurl = 'http://' . $this->prefix . '.mania-exchange.com/replays/download/' . $this->replayid; $this->replayurl = 'http://' . $this->prefix . '.mania-exchange.com/replays/download/' . $this->replayid;
} else { } else {
$this->replayurl = ''; $this->replayurl = '';
}
} }
} }
} }