2013-11-25 00:02:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\Controls;
|
|
|
|
|
2013-11-28 02:04:06 +01:00
|
|
|
use FML\Types\Actionable;
|
2013-11-25 00:02:07 +01:00
|
|
|
use FML\Types\Linkable;
|
|
|
|
use FML\Types\NewLineable;
|
|
|
|
use FML\Types\Scriptable;
|
|
|
|
use FML\Types\Styleable;
|
|
|
|
use FML\Types\TextFormatable;
|
|
|
|
|
|
|
|
/**
|
2014-01-19 19:30:21 +01:00
|
|
|
* Label Control
|
2014-01-12 00:51:46 +01:00
|
|
|
* (CMlLabel)
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
|
|
|
* @author steeffeen
|
|
|
|
*/
|
2013-11-28 02:04:06 +01:00
|
|
|
class Label extends Control implements Actionable, Linkable, NewLineable, Scriptable, Styleable, TextFormatable {
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Protected Properties
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
protected $text = '';
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $textId = '';
|
2013-11-25 00:02:07 +01:00
|
|
|
protected $textPrefix = '';
|
|
|
|
protected $textEmboss = 0;
|
2013-11-28 01:12:52 +01:00
|
|
|
protected $translate = 0;
|
2014-01-12 00:51:46 +01:00
|
|
|
protected $maxLines = -1;
|
2013-11-28 02:04:06 +01:00
|
|
|
protected $action = '';
|
2014-01-12 00:51:46 +01:00
|
|
|
protected $actionKey = -1;
|
2013-11-25 00:02:07 +01:00
|
|
|
protected $url = '';
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $urlId = '';
|
2013-11-25 00:02:07 +01:00
|
|
|
protected $manialink = '';
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $manialinkId = '';
|
2013-11-25 00:02:07 +01:00
|
|
|
protected $autoNewLine = 0;
|
|
|
|
protected $scriptEvents = 0;
|
|
|
|
protected $style = '';
|
|
|
|
protected $textSize = -1;
|
|
|
|
protected $textColor = '';
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $focusAreaColor1 = '';
|
|
|
|
protected $focusAreaColor2 = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new Label Control
|
|
|
|
*
|
|
|
|
* @param string $id (optional) Control Id
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public static function create($id = null) {
|
|
|
|
$label = new Label($id);
|
|
|
|
return $label;
|
|
|
|
}
|
2013-11-25 00:02:07 +01:00
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Construct a new Label Control
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $id (optional) Control Id
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function __construct($id = null) {
|
|
|
|
parent::__construct($id);
|
|
|
|
$this->tagName = 'label';
|
|
|
|
$this->setZ(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Text
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $text Text Value
|
2013-11-25 00:02:07 +01:00
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setText($text) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->text = (string) $text;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
|
|
|
* Set Text Id to use from the Dico
|
|
|
|
*
|
|
|
|
* @param string $textId Text Id
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setTextId($textId) {
|
|
|
|
$this->textId = (string) $textId;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Text Prefix
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $textPrefix Text Prefix
|
2013-11-25 00:02:07 +01:00
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setTextPrefix($textPrefix) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->textPrefix = (string) $textPrefix;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Text Emboss
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param bool $textEmboss Whether Text should be embossed
|
2013-11-25 00:02:07 +01:00
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setTextEmboss($textEmboss) {
|
|
|
|
$this->textEmboss = ($textEmboss ? 1 : 0);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-28 01:12:52 +01:00
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Translate
|
2013-11-28 02:04:06 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param bool $translate Whether Text should be translated
|
2013-11-28 01:12:52 +01:00
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setTranslate($translate) {
|
|
|
|
$this->translate = ($translate ? 1 : 0);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Max Lines Count
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param int $maxLines Max Lines Count
|
2013-11-25 00:02:07 +01:00
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setMaxLines($maxLines) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->maxLines = (int) $maxLines;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-28 02:04:06 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Actionable::setAction()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setAction($action) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->action = (string) $action;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Actionable::setActionKey()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setActionKey($actionKey) {
|
|
|
|
$this->actionKey = (int) $actionKey;
|
2013-11-28 02:04:06 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Linkable::setUrl()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setUrl($url) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->url = (string) $url;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Linkable::setUrlId()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setUrlId($urlId) {
|
|
|
|
$this->urlId = (string) $urlId;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Linkable::setManialink()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setManialink($manialink) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->manialink = (string) $manialink;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Linkable::setManialinkId()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setManialinkId($manialinkId) {
|
|
|
|
$this->manialinkId = (string) $manialinkId;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\NewLineable::setAutoNewLine()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setAutoNewLine($autoNewLine) {
|
|
|
|
$this->autoNewLine = ($autoNewLine ? 1 : 0);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Scriptable::setScriptEvents()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setScriptEvents($scriptEvents) {
|
|
|
|
$this->scriptEvents = ($scriptEvents ? 1 : 0);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Styleable::setStyle()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setStyle($style) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->style = (string) $style;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\TextFormatable::setTextSize()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setTextSize($textSize) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->textSize = (int) $textSize;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\TextFormatable::setTextColor()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setTextColor($textColor) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->textColor = (string) $textColor;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\TextFormatable::setAreaColor()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setAreaColor($areaColor) {
|
2014-01-19 19:30:21 +01:00
|
|
|
$this->focusAreaColor1 = (string) $areaColor;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\TextFormatable::setAreaFocusColor()
|
|
|
|
* @return \FML\Controls\Label
|
|
|
|
*/
|
|
|
|
public function setAreaFocusColor($areaFocusColor) {
|
2014-01-19 19:30:21 +01:00
|
|
|
$this->focusAreaColor2 = (string) $areaFocusColor;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Control::render()
|
|
|
|
*/
|
|
|
|
public function render(\DOMDocument $domDocument) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement = parent::render($domDocument);
|
2013-11-25 00:02:07 +01:00
|
|
|
if ($this->text) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('text', $this->text);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
2014-01-19 19:30:21 +01:00
|
|
|
if ($this->textId) {
|
|
|
|
$xmlElement->setAttribute('textid', $this->textId);
|
|
|
|
}
|
2013-11-25 00:02:07 +01:00
|
|
|
if ($this->textPrefix) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('textprefix', $this->textPrefix);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->textEmboss) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('textemboss', $this->textEmboss);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
2013-11-28 01:12:52 +01:00
|
|
|
if ($this->translate) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('translate', $this->translate);
|
2013-11-28 01:12:52 +01:00
|
|
|
}
|
2014-01-12 00:51:46 +01:00
|
|
|
if ($this->maxLines >= 0) {
|
|
|
|
$xmlElement->setAttribute('maxlines', $this->maxLines);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
2013-11-28 02:04:06 +01:00
|
|
|
if ($this->action) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('action', $this->action);
|
|
|
|
}
|
|
|
|
if ($this->actionKey >= 0) {
|
|
|
|
$xmlElement->setAttribute('actionkey', $this->actionKey);
|
2013-11-28 02:04:06 +01:00
|
|
|
}
|
2013-11-25 00:02:07 +01:00
|
|
|
if ($this->url) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('url', $this->url);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->manialink) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('manialink', $this->manialink);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->autoNewLine) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('autonewline', $this->autoNewLine);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->scriptEvents) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->style) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('style', $this->style);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->textSize >= 0) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('textsize', $this->textSize);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->textColor) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('textcolor', $this->textColor);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
2014-01-19 19:30:21 +01:00
|
|
|
if ($this->focusAreaColor1) {
|
|
|
|
$xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
2014-01-19 19:30:21 +01:00
|
|
|
if ($this->focusAreaColor2) {
|
|
|
|
$xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
2014-01-12 00:51:46 +01:00
|
|
|
return $xmlElement;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
}
|