escaping utility methods
This commit is contained in:
parent
3b47f0fd9a
commit
56108f0605
@ -11,6 +11,16 @@ namespace ManiaControl;
|
|||||||
*/
|
*/
|
||||||
abstract class Formatter {
|
abstract class Formatter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the given Text with Escaping around it
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function escapeText($text) {
|
||||||
|
return '$<' . $text . '$>';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format the given Time (in Milliseconds)
|
* Format the given Time (in Milliseconds)
|
||||||
*
|
*
|
||||||
|
@ -70,6 +70,15 @@ class Map {
|
|||||||
$this->authorNick = $this->authorLogin;
|
$this->authorNick = $this->authorLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the escaped Map Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getEscapedName() {
|
||||||
|
return Formatter::escapeText($this->name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get's the gameType of the Current Map
|
* Get's the gameType of the Current Map
|
||||||
*
|
*
|
||||||
|
@ -68,7 +68,7 @@ class Player {
|
|||||||
* Construct a new Player
|
* Construct a new Player
|
||||||
*
|
*
|
||||||
* @param ManiaControl $maniaControl
|
* @param ManiaControl $maniaControl
|
||||||
* @param bool $connected
|
* @param bool $connected
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl, $connected) {
|
public function __construct(ManiaControl $maniaControl, $connected) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
@ -78,6 +78,19 @@ class Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Escaped Nickname
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getEscapedNickname() {
|
||||||
|
$nickname = $this->nickname;
|
||||||
|
if (!$nickname) {
|
||||||
|
$nickname = $this->login;
|
||||||
|
}
|
||||||
|
return Formatter::escapeText($nickname);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update from ManiaPlanet PlayerInfo structure
|
* Update from ManiaPlanet PlayerInfo structure
|
||||||
*
|
*
|
||||||
|
@ -176,8 +176,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||||
$self->maniaControl->log("Try to connect on Dedimania");
|
$self->maniaControl->log("Try to connect on Dedimania");
|
||||||
|
|
||||||
if ($error != '') {
|
if (!$data || $error) {
|
||||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
$self->maniaControl->log("Dedimania Error: '{$error}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $self->decode($data);
|
$data = $self->decode($data);
|
||||||
|
Loading…
Reference in New Issue
Block a user