Updated to ManiaLink v3
This commit is contained in:
@ -12,88 +12,132 @@ use FML\Types\ScriptFeatureable;
|
||||
* (CMlFrame)
|
||||
*
|
||||
* @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 Frame extends Control implements Container {
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $tagName = 'frame';
|
||||
/** @var Renderable[] $children */
|
||||
protected $children = array();
|
||||
/** @var Format $format */
|
||||
protected $format = null;
|
||||
class Frame extends Control implements Container
|
||||
{
|
||||
|
||||
/**
|
||||
* @see \FML\Controls\Control::getManiaScriptClass()
|
||||
*/
|
||||
public function getManiaScriptClass() {
|
||||
return 'CMlFrame';
|
||||
}
|
||||
/**
|
||||
* @var Renderable[] $children Children
|
||||
*/
|
||||
protected $children = array();
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::add()
|
||||
*/
|
||||
public function add(Renderable $child) {
|
||||
if (!in_array($child, $this->children, true)) {
|
||||
array_push($this->children, $child);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var Format $format Format
|
||||
*/
|
||||
protected $format = null;
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::removeChildren()
|
||||
*/
|
||||
public function removeChildren() {
|
||||
$this->children = array();
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @see Container::getChildren()
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::getFormat()
|
||||
*/
|
||||
public function getFormat($createIfEmpty = true) {
|
||||
if (!$this->format && $createIfEmpty) {
|
||||
$this->setFormat(new Format());
|
||||
}
|
||||
return $this->format;
|
||||
}
|
||||
/**
|
||||
* @see Container::addChild()
|
||||
* @deprecated use addChild() instead
|
||||
*/
|
||||
public function add(Renderable $child)
|
||||
{
|
||||
return $this->addChild($child);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::setFormat()
|
||||
*/
|
||||
public function setFormat(Format $format) {
|
||||
$this->format = $format;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @see Container::addChild()
|
||||
*/
|
||||
public function addChild(Renderable $child)
|
||||
{
|
||||
if (!in_array($child, $this->children, true)) {
|
||||
array_push($this->children, $child);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Controls\Control::getScriptFeatures()
|
||||
*/
|
||||
public function getScriptFeatures() {
|
||||
$scriptFeatures = $this->scriptFeatures;
|
||||
foreach ($this->children as $child) {
|
||||
if ($child instanceof ScriptFeatureable) {
|
||||
$scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures());
|
||||
}
|
||||
}
|
||||
return $scriptFeatures;
|
||||
}
|
||||
/**
|
||||
* @see Container::addChildren()
|
||||
*/
|
||||
public function addChildren(array $children)
|
||||
{
|
||||
foreach ($children as $child) {
|
||||
$this->addChild($child);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Container::removeAllChildren()
|
||||
*/
|
||||
public function removeAllChildren()
|
||||
{
|
||||
$this->children = array();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Container::getFormat()
|
||||
*/
|
||||
public function getFormat()
|
||||
{
|
||||
return $this->format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Container::setFormat()
|
||||
*/
|
||||
public function setFormat(Format $format = null)
|
||||
{
|
||||
$this->format = $format;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Control::getTagName()
|
||||
*/
|
||||
public function getTagName()
|
||||
{
|
||||
return "frame";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Control::getManiaScriptClass()
|
||||
*/
|
||||
public function getManiaScriptClass()
|
||||
{
|
||||
return "CMlFrame";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Control::getScriptFeatures()
|
||||
*/
|
||||
public function getScriptFeatures()
|
||||
{
|
||||
$scriptFeatures = $this->scriptFeatures;
|
||||
foreach ($this->children as $child) {
|
||||
if ($child instanceof ScriptFeatureable) {
|
||||
$scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures());
|
||||
}
|
||||
}
|
||||
return $scriptFeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$domElement = parent::render($domDocument);
|
||||
if ($this->format) {
|
||||
$formatXml = $this->format->render($domDocument);
|
||||
$domElement->appendChild($formatXml);
|
||||
}
|
||||
foreach ($this->children as $child) {
|
||||
$childXmlElement = $child->render($domDocument);
|
||||
$domElement->appendChild($childXmlElement);
|
||||
}
|
||||
return $domElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$xmlElement = parent::render($domDocument);
|
||||
if ($this->format) {
|
||||
$formatXml = $this->format->render($domDocument);
|
||||
$xmlElement->appendChild($formatXml);
|
||||
}
|
||||
foreach ($this->children as $child) {
|
||||
$childXmlElement = $child->render($domDocument);
|
||||
$xmlElement->appendChild($childXmlElement);
|
||||
}
|
||||
return $xmlElement;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user