Updated to ManiaLink v3

This commit is contained in:
Jocy Wolff
2017-03-25 18:40:15 +01:00
parent 1010c1db6b
commit 120a0e2169
133 changed files with 16194 additions and 8949 deletions

View File

@ -8,57 +8,77 @@ use FML\Types\Renderable;
* Class representing a ManiaLink script tag with a simple script text
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class SimpleScript implements Renderable {
/*
* Protected properties
*/
protected $tagName = 'script';
protected $text = null;
class SimpleScript implements Renderable
{
/**
* Create a new SimpleScript object
*
* @param string $text (optional) Script text
* @return static
*/
public static function create($text = null) {
return new static($text);
}
/**
* @var string $text Script text
*/
protected $text = null;
/**
* Construct a new SimpleScript object
*
* @param string $text (optional) Script text
*/
public function __construct($text = null) {
if ($text !== null) {
$this->setText($text);
}
}
/**
* Create a new SimpleScript
*
* @api
* @param string $text (optional) Script text
* @return static
*/
public static function create($text = null)
{
return new static($text);
}
/**
* Set script text
*
* @param string $text Complete script text
* @return static
*/
public function setText($text) {
$this->text = (string)$text;
return $this;
}
/**
* Construct a new SimpleScript
*
* @api
* @param string $text (optional) Script text
*/
public function __construct($text = null)
{
if ($text) {
$this->setText($text);
}
}
/**
* Get the script text
*
* @api
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* Set the script text
*
* @api
* @param string $text Complete script text
* @return static
*/
public function setText($text)
{
$this->text = (string)$text;
return $this;
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("script");
if ($this->text) {
$scriptComment = $domDocument->createComment($this->text);
$domElement->appendChild($scriptComment);
}
return $domElement;
}
/**
* @see \FML\Types\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
if ($this->text) {
$scriptComment = $domDocument->createComment($this->text);
$xmlElement->appendChild($scriptComment);
}
return $xmlElement;
}
}