TrackManiaControl/application/core/FML/Controls/Frame.php

65 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace FML\Controls;
use FML\Types\Container;
use FML\Types\Renderable;
/**
2014-01-12 00:51:46 +01:00
* Frame Element
* (CMlFrame)
*
* @author steeffeen
*/
class Frame extends Control implements Container {
/**
2013-12-31 02:55:19 +01:00
* Protected Properties
*/
protected $children = array();
/**
2013-12-31 02:55:19 +01:00
* Construct a new Frame Control
*
2014-01-12 00:51:46 +01:00
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'frame';
}
/**
*
* @see \FML\Types\Container::add()
* @return \FML\Controls\Frame
*/
public function add(Renderable $child) {
2014-01-12 14:47:17 +01:00
if (!in_array($child, $this->children, true)) {
2014-01-12 00:51:46 +01:00
array_push($this->children, $child);
}
return $this;
}
/**
*
* @see \FML\Types\Container::removeChildren()
* @return \FML\Controls\Frame
*/
public function removeChildren() {
$this->children = array();
return $this;
}
/**
*
* @see \FML\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
2014-01-12 00:51:46 +01:00
$xmlElement = parent::render($domDocument);
foreach ($this->children as $child) {
2014-01-12 00:51:46 +01:00
$childXmlElement = $child->render($domDocument);
$xmlElement->appendChild($childXmlElement);
}
2014-01-12 00:51:46 +01:00
return $xmlElement;
}
}