Updated to ManiaLink v3
This commit is contained in:
@ -5,7 +5,6 @@ namespace FML\Components;
|
||||
use FML\Controls\Entry;
|
||||
use FML\Controls\Frame;
|
||||
use FML\Controls\Quad;
|
||||
use FML\Models\CheckBoxDesign;
|
||||
use FML\Script\Features\CheckBoxFeature;
|
||||
use FML\Script\Features\ScriptFeature;
|
||||
use FML\Types\Renderable;
|
||||
@ -14,144 +13,257 @@ use FML\Types\ScriptFeatureable;
|
||||
/**
|
||||
* CheckBox Component
|
||||
*
|
||||
* @uses Quad
|
||||
* @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 CheckBox implements Renderable, ScriptFeatureable {
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $name = null;
|
||||
protected $feature = null;
|
||||
class CheckBox implements Renderable, ScriptFeatureable
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new CheckBox Component
|
||||
*
|
||||
* @param string $name (optional) CheckBox name
|
||||
* @param bool $default (optional) Default value
|
||||
* @param Quad $quad (optional) CheckBox quad
|
||||
*/
|
||||
public function __construct($name = null, $default = null, Quad $quad = null) {
|
||||
$this->feature = new CheckBoxFeature();
|
||||
$this->setName($name);
|
||||
$this->setDefault($default);
|
||||
$this->setQuad($quad);
|
||||
}
|
||||
/**
|
||||
* @var string $name CheckBox name
|
||||
*/
|
||||
protected $name = null;
|
||||
|
||||
/**
|
||||
* Set the name
|
||||
*
|
||||
* @param string $name CheckBox name
|
||||
* @return static
|
||||
*/
|
||||
public function setName($name) {
|
||||
$this->name = (string)$name;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var CheckBoxFeature $feature CheckBox Feature
|
||||
*/
|
||||
protected $feature = null;
|
||||
|
||||
/**
|
||||
* Set the default value
|
||||
*
|
||||
* @param bool $default Default value
|
||||
* @return static
|
||||
*/
|
||||
public function setDefault($default) {
|
||||
$this->feature->setDefault($default);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Construct a new CheckBox
|
||||
*
|
||||
* @api
|
||||
* @param string $name (optional) CheckBox name
|
||||
* @param bool $default (optional) Default value
|
||||
* @param Quad $quad (optional) CheckBox quad
|
||||
*/
|
||||
public function __construct($name = null, $default = null, Quad $quad = null)
|
||||
{
|
||||
$this->feature = new CheckBoxFeature();
|
||||
if ($name) {
|
||||
$this->setName($name);
|
||||
}
|
||||
if ($default !== null) {
|
||||
$this->setDefault($default);
|
||||
}
|
||||
if ($quad) {
|
||||
$this->setQuad($quad);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the enabled Design
|
||||
*
|
||||
* @param string $style Style name or image url
|
||||
* @param string $subStyle SubStyle name
|
||||
* @return static
|
||||
*/
|
||||
public function setEnabledDesign($style, $subStyle = null) {
|
||||
if ($style instanceof CheckBoxDesign) {
|
||||
$this->feature->setEnabledDesign($style);
|
||||
} else {
|
||||
$checkBoxDesign = new CheckBoxDesign($style, $subStyle);
|
||||
$this->feature->setEnabledDesign($checkBoxDesign);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Get the name
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the disabled Design
|
||||
*
|
||||
* @param string $style Style name or image url
|
||||
* @param string $subStyle SubStyle name
|
||||
* @return static
|
||||
*/
|
||||
public function setDisabledDesign($style, $subStyle = null) {
|
||||
if ($style instanceof CheckBoxDesign) {
|
||||
$this->feature->setDisabledDesign($style);
|
||||
} else {
|
||||
$checkBoxDesign = new CheckBoxDesign($style, $subStyle);
|
||||
$this->feature->setDisabledDesign($checkBoxDesign);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set the name
|
||||
*
|
||||
* @api
|
||||
* @param string $name CheckBox name
|
||||
* @return static
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = (string)$name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CheckBox Quad
|
||||
*
|
||||
* @param Quad $quad CheckBox Quad
|
||||
* @return static
|
||||
*/
|
||||
public function setQuad(Quad $quad = null) {
|
||||
$this->feature->setQuad($quad);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Get the default value
|
||||
*
|
||||
* @api
|
||||
* @return bool
|
||||
*/
|
||||
public function getDefault()
|
||||
{
|
||||
return $this->feature->getDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\ScriptFeatureable::getScriptFeatures()
|
||||
*/
|
||||
public function getScriptFeatures() {
|
||||
return ScriptFeature::collect($this->feature, $this->getQuad(), $this->feature->getEntry());
|
||||
}
|
||||
/**
|
||||
* Set the default value
|
||||
*
|
||||
* @api
|
||||
* @param bool $default Default value
|
||||
* @return static
|
||||
*/
|
||||
public function setDefault($default)
|
||||
{
|
||||
$this->feature->setDefault($default);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CheckBox Quad
|
||||
*
|
||||
* @param bool $createIfEmpty (optional) Create the Quad if it's not set
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function getQuad($createIfEmpty = true) {
|
||||
if (!$this->feature->getQuad() && $createIfEmpty) {
|
||||
$quad = new Quad();
|
||||
$quad->setSize(10, 10);
|
||||
$this->setQuad($quad);
|
||||
}
|
||||
return $this->feature->getQuad();
|
||||
}
|
||||
/**
|
||||
* Get the enabled design
|
||||
*
|
||||
* @api
|
||||
* @return CheckBoxDesign
|
||||
*/
|
||||
public function getEnabledDesign()
|
||||
{
|
||||
return $this->feature->getEnabledDesign();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$frame = new Frame();
|
||||
/**
|
||||
* Set the enabled design
|
||||
*
|
||||
* @api
|
||||
* @param string|CheckBoxDesign $style Style name, image url or checkbox design
|
||||
* @param string $subStyle SubStyle name
|
||||
* @return static
|
||||
*/
|
||||
public function setEnabledDesign($style, $subStyle = null)
|
||||
{
|
||||
if ($style instanceof CheckBoxDesign) {
|
||||
$this->feature->setEnabledDesign($style);
|
||||
} else {
|
||||
$checkBoxDesign = new CheckBoxDesign($style, $subStyle);
|
||||
$this->feature->setEnabledDesign($checkBoxDesign);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
$quad = $this->getQuad();
|
||||
$frame->add($quad);
|
||||
/**
|
||||
* Get the disabled design
|
||||
*
|
||||
* @api
|
||||
* @return CheckBoxDesign
|
||||
*/
|
||||
public function getDisabledDesign()
|
||||
{
|
||||
return $this->feature->getDisabledDesign();
|
||||
}
|
||||
|
||||
$entry = $this->buildEntry();
|
||||
$frame->add($entry);
|
||||
$this->feature->setEntry($entry);
|
||||
/**
|
||||
* Set the disabled design
|
||||
*
|
||||
* @api
|
||||
* @param string|CheckBoxDesign $style Style name, image url or checkbox design
|
||||
* @param string $subStyle SubStyle name
|
||||
* @return static
|
||||
*/
|
||||
public function setDisabledDesign($style, $subStyle = null)
|
||||
{
|
||||
if ($style instanceof CheckBoxDesign) {
|
||||
$this->feature->setDisabledDesign($style);
|
||||
} else {
|
||||
$checkBoxDesign = new CheckBoxDesign($style, $subStyle);
|
||||
$this->feature->setDisabledDesign($checkBoxDesign);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $frame->render($domDocument);
|
||||
}
|
||||
/**
|
||||
* Get the CheckBox Quad
|
||||
*
|
||||
* @api
|
||||
* @return Quad
|
||||
*/
|
||||
public function getQuad()
|
||||
{
|
||||
$quad = $this->feature->getQuad();
|
||||
if ($quad) {
|
||||
return $quad;
|
||||
}
|
||||
return $this->createQuad();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CheckBox Quad
|
||||
*
|
||||
* @api
|
||||
* @param Quad $quad CheckBox Quad
|
||||
* @return static
|
||||
*/
|
||||
public function setQuad(Quad $quad)
|
||||
{
|
||||
$this->feature->setQuad($quad);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the CheckBox Quad
|
||||
*
|
||||
* @return Quad
|
||||
*/
|
||||
protected function createQuad()
|
||||
{
|
||||
$quad = new Quad();
|
||||
$quad->setSize(10, 10);
|
||||
$this->setQuad($quad);
|
||||
return $quad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hidden Entry
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public function getEntry()
|
||||
{
|
||||
$entry = $this->feature->getEntry();
|
||||
if ($entry) {
|
||||
return $entry;
|
||||
}
|
||||
return $this->createEntry();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the hidden Entry
|
||||
*
|
||||
* @param Entry $entry Hidden Entry
|
||||
* @return static
|
||||
*/
|
||||
public function setEntry(Entry $entry)
|
||||
{
|
||||
$this->feature->setEntry($entry);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the hidden Entry
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
protected function createEntry()
|
||||
{
|
||||
$entry = new Entry();
|
||||
$entry->setVisible(false)
|
||||
->setName($this->name);
|
||||
$this->setEntry($entry);
|
||||
return $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ScriptFeatureable::getScriptFeatures()
|
||||
*/
|
||||
public function getScriptFeatures()
|
||||
{
|
||||
return ScriptFeature::collect($this->feature, $this->getQuad(), $this->feature->getEntry());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$frame = new Frame();
|
||||
|
||||
$quad = $this->getQuad();
|
||||
$frame->addChild($quad);
|
||||
|
||||
$entry = $this->getEntry();
|
||||
$frame->addChild($entry);
|
||||
|
||||
return $frame->render($domDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the hidden Entry
|
||||
*
|
||||
* @return \FML\Controls\Entry
|
||||
*/
|
||||
protected function buildEntry() {
|
||||
$entry = new Entry();
|
||||
$entry->setVisible(false)->setName($this->name);
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
163
libs/FML/Components/CheckBoxDesign.php
Normal file
163
libs/FML/Components/CheckBoxDesign.php
Normal file
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Components;
|
||||
|
||||
use FML\Controls\Quad;
|
||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||
use FML\Types\Imageable;
|
||||
use FML\Types\Styleable;
|
||||
use FML\Types\SubStyleable;
|
||||
|
||||
/**
|
||||
* Class representing CheckBox Design
|
||||
*
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CheckBoxDesign implements Imageable, Styleable, SubStyleable
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string $style Style name
|
||||
*/
|
||||
protected $style = null;
|
||||
|
||||
/**
|
||||
* @var string $subStyle SubStyle name
|
||||
*/
|
||||
protected $subStyle = null;
|
||||
|
||||
/**
|
||||
* @var string $imageUrl Image url
|
||||
*/
|
||||
protected $imageUrl = null;
|
||||
|
||||
/**
|
||||
* Create the default Design
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function defaultDesign()
|
||||
{
|
||||
return new static(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_Check);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new CheckBox Design
|
||||
*
|
||||
* @api
|
||||
* @param string $style (optional) Style name or image url
|
||||
* @param string $subStyle (optional) SubStyle name
|
||||
*/
|
||||
public function __construct($style = null, $subStyle = null)
|
||||
{
|
||||
if ($subStyle) {
|
||||
$this->setStyles($style, $subStyle);
|
||||
} elseif ($style) {
|
||||
$this->setImageUrl($style);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Styleable::getStyle()
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Styleable::setStyle()
|
||||
*/
|
||||
public function setStyle($style)
|
||||
{
|
||||
$this->style = (string)$style;
|
||||
$this->url = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SubStyleable::getSubStyle()
|
||||
*/
|
||||
public function getSubStyle()
|
||||
{
|
||||
return $this->subStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SubStyleable::setSubStyle()
|
||||
*/
|
||||
public function setSubStyle($subStyle)
|
||||
{
|
||||
$this->subStyle = (string)$subStyle;
|
||||
$this->url = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SubStyleable::setStyles()
|
||||
*/
|
||||
public function setStyles($style, $subStyle)
|
||||
{
|
||||
return $this->setStyle($style)
|
||||
->setSubStyle($subStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the image url
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getImageUrl()
|
||||
{
|
||||
return $this->imageUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the image url
|
||||
*
|
||||
* @api
|
||||
* @param string $imageUrl Image url
|
||||
* @return static
|
||||
*/
|
||||
public function setImageUrl($imageUrl)
|
||||
{
|
||||
$this->style = null;
|
||||
$this->subStyle = null;
|
||||
$this->imageUrl = (string)$imageUrl;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Design to the given Quad
|
||||
*
|
||||
* @api
|
||||
* @param Quad $quad CheckBox Quad
|
||||
* @return static
|
||||
*/
|
||||
public function applyToQuad(Quad $quad)
|
||||
{
|
||||
if ($this->imageUrl) {
|
||||
$quad->setImageUrl($this->imageUrl);
|
||||
} elseif ($this->style) {
|
||||
$quad->setStyles($this->style, $this->subStyle);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CheckBox Design string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDesignString()
|
||||
{
|
||||
if ($this->imageUrl) {
|
||||
return $this->imageUrl;
|
||||
}
|
||||
return $this->style . "|" . $this->subStyle;
|
||||
}
|
||||
|
||||
}
|
@ -13,122 +13,224 @@ use FML\Types\ScriptFeatureable;
|
||||
/**
|
||||
* ValuePicker Component
|
||||
*
|
||||
* @uses Entry
|
||||
* @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 ValuePicker implements Renderable, ScriptFeatureable {
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $name = null;
|
||||
protected $feature = null;
|
||||
class ValuePicker implements Renderable, ScriptFeatureable
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new ValuePicker Component
|
||||
*
|
||||
* @param string $name (optional) CheckBox name
|
||||
* @param array $values (optional) Possible values
|
||||
* @param bool $default (optional) Default value
|
||||
* @param Label $label (optional) ValuePicker label
|
||||
*/
|
||||
public function __construct($name = null, array $values = array(), $default = null, Label $label = null) {
|
||||
$this->feature = new ValuePickerFeature();
|
||||
$this->setName($name);
|
||||
$this->setValues($values);
|
||||
$this->setDefault($default);
|
||||
$this->setLabel($label);
|
||||
}
|
||||
/**
|
||||
* @var string $name ValuePicker name
|
||||
*/
|
||||
protected $name = null;
|
||||
|
||||
/**
|
||||
* Set Name
|
||||
*
|
||||
* @param string $name ValuePicker name
|
||||
* @return static
|
||||
*/
|
||||
public function setName($name) {
|
||||
$this->name = (string)$name;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var ValuePickerFeature $feature ValuePicker Feature
|
||||
*/
|
||||
protected $feature = null;
|
||||
|
||||
/**
|
||||
* Set the possible values
|
||||
*
|
||||
* @param array $values Possible values
|
||||
* @return static
|
||||
*/
|
||||
public function setValues(array $values) {
|
||||
$this->feature->setValues($values);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Create a new ValuePicker
|
||||
*
|
||||
* @api
|
||||
* @param string $name (optional) ValuePicker name
|
||||
* @param string[] $values (optional) Possible values
|
||||
* @param string $default (optional) Default value
|
||||
* @param Label $label (optional) ValuePicker label
|
||||
*/
|
||||
public function __construct($name = null, array $values = null, $default = null, Label $label = null)
|
||||
{
|
||||
$this->feature = new ValuePickerFeature();
|
||||
if ($name) {
|
||||
$this->setName($name);
|
||||
}
|
||||
if ($values) {
|
||||
$this->setValues($values);
|
||||
}
|
||||
if ($default !== null) {
|
||||
$this->setDefault($default);
|
||||
}
|
||||
if ($label) {
|
||||
$this->setLabel($label);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default value
|
||||
*
|
||||
* @param bool $default Default value
|
||||
* @return static
|
||||
*/
|
||||
public function setDefault($default) {
|
||||
$this->feature->setDefault($default);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Get the name
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ValuePicker Label
|
||||
*
|
||||
* @param Label $label ValuePicker Label
|
||||
* @return static
|
||||
*/
|
||||
public function setLabel(Label $label = null) {
|
||||
$this->feature->setLabel($label);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set the name
|
||||
*
|
||||
* @api
|
||||
* @param string $name ValuePicker name
|
||||
* @return static
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = (string)$name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ValuePicker Label
|
||||
*
|
||||
* @param bool $createIfEmpty (optional) Create the Label if it's not set
|
||||
* @return \FML\Controls\Label
|
||||
*/
|
||||
public function getLabel($createIfEmpty = true) {
|
||||
if (!$this->feature->getLabel() && $createIfEmpty) {
|
||||
$label = new Label();
|
||||
$this->setLabel($label);
|
||||
}
|
||||
return $this->feature->getLabel();
|
||||
}
|
||||
/**
|
||||
* Get the possible values
|
||||
*
|
||||
* @api
|
||||
* @return string[]
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
return $this->feature->getValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\ScriptFeatureable::getScriptFeatures()
|
||||
*/
|
||||
public function getScriptFeatures() {
|
||||
return ScriptFeature::collect($this->feature, $this->getLabel(), $this->feature->getEntry());
|
||||
}
|
||||
/**
|
||||
* Set the possible values
|
||||
*
|
||||
* @api
|
||||
* @param array $values Possible values
|
||||
* @return static
|
||||
*/
|
||||
public function setValues(array $values)
|
||||
{
|
||||
$this->feature->setValues($values);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$frame = new Frame();
|
||||
/**
|
||||
* Get the default value
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getDefault()
|
||||
{
|
||||
return $this->feature->getDefault();
|
||||
}
|
||||
|
||||
$label = $this->getLabel();
|
||||
$frame->add($label);
|
||||
/**
|
||||
* Set the default value
|
||||
*
|
||||
* @api
|
||||
* @param bool $default Default value
|
||||
* @return static
|
||||
*/
|
||||
public function setDefault($default)
|
||||
{
|
||||
$this->feature->setDefault($default);
|
||||
return $this;
|
||||
}
|
||||
|
||||
$entry = $this->buildEntry();
|
||||
$frame->add($entry);
|
||||
$this->feature->setEntry($entry);
|
||||
/**
|
||||
* Get the Label
|
||||
*
|
||||
* @api
|
||||
* @return Label
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
$label = $this->feature->getLabel();
|
||||
if ($label) {
|
||||
return $label;
|
||||
}
|
||||
return $this->createLabel();
|
||||
}
|
||||
|
||||
return $frame->render($domDocument);
|
||||
}
|
||||
/**
|
||||
* Set the Label
|
||||
*
|
||||
* @api
|
||||
* @param Label $label ValuePicker Label
|
||||
* @return static
|
||||
*/
|
||||
public function setLabel(Label $label)
|
||||
{
|
||||
$this->feature->setLabel($label);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Label
|
||||
*
|
||||
* @return Label
|
||||
*/
|
||||
protected function createLabel()
|
||||
{
|
||||
$label = new Label();
|
||||
$this->setLabel($label);
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hidden Entry
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public function getEntry()
|
||||
{
|
||||
$entry = $this->feature->getEntry();
|
||||
if ($entry) {
|
||||
return $entry;
|
||||
}
|
||||
return $this->createEntry();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the hidden Entry
|
||||
*
|
||||
* @param Entry $entry Hidden Entry
|
||||
* @return static
|
||||
*/
|
||||
public function setEntry(Entry $entry)
|
||||
{
|
||||
$this->feature->setEntry($entry);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the hidden Entry
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
protected function createEntry()
|
||||
{
|
||||
$entry = new Entry();
|
||||
$entry->setVisible(false)
|
||||
->setName($this->name);
|
||||
$this->setEntry($entry);
|
||||
return $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ScriptFeatureable::getScriptFeatures()
|
||||
*/
|
||||
public function getScriptFeatures()
|
||||
{
|
||||
return ScriptFeature::collect($this->feature, $this->getLabel(), $this->feature->getEntry());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$frame = new Frame();
|
||||
|
||||
$label = $this->getLabel();
|
||||
$frame->addChild($label);
|
||||
|
||||
$entry = $this->getEntry();
|
||||
$frame->addChild($entry);
|
||||
|
||||
return $frame->render($domDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the hidden Entry
|
||||
*
|
||||
* @return \FML\Controls\Entry
|
||||
*/
|
||||
protected function buildEntry() {
|
||||
$entry = new Entry();
|
||||
$entry->setVisible(false)->setName($this->name);
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user