2014-01-19 19:30:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\Controls;
|
|
|
|
|
|
|
|
use FML\Elements\FrameModel;
|
2014-04-27 14:44:40 +02:00
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Class representing an instance of a Frame Model
|
2014-01-19 19:30:21 +01:00
|
|
|
* (CMlFrame)
|
|
|
|
*
|
2014-05-20 15:44:45 +02:00
|
|
|
* @author steeffeen <mail@steeffeen.com>
|
2017-03-25 18:40:15 +01:00
|
|
|
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
|
2014-05-14 23:24:00 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
2017-03-25 18:40:15 +01:00
|
|
|
class FrameInstance extends Control
|
|
|
|
{
|
2014-01-19 19:30:21 +01:00
|
|
|
|
2017-03-25 18:40:15 +01:00
|
|
|
/**
|
|
|
|
* @var string $modelId FrameModel id
|
|
|
|
*/
|
|
|
|
protected $modelId = null;
|
2014-06-21 03:18:21 +02:00
|
|
|
|
2017-03-25 18:40:15 +01:00
|
|
|
/**
|
|
|
|
* @var FrameModel $model FrameModel
|
|
|
|
*/
|
|
|
|
protected $model = null;
|
2014-01-19 19:30:21 +01:00
|
|
|
|
2017-04-02 16:32:57 +02:00
|
|
|
/**
|
|
|
|
* Create a new Frame Instance
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @param string $controlId (optional) Control Id
|
|
|
|
* @param string $modelId (optional) Model Id
|
|
|
|
* @return static
|
|
|
|
*/
|
|
|
|
public static function create($controlId = null, $modelId = null)
|
|
|
|
{
|
|
|
|
return new static($controlId, $modelId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a new Frame Instance
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @param string $controlId (optional) Control Id
|
|
|
|
* @param string $modelId (optional) Model Id
|
|
|
|
*/
|
|
|
|
public function __construct($controlId = null, $modelId = null)
|
|
|
|
{
|
|
|
|
parent::__construct($controlId);
|
|
|
|
if ($modelId) {
|
|
|
|
$this->setModelId($modelId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-25 18:40:15 +01:00
|
|
|
/**
|
|
|
|
* Get the FrameModel id
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getModelId()
|
|
|
|
{
|
|
|
|
return $this->modelId;
|
|
|
|
}
|
2014-01-19 19:30:21 +01:00
|
|
|
|
2017-03-25 18:40:15 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
2014-05-16 22:44:22 +02:00
|
|
|
|
2017-03-25 18:40:15 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
2014-05-16 22:44:22 +02:00
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
}
|