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

@ -9,84 +9,101 @@ use FML\Elements\FrameModel;
* (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 FrameInstance extends Control {
/*
* Protected properties
*/
protected $tagName = 'frameinstance';
protected $modelId = null;
/** @var FrameModel $model */
protected $model = null;
class FrameInstance extends Control
{
/**
* Create a new Frame Instance object
*
* @param string $modelId (optional) Frame Model id
* @param string $controlId (optional) Frame id
* @return static
*/
public static function create($modelId = null, $controlId = null) {
return new static($modelId, $controlId);
}
/**
* @var string $modelId FrameModel id
*/
protected $modelId = null;
/**
* Construct a new Frame Instance object
*
* @param string $modelId (optional) Frame Model id
* @param string $controlId (optional) Frame id
*/
public function __construct($modelId = null, $controlId = null) {
parent::__construct($controlId);
if ($modelId !== null) {
$this->setModelId($modelId);
}
}
/**
* @var FrameModel $model FrameModel
*/
protected $model = null;
/**
* Set Frame Model id
*
* @param string $modelId Frame Model id
* @return static
*/
public function setModelId($modelId) {
$this->modelId = (string)$modelId;
$this->model = null;
return $this;
}
/**
* Get the FrameModel id
*
* @api
* @return string
*/
public function getModelId()
{
return $this->modelId;
}
/**
* Set Frame Model
*
* @param FrameModel $frameModel Frame Model
* @return static
*/
public function setModel(FrameModel $frameModel) {
$this->model = $frameModel;
$this->modelId = null;
return $this;
}
/**
* Set the FrameModel id
*
* @api
* @param string $modelId FrameModel id
* @return static
*/
public function setModelId($modelId)
{
$this->modelId = (string)$modelId;
$this->model = null;
return $this;
}
/**
* @see \FML\Controls\Control::getManiaScriptClass()
*/
public function getManiaScriptClass() {
return 'CMlFrame';
}
/**
* Get the FrameModel
*
* @api
* @return FrameModel
*/
public function getModel()
{
return $this->model;
}
/**
* Set the FrameModel
*
* @api
* @param FrameModel $frameModel FrameModel
* @return static
*/
public function setModel(FrameModel $frameModel)
{
$this->modelId = null;
$this->model = $frameModel;
return $this;
}
/**
* @see Control::getTagName()
*/
public function getTagName()
{
return "frameinstance";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlFrame";
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->model) {
$this->model->checkId();
$domElement->setAttribute("modelid", $this->model->getId());
} else if ($this->modelId) {
$domElement->setAttribute("modelid", $this->modelId);
}
return $domElement;
}
/**
* @see \FML\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
if ($this->model) {
$this->model->checkId();
$xmlElement->setAttribute('modelid', $this->model->getId());
} else if ($this->modelId) {
$xmlElement->setAttribute('modelid', $this->modelId);
}
return $xmlElement;
}
}