2014-01-28 15:56:50 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\ManiaExchange;
|
|
|
|
|
2014-05-13 14:32:30 +02:00
|
|
|
use ManiaControl\Utils\Formatter;
|
2014-02-08 19:33:26 +01:00
|
|
|
|
2014-01-28 15:56:50 +01:00
|
|
|
/**
|
|
|
|
* Mania Exchange Map Info Object
|
|
|
|
*
|
2014-05-02 17:50:30 +02:00
|
|
|
* @author Xymph
|
|
|
|
* @updated kremsy <kremsy@maniacontrol.com>
|
2015-01-19 11:06:20 +01:00
|
|
|
* @copyright 2014-2015 ManiaControl Team
|
2014-05-02 17:50:30 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-01-28 15:56:50 +01:00
|
|
|
*/
|
|
|
|
class MXMapInfo {
|
2014-08-02 22:31:46 +02:00
|
|
|
/*
|
|
|
|
* Public properties
|
|
|
|
*/
|
2014-01-28 15:56:50 +01:00
|
|
|
public $prefix, $id, $uid, $name, $userid, $author, $uploaded, $updated, $type, $maptype;
|
2015-01-12 18:16:14 +01:00
|
|
|
public $titlepack, $style, $envir, $mood, $dispcost, $lightmap, $modname, $exever;
|
|
|
|
public $exebld, $routes, $length, $unlimiter, $laps, $difficulty, $lbrating, $trkvalue;
|
|
|
|
public $replaytyp, $replayid, $replaycnt, $authorComment, $commentCount, $awards;
|
|
|
|
public $pageurl, $replayurl, $imageurl, $thumburl, $downloadurl, $dir;
|
|
|
|
public $ratingVoteCount, $ratingVoteAverage, $vehicleName;
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-01-28 15:56:50 +01:00
|
|
|
/**
|
|
|
|
* Returns map object with all available data from MX map data
|
|
|
|
*
|
|
|
|
* @param String $prefix MX URL prefix
|
2014-02-13 00:46:41 +01:00
|
|
|
* @param $mx
|
2014-01-28 15:56:50 +01:00
|
|
|
* @return MXMapInfo
|
|
|
|
*/
|
|
|
|
public function __construct($prefix, $mx) {
|
|
|
|
$this->prefix = $prefix;
|
2014-05-11 19:57:33 +02:00
|
|
|
|
|
|
|
if (!$mx) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-14 14:32:29 +02:00
|
|
|
if ($this->prefix === 'tm') {
|
2014-05-11 19:57:33 +02:00
|
|
|
$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 : '';
|
|
|
|
}
|
|
|
|
|
2014-06-14 14:32:29 +02:00
|
|
|
if (!isset($mx->GbxMapName) || $mx->GbxMapName === '?') {
|
2014-05-11 19:57:33 +02:00
|
|
|
$this->name = $mx->Name;
|
|
|
|
} else {
|
|
|
|
$this->name = Formatter::stripDirtyCodes($mx->GbxMapName);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->userid = $mx->UserID;
|
|
|
|
$this->author = $mx->Username;
|
|
|
|
$this->uploaded = $mx->UploadedAt;
|
|
|
|
$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->awards = isset($mx->AwardCount) ? $mx->AwardCount : 0;
|
|
|
|
$this->vehicleName = isset($mx->VehicleName) ? $mx->VehicleName : '';
|
|
|
|
|
2014-05-11 20:28:52 +02:00
|
|
|
$this->authorComment = $mx->Comments;
|
|
|
|
$this->commentCount = $mx->CommentCount;
|
|
|
|
|
2014-05-11 19:57:33 +02:00
|
|
|
$this->ratingVoteCount = isset($mx->RatingVoteCount) ? $mx->RatingVoteCount : 0;
|
|
|
|
$this->ratingVoteAverage = isset($mx->RatingVoteAverage) ? $mx->RatingVoteAverage : 0;
|
|
|
|
|
2014-06-14 14:32:29 +02:00
|
|
|
if (!$this->trkvalue && $this->lbrating > 0) {
|
2014-05-11 19:57:33 +02:00
|
|
|
$this->trkvalue = $this->lbrating;
|
2014-06-14 14:32:29 +02:00
|
|
|
} elseif (!$this->lbrating && $this->trkvalue > 0) {
|
2014-05-11 19:57:33 +02:00
|
|
|
$this->lbrating = $this->trkvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$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) {
|
|
|
|
$this->imageurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/screenshot/normal/' . $this->id;
|
|
|
|
} else {
|
|
|
|
$this->imageurl = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($mx->HasThumbnail) {
|
2015-01-12 18:16:14 +01:00
|
|
|
$this->thumburl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/thumbnail/' . $this->id;
|
2014-05-11 19:57:33 +02:00
|
|
|
} else {
|
|
|
|
$this->thumburl = '';
|
|
|
|
}
|
|
|
|
|
2014-06-14 14:32:29 +02:00
|
|
|
if ($this->prefix === 'tm' && $this->replayid > 0) {
|
2014-05-11 19:57:33 +02:00
|
|
|
$this->replayurl = 'http://' . $this->prefix . '.mania-exchange.com/replays/download/' . $this->replayid;
|
|
|
|
} else {
|
|
|
|
$this->replayurl = '';
|
2014-01-28 15:56:50 +01:00
|
|
|
}
|
|
|
|
}
|
2014-04-12 12:14:37 +02:00
|
|
|
}
|