diff --git a/application/core/FML/Controls/Audio.php b/application/core/FML/Controls/Audio.php index 65b51289..63436599 100644 --- a/application/core/FML/Controls/Audio.php +++ b/application/core/FML/Controls/Audio.php @@ -6,7 +6,7 @@ use FML\Types\Playable; use FML\Types\Scriptable; /** - * Audio Element + * Audio Control * (CMlMediaPlayer) * * @author steeffeen @@ -16,12 +16,24 @@ class Audio extends Control implements Playable, Scriptable { * Protected Properties */ protected $data = ''; + protected $dataId = ''; protected $play = 0; protected $looping = 0; protected $music = 0; protected $volume = 1.; protected $scriptEvents = 0; + /** + * Create a new Audio Control + * + * @param string $id (optional) Control Id + * @return \FML\Controls\Audio + */ + public static function create($id = null) { + $audio = new Audio($id); + return $audio; + } + /** * Construct a new Audio Control * @@ -42,6 +54,16 @@ class Audio extends Control implements Playable, Scriptable { return $this; } + /** + * + * @see \FML\Types\Playable::setDataId() + * @return \FML\Controls\Audio + */ + public function setDataId($dataId) { + $this->dataId = (string) $dataId; + return $this; + } + /** * * @see \FML\Types\Playable::setPlay() @@ -104,7 +126,7 @@ class Audio extends Control implements Playable, Scriptable { if ($this->play) { $xmlElement->setAttribute('play', $this->play); } - if ($this->looping) { + if (!$this->looping) { $xmlElement->setAttribute('looping', $this->looping); } if ($this->music) { diff --git a/application/core/FML/Controls/Control.php b/application/core/FML/Controls/Control.php index 3863cfe0..3174acc1 100644 --- a/application/core/FML/Controls/Control.php +++ b/application/core/FML/Controls/Control.php @@ -5,7 +5,7 @@ namespace FML\Controls; use FML\Types\Renderable; /** - * Base Control Element + * Base Control * (CMlControl) * * @author steeffeen @@ -43,7 +43,9 @@ abstract class Control implements Renderable { * @param string $id (optional) Control Id */ public function __construct($id = null) { - $this->setId($id); + if ($id !== null) { + $this->setId($id); + } } /** diff --git a/application/core/FML/Controls/Entry.php b/application/core/FML/Controls/Entry.php index 316e75c8..ba8a0ec4 100644 --- a/application/core/FML/Controls/Entry.php +++ b/application/core/FML/Controls/Entry.php @@ -8,7 +8,7 @@ use FML\Types\Styleable; use FML\Types\TextFormatable; /** - * Entry Element + * Entry Control * (CMlEntry) * * @author steeffeen @@ -24,8 +24,19 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF protected $style = ''; protected $textColor = ''; protected $textSize = -1; - protected $areaColor = ''; - protected $areaFocusColor = ''; + 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; + } /** * Construct a new Entry Control @@ -115,7 +126,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF * @return \FML\Controls\Entry */ public function setAreaColor($areaColor) { - $this->areaColor = (string) $areaColor; + $this->focusAreaColor1 = (string) $areaColor; return $this; } @@ -125,7 +136,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF * @return \FML\Controls\Entry */ public function setAreaFocusColor($areaFocusColor) { - $this->areaFocusColor = (string) $areaFocusColor; + $this->focusAreaColor2 = (string) $areaFocusColor; return $this; } @@ -156,11 +167,11 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF if ($this->textSize >= 0.) { $xmlElement->setAttribute('textsize', $this->textSize); } - if ($this->areaColor) { - $xmlElement->setAttribute('areacolor', $this->areaColor); + if ($this->focusAreaColor1) { + $xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1); } - if ($this->areaFocusColor) { - $xmlElement->setAttribute('areafocuscolor', $this->areaFocusColor); + if ($this->focusAreaColor2) { + $xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2); } return $xmlElement; } diff --git a/application/core/FML/Controls/FileEntry.php b/application/core/FML/Controls/FileEntry.php index 2e1fbb24..b3ca3f7b 100644 --- a/application/core/FML/Controls/FileEntry.php +++ b/application/core/FML/Controls/FileEntry.php @@ -3,7 +3,8 @@ namespace FML\Controls; /** - * Class representing CMlFileEntry + * FileEntry Control + * (CMlFileEntry) * * @author steeffeen */ @@ -13,6 +14,17 @@ class FileEntry extends Entry { */ protected $folder = ''; + /** + * Create a new FileEntry Control + * + * @param string $id (optional) Control Id + * @return \FML\Controls\FileEntry + */ + public static function create($id = null) { + $fileEntry = new FileEntry($id); + return $fileEntry; + } + /** * Construct a new FileEntry Control * diff --git a/application/core/FML/Controls/Frame.php b/application/core/FML/Controls/Frame.php index d6db26ae..4642118d 100644 --- a/application/core/FML/Controls/Frame.php +++ b/application/core/FML/Controls/Frame.php @@ -4,9 +4,11 @@ namespace FML\Controls; use FML\Types\Container; use FML\Types\Renderable; +use FML\Elements\Format; +use FML\Elements\FrameModel; /** - * Frame Element + * Frame Control * (CMlFrame) * * @author steeffeen @@ -16,6 +18,18 @@ class Frame extends Control implements Container { * Protected Properties */ protected $children = array(); + protected $format = null; + + /** + * Create a new Frame Control + * + * @param string $id (optional) Control Id + * @return \FML\Controls\Frame + */ + public static function create($id = null) { + $frame = new Frame($id); + return $frame; + } /** * Construct a new Frame Control @@ -32,7 +46,7 @@ class Frame extends Control implements Container { * @see \FML\Types\Container::add() * @return \FML\Controls\Frame */ - public function add(Renderable $child) { + public function add(Control $child) { if (!in_array($child, $this->children, true)) { array_push($this->children, $child); } @@ -49,12 +63,37 @@ class Frame extends Control implements Container { return $this; } + /** + * + * @see \FML\Types\Container::setFormat() + * @return \FML\Controls\Frame + */ + 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\Renderable::render() */ public function render(\DOMDocument $domDocument) { $xmlElement = parent::render($domDocument); + if ($this->format) { + $formatXml = $this->format->render($domDocument); + $xmlElement->appendChild($formatXml); + } foreach ($this->children as $child) { $childXmlElement = $child->render($domDocument); $xmlElement->appendChild($childXmlElement); diff --git a/application/core/FML/Controls/Frame3d.php b/application/core/FML/Controls/Frame3d.php index 35e3653b..67c498ec 100644 --- a/application/core/FML/Controls/Frame3d.php +++ b/application/core/FML/Controls/Frame3d.php @@ -3,9 +3,10 @@ namespace FML\Controls; use FML\Types\Scriptable; +use FML\Stylesheet\Style3d; /** - * Frame3d Element + * Frame3d Control * (CMlFrame) * * @author steeffeen @@ -14,9 +15,21 @@ class Frame3d extends Frame implements Scriptable { /** * Protected Properties */ - protected $style3d = ''; + protected $style3dId = ''; + protected $style3d = null; protected $scriptEvents = 0; + /** + * Create a new Frame3d Control + * + * @param string $id (optional) Control Id + * @return \FML\Controls\Frame3d + */ + public static function create($id = null) { + $frame3d = new Frame3d($id); + return $frame3d; + } + /** * Construct a new Frame3d Control * @@ -28,13 +41,26 @@ class Frame3d extends Frame implements Scriptable { } /** - * Set style3d + * Set Style3d Id * - * @param string $style3d 3D Style + * @param string $style3dId Style3d Id * @return \FML\Controls\Frame3d */ - public function setStyle3d($style3d) { - $this->style3d = (string) $style3d; + public function setStyle3dId($style3dId) { + $this->style3dId = (string) $style3dId; + $this->style3d = null; + return $this; + } + + /** + * Set Style3d + * + * @param Style3d $style3d Style3d Object + * @return \FML\Controls\Frame3d + */ + public function setStyle3d(Style3d $style3d) { + $this->style3d = $style3d; + $this->style = ''; return $this; } @@ -55,7 +81,11 @@ class Frame3d extends Frame implements Scriptable { public function render(\DOMDocument $domDocument) { $xmlElement = parent::render($domDocument); if ($this->style3d) { - $xmlElement->setAttribute('style3d', $this->style3d); + $this->style3d->checkId(); + $xmlElement->setAttribute('style3d', $this->style3d->getId()); + } + else if ($this->style3dId) { + $xmlElement->setAttribute('style3d', $this->style3dId); } if ($this->scriptEvents) { $xmlElement->setAttribute('scriptevents', $this->scriptEvents); diff --git a/application/core/FML/Controls/FrameInstance.php b/application/core/FML/Controls/FrameInstance.php new file mode 100644 index 00000000..ae445958 --- /dev/null +++ b/application/core/FML/Controls/FrameInstance.php @@ -0,0 +1,86 @@ +tagName = 'frameinstance'; + if ($modelId !== null) { + $this->setModelId($modelId); + } + } + + /** + * Set Model Id + * + * @param string $modelId Model Id + * @return \FML\Controls\FrameInstance + */ + public function setModelId($modelId) { + $this->modelId = (string) $modelId; + $this->model = null; + return $this; + } + + /** + * Set Frame Model to use + * + * @param FrameModel $frameModel Frame Model + * @return \FML\Controls\FrameInstance + */ + public function setModel(FrameModel $frameModel) { + $this->model = $frameModel; + $this->modelId = ''; + return $this; + } + + /** + * + * @see \FML\Renderable::render() + */ + public function render(\DOMDocument $domDocument) { + $xmlElement = parent::render($domDocument); + if ($this->model) { + $this->model->checkId(); + $xmlElement->setAttribute('modelid', $this->model->getId()); + } + else if ($this->modelId) { + $xmlElement->setAttribute('modelid', $this->modelId); + } + return $xmlElement; + } +} diff --git a/application/core/FML/Controls/Gauge.php b/application/core/FML/Controls/Gauge.php index db93230c..a0a2d813 100644 --- a/application/core/FML/Controls/Gauge.php +++ b/application/core/FML/Controls/Gauge.php @@ -5,17 +5,17 @@ namespace FML\Controls; use FML\Types\Styleable; /** - * Gauge Element + * Gauge Control * (CMlGauge) * * @author steeffeen */ +// TODO: gauge styles class Gauge extends Control implements Styleable { /** * Protected Properties */ - protected $ratio = 1.; - // TODO: validate grading + protected $ratio = 0.; protected $grading = 1.; protected $color = ''; protected $rotation = 0.; @@ -25,6 +25,17 @@ class Gauge extends Control implements Styleable { protected $drawBlockBg = 1; protected $style = ''; + /** + * Create a new Gauge Control + * + * @param string $id (optional) Control Id + * @return \FML\Controls\Gauge + */ + public static function create($id = null) { + $gauge = new Gauge($id); + return $gauge; + } + /** * Construct a new Gauge Control * @@ -139,9 +150,12 @@ class Gauge extends Control implements Styleable { */ public function render(\DOMDocument $domDocument) { $xmlElement = parent::render($domDocument); - // TODO: validate default values - $xmlElement->setAttribute('ratio', $this->ratio); - $xmlElement->setAttribute('grading', $this->grading); + if ($this->ratio) { + $xmlElement->setAttribute('ratio', $this->ratio); + } + if ($this->grading != 1.) { + $xmlElement->setAttribute('grading', $this->grading); + } if ($this->color) { $xmlElement->setAttribute('color', $this->color); } @@ -154,8 +168,12 @@ class Gauge extends Control implements Styleable { if ($this->clan) { $xmlElement->setAttribute('clan', $this->clan); } - $xmlElement->setAttribute('drawbg', $this->drawBg); - $xmlElement->setAttribute('drawblockbg', $this->drawBlockBg); + if (!$this->drawBg) { + $xmlElement->setAttribute('drawbg', $this->drawBg); + } + if (!$this->drawBlockBg) { + $xmlElement->setAttribute('drawblockbg', $this->drawBlockBg); + } if ($this->style) { $xmlElement->setAttribute('style', $this->style); } diff --git a/application/core/FML/Controls/Label.php b/application/core/FML/Controls/Label.php index 7a90e906..015b5afb 100644 --- a/application/core/FML/Controls/Label.php +++ b/application/core/FML/Controls/Label.php @@ -10,7 +10,7 @@ use FML\Types\Styleable; use FML\Types\TextFormatable; /** - * Label Element + * Label Control * (CMlLabel) * * @author steeffeen @@ -20,6 +20,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script * Protected Properties */ protected $text = ''; + protected $textId = ''; protected $textPrefix = ''; protected $textEmboss = 0; protected $translate = 0; @@ -27,14 +28,27 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script protected $action = ''; protected $actionKey = -1; protected $url = ''; + protected $urlId = ''; protected $manialink = ''; + protected $manialinkId = ''; protected $autoNewLine = 0; protected $scriptEvents = 0; protected $style = ''; protected $textSize = -1; protected $textColor = ''; - protected $areaColor = ''; - protected $areaFocusColor = ''; + 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; + } /** * Construct a new Label Control @@ -58,6 +72,17 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script return $this; } + /** + * 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; + } + /** * Set Text Prefix * @@ -132,6 +157,16 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script return $this; } + /** + * + * @see \FML\Types\Linkable::setUrlId() + * @return \FML\Controls\Label + */ + public function setUrlId($urlId) { + $this->urlId = (string) $urlId; + return $this; + } + /** * * @see \FML\Types\Linkable::setManialink() @@ -142,6 +177,16 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script return $this; } + /** + * + * @see \FML\Types\Linkable::setManialinkId() + * @return \FML\Controls\Label + */ + public function setManialinkId($manialinkId) { + $this->manialinkId = (string) $manialinkId; + return $this; + } + /** * * @see \FML\Types\NewLineable::setAutoNewLine() @@ -198,7 +243,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script * @return \FML\Controls\Label */ public function setAreaColor($areaColor) { - $this->areaColor = (string) $areaColor; + $this->focusAreaColor1 = (string) $areaColor; return $this; } @@ -208,7 +253,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script * @return \FML\Controls\Label */ public function setAreaFocusColor($areaFocusColor) { - $this->areaFocusColor = (string) $areaFocusColor; + $this->focusAreaColor2 = (string) $areaFocusColor; return $this; } @@ -221,6 +266,9 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script if ($this->text) { $xmlElement->setAttribute('text', $this->text); } + if ($this->textId) { + $xmlElement->setAttribute('textid', $this->textId); + } if ($this->textPrefix) { $xmlElement->setAttribute('textprefix', $this->textPrefix); } @@ -260,11 +308,11 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script if ($this->textColor) { $xmlElement->setAttribute('textcolor', $this->textColor); } - if ($this->areaColor) { - $xmlElement->setAttribute('areacolor', $this->areaColor); + if ($this->focusAreaColor1) { + $xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1); } - if ($this->areaFocusColor) { - $xmlElement->setAttribute('areafocuscolor', $this->areaFocusColor); + if ($this->focusAreaColor2) { + $xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2); } return $xmlElement; } diff --git a/application/core/FML/Controls/Labels/Label_Button.php b/application/core/FML/Controls/Labels/Label_Button.php index 0917abf7..75739e41 100644 --- a/application/core/FML/Controls/Labels/Label_Button.php +++ b/application/core/FML/Controls/Labels/Label_Button.php @@ -31,4 +31,24 @@ class Label_Button extends Label { const STYLE_CardButtonSmallXXXL = 'CardButtonSmallXXXL'; const STYLE_CardMain_Quit = 'CardMain_Quit'; const STYLE_CardMain_Tool = 'CardMain_Tool'; + + /** + * Create a new Label_Button Control + * + * @param string $id (optional) Control Id + * @return \FML\Controls\Labels\Label_Button + */ + public static function create($id = null) { + $labelButton = new Label_Button($id); + return $labelButton; + } + + /** + * Construct a new Label_Button Control + * + * @param string $id (optional) Control Id + */ + public function __construct($id = null) { + parent::__construct($id); + } } diff --git a/application/core/FML/Controls/Labels/Label_Text.php b/application/core/FML/Controls/Labels/Label_Text.php index b1ddeac4..5dcb2242 100644 --- a/application/core/FML/Controls/Labels/Label_Text.php +++ b/application/core/FML/Controls/Labels/Label_Text.php @@ -88,4 +88,24 @@ class Label_Text extends Label { const STYLE_UiDriving_BgBottom = 'UiDriving_BgBottom'; const STYLE_UiDriving_BgCard = 'UiDriving_BgCard'; const STYLE_UiDriving_BgCenter = 'UiDriving_BgCenter'; + + /** + * Create a new Label_Text Control + * + * @param string $id (optional) Control Id + * @return \FML\Controls\Labels\Label_Button + */ + public static function create($id = null) { + $labelText = new Label_Text($id); + return $labelText; + } + + /** + * Construct a new Label_Text Control + * + * @param string $id (optional) Control Id + */ + public function __construct($id = null) { + parent::__construct($id); + } } diff --git a/application/core/FML/Controls/Quad.php b/application/core/FML/Controls/Quad.php index f8842c73..e5a931cd 100644 --- a/application/core/FML/Controls/Quad.php +++ b/application/core/FML/Controls/Quad.php @@ -10,7 +10,7 @@ use FML\Types\Styleable; use FML\Types\SubStyleable; /** - * Quad Element + * Quad Control * (CMlQuad) * * @author steeffeen @@ -20,7 +20,9 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta * Protected Properties */ protected $image = ''; + protected $imageId = ''; protected $imageFocus = ''; + protected $imageFocusId = ''; protected $colorize = ''; protected $modulizeColor = ''; protected $autoScale = 1; @@ -28,11 +30,24 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta protected $actionKey = -1; protected $bgColor = ''; protected $url = ''; + protected $urlId = ''; protected $manialink = ''; + protected $manialinkId = ''; protected $scriptEvents = 0; protected $style = ''; protected $subStyle = ''; + /** + * Create a new Quad Control + * + * @param string $id (optional) Control Id + * @return \FML\Controls\Quad + */ + public static function create($id = null) { + $quad = new Quad($id); + return $quad; + } + /** * Construct a new Quad Control * @@ -55,6 +70,17 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta return $this; } + /** + * Set Image Id to use from the Dico + * + * @param string $imageId Image Id + * @return \FML\Controls\Quad + */ + public function setImageId($imageId) { + $this->imageId = (string) $imageId; + return $this; + } + /** * Set Focus Image Url * @@ -66,6 +92,17 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta return $this; } + /** + * Set Focus Image Id to use from the Dico + * + * @param string $imageFocusId Focus Image Id + * @return \FML\Controls\Quad + */ + public function setImageFocusId($imageFocusId) { + $this->imageFocusId = (string) $imageFocusId; + return $this; + } + /** * Set Colorization * @@ -139,6 +176,16 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta return $this; } + /** + * + * @see \FML\Types\Linkable::setUrlId() + * @return \FML\Controls\Quad + */ + public function setUrlId($urlId) { + $this->urlId = (string) $urlId; + return $this; + } + /** * * @see \FML\Types\Linkable::setManialink() @@ -149,6 +196,16 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta return $this; } + /** + * + * @see \FML\Types\Linkable::setManialinkId() + * @return \FML\Controls\Quad + */ + public function setManialinkId($manialinkId) { + $this->manialinkId = (string) $manialinkId; + return $this; + } + /** * * @see \FML\Types\Scriptable::setScriptEvents() @@ -199,9 +256,15 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta if ($this->image) { $xmlElement->setAttribute('image', $this->image); } + if ($this->imageId) { + $xmlElement->setAttribute('imageid', $this->imageId); + } if ($this->imageFocus) { $xmlElement->setAttribute('imagefocus', $this->imageFocus); } + if ($this->imageFocusId) { + $xmlElement->setAttribute('imagefocusid', $this->imageFocusId); + } if ($this->colorize) { $xmlElement->setAttribute('colorize', $this->colorize); } diff --git a/application/core/FML/Controls/Quads/Quad_321Go.php b/application/core/FML/Controls/Quads/Quad_321Go.php index 937bfdea..9e640a9f 100644 --- a/application/core/FML/Controls/Quads/Quad_321Go.php +++ b/application/core/FML/Controls/Quads/Quad_321Go.php @@ -20,8 +20,20 @@ class Quad_321Go extends Quad { const SUBSTYLE_Go = 'Go!'; /** + * Create a new Quad_321Go Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_321Go + */ + public static function create($id = null) { + $quad321Go = new Quad_321Go($id); + return $quad321Go; + } + + /** + * Construct a new Quad_321Go Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_BgRaceScore2.php b/application/core/FML/Controls/Quads/Quad_BgRaceScore2.php index 9419d7c1..e2616c73 100644 --- a/application/core/FML/Controls/Quads/Quad_BgRaceScore2.php +++ b/application/core/FML/Controls/Quads/Quad_BgRaceScore2.php @@ -43,8 +43,20 @@ class Quad_BgRaceScore2 extends Quad { const SUBSTYLE_Warmup = 'Warmup'; /** + * Create a new Quad_BgRaceScore2 Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_BgRaceScore2 + */ + public static function create($id = null) { + $quadBgRaceScore2 = new Quad_BgRaceScore2($id); + return $quadBgRaceScore2; + } + + /** + * Construct a new Quad_BgRaceScore2 Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_Bgs1.php b/application/core/FML/Controls/Quads/Quad_Bgs1.php index edc18129..ba1230c0 100644 --- a/application/core/FML/Controls/Quads/Quad_Bgs1.php +++ b/application/core/FML/Controls/Quads/Quad_Bgs1.php @@ -80,8 +80,20 @@ class Quad_Bgs1 extends Quad { const SUBSTYLE_Shadow = 'Shadow'; /** + * Create a new Quad_Bgs1 Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_Bgs1 + */ + public static function create($id = null) { + $quadBgs1 = new Quad_Bgs1($id); + return $quadBgs1; + } + + /** + * Construct a new Quad_Bgs1 Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_Bgs1InRace.php b/application/core/FML/Controls/Quads/Quad_Bgs1InRace.php index 0cef7cd9..8568fd1a 100644 --- a/application/core/FML/Controls/Quads/Quad_Bgs1InRace.php +++ b/application/core/FML/Controls/Quads/Quad_Bgs1InRace.php @@ -80,8 +80,20 @@ class Quad_Bgs1InRace extends Quad { const SUBSTYLE_Shadow = 'Shadow'; /** + * Create a new Quad_Bgs1InRace Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_Bgs1InRace + */ + public static function create($id = null) { + $quadBgs1InRace = new Quad_Bgs1InRace($id); + return $quadBgs1InRace; + } + + /** + * Construct a new Quad_Bgs1InRace Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_BgsChallengeMedals.php b/application/core/FML/Controls/Quads/Quad_BgsChallengeMedals.php index 3e0f37b8..618b1d2c 100644 --- a/application/core/FML/Controls/Quads/Quad_BgsChallengeMedals.php +++ b/application/core/FML/Controls/Quads/Quad_BgsChallengeMedals.php @@ -22,8 +22,20 @@ class Quad_BgsChallengeMedals extends Quad { const SUBSTYLE_BgSilver = 'BgSilver'; /** + * Create a new Quad_BgsChallengeMedals Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_BgsChallengeMedals + */ + public static function create($id = null) { + $quadBgsChallengeMedals = new Quad_BgsChallengeMedals($id); + return $quadBgsChallengeMedals; + } + + /** + * Construct a new Quad_BgsChallengeMedals Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_BgsPlayerCard.php b/application/core/FML/Controls/Quads/Quad_BgsPlayerCard.php index 75a6182d..9903c0b6 100644 --- a/application/core/FML/Controls/Quads/Quad_BgsPlayerCard.php +++ b/application/core/FML/Controls/Quads/Quad_BgsPlayerCard.php @@ -30,8 +30,20 @@ class Quad_BgsPlayerCard extends Quad { const SUBSTYLE_ProgressBar = 'ProgressBar'; /** + * Create a new Quad_BgsPlayerCard Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_BgsPlayerCard + */ + public static function create($id = null) { + $quadBgsPlayerCard = new Quad_BgsPlayerCard($id); + return $quadBgsPlayerCard; + } + + /** + * Construct a new Quad_BgsPlayerCard Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_Copilot.php b/application/core/FML/Controls/Quads/Quad_Copilot.php index 8c072031..049673e8 100644 --- a/application/core/FML/Controls/Quads/Quad_Copilot.php +++ b/application/core/FML/Controls/Quads/Quad_Copilot.php @@ -28,8 +28,20 @@ class Quad_Copilot extends Quad { const SUBSTYLE_UpWrong = 'UpWrong'; /** + * Create a new Quad_Copilot Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_Copilot + */ + public static function create($id = null) { + $quadCopilot = new Quad_Copilot($id); + return $quadCopilot; + } + + /** + * Construct a new Quad_Copilot Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_Emblems.php b/application/core/FML/Controls/Quads/Quad_Emblems.php index 7a360e80..0a41f077 100644 --- a/application/core/FML/Controls/Quads/Quad_Emblems.php +++ b/application/core/FML/Controls/Quads/Quad_Emblems.php @@ -19,8 +19,20 @@ class Quad_Emblems extends Quad { const SUBSTYLE_2 = '#2'; /** + * Create a new Quad_Emblems Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_Emblems + */ + public static function create($id = null) { + $quadEmblems = new Quad_Emblems($id); + return $quadEmblems; + } + + /** + * Construct a new Quad_Emblems Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_EnergyBar.php b/application/core/FML/Controls/Quads/Quad_EnergyBar.php index 82d5274a..3d66a196 100644 --- a/application/core/FML/Controls/Quads/Quad_EnergyBar.php +++ b/application/core/FML/Controls/Quads/Quad_EnergyBar.php @@ -22,8 +22,20 @@ class Quad_EnergyBar extends Quad { const SUBSTYLE_HeaderGaugeRight = 'HeaderGaugeRight'; /** + * Create a new Quad_EnergyBar Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_EnergyBar + */ + public static function create($id = null) { + $quadEnergybar = new Quad_EnergyBar($id); + return $quadEnergybar; + } + + /** + * Construct a new Quad_EnergyBar Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_Hud3dEchelons.php b/application/core/FML/Controls/Quads/Quad_Hud3dEchelons.php index b50dd366..33cc67df 100644 --- a/application/core/FML/Controls/Quads/Quad_Hud3dEchelons.php +++ b/application/core/FML/Controls/Quads/Quad_Hud3dEchelons.php @@ -25,8 +25,20 @@ class Quad_Hud3dEchelons extends Quad { const SUBSTYLE_EchelonSilver3 = 'EchelonSilver3'; /** + * Create a new Quad_Hud3dEchelons Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_Hud3dEchelons + */ + public static function create($id = null) { + $quadHud3dEchelons = new Quad_Hud3dEchelons($id); + return $quadHud3dEchelons; + } + + /** + * Construct a new Quad_Hud3dEchelons Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_Icons128x128_1.php b/application/core/FML/Controls/Quads/Quad_Icons128x128_1.php index d461b2ce..3086066c 100644 --- a/application/core/FML/Controls/Quads/Quad_Icons128x128_1.php +++ b/application/core/FML/Controls/Quads/Quad_Icons128x128_1.php @@ -80,7 +80,20 @@ class Quad_Icons128x128_1 extends Quad { const SUBSTYLE_Vehicles = 'Vehicles'; /** - * Construct Icons128x128_1 quad + * Create a new Quad_Icons128x128_1 Control + * + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_Icons128x128_1 + */ + public static function create($id = null) { + $quadIcons128x128_1 = new Quad_Icons128x128_1($id); + return $quadIcons128x128_1; + } + + /** + * Construct a new Quad_Icons128x128_1 Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_Icons128x128_Blink.php b/application/core/FML/Controls/Quads/Quad_Icons128x128_Blink.php index a893dd77..23f749b7 100644 --- a/application/core/FML/Controls/Quads/Quad_Icons128x128_Blink.php +++ b/application/core/FML/Controls/Quads/Quad_Icons128x128_Blink.php @@ -80,8 +80,20 @@ class Quad_Icons128x128_Blink extends Quad { const SUBSTYLE_Vehicles = 'Vehicles'; /** + * Create a new Quad_Icons128x128_Blink Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_Icons128x128_Blink + */ + public static function create($id = null) { + $quadIcons128x128_Blink = new Quad_Icons128x128_Blink($id); + return $quadIcons128x128_Blink; + } + + /** + * Construct a new Quad_Icons128x128_Blink Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_Icons128x32_1.php b/application/core/FML/Controls/Quads/Quad_Icons128x32_1.php index 7efd6e3c..b1892255 100644 --- a/application/core/FML/Controls/Quads/Quad_Icons128x32_1.php +++ b/application/core/FML/Controls/Quads/Quad_Icons128x32_1.php @@ -41,8 +41,20 @@ class Quad_Icons128x32_1 extends Quad { const SUBSTYLE_Windowed = 'Windowed'; /** + * Create a new Quad_Icons128x32_1 Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_Icons128x32_1 + */ + public static function create($id = null) { + $quadIcons128x32_1 = new Quad_Icons128x32_1($id); + return $quadIcons128x32_1; + } + + /** + * Construct a new Quad_Icons128x32_1 Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_Icons64x64_1.php b/application/core/FML/Controls/Quads/Quad_Icons64x64_1.php index ce4d3366..2d411257 100644 --- a/application/core/FML/Controls/Quads/Quad_Icons64x64_1.php +++ b/application/core/FML/Controls/Quads/Quad_Icons64x64_1.php @@ -101,8 +101,20 @@ class Quad_Icons64x64_1 extends Quad { const SUBSTYLE_YellowLow = 'YellowLow'; /** + * Create a new Quad_Icons64x64_1 Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_Icons64x64_1 + */ + public static function create($id = null) { + $quadIcons64x64_1 = new Quad_Icons64x64_1($id); + return $quadIcons64x64_1; + } + + /** + * Construct a new Quad_Icons64x64_1 Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_Icons64x64_2.php b/application/core/FML/Controls/Quads/Quad_Icons64x64_2.php index d0783c64..6f931b9c 100644 --- a/application/core/FML/Controls/Quads/Quad_Icons64x64_2.php +++ b/application/core/FML/Controls/Quads/Quad_Icons64x64_2.php @@ -29,8 +29,20 @@ class Quad_Icons64x64_2 extends Quad { const SUBSTYLE_UnknownHit = 'UnknownHit'; /** + * Create a new Quad_Icons64x64_2 Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_Icons64x64_2 + */ + public static function create($id = null) { + $quadIcons64x64_2 = new Quad_Icons64x64_2($id); + return $quadIcons64x64_2; + } + + /** + * Construct a new Quad_Icons64x64_2 Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_ManiaPlanetLogos.php b/application/core/FML/Controls/Quads/Quad_ManiaPlanetLogos.php index 1435e043..7df4dcf2 100644 --- a/application/core/FML/Controls/Quads/Quad_ManiaPlanetLogos.php +++ b/application/core/FML/Controls/Quads/Quad_ManiaPlanetLogos.php @@ -23,8 +23,20 @@ class Quad_ManiaPlanetLogos extends Quad { const SUBSTYLE_ManiaPlanetLogoWhiteSmall = 'ManiaPlanetLogoWhiteSmall'; /** + * Create a new Quad_ManiaPlanetLogos Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_ManiaPlanetLogos + */ + public static function create($id = null) { + $quadManiaPlanetLogos = new Quad_ManiaPlanetLogos($id); + return $quadManiaPlanetLogos; + } + + /** + * Construct a new Quad_ManiaPlanetLogos Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_ManiaplanetSystem.php b/application/core/FML/Controls/Quads/Quad_ManiaplanetSystem.php index e537b3b3..b6590a3c 100644 --- a/application/core/FML/Controls/Quads/Quad_ManiaplanetSystem.php +++ b/application/core/FML/Controls/Quads/Quad_ManiaplanetSystem.php @@ -22,8 +22,20 @@ class Quad_ManiaplanetSystem extends Quad { const SUBSTYLE_Statistics = 'Statistics'; /** + * Create a new Quad_ManiaplanetSystem Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_ManiaplanetSystem + */ + public static function create($id = null) { + $quadManiaplanetSystem = new Quad_ManiaplanetSystem($id); + return $quadManiaplanetSystem; + } + + /** + * Construct a new Quad_ManiaplanetSystem Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_MedalsBig.php b/application/core/FML/Controls/Quads/Quad_MedalsBig.php index b2069d45..cd511da6 100644 --- a/application/core/FML/Controls/Quads/Quad_MedalsBig.php +++ b/application/core/FML/Controls/Quads/Quad_MedalsBig.php @@ -23,8 +23,20 @@ class Quad_MedalsBig extends Quad { const SUBSTYLE_MedalSlot = 'MedalSlot'; /** + * Create a new Quad_MedalsBig Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_MedalsBig + */ + public static function create($id = null) { + $quadMedalsBig = new Quad_MedalsBig($id); + return $quadMedalsBig; + } + + /** + * Construct a new Quad_MedalsBig Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_TitleLogos.php b/application/core/FML/Controls/Quads/Quad_TitleLogos.php index 310fdd0b..c9e09c86 100644 --- a/application/core/FML/Controls/Quads/Quad_TitleLogos.php +++ b/application/core/FML/Controls/Quads/Quad_TitleLogos.php @@ -20,8 +20,20 @@ class Quad_TitleLogos extends Quad { const SUBSTYLE_Title = 'Title'; /** + * Create a new Quad_TitleLogos Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_TitleLogos + */ + public static function create($id = null) { + $quadTitleLogos = new Quad_TitleLogos($id); + return $quadTitleLogos; + } + + /** + * Construct a new Quad_TitleLogos Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_UIConstruction_Buttons.php b/application/core/FML/Controls/Quads/Quad_UIConstruction_Buttons.php index d8251ae4..7591ae8a 100644 --- a/application/core/FML/Controls/Quads/Quad_UIConstruction_Buttons.php +++ b/application/core/FML/Controls/Quads/Quad_UIConstruction_Buttons.php @@ -70,8 +70,20 @@ class Quad_UIConstruction_Buttons extends Quad { const SUBSTYLE_Validate_Step3 = 'Validate_Step3'; /** + * Create a new Quad_UIConstruction_Buttons Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_UIConstruction_Buttons + */ + public static function create($id = null) { + $quadUIConstructionButtons = new Quad_UIConstruction_Buttons($id); + return $quadUIConstructionButtons; + } + + /** + * Construct a new Quad_UIConstruction_Buttons Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php b/application/core/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php index 8464327c..c8d48b9a 100644 --- a/application/core/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php +++ b/application/core/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php @@ -37,8 +37,20 @@ class Quad_UiSMSpectatorScoreBig extends Quad { CONST SUBSTYLE_UIRange2Bg = 'UIRange2Bg'; /** + * Create a new Quad_UiSMSpectatorScoreBig Control * - * @see \FML\Controls\Quad + * @param string $id (optional) Control Id + * @return \FML\Controls\Quads\Quad_UiSMSpectatorScoreBig + */ + public static function create($id = null) { + $quadUiSMSpectatorScoreBig = new Quad_UiSMSpectatorScoreBig($id); + return $quadUiSMSpectatorScoreBig; + } + + /** + * Construct a new Quad_UiSMSpectatorScoreBig Control + * + * @param string $id (optional) Control Id */ public function __construct($id = null) { parent::__construct($id); diff --git a/application/core/FML/Controls/Video.php b/application/core/FML/Controls/Video.php index d870ee57..5136b700 100644 --- a/application/core/FML/Controls/Video.php +++ b/application/core/FML/Controls/Video.php @@ -6,7 +6,7 @@ use FML\Types\Playable; use FML\Types\Scriptable; /** - * Video Element + * Video Control * (CMlMediaPlayer) * * @author steeffeen @@ -16,12 +16,24 @@ class Video extends Control implements Playable, Scriptable { * Protected Properties */ protected $data = ''; + protected $dataId = ''; protected $play = 0; protected $looping = 0; protected $music = 0; protected $volume = 1.; protected $scriptEvents = 0; + /** + * Create a new Video Control + * + * @param string $id (optional) Control Id + * @return \FML\Controls\Video + */ + public static function create($id = null) { + $video = new Video($id); + return $video; + } + /** * Construct a new Video Control * @@ -42,6 +54,16 @@ class Video extends Control implements Playable, Scriptable { return $this; } + /** + * + * @see \FML\Types\Playable::setDataId() + * @return \FML\Controls\Video + */ + public function setDataId($dataId) { + $this->dataId = (string) $dataId; + return $this; + } + /** * * @see \FML\Types\Playable::setPlay() @@ -104,7 +126,7 @@ class Video extends Control implements Playable, Scriptable { if ($this->play) { $xmlElement->setAttribute('play', $this->play); } - if ($this->looping) { + if (!$this->looping) { $xmlElement->setAttribute('looping', $this->looping); } if ($this->music) { diff --git a/application/core/FML/CustomUI.php b/application/core/FML/CustomUI.php index 566b36f8..06ccc08a 100644 --- a/application/core/FML/CustomUI.php +++ b/application/core/FML/CustomUI.php @@ -22,6 +22,22 @@ class CustomUI { protected $scoretableVisible = null; protected $globalVisible = null; + /** + * Create a new CustomUI Object + * + * @return \FML\CustomUI + */ + public static function create() { + $customUI = new CustomUI(); + return $customUI; + } + + /** + * Construct a new CustomUI Object + */ + public function __construct() { + } + /** * Set XML Encoding * @@ -131,6 +147,7 @@ class CustomUI { $isChild = (bool) $domDocument; if (!$isChild) { $domDocument = new \DOMDocument('1.0', $this->encoding); + $domDocument->xmlStandalone = true; } $xmlElement = $domDocument->createElement($this->tagName); if (!$isChild) { diff --git a/application/core/FML/Elements/Dico.php b/application/core/FML/Elements/Dico.php new file mode 100644 index 00000000..c00a11af --- /dev/null +++ b/application/core/FML/Elements/Dico.php @@ -0,0 +1,274 @@ +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; + } +} diff --git a/application/core/FML/Elements/Format.php b/application/core/FML/Elements/Format.php index 1133e426..9703f27a 100644 --- a/application/core/FML/Elements/Format.php +++ b/application/core/FML/Elements/Format.php @@ -21,8 +21,24 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable { protected $style = ''; protected $textSize = -1; protected $textColor = ''; - protected $areaColor = ''; - protected $areaFocusColor = ''; + 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() { + } /** * @@ -70,7 +86,7 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable { * @return \FML\Elements\Format */ public function setAreaColor($areaColor) { - $this->areaColor = (string) $areaColor; + $this->focusAreaColor1 = (string) $areaColor; return $this; } @@ -80,7 +96,7 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable { * @return \FML\Elements\Format */ public function setAreaFocusColor($areaFocusColor) { - $this->areaFocusColor = (string) $areaFocusColor; + $this->focusAreaColor2 = (string) $areaFocusColor; return $this; } @@ -89,25 +105,25 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable { * @see \FML\Renderable::render() */ public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); + $formatXmlElement = $domDocument->createElement($this->tagName); if ($this->bgColor) { - $xmlElement->setAttribute('bgcolor', $this->bgColor); + $formatXmlElement->setAttribute('bgcolor', $this->bgColor); } if ($this->style) { - $xmlElement->setAttribute('style', $this->style); + $formatXmlElement->setAttribute('style', $this->style); } if ($this->textSize >= 0) { - $xmlElement->setAttribute('textsize', $this->textSize); + $formatXmlElement->setAttribute('textsize', $this->textSize); } if ($this->textColor) { - $xmlElement->setAttribute('textcolor', $this->textColor); + $formatXmlElement->setAttribute('textcolor', $this->textColor); } - if ($this->areaColor) { - $xmlElement->setAttribute('areacolor', $this->areaColor); + if ($this->focusAreaColor1) { + $formatXmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1); } - if ($this->areaFocusColor) { - $xmlElement->setAttribute('areafocuscolor', $this->areaFocusColor); + if ($this->focusAreaColor2) { + $formatXmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2); } - return $xmlElement; + return $formatXmlElement; } } diff --git a/application/core/FML/Elements/FrameModel.php b/application/core/FML/Elements/FrameModel.php new file mode 100644 index 00000000..99fff3db --- /dev/null +++ b/application/core/FML/Elements/FrameModel.php @@ -0,0 +1,116 @@ +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; + } +} diff --git a/application/core/FML/Elements/Including.php b/application/core/FML/Elements/Including.php index fcc5744f..c3a85784 100644 --- a/application/core/FML/Elements/Including.php +++ b/application/core/FML/Elements/Including.php @@ -16,6 +16,28 @@ class Including implements Renderable { 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 * diff --git a/application/core/FML/Elements/Music.php b/application/core/FML/Elements/Music.php index 49457d65..0008938c 100644 --- a/application/core/FML/Elements/Music.php +++ b/application/core/FML/Elements/Music.php @@ -16,6 +16,28 @@ class Music implements Renderable { 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 * diff --git a/application/core/FML/Elements/SimpleScript.php b/application/core/FML/Elements/SimpleScript.php index 16c0e178..a4a3f843 100644 --- a/application/core/FML/Elements/SimpleScript.php +++ b/application/core/FML/Elements/SimpleScript.php @@ -16,6 +16,28 @@ class SimpleScript implements Renderable { 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 * @@ -23,7 +45,7 @@ class SimpleScript implements Renderable { * @return \FML\Script\Script */ public function setText($text) { - $this->text = $text; + $this->text = (string) $text; return $this; } @@ -33,8 +55,10 @@ class SimpleScript implements Renderable { */ public function render(\DOMDocument $domDocument) { $xmlElement = $domDocument->createElement($this->tagName); - $scriptComment = $domDocument->createComment($this->text); - $xmlElement->appendChild($scriptComment); + if ($this->text) { + $scriptComment = $domDocument->createComment($this->text); + $xmlElement->appendChild($scriptComment); + } return $xmlElement; } } diff --git a/application/core/FML/ManiaCode.php b/application/core/FML/ManiaCode.php index f2ea07ed..2c1be431 100644 --- a/application/core/FML/ManiaCode.php +++ b/application/core/FML/ManiaCode.php @@ -2,22 +2,22 @@ namespace FML; -use FML\ManiaCode\Message; -use FML\ManiaCode\Element; -use FML\ManiaCode\ShowMessage; -use FML\ManiaCode\InstallMap; -use FML\ManiaCode\PlayMap; -use FML\ManiaCode\InstallReplay; -use FML\ManiaCode\ViewReplay; -use FML\ManiaCode\PlayReplay; -use FML\ManiaCode\InstallSkin; -use FML\ManiaCode\GetSkin; use FML\ManiaCode\AddBuddy; -use FML\ManiaCode\Go_To; -use FML\ManiaCode\JoinServer; use FML\ManiaCode\AddFavorite; -use FML\ManiaCode\InstallScript; +use FML\ManiaCode\Element; +use FML\ManiaCode\GetSkin; +use FML\ManiaCode\Go_To; +use FML\ManiaCode\InstallMap; use FML\ManiaCode\InstallPack; +use FML\ManiaCode\InstallReplay; +use FML\ManiaCode\InstallScript; +use FML\ManiaCode\InstallSkin; +use FML\ManiaCode\JoinServer; +use FML\ManiaCode\Message; +use FML\ManiaCode\PlayMap; +use FML\ManiaCode\PlayReplay; +use FML\ManiaCode\ShowMessage; +use FML\ManiaCode\ViewReplay; /** * Class representing a ManiaCode @@ -33,6 +33,22 @@ class ManiaCode { protected $noConfirmation = null; protected $elements = array(); + /** + * Create a new ManiaCode Object + * + * @return \FML\ManiaCode + */ + public static function create() { + $maniaCode = new ManiaCode(); + return $maniaCode; + } + + /** + * Construct a new ManiaCode Object + */ + public function __construct() { + } + /** * Set XML Encoding * @@ -265,6 +281,7 @@ class ManiaCode { */ public function render($echo = false) { $domDocument = new \DOMDocument('1.0', $this->encoding); + $domDocument->xmlStandalone = true; $maniaCode = $domDocument->createElement($this->tagName); $domDocument->appendChild($maniaCode); if ($this->noConfirmation) { @@ -275,7 +292,7 @@ class ManiaCode { $maniaCode->appendChild($xmlElement); } if ($echo) { - header('Content-Type: application/xml'); + header('Content-Type: application/xml; charset=utf-8;'); echo $domDocument->saveXML(); } return $domDocument; diff --git a/application/core/FML/ManiaCode/AddBuddy.php b/application/core/FML/ManiaCode/AddBuddy.php index 860314ee..2fe2410c 100644 --- a/application/core/FML/ManiaCode/AddBuddy.php +++ b/application/core/FML/ManiaCode/AddBuddy.php @@ -14,6 +14,17 @@ class AddBuddy implements Element { protected $tagName = 'add_buddy'; protected $login = ''; + /** + * Construct a new AddBuddy Element + * + * @param string $login (optional) Buddy Login + * @return \FML\ManiaCode\AddBuddy + */ + public static function create($login = null) { + $addBuddy = new AddBuddy($login); + return $addBuddy; + } + /** * Construct a new AddBuddy Element * diff --git a/application/core/FML/ManiaCode/AddFavorite.php b/application/core/FML/ManiaCode/AddFavorite.php index 87af3da8..64b1a274 100644 --- a/application/core/FML/ManiaCode/AddFavorite.php +++ b/application/core/FML/ManiaCode/AddFavorite.php @@ -16,6 +16,17 @@ class AddFavorite implements Element { protected $ip = null; protected $port = null; + /** + * Construct a new AddFavorite Element + * + * @param string $login (optional) Server Login + * @return \FML\ManiaCode\AddFavorite + */ + public static function create($login = null) { + $addFavorite = new AddFavorite($login); + return $addFavorite; + } + /** * Construct a new AddFavorite Element * diff --git a/application/core/FML/ManiaCode/GetSkin.php b/application/core/FML/ManiaCode/GetSkin.php index 8ac97240..8155a509 100644 --- a/application/core/FML/ManiaCode/GetSkin.php +++ b/application/core/FML/ManiaCode/GetSkin.php @@ -3,7 +3,7 @@ namespace FML\ManiaCode; /** - * ManiaCode Element getting a Skin + * ManiaCode Element downloading a Skin * * @author steeffeen */ @@ -16,6 +16,19 @@ class GetSkin implements Element { protected $file = ''; protected $url = ''; + /** + * Create a new GetSkin Element + * + * @param string $name (optional) Skin Name + * @param string $file (optional) Skin File + * @param string $url (optional) Skin Url + * @return \FML\ManiaCode\GetSkin + */ + public static function create($name = null, $file = null, $url = null) { + $getSkin = new GetSkin($name, $file, $url); + return $getSkin; + } + /** * Construct a new GetSkin Element * diff --git a/application/core/FML/ManiaCode/Go_To.php b/application/core/FML/ManiaCode/Go_To.php index 6e97a459..e525e6c1 100644 --- a/application/core/FML/ManiaCode/Go_To.php +++ b/application/core/FML/ManiaCode/Go_To.php @@ -14,6 +14,17 @@ class Go_To implements Element { protected $tagName = 'goto'; protected $link = ''; + /** + * Create a new Go_To Element + * + * @param string $link (optional) Goto Link + * @return \FML\ManiaCode\Go_To + */ + public static function create($link = null) { + $goTo = new Go_To($link); + return $goTo; + } + /** * Construct a new Go_To Element * diff --git a/application/core/FML/ManiaCode/InstallMap.php b/application/core/FML/ManiaCode/InstallMap.php index f920174a..bbc286a6 100644 --- a/application/core/FML/ManiaCode/InstallMap.php +++ b/application/core/FML/ManiaCode/InstallMap.php @@ -15,6 +15,18 @@ class InstallMap implements Element { protected $name = ''; protected $url = ''; + /** + * Create a new InstallMap Element + * + * @param string $name (optional) Map Name + * @param string $url (optional) Map Url + * @return \FML\ManiaCode\InstallMap + */ + public static function create($name = null, $url = null) { + $installMap = new InstallMap($name, $url); + return $installMap; + } + /** * Construct a new InstallMap Element * diff --git a/application/core/FML/ManiaCode/InstallPack.php b/application/core/FML/ManiaCode/InstallPack.php index 5c3ff147..013a5b37 100644 --- a/application/core/FML/ManiaCode/InstallPack.php +++ b/application/core/FML/ManiaCode/InstallPack.php @@ -16,6 +16,19 @@ class InstallPack implements Element { protected $file = ''; protected $url = ''; + /** + * Create a new InstallPack Element + * + * @param string $name (optional) Pack Name + * @param string $file (optional) Pack File + * @param string $url (optional) Pack Url + * @return \FML\ManiaCode\InstallPack + */ + public static function create($name = null, $file = null, $url = null) { + $installPack = new InstallPack($name, $file, $url); + return $installPack; + } + /** * Construct a new InstallPack Element * @@ -40,7 +53,7 @@ class InstallPack implements Element { * * @param string $name Pack Name * @return \FML\ManiaCode\InstallPack - */ + */ public function setName($name) { $this->name = (string) $name; return $this; diff --git a/application/core/FML/ManiaCode/InstallReplay.php b/application/core/FML/ManiaCode/InstallReplay.php index 62b68625..cfb38255 100644 --- a/application/core/FML/ManiaCode/InstallReplay.php +++ b/application/core/FML/ManiaCode/InstallReplay.php @@ -15,6 +15,18 @@ class InstallReplay implements Element { protected $name = ''; protected $url = ''; + /** + * Create a new InstallReplay Element + * + * @param string $name (optional) Replay Name + * @param string $url (optional) Replay Url + * @return \FML\ManiaCode\InstallReplay + */ + public static function create($name = null, $url = null) { + $installReplay = new InstallReplay($name, $url); + return $installReplay; + } + /** * Construct a new InstallReplay Element * diff --git a/application/core/FML/ManiaCode/InstallScript.php b/application/core/FML/ManiaCode/InstallScript.php index 4ce76383..2613c30a 100644 --- a/application/core/FML/ManiaCode/InstallScript.php +++ b/application/core/FML/ManiaCode/InstallScript.php @@ -16,6 +16,19 @@ class InstallScript implements Element { protected $file = ''; protected $url = ''; + /** + * Create a new InstallScript Element + * + * @param string $name (optional) Script Name + * @param string $file (optional) Script File + * @param string $url (optional) Script Url + * @return \FML\ManiaCode\InstallScript + */ + public static function create($name = null, $file = null, $url = null) { + $installScript = new InstallScript($name, $file, $url); + return $installScript; + } + /** * Construct a new InstallScript Element * diff --git a/application/core/FML/ManiaCode/InstallSkin.php b/application/core/FML/ManiaCode/InstallSkin.php index 01a15b8a..4cac8bbc 100644 --- a/application/core/FML/ManiaCode/InstallSkin.php +++ b/application/core/FML/ManiaCode/InstallSkin.php @@ -16,6 +16,19 @@ class InstallSkin implements Element { protected $file = ''; protected $url = ''; + /** + * Create a new InstallSkin Element + * + * @param string $name (optional) Skin Name + * @param string $file (optional) Skin File + * @param string $url (optional) Skin Url + * @return \FML\ManiaCode\InstallSkin + */ + public static function create($name = null, $file = null, $url = null) { + $installSkin = new InstallSkin($name, $file, $url); + return $installSkin; + } + /** * Construct a new InstallSkin Element * diff --git a/application/core/FML/ManiaCode/JoinServer.php b/application/core/FML/ManiaCode/JoinServer.php index 96854064..4c54cada 100644 --- a/application/core/FML/ManiaCode/JoinServer.php +++ b/application/core/FML/ManiaCode/JoinServer.php @@ -16,6 +16,17 @@ class JoinServer implements Element { protected $ip = null; protected $port = null; + /** + * Create a new JoinServer Element + * + * @param string $login (optional) Server Login + * @return \FML\ManiaCode\JoinServer + */ + public static function create($login = null) { + $joinServer = new JoinServer($login); + return $joinServer; + } + /** * Construct a new JoinServer Element * diff --git a/application/core/FML/ManiaCode/PlayMap.php b/application/core/FML/ManiaCode/PlayMap.php index 07cca8d9..9227fd18 100644 --- a/application/core/FML/ManiaCode/PlayMap.php +++ b/application/core/FML/ManiaCode/PlayMap.php @@ -15,6 +15,18 @@ class PlayMap implements Element { protected $name = ''; protected $url = ''; + /** + * Create a new PlayMap Element + * + * @param string $name (optional) Map Name + * @param string $url (optional) Map Url + * @return \FML\ManiaCode\PlayMap + */ + public static function create($name = null, $url = null) { + $playMap = new PlayMap($name, $url); + return $playMap; + } + /** * Construct a new PlayMap Element * diff --git a/application/core/FML/ManiaCode/PlayReplay.php b/application/core/FML/ManiaCode/PlayReplay.php index 80e06d2d..a56fbd26 100644 --- a/application/core/FML/ManiaCode/PlayReplay.php +++ b/application/core/FML/ManiaCode/PlayReplay.php @@ -15,6 +15,18 @@ class PlayReplay implements Element { protected $name = ''; protected $url = ''; + /** + * Create a new PlayReplay Element + * + * @param string $name (optional) Replay Name + * @param string $url (optional) Replay Url + * @return \FML\ManiaCode\PlayReplay + */ + public static function create($name = null, $url = null) { + $playReplay = new PlayReplay($name, $url); + return $playReplay; + } + /** * Construct a new PlayReplay Element * diff --git a/application/core/FML/ManiaCode/ShowMessage.php b/application/core/FML/ManiaCode/ShowMessage.php index 4b94885a..fce4b631 100644 --- a/application/core/FML/ManiaCode/ShowMessage.php +++ b/application/core/FML/ManiaCode/ShowMessage.php @@ -14,6 +14,17 @@ class ShowMessage implements Element { protected $tagName = 'show_message'; protected $message = ''; + /** + * Create a new ShowMessage Element + * + * @param string $message (optional) Message Text + * @return \FML\ManiaCode\ShowMessage + */ + public static function create($message = null) { + $showMessage = new ShowMessage($message); + return $showMessage; + } + /** * Construct a new ShowMessage Element * diff --git a/application/core/FML/ManiaCode/ViewReplay.php b/application/core/FML/ManiaCode/ViewReplay.php index 6900e57e..0d35ec7d 100644 --- a/application/core/FML/ManiaCode/ViewReplay.php +++ b/application/core/FML/ManiaCode/ViewReplay.php @@ -15,6 +15,18 @@ class ViewReplay implements Element { protected $name = ''; protected $url = ''; + /** + * Create a new ViewReplay Element + * + * @param string $name (optional) Replay Name + * @param string $url (optional) Replay Url + * @return \FML\ManiaCode\ViewReplay + */ + public static function create($name = null, $url = null) { + $viewReplay = new ViewReplay($name, $url); + return $viewReplay; + } + /** * Construct a new ViewReplay Element * diff --git a/application/core/FML/ManiaLink.php b/application/core/FML/ManiaLink.php index 534742c4..0f19ac74 100644 --- a/application/core/FML/ManiaLink.php +++ b/application/core/FML/ManiaLink.php @@ -2,16 +2,25 @@ namespace FML; -use FML\Types\Container; use FML\Types\Renderable; use FML\Script\Script; +use FML\Elements\Dico; +use FML\Stylesheet\Stylesheet; /** * Class representing a ManiaLink * * @author steeffeen */ -class ManiaLink implements Container { +class ManiaLink { + /** + * Constants + */ + const BACKGROUND_0 = '0'; + const BACKGROUND_STARS = 'stars'; + const BACKGROUND_STATIONS = 'stations'; + const BACKGROUND_TITLE = 'title'; + /** * Protected Properties */ @@ -23,15 +32,30 @@ class ManiaLink implements Container { protected $navigable3d = 0; protected $timeout = 0; protected $children = array(); + protected $dico = null; + protected $stylesheet = null; protected $script = null; /** - * Create a new ManiaLink + * Create a new ManiaLink Object * - * @param string $id Manialink Id + * @param string $id (optional) Manialink Id + * @return \FML\ManiaLink + */ + public static function create($id = null) { + $maniaLink = new ManiaLink($id); + return $maniaLink; + } + + /** + * Construct a new ManiaLink Object + * + * @param string $id (optional) Manialink Id */ public function __construct($id = null) { - $this->setId($id); + if ($id !== null) { + $this->setId($id); + } } /** @@ -90,8 +114,8 @@ class ManiaLink implements Container { } /** + * Add an Element to the ManiaLink * - * @see \FML\Types\Container::add() * @return \FML\ManiaLink */ public function add(Renderable $child) { @@ -102,8 +126,8 @@ class ManiaLink implements Container { } /** + * Remove all Elements from the ManiaLinks * - * @see \FML\Types\Container::removeChildren() * @return \FML\ManiaLink */ public function removeChildren() { @@ -111,6 +135,54 @@ class ManiaLink implements Container { return $this; } + /** + * Set the Dictionary of the ManiaLink + * + * @param Dico $dico The Dictionary to use + * @return \FML\ManiaLink + */ + public function setDico(Dico $dico) { + $this->dico = $dico; + return $this; + } + + /** + * Get the current Dictionary of the ManiaLink + * + * @param bool $createIfEmpty (optional) Whether the Dico Object should be created if it's not set yet + * @return \FML\Elements\Dico + */ + public function getDico($createIfEmpty = true) { + if (!$this->dico && $createIfEmpty) { + $this->dico = new Dico(); + } + return $this->dico; + } + + /** + * Set the Stylesheet of the ManiaLink + * + * @param Stylesheet $stylesheet Stylesheet Object + * @return \FML\ManiaLink + */ + public function setStylesheet(Stylesheet $stylesheet) { + $this->stylesheet = $stylesheet; + return $this; + } + + /** + * Get the Stylesheet of the ManiaLink + * + * @param bool $createIfEmpty (optional) Whether the Script Object should be created if it's not set yet + * @return \FML\Stylesheet\Stylesheet + */ + public function getStylesheet($createIfEmpty = true) { + if (!$this->stylesheet && $createIfEmpty) { + $this->stylesheet = new Stylesheet(); + } + return $this->stylesheet; + } + /** * Set the Script of the ManiaLink * @@ -125,7 +197,7 @@ class ManiaLink implements Container { /** * Get the current Script of the ManiaLink * - * @param string $createIfEmpty (optional) Whether the Script Object should be created if it's not set yet + * @param bool $createIfEmpty (optional) Whether the Script Object should be created if it's not set yet * @return \FML\Script\Script */ public function getScript($createIfEmpty = true) { @@ -146,24 +218,25 @@ class ManiaLink implements Container { $isChild = (bool) $domDocument; if (!$isChild) { $domDocument = new \DOMDocument('1.0', $this->encoding); + $domDocument->xmlStandalone = true; } $maniaLink = $domDocument->createElement($this->tagName); if (!$isChild) { $domDocument->appendChild($maniaLink); } - if ($this->id !== null) { + if ($this->id) { $maniaLink->setAttribute('id', $this->id); } - if ($this->version !== null) { + if ($this->version) { $maniaLink->setAttribute('version', $this->version); } - if ($this->background !== null) { + if ($this->background) { $maniaLink->setAttribute('background', $this->background); } - if ($this->navigable3d !== null) { + if (!$this->navigable3d) { $maniaLink->setAttribute('navigable3d', $this->navigable3d); } - if ($this->timeout !== null) { + if ($this->timeout) { $timeoutXml = $domDocument->createElement('timeout', $this->timeout); $maniaLink->appendChild($timeoutXml); } @@ -171,6 +244,14 @@ class ManiaLink implements Container { $childXml = $child->render($domDocument); $maniaLink->appendChild($childXml); } + if ($this->dico) { + $dicoXml = $this->dico->render($domDocument); + $maniaLink->appendChild($dicoXml); + } + if ($this->stylesheet) { + $stylesheetXml = $this->stylesheet->render($domDocument); + $maniaLink->appendChild($stylesheetXml); + } if ($this->script) { $scriptXml = $this->script->render($domDocument); $maniaLink->appendChild($scriptXml); @@ -179,7 +260,7 @@ class ManiaLink implements Container { return $maniaLink; } if ($echo) { - header('Content-Type: application/xml'); + header('Content-Type: application/xml; charset=utf-8;'); echo $domDocument->saveXML(); } return $domDocument; diff --git a/application/core/FML/ManiaLinks.php b/application/core/FML/ManiaLinks.php index 0d10c33e..7d0251d7 100644 --- a/application/core/FML/ManiaLinks.php +++ b/application/core/FML/ManiaLinks.php @@ -16,6 +16,22 @@ class ManiaLinks { protected $children = array(); protected $customUI = null; + /** + * Create a new ManiaLinks Object + * + * @return \FML\ManiaLinks + */ + public static function create() { + $maniaLinks = new ManiaLinks(); + return $maniaLinks; + } + + /** + * Construct a new ManiaLinks Object + */ + public function __construct() { + } + /** * Set XML Encoding * @@ -61,6 +77,19 @@ class ManiaLinks { return $this; } + /** + * Get the current CustomUI + * + * @param bool $createIfEmpty (optional) Whether the CustomUI Object should be created if it's not set yet + * @return \FML\CustomUI + */ + public function getCustomUI($createIfEmpty = true) { + if (!$this->customUI && $createIfEmpty) { + $this->customUI = new CustomUI(); + } + return $this->customUI; + } + /** * Render the XML Document * @@ -69,6 +98,7 @@ class ManiaLinks { */ public function render($echo = false) { $domDocument = new \DOMDocument('1.0', $this->encoding); + $domDocument->xmlStandalone = true; $maniaLinks = $domDocument->createElement($this->tagName); $domDocument->appendChild($maniaLinks); foreach ($this->children as $child) { @@ -80,7 +110,7 @@ class ManiaLinks { $maniaLinks->appendChild($customUIXml); } if ($echo) { - header('Content-Type: application/xml'); + header('Content-Type: application/xml; charset=utf-8;'); echo $domDocument->saveXML(); } return $domDocument; diff --git a/application/core/FML/Script/Builder.php b/application/core/FML/Script/Builder.php index 3f3c2006..0fd8731e 100644 --- a/application/core/FML/Script/Builder.php +++ b/application/core/FML/Script/Builder.php @@ -21,10 +21,24 @@ abstract class Builder { return $labelText; } + /** + * Escape dangerous Characters in the given Text + * + * @param string $text Text to escape + * @return string + */ + public static function escapeText($text) { + $escapedText = $text; + $dangers = array('\\', '"'); + $replacements = array('\\\\', '\\"'); + $escapedText = str_ireplace($dangers, $replacements, $escapedText); + return $escapedText; + } + /** * Get the Real String-Representation of the given Value * - * @param float $value The Float Value to convert to a ManiaScript Real + * @param float $value The Float Value to convert to a ManiaScript Real * @return string */ public static function getReal($value) { diff --git a/application/core/FML/Script/Script.php b/application/core/FML/Script/Script.php index f17d0330..9a2c6de6 100644 --- a/application/core/FML/Script/Script.php +++ b/application/core/FML/Script/Script.php @@ -3,8 +3,8 @@ namespace FML\Script; use FML\Controls\Control; -use FML\Types\Scriptable; use FML\Controls\Label; +use FML\Types\Scriptable; /** * Class representing the ManiaLink Script @@ -31,6 +31,7 @@ class Script { const OPTION_TOOLTIP_TEXT = 'FML_Text_Tooltip'; const OPTION_TOGGLE_SHOW = 'FML_Show_Toggle'; const OPTION_TOGGLE_HIDE = 'FML_Hide_Toggle'; + const OPTION_PROFILE_OWN = 'FML_Own_Profile'; const LABEL_ONINIT = 'OnInit'; const LABEL_LOOP = 'Loop'; const LABEL_ENTRYSUBMIT = 'EntrySubmit'; @@ -60,6 +61,22 @@ class Script { protected $toggles = false; protected $spectate = false; + /** + * Create a new Script Object + * + * @return \FML\Script\Script + */ + public static function create() { + $script = new Script(); + return $script; + } + + /** + * Construct a new Script Object + */ + public function __construct() { + } + /** * Set an Include of the Script * @@ -223,6 +240,7 @@ class Script { * * @param Control $profileControl The Control opening a Profile * @param string $playerLogin The Player Login + * @param string $options,... (optional) Unlimited Number of Profile Options * @return \FML\Script\Script */ public function addProfileButton(Control $profileControl, $playerLogin) { @@ -234,6 +252,10 @@ class Script { $profileControl->addClass(self::CLASS_PROFILE); $playerLogin = (string) $playerLogin; $profileControl->addClass(self::CLASS_PROFILE . '-' . $playerLogin); + $options = $this->spliceParameters(func_get_args(), 2); + foreach ($options as $option => $value) { + $profileControl->addClass($option); + } $this->profile = true; return $this; } @@ -322,6 +344,7 @@ class Script { * @return \FML\Script\Script */ public function addSpectateButton(Control $clickControl, $spectateTargetLogin) { + // FIXME: current implementation doesn't support logins with dots in them ('nick.name') if (!($clickControl instanceof Scriptable)) { trigger_error('Scriptable Control needed as ClickControl for Spectating!'); return $this; @@ -419,12 +442,12 @@ class Script { $count = count($this->tooltipTexts); if ($count > 0) { foreach ($this->tooltipTexts as $tooltipId => $tooltipTexts) { - $constantText .= '"' . $tooltipId . '" => ['; + $constantText .= '"' . Builder::escapeText($tooltipId) . '" => ['; $subIndex = 0; $subCount = count($tooltipTexts); if ($subCount > 0) { foreach ($tooltipTexts as $hoverId => $text) { - $constantText .= '"' . $hoverId . '" => "' . $text . '"'; + $constantText .= '"' . Builder::escapeText($hoverId) . '" => "' . Builder::escapeText($text) . '"'; if ($subIndex < $subCount - 1) $constantText .= ', '; $subIndex++; } @@ -688,19 +711,18 @@ if (Event.Control.HasClass(\"" . self::CLASS_PAGER . "\")) { private function getProfileLabels() { if (!$this->profile) return ""; $this->setInclude('TextLib', 'TextLib'); + $prefixLength = strlen(self::CLASS_PROFILE) + 1; $profileScript = " if (Event.Control.HasClass(\"" . self::CLASS_PROFILE . "\")) { declare Login = LocalUser.Login; - foreach (ControlClass in Event.Control.ControlClasses) { - declare ClassParts = TextLib::Split(\"-\", ControlClass); - if (ClassParts.count < 2) continue; - if (ClassParts[0] != \"" . self::CLASS_PROFILE . "\") continue; - Login = \"\"; - for (Index, 1, ClassParts.count - 1) { - Login ^= ClassParts[Index]; - if (Index < ClassParts.count - 1) Login ^= \"-\"; + if (!Event.Control.HasClass(\"" . self::OPTION_PROFILE_OWN . "\") { + foreach (ControlClass in Event.Control.ControlClasses) { + declare ClassParts = TextLib::Split(\"-\", ControlClass); + if (ClassParts.count < 2) continue; + if (ClassParts[0] != \"" . self::CLASS_PROFILE . "\") continue; + Login = TextLib::SubText(ControlClass, {$prefixLength}, TextLib::Length(ControlClass)); + break; } - break; } ShowProfile(Login); }"; @@ -800,17 +822,16 @@ if (Event.Control.HasClass(\"" . self::CLASS_TOGGLE . "\")) { private function getSpectateLabels() { if (!$this->spectate) return ''; $this->setInclude('TextLib', 'TextLib'); + $prefixLength = strlen(self::CLASS_SPECTATE) + 1; $spectateScript = " if (Event.Control.HasClass(\"" . self::CLASS_SPECTATE . "\")) { declare Login = \"\"; - foreach (ControlClass in Event.Control.ControlClass) { + foreach (ControlClass in Event.Control.ControlClasses) { declare ClassParts = TextLib::Split(\"-\", ControlClass); if (ClassParts.count < 2) continue; if (ClassParts[0] != \"" . self::CLASS_SPECTATE . "\") continue; - for (Index, 1, ClassParts.count - 1) { - Login ^= ClassParts[Index]; - if (Index < ClassParts.count - 1) Login ^= \"-\"; - } + Login = TextLib::SubText(ControlClass, {$prefixLength}, TextLib::Length(ControlClass)); + break; } if (Login != \"\") { SetSpectateTarget(Login); diff --git a/application/core/FML/Stylesheet/Mood.php b/application/core/FML/Stylesheet/Mood.php new file mode 100644 index 00000000..74d3adb5 --- /dev/null +++ b/application/core/FML/Stylesheet/Mood.php @@ -0,0 +1,311 @@ +lAmbient_LinearRgb = "{$red} {$green} {$blue}"; + return $this; + } + + /** + * Set Minimum Value for the Background Color Range + * + * @param float $red Red Color Value + * @param float $green Green Color Value + * @param float $blue Blue Color Value + * @return \FML\Stylesheet\Mood + */ + public function setCloudsColorMin($red, $green, $blue) { + $red = (float) $red; + $green = (float) $green; + $blue = (float) $blue; + $this->cloudsRgbMinLinear = "{$red} {$green} {$blue}"; + return $this; + } + + /** + * Set Maximum Value for the Background Color Range + * + * @param float $red Red Color Value + * @param float $green Green Color Value + * @param float $blue Blue Color Value + * @return \FML\Stylesheet\Mood + */ + public function setCloudsColorMax($red, $green, $blue) { + $red = (float) $red; + $green = (float) $green; + $blue = (float) $blue; + $this->cloudsRgbMaxLinear = "{$red} {$green} {$blue}"; + return $this; + } + + /** + * Set RGB Color of Light Source 0 + * + * @param float $red Red Color Value + * @param float $green Green Color Value + * @param float $blue Blue Color Value + * @return \FML\Stylesheet\Mood + */ + public function setLight0Color($red, $green, $blue) { + $red = (float) $red; + $green = (float) $green; + $blue = (float) $blue; + $this->lDir0_LinearRgb = "{$red} {$green} {$blue}"; + return $this; + } + + /** + * Set Intensity of Light Source 0 + * + * @param float $intensity Light Intensity + * @return \FML\Stylesheet\Mood + */ + public function setLight0Intensity($intensity) { + $this->lDir0_Intens = (float) $intensity; + return $this; + } + + /** + * Set Phi-Angle of Light Source 0 + * + * @param float $phiAngle Phi-Angle + * @return \FML\Stylesheet\Mood + */ + public function setLight0PhiAngle($phiAngle) { + $this->lDir0_DirPhi = (float) $phiAngle; + return $this; + } + + /** + * Set Theta-Angle of Light Source 0 + * + * @param float $thetaAngle Theta-Angle + * @return \FML\Stylesheet\Mood + */ + public function setLight0ThetaAngle($thetaAngle) { + $this->lDir0_DirTheta = (float) $thetaAngle; + return $this; + } + + /** + * Set Light Ball Color + * + * @param float $red Red Color Value + * @param float $green Green Color Value + * @param float $blue Blue Color Value + * @return \FML\Stylesheet\Mood + */ + public function setLightBallColor($red, $green, $blue) { + $red = (float) $red; + $green = (float) $green; + $blue = (float) $blue; + $this->lBall_LinearRgb = "{$red} {$green} {$blue}"; + return $this; + } + + /** + * Set Light Ball Intensity + * + * @param float $intensity Light Ball Intensity + * @return \FML\Stylesheet\Mood + */ + public function setLightBallIntensity($intensity) { + $this->lBall_Intens = (float) $intensity; + return $this; + } + + /** + * Set Light Ball Radius + * + * @param float $radius Light Ball Radius + * @return \FML\Stylesheet\Mood + */ + public function setLightBallRadius($radius) { + $this->lBall_Radius = (float) $radius; + return $this; + } + + /** + * Set Fog Color + * + * @param float $red Red Color Value + * @param float $green Green Color Value + * @param float $blue Blue Color Value + * @return \FML\Stylesheet\Mood + */ + public function setFogColor($red, $green, $blue) { + $red = (float) $red; + $green = (float) $green; + $blue = (float) $blue; + $this->fogColorSrgb = "{$red} {$green} {$blue}"; + return $this; + } + + /** + * Set Self Illumination Color + * + * @param float $red Red Color Value + * @param float $green Green Color Value + * @param float $blue Blue Color Value + * @return \FML\Stylesheet\Mood + */ + public function setSelfIllumColor($red, $green, $blue) { + $red = (float) $red; + $green = (float) $green; + $blue = (float) $blue; + $this->selfIllumColor = "{$red} {$green} {$blue}"; + return $this; + } + + /** + * Set Sky Gradient Scale + * + * @param float $vScale Gradient Scale Scale + * @return \FML\Stylesheet\Mood + */ + public function setSkyGradientScale($scale) { + $this->skyGradientV_Scale = (float) $scale; + return $this; + } + + /** + * Add a Key for the SkyGradient + * + * @param float $x Scale Value + * @param string $color Gradient Color + * @return \FML\Stylesheet\Mood + */ + public function addSkyGradientKey($x, $color) { + $x = (float) $x; + $color = (string) $color; + $gradientKey = array('x' => $x, 'color' => $color); + array_push($this->skyGradientKeys, $gradientKey); + return $this; + } + + /** + * Remove all SkyGradient Keys + * + * @return \FML\Stylesheet\Mood + */ + public function removeSkyGradientKeys() { + $this->skyGradientKeys = array(); + return $this; + } + + /** + * Render the Mood XML Element + * + * @param \DOMDocument $domDocument DomDocument for which the Mood XML Element should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) { + $moodXml = $domDocument->createElement($this->tagName); + if ($this->lAmbient_LinearRgb) { + $moodXml->setAttribute('LAmbient_LinearRgb', $this->lAmbient_LinearRgb); + } + if ($this->cloudsRgbMinLinear) { + $moodXml->setAttribute('CloudsRgbMinLinear', $this->cloudsRgbMinLinear); + } + if ($this->cloudsRgbMaxLinear) { + $moodXml->setAttribute('CloudsRgbMaxLinear', $this->cloudsRgbMaxLinear); + } + if ($this->lDir0_LinearRgb) { + $moodXml->setAttribute('LDir0_LinearRgb', $this->lDir0_LinearRgb); + } + if ($this->lDir0_Intens) { + $moodXml->setAttribute('LDir0_Intens', $this->lDir0_Intens); + } + if ($this->lDir0_DirPhi) { + $moodXml->setAttribute('LDir0_DirPhi', $this->lDir0_DirPhi); + } + if ($this->lDir0_DirTheta) { + $moodXml->setAttribute('LDir0_DirTheta', $this->lDir0_DirTheta); + } + if ($this->lBall_LinearRgb) { + $moodXml->setAttribute('LBall_LinearRgb', $this->lBall_LinearRgb); + } + if ($this->lBall_Intens) { + $moodXml->setAttribute('LBall_Intens', $this->lBall_Intens); + } + if ($this->lBall_Radius) { + $moodXml->setAttribute('LBall_Radius', $this->lBall_Radius); + } + if ($this->fogColorSrgb) { + $moodXml->setAttribute('FogColorSrgb', $this->fogColorSrgb); + } + if ($this->selfIllumColor) { + $moodXml->setAttribute('SelfIllumColor', $this->selfIllumColor); + } + if ($this->skyGradientV_Scale) { + $moodXml->setAttribute('SkyGradientV_Scale', $this->skyGradientV_Scale); + } + if ($this->skyGradientKeys) { + $skyGradientXml = $domDocument->createElement('skygradient'); + $moodXml->appendChild($skyGradientXml); + foreach ($this->skyGradientKeys as $gradientKey) { + $keyXml = $domDocument->createElement('key'); + $skyGradientXml->appendChild($keyXml); + $keyXml->setAttribute('x', $gradientKey['x']); + $keyXml->setAttribute('color', $gradientKey['color']); + } + } + return $moodXml; + } +} diff --git a/application/core/FML/Stylesheet/Style3d.php b/application/core/FML/Stylesheet/Style3d.php new file mode 100644 index 00000000..980f573a --- /dev/null +++ b/application/core/FML/Stylesheet/Style3d.php @@ -0,0 +1,245 @@ +setId($id); + } + } + + /** + * Set Style Id + * + * @param string $id Style Id + * @return \FML\Stylesheet\Style3d + */ + public function setId($id) { + $this->id = (string) $id; + return $this; + } + + /** + * Check for Id and assign one if necessary + * + * @return \FML\Stylesheet\Style3d + */ + public function checkId() { + if (!$this->id) { + $this->id = uniqid(); + } + return $this; + } + + /** + * Get Style Id + * + * @return string + */ + public function getId() { + return $this->id; + } + + /** + * Set Model + * + * @param string $model Style Model + * @return \FML\Stylesheet\Style3d + */ + public function setModel($model) { + $this->model = (string) $model; + return $this; + } + + /** + * Set Thickness + * + * @param float $thickness Style Thickness + * @return \FML\Stylesheet\Style3d + */ + public function setThickness($thickness) { + $this->thickness = (float) $thickness; + return $this; + } + + /** + * Set Color + * + * @param string $color Style Color + * @return \FML\Stylesheet\Style3d + */ + public function setColor($color) { + $this->color = (string) $color; + return $this; + } + + /** + * Set Focus Color + * + * @param string $focusColor Style Focus Color + * @return \FML\Stylesheet\Style3d + */ + public function setFocusColor($focusColor) { + $this->focusColor = (string) $focusColor; + return $this; + } + + /** + * Set Light Color + * + * @param string $lightColor Light Color + * @return \FML\Stylesheet\Style3d + */ + public function setLightColor($lightColor) { + $this->lightColor = (string) $lightColor; + return $this; + } + + /** + * Set Focus Light Color + * + * @param string $focusLightColor Focus Light Color + * @return \FML\Stylesheet\Style3d + */ + public function setFocusLightColor($focusLightColor) { + $this->focusLightColor = (string) $focusLightColor; + return $this; + } + + /** + * Set Y-Offset + * + * @param flaot $yOffset Y-Offset + * @return \FML\Stylesheet\Style3d + */ + public function setYOffset($yOffset) { + $this->yOffset = (float) $yOffset; + return $this; + } + + /** + * Set Focus Y-Offset + * + * @param float $focusYOffset Focus Y-Offset + * @return \FML\Stylesheet\Style3d + */ + public function setFocusYOffset($focusYOffset) { + $this->focusYOffset = (float) $focusYOffset; + return $this; + } + + /** + * Set Z-Offset + * + * @param float $zOffset Z-Offset + * @return \FML\Stylesheet\Style3d + */ + public function setZOffset($zOffset) { + $this->zOffset = (float) $zOffset; + return $this; + } + + /** + * Set Focus Z-Offset + * + * @param float $focusZOffset Focus Z-Offset + * @return \FML\Stylesheet\Style3d + */ + public function setFocusZOffset($focusZOffset) { + $this->focusZOffset = (float) $focusZOffset; + return $this; + } + + /** + * Render the Style3d XML Element + * + * @param \DOMDocument $domDocument DomDocument for which the Style3d XML Element should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) { + $style3dXml = $domDocument->createElement($this->tagName); + $this->checkId(); + if ($this->id) { + $style3dXml->setAttribute('id', $this->id); + } + if ($this->model) { + $style3dXml->setAttribute('model', $this->model); + } + if ($this->thickness) { + $style3dXml->setAttribute('thickness', $this->thickness); + } + if ($this->color) { + $style3dXml->setAttribute('color', $this->color); + } + if ($this->focusColor) { + $style3dXml->setAttribute('fcolor', $this->focusColor); + } + if ($this->lightColor) { + $style3dXml->setAttribute('lightcolor', $this->lightColor); + } + if ($this->focusLightColor) { + $style3dXml->setAttribute('flightcolor', $this->focusLightColor); + } + if ($this->yOffset) { + $style3dXml->setAttribute('yoffset', $this->yOffset); + } + if ($this->focusYOffset) { + $style3dXml->setAttribute('fyoffset', $this->focusYOffset); + } + if ($this->zOffset) { + $style3dXml->setAttribute('zoffset', $this->zOffset); + } + if ($this->focusZOffset) { + $style3dXml->setAttribute('fzoffset', $this->focusZOffset); + } + return $style3dXml; + } +} diff --git a/application/core/FML/Stylesheet/Stylesheet.php b/application/core/FML/Stylesheet/Stylesheet.php new file mode 100644 index 00000000..a9850775 --- /dev/null +++ b/application/core/FML/Stylesheet/Stylesheet.php @@ -0,0 +1,103 @@ +styles3d, true)) { + array_push($this->styles3d, $style3d); + } + return $this; + } + + /** + * Remove all Styles + * + * @return \FML\Stylesheet\Frame3dStyles + */ + public function removeStyles() { + $this->styles3d = array(); + return $this; + } + + /** + * Set the Mood Object of the Stylesheet + * + * @param Mood $mood Mood Object + * @return \FML\Stylesheet\Stylesheet + */ + public function setMood(Mood $mood) { + $this->mood = $mood; + return $this; + } + + /** + * Get the Mood Object + * + * @param bool $createIfEmpty (optional) Whether the Mood Object should be created if it's not set yet + * @return \FML\Stylesheet\Mood + */ + public function getMood($createIfEmpty = true) { + if (!$this->mood && $createIfEmpty) { + $this->mood = new Mood(); + } + return $this->mood; + } + + /** + * Render the Stylesheet XML Element + * + * @param \DOMDocument $domDocument DomDocument for which the Stylesheet XML Element should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) { + $stylesheetXml = $domDocument->createElement($this->tagName); + if ($this->styles3d) { + $stylesXml = $domDocument->createElement('frame3dstyles'); + $stylesheetXml->appendChild($stylesXml); + foreach ($this->styles3d as $style3d) { + $style3dXml = $style3d->render($domDocument); + $stylesXml->appendChild($style3dXml); + } + } + if ($this->mood) { + $moodXml = $this->mood->render($domDocument); + $stylesheetXml->appendChild($moodXml); + } + return $stylesheetXml; + } +} diff --git a/application/core/FML/Types/Container.php b/application/core/FML/Types/Container.php index 233b3553..353232bf 100644 --- a/application/core/FML/Types/Container.php +++ b/application/core/FML/Types/Container.php @@ -2,22 +2,44 @@ namespace FML\Types; +use FML\Controls\Control; +use FML\Elements\Format; + /** - * Interface for Elements being able to contain other Elements + * Interface for Element being able to contain other Controls * * @author steeffeen */ interface Container { /** - * Add a new Child + * Add a new Child Control * - * @param Renderable $child The Child Element to add + * @param Control $child The Child Control to add + * @return \FML\Types\Container */ - public function add(Renderable $child); + public function add(Control $child); /** * Remove all Children + * + * @return \FML\Types\Container */ public function removeChildren(); + + /** + * Set the Format Object of the Container + * + * @param Format $format New Format Object + * @return \FML\Types\Container + */ + public function setFormat(Format $format); + + /** + * Get the Format Object of the Container + * + * @param bool $createIfEmpty (optional) Whether the Format Object should be created if it's not set yet + * @return \FML\Elements\Format + */ + public function getFormat($createIfEmpty = true); } diff --git a/application/core/FML/Types/Linkable.php b/application/core/FML/Types/Linkable.php index 3cfed015..59dd432d 100644 --- a/application/core/FML/Types/Linkable.php +++ b/application/core/FML/Types/Linkable.php @@ -16,10 +16,24 @@ interface Linkable { */ public function setUrl($url); + /** + * Set Url Id to use from the Dico + * + * @param string $urlId + */ + public function setUrlId($urlId); + /** * Set Manialink * * @param string $manialink Manialink Name */ public function setManialink($manialink); + + /** + * Set Manialink Id to use from the Dico + * + * @param string $manialinkId Manialink Id + */ + public function setManialinkId($manialinkId); } diff --git a/application/core/FML/Types/Playable.php b/application/core/FML/Types/Playable.php index 30754175..f8a1e573 100644 --- a/application/core/FML/Types/Playable.php +++ b/application/core/FML/Types/Playable.php @@ -16,6 +16,13 @@ interface Playable { */ public function setData($data); + /** + * Set Data Id to use from the Dico + * + * @param string $dataId + */ + public function setDataId($dataId); + /** * Set Play *