2013-11-25 00:02:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\Controls;
|
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
use FML\Types\NewLineable;
|
|
|
|
use FML\Types\Scriptable;
|
|
|
|
use FML\Types\Styleable;
|
|
|
|
use FML\Types\TextFormatable;
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
2014-01-19 19:30:21 +01:00
|
|
|
* Entry Control
|
2014-01-12 00:51:46 +01:00
|
|
|
* (CMlEntry)
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
|
|
|
* @author steeffeen
|
2014-04-13 18:21:40 +02:00
|
|
|
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable {
|
2014-01-21 20:30:40 +01:00
|
|
|
/*
|
2013-12-31 02:55:19 +01:00
|
|
|
* Protected Properties
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
protected $name = '';
|
|
|
|
protected $default = null;
|
2013-11-28 17:36:39 +01:00
|
|
|
protected $autoNewLine = 0;
|
|
|
|
protected $scriptEvents = 0;
|
|
|
|
protected $style = '';
|
|
|
|
protected $textColor = '';
|
|
|
|
protected $textSize = -1;
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $focusAreaColor1 = '';
|
|
|
|
protected $focusAreaColor2 = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new Entry Control
|
|
|
|
*
|
|
|
|
* @param string $id (optional) Control Id
|
|
|
|
* @return \FML\Controls\Entry
|
|
|
|
*/
|
|
|
|
public static function create($id = null) {
|
|
|
|
$entry = new Entry($id);
|
|
|
|
return $entry;
|
|
|
|
}
|
2013-11-25 00:02:07 +01:00
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Construct a new Entry 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 = 'entry';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Entry Name
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $name Entry Name
|
2013-11-25 00:02:07 +01:00
|
|
|
* @return \FML\Controls\Entry
|
|
|
|
*/
|
|
|
|
public function setName($name) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->name = (string) $name;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Default Value
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $default Default Value
|
2013-11-25 00:02:07 +01:00
|
|
|
* @return \FML\Controls\Entry
|
|
|
|
*/
|
|
|
|
public function setDefault($default) {
|
|
|
|
$this->default = $default;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\NewLineable::setAutoNewLine()
|
|
|
|
* @return \FML\Controls\Entry
|
|
|
|
*/
|
|
|
|
public function setAutoNewLine($autoNewLine) {
|
|
|
|
$this->autoNewLine = ($autoNewLine ? 1 : 0);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Scriptable::setScriptEvents()
|
|
|
|
* @return \FML\Controls\Entry
|
|
|
|
*/
|
|
|
|
public function setScriptEvents($scriptEvents) {
|
|
|
|
$this->scriptEvents = ($scriptEvents ? 1 : 0);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Styleable::setStyle()
|
|
|
|
* @return \FML\Controls\Entry
|
|
|
|
*/
|
|
|
|
public function setStyle($style) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->style = (string) $style;
|
2013-11-28 17:36:39 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\TextFormatable::setTextColor()
|
|
|
|
* @return \FML\Controls\Entry
|
|
|
|
*/
|
|
|
|
public function setTextColor($textColor) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->textColor = (string) $textColor;
|
2013-11-28 17:36:39 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\TextFormatable::setTextSize()
|
|
|
|
* @return \FML\Controls\Entry
|
|
|
|
*/
|
|
|
|
public function setTextSize($textSize) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->textSize = (int) $textSize;
|
2013-11-28 17:36:39 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\TextFormatable::setAreaColor()
|
|
|
|
* @return \FML\Controls\Entry
|
|
|
|
*/
|
|
|
|
public function setAreaColor($areaColor) {
|
2014-01-19 19:30:21 +01:00
|
|
|
$this->focusAreaColor1 = (string) $areaColor;
|
2013-11-28 17:36:39 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\TextFormatable::setAreaFocusColor()
|
|
|
|
* @return \FML\Controls\Entry
|
|
|
|
*/
|
|
|
|
public function setAreaFocusColor($areaFocusColor) {
|
2014-01-19 19:30:21 +01:00
|
|
|
$this->focusAreaColor2 = (string) $areaFocusColor;
|
2013-11-28 17:36:39 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @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->name) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('name', $this->name);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->default !== null) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('default', $this->default);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
2013-11-28 17:36:39 +01:00
|
|
|
if ($this->autoNewLine) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('autonewline', $this->autoNewLine);
|
2013-11-28 17:36:39 +01:00
|
|
|
}
|
|
|
|
if ($this->scriptEvents) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
|
2013-11-28 17:36:39 +01:00
|
|
|
}
|
|
|
|
if ($this->style) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('style', $this->style);
|
2013-11-28 17:36:39 +01:00
|
|
|
}
|
|
|
|
if ($this->textColor) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('textcolor', $this->textColor);
|
2013-11-28 17:36:39 +01:00
|
|
|
}
|
|
|
|
if ($this->textSize >= 0.) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('textsize', $this->textSize);
|
2013-11-28 17:36:39 +01:00
|
|
|
}
|
2014-01-19 19:30:21 +01:00
|
|
|
if ($this->focusAreaColor1) {
|
|
|
|
$xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1);
|
2013-11-28 17:36:39 +01:00
|
|
|
}
|
2014-01-19 19:30:21 +01:00
|
|
|
if ($this->focusAreaColor2) {
|
|
|
|
$xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2);
|
2013-11-28 17:36:39 +01:00
|
|
|
}
|
2014-01-12 00:51:46 +01:00
|
|
|
return $xmlElement;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
}
|