TrackManiaControl/application/core/Libs/FML/Elements/Format.php

130 lines
2.7 KiB
PHP
Raw Normal View History

<?php
namespace FML\Elements;
2014-01-12 00:51:46 +01:00
use FML\Types\BgColorable;
use FML\Types\Renderable;
use FML\Types\Styleable;
use FML\Types\TextFormatable;
/**
2014-01-12 00:51:46 +01:00
* Format Element
*
* @author steeffeen
*/
class Format implements BgColorable, Renderable, Styleable, TextFormatable {
2014-01-21 20:30:40 +01:00
/*
2013-12-31 02:55:19 +01:00
* Protected Properties
*/
protected $tagName = 'format';
2014-01-12 00:51:46 +01:00
protected $bgColor = '';
protected $style = '';
protected $textSize = -1;
protected $textColor = '';
2014-01-19 19:30:21 +01:00
protected $focusAreaColor1 = '';
protected $focusAreaColor2 = '';
/**
* Create a new Format Element
*
* @return \FML\Elements\Format
*/
public static function create() {
$format = new Format();
return $format;
}
/**
* Construct a new Format Element
*/
public function __construct() {
}
2014-01-12 00:51:46 +01:00
/**
*
* @see \FML\Types\BgColorable::setBgColor()
* @return \FML\Elements\Format
*/
public function setBgColor($bgColor) {
$this->bgColor = (string) $bgColor;
return $this;
}
/**
*
* @see \FML\Types\Styleable::setStyle()
* @return \FML\Elements\Format
*/
public function setStyle($style) {
$this->style = (string) $style;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setTextSize()
* @return \FML\Elements\Format
*/
public function setTextSize($textSize) {
$this->textSize = (int) $textSize;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setTextColor()
* @return \FML\Elements\Format
*/
public function setTextColor($textColor) {
$this->textColor = (string) $textColor;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setAreaColor()
* @return \FML\Elements\Format
*/
public function setAreaColor($areaColor) {
2014-01-19 19:30:21 +01:00
$this->focusAreaColor1 = (string) $areaColor;
2014-01-12 00:51:46 +01:00
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setAreaFocusColor()
* @return \FML\Elements\Format
*/
public function setAreaFocusColor($areaFocusColor) {
2014-01-19 19:30:21 +01:00
$this->focusAreaColor2 = (string) $areaFocusColor;
2014-01-12 00:51:46 +01:00
return $this;
}
/**
*
* @see \FML\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
2014-01-19 19:30:21 +01:00
$formatXmlElement = $domDocument->createElement($this->tagName);
2014-01-12 00:51:46 +01:00
if ($this->bgColor) {
2014-01-19 19:30:21 +01:00
$formatXmlElement->setAttribute('bgcolor', $this->bgColor);
2014-01-12 00:51:46 +01:00
}
if ($this->style) {
2014-01-19 19:30:21 +01:00
$formatXmlElement->setAttribute('style', $this->style);
2014-01-12 00:51:46 +01:00
}
if ($this->textSize >= 0) {
2014-01-19 19:30:21 +01:00
$formatXmlElement->setAttribute('textsize', $this->textSize);
2014-01-12 00:51:46 +01:00
}
if ($this->textColor) {
2014-01-19 19:30:21 +01:00
$formatXmlElement->setAttribute('textcolor', $this->textColor);
2014-01-12 00:51:46 +01:00
}
2014-01-19 19:30:21 +01:00
if ($this->focusAreaColor1) {
$formatXmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1);
2014-01-12 00:51:46 +01:00
}
2014-01-19 19:30:21 +01:00
if ($this->focusAreaColor2) {
$formatXmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2);
2014-01-12 00:51:46 +01:00
}
2014-01-19 19:30:21 +01:00
return $formatXmlElement;
}
}