folderstructure change
This commit is contained in:
committed by
Steffen Schröder
parent
043c85fa97
commit
570b32fff8
274
application/core/Libs/FML/Elements/Dico.php
Normal file
274
application/core/Libs/FML/Elements/Dico.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Elements;
|
||||
|
||||
/**
|
||||
* Dictionary Element
|
||||
*
|
||||
* @author steeffeen
|
||||
*/
|
||||
class Dico {
|
||||
/**
|
||||
* Czech Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_CZECH = 'cz';
|
||||
|
||||
/**
|
||||
* Danish Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_DANISH = 'da';
|
||||
|
||||
/**
|
||||
* German Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_GERMAN = 'de';
|
||||
|
||||
/**
|
||||
* English Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_ENGLISH = 'en';
|
||||
|
||||
/**
|
||||
* Spanish Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_SPANISH = 'es';
|
||||
|
||||
/**
|
||||
* French Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_FRENCH = 'fr';
|
||||
|
||||
/**
|
||||
* Hungarian Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_HUNGARIAN = 'hu';
|
||||
|
||||
/**
|
||||
* Italian Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_ITALIAN = 'it';
|
||||
|
||||
/**
|
||||
* Japanese Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_JAPANESE = 'jp';
|
||||
|
||||
/**
|
||||
* Korean Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_KOREAN = 'kr';
|
||||
|
||||
/**
|
||||
* Norwegian Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_NORWEGIAN = 'nb';
|
||||
|
||||
/**
|
||||
* Dutch Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_DUTCH = 'nl';
|
||||
|
||||
/**
|
||||
* Polish Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_POLISH = 'pl';
|
||||
|
||||
/**
|
||||
* Portuguese Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_PORTUGUESE = 'pt';
|
||||
|
||||
/**
|
||||
* Brazilian Portuguese Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_BRAZILIAN_PORTUGUESE = 'pt_BR';
|
||||
|
||||
/**
|
||||
* Romanian Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_ROMANIAN = 'ro';
|
||||
|
||||
/**
|
||||
* Russian Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_RUSSIAN = 'ru';
|
||||
|
||||
/**
|
||||
* Slovak Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_SLOVAK = 'sk';
|
||||
|
||||
/**
|
||||
* Turkish Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_TURKISH = 'tr';
|
||||
|
||||
/**
|
||||
* Chinese Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LANG_CHINESE = 'zh';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $tagName = 'dico';
|
||||
protected $entries = array();
|
||||
|
||||
/**
|
||||
* Create a new Dictionary Object
|
||||
*
|
||||
* @return \FML\Elements\Dico
|
||||
*/
|
||||
public static function create() {
|
||||
$dico = new Dico();
|
||||
return $dico;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Dictionary Object
|
||||
*/
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 \FML\Elements\Dico
|
||||
*/
|
||||
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 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 \FML\Elements\Dico
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Entries of the given Language
|
||||
*
|
||||
* @param string $language Language of which all Entries should be removed
|
||||
* @param string $entryId (optional) Only remove the given Entry Id
|
||||
* @return \FML\Elements\Dico
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all Entries from the Dictionary
|
||||
*
|
||||
* @return \FML\Elements\Dico
|
||||
*/
|
||||
public function removeEntries() {
|
||||
$this->entries = array();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
129
application/core/Libs/FML/Elements/Format.php
Normal file
129
application/core/Libs/FML/Elements/Format.php
Normal file
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Elements;
|
||||
|
||||
use FML\Types\BgColorable;
|
||||
use FML\Types\Renderable;
|
||||
use FML\Types\Styleable;
|
||||
use FML\Types\TextFormatable;
|
||||
|
||||
/**
|
||||
* Format Element
|
||||
*
|
||||
* @author steeffeen
|
||||
*/
|
||||
class Format implements BgColorable, Renderable, Styleable, TextFormatable {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $tagName = 'format';
|
||||
protected $bgColor = '';
|
||||
protected $style = '';
|
||||
protected $textSize = -1;
|
||||
protected $textColor = '';
|
||||
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() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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) {
|
||||
$this->focusAreaColor1 = (string) $areaColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\TextFormatable::setAreaFocusColor()
|
||||
* @return \FML\Elements\Format
|
||||
*/
|
||||
public function setAreaFocusColor($areaFocusColor) {
|
||||
$this->focusAreaColor2 = (string) $areaFocusColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\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->textColor) {
|
||||
$formatXmlElement->setAttribute('textcolor', $this->textColor);
|
||||
}
|
||||
if ($this->focusAreaColor1) {
|
||||
$formatXmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1);
|
||||
}
|
||||
if ($this->focusAreaColor2) {
|
||||
$formatXmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2);
|
||||
}
|
||||
return $formatXmlElement;
|
||||
}
|
||||
}
|
116
application/core/Libs/FML/Elements/FrameModel.php
Normal file
116
application/core/Libs/FML/Elements/FrameModel.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Elements;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Types\Container;
|
||||
use FML\Types\Renderable;
|
||||
|
||||
/**
|
||||
* Class representing a Frame Model
|
||||
*
|
||||
* @author steeffeen
|
||||
*/
|
||||
class FrameModel implements Container, Renderable {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $tagName = 'framemodel';
|
||||
protected $id = '';
|
||||
protected $children = array();
|
||||
protected $format = null;
|
||||
|
||||
/**
|
||||
* Set Model Id
|
||||
*
|
||||
* @param string $id Model Id
|
||||
* @return \FML\Elements\FrameModel
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = (string) $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Model Id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign an Id if necessary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function checkId() {
|
||||
if (!$this->id) {
|
||||
$this->id = uniqid();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::add()
|
||||
* @return \FML\Elements\FrameModel
|
||||
*/
|
||||
public function add(Control $childControl) {
|
||||
if (!in_array($childControl, $this->children, true)) {
|
||||
array_push($this->children, $childControl);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::removeChildren()
|
||||
* @return \FML\Elements\FrameModel
|
||||
*/
|
||||
public function removeChildren() {
|
||||
$this->children = array();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::setFormat()
|
||||
* @return \FML\Elements\FrameModel
|
||||
*/
|
||||
public function setFormat(Format $format) {
|
||||
$this->format = $format;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::getFormat()
|
||||
*/
|
||||
public function getFormat($createIfEmpty = true) {
|
||||
if (!$this->format && $createIfEmpty) {
|
||||
$this->format = new Format();
|
||||
}
|
||||
return $this->format;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
61
application/core/Libs/FML/Elements/Including.php
Normal file
61
application/core/Libs/FML/Elements/Including.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Elements;
|
||||
|
||||
use FML\Types\Renderable;
|
||||
|
||||
/**
|
||||
* Include Element
|
||||
*
|
||||
* @author steeffeen
|
||||
*/
|
||||
class Including implements Renderable {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $tagName = 'include';
|
||||
protected $url = '';
|
||||
|
||||
/**
|
||||
* Construct a new Include Element
|
||||
*
|
||||
* @param string $url (optional) Include Url
|
||||
* @return \FML\Elements\Including
|
||||
*/
|
||||
public static function create($url = null) {
|
||||
$including = new Including($url);
|
||||
return $including;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Include Element
|
||||
*
|
||||
* @param string $url (optional) Include Url
|
||||
*/
|
||||
public function __construct($url = null) {
|
||||
if ($url !== null) {
|
||||
$this->setUrl($url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Url
|
||||
*
|
||||
* @param string $url Include Url
|
||||
*/
|
||||
public function setUrl($url) {
|
||||
$this->url = (string) $url;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$xmlElement = $domDocument->createElement($this->tagName);
|
||||
if ($this->url) {
|
||||
$xmlElement->setAttribute('url', $this->url);
|
||||
}
|
||||
return $xmlElement;
|
||||
}
|
||||
}
|
63
application/core/Libs/FML/Elements/Music.php
Normal file
63
application/core/Libs/FML/Elements/Music.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Elements;
|
||||
|
||||
use FML\Types\Renderable;
|
||||
|
||||
/**
|
||||
* Music Element
|
||||
*
|
||||
* @author steeffeen
|
||||
*/
|
||||
class Music implements Renderable {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $tagName = 'music';
|
||||
protected $data = '';
|
||||
|
||||
/**
|
||||
* Create a new Music Element
|
||||
*
|
||||
* @param string $data (optional) Media Url
|
||||
* @return \FML\Elements\Music
|
||||
*/
|
||||
public static function create($data = null) {
|
||||
$music = new Music($data);
|
||||
return $music;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Music Element
|
||||
*
|
||||
* @param string $data (optional) Media Url
|
||||
*/
|
||||
public function __construct($data = null) {
|
||||
if ($data !== null) {
|
||||
$this->setData($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Data Url
|
||||
*
|
||||
* @param string $data Media Url
|
||||
* @return \FML\Elements\Music
|
||||
*/
|
||||
public function setData($data) {
|
||||
$this->data = (string) $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$xmlElement = $domDocument->createElement($this->tagName);
|
||||
if ($this->data) {
|
||||
$xmlElement->setAttribute('data', $this->data);
|
||||
}
|
||||
return $xmlElement;
|
||||
}
|
||||
}
|
64
application/core/Libs/FML/Elements/SimpleScript.php
Normal file
64
application/core/Libs/FML/Elements/SimpleScript.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Elements;
|
||||
|
||||
use FML\Types\Renderable;
|
||||
|
||||
/**
|
||||
* Class representing a ManiaLink Script Tag with a simple Script Text
|
||||
*
|
||||
* @author steeffeen
|
||||
*/
|
||||
class SimpleScript implements Renderable {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $tagName = 'script';
|
||||
protected $text = '';
|
||||
|
||||
/**
|
||||
* Create a new SimpleScript Element
|
||||
*
|
||||
* @param string $text (optional) Script Text
|
||||
* @return \FML\Elements\SimpleScript
|
||||
*/
|
||||
public static function create($text = null) {
|
||||
$simpleScript = new SimpleScript($text);
|
||||
return $simpleScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new SimpleScript Element
|
||||
*
|
||||
* @param string $text (optional) Script Text
|
||||
*/
|
||||
public function __construct($text = null) {
|
||||
if ($text !== null) {
|
||||
$this->setText($text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Script Text
|
||||
*
|
||||
* @param string $text The Complete Script Text
|
||||
* @return \FML\Script\Script
|
||||
*/
|
||||
public function setText($text) {
|
||||
$this->text = (string) $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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