TrackManiaControl/application/core/Libs/FML/ManiaCode/ShowMessage.php

62 lines
1.4 KiB
PHP
Raw Normal View History

2014-01-12 00:51:46 +01:00
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element showing a Message
*
2014-05-18 19:45:50 +02:00
* @author steeffeen
2014-04-13 18:21:40 +02:00
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
2014-05-18 19:45:50 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
2014-01-12 00:51:46 +01:00
*/
class ShowMessage implements Element {
2014-01-21 20:30:40 +01:00
/*
2014-01-12 00:51:46 +01:00
* Protected Properties
*/
protected $tagName = 'show_message';
protected $message = '';
2014-01-19 19:30:21 +01:00
/**
* Create a new ShowMessage Element
2014-05-18 19:45:50 +02:00
*
2014-01-19 19:30:21 +01:00
* @param string $message (optional) Message Text
* @return \FML\ManiaCode\ShowMessage
*/
public static function create($message = null) {
$showMessage = new ShowMessage($message);
return $showMessage;
}
2014-01-12 00:51:46 +01:00
/**
* Construct a new ShowMessage Element
*
* @param string $message (optional) Message Text
*/
public function __construct($message = null) {
if ($message !== null) {
$this->setMessage($message);
}
}
/**
* Set the displayed Message Text
*
* @param string $message Message Text
* @return \FML\ManiaCode\ShowMessage
*/
public function setMessage($message) {
2014-05-18 19:45:50 +02:00
$this->message = (string)$message;
2014-01-12 00:51:46 +01:00
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
2014-05-18 19:45:50 +02:00
$xmlElement = $domDocument->createElement($this->tagName);
2014-01-12 00:51:46 +01:00
$messageElement = $domDocument->createElement('message', $this->message);
$xmlElement->appendChild($messageElement);
return $xmlElement;
}
}