Updated to ManiaLink v3
This commit is contained in:
@ -6,261 +6,276 @@ namespace FML\Elements;
|
||||
* Dictionary Element
|
||||
*
|
||||
* @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 Dico {
|
||||
/**
|
||||
* Czech language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_CZECH = 'cz';
|
||||
class Dico
|
||||
{
|
||||
|
||||
/**
|
||||
* Danish language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_DANISH = 'da';
|
||||
/**
|
||||
* Czech language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_CZECH = 'cz';
|
||||
|
||||
/**
|
||||
* German language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_GERMAN = 'de';
|
||||
/**
|
||||
* Danish language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_DANISH = 'da';
|
||||
|
||||
/**
|
||||
* English language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_ENGLISH = 'en';
|
||||
/**
|
||||
* German language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_GERMAN = 'de';
|
||||
|
||||
/**
|
||||
* Spanish language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_SPANISH = 'es';
|
||||
/**
|
||||
* English language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_ENGLISH = 'en';
|
||||
|
||||
/**
|
||||
* French language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_FRENCH = 'fr';
|
||||
/**
|
||||
* Spanish language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_SPANISH = 'es';
|
||||
|
||||
/**
|
||||
* Hungarian language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_HUNGARIAN = 'hu';
|
||||
/**
|
||||
* French language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_FRENCH = 'fr';
|
||||
|
||||
/**
|
||||
* Italian language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_ITALIAN = 'it';
|
||||
/**
|
||||
* Hungarian language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_HUNGARIAN = 'hu';
|
||||
|
||||
/**
|
||||
* Japanese language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_JAPANESE = 'jp';
|
||||
/**
|
||||
* Italian language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_ITALIAN = 'it';
|
||||
|
||||
/**
|
||||
* Korean language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_KOREAN = 'kr';
|
||||
/**
|
||||
* Japanese language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_JAPANESE = 'jp';
|
||||
|
||||
/**
|
||||
* Norwegian language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_NORWEGIAN = 'nb';
|
||||
/**
|
||||
* Korean language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_KOREAN = 'kr';
|
||||
|
||||
/**
|
||||
* Dutch language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_DUTCH = 'nl';
|
||||
/**
|
||||
* Norwegian language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_NORWEGIAN = 'nb';
|
||||
|
||||
/**
|
||||
* Polish language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_POLISH = 'pl';
|
||||
/**
|
||||
* Dutch language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_DUTCH = 'nl';
|
||||
|
||||
/**
|
||||
* Portuguese language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_PORTUGUESE = 'pt';
|
||||
/**
|
||||
* Polish language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_POLISH = 'pl';
|
||||
|
||||
/**
|
||||
* Brazilian Portuguese language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_BRAZILIAN_PORTUGUESE = 'pt_BR';
|
||||
/**
|
||||
* Portuguese language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_PORTUGUESE = 'pt';
|
||||
|
||||
/**
|
||||
* Romanian language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_ROMANIAN = 'ro';
|
||||
/**
|
||||
* Brazilian Portuguese language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_BRAZILIAN_PORTUGUESE = 'pt_BR';
|
||||
|
||||
/**
|
||||
* Russian language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_RUSSIAN = 'ru';
|
||||
/**
|
||||
* Romanian language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_ROMANIAN = 'ro';
|
||||
|
||||
/**
|
||||
* Slovak language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_SLOVAK = 'sk';
|
||||
/**
|
||||
* Russian language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_RUSSIAN = 'ru';
|
||||
|
||||
/**
|
||||
* Turkish language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_TURKISH = 'tr';
|
||||
/**
|
||||
* Slovak language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_SLOVAK = 'sk';
|
||||
|
||||
/**
|
||||
* Chinese language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_CHINESE = 'zh';
|
||||
/**
|
||||
* Turkish language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_TURKISH = 'tr';
|
||||
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $tagName = 'dico';
|
||||
protected $entries = array();
|
||||
/**
|
||||
* Chinese language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_CHINESE = 'zh';
|
||||
|
||||
/**
|
||||
* Create a new Dictionary object
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create() {
|
||||
return new static();
|
||||
}
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $entries = array();
|
||||
|
||||
/**
|
||||
* Set the translatable entry for the specific language
|
||||
*
|
||||
* @param string $language Language id
|
||||
* @param string $entryId Entry id
|
||||
* @param string $entryValue Translated entry value
|
||||
* @return static
|
||||
*/
|
||||
public function setEntry($language, $entryId, $entryValue) {
|
||||
$language = (string)$language;
|
||||
$entryId = (string)$entryId;
|
||||
$entryValue = (string)$entryValue;
|
||||
if (!isset($this->entries[$language]) && $entryValue) {
|
||||
$this->entries[$language] = array();
|
||||
}
|
||||
if ($entryValue) {
|
||||
$this->entries[$language][$entryId] = $entryValue;
|
||||
} else {
|
||||
if (isset($this->entries[$language][$entryId])) {
|
||||
unset($this->entries[$language][$entryId]);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Create a new Dico
|
||||
*
|
||||
* @api
|
||||
* @return static
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
return new static();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove entries of the given id
|
||||
*
|
||||
* @param string $entryId Entry id that should be removed
|
||||
* @param string $language (optional) Only remove entries of the given language
|
||||
* @return static
|
||||
*/
|
||||
public function removeEntry($entryId, $language = null) {
|
||||
$entryId = (string)$entryId;
|
||||
if ($language) {
|
||||
$language = (string)$language;
|
||||
if (isset($this->entries[$language])) {
|
||||
unset($this->entries[$language][$entryId]);
|
||||
}
|
||||
} else {
|
||||
foreach ($this->entries as $language => $entries) {
|
||||
if (isset($entries[$entryId])) {
|
||||
unset($entries[$language][$entryId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Get the translatable entry
|
||||
*
|
||||
* @api
|
||||
* @param string $language Language id
|
||||
* @param string $entryId Entry id
|
||||
* @return string
|
||||
*/
|
||||
public function getEntry($language, $entryId)
|
||||
{
|
||||
if (isset($this->entries[$language]) && isset($this->entries[$language][$entryId])) {
|
||||
return $this->entries[$language][$entryId];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove entries of the given language
|
||||
*
|
||||
* @param string $language Language which entries should be removed
|
||||
* @param string $entryId (optional) Only remove the given entry id
|
||||
* @return static
|
||||
*/
|
||||
public function removeLanguage($language, $entryId = null) {
|
||||
$language = (string)$language;
|
||||
if (isset($this->entries[$language])) {
|
||||
if ($entryId) {
|
||||
$entryId = (string)$entryId;
|
||||
unset($this->entries[$language][$entryId]);
|
||||
} else {
|
||||
unset($this->entries[$language]);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set the translatable entry for the specific language
|
||||
*
|
||||
* @api
|
||||
* @param string $language Language id
|
||||
* @param string $entryId Entry id
|
||||
* @param string $entryValue Translated entry value
|
||||
* @return static
|
||||
*/
|
||||
public function setEntry($language, $entryId, $entryValue)
|
||||
{
|
||||
$language = (string)$language;
|
||||
$entryId = (string)$entryId;
|
||||
$entryValue = (string)$entryValue;
|
||||
if (!isset($this->entries[$language]) && $entryValue) {
|
||||
$this->entries[$language] = array();
|
||||
}
|
||||
if ($entryValue) {
|
||||
$this->entries[$language][$entryId] = $entryValue;
|
||||
} else {
|
||||
if (isset($this->entries[$language][$entryId])) {
|
||||
unset($this->entries[$language][$entryId]);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all entries from the Dictionary
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function removeEntries() {
|
||||
$this->entries = array();
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Remove entries of the given id
|
||||
*
|
||||
* @api
|
||||
* @param string $entryId Entry id that should be removed
|
||||
* @return static
|
||||
*/
|
||||
public function removeEntry($entryId)
|
||||
{
|
||||
$entryId = (string)$entryId;
|
||||
foreach ($this->entries as $language => $entries) {
|
||||
if (isset($this->entries[$language][$entryId])) {
|
||||
unset($this->entries[$language][$entryId]);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove entries of the given language
|
||||
*
|
||||
* @api
|
||||
* @param string $language Language which entries should be removed
|
||||
* @return static
|
||||
*/
|
||||
public function removeLanguage($language)
|
||||
{
|
||||
$language = (string)$language;
|
||||
if (isset($this->entries[$language])) {
|
||||
unset($this->entries[$language]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all entries
|
||||
*
|
||||
* @api
|
||||
* @return static
|
||||
*/
|
||||
public function removeAllEntries()
|
||||
{
|
||||
$this->entries = array();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Dico
|
||||
*
|
||||
* @param \DOMDocument $domDocument DOMDocument for which the Dico should be rendered
|
||||
* @return \DOMElement
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$domElement = $domDocument->createElement("dico");
|
||||
foreach ($this->entries as $language => $entries) {
|
||||
$languageElement = $domDocument->createElement("language");
|
||||
$languageElement->setAttribute("id", $language);
|
||||
foreach ($entries as $entryId => $entryValue) {
|
||||
$entryElement = $domDocument->createElement($entryId, $entryValue);
|
||||
$languageElement->appendChild($entryElement);
|
||||
}
|
||||
$domElement->appendChild($languageElement);
|
||||
}
|
||||
return $domElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Dico XML element
|
||||
*
|
||||
* @param \DOMDocument $domDocument DOMDocument for which the Dico XML element should be rendered
|
||||
* @return \DOMElement
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$xmlElement = $domDocument->createElement($this->tagName);
|
||||
foreach ($this->entries as $language => $entries) {
|
||||
$languageElement = $domDocument->createElement('language');
|
||||
$languageElement->setAttribute('id', $language);
|
||||
foreach ($entries as $entryId => $entryValue) {
|
||||
$entryElement = $domDocument->createElement($entryId, $entryValue);
|
||||
$languageElement->appendChild($entryElement);
|
||||
}
|
||||
$xmlElement->appendChild($languageElement);
|
||||
}
|
||||
return $xmlElement;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace FML\Elements;
|
||||
|
||||
use FML\Types\BgColorable;
|
||||
use FML\Types\BackgroundColorable;
|
||||
use FML\Types\Renderable;
|
||||
use FML\Types\Styleable;
|
||||
use FML\Types\TextFormatable;
|
||||
@ -11,113 +11,205 @@ use FML\Types\TextFormatable;
|
||||
* Format Element
|
||||
*
|
||||
* @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 Format implements BgColorable, Renderable, Styleable, TextFormatable {
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $tagName = 'format';
|
||||
protected $bgColor = null;
|
||||
protected $style = null;
|
||||
protected $textSize = -1;
|
||||
protected $textFont = null;
|
||||
protected $textColor = null;
|
||||
protected $focusAreaColor1 = null;
|
||||
protected $focusAreaColor2 = null;
|
||||
class Format implements BackgroundColorable, Renderable, Styleable, TextFormatable
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new Format Element
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create() {
|
||||
return new static();
|
||||
}
|
||||
/**
|
||||
* @var string $backgroundColor Background color
|
||||
*/
|
||||
protected $backgroundColor = null;
|
||||
|
||||
/**
|
||||
* @see \FML\Types\BgColorable::setBgColor()
|
||||
*/
|
||||
public function setBgColor($bgColor) {
|
||||
$this->bgColor = (string)$bgColor;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var string $style Style
|
||||
*/
|
||||
protected $style = null;
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Styleable::setStyle()
|
||||
*/
|
||||
public function setStyle($style) {
|
||||
$this->style = (string)$style;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var int $textSize Text size
|
||||
*/
|
||||
protected $textSize = null;
|
||||
|
||||
/**
|
||||
* @see \FML\Types\TextFormatable::setTextSize()
|
||||
*/
|
||||
public function setTextSize($textSize) {
|
||||
$this->textSize = (int)$textSize;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var string $textFont Text font
|
||||
*/
|
||||
protected $textFont = null;
|
||||
|
||||
/**
|
||||
* @see \FML\Types\TextFormatable::setTextFont()
|
||||
*/
|
||||
public function setTextFont($textFont) {
|
||||
$this->textFont = (string)$textFont;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var string $textColor Text color
|
||||
*/
|
||||
protected $textColor = null;
|
||||
|
||||
/**
|
||||
* @see \FML\Types\TextFormatable::setTextColor()
|
||||
*/
|
||||
public function setTextColor($textColor) {
|
||||
$this->textColor = (string)$textColor;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var string $areaColor Area color
|
||||
*/
|
||||
protected $areaColor = null;
|
||||
|
||||
/**
|
||||
* @see \FML\Types\TextFormatable::setAreaColor()
|
||||
*/
|
||||
public function setAreaColor($areaColor) {
|
||||
$this->focusAreaColor1 = (string)$areaColor;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var string $focusAreaColor Focus area color
|
||||
*/
|
||||
protected $focusAreaColor = null;
|
||||
|
||||
/**
|
||||
* @see \FML\Types\TextFormatable::setAreaFocusColor()
|
||||
*/
|
||||
public function setAreaFocusColor($areaFocusColor) {
|
||||
$this->focusAreaColor2 = (string)$areaFocusColor;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Create a new Format
|
||||
*
|
||||
* @api
|
||||
* @return static
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
return new static();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see BgColorable::getBackgroundColor()
|
||||
*/
|
||||
public function getBackgroundColor()
|
||||
{
|
||||
return $this->backgroundColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see BgColorable::setBackgroundColor()
|
||||
*/
|
||||
public function setBackgroundColor($backgroundColor)
|
||||
{
|
||||
$this->backgroundColor = (string)$backgroundColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Styleable::getStyle()
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Styleable::setStyle()
|
||||
*/
|
||||
public function setStyle($style)
|
||||
{
|
||||
$this->style = (string)$style;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextFormatable::getTextSize()
|
||||
*/
|
||||
public function getTextSize()
|
||||
{
|
||||
return $this->textSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextFormatable::setTextSize()
|
||||
*/
|
||||
public function setTextSize($textSize)
|
||||
{
|
||||
$this->textSize = (int)$textSize;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextFormatable::getTextFont()
|
||||
*/
|
||||
public function getTextFont()
|
||||
{
|
||||
return $this->textFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextFormatable::setTextFont()
|
||||
*/
|
||||
public function setTextFont($textFont)
|
||||
{
|
||||
$this->textFont = (string)$textFont;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextFormatable::getTextColor()
|
||||
*/
|
||||
public function getTextColor()
|
||||
{
|
||||
return $this->textColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextFormatable::setTextColor()
|
||||
*/
|
||||
public function setTextColor($textColor)
|
||||
{
|
||||
$this->textColor = (string)$textColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextFormatable::getAreaColor()
|
||||
*/
|
||||
public function getAreaColor()
|
||||
{
|
||||
return $this->areaColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextFormatable::setAreaColor()
|
||||
*/
|
||||
public function setAreaColor($areaColor)
|
||||
{
|
||||
$this->areaColor = (string)$areaColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextFormatable::getAreaFocusColor()
|
||||
*/
|
||||
public function getAreaFocusColor()
|
||||
{
|
||||
return $this->focusAreaColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextFormatable::setAreaFocusColor()
|
||||
*/
|
||||
public function setAreaFocusColor($areaFocusColor)
|
||||
{
|
||||
$this->focusAreaColor = (string)$areaFocusColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$domElement = $domDocument->createElement("format");
|
||||
if ($this->backgroundColor) {
|
||||
$domElement->setAttribute("bgcolor", $this->backgroundColor);
|
||||
}
|
||||
if ($this->style) {
|
||||
$domElement->setAttribute("style", $this->style);
|
||||
}
|
||||
if ($this->textSize) {
|
||||
$domElement->setAttribute("textsize", $this->textSize);
|
||||
}
|
||||
if ($this->textFont) {
|
||||
$domElement->setAttribute("textfont", $this->textFont);
|
||||
}
|
||||
if ($this->textColor) {
|
||||
$domElement->setAttribute("textcolor", $this->textColor);
|
||||
}
|
||||
if ($this->areaColor) {
|
||||
$domElement->setAttribute("focusareacolor1", $this->areaColor);
|
||||
}
|
||||
if ($this->focusAreaColor) {
|
||||
$domElement->setAttribute("focusareacolor2", $this->focusAreaColor);
|
||||
}
|
||||
return $domElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$formatXmlElement = $domDocument->createElement($this->tagName);
|
||||
if ($this->bgColor) {
|
||||
$formatXmlElement->setAttribute('bgcolor', $this->bgColor);
|
||||
}
|
||||
if ($this->style) {
|
||||
$formatXmlElement->setAttribute('style', $this->style);
|
||||
}
|
||||
if ($this->textSize >= 0) {
|
||||
$formatXmlElement->setAttribute('textsize', $this->textSize);
|
||||
}
|
||||
if ($this->textFont) {
|
||||
$formatXmlElement->setAttribute('textfont', $this->textFont);
|
||||
}
|
||||
if ($this->textColor) {
|
||||
$formatXmlElement->setAttribute('textcolor', $this->textColor);
|
||||
}
|
||||
if ($this->focusAreaColor1) {
|
||||
$formatXmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1);
|
||||
}
|
||||
if ($this->focusAreaColor2) {
|
||||
$formatXmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2);
|
||||
}
|
||||
return $formatXmlElement;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace FML\Elements;
|
||||
|
||||
use FML\Types\Container;
|
||||
use FML\Types\Identifiable;
|
||||
use FML\Types\Renderable;
|
||||
use FML\UniqueID;
|
||||
|
||||
@ -10,103 +11,172 @@ use FML\UniqueID;
|
||||
* Class representing a Frame Model
|
||||
*
|
||||
* @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 FrameModel implements Container, Renderable {
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $tagName = 'framemodel';
|
||||
protected $modelId = null;
|
||||
/** @var Renderable[] $children */
|
||||
protected $children = array();
|
||||
/** @var Format $format */
|
||||
protected $format = null;
|
||||
class FrameModel implements Container, Identifiable, Renderable
|
||||
{
|
||||
|
||||
/**
|
||||
* Set Model id
|
||||
*
|
||||
* @param string $modelId Model id
|
||||
* @return static
|
||||
*/
|
||||
public function setId($modelId) {
|
||||
$this->modelId = (string)$modelId;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var string $modelId Model id
|
||||
*/
|
||||
protected $modelId = null;
|
||||
|
||||
/**
|
||||
* Get Model id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId() {
|
||||
return $this->modelId;
|
||||
}
|
||||
/**
|
||||
* @var Renderable[] $children Children
|
||||
*/
|
||||
protected $children = array();
|
||||
|
||||
/**
|
||||
* Assign an id if necessary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function checkId() {
|
||||
if (!$this->modelId) {
|
||||
$this->setId(UniqueID::create());
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var Format $format Format
|
||||
*/
|
||||
protected $format = null;
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::add()
|
||||
*/
|
||||
public function add(Renderable $childElement) {
|
||||
if (!in_array($childElement, $this->children, true)) {
|
||||
array_push($this->children, $childElement);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Create a new Frame Model
|
||||
*
|
||||
* @api
|
||||
* @param string $modelId Model id
|
||||
* @param Renderable[] $children Children
|
||||
* @return static
|
||||
*/
|
||||
public static function create($modelId = null, array $children = null)
|
||||
{
|
||||
return new static($modelId, $children);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::removeChildren()
|
||||
*/
|
||||
public function removeChildren() {
|
||||
$this->children = array();
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Construct a new Frame Model
|
||||
*
|
||||
* @api
|
||||
* @param string $modelId Model id
|
||||
* @param Renderable[] $children Children
|
||||
*/
|
||||
public function __construct($modelId = null, array $children = null)
|
||||
{
|
||||
if ($modelId) {
|
||||
$this->setId($modelId);
|
||||
}
|
||||
if ($children) {
|
||||
$this->addChildren($children);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::setFormat()
|
||||
*/
|
||||
public function setFormat(Format $format) {
|
||||
$this->format = $format;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @see Identifiable::getId()
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (!$this->modelId) {
|
||||
return $this->createId();
|
||||
}
|
||||
return $this->modelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::getFormat()
|
||||
*/
|
||||
public function getFormat($createIfEmpty = true) {
|
||||
if (!$this->format && $createIfEmpty) {
|
||||
$this->setFormat(new Format());
|
||||
}
|
||||
return $this->format;
|
||||
}
|
||||
/**
|
||||
* @see Identifiable::setId()
|
||||
*/
|
||||
public function setId($modelId)
|
||||
{
|
||||
$this->modelId = (string)$modelId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Identifiable::checkId()
|
||||
*/
|
||||
public function checkId()
|
||||
{
|
||||
return UniqueID::check($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new model id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createId()
|
||||
{
|
||||
$modelId = UniqueID::create();
|
||||
$this->setId($modelId);
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Container::getChildren()
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Container::addChild()
|
||||
*/
|
||||
public function addChild(Renderable $childElement)
|
||||
{
|
||||
if (!in_array($childElement, $this->children, true)) {
|
||||
array_push($this->children, $childElement);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Container::addChildren()
|
||||
*/
|
||||
public function addChildren(array $children)
|
||||
{
|
||||
foreach ($children as $child) {
|
||||
$this->addChild($child);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Container::removeAllChildren()
|
||||
*/
|
||||
public function removeAllChildren()
|
||||
{
|
||||
$this->children = array();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Container::getFormat()
|
||||
*/
|
||||
public function getFormat()
|
||||
{
|
||||
return $this->format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Container::setFormat()
|
||||
*/
|
||||
public function setFormat(Format $format = null)
|
||||
{
|
||||
$this->format = $format;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$domElement = $domDocument->createElement("framemodel");
|
||||
$domElement->setAttribute("id", $this->getId());
|
||||
|
||||
if ($this->format) {
|
||||
$formatElement = $this->format->render($domDocument);
|
||||
$domElement->appendChild($formatElement);
|
||||
}
|
||||
|
||||
foreach ($this->children as $child) {
|
||||
$childElement = $child->render($domDocument);
|
||||
$domElement->appendChild($childElement);
|
||||
}
|
||||
|
||||
return $domElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$xmlElement = $domDocument->createElement($this->tagName);
|
||||
$this->checkId();
|
||||
$xmlElement->setAttribute('id', $this->getId());
|
||||
if ($this->format) {
|
||||
$formatXml = $this->format->render($domDocument);
|
||||
$xmlElement->appendChild($formatXml);
|
||||
}
|
||||
foreach ($this->children as $child) {
|
||||
$childElement = $child->render($domDocument);
|
||||
$xmlElement->appendChild($childElement);
|
||||
}
|
||||
return $xmlElement;
|
||||
}
|
||||
}
|
||||
|
@ -8,56 +8,76 @@ use FML\Types\Renderable;
|
||||
* Include Element
|
||||
*
|
||||
* @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 Including implements Renderable {
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $tagName = 'include';
|
||||
protected $url = null;
|
||||
class Including implements Renderable
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new Include object
|
||||
*
|
||||
* @param string $url (optional) Include url
|
||||
* @return static
|
||||
*/
|
||||
public static function create($url = null) {
|
||||
return new static($url);
|
||||
}
|
||||
/**
|
||||
* @var string $url Include url
|
||||
*/
|
||||
protected $url = null;
|
||||
|
||||
/**
|
||||
* Construct a new Include object
|
||||
*
|
||||
* @param string $url (optional) Include url
|
||||
*/
|
||||
public function __construct($url = null) {
|
||||
if ($url !== null) {
|
||||
$this->setUrl($url);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a new Include
|
||||
*
|
||||
* @api
|
||||
* @param string $url (optional) Include url
|
||||
* @return static
|
||||
*/
|
||||
public static function create($url = null)
|
||||
{
|
||||
return new static($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set url
|
||||
*
|
||||
* @param string $url Include url
|
||||
* @return static
|
||||
*/
|
||||
public function setUrl($url) {
|
||||
$this->url = (string)$url;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Construct a new Include
|
||||
*
|
||||
* @api
|
||||
* @param string $url (optional) Include url
|
||||
*/
|
||||
public function __construct($url = null)
|
||||
{
|
||||
if ($url) {
|
||||
$this->setUrl($url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the url
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the url
|
||||
*
|
||||
* @api
|
||||
* @param string $url Include url
|
||||
* @return static
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = (string)$url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$domElement = $domDocument->createElement("include");
|
||||
if ($this->url) {
|
||||
$domElement->setAttribute("url", $this->url);
|
||||
}
|
||||
return $domElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$xmlElement = $domDocument->createElement($this->tagName);
|
||||
if ($this->url) {
|
||||
$xmlElement->setAttribute('url', $this->url);
|
||||
}
|
||||
return $xmlElement;
|
||||
}
|
||||
}
|
||||
|
@ -8,56 +8,76 @@ use FML\Types\Renderable;
|
||||
* Music Element
|
||||
*
|
||||
* @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 Music implements Renderable {
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $tagName = 'music';
|
||||
protected $data = null;
|
||||
class Music implements Renderable
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new Music object
|
||||
*
|
||||
* @param string $data (optional) Media url
|
||||
* @return static
|
||||
*/
|
||||
public static function create($data = null) {
|
||||
return new static($data);
|
||||
}
|
||||
/**
|
||||
* @var string $data Media url
|
||||
*/
|
||||
protected $data = null;
|
||||
|
||||
/**
|
||||
* Construct a new Music object
|
||||
*
|
||||
* @param string $data (optional) Media url
|
||||
*/
|
||||
public function __construct($data = null) {
|
||||
if ($data !== null) {
|
||||
$this->setData($data);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a new Music
|
||||
*
|
||||
* @api
|
||||
* @param string $data (optional) Media url
|
||||
* @return static
|
||||
*/
|
||||
public static function create($data = null)
|
||||
{
|
||||
return new static($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data url
|
||||
*
|
||||
* @param string $data Data url
|
||||
* @return static
|
||||
*/
|
||||
public function setData($data) {
|
||||
$this->data = (string)$data;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Construct a new Music
|
||||
*
|
||||
* @api
|
||||
* @param string $data (optional) Media url
|
||||
*/
|
||||
public function __construct($data = null)
|
||||
{
|
||||
if ($data) {
|
||||
$this->setData($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the media url
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the media url
|
||||
*
|
||||
* @api
|
||||
* @param string $data Media url
|
||||
* @return static
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = (string)$data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$domElement = $domDocument->createElement("music");
|
||||
if ($this->data) {
|
||||
$domElement->setAttribute("data", $this->data);
|
||||
}
|
||||
return $domElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$xmlElement = $domDocument->createElement($this->tagName);
|
||||
if ($this->data) {
|
||||
$xmlElement->setAttribute('data', $this->data);
|
||||
}
|
||||
return $xmlElement;
|
||||
}
|
||||
}
|
||||
|
@ -8,57 +8,77 @@ use FML\Types\Renderable;
|
||||
* Class representing a ManiaLink script tag with a simple script text
|
||||
*
|
||||
* @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 SimpleScript implements Renderable {
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $tagName = 'script';
|
||||
protected $text = null;
|
||||
class SimpleScript implements Renderable
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new SimpleScript object
|
||||
*
|
||||
* @param string $text (optional) Script text
|
||||
* @return static
|
||||
*/
|
||||
public static function create($text = null) {
|
||||
return new static($text);
|
||||
}
|
||||
/**
|
||||
* @var string $text Script text
|
||||
*/
|
||||
protected $text = null;
|
||||
|
||||
/**
|
||||
* Construct a new SimpleScript object
|
||||
*
|
||||
* @param string $text (optional) Script text
|
||||
*/
|
||||
public function __construct($text = null) {
|
||||
if ($text !== null) {
|
||||
$this->setText($text);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a new SimpleScript
|
||||
*
|
||||
* @api
|
||||
* @param string $text (optional) Script text
|
||||
* @return static
|
||||
*/
|
||||
public static function create($text = null)
|
||||
{
|
||||
return new static($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set script text
|
||||
*
|
||||
* @param string $text Complete script text
|
||||
* @return static
|
||||
*/
|
||||
public function setText($text) {
|
||||
$this->text = (string)$text;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Construct a new SimpleScript
|
||||
*
|
||||
* @api
|
||||
* @param string $text (optional) Script text
|
||||
*/
|
||||
public function __construct($text = null)
|
||||
{
|
||||
if ($text) {
|
||||
$this->setText($text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the script text
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the script text
|
||||
*
|
||||
* @api
|
||||
* @param string $text Complete script text
|
||||
* @return static
|
||||
*/
|
||||
public function setText($text)
|
||||
{
|
||||
$this->text = (string)$text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$domElement = $domDocument->createElement("script");
|
||||
if ($this->text) {
|
||||
$scriptComment = $domDocument->createComment($this->text);
|
||||
$domElement->appendChild($scriptComment);
|
||||
}
|
||||
return $domElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$xmlElement = $domDocument->createElement($this->tagName);
|
||||
if ($this->text) {
|
||||
$scriptComment = $domDocument->createComment($this->text);
|
||||
$xmlElement->appendChild($scriptComment);
|
||||
}
|
||||
return $xmlElement;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user