Updated to ManiaLink v3

This commit is contained in:
Jocy Wolff 2017-03-25 18:40:15 +01:00
parent 1010c1db6b
commit 120a0e2169
133 changed files with 16194 additions and 8949 deletions

View File

@ -10,6 +10,7 @@ use FML\Controls\Quads\Quad_BgsPlayerCard;
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
use FML\ManiaLink;
use FML\Script\Features\Paging;
use FML\Script\Script;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl;
@ -88,9 +89,10 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
//Create ManiaLink
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
$script = $maniaLink->getScript();
$paging = new Paging();
$script = new Script();
$script->addFeature($paging);
$maniaLink->setScript($script);
// Main frame
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
@ -120,7 +122,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
$pageFrame = new Frame();
$frame->add($pageFrame);
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height / 2 - 10;
}

View File

@ -9,6 +9,7 @@ use FML\Controls\Quads\Quad_BgRaceScore2;
use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
use FML\ManiaLink;
use FML\Script\Script;
use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
@ -134,8 +135,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
* @param Player $player
*/
public function handleConfigCommand(array $callback, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_OPEN_CONFIGURATOR)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_OPEN_CONFIGURATOR)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -199,15 +199,16 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
$frame = new Frame();
$manialink->add($frame);
$frame->setPosition($menuPosX, $menuPosY, 34);
$frame->setPosition($menuPosX, $menuPosY, ManialinkManager::MAIN_MANIALINK_Z_VALUE);
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$backgroundQuad->setZ(-2)->setSize($menuWidth, $menuHeight)->setStyles($quadStyle, $quadSubstyle);
$backgroundQuad->setZ(-1)->setSize($menuWidth, $menuHeight)->setStyles($quadStyle, $quadSubstyle);
$menuItemsFrame = new Frame();
$frame->add($menuItemsFrame);
$menuItemsFrame->setX($menuWidth * -0.5 + $menuListWidth * 0.5);
$menuItemsFrame->setZ(-1);
$itemsBackgroundQuad = new Quad();
$menuItemsFrame->add($itemsBackgroundQuad);
@ -226,8 +227,9 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
foreach ($this->menus as $menu) {
// Add title
$menuItemLabel = new Label_Text();
$menuItemsFrame->add($menuItemLabel);
$menuItemLabel->setY($menuItemY)->setSize($menuListWidth * 0.9, $menuItemHeight * 0.9)->setStyle($menuItemLabel::STYLE_TextCardRaceRank)->setText($menu->getTitle())->setAction(self::ACTION_SELECTMENU . $menuId);
$frame->add($menuItemLabel);
$menuItemLabel->setX($menuWidth * -0.5 + $menuListWidth * 0.5);
$menuItemLabel->setZ(2)->setStyle(Label_Text::STYLE_TextCardRaceRank)->setY($menuItemY)->setSize($menuListWidth * 0.9, $menuItemHeight * 0.9)->setText($menu->getTitle())->setAction(self::ACTION_SELECTMENU . $menuId);
// Show the menu
if ($menuId === $menuIdShown) {
@ -251,12 +253,12 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
// Add close button
$closeButton = new Label_Text();
$frame->add($closeButton);
$closeButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.29, $menuHeight * -0.43)->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)->setStyle($closeButton::STYLE_TextButtonNavBack)->setTextPrefix('$999')->setTranslate(true)->setText('Close')->setAction(self::ACTION_TOGGLEMENU);
$closeButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.29, $menuHeight * -0.43)->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)->setStyle($closeButton::STYLE_TextButtonNavBack)->setTextPrefix('$999')->setText('Close')->setAction(self::ACTION_TOGGLEMENU);
// Add save button
$saveButton = new Label_Text();
$frame->add($saveButton);
$saveButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.71, $menuHeight * -0.43)->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)->setStyle($saveButton::STYLE_TextButtonNavBack)->setTextPrefix('$0f5')->setTranslate(true)->setText('Save')->setAction(self::ACTION_SAVECONFIG);
$saveButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.71, $menuHeight * -0.43)->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)->setStyle($saveButton::STYLE_TextButtonNavBack)->setTextPrefix('$2af')->setText('Save')->setAction(self::ACTION_SAVECONFIG);
return $manialink;
}

View File

@ -59,14 +59,14 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle()
*/
public static function getTitle() {
return self::TITLE;
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
*/
public function getMenu($width, $height, Script $script, Player $player) {
$openedClass = $player->getCache($this, self::CACHE_CLASS_OPENED);
@ -112,8 +112,8 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
$paging->addButton($pagerNext);
$paging->addButton($pagerPrev);
$paging->addButtonControl($pagerNext);
$paging->addButtonControl($pagerPrev);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
@ -150,7 +150,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
if ($index % $pageMaxCount === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height * 0.41 - $settingHeight * 1.5;
}
@ -239,8 +239,8 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
$paging->addButton($pagerNext);
$paging->addButton($pagerPrev);
$paging->addButtonControl($pagerNext);
$paging->addButtonControl($pagerPrev);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
@ -258,7 +258,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
$pageFrame = new Frame();
$frame->add($pageFrame);
$posY = $height * 0.41;
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
}
$classLabel = new Label_Text();

View File

@ -221,8 +221,8 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
$paging->addButton($pagerNext);
$paging->addButton($pagerPrev);
$paging->addButtonControl($pagerNext);
$paging->addButtonControl($pagerPrev);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
@ -249,7 +249,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
$pageFrame = new Frame();
$frame->add($pageFrame);
$posY = $height * 0.41;
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
}
$settingFrame = new Frame();
@ -293,8 +293,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
$descriptionLabel->setSize($width * 0.7, $settingHeight);
$descriptionLabel->setTextSize($labelTextSize);
$descriptionLabel->setTranslate(true);
$descriptionLabel->setText($scriptParam->desc);
$nameLabel->addTooltipFeature($descriptionLabel);
$nameLabel->addTooltipLabelFeature($descriptionLabel, $scriptParam->desc);
$posY -= $settingHeight;
}

View File

@ -189,7 +189,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
$pageFrame = new Frame();
$frame->add($pageFrame);
$posY = $height / 2 - 16;
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
}
// Map Frame

View File

@ -31,6 +31,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
const ACTION_CLOSEWIDGET = 'ManiaLinkManager.CloseWidget';
const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed';
const CB_MAIN_WINDOW_OPENED = 'ManialinkManagerCallback.MainWindowOpened';
const MAIN_MANIALINK_Z_VALUE = 10;
/*
* Public properties
@ -236,6 +237,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
public function sendManialink($manialinkText, $logins = null, $timeout = 0, $hideOnClick = false) {
$manialinkText = (string) $manialinkText;
var_dump($manialinkText);
if (!$manialinkText) {
return true;
}

View File

@ -193,7 +193,7 @@ class StyleManager {
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)->setPosition($width * 0.40, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(1.3);
if ($paging) {
$paging->addButton($pagerNext)->addButton($pagerPrev)->setLabel($pageCountLabel);
$paging->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel);
}
}

View File

@ -253,7 +253,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$pageFrame = new Frame();
$frame->add($pageFrame);
$posY = $height / 2 - 10;
$paging->addPage($pageFrame, $pageNumber);
$paging->addPageControl($pageFrame, $pageNumber);
$pageNumber++;
}

View File

@ -179,7 +179,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$pageFrame = new Frame();
$frame->add($pageFrame);
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height / 2 - 10;
}

View File

@ -53,14 +53,14 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle()
*/
public static function getTitle() {
return 'Install Plugins';
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
*/
public function getMenu($width, $height, Script $script, Player $player) {
$paging = new Paging();
@ -102,7 +102,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)->setPosition($width * 0.35, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(2);
$paging->addButton($pagerNext)->addButton($pagerPrev)->setLabel($pageCountLabel);
$paging->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel);
// Info tooltip
$infoTooltipLabel = new Label();
@ -121,7 +121,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
// New page
$pageFrame = new Frame();
$frame->add($pageFrame);
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height * 0.41;
}
@ -221,7 +221,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
* @see \ManiaControl\Configurator\ConfiguratorMenu::saveConfigData()
*/
public function saveConfigData(array $configData, Player $player) {
}

View File

@ -69,7 +69,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle()
*/
public static function getTitle() {
return 'Plugins';
@ -87,7 +87,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
*/
public function getMenu($width, $height, Script $script, Player $player) {
$paging = new Paging();
@ -114,8 +114,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
$paging->addButton($pagerNext);
$paging->addButton($pagerPrev);
$paging->addButtonControl($pagerNext);
$paging->addButtonControl($pagerPrev);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
@ -149,7 +149,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
if ($index % $pageMaxCount === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height * 0.41;
}
@ -186,11 +186,10 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$descriptionLabel->setTextSize(2);
$descriptionLabel->setTranslate(true);
$descriptionLabel->setVisible(false);
$descriptionLabel->setAutoNewLine(true);
$descriptionLabel->setMaxLines(5);
$descriptionLabel->setLineSpacing(1);
$description = "Author: {$pluginClass::getAuthor()}\nVersion: {$pluginClass::getVersion()}\nDesc: {$pluginClass::getDescription()}";
$descriptionLabel->setText($description);
$nameLabel->addTooltipFeature($descriptionLabel);
$nameLabel->addTooltipLabelFeature($descriptionLabel,$description);
$quad = new Quad_Icons128x32_1();
$pluginFrame->add($quad);
@ -278,7 +277,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
if ($index % $pageSettingsMaxCount === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height * 0.41 - $settingHeight * 1.5;
}
@ -392,7 +391,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
* @see \ManiaControl\Configurator\ConfiguratorMenu::saveConfigData()
*/
public function saveConfigData(array $configData, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS)

View File

@ -104,7 +104,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle()
*/
public static function getTitle() {
return 'Server Options';
@ -241,7 +241,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
*/
public function getMenu($width, $height, Script $script, Player $player) {
$paging = new Paging();
@ -269,7 +269,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)->setPosition($width * 0.35, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(2);
$paging->addButton($pagerNext)->addButton($pagerPrev)->setLabel($pageCountLabel);
$paging->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel);
// Pages
$posY = 0.;
@ -287,7 +287,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList
$pageFrame = new Frame();
$frame->add($pageFrame);
$posY = $height * 0.41;
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
}
$optionsFrame = new Frame();
@ -326,7 +326,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
* @see \ManiaControl\Configurator\ConfiguratorMenu::saveConfigData()
*/
public function saveConfigData(array $configData, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SERVER_OPTIONS)) {

View File

@ -5,7 +5,6 @@ namespace FML\Components;
use FML\Controls\Entry;
use FML\Controls\Frame;
use FML\Controls\Quad;
use FML\Models\CheckBoxDesign;
use FML\Script\Features\CheckBoxFeature;
use FML\Script\Features\ScriptFeature;
use FML\Types\Renderable;
@ -14,61 +13,115 @@ use FML\Types\ScriptFeatureable;
/**
* CheckBox Component
*
* @uses Quad
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CheckBox implements Renderable, ScriptFeatureable {
/*
* Protected properties
class CheckBox implements Renderable, ScriptFeatureable
{
/**
* @var string $name CheckBox name
*/
protected $name = null;
/**
* @var CheckBoxFeature $feature CheckBox Feature
*/
protected $feature = null;
/**
* Create a new CheckBox Component
* Construct a new CheckBox
*
* @api
* @param string $name (optional) CheckBox name
* @param bool $default (optional) Default value
* @param Quad $quad (optional) CheckBox quad
*/
public function __construct($name = null, $default = null, Quad $quad = null) {
public function __construct($name = null, $default = null, Quad $quad = null)
{
$this->feature = new CheckBoxFeature();
if ($name) {
$this->setName($name);
}
if ($default !== null) {
$this->setDefault($default);
}
if ($quad) {
$this->setQuad($quad);
}
}
/**
* Get the name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the name
*
* @api
* @param string $name CheckBox name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Get the default value
*
* @api
* @return bool
*/
public function getDefault()
{
return $this->feature->getDefault();
}
/**
* Set the default value
*
* @api
* @param bool $default Default value
* @return static
*/
public function setDefault($default) {
public function setDefault($default)
{
$this->feature->setDefault($default);
return $this;
}
/**
* Set the enabled Design
* Get the enabled design
*
* @param string $style Style name or image url
* @api
* @return CheckBoxDesign
*/
public function getEnabledDesign()
{
return $this->feature->getEnabledDesign();
}
/**
* Set the enabled design
*
* @api
* @param string|CheckBoxDesign $style Style name, image url or checkbox design
* @param string $subStyle SubStyle name
* @return static
*/
public function setEnabledDesign($style, $subStyle = null) {
public function setEnabledDesign($style, $subStyle = null)
{
if ($style instanceof CheckBoxDesign) {
$this->feature->setEnabledDesign($style);
} else {
@ -79,13 +132,26 @@ class CheckBox implements Renderable, ScriptFeatureable {
}
/**
* Set the disabled Design
* Get the disabled design
*
* @param string $style Style name or image url
* @api
* @return CheckBoxDesign
*/
public function getDisabledDesign()
{
return $this->feature->getDisabledDesign();
}
/**
* Set the disabled design
*
* @api
* @param string|CheckBoxDesign $style Style name, image url or checkbox design
* @param string $subStyle SubStyle name
* @return static
*/
public function setDisabledDesign($style, $subStyle = null) {
public function setDisabledDesign($style, $subStyle = null)
{
if ($style instanceof CheckBoxDesign) {
$this->feature->setDisabledDesign($style);
} else {
@ -95,63 +161,109 @@ class CheckBox implements Renderable, ScriptFeatureable {
return $this;
}
/**
* Get the CheckBox Quad
*
* @api
* @return Quad
*/
public function getQuad()
{
$quad = $this->feature->getQuad();
if ($quad) {
return $quad;
}
return $this->createQuad();
}
/**
* Set the CheckBox Quad
*
* @api
* @param Quad $quad CheckBox Quad
* @return static
*/
public function setQuad(Quad $quad = null) {
public function setQuad(Quad $quad)
{
$this->feature->setQuad($quad);
return $this;
}
/**
* @see \FML\Types\ScriptFeatureable::getScriptFeatures()
* Create the CheckBox Quad
*
* @return Quad
*/
public function getScriptFeatures() {
protected function createQuad()
{
$quad = new Quad();
$quad->setSize(10, 10);
$this->setQuad($quad);
return $quad;
}
/**
* Get the hidden Entry
*
* @return Entry
*/
public function getEntry()
{
$entry = $this->feature->getEntry();
if ($entry) {
return $entry;
}
return $this->createEntry();
}
/**
* Set the hidden Entry
*
* @param Entry $entry Hidden Entry
* @return static
*/
public function setEntry(Entry $entry)
{
$this->feature->setEntry($entry);
return $this;
}
/**
* Create the hidden Entry
*
* @return Entry
*/
protected function createEntry()
{
$entry = new Entry();
$entry->setVisible(false)
->setName($this->name);
$this->setEntry($entry);
return $entry;
}
/**
* @see ScriptFeatureable::getScriptFeatures()
*/
public function getScriptFeatures()
{
return ScriptFeature::collect($this->feature, $this->getQuad(), $this->feature->getEntry());
}
/**
* Get the CheckBox Quad
*
* @param bool $createIfEmpty (optional) Create the Quad if it's not set
* @return \FML\Controls\Quad
* @see Renderable::render()
*/
public function getQuad($createIfEmpty = true) {
if (!$this->feature->getQuad() && $createIfEmpty) {
$quad = new Quad();
$quad->setSize(10, 10);
$this->setQuad($quad);
}
return $this->feature->getQuad();
}
/**
* @see \FML\Types\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
public function render(\DOMDocument $domDocument)
{
$frame = new Frame();
$quad = $this->getQuad();
$frame->add($quad);
$frame->addChild($quad);
$entry = $this->buildEntry();
$frame->add($entry);
$this->feature->setEntry($entry);
$entry = $this->getEntry();
$frame->addChild($entry);
return $frame->render($domDocument);
}
/**
* Build the hidden Entry
*
* @return \FML\Controls\Entry
*/
protected function buildEntry() {
$entry = new Entry();
$entry->setVisible(false)->setName($this->name);
return $entry;
}
}

View File

@ -0,0 +1,163 @@
<?php
namespace FML\Components;
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\Types\Imageable;
use FML\Types\Styleable;
use FML\Types\SubStyleable;
/**
* Class representing CheckBox Design
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CheckBoxDesign implements Imageable, Styleable, SubStyleable
{
/**
* @var string $style Style name
*/
protected $style = null;
/**
* @var string $subStyle SubStyle name
*/
protected $subStyle = null;
/**
* @var string $imageUrl Image url
*/
protected $imageUrl = null;
/**
* Create the default Design
*
* @return static
*/
public static function defaultDesign()
{
return new static(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_Check);
}
/**
* Construct a new CheckBox Design
*
* @api
* @param string $style (optional) Style name or image url
* @param string $subStyle (optional) SubStyle name
*/
public function __construct($style = null, $subStyle = null)
{
if ($subStyle) {
$this->setStyles($style, $subStyle);
} elseif ($style) {
$this->setImageUrl($style);
}
}
/**
* @see Styleable::getStyle()
*/
public function getStyle()
{
return $this->style;
}
/**
* @see Styleable::setStyle()
*/
public function setStyle($style)
{
$this->style = (string)$style;
$this->url = null;
return $this;
}
/**
* @see SubStyleable::getSubStyle()
*/
public function getSubStyle()
{
return $this->subStyle;
}
/**
* @see SubStyleable::setSubStyle()
*/
public function setSubStyle($subStyle)
{
$this->subStyle = (string)$subStyle;
$this->url = null;
return $this;
}
/**
* @see SubStyleable::setStyles()
*/
public function setStyles($style, $subStyle)
{
return $this->setStyle($style)
->setSubStyle($subStyle);
}
/**
* Get the image url
*
* @api
* @return string
*/
public function getImageUrl()
{
return $this->imageUrl;
}
/**
* Set the image url
*
* @api
* @param string $imageUrl Image url
* @return static
*/
public function setImageUrl($imageUrl)
{
$this->style = null;
$this->subStyle = null;
$this->imageUrl = (string)$imageUrl;
return $this;
}
/**
* Apply the Design to the given Quad
*
* @api
* @param Quad $quad CheckBox Quad
* @return static
*/
public function applyToQuad(Quad $quad)
{
if ($this->imageUrl) {
$quad->setImageUrl($this->imageUrl);
} elseif ($this->style) {
$quad->setStyles($this->style, $this->subStyle);
}
return $this;
}
/**
* Get the CheckBox Design string
*
* @return string
*/
public function getDesignString()
{
if ($this->imageUrl) {
return $this->imageUrl;
}
return $this->style . "|" . $this->subStyle;
}
}

View File

@ -13,122 +13,224 @@ use FML\Types\ScriptFeatureable;
/**
* ValuePicker Component
*
* @uses Entry
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ValuePicker implements Renderable, ScriptFeatureable {
/*
* Protected properties
class ValuePicker implements Renderable, ScriptFeatureable
{
/**
* @var string $name ValuePicker name
*/
protected $name = null;
/**
* @var ValuePickerFeature $feature ValuePicker Feature
*/
protected $feature = null;
/**
* Create a new ValuePicker Component
* Create a new ValuePicker
*
* @param string $name (optional) CheckBox name
* @param array $values (optional) Possible values
* @param bool $default (optional) Default value
* @api
* @param string $name (optional) ValuePicker name
* @param string[] $values (optional) Possible values
* @param string $default (optional) Default value
* @param Label $label (optional) ValuePicker label
*/
public function __construct($name = null, array $values = array(), $default = null, Label $label = null) {
public function __construct($name = null, array $values = null, $default = null, Label $label = null)
{
$this->feature = new ValuePickerFeature();
if ($name) {
$this->setName($name);
}
if ($values) {
$this->setValues($values);
}
if ($default !== null) {
$this->setDefault($default);
}
if ($label) {
$this->setLabel($label);
}
}
/**
* Set Name
* Get the name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the name
*
* @api
* @param string $name ValuePicker name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Get the possible values
*
* @api
* @return string[]
*/
public function getValues()
{
return $this->feature->getValues();
}
/**
* Set the possible values
*
* @api
* @param array $values Possible values
* @return static
*/
public function setValues(array $values) {
public function setValues(array $values)
{
$this->feature->setValues($values);
return $this;
}
/**
* Get the default value
*
* @api
* @return string
*/
public function getDefault()
{
return $this->feature->getDefault();
}
/**
* Set the default value
*
* @api
* @param bool $default Default value
* @return static
*/
public function setDefault($default) {
public function setDefault($default)
{
$this->feature->setDefault($default);
return $this;
}
/**
* Set the ValuePicker Label
* Get the Label
*
* @api
* @return Label
*/
public function getLabel()
{
$label = $this->feature->getLabel();
if ($label) {
return $label;
}
return $this->createLabel();
}
/**
* Set the Label
*
* @api
* @param Label $label ValuePicker Label
* @return static
*/
public function setLabel(Label $label = null) {
public function setLabel(Label $label)
{
$this->feature->setLabel($label);
return $this;
}
/**
* Get the ValuePicker Label
* Create the Label
*
* @param bool $createIfEmpty (optional) Create the Label if it's not set
* @return \FML\Controls\Label
* @return Label
*/
public function getLabel($createIfEmpty = true) {
if (!$this->feature->getLabel() && $createIfEmpty) {
protected function createLabel()
{
$label = new Label();
$this->setLabel($label);
}
return $this->feature->getLabel();
return $label;
}
/**
* @see \FML\Types\ScriptFeatureable::getScriptFeatures()
* Get the hidden Entry
*
* @return Entry
*/
public function getScriptFeatures() {
public function getEntry()
{
$entry = $this->feature->getEntry();
if ($entry) {
return $entry;
}
return $this->createEntry();
}
/**
* Set the hidden Entry
*
* @param Entry $entry Hidden Entry
* @return static
*/
public function setEntry(Entry $entry)
{
$this->feature->setEntry($entry);
return $this;
}
/**
* Create the hidden Entry
*
* @return Entry
*/
protected function createEntry()
{
$entry = new Entry();
$entry->setVisible(false)
->setName($this->name);
$this->setEntry($entry);
return $entry;
}
/**
* @see ScriptFeatureable::getScriptFeatures()
*/
public function getScriptFeatures()
{
return ScriptFeature::collect($this->feature, $this->getLabel(), $this->feature->getEntry());
}
/**
* @see \FML\Types\Renderable::render()
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
public function render(\DOMDocument $domDocument)
{
$frame = new Frame();
$label = $this->getLabel();
$frame->add($label);
$frame->addChild($label);
$entry = $this->buildEntry();
$frame->add($entry);
$this->feature->setEntry($entry);
$entry = $this->getEntry();
$frame->addChild($entry);
return $frame->render($domDocument);
}
/**
* Build the hidden Entry
*
* @return \FML\Controls\Entry
*/
protected function buildEntry() {
$entry = new Entry();
$entry->setVisible(false)->setName($this->name);
return $entry;
}
}

View File

@ -10,108 +10,262 @@ use FML\Types\Scriptable;
* (CMlMediaPlayer)
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Audio extends Control implements Playable, Scriptable {
/*
* Protected properties
class Audio extends Control implements Playable, Scriptable
{
/**
* @var string $data Data url
*/
protected $tagName = 'audio';
protected $data = null;
/**
* @var string $dataId Data id
*/
protected $dataId = null;
/**
* @var bool $play Play automaticcaly
*/
protected $play = null;
/**
* @var bool $looping Looping
*/
protected $looping = true;
/**
* @var bool $music Music type
*/
protected $music = null;
/**
* @var float $volume Volume
*/
protected $volume = 1.;
/**
* @var bool $scriptEvents Script events usage
*/
protected $scriptEvents = null;
/**
* @see \FML\Controls\Control::getManiaScriptClass()
* @var string $scriptAction Script action
*/
public function getManiaScriptClass() {
return 'CMlMediaPlayer';
protected $scriptAction = null;
/**
* @var string[] $scriptActionParameters Script action parameters
*/
protected $scriptActionParameters = null;
/**
* @see Playable::getData()
*/
public function getData()
{
return $this->data;
}
/**
* @see \FML\Types\Playable::setData()
* @see Playable::setData()
*/
public function setData($data) {
public function setData($data)
{
$this->data = (string)$data;
return $this;
}
/**
* @see \FML\Types\Playable::setDataId()
* @see Playable::getDataId()
*/
public function setDataId($dataId) {
public function getDataId()
{
return $this->dataId;
}
/**
* @see Playable::setDataId()
*/
public function setDataId($dataId)
{
$this->dataId = (string)$dataId;
return $this;
}
/**
* @see \FML\Types\Playable::setPlay()
* @see Playable::getPlay()
*/
public function setPlay($play) {
$this->play = ($play ? 1 : 0);
public function getPlay()
{
return $this->play;
}
/**
* @see Playable::setPlay()
*/
public function setPlay($play)
{
$this->play = (bool)$play;
return $this;
}
/**
* @see \FML\Types\Playable::setLooping()
* @see Playable::getLooping()
*/
public function setLooping($looping) {
$this->looping = ($looping ? 1 : 0);
public function getLooping()
{
return $this->looping;
}
/**
* @see Playable::setLooping()
*/
public function setLooping($looping)
{
$this->looping = (bool)$looping;
return $this;
}
/**
* @see \FML\Types\Playable::setMusic()
* @see Playable::getMusic()
*/
public function setMusic($music) {
$this->music = ($music ? 1 : 0);
public function getMusic()
{
return $this->music;
}
/**
* @see Playable::setMusic()
*/
public function setMusic($music)
{
$this->music = (bool)$music;
return $this;
}
/**
* @see \FML\Types\Playable::setVolume()
* @see Playable::getVolume()
*/
public function setVolume($volume) {
public function getVolume()
{
return $this->volume;
}
/**
* @see Playable::setVolume()
*/
public function setVolume($volume)
{
$this->volume = (float)$volume;
return $this;
}
/**
* @see \FML\Types\Scriptable::setScriptEvents()
* @see Scriptable::getScriptEvents()
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
public function getScriptEvents()
{
return $this->scriptEvents;
}
/**
* @see Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents)
{
$this->scriptEvents = (bool)$scriptEvents;
return $this;
}
/**
* @see \FML\Types\Renderable::render()
* @see Scriptable::getScriptAction()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
public function getScriptAction()
{
return $this->scriptAction;
}
/**
* @see Scriptable::setScriptAction()
*/
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
{
$this->scriptAction = (string)$scriptAction;
$this->setScriptActionParameters($scriptActionParameters);
return $this;
}
/**
* @see Scriptable::getScriptActionParameters()
*/
public function getScriptActionParameters()
{
return $this->scriptActionParameters;
}
/**
* @see Scriptable::setScriptActionParameters()
*/
public function setScriptActionParameters(array $scriptActionParameters = null)
{
$this->scriptActionParameters = $scriptActionParameters;
return $this;
}
/**
* @see Control::getTagName()
*/
public function getTagName()
{
return "audio";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlMediaPlayer";
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->data) {
$xmlElement->setAttribute('data', $this->data);
$domElement->setAttribute("data", $this->data);
}
if ($this->dataId) {
$domElement->setAttribute("dataid", $this->dataId);
}
if ($this->play) {
$xmlElement->setAttribute('play', $this->play);
$domElement->setAttribute("play", 1);
}
if (!$this->looping) {
$xmlElement->setAttribute('looping', $this->looping);
$domElement->setAttribute("looping", 0);
}
if ($this->music) {
$xmlElement->setAttribute('music', $this->music);
$domElement->setAttribute("music", 1);
}
if ($this->volume != 1.) {
$xmlElement->setAttribute('volume', $this->volume);
$domElement->setAttribute("volume", $this->volume);
}
if ($this->scriptEvents) {
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
$domElement->setAttribute("scriptevents", 1);
}
return $xmlElement;
if ($this->scriptAction) {
$scriptAction = array($this->scriptAction);
if ($this->scriptActionParameters) {
$scriptAction = array_merge($scriptAction, $this->scriptActionParameters);
}
$domElement->setAttribute("scriptaction", implode("'", $scriptAction));
}
return $domElement;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
namespace FML\Controls;
use FML\Form\Parameters;
use FML\Script\Features\EntrySubmit;
use FML\Types\NewLineable;
use FML\Types\Scriptable;
@ -13,49 +14,115 @@ use FML\Types\TextFormatable;
* (CMlEntry)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable {
class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable
{
/*
* Protected properties
* Constants
*/
const FORMAT_Default = "Default";
const FORMAT_Password = "Password";
const FORMAT_NewPassword = "NewPassword";
/**
* @var string $name Entry name
*/
protected $tagName = 'entry';
protected $name = null;
/**
* @var string $default Default value
*/
protected $default = null;
/**
* @var bool $selectText Select text
*/
protected $selectText = null;
/**
* @deprecated
* @var bool $autoNewLine Auto new line
*/
protected $autoNewLine = null;
/**
* @var string $textFormat Text format
*/
protected $textFormat = null;
/**
* @var bool $scriptEvents Script events usage
*/
protected $scriptEvents = null;
/**
* @var string $scriptAction Script action
*/
protected $scriptAction = null;
/**
* @var string[] $scriptActionParameters Script action parameters
*/
protected $scriptActionParameters = null;
/**
* @var string $style Style
*/
protected $style = null;
/**
* @var string $textColor Text color
*/
protected $textColor = null;
protected $textSize = -1;
/**
* @var int $textSize Text size
*/
protected $textSize = null;
/**
* @var string $textFont Text font
*/
protected $textFont = null;
protected $focusAreaColor1 = null;
protected $focusAreaColor2 = null;
/**
* @var string $areaColor Area color
*/
protected $areaColor = null;
/**
* @var string $focusAreaColor Focus area color
*/
protected $focusAreaColor = null;
/**
* @var bool $autoComplete Auto complete
*/
protected $autoComplete = null;
/**
* @see \FML\Controls\Control::getManiaScriptClass()
*/
public function getManiaScriptClass() {
return 'CMlEntry';
}
/**
* Get the Entry name
* Get the name
*
* @api
* @return string
*/
public function getName() {
public function getName()
{
return $this->name;
}
/**
* Set Entry name
* Set the name
*
* @api
* @param string $name Entry name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
@ -63,94 +130,266 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/**
* Get the default value
*
* @api
* @return mixed
*/
public function getDefault() {
public function getDefault()
{
return $this->default;
}
/**
* Set default value
* Set the default value
*
* @api
* @param string $default Default value
* @return static
*/
public function setDefault($default) {
public function setDefault($default)
{
$this->default = $default;
return $this;
}
/**
* @see \FML\Types\NewLineable::setAutoNewLine()
* Get select text
*
* @api
* @return bool
*/
public function setAutoNewLine($autoNewLine) {
$this->autoNewLine = ($autoNewLine ? 1 : 0);
public function getSelectText()
{
return $this->selectText;
}
/**
* Set select text
*
* @api
* @param bool $selectText Select text
* @return static
*/
public function setSelectText($selectText)
{
$this->selectText = $selectText;
return $this;
}
/**
* @see \FML\Types\Scriptable::setScriptEvents()
* @see NewLineable::getAutoNewLine()
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
public function getAutoNewLine()
{
return $this->autoNewLine;
}
/**
* @see NewLineable::setAutoNewLine()
*/
public function setAutoNewLine($autoNewLine)
{
$this->autoNewLine = (bool)$autoNewLine;
return $this;
}
/**
* @see \FML\Types\Styleable::setStyle()
* Get text format
*
* @api
* @return string
*/
public function setStyle($style) {
public function getTextFormat()
{
return $this->textFormat;
}
/**
* Set text format
*
* @api
* @param string $textFormat Text format
* @return static
*/
public function setTextFormat($textFormat)
{
$this->textFormat = $textFormat;
return $this;
}
/**
* @see Scriptable::getScriptEvents()
*/
public function getScriptEvents()
{
return $this->scriptEvents;
}
/**
* @see Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents)
{
$this->scriptEvents = (bool)$scriptEvents;
return $this;
}
/**
* @see Scriptable::getScriptAction()
*/
public function getScriptAction()
{
return $this->scriptAction;
}
/**
* @see Scriptable::setScriptAction()
*/
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
{
$this->scriptAction = (string)$scriptAction;
$this->setScriptActionParameters($scriptActionParameters);
return $this;
}
/**
* @see Scriptable::getScriptActionParameters()
*/
public function getScriptActionParameters()
{
return $this->scriptActionParameters;
}
/**
* @see Scriptable::setScriptActionParameters()
*/
public function setScriptActionParameters(array $scriptActionParameters = null)
{
$this->scriptActionParameters = $scriptActionParameters;
return $this;
}
/**
* @see Styleable::getStyle()
*/
public function getStyle()
{
return $this->style;
}
/**
* @see Styleable::setStyle()
*/
public function setStyle($style)
{
$this->style = (string)$style;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setTextColor()
* @see TextFormatable::getTextColor()
*/
public function setTextColor($textColor) {
public function getTextColor()
{
return $this->textColor;
}
/**
* @see TextFormatable::setTextColor()
*/
public function setTextColor($textColor)
{
$this->textColor = (string)$textColor;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setTextSize()
* @see TextFormatable::getTextSize()
*/
public function setTextSize($textSize) {
public function getTextSize()
{
return $this->textSize;
}
/**
* @see TextFormatable::setTextSize()
*/
public function setTextSize($textSize)
{
$this->textSize = (int)$textSize;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setTextFont()
* @see TextFormatable::getTextFont()
*/
public function setTextFont($textFont) {
public function getTextFont()
{
return $this->textFont;
}
/**
* @see TextFormatable::setTextFont()
*/
public function setTextFont($textFont)
{
$this->textFont = (string)$textFont;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setAreaColor()
* @see TextFormatable::getAreaColor()
*/
public function setAreaColor($areaColor) {
$this->focusAreaColor1 = (string)$areaColor;
public function getAreaColor()
{
return $this->areaColor;
}
/**
* @see TextFormatable::setAreaColor()
*/
public function setAreaColor($areaColor)
{
$this->areaColor = (string)$areaColor;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setAreaFocusColor()
* @see TextFormatable::getAreaFocusColor()
*/
public function setAreaFocusColor($areaFocusColor) {
$this->focusAreaColor2 = (string)$areaFocusColor;
public function getAreaFocusColor()
{
return $this->focusAreaColor;
}
/**
* @see TextFormatable::setAreaFocusColor()
*/
public function setAreaFocusColor($areaFocusColor)
{
$this->focusAreaColor = (string)$areaFocusColor;
return $this;
}
/**
* Get auto completion
*
* @api
* @return bool
*/
public function getAutoComplete()
{
return $this->autoComplete;
}
/**
* Set auto completion
*
* @param bool $autoComplete Whether the default value should be automatically completed based on the current request parameters
* @api
* @param bool $autoComplete Automatically complete the default value based on the current request parameters
* @return static
*/
public function setAutoComplete($autoComplete) {
public function setAutoComplete($autoComplete)
{
$this->autoComplete = (bool)$autoComplete;
return $this;
}
@ -158,60 +397,87 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/**
* Add a dynamic Feature submitting the Entry
*
* @api
* @param string $url Submit url
* @return static
*/
public function addSubmitFeature($url) {
public function addSubmitFeature($url)
{
$entrySubmit = new EntrySubmit($this, $url);
$this->addScriptFeature($entrySubmit);
return $this;
return $this->addScriptFeature($entrySubmit);
}
/**
* @see \FML\Types\Renderable::render()
* @see Control::getTagName()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
public function getTagName()
{
return "entry";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlEntry";
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->name) {
$xmlElement->setAttribute('name', $this->name);
$domElement->setAttribute("name", $this->name);
}
if ($this->default !== null) {
$xmlElement->setAttribute('default', $this->default);
$domElement->setAttribute("default", $this->default);
} else if ($this->autoComplete) {
$value = null;
if (array_key_exists($this->name, $_GET)) {
$value = $_GET[$this->name];
} else if (array_key_exists($this->name, $_POST)) {
$value = $_POST[$this->name];
}
$value = Parameters::getValue($this->name);
if ($value) {
$xmlElement->setAttribute('default', $value);
$domElement->setAttribute("default", $value);
}
}
if ($this->selectText) {
$domElement->setAttribute("selecttext", 1);
}
if ($this->autoNewLine) {
$xmlElement->setAttribute('autonewline', $this->autoNewLine);
$domElement->setAttribute("autonewline", 1);
}
if ($this->textFormat) {
$domElement->setAttribute("textformat", $this->textFormat);
}
if ($this->scriptEvents) {
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
$domElement->setAttribute("scriptevents", 1);
}
if ($this->scriptAction) {
$scriptAction = array($this->scriptAction);
if ($this->scriptActionParameters) {
$scriptAction = array_merge($scriptAction, $this->scriptActionParameters);
}
$domElement->setAttribute("scriptaction", implode("'", $scriptAction));
}
if ($this->style) {
$xmlElement->setAttribute('style', $this->style);
$domElement->setAttribute("style", $this->style);
}
if ($this->textColor) {
$xmlElement->setAttribute('textcolor', $this->textColor);
$domElement->setAttribute("textcolor", $this->textColor);
}
if ($this->textSize >= 0.) {
$xmlElement->setAttribute('textsize', $this->textSize);
if ($this->textSize) {
$domElement->setAttribute("textsize", $this->textSize);
}
if ($this->textFont) {
$xmlElement->setAttribute('textfont', $this->textFont);
$domElement->setAttribute("textfont", $this->textFont);
}
if ($this->focusAreaColor1) {
$xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1);
if ($this->areaColor) {
$domElement->setAttribute("focusareacolor1", $this->areaColor);
}
if ($this->focusAreaColor2) {
$xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2);
if ($this->focusAreaColor) {
$domElement->setAttribute("focusareacolor2", $this->focusAreaColor);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -7,42 +7,67 @@ namespace FML\Controls;
* (CMlFileEntry)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class FileEntry extends Entry {
/*
* Protected properties
class FileEntry extends Entry
{
/**
* @var string $folder Folder
*/
protected $tagName = 'fileentry';
protected $folder = null;
/**
* @see \FML\Controls\Control::getManiaScriptClass()
* Get the folder
*
* @api
* @return string
*/
public function getManiaScriptClass() {
return 'CMlFileEntry';
public function getFolder()
{
return $this->folder;
}
/**
* Set the base folder
* Set the folder
*
* @api
* @param string $folder Base folder
* @return static
*/
public function setFolder($folder) {
public function setFolder($folder)
{
$this->folder = (string)$folder;
return $this;
}
/**
* @see \FML\Types\Renderable::render()
* @see Control::getTagName()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
public function getTagName()
{
return "fileentry";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlFileEntry";
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->folder) {
$xmlElement->setAttribute('folder', $this->folder);
$domElement->setAttribute("folder", $this->folder);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -12,30 +12,44 @@ use FML\Types\ScriptFeatureable;
* (CMlFrame)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Frame extends Control implements Container {
/*
* Protected properties
class Frame extends Control implements Container
{
/**
* @var Renderable[] $children Children
*/
protected $tagName = 'frame';
/** @var Renderable[] $children */
protected $children = array();
/** @var Format $format */
/**
* @var Format $format Format
*/
protected $format = null;
/**
* @see \FML\Controls\Control::getManiaScriptClass()
* @see Container::getChildren()
*/
public function getManiaScriptClass() {
return 'CMlFrame';
public function getChildren()
{
return $this->children;
}
/**
* @see \FML\Types\Container::add()
* @see Container::addChild()
* @deprecated use addChild() instead
*/
public function add(Renderable $child) {
public function add(Renderable $child)
{
return $this->addChild($child);
}
/**
* @see Container::addChild()
*/
public function addChild(Renderable $child)
{
if (!in_array($child, $this->children, true)) {
array_push($this->children, $child);
}
@ -43,35 +57,63 @@ class Frame extends Control implements Container {
}
/**
* @see \FML\Types\Container::removeChildren()
* @see Container::addChildren()
*/
public function removeChildren() {
public function addChildren(array $children)
{
foreach ($children as $child) {
$this->addChild($child);
}
return $this;
}
/**
* @see Container::removeAllChildren()
*/
public function removeAllChildren()
{
$this->children = array();
return $this;
}
/**
* @see \FML\Types\Container::getFormat()
* @see Container::getFormat()
*/
public function getFormat($createIfEmpty = true) {
if (!$this->format && $createIfEmpty) {
$this->setFormat(new Format());
}
public function getFormat()
{
return $this->format;
}
/**
* @see \FML\Types\Container::setFormat()
* @see Container::setFormat()
*/
public function setFormat(Format $format) {
public function setFormat(Format $format = null)
{
$this->format = $format;
return $this;
}
/**
* @see \FML\Controls\Control::getScriptFeatures()
* @see Control::getTagName()
*/
public function getScriptFeatures() {
public function getTagName()
{
return "frame";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlFrame";
}
/**
* @see Control::getScriptFeatures()
*/
public function getScriptFeatures()
{
$scriptFeatures = $this->scriptFeatures;
foreach ($this->children as $child) {
if ($child instanceof ScriptFeatureable) {
@ -82,18 +124,20 @@ class Frame extends Control implements Container {
}
/**
* @see \FML\Types\Renderable::render()
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->format) {
$formatXml = $this->format->render($domDocument);
$xmlElement->appendChild($formatXml);
$domElement->appendChild($formatXml);
}
foreach ($this->children as $child) {
$childXmlElement = $child->render($domDocument);
$xmlElement->appendChild($childXmlElement);
$domElement->appendChild($childXmlElement);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -10,16 +10,18 @@ use FML\Types\Scriptable;
* (CMlFrame)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Frame3d extends Frame implements Scriptable {
class Frame3d extends Frame implements Scriptable
{
/*
* Constants
*/
const STYLE_BaseStation = 'BaseStation';
const STYLE_BaseBoxCase = 'BaseBoxCase';
const STYLE_Titlelogo = 'Titlelogo';
const STYLE_TitleLogo = 'Titlelogo';
const STYLE_ButtonBack = 'ButtonBack';
const STYLE_ButtonNav = 'ButtonNav';
const STYLE_ButtonH = 'ButtonH';
@ -28,61 +30,164 @@ class Frame3d extends Frame implements Scriptable {
const STYLE_TitleEditor = 'TitleEditor';
const STYLE_Window = 'Window';
/*
* Protected properties
/**
* @var string $style3dId Style3d id
*/
protected $tagName = 'frame3d';
protected $style3dId = null;
/** @var Style3d $style3d */
/**
* @var Style3d $style3d Style3d
*/
protected $style3d = null;
/**
* @var bool $scriptEvents Script events usage
*/
protected $scriptEvents = null;
/**
* Set Style3d id
* @var string[] $scriptActionParameters Script action parameters
*/
protected $scriptActionParameters = null;
/**
* @var string $scriptAction Script action
*/
protected $scriptAction = null;
/**
* Get the Style3d id
*
* @api
* @return string
*/
public function getStyle3dId()
{
return $this->style3dId;
}
/**
* Set the Style3d id
*
* @api
* @param string $style3dId Style3d id
* @return static
*/
public function setStyle3dId($style3dId) {
public function setStyle3dId($style3dId)
{
$this->style3dId = (string)$style3dId;
$this->style3d = null;
return $this;
}
/**
* Set Style3d
* Get the Style3d
*
* @param Style3d $style3d Style3d object
* @api
* @return Style3d
*/
public function getStyle3d()
{
return $this->style3d;
}
/**
* Set the Style3d
*
* @api
* @param Style3d $style3d Style3d
* @return static
*/
public function setStyle3d(Style3d $style3d) {
$this->style3d = $style3d;
public function setStyle3d(Style3d $style3d)
{
$this->style3dId = null;
$this->style3d = $style3d;
return $this;
}
/**
* @see \FML\Types\Scriptable::setScriptEvents()
* @see Scriptable::getScriptEvents()
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
public function getScriptEvents()
{
return $this->scriptEvents;
}
/**
* @see Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents)
{
$this->scriptEvents = (bool)$scriptEvents;
return $this;
}
/**
* @see \FML\Types\Renderable::render()
* @see Scriptable::getScriptAction()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
public function getScriptAction()
{
return $this->scriptAction;
}
/**
* @see Scriptable::setScriptAction()
*/
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
{
$this->scriptAction = (string)$scriptAction;
$this->setScriptActionParameters($scriptActionParameters);
return $this;
}
/**
* @see Scriptable::getScriptActionParameters()
*/
public function getScriptActionParameters()
{
return $this->scriptActionParameters;
}
/**
* @see Scriptable::setScriptActionParameters()
*/
public function setScriptActionParameters(array $scriptActionParameters = null)
{
$this->scriptActionParameters = $scriptActionParameters;
return $this;
}
/**
* @see Control::getTagName()
*/
public function getTagName()
{
return "frame3d";
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->style3d) {
$this->style3d->checkId();
$xmlElement->setAttribute('style3d', $this->style3d->getId());
$domElement->setAttribute("style3d", $this->style3d->getId());
} else if ($this->style3dId) {
$xmlElement->setAttribute('style3d', $this->style3dId);
$domElement->setAttribute("style3d", $this->style3dId);
}
if ($this->scriptEvents) {
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
$domElement->setAttribute("scriptevents", 1);
}
return $xmlElement;
if ($this->scriptAction) {
$scriptAction = array($this->scriptAction);
if ($this->scriptActionParameters) {
$scriptAction = array_merge($scriptAction, $this->scriptActionParameters);
}
$domElement->setAttribute("scriptaction", implode("'", $scriptAction));
}
return $domElement;
}
}

View File

@ -9,84 +9,101 @@ use FML\Elements\FrameModel;
* (CMlFrame)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class FrameInstance extends Control {
/*
* Protected properties
class FrameInstance extends Control
{
/**
* @var string $modelId FrameModel id
*/
protected $tagName = 'frameinstance';
protected $modelId = null;
/** @var FrameModel $model */
/**
* @var FrameModel $model FrameModel
*/
protected $model = null;
/**
* Create a new Frame Instance object
* Get the FrameModel id
*
* @param string $modelId (optional) Frame Model id
* @param string $controlId (optional) Frame id
* @return static
* @api
* @return string
*/
public static function create($modelId = null, $controlId = null) {
return new static($modelId, $controlId);
public function getModelId()
{
return $this->modelId;
}
/**
* Construct a new Frame Instance object
* Set the FrameModel id
*
* @param string $modelId (optional) Frame Model id
* @param string $controlId (optional) Frame id
*/
public function __construct($modelId = null, $controlId = null) {
parent::__construct($controlId);
if ($modelId !== null) {
$this->setModelId($modelId);
}
}
/**
* Set Frame Model id
*
* @param string $modelId Frame Model id
* @api
* @param string $modelId FrameModel id
* @return static
*/
public function setModelId($modelId) {
public function setModelId($modelId)
{
$this->modelId = (string)$modelId;
$this->model = null;
return $this;
}
/**
* Set Frame Model
* Get the FrameModel
*
* @param FrameModel $frameModel Frame Model
* @api
* @return FrameModel
*/
public function getModel()
{
return $this->model;
}
/**
* Set the FrameModel
*
* @api
* @param FrameModel $frameModel FrameModel
* @return static
*/
public function setModel(FrameModel $frameModel) {
$this->model = $frameModel;
public function setModel(FrameModel $frameModel)
{
$this->modelId = null;
$this->model = $frameModel;
return $this;
}
/**
* @see \FML\Controls\Control::getManiaScriptClass()
* @see Control::getTagName()
*/
public function getManiaScriptClass() {
return 'CMlFrame';
public function getTagName()
{
return "frameinstance";
}
/**
* @see \FML\Renderable::render()
* @see Control::getManiaScriptClass()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
public function getManiaScriptClass()
{
return "CMlFrame";
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->model) {
$this->model->checkId();
$xmlElement->setAttribute('modelid', $this->model->getId());
$domElement->setAttribute("modelid", $this->model->getId());
} else if ($this->modelId) {
$xmlElement->setAttribute('modelid', $this->modelId);
$domElement->setAttribute("modelid", $this->modelId);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -2,6 +2,7 @@
namespace FML\Controls;
use FML\Types\Colorable;
use FML\Types\Styleable;
/**
@ -9,152 +10,298 @@ use FML\Types\Styleable;
* (CMlGauge)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Gauge extends Control implements Styleable {
class Gauge extends Control implements Colorable, Styleable
{
/*
* Constants
*/
const STYLE_BgCard = 'BgCard';
const STYLE_EnergyBar = 'EnergyBar';
const STYLE_ProgressBar = 'ProgressBar';
const STYLE_ProgressBarSmall = 'ProgressBarSmall';
const STYLE_BgCard = "BgCard";
const STYLE_EnergyBar = "EnergyBar";
const STYLE_ProgressBar = "ProgressBar";
const STYLE_ProgressBarSmall = "ProgressBarSmall";
/*
* Protected properties
/**
* @var float $ratio Ratio
*/
protected $ratio = 0.0;
/**
* @var float $grading Grading
*/
protected $tagName = 'gauge';
protected $ratio = 0.;
protected $grading = 1.;
/**
* @var string $color Color
*/
protected $color = null;
/**
* @var bool $centered Centered
*/
protected $centered = null;
/**
* @var int $clan Clan number
*/
protected $clan = null;
protected $drawBg = 1;
protected $drawBlockBg = 1;
/**
* @var bool $drawBackground Draw background
*/
protected $drawBackground = true;
/**
* @var bool $drawBlockBackground Draw block background
*/
protected $drawBlockBackground = true;
/**
* @var string $style Style
*/
protected $style = null;
/**
* @see \FML\Controls\Control::getManiaScriptClass()
* Get the ratio
*
* @api
* @return float
*/
public function getManiaScriptClass() {
return 'CMlGauge';
public function getRatio()
{
return $this->ratio;
}
/**
* Set ratio
* Set the ratio
*
* @api
* @param float $ratio Ratio value
* @return static
*/
public function setRatio($ratio) {
public function setRatio($ratio)
{
$this->ratio = (float)$ratio;
return $this;
}
/**
* Set grading
* Get the grading
*
* @api
* @return float
*/
public function getGrading()
{
return $this->grading;
}
/**
* Set the grading
*
* @api
* @param float $grading Grading value
* @return static
*/
public function setGrading($grading) {
public function setGrading($grading)
{
$this->grading = (float)$grading;
return $this;
}
/**
* Set color
*
* @param string $color Gauge color
* @return static
* @see Colorable::getColor
*/
public function setColor($color) {
public function getColor()
{
return $this->color;
}
/**
* @see Colorable::setColor
*/
public function setColor($color)
{
$this->color = (string)$color;
return $this;
}
/**
* Get centered
*
* @api
* @return bool
*/
public function getCentered()
{
return $this->centered;
}
/**
* Set centered
*
* @param bool $centered Whether the Gauge is centered
* @api
* @param bool $centered If the Gauge should be centered
* @return static
*/
public function setCentered($centered) {
$this->centered = ($centered ? 1 : 0);
public function setCentered($centered)
{
$this->centered = (bool)$centered;
return $this;
}
/**
* Set clan
* Get the clan
*
* @api
* @return int
*/
public function getClan()
{
return $this->clan;
}
/**
* Set the clan
*
* @api
* @param int $clan Clan number
* @return static
*/
public function setClan($clan) {
public function setClan($clan)
{
$this->clan = (int)$clan;
return $this;
}
/**
* Get draw background
*
* @api
* @return bool
*/
public function getDrawBackground()
{
return $this->drawBackground;
}
/**
* Set draw background
*
* @param bool $drawBg Whether the Gauges background should be drawn
* @api
* @param bool $drawBackground If the Gauges background should be drawn
* @return static
* @deprecated use setDrawBackground() instead
*/
public function setDrawBg($drawBackground)
{
return $this->setDrawBackground($drawBackground);
}
/**
* Set draw background
*
* @api
* @param bool $drawBackground If the Gauges background should be drawn
* @return static
*/
public function setDrawBg($drawBg) {
$this->drawBg = ($drawBg ? 1 : 0);
public function setDrawBackground($drawBackground)
{
$this->drawBackground = (bool)$drawBackground;
return $this;
}
/**
* Get draw block background
*
* @api
* @return bool
*/
public function getDrawBlockBackground()
{
return $this->drawBlockBackground;
}
/**
* Set draw block background
*
* @param bool $drawBlockBg Whether the Gauges block background should be drawn
* @api
* @param bool $drawBlockBackground If the Gauges block background should be drawn
* @return static
*/
public function setDrawBlockBg($drawBlockBg) {
$this->drawBlockBg = ($drawBlockBg ? 1 : 0);
public function setDrawBlockBackground($drawBlockBackground)
{
$this->drawBlockBackground = (bool)$drawBlockBackground;
return $this;
}
/**
* @see \FML\Types\Styleable::setStyle()
* @see Styleable::getStyle()
*/
public function setStyle($style) {
public function getStyle()
{
return $this->style;
}
/**
* @see Styleable::setStyle()
*/
public function setStyle($style)
{
$this->style = (string)$style;
return $this;
}
/**
* @see \FML\Control::render()
* @see Control::getTagName()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
public function getTagName()
{
return "gauge";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlGauge";
}
/**
* @see Control::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->ratio) {
$xmlElement->setAttribute('ratio', $this->ratio);
$domElement->setAttribute("ratio", $this->ratio);
}
if ($this->grading != 1.) {
$xmlElement->setAttribute('grading', $this->grading);
$domElement->setAttribute("grading", $this->grading);
}
if ($this->color) {
$xmlElement->setAttribute('color', $this->color);
$domElement->setAttribute("color", $this->color);
}
if ($this->centered) {
$xmlElement->setAttribute('centered', $this->centered);
$domElement->setAttribute("centered", 1);
}
if ($this->clan) {
$xmlElement->setAttribute('clan', $this->clan);
$domElement->setAttribute("clan", $this->clan);
}
if (!$this->drawBg) {
$xmlElement->setAttribute('drawbg', $this->drawBg);
if (!$this->drawBackground) {
$domElement->setAttribute("drawbg", 0);
}
if (!$this->drawBlockBg) {
$xmlElement->setAttribute('drawblockbg', $this->drawBlockBg);
if (!$this->drawBlockBackground) {
$domElement->setAttribute("drawblockbg", 0);
}
if ($this->style) {
$xmlElement->setAttribute('style', $this->style);
$domElement->setAttribute("style", $this->style);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace FML\Controls;
use FML\Script\Features\GraphCurve;
// TODO: check CoordsMin & CoordsMax properties of CMlGraph
/**
* Graph Control
* (CMlGraph)
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Graph extends Control
{
/**
* @var GraphCurve[] $curves Curves
*/
protected $curves = array();
/**
* Get curves
*
* @api
* @return GraphCurve[]
*/
public function getCurves()
{
return $this->curves;
}
/**
* Add curve
*
* @api
* @param GraphCurve $curve Curve
* @return static
*/
public function addCurve(GraphCurve $curve)
{
$curve->setGraph($this);
$this->addScriptFeature($curve);
array_push($this->curves, $curve);
return $this;
}
/**
* Add curves
*
* @api
* @param GraphCurve[] $curves Curves
* @return static
*/
public function addCurves(array $curves)
{
foreach ($curves as $curve) {
$this->addCurve($curve);
}
return $this;
}
/**
* @see Control::getTagName()
*/
public function getTagName()
{
return "graph";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlGraph";
}
}

View File

@ -5,6 +5,7 @@ namespace FML\Controls;
use FML\Script\Features\Clock;
use FML\Types\Actionable;
use FML\Types\Linkable;
use FML\Types\MultiLineable;
use FML\Types\NewLineable;
use FML\Types\Scriptable;
use FML\Types\Styleable;
@ -15,303 +16,694 @@ use FML\Types\TextFormatable;
* (CMlLabel)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Label extends Control implements Actionable, Linkable, NewLineable, Scriptable, Styleable, TextFormatable {
/*
* Protected properties
*/
protected $tagName = 'label';
protected $text = null;
protected $textId = null;
protected $textPrefix = null;
protected $textEmboss = null;
protected $translate = null;
protected $maxLines = -1;
protected $opacity = 1.;
protected $action = null;
protected $actionKey = -1;
protected $url = null;
protected $urlId = null;
protected $manialink = null;
protected $manialinkId = null;
protected $autoNewLine = null;
protected $scriptEvents = null;
protected $style = null;
protected $textSize = -1;
protected $textFont = null;
protected $textColor = null;
protected $focusAreaColor1 = null;
protected $focusAreaColor2 = null;
class Label extends Control implements Actionable, Linkable, NewLineable, MultiLineable, Scriptable, Styleable, TextFormatable
{
/**
* @see \FML\Controls\Control::getManiaScriptClass()
* @var string $text Text
*/
public function getManiaScriptClass() {
return 'CMlLabel';
protected $text = null;
/**
* @var string $textId Text ID
*/
protected $textId = null;
/**
* @var string $textPrefix Text prefix
*/
protected $textPrefix = null;
/**
* @var bool $textEmboss Text emboss
*/
protected $textEmboss = null;
/**
* @var bool $translate Translate text
*/
protected $translate = null;
/**
* @var int $maxLines Maximum lines
*/
protected $maxLines = -1;
/**
* @var float $opacity Opacity
*/
protected $opacity = 1.;
/**
* @var string $action Action
*/
protected $action = null;
/**
* @var int $actionKey Action key
*/
protected $actionKey = -1;
/**
* @var string $url Url
*/
protected $url = null;
/**
* @var string $urlId Url ID
*/
protected $urlId = null;
/**
* @var string $manialink Manialink
*/
protected $manialink = null;
/**
* @var string $manialinkId Manialink ID
*/
protected $manialinkId = null;
/**
* @var bool $autoNewLine Automatic new line
*/
protected $autoNewLine = null;
/**
* @var float $lineSpacing Line spacing
*/
protected $lineSpacing = -1.;
/**
* @var bool $scriptEvents Script events usage
*/
protected $scriptEvents = null;
/**
* @var string $scriptAction Script action
*/
protected $scriptAction = null;
/**
* @var string[] $scriptActionParameters Script action parameters
*/
protected $scriptActionParameters = null;
/**
* @var string $style Style
*/
protected $style = null;
/**
* @var int $textSize Text size
*/
protected $textSize = -1;
/**
* @var string $textFont Text font
*/
protected $textFont = null;
/**
* @var string $textColor Text color
*/
protected $textColor = null;
/**
* @var string $areaColor Area color
*/
protected $areaColor = null;
/**
* @var string $focusAreaColor Focus area color
*/
protected $focusAreaColor = null;
/**
* Get the text
*
* @api
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* Set text
* Set the text
*
* @api
* @param string $text Text value
* @return static
*/
public function setText($text) {
public function setText($text)
{
$this->text = (string)$text;
return $this;
}
/**
* Set text id to use from Dico
* Get the text id to use from Dico
*
* @api
* @return string
*/
public function getTextId()
{
return $this->textId;
}
/**
* Set the text id to use from Dico
*
* @api
* @param string $textId Text id
* @return static
*/
public function setTextId($textId) {
public function setTextId($textId)
{
$this->textId = (string)$textId;
return $this;
}
/**
* Set text prefix
* Get the text prefix
*
* @api
* @return string
*/
public function getTextPrefix()
{
return $this->textPrefix;
}
/**
* Set the text prefix
*
* @api
* @param string $textPrefix Text prefix
* @return static
*/
public function setTextPrefix($textPrefix) {
public function setTextPrefix($textPrefix)
{
$this->textPrefix = (string)$textPrefix;
return $this;
}
/**
* Get text emboss
*
* @api
* @return bool
*/
public function getTextEmboss()
{
return $this->textEmboss;
}
/**
* Set text emboss
*
* @param bool $textEmboss Whether the text should be embossed
* @api
* @param bool $textEmboss If the text should be embossed
* @return static
*/
public function setTextEmboss($textEmboss) {
$this->textEmboss = ($textEmboss ? 1 : 0);
public function setTextEmboss($textEmboss)
{
$this->textEmboss = (bool)$textEmboss;
return $this;
}
/**
* Get translate
*
* @api
* @return bool
*/
public function getTranslate()
{
return $this->translate;
}
/**
* Set translate
*
* @param bool $translate Whether the text should be translated
* @api
* @param bool $translate If the text should be translated
* @return static
*/
public function setTranslate($translate) {
$this->translate = ($translate ? 1 : 0);
public function setTranslate($translate)
{
$this->translate = (bool)$translate;
return $this;
}
/**
* Set max lines count
* Get the opacity
*
* @param int $maxLines Max lines count
* @api
* @return float
*/
public function getOpacity()
{
return $this->opacity;
}
/**
* Set the opacity
*
* @api
* @param float $opacity Opacity
* @return static
*/
public function setMaxLines($maxLines) {
$this->maxLines = (int)$maxLines;
public function setOpacity($opacity)
{
$this->opacity = (float)$opacity;
return $this;
}
/**
* @see \FML\Types\Actionable::getAction()
* @see Actionable::getAction()
*/
public function getAction() {
public function getAction()
{
return $this->action;
}
/**
* @see \FML\Types\Actionable::setAction()
* @see Actionable::setAction()
*/
public function setAction($action) {
public function setAction($action)
{
$this->action = (string)$action;
return $this;
}
/**
* @see \FML\Types\Actionable::setActionKey()
* @see Actionable::getActionKey()
*/
public function setActionKey($actionKey) {
public function getActionKey()
{
return $this->actionKey;
}
/**
* @see Actionable::setActionKey()
*/
public function setActionKey($actionKey)
{
$this->actionKey = (int)$actionKey;
return $this;
}
/**
* @see \FML\Types\Linkable::setUrl()
* @see Linkable::getUrl()
*/
public function setUrl($url) {
public function getUrl()
{
return $this->url;
}
/**
* @see Linkable::setUrl()
*/
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\Types\Linkable::setUrlId()
* @see Linkable::getUrlId()
*/
public function setUrlId($urlId) {
public function getUrlId()
{
return $this->urlId;
}
/**
* @see Linkable::setUrlId()
*/
public function setUrlId($urlId)
{
$this->urlId = (string)$urlId;
return $this;
}
/**
* @see \FML\Types\Linkable::setManialink()
* @see Linkable::getManialink()
*/
public function setManialink($manialink) {
public function getManialink()
{
return $this->manialink;
}
/**
* @see Linkable::setManialink()
*/
public function setManialink($manialink)
{
$this->manialink = (string)$manialink;
return $this;
}
/**
* @see \FML\Types\Linkable::setManialinkId()
* @see Linkable::getManialinkId()
*/
public function setManialinkId($manialinkId) {
public function getManialinkId()
{
return $this->manialinkId;
}
/**
* @see Linkable::setManialinkId()
*/
public function setManialinkId($manialinkId)
{
$this->manialinkId = (string)$manialinkId;
return $this;
}
/**
* @see \FML\Types\NewLineable::setAutoNewLine()
* @see MultiLineable::getAutoNewLine()
*/
public function setAutoNewLine($autoNewLine) {
$this->autoNewLine = ($autoNewLine ? 1 : 0);
public function getAutoNewLine()
{
return $this->autoNewLine;
}
/**
* @see MultiLineable::setAutoNewLine()
*/
public function setAutoNewLine($autoNewLine)
{
$this->autoNewLine = (bool)$autoNewLine;
return $this;
}
/**
* @see \FML\Types\Scriptable::setScriptEvents()
* @see MultiLineable::getLineSpacing()
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
public function getLineSpacing()
{
return $this->lineSpacing;
}
/**
* @see MultiLineable::setLineSpacing()
*/
public function setLineSpacing($lineSpacing)
{
$this->lineSpacing = (float)$lineSpacing;
return $this;
}
/**
* @see \FML\Types\Styleable::setStyle()
* @see MultiLineable::getMaxLines()
*/
public function setStyle($style) {
public function getMaxLines()
{
return $this->maxLines;
}
/**
* @see MultiLineable::setMaxLines()
*/
public function setMaxLines($maxLines)
{
$this->maxLines = (int)$maxLines;
return $this;
}
/**
* @see Scriptable::getScriptEvents()
*/
public function getScriptEvents()
{
return $this->scriptEvents;
}
/**
* @see Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents)
{
$this->scriptEvents = (bool)$scriptEvents;
return $this;
}
/**
* @see Scriptable::getScriptAction()
*/
public function getScriptAction()
{
return $this->scriptAction;
}
/**
* @see Scriptable::setScriptAction()
*/
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
{
$this->scriptAction = (string)$scriptAction;
$this->setScriptActionParameters($scriptActionParameters);
return $this;
}
/**
* @see Scriptable::getScriptActionParameters()
*/
public function getScriptActionParameters()
{
return $this->scriptActionParameters;
}
/**
* @see Scriptable::setScriptActionParameters()
*/
public function setScriptActionParameters(array $scriptActionParameters = null)
{
$this->scriptActionParameters = $scriptActionParameters;
return $this;
}
/**
* @see Styleable::getStyle()
*/
public function getStyle()
{
return $this->style;
}
/**
* @see Styleable::setStyle()
*/
public function setStyle($style)
{
$this->style = (string)$style;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setTextSize()
* @see TextFormatable::getTextSize()
*/
public function setTextSize($textSize) {
public function getTextSize()
{
return $this->textSize;
}
/**
* @see TextFormatable::setTextSize()
*/
public function setTextSize($textSize)
{
$this->textSize = (int)$textSize;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setTextFont()
* @see TextFormatable::getTextFont()
*/
public function setTextFont($textFont) {
public function getTextFont()
{
return $this->textFont;
}
/**
* @see TextFormatable::setTextFont()
*/
public function setTextFont($textFont)
{
$this->textFont = (string)$textFont;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setTextColor()
* @see TextFormatable::getTextColor()
*/
public function setTextColor($textColor) {
public function getTextColor()
{
return $this->textColor;
}
/**
* @see TextFormatable::setTextColor()
*/
public function setTextColor($textColor)
{
$this->textColor = (string)$textColor;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setAreaColor()
* @see TextFormatable::getAreaColor()
*/
public function setAreaColor($areaColor) {
$this->focusAreaColor1 = (string)$areaColor;
public function getAreaColor()
{
return $this->areaColor;
}
/**
* @see TextFormatable::setAreaColor()
*/
public function setAreaColor($areaColor)
{
$this->areaColor = (string)$areaColor;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setAreaFocusColor()
* @see TextFormatable::getAreaFocusColor()
*/
public function setAreaFocusColor($areaFocusColor) {
$this->focusAreaColor2 = (string)$areaFocusColor;
public function getAreaFocusColor()
{
return $this->focusAreaColor;
}
/**
* @see TextFormatable::setAreaFocusColor()
*/
public function setAreaFocusColor($areaFocusColor)
{
$this->focusAreaColor = (string)$areaFocusColor;
return $this;
}
/**
* Add a dynamic Feature showing the current time
*
* @param bool $showSeconds (optional) Whether the seconds should be shown
* @param bool $showFullDate (optional) Whether the date should be shown
* @api
* @param bool $showSeconds (optional) If the seconds should be shown
* @param bool $showFullDate (optional) If the date should be shown
* @return static
*/
public function addClockFeature($showSeconds = true, $showFullDate = false) {
public function addClockFeature($showSeconds = true, $showFullDate = false)
{
$clock = new Clock($this, $showSeconds, $showFullDate);
$this->addScriptFeature($clock);
return $this;
}
/**
* @see \FML\Types\Renderable::render()
* @see Control::getTagName()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
if (strlen($this->text) > 0) {
$xmlElement->setAttribute('text', $this->text);
public function getTagName()
{
return "label";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlLabel";
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->text) {
$domElement->setAttribute("text", $this->text);
}
if ($this->textId) {
$xmlElement->setAttribute('textid', $this->textId);
$domElement->setAttribute("textid", $this->textId);
}
if ($this->textPrefix) {
$xmlElement->setAttribute('textprefix', $this->textPrefix);
$domElement->setAttribute("textprefix", $this->textPrefix);
}
if ($this->textEmboss) {
$xmlElement->setAttribute('textemboss', $this->textEmboss);
$domElement->setAttribute("textemboss", $this->textEmboss);
}
if ($this->translate) {
$xmlElement->setAttribute('translate', $this->translate);
}
if ($this->maxLines >= 0) {
$xmlElement->setAttribute('maxlines', $this->maxLines);
$domElement->setAttribute("translate", $this->translate);
}
if ($this->opacity != 1.) {
$xmlElement->setAttribute('opacity', $this->opacity);
$domElement->setAttribute("opacity", $this->opacity);
}
if (strlen($this->action) > 0) {
$xmlElement->setAttribute('action', $this->action);
if ($this->action) {
$domElement->setAttribute("action", $this->action);
}
if ($this->actionKey >= 0) {
$xmlElement->setAttribute('actionkey', $this->actionKey);
$domElement->setAttribute("actionkey", $this->actionKey);
}
if ($this->url) {
$xmlElement->setAttribute('url', $this->url);
$domElement->setAttribute("url", $this->url);
}
if ($this->urlId) {
$domElement->setAttribute("urlid", $this->urlId);
}
if ($this->manialink) {
$xmlElement->setAttribute('manialink', $this->manialink);
$domElement->setAttribute("manialink", $this->manialink);
}
if ($this->manialinkId) {
$domElement->setAttribute("manialinkid", $this->manialinkId);
}
if ($this->autoNewLine) {
$xmlElement->setAttribute('autonewline', $this->autoNewLine);
$domElement->setAttribute("autonewline", $this->autoNewLine);
}
if ($this->lineSpacing) {
$domElement->setAttribute("linespacing", $this->lineSpacing);
}
if ($this->maxLines > 0) {
$domElement->setAttribute("maxline", $this->maxLines);
}
if ($this->scriptEvents) {
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
$domElement->setAttribute("scriptevents", $this->scriptEvents);
}
if ($this->scriptAction) {
$scriptAction = array($this->scriptAction);
if ($this->scriptActionParameters) {
$scriptAction = array_merge($scriptAction, $this->scriptActionParameters);
}
$domElement->setAttribute("scriptaction", implode("'", $scriptAction));
}
if ($this->style) {
$xmlElement->setAttribute('style', $this->style);
$domElement->setAttribute("style", $this->style);
}
if ($this->textSize >= 0) {
$xmlElement->setAttribute('textsize', $this->textSize);
$domElement->setAttribute("textsize", $this->textSize);
}
if ($this->textFont) {
$xmlElement->setAttribute('textfont', $this->textFont);
$domElement->setAttribute("textfont", $this->textFont);
}
if ($this->textColor) {
$xmlElement->setAttribute('textcolor', $this->textColor);
$domElement->setAttribute("textcolor", $this->textColor);
}
if ($this->focusAreaColor1) {
$xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1);
if ($this->areaColor) {
$domElement->setAttribute("focusareacolor1", $this->areaColor);
}
if ($this->focusAreaColor2) {
$xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2);
if ($this->focusAreaColor) {
$domElement->setAttribute("focusareacolor2", $this->focusAreaColor);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Label;
* Label class for button styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Label_Button extends Label {
class Label_Button extends Label
{
/*
* Constants
*/
@ -35,4 +37,5 @@ class Label_Button extends Label {
const STYLE_CardMain_Tool = 'CardMain_Tool';
const STYLE_CardMain_Tool_NoBg = 'CardMain_Tool_NoBg';
const STYLE_CardMain_Tool_NoBg2 = 'CardMain_Tool_NoBg2';
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Label;
* Label class for text styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Label_Text extends Label {
class Label_Text extends Label
{
/*
* Constants
*/
@ -94,4 +96,5 @@ class Label_Text extends Label {
const STYLE_UiDriving_BgBottom = 'UiDriving_BgBottom';
const STYLE_UiDriving_BgCard = 'UiDriving_BgCard';
const STYLE_UiDriving_BgCenter = 'UiDriving_BgCenter';
}

View File

@ -2,9 +2,9 @@
namespace FML\Controls;
use FML\Models\CheckBoxDesign;
use FML\Types\Actionable;
use FML\Types\BgColorable;
use FML\Types\BackgroundColorable;
use FML\Types\Imageable;
use FML\Types\Linkable;
use FML\Types\Scriptable;
use FML\Types\Styleable;
@ -15,325 +15,716 @@ use FML\Types\SubStyleable;
* (CMlQuad)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad extends Control implements Actionable, BgColorable, Linkable, Scriptable, Styleable, SubStyleable {
class Quad extends Control implements Actionable, BackgroundColorable, Imageable, Linkable, Scriptable, Styleable, SubStyleable
{
/*
* Constants
*/
const KEEP_RATIO_INACTIVE = 'inactive';
const KEEP_RATIO_CLIP = 'Clip';
const KEEP_RATIO_FIT = 'Fit';
/*
* Protected properties
*/
protected $tagName = 'quad';
protected $image = null;
protected $imageId = null;
protected $imageFocus = null;
protected $imageFocusId = null;
protected $colorize = null;
protected $modulizeColor = null;
protected $autoScale = 1;
protected $keepRatio = null;
protected $action = null;
protected $actionKey = -1;
protected $bgColor = null;
protected $url = null;
protected $urlId = null;
protected $manialink = null;
protected $manialinkId = null;
protected $scriptEvents = null;
protected $style = null;
protected $subStyle = null;
protected $styleSelected = null;
protected $opacity = null;
const KEEP_RATIO_INACTIVE = "inactive";
const KEEP_RATIO_CLIP = "Clip";
const KEEP_RATIO_FIT = "Fit";
/**
* @see \FML\Controls\Control::getManiaScriptClass()
* @var string $imageUrl Image url
*/
public function getManiaScriptClass() {
return 'CMlQuad';
protected $imageUrl = null;
/**
* @var string $imageId Image ID
*/
protected $imageId = null;
/**
* @var string $imageFocusUrl Focus image url
*/
protected $imageFocusUrl = null;
/**
* @var string $imageFocusId Focus image ID
*/
protected $imageFocusId = null;
/**
* @var string $colorize Colorize value
*/
protected $colorize = null;
/**
* @var string $modulizeColor Modulization color
*/
protected $modulizeColor = null;
/**
* @var bool $autoScale Automatic scaling
*/
protected $autoScale = true;
/**
* @var float $autoScaleFixedWidth Fixed width for automatic scaling
*/
protected $autoScaleFixedWidth = -1.;
/**
* @var string $keepRatio Keep ratio mode
*/
protected $keepRatio = null;
/**
* @var float $opacity Opacity
*/
protected $opacity = 1.;
/**
* @var string $backgroundColor Background color
*/
protected $backgroundColor = null;
/**
* @var string $action Action name
*/
protected $action = null;
/**
* @var int $actionKey Action key
*/
protected $actionKey = -1;
/**
* @var string $url Link url
*/
protected $url = null;
/**
* @var string $urlId Link url ID
*/
protected $urlId = null;
/**
* @var string $manialink Manialink
*/
protected $manialink = null;
/**
* @var string $manialinkId Manialink ID
*/
protected $manialinkId = null;
/**
* @var bool $scriptEvents Script events usage
*/
protected $scriptEvents = null;
/**
* @var string $scriptAction Script action
*/
protected $scriptAction = null;
/**
* @var string[] $scriptActionParameters Script action parameters
*/
protected $scriptActionParameters = null;
/**
* @var string $style Style
*/
protected $style = null;
/**
* @var string $subStyle SubStyle
*/
protected $subStyle = null;
/**
* @var bool $styleSelected Style selected
*/
protected $styleSelected = null;
/**
* @see Imageable::getImageUrl()
*/
public function getImageUrl()
{
return $this->imageUrl;
}
/**
* Set image url
*
* @param string $image Image url
* @return static
* @deprecated use setImageUrl() instead
*/
public function setImage($image) {
$this->image = (string)$image;
public function setImage($imageUrl)
{
return $this->setImageUrl($imageUrl);
}
/**
* @see Imageable::setImageUrl()
*/
public function setImageUrl($imageUrl)
{
$this->imageUrl = (string)$imageUrl;
return $this;
}
/**
* Set image id to use from Dico
* Get the image id to use from Dico
*
* @api
* @return string
*/
public function getImageId()
{
return $this->imageId;
}
/**
* Set the image id to use from Dico
*
* @api
* @param string $imageId Image id
* @return static
*/
public function setImageId($imageId) {
public function setImageId($imageId)
{
$this->imageId = (string)$imageId;
return $this;
}
/**
* Set focus image url
* Get the focus image url
*
* @param string $imageFocus Focus image url
* @api
* @return string
*/
public function getImageFocusUrl()
{
return $this->imageFocusUrl;
}
/**
* @param $imageFocusUrl
* @return \FML\Controls\Quad
* @deprecated
*/
public function setImageFocus($imageFocusUrl)
{
return $this->setImageFocusUrl($imageFocusUrl);
}
/**
* Set the focus image url
*
* @api
* @param string $imageFocusUrl Focus image url
* @return static
*/
public function setImageFocus($imageFocus) {
$this->imageFocus = (string)$imageFocus;
public function setImageFocusUrl($imageFocusUrl)
{
$this->imageFocusUrl = (string)$imageFocusUrl;
return $this;
}
/**
* Set focus image id to use from Dico
* Get the focus image id to use from Dico
*
* @api
* @return string
*/
public function getImageFocusId()
{
return $this->imageFocusId;
}
/**
* Set the focus image id to use from Dico
*
* @api
* @param string $imageFocusId Focus image id
* @return static
*/
public function setImageFocusId($imageFocusId) {
public function setImageFocusId($imageFocusId)
{
$this->imageFocusId = (string)$imageFocusId;
return $this;
}
/**
* Set colorization
* Get the colorization
*
* @api
* @return string
*/
public function getColorize()
{
return $this->colorize;
}
/**
* Set the colorization
*
* @api
* @param string $colorize Colorize value
* @return static
*/
public function setColorize($colorize) {
public function setColorize($colorize)
{
$this->colorize = (string)$colorize;
return $this;
}
/**
* Set modulization
* Get the modulization color
*
* @param string $modulizeColor Modulize value
* @api
* @return string
*/
public function getModulizeColor()
{
return $this->modulizeColor;
}
/**
* Set the modulization color
*
* @api
* @param string $modulizeColor Modulization color
* @return static
*/
public function setModulizeColor($modulizeColor) {
public function setModulizeColor($modulizeColor)
{
$this->modulizeColor = (string)$modulizeColor;
return $this;
}
/**
* Disable the automatic image scaling
* Get the automatic image scaling
*
* @param bool $autoScale Whether the image should scale automatically
* @api
* @return bool
*/
public function getAutoScale()
{
return $this->autoScale;
}
/**
* Set the automatic image scaling
*
* @api
* @param bool $autoScale If the image should scale automatically
* @return static
*/
public function setAutoScale($autoScale) {
$this->autoScale = ($autoScale ? 1 : 0);
public function setAutoScale($autoScale)
{
$this->autoScale = (bool)$autoScale;
return $this;
}
/**
* Set Keep Ratio Mode
* Get the fixed width for automatic image scaling
*
* @param string $keepRatio Keep Ratio Mode
* @api
* @return float
*/
public function getAutoScaleFixedWidth()
{
return $this->autoScaleFixedWidth;
}
/**
* Set the fixed width for automatic image scaling
*
* @api
* @param float $autoScaleFixedWidth Fixed width for automatic image scaling
* @return static
*/
public function setKeepRatio($keepRatio) {
public function setAutoScaleFixedWidth($autoScaleFixedWidth)
{
$this->autoScaleFixedWidth = (float)$autoScaleFixedWidth;
return $this;
}
/**
* Get the Keep Ratio mode
*
* @api
* @return string
*/
public function getKeepRatio()
{
return $this->keepRatio;
}
/**
* Set the Keep Ratio mode
*
* @api
* @param string $keepRatio Keep Ratio mode
* @return static
*/
public function setKeepRatio($keepRatio)
{
$this->keepRatio = (string)$keepRatio;
return $this;
}
/**
* @see \FML\Types\Actionable::getAction()
*/
public function getAction() {
return $this->action;
}
/**
* @see \FML\Types\Actionable::setAction()
*/
public function setAction($action) {
$this->action = (string)$action;
return $this;
}
/**
* @see \FML\Types\Actionable::setActionKey()
*/
public function setActionKey($actionKey) {
$this->actionKey = (int)$actionKey;
return $this;
}
/**
* @see \FML\Types\BgColorable::setBgColor()
*/
public function setBgColor($bgColor) {
$this->bgColor = (string)$bgColor;
return $this;
}
/**
* @see \FML\Types\Linkable::setUrl()
*/
public function setUrl($url) {
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\Types\Linkable::setUrlId()
*/
public function setUrlId($urlId) {
$this->urlId = (string)$urlId;
return $this;
}
/**
* @see \FML\Types\Linkable::setManialink()
*/
public function setManialink($manialink) {
$this->manialink = (string)$manialink;
return $this;
}
/**
* @see \FML\Types\Linkable::setManialinkId()
*/
public function setManialinkId($manialinkId) {
$this->manialinkId = (string)$manialinkId;
return $this;
}
/**
* @see \FML\Types\Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
return $this;
}
/**
* @see \FML\Types\SubStyleable::setStyles()
*/
public function setStyles($style, $subStyle) {
$this->setStyle($style);
$this->setSubStyle($subStyle);
return $this;
}
/**
* @see \FML\Types\Styleable::setStyle()
*/
public function setStyle($style) {
$this->style = (string)$style;
return $this;
}
/**
* @see \FML\Types\SubStyleable::setSubStyle()
*/
public function setSubStyle($subStyle) {
$this->subStyle = (string)$subStyle;
return $this;
}
/**
* Set selected mode
* Get the opacity
*
* @param bool $styleSelected
* @api
* @return float
*/
public function getOpacity()
{
return $this->opacity;
}
/**
* Set the opacity
*
* @api
* @param float $opacity Opacity value
* @return static
*/
public function setStyleSelected($styleSelected) {
$this->styleSelected = ($styleSelected ? 1 : 0);
return $this;
}
/**
* Set opacity
*
* @param float $opacity
* @return static
*/
public function setOpacity($opacity) {
public function setOpacity($opacity)
{
$this->opacity = (float)$opacity;
return $this;
}
/**
* Apply the given CheckBox Design
*
* @param CheckBoxDesign $checkBoxDesign CheckBox Design
* @return static
* @see BackgroundColorable::getBackgroundColor()
*/
public function applyCheckBoxDesign(CheckBoxDesign $checkBoxDesign) {
$checkBoxDesign->applyToQuad($this);
public function getBackgroundColor()
{
return $this->backgroundColor;
}
/**
* @see BackgroundColorable::setBgColor()
*/
public function setBackgroundColor($backgroundColor)
{
$this->backgroundColor = (string)$backgroundColor;
return $this;
}
/**
* @see \FML\Types\Renderable::render()
* @see Actionable::getAction()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
if ($this->image) {
$xmlElement->setAttribute('image', $this->image);
public function getAction()
{
return $this->action;
}
/**
* @see Actionable::setAction()
*/
public function setAction($action)
{
$this->action = (string)$action;
return $this;
}
/**
* @see Actionable::getActionKey()
*/
public function getActionKey()
{
return $this->actionKey;
}
/**
* @see Actionable::setActionKey()
*/
public function setActionKey($actionKey)
{
$this->actionKey = (int)$actionKey;
return $this;
}
/**
* @see Linkable::getUrl()
*/
public function getUrl()
{
return $this->url;
}
/**
* @see Linkable::setUrl()
*/
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see Linkable::getUrlId()
*/
public function getUrlId()
{
return $this->urlId;
}
/**
* @see Linkable::setUrlId()
*/
public function setUrlId($urlId)
{
$this->urlId = (string)$urlId;
return $this;
}
/**
* @see Linkable::getManialink()
*/
public function getManialink()
{
return $this->manialink;
}
/**
* @see Linkable::setManialink()
*/
public function setManialink($manialink)
{
$this->manialink = (string)$manialink;
return $this;
}
/**
* @see Linkable::getManialinkId()
*/
public function getManialinkId()
{
return $this->manialinkId;
}
/**
* @see Linkable::setManialinkId()
*/
public function setManialinkId($manialinkId)
{
$this->manialinkId = (string)$manialinkId;
return $this;
}
/**
* @see Scriptable::getScriptEvents()
*/
public function getScriptEvents()
{
return $this->scriptEvents;
}
/**
* @see Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents)
{
$this->scriptEvents = (bool)$scriptEvents;
return $this;
}
/**
* @see Scriptable::getScriptAction()
*/
public function getScriptAction()
{
return $this->scriptAction;
}
/**
* @see Scriptable::setScriptAction()
*/
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
{
$this->scriptAction = (string)$scriptAction;
$this->setScriptActionParameters($scriptActionParameters);
return $this;
}
/**
* @see Scriptable::getScriptActionParameters()
*/
public function getScriptActionParameters()
{
return $this->scriptActionParameters;
}
/**
* @see Scriptable::setScriptActionParameters()
*/
public function setScriptActionParameters(array $scriptActionParameters = null)
{
$this->scriptActionParameters = $scriptActionParameters;
return $this;
}
/**
* @see Styleable::getStyle()
*/
public function getStyle()
{
return $this->style;
}
/**
* @see Styleable::setStyle()
*/
public function setStyle($style)
{
$this->style = (string)$style;
return $this;
}
/**
* @see Styleable::getSubStyle()
*/
public function getSubStyle()
{
return $this->subStyle;
}
/**
* @see SubStyleable::setSubStyle()
*/
public function setSubStyle($subStyle)
{
$this->subStyle = (string)$subStyle;
return $this;
}
/**
* @see SubStyleable::setStyles()
*/
public function setStyles($style, $subStyle)
{
return $this->setStyle($style)
->setSubStyle($subStyle);
}
/**
* Get selected style
*
* @api
* @return bool
*/
public function getStyleSelected()
{
return $this->styleSelected;
}
/**
* Set selected style
*
* @api
* @param bool $styleSelected If the quad should be styled selected
* @return static
*/
public function setStyleSelected($styleSelected)
{
$this->styleSelected = (bool)$styleSelected;
return $this;
}
/**
* @see Control::getTagName()
*/
public function getTagName()
{
return "quad";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlQuad";
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->imageUrl) {
$domElement->setAttribute("image", $this->imageUrl);
}
if ($this->imageId) {
$xmlElement->setAttribute('imageid', $this->imageId);
$domElement->setAttribute("imageid", $this->imageId);
}
if ($this->imageFocus) {
$xmlElement->setAttribute('imagefocus', $this->imageFocus);
if ($this->imageFocusUrl) {
$domElement->setAttribute("imagefocus", $this->imageFocusUrl);
}
if ($this->imageFocusId) {
$xmlElement->setAttribute('imagefocusid', $this->imageFocusId);
$domElement->setAttribute("imagefocusid", $this->imageFocusId);
}
if ($this->colorize) {
$xmlElement->setAttribute('colorize', $this->colorize);
$domElement->setAttribute("colorize", $this->colorize);
}
if ($this->modulizeColor) {
$xmlElement->setAttribute('modulizecolor', $this->modulizeColor);
$domElement->setAttribute("modulizecolor", $this->modulizeColor);
}
if (!$this->autoScale) {
$xmlElement->setAttribute('autoscale', $this->autoScale);
$domElement->setAttribute("autoscale", 0);
}
if ($this->autoScaleFixedWidth > 0.) {
$domElement->setAttribute("autoscalefixedWidth", $this->autoScaleFixedWidth);
}
if ($this->keepRatio) {
$xmlElement->setAttribute('keepratio', $this->keepRatio);
}
if (strlen($this->action) > 0) {
$xmlElement->setAttribute('action', $this->action);
}
if ($this->actionKey >= 0) {
$xmlElement->setAttribute('actionkey', $this->actionKey);
}
if ($this->bgColor) {
$xmlElement->setAttribute('bgcolor', $this->bgColor);
}
if ($this->url) {
$xmlElement->setAttribute('url', $this->url);
}
if ($this->manialink) {
$xmlElement->setAttribute('manialink', $this->manialink);
}
if ($this->scriptEvents) {
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
}
if ($this->style) {
$xmlElement->setAttribute('style', $this->style);
}
if ($this->subStyle) {
$xmlElement->setAttribute('substyle', $this->subStyle);
}
if ($this->styleSelected) {
$xmlElement->setAttribute('styleselected', $this->styleSelected);
$domElement->setAttribute("keepratio", $this->keepRatio);
}
if ($this->opacity !== 1.) {
$xmlElement->setAttribute('opacity', $this->opacity);
$domElement->setAttribute("opacity", $this->opacity);
}
return $xmlElement;
if ($this->backgroundColor) {
$domElement->setAttribute("bgcolor", $this->backgroundColor);
}
if ($this->action) {
$domElement->setAttribute("action", $this->action);
}
if ($this->actionKey) {
$domElement->setAttribute("actionkey", $this->actionKey);
}
if ($this->url) {
$domElement->setAttribute("url", $this->url);
}
if ($this->urlId) {
$domElement->setAttribute("urlid", $this->urlId);
}
if ($this->manialink) {
$domElement->setAttribute("manialink", $this->manialink);
}
if ($this->manialinkId) {
$domElement->setAttribute("manialinkid", $this->manialinkId);
}
if ($this->scriptEvents) {
$domElement->setAttribute("scriptevents", 1);
}
if ($this->scriptAction) {
$scriptAction = array($this->scriptAction);
if ($this->scriptActionParameters) {
$scriptAction = array_merge($scriptAction, $this->scriptActionParameters);
}
$domElement->setAttribute("scriptaction", implode("'", $scriptAction));
}
if ($this->style) {
$domElement->setAttribute("style", $this->style);
}
if ($this->subStyle) {
$domElement->setAttribute("substyle", $this->subStyle);
}
if ($this->styleSelected) {
$domElement->setAttribute("styleselected", 1);
}
return $domElement;
}
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for '321Go' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_321Go extends Quad {
class Quad_321Go extends Quad
{
/*
* Constants
*/
@ -21,8 +23,9 @@ class Quad_321Go extends Quad {
const SUBSTYLE_1 = '1';
const SUBSTYLE_Go = 'Go!';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'BgRaceScore2' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_BgRaceScore2 extends Quad {
class Quad_BgRaceScore2 extends Quad
{
/*
* Constants
*/
@ -44,8 +46,9 @@ class Quad_BgRaceScore2 extends Quad {
const SUBSTYLE_Tv = 'Tv';
const SUBSTYLE_Warmup = 'Warmup';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Bgs1' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Bgs1 extends Quad {
class Quad_Bgs1 extends Quad
{
/*
* Constants
*/
@ -86,8 +88,9 @@ class Quad_Bgs1 extends Quad {
const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall';
const SUBSTYLE_Shadow = 'Shadow';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Bgs1InRace' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Bgs1InRace extends Quad {
class Quad_Bgs1InRace extends Quad
{
/*
* Constants
*/
@ -86,8 +88,9 @@ class Quad_Bgs1InRace extends Quad {
const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall';
const SUBSTYLE_Shadow = 'Shadow';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'BgsButtons' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_BgsButtons extends Quad {
class Quad_BgsButtons extends Quad
{
/*
* Constants
*/
@ -24,8 +26,9 @@ class Quad_BgsButtons extends Quad {
const SUBSTYLE_BgButtonSmall2 = 'BgButtonSmall2';
const SUBSTYLE_BgButtonXSmall = 'BgButtonXSmall';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'BgsChallengeMedals' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_BgsChallengeMedals extends Quad {
class Quad_BgsChallengeMedals extends Quad
{
/*
* Constants
*/
@ -23,8 +25,9 @@ class Quad_BgsChallengeMedals extends Quad {
const SUBSTYLE_BgPlayed = 'BgPlayed';
const SUBSTYLE_BgSilver = 'BgSilver';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'BgsPlayerCard' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_BgsPlayerCard extends Quad {
class Quad_BgsPlayerCard extends Quad
{
/*
* Constants
*/
@ -31,8 +33,9 @@ class Quad_BgsPlayerCard extends Quad {
const SUBSTYLE_BgRacePlayerName = 'BgRacePlayerName';
const SUBSTYLE_ProgressBar = 'ProgressBar';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Copilot' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Copilot extends Quad {
class Quad_Copilot extends Quad
{
/*
* Constants
*/
@ -29,8 +31,9 @@ class Quad_Copilot extends Quad {
const SUBSTYLE_UpGood = 'UpGood';
const SUBSTYLE_UpWrong = 'UpWrong';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Emblems' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Emblems extends Quad {
class Quad_Emblems extends Quad
{
/*
* Constants
*/
@ -20,8 +22,9 @@ class Quad_Emblems extends Quad {
const SUBSTYLE_1 = '#1';
const SUBSTYLE_2 = '#2';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'EnergyBar' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_EnergyBar extends Quad {
class Quad_EnergyBar extends Quad
{
/*
* Constants
*/
@ -23,8 +25,9 @@ class Quad_EnergyBar extends Quad {
const SUBSTYLE_HeaderGaugeLeft = 'HeaderGaugeLeft';
const SUBSTYLE_HeaderGaugeRight = 'HeaderGaugeRight';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Hud3dEchelons' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Hud3dEchelons extends Quad {
class Quad_Hud3dEchelons extends Quad
{
/*
* Constants
*/
@ -26,8 +28,9 @@ class Quad_Hud3dEchelons extends Quad {
const SUBSTYLE_EchelonSilver2 = 'EchelonSilver2';
const SUBSTYLE_EchelonSilver3 = 'EchelonSilver3';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Hud3dIcons' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Hud3dIcons extends Quad {
class Quad_Hud3dIcons extends Quad
{
/*
* Constants
*/
@ -25,8 +27,9 @@ class Quad_Hud3dIcons extends Quad {
const SUBSTYLE_PointB = 'PointB';
const SUBSTYLE_PointC = 'PointC';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Icons128x128_1' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Icons128x128_1 extends Quad {
class Quad_Icons128x128_1 extends Quad
{
/*
* Constants
*/
@ -81,8 +83,9 @@ class Quad_Icons128x128_1 extends Quad {
const SUBSTYLE_Upload = 'Upload';
const SUBSTYLE_Vehicles = 'Vehicles';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Icons128x128_Blink' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Icons128x128_Blink extends Quad {
class Quad_Icons128x128_Blink extends Quad
{
/*
* Constants
*/
@ -81,8 +83,9 @@ class Quad_Icons128x128_Blink extends Quad {
const SUBSTYLE_Upload = 'Upload';
const SUBSTYLE_Vehicles = 'Vehicles';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Icons128x32_1' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Icons128x32_1 extends Quad {
class Quad_Icons128x32_1 extends Quad
{
/*
* Constants
*/
@ -47,8 +49,9 @@ class Quad_Icons128x32_1 extends Quad {
const SUBSTYLE_UrlBg = 'UrlBg';
const SUBSTYLE_Windowed = 'Windowed';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Icons64x64_1' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Icons64x64_1 extends Quad {
class Quad_Icons64x64_1 extends Quad
{
/*
* Constants
*/
@ -103,8 +105,9 @@ class Quad_Icons64x64_1 extends Quad {
const SUBSTYLE_YellowHigh = 'YellowHigh';
const SUBSTYLE_YellowLow = 'YellowLow';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'Icons64x64_2' styles
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_Icons64x64_2 extends Quad {
class Quad_Icons64x64_2 extends Quad
{
/*
* Constants
*/
@ -32,8 +34,9 @@ class Quad_Icons64x64_2 extends Quad {
const SUBSTYLE_UnknownElimination = 'UnknownElimination';
const SUBSTYLE_UnknownHit = 'UnknownHit';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'ManiaPlanetLogos' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_ManiaPlanetLogos extends Quad {
class Quad_ManiaPlanetLogos extends Quad
{
/*
* Constants
*/
@ -24,8 +26,9 @@ class Quad_ManiaPlanetLogos extends Quad {
const SUBSTYLE_ManiaPlanetLogoWhite = 'ManiaPlanetLogoWhite';
const SUBSTYLE_ManiaPlanetLogoWhiteSmall = 'ManiaPlanetLogoWhiteSmall';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'ManiaPlanetMainMenu' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_ManiaPlanetMainMenu extends Quad {
class Quad_ManiaPlanetMainMenu extends Quad
{
/*
* Constants
*/
@ -28,8 +30,9 @@ class Quad_ManiaPlanetMainMenu extends Quad {
const SUBSTYLE_TitleBg = 'TitleBg';
const SUBSTYLE_TopBar = 'TopBar';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'ManiaplanetSystem' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_ManiaplanetSystem extends Quad {
class Quad_ManiaplanetSystem extends Quad
{
/*
* Constants
*/
@ -23,8 +25,9 @@ class Quad_ManiaplanetSystem extends Quad {
const SUBSTYLE_Medals = 'Medals';
const SUBSTYLE_Statistics = 'Statistics';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'MedalsBig' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_MedalsBig extends Quad {
class Quad_MedalsBig extends Quad
{
/*
* Constants
*/
@ -24,8 +26,9 @@ class Quad_MedalsBig extends Quad {
const SUBSTYLE_MedalSilver = 'MedalSilver';
const SUBSTYLE_MedalSlot = 'MedalSlot';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'TitleLogos' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_TitleLogos extends Quad {
class Quad_TitleLogos extends Quad
{
/*
* Constants
*/
@ -21,8 +23,9 @@ class Quad_TitleLogos extends Quad {
const SUBSTYLE_Icon = 'Icon';
const SUBSTYLE_Title = 'Title';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'UIConstructionBullet_Buttons' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_UIConstructionBullet_Buttons extends Quad {
class Quad_UIConstructionBullet_Buttons extends Quad
{
/*
* Constants
*/
@ -40,8 +42,9 @@ class Quad_UIConstructionBullet_Buttons extends Quad {
const SUBSTYLE_Trail = 'Trail';
const SUBSTYLE_TrailFolder = 'TrailFolder';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'UIConstruction_Buttons' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_UIConstruction_Buttons extends Quad {
class Quad_UIConstruction_Buttons extends Quad
{
/*
* Constants
*/
@ -74,8 +76,9 @@ class Quad_UIConstruction_Buttons extends Quad {
const SUBSTYLE_Validate_Step2 = 'Validate_Step2';
const SUBSTYLE_Validate_Step3 = 'Validate_Step3';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'UIConstruction_Buttons2' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_UIConstruction_Buttons2 extends Quad {
class Quad_UIConstruction_Buttons2 extends Quad
{
/*
* Constants
*/
@ -29,8 +31,9 @@ class Quad_UIConstruction_Buttons2 extends Quad {
const SUBSTYLE_Open = 'Open';
const SUBSTYLE_Symmetry = 'Symmetry';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -8,10 +8,12 @@ use FML\Controls\Quad;
* Quad class for 'UiSMSpectatorScoreBig' styles
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad_UiSMSpectatorScoreBig extends Quad {
class Quad_UiSMSpectatorScoreBig extends Quad
{
/*
* Constants
*/
@ -38,8 +40,9 @@ class Quad_UiSMSpectatorScoreBig extends Quad {
CONST SUBSTYLE_UIRange1Bg = 'UIRange1Bg';
CONST SUBSTYLE_UIRange2Bg = 'UIRange2Bg';
/*
* Protected properties
/**
* @var string $style Style
*/
protected $style = self::STYLE;
}

View File

@ -0,0 +1,452 @@
<?php
namespace FML\Controls;
use FML\Types\MultiLineable;
use FML\Types\Scriptable;
use FML\Types\Styleable;
use FML\Types\TextFormatable;
/**
* TextEdit Control
* (CMlTextEdit)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class TextEdit extends Control implements MultiLineable, Scriptable, Styleable, TextFormatable
{
/*
* Constants
*/
const FORMAT_Default = "Default";
const FORMAT_Script = "Script";
const FORMAT_Password = "Password";
const FORMAT_NewPassword = "NewPassword";
/**
* @var string $default Default value
*/
protected $default = null;
/**
* @var bool $autoNewLine Auto new line
*/
protected $autoNewLine = null;
/**
* @var float $lineSpacing Line spacing
*/
protected $lineSpacing = -1.;
/**
* @var int $maxLines Maximum number of lines
*/
protected $maxLines = -1;
/**
* @var bool $showLineNumbers Show lines numbers
*/
protected $showLineNumbers = null;
/**
* @var string $textFormat Text format
*/
protected $textFormat = null;
/**
* @var bool $scriptEvents Script events usage
*/
protected $scriptEvents = null;
/**
* @var string $scriptAction Script action
*/
protected $scriptAction = null;
/**
* @var string[] $scriptActionParameters Script action parameters
*/
protected $scriptActionParameters = null;
/**
* @var string $style Style
*/
protected $style = null;
/**
* @var string $textColor Text color
*/
protected $textColor = null;
/**
* @var int $textSize Text size
*/
protected $textSize = null;
/**
* @var string $textFont Text font
*/
protected $textFont = null;
/**
* @var string $areaColor Area color
*/
protected $areaColor = null;
/**
* @var string $focusAreaColor Focus area color
*/
protected $focusAreaColor = null;
/**
* Get the default value
*
* @api
* @return mixed
*/
public function getDefault()
{
return $this->default;
}
/**
* Set the default value
*
* @api
* @param string $default Default value
* @return static
*/
public function setDefault($default)
{
$this->default = $default;
return $this;
}
/**
* @see MultiLineable::getAutoNewLine()
*/
public function getAutoNewLine()
{
return $this->autoNewLine;
}
/**
* @see MultiLineable::setAutoNewLine()
*/
public function setAutoNewLine($autoNewLine)
{
$this->autoNewLine = (bool)$autoNewLine;
return $this;
}
/**
* @see MultiLineable::getLineSpacing()
*/
public function getLineSpacing()
{
return $this->lineSpacing;
}
/**
* @see MultiLineable::setLineSpacing()
*/
public function setLineSpacing($lineSpacing)
{
$this->lineSpacing = (float)$lineSpacing;
return $this;
}
/**
* @see MultiLineable::getMaxLines()
*/
public function getMaxLines()
{
return $this->maxLines;
}
/**
* @see MultiLineable::setMaxLines()
*/
public function setMaxLines($maxLines)
{
$this->maxLines = (int)$maxLines;
return $this;
}
/**
* Get showing of line numbers
*
* @api
* @return bool
*/
public function getShowLineNumbers()
{
return $this->showLineNumbers;
}
/**
* Set showing of line numbers
*
* @api
* @param bool $showLineNumbers Show line numbers
* @return static
*/
public function setShowLineNumbers($showLineNumbers)
{
$this->showLineNumbers = (bool)$showLineNumbers;
return $this;
}
/**
* Get text format
*
* @api
* @return string
*/
public function getTextFormat()
{
return $this->textFormat;
}
/**
* Set text format
*
* @api
* @param string $textFormat Text format
* @return static
*/
public function setTextFormat($textFormat)
{
$this->textFormat = (string)$textFormat;
return $this;
}
/**
* @see Scriptable::getScriptEvents()
*/
public function getScriptEvents()
{
return $this->scriptEvents;
}
/**
* @see Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents)
{
$this->scriptEvents = (bool)$scriptEvents;
return $this;
}
/**
* @see Scriptable::getScriptAction()
*/
public function getScriptAction()
{
return $this->scriptAction;
}
/**
* @see Scriptable::setScriptAction()
*/
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
{
$this->scriptAction = (string)$scriptAction;
$this->setScriptActionParameters($scriptActionParameters);
return $this;
}
/**
* @see Scriptable::getScriptActionParameters()
*/
public function getScriptActionParameters()
{
return $this->scriptActionParameters;
}
/**
* @see Scriptable::setScriptActionParameters()
*/
public function setScriptActionParameters(array $scriptActionParameters = null)
{
$this->scriptActionParameters = $scriptActionParameters;
return $this;
}
/**
* @see Styleable::getStyle()
*/
public function getStyle()
{
return $this->style;
}
/**
* @see Styleable::setStyle()
*/
public function setStyle($style)
{
$this->style = (string)$style;
return $this;
}
/**
* @see TextFormatable::getTextColor()
*/
public function getTextColor()
{
return $this->textColor;
}
/**
* @see TextFormatable::setTextColor()
*/
public function setTextColor($textColor)
{
$this->textColor = (string)$textColor;
return $this;
}
/**
* @see TextFormatable::getTextSize()
*/
public function getTextSize()
{
return $this->textSize;
}
/**
* @see TextFormatable::setTextSize()
*/
public function setTextSize($textSize)
{
$this->textSize = (int)$textSize;
return $this;
}
/**
* @see TextFormatable::getTextFont()
*/
public function getTextFont()
{
return $this->textFont;
}
/**
* @see TextFormatable::setTextFont()
*/
public function setTextFont($textFont)
{
$this->textFont = (string)$textFont;
return $this;
}
/**
* @see TextFormatable::getAreaColor()
*/
public function getAreaColor()
{
return $this->areaColor;
}
/**
* @see TextFormatable::setAreaColor()
*/
public function setAreaColor($areaColor)
{
$this->areaColor = (string)$areaColor;
return $this;
}
/**
* @see TextFormatable::getAreaFocusColor()
*/
public function getAreaFocusColor()
{
return $this->focusAreaColor;
}
/**
* @see TextFormatable::setAreaFocusColor()
*/
public function setAreaFocusColor($areaFocusColor)
{
$this->focusAreaColor = (string)$areaFocusColor;
return $this;
}
/**
* @see Control::getTagName()
*/
public function getTagName()
{
return "textedit";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlTextEdit";
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->default !== null) {
$domElement->setAttribute("default", $this->default);
}
if ($this->autoNewLine) {
$domElement->setAttribute("autonewline", 1);
}
if ($this->lineSpacing > 0) {
$domElement->setAttribute("linespacing", $this->lineSpacing);
}
if ($this->maxLines > 0) {
$domElement->setAttribute("maxline", $this->maxLines);
}
if ($this->showLineNumbers) {
$domElement->setAttribute("showlinenumbers", 1);
}
if ($this->textFormat) {
$domElement->setAttribute("textformat", $this->textFormat);
}
if ($this->scriptEvents) {
$domElement->setAttribute("scriptevents", 1);
}
if ($this->scriptAction) {
$scriptAction = array($this->scriptAction);
if ($this->scriptActionParameters) {
$scriptAction = array_merge($scriptAction, $this->scriptActionParameters);
}
$domElement->setAttribute("scriptaction", implode("'", $scriptAction));
}
if ($this->style) {
$domElement->setAttribute("style", $this->style);
}
if ($this->textColor) {
$domElement->setAttribute("textcolor", $this->textColor);
}
if ($this->textSize) {
$domElement->setAttribute("textsize", $this->textSize);
}
if ($this->textFont) {
$domElement->setAttribute("textfont", $this->textFont);
}
if ($this->areaColor) {
$domElement->setAttribute("focusareacolor1", $this->areaColor);
}
if ($this->focusAreaColor) {
$domElement->setAttribute("focusareacolor2", $this->focusAreaColor);
}
return $domElement;
}
}

View File

@ -10,108 +10,262 @@ use FML\Types\Scriptable;
* (CMlMediaPlayer)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Video extends Control implements Playable, Scriptable {
/*
* Protected properties
class Video extends Control implements Playable, Scriptable
{
/**
* @var string $data Data url
*/
protected $tagName = 'video';
protected $data = null;
/**
* @var string $dataId Data id
*/
protected $dataId = null;
/**
* @var bool $play Play automaticcaly
*/
protected $play = null;
/**
* @var bool $looping Looping
*/
protected $looping = true;
/**
* @var bool $music Music type
*/
protected $music = null;
/**
* @var float $volume Volume
*/
protected $volume = 1.;
/**
* @var bool $scriptEvents Script events usage
*/
protected $scriptEvents = null;
/**
* @see \FML\Controls\Control::getManiaScriptClass()
* @var string $scriptAction Script action
*/
public function getManiaScriptClass() {
return 'CMlMediaPlayer';
protected $scriptAction = null;
/**
* @var string[] $scriptActionParameters Script action parameters
*/
protected $scriptActionParameters = null;
/**
* @see Playable::getData()
*/
public function getData()
{
return $this->data;
}
/**
* @see \FML\Types\Playable::setData()
* @see Playable::setData()
*/
public function setData($data) {
public function setData($data)
{
$this->data = (string)$data;
return $this;
}
/**
* @see \FML\Types\Playable::setDataId()
* @see Playable::getDataId()
*/
public function setDataId($dataId) {
public function getDataId()
{
return $this->dataId;
}
/**
* @see Playable::setDataId()
*/
public function setDataId($dataId)
{
$this->dataId = (string)$dataId;
return $this;
}
/**
* @see \FML\Types\Playable::setPlay()
* @see Playable::getPlay()
*/
public function setPlay($play) {
$this->play = ($play ? 1 : 0);
public function getPlay()
{
return $this->play;
}
/**
* @see Playable::setPlay()
*/
public function setPlay($play)
{
$this->play = (bool)$play;
return $this;
}
/**
* @see \FML\Types\Playable::setLooping()
* @see Playable::getLooping()
*/
public function setLooping($looping) {
$this->looping = ($looping ? 1 : 0);
public function getLooping()
{
return $this->looping;
}
/**
* @see Playable::setLooping()
*/
public function setLooping($looping)
{
$this->looping = (bool)$looping;
return $this;
}
/**
* @see \FML\Types\Playable::setMusic()
* @see Playable::getMusic()
*/
public function setMusic($music) {
$this->music = ($music ? 1 : 0);
public function getMusic()
{
return $this->music;
}
/**
* @see Playable::setMusic()
*/
public function setMusic($music)
{
$this->music = (bool)$music;
return $this;
}
/**
* @see \FML\Types\Playable::setVolume()
* @see Playable::getVolume()
*/
public function setVolume($volume) {
public function getVolume()
{
return $this->volume;
}
/**
* @see Playable::setVolume()
*/
public function setVolume($volume)
{
$this->volume = (float)$volume;
return $this;
}
/**
* @see \FML\Types\Scriptable::setScriptEvents()
* @see Scriptable::getScriptEvents()
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
public function getScriptEvents()
{
return $this->scriptEvents;
}
/**
* @see Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents)
{
$this->scriptEvents = (bool)$scriptEvents;
return $this;
}
/**
* @see \FML\Types\Renderable::render()
* @see Scriptable::getScriptAction()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
public function getScriptAction()
{
return $this->scriptAction;
}
/**
* @see Scriptable::setScriptAction()
*/
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
{
$this->scriptAction = (string)$scriptAction;
$this->setScriptActionParameters($scriptActionParameters);
return $this;
}
/**
* @see Scriptable::getScriptActionParameters()
*/
public function getScriptActionParameters()
{
return $this->scriptActionParameters;
}
/**
* @see Scriptable::setScriptActionParameters()
*/
public function setScriptActionParameters(array $scriptActionParameters = null)
{
$this->scriptActionParameters = $scriptActionParameters;
return $this;
}
/**
* @see Control::getTagName()
*/
public function getTagName()
{
return "video";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlMediaPlayer";
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->data) {
$xmlElement->setAttribute('data', $this->data);
$domElement->setAttribute("data", $this->data);
}
if ($this->dataId) {
$domElement->setAttribute("dataid", $this->dataId);
}
if ($this->play) {
$xmlElement->setAttribute('play', $this->play);
$domElement->setAttribute("play", 1);
}
if (!$this->looping) {
$xmlElement->setAttribute('looping', $this->looping);
$domElement->setAttribute("looping", 0);
}
if ($this->music) {
$xmlElement->setAttribute('music', $this->music);
$domElement->setAttribute("music", 1);
}
if ($this->volume != 1.) {
$xmlElement->setAttribute('volume', $this->volume);
$domElement->setAttribute("volume", $this->volume);
}
if ($this->scriptEvents) {
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
$domElement->setAttribute("scriptevents", 1);
}
return $xmlElement;
if ($this->scriptAction) {
$scriptAction = array($this->scriptAction);
if ($this->scriptActionParameters) {
$scriptAction = array_merge($scriptAction, $this->scriptActionParameters);
}
$domElement->setAttribute("scriptaction", implode("'", $scriptAction));
}
return $domElement;
}
}

View File

@ -6,161 +6,293 @@ namespace FML;
* Class representing a Custom_UI
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CustomUI {
/*
* Protected properties
class CustomUI
{
/**
* @var bool $globalVisible If the UI should be shown at all
*/
protected $encoding = 'utf-8';
protected $tagName = 'custom_ui';
protected $noticeVisible = null;
protected $challengeInfoVisible = null;
protected $netInfosVisible = null;
protected $chatVisible = null;
protected $checkpointListVisible = null;
protected $roundScoresVisible = null;
protected $scoretableVisible = null;
protected $globalVisible = null;
/**
* Create a new CustomUI object
* @var bool $challengeInfoVisible If the challenge info should be shown
*/
protected $challengeInfoVisible = null;
/**
* @var bool $chatVisible If the chat should be shown
*/
protected $chatVisible = null;
/**
* @var bool $checkpointListVisible If the checkpoint list should be shown
*/
protected $checkpointListVisible = null;
/**
* @var bool $netInfosVisible If the net infos should be shown
*/
protected $netInfosVisible = null;
/**
* @var bool $noticeVisible If notices should be shown
*/
protected $noticeVisible = null;
/**
* @var bool $roundScoresVisible If round scores should be shown
*/
protected $roundScoresVisible = null;
/**
* @var bool $scoretableVisible If the score table should be shown
*/
protected $scoretableVisible = null;
/**
* Create a new CustomUI
*
* @api
* @return static
*/
public static function create() {
public static function create()
{
return new static();
}
/**
* Set XML encoding
* Get global visibility
*
* @param string $encoding XML encoding
* @return static
* @api
* @return bool
*/
public function setXMLEncoding($encoding) {
$this->encoding = (string)$encoding;
return $this;
public function getGlobalVisible()
{
return $this->globalVisible;
}
/**
* Set showing of notices
* Set global visibility
*
* @param bool $visible Whether notices should be shown
* @api
* @param bool $visible If the UI should be shown at all
* @return static
*/
public function setNoticeVisible($visible) {
$this->noticeVisible = $visible;
return $this;
}
/**
* Set showing of the challenge info
*
* @param bool $visible Whether the challenge info should be shown
* @return static
*/
public function setChallengeInfoVisible($visible) {
$this->challengeInfoVisible = $visible;
return $this;
}
/**
* Set showing of the net infos
*
* @param bool $visible Whether the net infos should be shown
* @return static
*/
public function setNetInfosVisible($visible) {
$this->netInfosVisible = $visible;
return $this;
}
/**
* Set showing of the chat
*
* @param bool $visible Whether the chat should be shown
* @return static
*/
public function setChatVisible($visible) {
$this->chatVisible = $visible;
return $this;
}
/**
* Set showing of the checkpoint list
*
* @param bool $visible Whether the checkpoint should be shown
* @return static
*/
public function setCheckpointListVisible($visible) {
$this->checkpointListVisible = $visible;
return $this;
}
/**
* Set showing of round scores
*
* @param bool $visible Whether the round scores should be shown
* @return static
*/
public function setRoundScoresVisible($visible) {
$this->roundScoresVisible = $visible;
return $this;
}
/**
* Set showing of the scoretable
*
* @param bool $visible Whether the scoretable should be shown
* @return static
*/
public function setScoretableVisible($visible) {
$this->scoretableVisible = $visible;
return $this;
}
/**
* Set global showing
*
* @param bool $visible Whether the UI should be disabled completely
* @return static
*/
public function setGlobalVisible($visible) {
public function setGlobalVisible($visible)
{
$this->globalVisible = $visible;
return $this;
}
/**
* Render the XML document
* Get showing of the challenge info
*
* @api
* @return bool
*/
public function getChallengeInfoVisible()
{
return $this->challengeInfoVisible;
}
/**
* Set showing of the challenge info
*
* @api
* @param bool $visible If the challenge info should be shown
* @return static
*/
public function setChallengeInfoVisible($visible)
{
$this->challengeInfoVisible = $visible;
return $this;
}
/**
* Get showing of the chat
*
* @api
* @return bool
*/
public function getChatVisible()
{
return $this->chatVisible;
}
/**
* Set showing of the chat
*
* @api
* @param bool $visible If the chat should be shown
* @return static
*/
public function setChatVisible($visible)
{
$this->chatVisible = $visible;
return $this;
}
/**
* Get showing of the checkpoint list
*
* @api
* @return bool
*/
public function getCheckpointListVisible()
{
return $this->checkpointListVisible;
}
/**
* Set showing of the checkpoint list
*
* @api
* @param bool $visible If the checkpoint list should be shown
* @return static
*/
public function setCheckpointListVisible($visible)
{
$this->checkpointListVisible = $visible;
return $this;
}
/**
* Get showing of the net infos
*
* @api
* @return bool
*/
public function getNetInfosVisible()
{
return $this->netInfosVisible;
}
/**
* Set showing of the net infos
*
* @api
* @param bool $visible If the net infos should be shown
* @return static
*/
public function setNetInfosVisible($visible)
{
$this->netInfosVisible = $visible;
return $this;
}
/**
* Get showing of notices
*
* @api
* @return bool
*/
public function getNoticeVisible()
{
return $this->noticeVisible;
}
/**
* Set showing of notices
*
* @api
* @param bool $visible If notices should be shown
* @return static
*/
public function setNoticeVisible($visible)
{
$this->noticeVisible = $visible;
return $this;
}
/**
* Get showing of round scores
*
* @api
* @return bool
*/
public function getRoundScoresVisible()
{
return $this->roundScoresVisible;
}
/**
* Set showing of round scores
*
* @api
* @param bool $visible If round scores should be shown
* @return static
*/
public function setRoundScoresVisible($visible)
{
$this->roundScoresVisible = $visible;
return $this;
}
/**
* Get showing of the score table
*
* @api
* @return bool
*/
public function getScoretableVisible()
{
return $this->scoretableVisible;
}
/**
* Set showing of the score table
*
* @api
* @param bool $visible If the score table should be shown
* @return static
*/
public function setScoretableVisible($visible)
{
$this->scoretableVisible = $visible;
return $this;
}
/**
* Render the CustomUI standalone
*
* @param \DOMDocument $domDocument (optional) DOMDocument for which the XML element should be rendered
* @return \DOMDocument
*/
public function render($domDocument = null) {
$isChild = (bool)$domDocument;
if (!$isChild) {
$domDocument = new \DOMDocument('1.0', $this->encoding);
public function renderStandalone()
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$domElement = $this->render($domDocument);
$domDocument->appendChild($domElement);
return $domDocument;
}
$xmlElement = $domDocument->createElement($this->tagName);
if (!$isChild) {
$domDocument->appendChild($xmlElement);
}
/**
* Render the CustomUI
*
* @param \DOMDocument $domDocument DOMDocument for which the CustomUI should be rendered
* @return \DOMElement
*/
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("custom_ui");
$settings = $this->getSettings();
foreach ($settings as $setting => $value) {
if ($value === null) {
continue;
}
$xmlSubElement = $domDocument->createElement($setting);
$xmlSubElement->setAttribute('visible', ($value ? 1 : 0));
$xmlElement->appendChild($xmlSubElement);
$settingDomElement = $domDocument->createElement($setting);
$settingDomElement->setAttribute("visible", ($value ? 1 : 0));
$domElement->appendChild($settingDomElement);
}
if ($isChild) {
return $xmlElement;
}
return $domDocument;
return $domElement;
}
/**
@ -168,8 +300,10 @@ class CustomUI {
*
* @return string
*/
public function __toString() {
return $this->render()->saveXML();
public function __toString()
{
return $this->renderStandalone()
->saveXML();
}
/**
@ -177,16 +311,18 @@ class CustomUI {
*
* @return array
*/
protected function getSettings() {
$settings = array();
$settings['challenge_info'] = $this->challengeInfoVisible;
$settings['chat'] = $this->chatVisible;
$settings['checkpoint_list'] = $this->checkpointListVisible;
$settings['global'] = $this->globalVisible;
$settings['net_infos'] = $this->netInfosVisible;
$settings['notice'] = $this->noticeVisible;
$settings['round_scores'] = $this->roundScoresVisible;
$settings['scoretable'] = $this->scoretableVisible;
return $settings;
protected function getSettings()
{
return array(
"global" => $this->globalVisible,
"challenge_info" => $this->challengeInfoVisible,
"chat" => $this->chatVisible,
"checkpoint_list" => $this->checkpointListVisible,
"net_infos" => $this->netInfosVisible,
"notice" => $this->noticeVisible,
"round_scores" => $this->roundScoresVisible,
"scoretable" => $this->scoretableVisible
);
}
}

View File

@ -6,10 +6,12 @@ namespace FML\Elements;
* Dictionary Element
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Dico {
class Dico
{
/**
* Czech language
*
@ -153,27 +155,46 @@ class Dico {
/*
* Protected properties
*/
protected $tagName = 'dico';
protected $entries = array();
/**
* Create a new Dictionary object
* Create a new Dico
*
* @api
* @return static
*/
public static function create() {
public static function create()
{
return new static();
}
/**
* Get the translatable entry
*
* @api
* @param string $language Language id
* @param string $entryId Entry id
* @return string
*/
public function getEntry($language, $entryId)
{
if (isset($this->entries[$language]) && isset($this->entries[$language][$entryId])) {
return $this->entries[$language][$entryId];
}
return null;
}
/**
* Set the translatable entry for the specific language
*
* @api
* @param string $language Language id
* @param string $entryId Entry id
* @param string $entryValue Translated entry value
* @return static
*/
public function setEntry($language, $entryId, $entryValue) {
public function setEntry($language, $entryId, $entryValue)
{
$language = (string)$language;
$entryId = (string)$entryId;
$entryValue = (string)$entryValue;
@ -193,22 +214,16 @@ class Dico {
/**
* Remove entries of the given id
*
* @api
* @param string $entryId Entry id that should be removed
* @param string $language (optional) Only remove entries of the given language
* @return static
*/
public function removeEntry($entryId, $language = null) {
public function removeEntry($entryId)
{
$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]);
}
if (isset($this->entries[$language][$entryId])) {
unset($this->entries[$language][$entryId]);
}
}
return $this;
@ -217,50 +232,50 @@ class Dico {
/**
* Remove entries of the given language
*
* @api
* @param string $language Language which entries should be removed
* @param string $entryId (optional) Only remove the given entry id
* @return static
*/
public function removeLanguage($language, $entryId = null) {
public function removeLanguage($language)
{
$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
* Remove all entries
*
* @api
* @return static
*/
public function removeEntries() {
public function removeAllEntries()
{
$this->entries = array();
return $this;
}
/**
* Render the Dico XML element
* Render the Dico
*
* @param \DOMDocument $domDocument DOMDocument for which the Dico XML element should be rendered
* @param \DOMDocument $domDocument DOMDocument for which the Dico should be rendered
* @return \DOMElement
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("dico");
foreach ($this->entries as $language => $entries) {
$languageElement = $domDocument->createElement('language');
$languageElement->setAttribute('id', $language);
$languageElement = $domDocument->createElement("language");
$languageElement->setAttribute("id", $language);
foreach ($entries as $entryId => $entryValue) {
$entryElement = $domDocument->createElement($entryId, $entryValue);
$languageElement->appendChild($entryElement);
}
$xmlElement->appendChild($languageElement);
$domElement->appendChild($languageElement);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -2,7 +2,7 @@
namespace FML\Elements;
use FML\Types\BgColorable;
use FML\Types\BackgroundColorable;
use FML\Types\Renderable;
use FML\Types\Styleable;
use FML\Types\TextFormatable;
@ -11,113 +11,205 @@ use FML\Types\TextFormatable;
* Format Element
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Format implements BgColorable, Renderable, Styleable, TextFormatable {
/*
* Protected properties
*/
protected $tagName = 'format';
protected $bgColor = null;
protected $style = null;
protected $textSize = -1;
protected $textFont = null;
protected $textColor = null;
protected $focusAreaColor1 = null;
protected $focusAreaColor2 = null;
class Format implements BackgroundColorable, Renderable, Styleable, TextFormatable
{
/**
* Create a new Format Element
* @var string $backgroundColor Background color
*/
protected $backgroundColor = null;
/**
* @var string $style Style
*/
protected $style = null;
/**
* @var int $textSize Text size
*/
protected $textSize = null;
/**
* @var string $textFont Text font
*/
protected $textFont = null;
/**
* @var string $textColor Text color
*/
protected $textColor = null;
/**
* @var string $areaColor Area color
*/
protected $areaColor = null;
/**
* @var string $focusAreaColor Focus area color
*/
protected $focusAreaColor = null;
/**
* Create a new Format
*
* @api
* @return static
*/
public static function create() {
public static function create()
{
return new static();
}
/**
* @see \FML\Types\BgColorable::setBgColor()
* @see BgColorable::getBackgroundColor()
*/
public function setBgColor($bgColor) {
$this->bgColor = (string)$bgColor;
public function getBackgroundColor()
{
return $this->backgroundColor;
}
/**
* @see BgColorable::setBackgroundColor()
*/
public function setBackgroundColor($backgroundColor)
{
$this->backgroundColor = (string)$backgroundColor;
return $this;
}
/**
* @see \FML\Types\Styleable::setStyle()
* @see Styleable::getStyle()
*/
public function setStyle($style) {
public function getStyle()
{
return $this->style;
}
/**
* @see Styleable::setStyle()
*/
public function setStyle($style)
{
$this->style = (string)$style;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setTextSize()
* @see TextFormatable::getTextSize()
*/
public function setTextSize($textSize) {
public function getTextSize()
{
return $this->textSize;
}
/**
* @see TextFormatable::setTextSize()
*/
public function setTextSize($textSize)
{
$this->textSize = (int)$textSize;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setTextFont()
* @see TextFormatable::getTextFont()
*/
public function setTextFont($textFont) {
public function getTextFont()
{
return $this->textFont;
}
/**
* @see TextFormatable::setTextFont()
*/
public function setTextFont($textFont)
{
$this->textFont = (string)$textFont;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setTextColor()
* @see TextFormatable::getTextColor()
*/
public function setTextColor($textColor) {
public function getTextColor()
{
return $this->textColor;
}
/**
* @see TextFormatable::setTextColor()
*/
public function setTextColor($textColor)
{
$this->textColor = (string)$textColor;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setAreaColor()
* @see TextFormatable::getAreaColor()
*/
public function setAreaColor($areaColor) {
$this->focusAreaColor1 = (string)$areaColor;
public function getAreaColor()
{
return $this->areaColor;
}
/**
* @see TextFormatable::setAreaColor()
*/
public function setAreaColor($areaColor)
{
$this->areaColor = (string)$areaColor;
return $this;
}
/**
* @see \FML\Types\TextFormatable::setAreaFocusColor()
* @see TextFormatable::getAreaFocusColor()
*/
public function setAreaFocusColor($areaFocusColor) {
$this->focusAreaColor2 = (string)$areaFocusColor;
public function getAreaFocusColor()
{
return $this->focusAreaColor;
}
/**
* @see TextFormatable::setAreaFocusColor()
*/
public function setAreaFocusColor($areaFocusColor)
{
$this->focusAreaColor = (string)$areaFocusColor;
return $this;
}
/**
* @see \FML\Types\Renderable::render()
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$formatXmlElement = $domDocument->createElement($this->tagName);
if ($this->bgColor) {
$formatXmlElement->setAttribute('bgcolor', $this->bgColor);
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("format");
if ($this->backgroundColor) {
$domElement->setAttribute("bgcolor", $this->backgroundColor);
}
if ($this->style) {
$formatXmlElement->setAttribute('style', $this->style);
$domElement->setAttribute("style", $this->style);
}
if ($this->textSize >= 0) {
$formatXmlElement->setAttribute('textsize', $this->textSize);
if ($this->textSize) {
$domElement->setAttribute("textsize", $this->textSize);
}
if ($this->textFont) {
$formatXmlElement->setAttribute('textfont', $this->textFont);
$domElement->setAttribute("textfont", $this->textFont);
}
if ($this->textColor) {
$formatXmlElement->setAttribute('textcolor', $this->textColor);
$domElement->setAttribute("textcolor", $this->textColor);
}
if ($this->focusAreaColor1) {
$formatXmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1);
if ($this->areaColor) {
$domElement->setAttribute("focusareacolor1", $this->areaColor);
}
if ($this->focusAreaColor2) {
$formatXmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2);
if ($this->focusAreaColor) {
$domElement->setAttribute("focusareacolor2", $this->focusAreaColor);
}
return $formatXmlElement;
return $domElement;
}
}

View File

@ -3,6 +3,7 @@
namespace FML\Elements;
use FML\Types\Container;
use FML\Types\Identifiable;
use FML\Types\Renderable;
use FML\UniqueID;
@ -10,56 +11,110 @@ use FML\UniqueID;
* Class representing a Frame Model
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class FrameModel implements Container, Renderable {
/*
* Protected properties
class FrameModel implements Container, Identifiable, Renderable
{
/**
* @var string $modelId Model id
*/
protected $tagName = 'framemodel';
protected $modelId = null;
/** @var Renderable[] $children */
/**
* @var Renderable[] $children Children
*/
protected $children = array();
/** @var Format $format */
/**
* @var Format $format Format
*/
protected $format = null;
/**
* Set Model id
* Create a new Frame Model
*
* @api
* @param string $modelId Model id
* @param Renderable[] $children Children
* @return static
*/
public function setId($modelId) {
public static function create($modelId = null, array $children = null)
{
return new static($modelId, $children);
}
/**
* Construct a new Frame Model
*
* @api
* @param string $modelId Model id
* @param Renderable[] $children Children
*/
public function __construct($modelId = null, array $children = null)
{
if ($modelId) {
$this->setId($modelId);
}
if ($children) {
$this->addChildren($children);
}
}
/**
* @see Identifiable::getId()
*/
public function getId()
{
if (!$this->modelId) {
return $this->createId();
}
return $this->modelId;
}
/**
* @see Identifiable::setId()
*/
public function setId($modelId)
{
$this->modelId = (string)$modelId;
return $this;
}
/**
* Get Model id
*
* @return string
* @see Identifiable::checkId()
*/
public function getId() {
return $this->modelId;
public function checkId()
{
return UniqueID::check($this);
}
/**
* Assign an id if necessary
* Create a new model id
*
* @return string
*/
public function checkId() {
if (!$this->modelId) {
$this->setId(UniqueID::create());
}
return $this;
protected function createId()
{
$modelId = UniqueID::create();
$this->setId($modelId);
return $this->getId();
}
/**
* @see \FML\Types\Container::add()
* @see Container::getChildren()
*/
public function add(Renderable $childElement) {
public function getChildren()
{
return $this->children;
}
/**
* @see Container::addChild()
*/
public function addChild(Renderable $childElement)
{
if (!in_array($childElement, $this->children, true)) {
array_push($this->children, $childElement);
}
@ -67,46 +122,61 @@ class FrameModel implements Container, Renderable {
}
/**
* @see \FML\Types\Container::removeChildren()
* @see Container::addChildren()
*/
public function removeChildren() {
public function addChildren(array $children)
{
foreach ($children as $child) {
$this->addChild($child);
}
return $this;
}
/**
* @see Container::removeAllChildren()
*/
public function removeAllChildren()
{
$this->children = array();
return $this;
}
/**
* @see \FML\Types\Container::setFormat()
* @see Container::getFormat()
*/
public function setFormat(Format $format) {
public function getFormat()
{
return $this->format;
}
/**
* @see Container::setFormat()
*/
public function setFormat(Format $format = null)
{
$this->format = $format;
return $this;
}
/**
* @see \FML\Types\Container::getFormat()
* @see Renderable::render()
*/
public function getFormat($createIfEmpty = true) {
if (!$this->format && $createIfEmpty) {
$this->setFormat(new Format());
}
return $this->format;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("framemodel");
$domElement->setAttribute("id", $this->getId());
if ($this->format) {
$formatElement = $this->format->render($domDocument);
$domElement->appendChild($formatElement);
}
/**
* @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);
$domElement->appendChild($childElement);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -8,56 +8,76 @@ use FML\Types\Renderable;
* Include Element
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Including implements Renderable {
/*
* Protected properties
class Including implements Renderable
{
/**
* @var string $url Include url
*/
protected $tagName = 'include';
protected $url = null;
/**
* Create a new Include object
* Create a new Include
*
* @api
* @param string $url (optional) Include url
* @return static
*/
public static function create($url = null) {
public static function create($url = null)
{
return new static($url);
}
/**
* Construct a new Include object
* Construct a new Include
*
* @api
* @param string $url (optional) Include url
*/
public function __construct($url = null) {
if ($url !== null) {
public function __construct($url = null)
{
if ($url) {
$this->setUrl($url);
}
}
/**
* Set url
* Get the url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the url
*
* @api
* @param string $url Include url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\Types\Renderable::render()
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("include");
if ($this->url) {
$xmlElement->setAttribute('url', $this->url);
$domElement->setAttribute("url", $this->url);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -8,56 +8,76 @@ use FML\Types\Renderable;
* Music Element
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Music implements Renderable {
/*
* Protected properties
class Music implements Renderable
{
/**
* @var string $data Media url
*/
protected $tagName = 'music';
protected $data = null;
/**
* Create a new Music object
* Create a new Music
*
* @api
* @param string $data (optional) Media url
* @return static
*/
public static function create($data = null) {
public static function create($data = null)
{
return new static($data);
}
/**
* Construct a new Music object
* Construct a new Music
*
* @api
* @param string $data (optional) Media url
*/
public function __construct($data = null) {
if ($data !== null) {
public function __construct($data = null)
{
if ($data) {
$this->setData($data);
}
}
/**
* Set data url
* Get the media url
*
* @param string $data Data url
* @api
* @return string
*/
public function getData()
{
return $this->data;
}
/**
* Set the media url
*
* @api
* @param string $data Media url
* @return static
*/
public function setData($data) {
public function setData($data)
{
$this->data = (string)$data;
return $this;
}
/**
* @see \FML\Types\Renderable::render()
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("music");
if ($this->data) {
$xmlElement->setAttribute('data', $this->data);
$domElement->setAttribute("data", $this->data);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -8,57 +8,77 @@ use FML\Types\Renderable;
* Class representing a ManiaLink script tag with a simple script text
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class SimpleScript implements Renderable {
/*
* Protected properties
class SimpleScript implements Renderable
{
/**
* @var string $text Script text
*/
protected $tagName = 'script';
protected $text = null;
/**
* Create a new SimpleScript object
* Create a new SimpleScript
*
* @api
* @param string $text (optional) Script text
* @return static
*/
public static function create($text = null) {
public static function create($text = null)
{
return new static($text);
}
/**
* Construct a new SimpleScript object
* Construct a new SimpleScript
*
* @api
* @param string $text (optional) Script text
*/
public function __construct($text = null) {
if ($text !== null) {
public function __construct($text = null)
{
if ($text) {
$this->setText($text);
}
}
/**
* Set script text
* Get the script text
*
* @api
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* Set the script text
*
* @api
* @param string $text Complete script text
* @return static
*/
public function setText($text) {
public function setText($text)
{
$this->text = (string)$text;
return $this;
}
/**
* @see \FML\Types\Renderable::render()
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("script");
if ($this->text) {
$scriptComment = $domDocument->createComment($this->text);
$xmlElement->appendChild($scriptComment);
$domElement->appendChild($scriptComment);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace FML\Form;
/**
* Parameters Class
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Parameters
{
/**
* Get the submitted form value
*
* @param string $name Value name
* @return string
*/
public static function getValue($name)
{
if (array_key_exists($name, $_GET)) {
return $_GET[$name];
}
if (array_key_exists($name, $_POST)) {
return $_POST[$name];
}
return null;
}
}

View File

@ -23,297 +23,358 @@ use FML\ManiaCode\ViewReplay;
* Class representing a ManiaCode
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ManiaCode {
/*
* Protected properties
class ManiaCode
{
/**
* @var bool $disableConfirmation Disable the confirmation
*/
protected $disableConfirmation = null;
/**
* @var Element[] $elements ManiaCode Elements
*/
protected $encoding = 'utf-8';
protected $tagName = 'maniacode';
protected $noConfirmation = null;
/** @var Element[] $elements */
protected $elements = array();
/**
* Create a new ManiaCode object
* Create a new ManiaCode
*
* @api
* @return static
*/
public static function create() {
public static function create()
{
return new static();
}
/**
* Set XML encoding
* Get if the confirmation is disabled
*
* @param string $encoding XML encoding
* @return static
* @api
* @return bool
*/
public function setXmlEncoding($encoding) {
$this->encoding = (string)$encoding;
return $this;
public function getDisableConfirmation()
{
return $this->disableConfirmation;
}
/**
* Disable the showing of the confirmation at the end of the ManiaCode
*
* @param bool $disable Whether the confirmation should be shown
* @api
* @param bool $disableConfirmation If the confirmation should be disabled
* @return static
*/
public function disableConfirmation($disable) {
$this->noConfirmation = ($disable ? 1 : 0);
public function setDisableConfirmation($disableConfirmation)
{
$this->disableConfirmation = (bool)$disableConfirmation;
return $this;
}
/**
* Show a message
*
* @api
* @param string $message Message text
* @return static
*/
public function addShowMessage($message) {
public function addShowMessage($message)
{
$messageElement = new ShowMessage($message);
$this->addElement($messageElement);
return $this;
return $this->addElement($messageElement);
}
/**
* Install a Macroblock
*
* @api
* @param string $name Macroblock name
* @param string $file Macroblock file
* @param string $url Macroblock url
* @return static
*/
public function addInstallMacroblock($name, $file, $url) {
public function addInstallMacroblock($name, $file, $url)
{
$macroblockElement = new InstallMacroblock($name, $file, $url);
$this->addElement($macroblockElement);
return $this;
return $this->addElement($macroblockElement);
}
/**
* Install a map
*
* @api
* @param string $name Map name
* @param string $url Map url
* @return static
*/
public function addInstallMap($name, $url) {
public function addInstallMap($name, $url)
{
$mapElement = new InstallMap($name, $url);
$this->addElement($mapElement);
return $this;
return $this->addElement($mapElement);
}
/**
* Play a map
*
* @api
* @param string $name Map name
* @param string $url Map url
* @return static
*/
public function addPlayMap($name, $url) {
public function addPlayMap($name, $url)
{
$mapElement = new PlayMap($name, $url);
$this->addElement($mapElement);
return $this;
return $this->addElement($mapElement);
}
/**
* Install a replay
*
* @api
* @param string $name Replay name
* @param string $url Replay url
* @return static
*/
public function addInstallReplay($name, $url) {
public function addInstallReplay($name, $url)
{
$replayElement = new InstallReplay($name, $url);
$this->addElement($replayElement);
return $this;
return $this->addElement($replayElement);
}
/**
* View a replay
*
* @api
* @param string $name Replay name
* @param string $url Replay url
* @return static
*/
public function addViewReplay($name, $url) {
public function addViewReplay($name, $url)
{
$replayElement = new ViewReplay($name, $url);
$this->addElement($replayElement);
return $this;
return $this->addElement($replayElement);
}
/**
* Play a replay
*
* @api
* @param string $name Replay name
* @param string $url Replay url
* @return static
*/
public function addPlayReplay($name, $url) {
public function addPlayReplay($name, $url)
{
$replayElement = new PlayReplay($name, $url);
$this->addElement($replayElement);
return $this;
return $this->addElement($replayElement);
}
/**
* Install a skin
*
* @api
* @param string $name Skin name
* @param string $file Skin file
* @param string $url Skin url
* @return static
*/
public function addInstallSkin($name, $file, $url) {
public function addInstallSkin($name, $file, $url)
{
$skinElement = new InstallSkin($name, $file, $url);
$this->addElement($skinElement);
return $this;
return $this->addElement($skinElement);
}
/**
* Get a skin
*
* @api
* @param string $name Skin name
* @param string $file Skin file
* @param string $url Skin url
* @return static
*/
public function addGetSkin($name, $file, $url) {
public function addGetSkin($name, $file, $url)
{
$skinElement = new GetSkin($name, $file, $url);
$this->addElement($skinElement);
return $this;
return $this->addElement($skinElement);
}
/**
* Add a buddy
*
* @api
* @param string $login Buddy login
* @return static
*/
public function addAddBuddy($login) {
public function addAddBuddy($login)
{
$buddyElement = new AddBuddy($login);
$this->addElement($buddyElement);
return $this;
return $this->addElement($buddyElement);
}
/**
* Go to a link
*
* @api
* @param string $link Goto link
* @return static
*/
public function addGoto($link) {
public function addGoto($link)
{
$gotoElement = new Go_To($link);
$this->addElement($gotoElement);
return $this;
return $this->addElement($gotoElement);
}
/**
* Join a server
*
* @api
* @param string $login Server login
* @return static
*/
public function addJoinServer($login) {
public function addJoinServer($login)
{
$serverElement = new JoinServer($login);
$this->addElement($serverElement);
return $this;
return $this->addElement($serverElement);
}
/**
* Add a server as favorite
*
* @api
* @param string $login Server login
* @return static
*/
public function addAddFavorite($login) {
public function addAddFavorite($login)
{
$favoriteElement = new AddFavorite($login);
$this->addElement($favoriteElement);
return $this;
return $this->addElement($favoriteElement);
}
/**
* Install a script
*
* @api
* @param string $name Script name
* @param string $file Script file
* @param string $url Script url
* @return static
*/
public function addInstallScript($name, $file, $url) {
public function addInstallScript($name, $file, $url)
{
$scriptElement = new InstallScript($name, $file, $url);
$this->addElement($scriptElement);
return $this;
return $this->addElement($scriptElement);
}
/**
* Install a title pack
*
* @api
* @param string $name Pack name
* @param string $file Pack file
* @param string $url Pack url
* @return static
*/
public function addInstallPack($name, $file, $url) {
public function addInstallPack($name, $file, $url)
{
$packElement = new InstallPack($name, $file, $url);
$this->addElement($packElement);
return $this;
return $this->addElement($packElement);
}
/**
* Add a ManiaCode element
* Get all Elements
*
* @api
* @return Element[]
*/
public function getElements()
{
return $this->elements;
}
/**
* Add a ManiaCode Element
*
* @api
* @param Element $element Element to add
* @return static
*/
public function addElement(Element $element) {
public function addElement(Element $element)
{
if (!in_array($element, $this->elements, true)) {
array_push($this->elements, $element);
}
return $this;
}
/**
* Remove all elements from the ManiaCode
* Remove all ManiaCode Elements
*
* @api
* @return static
* @deprecated use removeAllElements() instead
*/
public function removeElements()
{
return $this->removeAllElements();
}
/**
* Remove all ManiaCode Elements
*
* @api
* @return static
*/
public function removeElements() {
public function removeAllElements()
{
$this->elements = array();
return $this;
}
/**
* Render the XML document
* Render the ManiaCode
*
* @param bool $echo (optional) Whether the XML text should be echoed and the Content-Type header should be set
* @api
* @param bool $echo (optional) If the XML text should be echoed and the Content-Type header should be set
* @return \DOMDocument
*/
public function render($echo = false) {
$domDocument = new \DOMDocument('1.0', $this->encoding);
public function render($echo = false)
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$maniaCode = $domDocument->createElement($this->tagName);
$domDocument->appendChild($maniaCode);
if ($this->noConfirmation) {
$maniaCode->setAttribute('noconfirmation', $this->noConfirmation);
$domElement = $domDocument->createElement("maniacode");
$domDocument->appendChild($domElement);
if ($this->disableConfirmation) {
$domElement->setAttribute("noconfirmation", 1);
}
foreach ($this->elements as $element) {
$xmlElement = $element->render($domDocument);
$maniaCode->appendChild($xmlElement);
$childDomElement = $element->render($domDocument);
$domElement->appendChild($childDomElement);
}
if ($echo) {
header('Content-Type: application/xml; charset=utf-8;');
header("Content-Type: application/xml; charset=utf-8;");
echo $domDocument->saveXML();
}
return $domDocument;
}
/**
* Get string representation
* Get the string representation
*
* @return string
*/
public function __toString() {
return $this->render()->saveXML();
public function __toString()
{
return $this->render()
->saveXML();
}
}

View File

@ -6,55 +6,77 @@ namespace FML\ManiaCode;
* ManiaCode Element adding a buddy
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class AddBuddy extends Element {
/*
* Protected properties
class AddBuddy implements Element
{
/**
* @var string $login Buddy login
*/
protected $tagName = 'add_buddy';
protected $login = null;
/**
* Create a new AddBuddy Element
*
* @api
* @param string $login (optional) Buddy login
* @return static
*/
public static function create($login = null) {
public static function create($login = null)
{
return new static($login);
}
/**
* Construct a new AddBuddy Element
*
* @api
* @param string $login (optional) Buddy login
*/
public function __construct($login = null) {
if ($login !== null) {
public function __construct($login = null)
{
if ($login) {
$this->setLogin($login);
}
}
/**
* Get the buddy login
*
* @api
* @return string
*/
public function getLogin()
{
return $this->login;
}
/**
* Set the buddy login
*
* @api
* @param string $login Buddy login
* @return static
*/
public function setLogin($login) {
public function setLogin($login)
{
$this->login = (string)$login;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$loginElement = $domDocument->createElement('login', $this->login);
$xmlElement->appendChild($loginElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("add_buddy");
$loginElement = $domDocument->createElement("login", $this->login);
$domElement->appendChild($loginElement);
return $domElement;
}
}

View File

@ -6,78 +6,150 @@ namespace FML\ManiaCode;
* ManiaCode Element adding a server as favorite
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class AddFavorite extends Element {
/*
* Protected properties
*/
protected $tagName = 'add_favourite';
protected $login = null;
protected $serverIp = null;
protected $serverPort = null;
class AddFavorite implements Element
{
/**
* Create a new AddFavorite object
* @var string $login Server login
*/
protected $login = null;
/**
* @var string $ip Server ip
*/
protected $ip = null;
/**
* @var int $port Server port
*/
protected $port = null;
/**
* Create a new AddFavorite Element
*
* @param string $login (optional) Server login
* @api
* @param string $loginOrIp (optional) Server login or ip
* @param int $port (optional) Server port
* @return static
*/
public static function create($login = null) {
return new static($login);
public static function create($loginOrIp = null, $port = null)
{
return new static($loginOrIp, $port);
}
/**
* Construct a new AddFavorite object
* Construct a new AddFavorite Element
*
* @param string $login (optional) Server login
* @api
* @param string $loginOrIp (optional) Server login or ip
* @param int $port (optional) Server port
*/
public function __construct($login = null) {
if ($login !== null) {
$this->setLogin($login);
public function __construct($loginOrIp = null, $port = null)
{
if ($port) {
$this->setIp($loginOrIp, $port);
} elseif ($loginOrIp) {
$this->setLogin($loginOrIp);
}
}
/**
* Get the server login
*
* @api
* @return string
*/
public function getLogin()
{
return $this->login;
}
/**
* Set the server login
*
* @api
* @param string $login Server login
* @return static
*/
public function setLogin($login) {
public function setLogin($login)
{
$this->login = (string)$login;
$this->serverIp = null;
$this->serverPort = null;
$this->ip = null;
$this->port = null;
return $this;
}
/**
* Get the server ip
*
* @api
* @return string
*/
public function getIp()
{
return $this->ip;
}
/**
* Set the server ip and port
*
* @param string $serverIp Server ip
* @param int $serverPort Server port
* @api
* @param string $ip Server ip
* @param int $port (optional) Server port
* @return static
*/
public function setIp($serverIp, $serverPort) {
$this->serverIp = (string)$serverIp;
$this->serverPort = (int)$serverPort;
public function setIp($ip, $port = null)
{
$this->login = null;
$this->ip = (string)$ip;
if ($port) {
$this->setPort($port);
}
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* Get the server port
*
* @api
* @return int
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
if ($this->serverIp === null) {
$loginElement = $domDocument->createElement('login', $this->login);
$xmlElement->appendChild($loginElement);
public function getPort()
{
return $this->port;
}
/**
* Set the server port
*
* @param int $port Server port
* @return static
*/
public function setPort($port)
{
$this->port = (int)$port;
return $this;
}
/**
* @see Element::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("add_favourite");
if ($this->login) {
$loginElement = $domDocument->createElement("login", $this->login);
$domElement->appendChild($loginElement);
} else {
$ipElement = $domDocument->createElement('ip', $this->serverIp . ':' . $this->serverPort);
$xmlElement->appendChild($ipElement);
$ipElement = $domDocument->createElement("ip", $this->ip . ":" . $this->port);
$domElement->appendChild($ipElement);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -6,14 +6,11 @@ namespace FML\ManiaCode;
* Base ManiaCode Element
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class Element {
/*
* Protected properties
*/
protected $tagName = 'element';
interface Element
{
/**
* Render the ManiaCode Element
@ -21,8 +18,6 @@ abstract class Element {
* @param \DOMDocument $domDocument The DOMDocument for which the Element should be rendered
* @return \DOMElement
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
return $xmlElement;
}
public function render(\DOMDocument $domDocument);
}

View File

@ -6,93 +6,151 @@ namespace FML\ManiaCode;
* ManiaCode Element downloading a skin
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class GetSkin extends Element {
/*
* Protected properties
class GetSkin implements Element
{
/**
* @var string $name Skin name
*/
protected $tagName = 'get_skin';
protected $name = null;
/**
* @var string $file Skin file
*/
protected $file = null;
/**
* @var string $url Skin url
*/
protected $url = null;
/**
* Create a new GetSkin object
* Create a new GetSkin Element
*
* @api
* @param string $name (optional) Skin name
* @param string $file (optional) Skin file
* @param string $url (optional) Skin url
* @return static
*/
public static function create($name = null, $file = null, $url = null) {
public static function create($name = null, $file = null, $url = null)
{
return new static($name, $file, $url);
}
/**
* Construct a new GetSkin object
* Construct a new GetSkin Element
*
* @api
* @param string $name (optional) Skin name
* @param string $file (optional) Skin file
* @param string $url (optional) Skin url
*/
public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) {
public function __construct($name = null, $file = null, $url = null)
{
if ($name) {
$this->setName($name);
}
if ($file !== null) {
if ($file) {
$this->setFile($file);
}
if ($url !== null) {
if ($url) {
$this->setUrl($url);
}
}
/**
* Set the name of the skin
* Get the skin name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the skin name
*
* @api
* @param string $name Skin name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set the file of the skin
* Get the skin file
*
* @api
* @return string
*/
public function getFile()
{
return $this->file;
}
/**
* Set the skin file
*
* @api
* @param string $file Skin file
* @return static
*/
public function setFile($file) {
public function setFile($file)
{
$this->file = (string)$file;
return $this;
}
/**
* Set the url of the skin
* Get the skin url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the skin url
*
* @api
* @param string $url Skin url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$fileElement = $domDocument->createElement('file', $this->file);
$xmlElement->appendChild($fileElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("get_skin");
$nameElement = $domDocument->createElement("name", $this->name);
$domElement->appendChild($nameElement);
$fileElement = $domDocument->createElement("file", $this->file);
$domElement->appendChild($fileElement);
$urlElement = $domDocument->createElement("url", $this->url);
$domElement->appendChild($urlElement);
return $domElement;
}
}

View File

@ -6,55 +6,77 @@ namespace FML\ManiaCode;
* ManiaCode Element for going to a link
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Go_To extends Element {
/*
* Protected properties
class Go_To implements Element
{
/**
* @var string $link Link
*/
protected $tagName = 'goto';
protected $link = null;
/**
* Create a new Go_To object
* Create a new Go_To Element
*
* @param string $link (optional) Goto link
* @api
* @param string $link (optional) Link
* @return static
*/
public static function create($link = null) {
public static function create($link = null)
{
return new static($link);
}
/**
* Construct a new Go_To object
* Construct a new Go_To Element
*
* @param string $link (optional) Goto link
* @api
* @param string $link (optional) Link
*/
public function __construct($link = null) {
if ($link !== null) {
public function __construct($link = null)
{
if ($link) {
$this->setLink($link);
}
}
/**
* Set link
* Get the link
*
* @param string $link Goto link
* @api
* @return string
*/
public function getLink()
{
return $this->link;
}
/**
* Set the link
*
* @api
* @param string $link Link
* @return static
*/
public function setLink($link) {
public function setLink($link)
{
$this->link = (string)$link;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$linkElement = $domDocument->createElement('link', $this->link);
$xmlElement->appendChild($linkElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("goto");
$linkElement = $domDocument->createElement("link", $this->link);
$domElement->appendChild($linkElement);
return $domElement;
}
}

View File

@ -6,92 +6,151 @@ namespace FML\ManiaCode;
* ManiaCode Element installing a macroblock
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class InstallMacroblock extends Element {
/*
* Protected properties
class InstallMacroblock implements Element
{
/**
* @var string $name Macroblock name
*/
protected $tagName = 'install_macroblock';
protected $name = null;
/**
* @var string $file Macroblock file
*/
protected $file = null;
/**
* @var string $url Macroblock url
*/
protected $url = null;
/**
* Create a new InstallMacroblock object
* Create a new InstallMacroblock Element
*
* @api
* @param string $name (optional) Macroblock name
* @param string $file (optional) Macroblock file
* @param string $url (optional) Macroblock url
* @return static
*/
public static function create($name = null, $url = null) {
return new static($name, $url);
public static function create($name = null, $file = null, $url = null)
{
return new static($name, $file, $url);
}
/**
* Construct a new InstallMacroblock object
* Construct a new InstallMacroblock Element
*
* @api
* @param string $name (optional) Macroblock name
* @param string $file (optional) Macroblock file
* @param string $url (optional) Macroblock url
*/
public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) {
public function __construct($name = null, $file = null, $url = null)
{
if ($name) {
$this->setName($name);
}
if ($file !== null) {
if ($file) {
$this->setFile($file);
}
if ($url !== null) {
if ($url) {
$this->setUrl($url);
}
}
/**
* Set the name of the macroblock
* Get the macroblock name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the macroblock name
*
* @api
* @param string $name Macroblock name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set the file of the macroblock
* Get the macroblock file
*
* @api
* @return string
*/
public function getFile()
{
return $this->file;
}
/**
* Set the macroblock file
*
* @api
* @param string $file Macroblock file
* @return static
*/
public function setFile($file) {
public function setFile($file)
{
$this->file = (string)$file;
return $this;
}
/**
* Set the url of the macroblock
* Get the macroblock url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the macroblock url
*
* @api
* @param string $url Macroblock url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$fileElement = $domDocument->createElement('file', $this->file);
$xmlElement->appendChild($fileElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("install_macroblock");
$nameElement = $domDocument->createElement("name", $this->name);
$domElement->appendChild($nameElement);
$fileElement = $domDocument->createElement("file", $this->file);
$domElement->appendChild($fileElement);
$urlElement = $domDocument->createElement("url", $this->url);
$domElement->appendChild($urlElement);
return $domElement;
}
}

View File

@ -6,74 +6,114 @@ namespace FML\ManiaCode;
* ManiaCode Element installing a map
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class InstallMap extends Element {
/*
* Protected properties
class InstallMap implements Element
{
/**
* @var string $name Map name
*/
protected $tagName = 'install_map';
protected $name = null;
/**
* @var string $url Map url
*/
protected $url = null;
/**
* Create a new InstallMap object
* Create a new InstallMap Element
*
* @api
* @param string $name (optional) Map name
* @param string $url (optional) Map url
* @return static
*/
public static function create($name = null, $url = null) {
public static function create($name = null, $url = null)
{
return new static($name, $url);
}
/**
* Construct a new InstallMap object
* Construct a new InstallMap Element
*
* @api
* @param string $name (optional) Map name
* @param string $url (optional) Map url
*/
public function __construct($name = null, $url = null) {
if ($name !== null) {
public function __construct($name = null, $url = null)
{
if ($name) {
$this->setName($name);
}
if ($url !== null) {
if ($url) {
$this->setUrl($url);
}
}
/**
* Set the name of the map
* Get the map name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the map name
*
* @api
* @param string $name Map name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set the url of the map
* Get the map url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the map url
*
* @api
* @param string $url Map url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("install_map");
$nameElement = $domDocument->createElement("name", $this->name);
$domElement->appendChild($nameElement);
$urlElement = $domDocument->createElement("url", $this->url);
$domElement->appendChild($urlElement);
return $domElement;
}
}

View File

@ -6,93 +6,151 @@ namespace FML\ManiaCode;
* ManiaCode Element installing a title pack
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class InstallPack extends Element {
/*
* Protected properties
class InstallPack implements Element
{
/**
* @var string $name Pack name
*/
protected $tagName = 'install_pack';
protected $name = null;
/**
* @var string $file Pack file
*/
protected $file = null;
/**
* @var string $url Pack url
*/
protected $url = null;
/**
* Create a new InstallPack object
* Create a new InstallPack Element
*
* @api
* @param string $name (optional) Pack name
* @param string $file (optional) Pack file
* @param string $url (optional) Pack url
* @return static
*/
public static function create($name = null, $file = null, $url = null) {
public static function create($name = null, $file = null, $url = null)
{
return new static($name, $file, $url);
}
/**
* Construct a new InstallPack object
* Construct a new InstallPack Element
*
* @api
* @param string $name (optional) Pack name
* @param string $file (optional) Pack file
* @param string $url (optional) Pack url
*/
public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) {
public function __construct($name = null, $file = null, $url = null)
{
if ($name) {
$this->setName($name);
}
if ($file !== null) {
if ($file) {
$this->setFile($file);
}
if ($url !== null) {
if ($url) {
$this->setUrl($url);
}
}
/**
* Set the name of the pack
* Get the pack name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the pack name
*
* @api
* @param string $name Pack name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set the file of the pack
* Get the pack file
*
* @api
* @return string
*/
public function getFile()
{
return $this->file;
}
/**
* Set the pack file
*
* @api
* @param string $file Pack file
* @return static
*/
public function setFile($file) {
public function setFile($file)
{
$this->file = (string)$file;
return $this;
}
/**
* Set the url of the pack
* Get the pack url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the pack url
*
* @api
* @param string $url Pack url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$fileElement = $domDocument->createElement('file', $this->file);
$xmlElement->appendChild($fileElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("install_pack");
$nameElement = $domDocument->createElement("name", $this->name);
$domElement->appendChild($nameElement);
$fileElement = $domDocument->createElement("file", $this->file);
$domElement->appendChild($fileElement);
$urlElement = $domDocument->createElement("url", $this->url);
$domElement->appendChild($urlElement);
return $domElement;
}
}

View File

@ -6,74 +6,114 @@ namespace FML\ManiaCode;
* ManiaCode Element installing a replay
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class InstallReplay extends Element {
/*
* Protected properties
class InstallReplay implements Element
{
/**
* @var string $name Replay name
*/
protected $tagName = 'install_replay';
protected $name = null;
/**
* @var string $url Replay url
*/
protected $url = null;
/**
* Create a new InstallReplay object
* Create a new InstallReplay Element
*
* @api
* @param string $name (optional) Replay name
* @param string $url (optional) Replay url
* @return static
*/
public static function create($name = null, $url = null) {
public static function create($name = null, $url = null)
{
return new static($name, $url);
}
/**
* Construct a new InstallReplay object
* Construct a new InstallReplay Element
*
* @api
* @param string $name (optional) Replay name
* @param string $url (optional) Replay url
*/
public function __construct($name = null, $url = null) {
if ($name!== null) {
public function __construct($name = null, $url = null)
{
if ($name) {
$this->setName($name);
}
if ($url!== null) {
if ($url) {
$this->setUrl($url);
}
}
/**
* Set the name of the replay
* Get the replay name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the replay name
*
* @api
* @param string $name Replay name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set the url of the replay
* Get the replay url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the replay url
*
* @api
* @param string $url Replay url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("install_replay");
$nameElement = $domDocument->createElement("name", $this->name);
$domElement->appendChild($nameElement);
$urlElement = $domDocument->createElement("url", $this->url);
$domElement->appendChild($urlElement);
return $domElement;
}
}

View File

@ -6,93 +6,151 @@ namespace FML\ManiaCode;
* ManiaCode Element installing a script
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class InstallScript extends Element {
/*
* Protected properties
class InstallScript implements Element
{
/**
* @var string $name Script name
*/
protected $tagName = 'install_script';
protected $name = null;
/**
* @var string $file Script file
*/
protected $file = null;
/**
* @var string $url Script url
*/
protected $url = null;
/**
* Create a new InstallScript object
* Create a new InstallScript Element
*
* @api
* @param string $name (optional) Script name
* @param string $file (optional) Script file
* @param string $url (optional) Script url
* @return static
*/
public static function create($name = null, $file = null, $url = null) {
public static function create($name = null, $file = null, $url = null)
{
return new static($name, $file, $url);
}
/**
* Construct a new InstallScript object
* Construct a new InstallScript Element
*
* @api
* @param string $name (optional) Script name
* @param string $file (optional) Script file
* @param string $url (optional) Script url
*/
public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) {
public function __construct($name = null, $file = null, $url = null)
{
if ($name) {
$this->setName($name);
}
if ($file !== null) {
if ($file) {
$this->setFile($file);
}
if ($url !== null) {
if ($url) {
$this->setUrl($url);
}
}
/**
* Set the name of the script
* Get the script name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the script name
*
* @api
* @param string $name Script name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set the file of the script
* Get the script file
*
* @api
* @return string
*/
public function getFile()
{
return $this->file;
}
/**
* Set the script file
*
* @api
* @param string $file Script file
* @return static
*/
public function setFile($file) {
public function setFile($file)
{
$this->file = (string)$file;
return $this;
}
/**
* Set the url of the script
* Get the script url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the script url
*
* @api
* @param string $url Script url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$fileElement = $domDocument->createElement('file', $this->file);
$xmlElement->appendChild($fileElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("install_script");
$nameElement = $domDocument->createElement("name", $this->name);
$domElement->appendChild($nameElement);
$fileElement = $domDocument->createElement("file", $this->file);
$domElement->appendChild($fileElement);
$urlElement = $domDocument->createElement("url", $this->url);
$domElement->appendChild($urlElement);
return $domElement;
}
}

View File

@ -6,93 +6,151 @@ namespace FML\ManiaCode;
* ManiaCode Element installing a skin
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class InstallSkin extends Element {
/*
* Protected properties
class InstallSkin implements Element
{
/**
* @var string $name Skin name
*/
protected $tagName = 'install_skin';
protected $name = null;
/**
* @var string $file Skin file
*/
protected $file = null;
/**
* @var string $url Skin url
*/
protected $url = null;
/**
* Create a new InstallSkin object
* Create a new InstallSkin Element
*
* @api
* @param string $name (optional) Skin name
* @param string $file (optional) Skin file
* @param string $url (optional) Skin url
* @return static
*/
public static function create($name = null, $file = null, $url = null) {
public static function create($name = null, $file = null, $url = null)
{
return new static($name, $file, $url);
}
/**
* Construct a new InstallSkin object
* Construct a new InstallSkin Element
*
* @api
* @param string $name (optional) Skin name
* @param string $file (optional) Skin file
* @param string $url (optional) Skin url
*/
public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) {
public function __construct($name = null, $file = null, $url = null)
{
if ($name) {
$this->setName($name);
}
if ($file !== null) {
if ($file) {
$this->setFile($file);
}
if ($url !== null) {
if ($url) {
$this->setUrl($url);
}
}
/**
* Set the name of the skin
* Get the skin name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the skin name
*
* @api
* @param string $name Skin name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set the file of the skin
* Get the skin file
*
* @api
* @return string
*/
public function getFile()
{
return $this->file;
}
/**
* Set the skin file
*
* @api
* @param string $file Skin file
* @return static
*/
public function setFile($file) {
public function setFile($file)
{
$this->file = (string)$file;
return $this;
}
/**
* Set the url of the skin
* Get the skin url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the skin url
*
* @api
* @param string $url Skin url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$fileElement = $domDocument->createElement('file', $this->file);
$xmlElement->appendChild($fileElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("install_skin");
$nameElement = $domDocument->createElement("name", $this->name);
$domElement->appendChild($nameElement);
$fileElement = $domDocument->createElement("file", $this->file);
$domElement->appendChild($fileElement);
$urlElement = $domDocument->createElement("url", $this->url);
$domElement->appendChild($urlElement);
return $domElement;
}
}

View File

@ -6,78 +6,150 @@ namespace FML\ManiaCode;
* ManiaCode Element for joining a server
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class JoinServer extends Element {
/*
* Protected properties
*/
protected $tagName = 'join_server';
protected $login = null;
protected $serverIp = null;
protected $serverPort = null;
class JoinServer implements Element
{
/**
* Create a new JoinServer object
* @var string $login Server login
*/
protected $login = null;
/**
* @var string $ip Server ip
*/
protected $ip = null;
/**
* @var int $port Server port
*/
protected $port = null;
/**
* Create a new JoinServer Element
*
* @param string $login (optional) Server login
* @api
* @param string $loginOrIp (optional) Server login or ip
* @param int $port (optional) Server port
* @return static
*/
public static function create($login = null) {
return new static($login);
public static function create($loginOrIp = null, $port = null)
{
return new static($loginOrIp, $port);
}
/**
* Construct a new JoinServer object
* Construct a new JoinServer Element
*
* @param string $login (optional) Server login
* @api
* @param string $loginOrIp (optional) Server login or ip
* @param int $port (optional) Server port
*/
public function __construct($login = null) {
if ($login !== null) {
$this->setLogin($login);
public function __construct($loginOrIp = null, $port = null)
{
if ($port) {
$this->setIp($loginOrIp, $port);
} elseif ($loginOrIp) {
$this->setLogin($loginOrIp);
}
}
/**
* Get the server login
*
* @api
* @return string
*/
public function getLogin()
{
return $this->login;
}
/**
* Set the server login
*
* @api
* @param string $login Server login
* @return static
*/
public function setLogin($login) {
public function setLogin($login)
{
$this->login = (string)$login;
$this->serverIp = null;
$this->serverPort = null;
$this->ip = null;
$this->port = null;
return $this;
}
/**
* Get the server ip
*
* @api
* @return string
*/
public function getIp()
{
return $this->ip;
}
/**
* Set the server ip and port
*
* @param string $serverIp Server ip
* @param int $serverPort Server port
* @api
* @param string $ip Server ip
* @param int $port (optional) Server port
* @return static
*/
public function setIp($serverIp, $serverPort) {
$this->serverIp = (string)$serverIp;
$this->serverPort = (int)$serverPort;
public function setIp($ip, $port = null)
{
$this->login = null;
$this->ip = (string)$ip;
if ($port) {
$this->setPort($port);
}
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* Get the server port
*
* @api
* @return int
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
if ($this->serverIp === null) {
$loginElement = $domDocument->createElement('login', $this->login);
$xmlElement->appendChild($loginElement);
public function getPort()
{
return $this->port;
}
/**
* Set the server port
*
* @param int $port Server port
* @return static
*/
public function setPort($port)
{
$this->port = (int)$port;
return $this;
}
/**
* @see Element::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("join_server");
if ($this->login) {
$loginElement = $domDocument->createElement("login", $this->login);
$domElement->appendChild($loginElement);
} else {
$ipElement = $domDocument->createElement('ip', $this->serverIp . ':' . $this->serverPort);
$xmlElement->appendChild($ipElement);
$ipElement = $domDocument->createElement("ip", $this->ip . ":" . $this->port);
$domElement->appendChild($ipElement);
}
return $xmlElement;
return $domElement;
}
}

View File

@ -6,74 +6,114 @@ namespace FML\ManiaCode;
* ManiaCode Element for playing a map
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayMap extends Element {
/*
* Protected properties
class PlayMap implements Element
{
/*+
* @var string $name Map name
*/
protected $tagName = 'play_map';
protected $name = null;
/**
* @var string $url Map url
*/
protected $url = null;
/**
* Create a new PlayMap object
* Create a new PlayMap Element
*
* @api
* @param string $name (optional) Map name
* @param string $url (optional) Map url
* @return static
*/
public static function create($name = null, $url = null) {
public static function create($name = null, $url = null)
{
return new static($name, $url);
}
/**
* Construct a new PlayMap object
* Construct a new PlayMap Element
*
* @api
* @param string $name (optional) Map name
* @param string $url (optional) Map url
*/
public function __construct($name = null, $url = null) {
if ($name !== null) {
public function __construct($name = null, $url = null)
{
if ($name) {
$this->setName($name);
}
if ($url !== null) {
if ($url) {
$this->setUrl($url);
}
}
/**
* Set the name of the map
* Get the map name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the map name
*
* @api
* @param string $name Map name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set the url of the map
* Get the map url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the map url
*
* @api
* @param string $url Map url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("play_map");
$nameElement = $domDocument->createElement("name", $this->name);
$domElement->appendChild($nameElement);
$urlElement = $domDocument->createElement("url", $this->url);
$domElement->appendChild($urlElement);
return $domElement;
}
}

View File

@ -6,74 +6,114 @@ namespace FML\ManiaCode;
* ManiaCode Element playing a replay
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayReplay extends Element {
/*
* Protected properties
class PlayReplay implements Element
{
/**
* @var string $name Replay name
*/
protected $tagName = 'play_replay';
protected $name = null;
/**
* @var string $url Replay url
*/
protected $url = null;
/**
* Create a new PlayReplay object
* Create a new PlayReplay Element
*
* @api
* @param string $name (optional) Replay name
* @param string $url (optional) Replay url
* @return static
*/
public static function create($name = null, $url = null) {
public static function create($name = null, $url = null)
{
return new static($name, $url);
}
/**
* Construct a new PlayReplay object
* Construct a new PlayReplay Element
*
* @api
* @param string $name (optional) Replay name
* @param string $url (optional) Replay url
*/
public function __construct($name = null, $url = null) {
if ($name !== null) {
public function __construct($name = null, $url = null)
{
if ($name) {
$this->setName($name);
}
if ($url !== null) {
if ($url) {
$this->setUrl($url);
}
}
/**
* Set the name of the replay
* Get the replay name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the replay name
*
* @api
* @param string $name Replay name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set the url of the replay
* Get the replay url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the replay url
*
* @api
* @param string $url Replay url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("play_replay");
$nameElement = $domDocument->createElement("name", $this->name);
$domElement->appendChild($nameElement);
$urlElement = $domDocument->createElement("url", $this->url);
$domElement->appendChild($urlElement);
return $domElement;
}
}

View File

@ -6,55 +6,77 @@ namespace FML\ManiaCode;
* ManiaCode Element showing a Message
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ShowMessage extends Element {
/*
* Protected properties
class ShowMessage implements Element
{
/**
* @var string $message Message text
*/
protected $tagName = 'show_message';
protected $message = null;
/**
* Create a new ShowMessage object
* Create a new ShowMessage Element
*
* @api
* @param string $message (optional) Message text
* @return static
*/
public static function create($message = null) {
public static function create($message = null)
{
return new static($message);
}
/**
* Construct a new ShowMessage object
* Construct a new ShowMessage Element
*
* @api
* @param string $message (optional) Message text
*/
public function __construct($message = null) {
if ($message !== null) {
public function __construct($message = null)
{
if ($message) {
$this->setMessage($message);
}
}
/**
* Get the message text
*
* @api
* @return string
*/
public function getMessage()
{
return $this->message;
}
/**
* Set the message text
*
* @api
* @param string $message Message text
* @return static
*/
public function setMessage($message) {
public function setMessage($message)
{
$this->message = (string)$message;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$messageElement = $domDocument->createElement('message', $this->message);
$xmlElement->appendChild($messageElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("show_message");
$messageElement = $domDocument->createElement("message", $this->message);
$domElement->appendChild($messageElement);
return $domElement;
}
}

View File

@ -6,74 +6,114 @@ namespace FML\ManiaCode;
* ManiaCode Element for viewing a replay
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ViewReplay extends Element {
/*
* Protected properties
class ViewReplay implements Element
{
/**
* @var string $name Replay name
*/
protected $tagName = 'view_replay';
protected $name = null;
/**
* @var string $url Replay url
*/
protected $url = null;
/**
* Create a new ViewReplay object
* Create a new ViewReplay Element
*
* @api
* @param string $name (optional) Replay name
* @param string $url (optional) Replay url
* @return static
*/
public static function create($name = null, $url = null) {
public static function create($name = null, $url = null)
{
return new static($name, $url);
}
/**
* Construct a new ViewReplay object
* Construct a new ViewReplay Element
*
* @api
* @param string $name (optional) Replay name
* @param string $url (optional) Replay url
*/
public function __construct($name = null, $url = null) {
if ($name !== null) {
public function __construct($name = null, $url = null)
{
if ($name) {
$this->setName($name);
}
if ($url !== null) {
if ($url) {
$this->setUrl($url);
}
}
/**
* Set the name of the replay
* Get the replay name
*
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the replay name
*
* @api
* @param string $name Replay name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set the url of the replay
* Get the replay url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the replay url
*
* @api
* @param string $url Replay url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
* @see Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("view_replay");
$nameElement = $domDocument->createElement("name", $this->name);
$domElement->appendChild($nameElement);
$urlElement = $domDocument->createElement("url", $this->url);
$domElement->appendChild($urlElement);
return $domElement;
}
}

View File

@ -12,151 +12,300 @@ use FML\Types\ScriptFeatureable;
* Class representing a ManiaLink
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ManiaLink {
class ManiaLink
{
/*
* Constants
*/
const BACKGROUND_0 = '0';
const BACKGROUND_1 = '1';
const BACKGROUND_STARS = 'stars';
const BACKGROUND_STATIONS = 'stations';
const BACKGROUND_TITLE = 'title';
const MANIALINK_VERSION = 3;
const BACKGROUND_0 = "0";
const BACKGROUND_1 = "1";
const BACKGROUND_STARS = "stars";
const BACKGROUND_STATIONS = "stations";
const BACKGROUND_TITLE = "title";
/*
* Protected properties
/**
* @var string $maniaLinkId ManiaLink ID
*/
protected $encoding = 'utf-8';
protected $tagName = 'manialink';
protected $maniaLinkId = null;
/**
* @var int $version ManiaLink version
*/
protected $version = 1;
protected $background = null;
protected $navigable3d = 1;
/**
* @var string $name ManiaLink name
*/
protected $name = null;
protected $timeout = 0;
/** @var Renderable[] $children */
/**
* @var string $background Background
*/
protected $background = null;
/**
* @var bool $navigable3d 3d navigable
*/
protected $navigable3d = true;
/**
* @var int $timeout Timeout
*/
protected $timeout = null;
/**
* @var Renderable[] $children Children
*/
protected $children = array();
/** @var Dico $dico */
/**
* @var Dico $dico Dictionary
*/
protected $dico = null;
/** @var Stylesheet $stylesheet */
/**
* @var Stylesheet $stylesheet Style sheet
*/
protected $stylesheet = null;
/** @var Script $script */
/**
* @var Script $script Script
*/
protected $script = null;
/**
* Create a new ManiaLink object
* Create a new ManiaLink
*
* @param string $maniaLinkId (optional) ManiaLink id
* @param string $maniaLinkName (optional) ManiaLink Name
* @api
* @param string $maniaLinkId (optional) ManiaLink ID
* @param int $version (optional) Version
* @param string $name (optional) Name
* @param Renderable[] $children (optional) Children
* @return static
*/
public static function create($maniaLinkId = null, $maniaLinkName = null) {
return new static($maniaLinkId, $maniaLinkName);
public static function create($maniaLinkId = null, $version = null, $name = null, array $children = null)
{
return new static($maniaLinkId, $version, $name, $children);
}
/**
* Construct a new ManiaLink object
* Construct a new ManiaLink
*
* @param string $maniaLinkId (optional) ManiaLink id
* @param string $maniaLinkName (optional) ManiaLink Name
* @api
* @param string $maniaLinkId (optional) ManiaLink ID
* @param int $version (optional) Version
* @param string $name (optional) Name
* @param Renderable[] $children (optional) Children
*/
public function __construct($maniaLinkId = null, $maniaLinkName = null) {
if ($maniaLinkId !== null) {
public function __construct($maniaLinkId = null, $version = null, $name = null, array $children = null)
{
if (is_string($version)) {
// backwards-compatibility (version has been introduced later)
$children = $name;
$name = $version;
$version = null;
}
if ($maniaLinkId) {
$this->setId($maniaLinkId);
}
if ($maniaLinkName !== false) {
if ($maniaLinkName) {
$this->setName($maniaLinkName);
} else {
$this->setName($maniaLinkId);
$this->setVersion(self::MANIALINK_VERSION);
if ($version) {
$this->setVersion($version);
}
if ($name) {
$this->setName($name);
}
if ($children) {
$this->setChildren($children);
}
$this->createScript();
}
/**
* Set XML encoding
*
* @param string $encoding XML encoding
* @return static
*/
public function setXmlEncoding($encoding) {
$this->encoding = (string)$encoding;
return $this;
}
/**
* Set ManiaLink id
*
* @param string $maniaLinkId ManiaLink id
* @return static
*/
public function setId($maniaLinkId) {
$this->maniaLinkId = (string)$maniaLinkId;
return $this;
}
/**
* Get ManiaLink id
* Get the ID
*
* @api
* @return string
*/
public function getId() {
public function getId()
{
return $this->maniaLinkId;
}
/**
* Set background
* Set the ID
*
* @param string $background Background value
* @api
* @param string $maniaLinkId ManiaLink ID
* @return static
*/
public function setBackground($background) {
$this->background = (string)$background;
public function setId($maniaLinkId)
{
$this->maniaLinkId = (string)$maniaLinkId;
if ($this->maniaLinkId && !$this->name) {
$this->setName($this->maniaLinkId);
}
return $this;
}
/**
* Set navigable3d
* Get the version
*
* @param bool $navigable3d Whether the manialink should be 3d navigable
* @api
* @return int
*/
public function getVersion()
{
return $this->version;
}
/**
* Set the version
*
* @api
* @param int $version ManiaLink version
* @return static
*/
public function setNavigable3d($navigable3d) {
$this->navigable3d = ($navigable3d ? 1 : 0);
public function setVersion($version)
{
$this->version = (int)$version;
return $this;
}
/**
* Set the ManiaLink Name
* Get the name
*
* @param string $name
* @api
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the name
*
* @api
* @param string $name ManiaLink Name
* @return static
*/
public function setName($name) {
public function setName($name)
{
$this->name = (string)$name;
return $this;
}
/**
* Set timeout
* Get the background
*
* @api
* @return string
*/
public function getBackground()
{
return $this->background;
}
/**
* Set the background
*
* @api
* @param string $background Background value
* @return static
*/
public function setBackground($background)
{
$this->background = (string)$background;
return $this;
}
/**
* Get navigable3d
*
* @api
* @return bool
*/
public function getNavigable3d()
{
return $this->navigable3d;
}
/**
* Set navigable3d
*
* @api
* @param bool $navigable3d If the ManiaLink should be 3d navigable
* @return static
*/
public function setNavigable3d($navigable3d)
{
$this->navigable3d = (bool)$navigable3d;
return $this;
}
/**
* Get the timeout
*
* @api
* @return int
*/
public function getTimeout()
{
return $this->timeout;
}
/**
* Set the timeout
*
* @api
* @param int $timeout Timeout duration
* @return static
*/
public function setTimeout($timeout) {
public function setTimeout($timeout)
{
$this->timeout = (int)$timeout;
return $this;
}
/**
* Add an element to the ManiaLink
* Get children
*
* @param Renderable $child Child element to add
* @api
* @return Renderable[]
*/
public function getChildren()
{
return $this->children;
}
/**
* Add a child
*
* @api
* @param Renderable $child Child Element to add
* @return static
* @deprecated use addChild() instead
*/
public function add(Renderable $child)
{
return $this->addChild($child);
}
/**
* Add a child
*
* @api
* @param Renderable $child Child Element to add
* @return static
*/
public function add(Renderable $child) {
public function addChild(Renderable $child)
{
if (!in_array($child, $this->children, true)) {
array_push($this->children, $child);
}
@ -164,142 +313,194 @@ class ManiaLink {
}
/**
* Remove all elements from the ManiaLink
* Set children
*
* @api
* @param Renderable[] $children Child Elements
* @return static
*/
public function removeChildren() {
public function setChildren(array $children)
{
$this->children = array();
foreach ($children as $child) {
$this->addChild($child);
}
return $this;
}
/**
* Remove all children
*
* @api
* @return static
* @deprecated use removeAllChildren() instead
*/
public function removeChildren()
{
return $this->removeAllChildren();
}
/**
* Remove all children
*
* @api
* @return static
*/
public function removeAllChildren()
{
$this->children = array();
return $this;
}
/**
* Set the Dictionary of the ManiaLink
* Get the Dictionary
*
* @param Dico $dico Dictionary for the ManiaLink
* @api
* @return Dico
*/
public function getDico()
{
return $this->dico;
}
/**
* Set the Dictionary
*
* @api
* @param Dico $dico Dictionary
* @return static
*/
public function setDico(Dico $dico) {
public function setDico(Dico $dico = null)
{
$this->dico = $dico;
return $this;
}
/**
* Get the Dictionary of the ManiaLink
* Get the Stylesheet
*
* @param bool $createIfEmpty (optional) Whether the Dico object should be created if it's not set
* @return \FML\Elements\Dico
* @api
* @return Stylesheet
*/
public function getDico($createIfEmpty = true) {
if (!$this->dico && $createIfEmpty) {
$this->setDico(new Dico());
}
return $this->dico;
public function getStylesheet()
{
return $this->stylesheet;
}
/**
* Set the Stylesheet of the ManiaLink
* Set the Stylesheet
*
* @param Stylesheet $stylesheet Stylesheet for the ManiaLink
* @api
* @param Stylesheet $stylesheet Stylesheet
* @return static
*/
public function setStylesheet(Stylesheet $stylesheet) {
public function setStylesheet(Stylesheet $stylesheet = null)
{
$this->stylesheet = $stylesheet;
return $this;
}
/**
* Get the Stylesheet of the ManiaLink
* Get the Script
*
* @param bool $createIfEmpty (optional) Whether the Stylesheet object should be created if it's not set
* @return \FML\Stylesheet\Stylesheet
* @api
* @return Script
*/
public function getStylesheet($createIfEmpty = true) {
if (!$this->stylesheet && $createIfEmpty) {
$this->setStylesheet(new Stylesheet());
}
return $this->stylesheet;
public function getScript()
{
return $this->script;
}
/**
* Set the Script of the ManiaLink
* Set the Script
*
* @param Script $script Script for the ManiaLink
* @api
* @param Script $script Script
* @return static
*/
public function setScript(Script $script) {
public function setScript(Script $script = null)
{
$this->script = $script;
return $this;
}
/**
* Get the current Script of the ManiaLink
* Create and assign a new Script if necessary
*
* @param bool $createIfEmpty (optional) Whether the Script object should be created if it's not set
* @return \FML\Script\Script
* @api
* @return Script
*/
public function getScript($createIfEmpty = true) {
if (!$this->script && $createIfEmpty) {
$this->setScript(new Script());
public function createScript()
{
if ($this->script) {
return $this->script;
}
$script = new Script();
$this->setScript($script);
return $this->script;
}
/**
* Render the XML document
* Render the ManiaLink
*
* @param bool $echo (optional) If the XML text should be echoed and the Content-Type header should be set
* @param \DOMDocument $domDocument (optional) DOMDocument for which the XML element should be created
* @param \DOMDocument $domDocument (optional) DOMDocument for which the ManiaLink should be rendered
* @return \DOMDocument
*/
public function render($echo = false, $domDocument = null) {
public function render($echo = false, $domDocument = null)
{
$isChild = (bool)$domDocument;
if (!$isChild) {
$domDocument = new \DOMDocument('1.0', $this->encoding);
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
}
$maniaLink = $domDocument->createElement($this->tagName);
$maniaLink = $domDocument->createElement("manialink");
if (!$isChild) {
$domDocument->appendChild($maniaLink);
}
if (strlen($this->maniaLinkId) > 0) {
$maniaLink->setAttribute('id', $this->maniaLinkId);
if ($this->maniaLinkId) {
$maniaLink->setAttribute("id", $this->maniaLinkId);
}
if ($this->version) {
$maniaLink->setAttribute('version', $this->version);
}
if (strlen($this->background) > 0) {
$maniaLink->setAttribute('background', $this->background);
}
if (!$this->navigable3d) {
$maniaLink->setAttribute('navigable3d', $this->navigable3d);
if ($this->version > 0) {
$maniaLink->setAttribute("version", $this->version);
}
if ($this->name) {
$maniaLink->setAttribute('name', $this->name);
$maniaLink->setAttribute("name", $this->name);
}
if ($this->background) {
$maniaLink->setAttribute("background", $this->background);
}
if (!$this->navigable3d) {
$maniaLink->setAttribute("navigable3d", "0");
}
if ($this->timeout) {
$timeoutXml = $domDocument->createElement('timeout', $this->timeout);
$timeoutXml = $domDocument->createElement("timeout", $this->timeout);
$maniaLink->appendChild($timeoutXml);
}
if ($this->dico) {
$dicoXml = $this->dico->render($domDocument);
$maniaLink->appendChild($dicoXml);
}
$scriptFeatures = array();
foreach ($this->children as $child) {
$childXml = $child->render($domDocument, $this->getScript());
$childXml = $child->render($domDocument);
$maniaLink->appendChild($childXml);
if ($child instanceof ScriptFeatureable) {
$scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures());
}
}
if ($scriptFeatures) {
$this->getScript()->loadFeatures($scriptFeatures);
}
if ($this->stylesheet) {
$stylesheetXml = $this->stylesheet->render($domDocument);
$maniaLink->appendChild($stylesheetXml);
}
if ($scriptFeatures) {
$this->createScript()
->loadFeatures($scriptFeatures);
}
if ($this->script) {
if ($this->script->needsRendering()) {
$scriptXml = $this->script->render($domDocument);
@ -307,22 +508,26 @@ class ManiaLink {
}
$this->script->resetGenericScriptLabels();
}
if ($isChild) {
return $maniaLink;
}
if ($echo) {
header('Content-Type: application/xml; charset=utf-8;');
header("Content-Type: application/xml; charset=utf-8;");
echo $domDocument->saveXML();
}
return $domDocument;
}
/**
* Get string representation
* Get the string representation
*
* @return string
*/
public function __toString() {
return $this->render()->saveXML();
public function __toString()
{
return $this->render()
->saveXML();
}
}

View File

@ -6,47 +6,80 @@ namespace FML;
* Class holding several ManiaLinks at once
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ManiaLinks {
/*
* Protected Properties
class ManiaLinks
{
/**
* @var ManiaLink[] $children ManiaLinks children
*/
protected $encoding = 'utf-8';
protected $tagName = 'manialinks';
/** @var ManiaLink[] $children */
protected $children = array();
/** @var CustomUI $customUI */
/**
* @var CustomUI $customUI Custom UI
*/
protected $customUI = null;
/**
* Create a new ManiaLinks object
*
* @api
* @param ManiaLink[] $children ManiaLink children
* @return static
*/
public static function create() {
return new static();
public static function create(array $children = null)
{
return new static($children);
}
/**
* Set XML encoding
* Construct a new ManiaLinks object
*
* @param string $encoding XML encoding
* @return static
* @api
* @param ManiaLink[] $children ManiaLink children
*/
public function setXmlEncoding($encoding) {
$this->encoding = (string)$encoding;
return $this;
public function __construct(array $children = null)
{
if ($children) {
$this->setChildren($children);
}
}
/**
* Get all child ManiaLinks
*
* @api
* @return ManiaLink[]
*/
public function getChildren()
{
return $this->children;
}
/**
* Add a child ManiaLink
*
* @api
* @param ManiaLink $child Child ManiaLink
* @return static
* @deprecated use addChild() instead
*/
public function add(ManiaLink $child)
{
return $this->addChild($child);
}
/**
* Add a child ManiaLink
*
* @api
* @param ManiaLink $child Child ManiaLink
* @return static
*/
public function add(ManiaLink $child) {
public function addChild(ManiaLink $child)
{
if (!in_array($child, $this->children, true)) {
array_push($this->children, $child);
}
@ -54,62 +87,97 @@ class ManiaLinks {
}
/**
* Remove all child ManiaLinks
* Set ManiaLink children
*
* @api
* @param ManiaLink[] $children ManiaLink children
* @return static
*/
public function removeChildren() {
public function setChildren(array $children)
{
$this->children = array();
foreach ($children as $child) {
$this->addChild($child);
}
return $this;
}
/**
* Set the CustomUI
* Remove all child ManiaLinks
*
* @param CustomUI $customUI CustomUI object
* @api
* @return static
* @deprecated use removeAllChildren instead
*/
public function removeChildren()
{
return $this->removeAllChildren();
}
/**
* Remove all child ManiaLinks
*
* @api
* @return static
*/
public function setCustomUI(CustomUI $customUI) {
$this->customUI = $customUI;
public function removeAllChildren()
{
$this->children = array();
return $this;
}
/**
* Get the CustomUI
*
* @param bool $createIfEmpty (optional) Whether the CustomUI object should be created if it's not set
* @return \FML\CustomUI
* @api
* @return CustomUI
*/
public function getCustomUI($createIfEmpty = true) {
if (!$this->customUI && $createIfEmpty) {
$this->setCustomUI(new CustomUI());
}
public function getCustomUI()
{
return $this->customUI;
}
/**
* Render the XML document
* Set the CustomUI
*
* @param bool (optional) $echo Whether the XML text should be echoed and the Content-Type header should be set
* @api
* @param CustomUI $customUI CustomUI object
* @return static
*/
public function setCustomUI(CustomUI $customUI = null)
{
$this->customUI = $customUI;
return $this;
}
/**
* Render the ManiaLinks object
*
* @param bool (optional) $echo If the XML text should be echoed and the Content-Type header should be set
* @return \DOMDocument
*/
public function render($echo = false) {
$domDocument = new \DOMDocument('1.0', $this->encoding);
public function render($echo = false)
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$maniaLinks = $domDocument->createElement($this->tagName);
$maniaLinks = $domDocument->createElement("manialinks");
$domDocument->appendChild($maniaLinks);
foreach ($this->children as $child) {
$childXml = $child->render(false, $domDocument);
$maniaLinks->appendChild($childXml);
}
if ($this->customUI) {
$customUIXml = $this->customUI->render($domDocument);
$maniaLinks->appendChild($customUIXml);
$customUIElement = $this->customUI->render($domDocument);
$maniaLinks->appendChild($customUIElement);
}
if ($echo) {
header('Content-Type: application/xml; charset=utf-8;');
header("Content-Type: application/xml; charset=utf-8;");
echo $domDocument->saveXML();
}
return $domDocument;
}
@ -118,7 +186,10 @@ class ManiaLinks {
*
* @return string
*/
public function __toString() {
return $this->render()->saveXML();
public function __toString()
{
return $this->render()
->saveXML();
}
}

View File

@ -1,129 +0,0 @@
<?php
namespace FML\Models;
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\Script\Builder;
use FML\Types\Styleable;
use FML\Types\SubStyleable;
/**
* Class representing CheckBox Design
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CheckBoxDesign implements Styleable, SubStyleable {
/*
* Protected properties
*/
protected $url = null;
protected $style = null;
protected $subStyle = null;
/**
* Create the default enabled Design
*
* @return static
*/
public static function defaultEnabledDesign() {
return new static(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_Check);
}
/**
* Create the default disabled Design
*
* @return static
*/
public static function defaultDisabledDesign() {
return new static(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_Check);
}
/**
* Construct a new CheckBox Design object
*
* @param string $style Style name or image url
* @param string $subStyle (optional) SubStyle name
*/
public function __construct($style, $subStyle = null) {
if ($subStyle === null) {
$this->setImageUrl($style);
} else {
$this->setStyle($style);
$this->setSubStyle($subStyle);
}
}
/**
* Set the image url
*
* @param string $url Image url
* @return static
*/
public function setImageUrl($url) {
$this->url = (string)$url;
$this->style = null;
$this->subStyle = null;
return $this;
}
/**
* @see \FML\Types\Styleable::setStyle()
*/
public function setStyle($style) {
$this->style = (string)$style;
$this->url = null;
return $this;
}
/**
* @see \FML\Types\SubStyleable::setSubStyle()
*/
public function setSubStyle($subStyle) {
$this->subStyle = (string)$subStyle;
$this->url = null;
return $this;
}
/**
* @see \FML\Types\SubStyleable::setStyles()
*/
public function setStyles($style, $subStyle) {
$this->setStyle($style);
$this->setSubStyle($subStyle);
return $this;
}
/**
* Apply the Design to the given Quad
*
* @param Quad $quad CheckBox Quad
* @return static
*/
public function applyToQuad(Quad $quad) {
$quad->setImage($this->url);
$quad->setStyles($this->style, $this->subStyle);
return $this;
}
/**
* Get the CheckBox Design string
*
* @param bool $escaped (optional) Whether the string should be escaped for the Script
* @param bool $addApostrophes (optional) Whether to add apostrophes before and after the text
* @return string
*/
public function getDesignString($escaped = true, $addApostrophes = true) {
if ($this->url !== null) {
$string = $this->url;
} else {
$string = $this->style . '|' . $this->subStyle;;
}
if ($escaped) {
return Builder::escapeText($string, $addApostrophes);
}
return $string;
}
}

View File

@ -2,43 +2,53 @@
namespace FML\Script;
use FML\Types\Identifiable;
/**
* ManiaScript Builder class
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class Builder {
abstract class Builder
{
/*
* Constants
*/
const EMPTY_STRING = '""';
/**
* Build a label implementation block
* Build a script label implementation block
*
* @api
* @param string $labelName Name of the label
* @param string $implementationCode Label implementation coding (without declaration)
* @param bool $isolate Whether the code should be isolated in an own block
* @param bool $isolate (optional) If the code should be isolated in an own block
* @return string
*/
public static function getLabelImplementationBlock($labelName, $implementationCode, $isolate = true) {
public static function getLabelImplementationBlock($labelName, $implementationCode, $isolate = true)
{
if ($isolate) {
$implementationCode = 'if(True){' . $implementationCode . '}';
$implementationCode = "if(True){{$implementationCode}}";
}
$labelText = PHP_EOL . "***{$labelName}***" . PHP_EOL . "***{$implementationCode}***" . PHP_EOL;
return $labelText;
return "
***{$labelName}***
***{$implementationCode}***
";
}
/**
* Escape dangerous characters in the given text
*
* @api
* @param string $text Text to escape
* @param bool $addApostrophes (optional) Whether to add apostrophes before and after the text
* @param bool $addApostrophes (optional) Add apostrophes before and after the text
* @return string
*/
public static function escapeText($text, $addApostrophes = false) {
public static function escapeText($text, $addApostrophes = true)
{
$dangers = array('\\', '"', "\n");
$replacements = array('\\\\', '\\"', '\\n');
$escapedText = str_ireplace($dangers, $replacements, $text);
@ -48,17 +58,30 @@ abstract class Builder {
return $escapedText;
}
/**
* Get the escaped Id of the given Element
*
* @param Identifiable $element Element
* @return string
*/
public static function getId(Identifiable $element)
{
return static::escapeText($element->getId(), false);
}
/**
* Get the 'Real' string representation of the given value
*
* @api
* @param float $value Float value to convert to a ManiaScript 'Real'
* @return string
*/
public static function getReal($value) {
public static function getReal($value)
{
$value = (float)$value;
$stringVal = (string)$value;
if (!fmod($value, 1)) {
$stringVal .= '.';
$stringVal .= ".";
}
return $stringVal;
}
@ -66,85 +89,135 @@ abstract class Builder {
/**
* Get the 'Boolean' string representation of the given value
*
* @api
* @param bool $value Value to convert to a ManiaScript 'Boolean'
* @return string
*/
public static function getBoolean($value) {
public static function getBoolean($value)
{
$bool = (bool)$value;
if ($bool) {
return 'True';
return "True";
}
return 'False';
return "False";
}
/**
* Get the Vec3 representation for the given values
*
* @api
* @param float|float[] $valueX Value X
* @param float $valueY (optional) Value Y
* @return string
*/
public static function getVec2($valueX, $valueY = null)
{
if (is_array($valueX)) {
$valueY = (isset($valueX[1]) ? $valueX[1] : 0.);
$valueX = (isset($valueX[0]) ? $valueX[0] : 0.);
}
return "<" . static::getReal($valueX) . "," . static::getReal($valueY) . ">";
}
/**
* Get the Vec3 representation for the given values
*
* @api
* @param float|float[] $valueX Value X
* @param float $valueY (optional) Value Y
* @param float $valueZ (optional) Value Z
* @return string
*/
public static function getVec3($valueX, $valueY = null, $valueZ = null)
{
if (is_array($valueX)) {
$valueZ = (isset($valueX[2]) ? $valueX[2] : 0.);
$valueY = (isset($valueX[1]) ? $valueX[1] : 0.);
$valueX = (isset($valueX[0]) ? $valueX[0] : 0.);
}
return "<" . static::getReal($valueX) . "," . static::getReal($valueY) . "," . static::getReal($valueZ) . ">";
}
/**
* Get the string representation of the given array
*
* @api
* @param array $array Array to convert to a ManiaScript array
* @param bool $associative (optional) Whether the array should be associative
* @return string
*/
public static function getArray(array $array, $associative = false) {
$arrayText = '[';
public static function getArray(array $array, $associative = false)
{
$arrayText = "[";
$index = 0;
$count = count($array);
foreach ($array as $key => $value) {
if ($associative) {
if (is_string($key)) {
$arrayText .= '"' . static::escapeText($key) . '"';
} else {
$arrayText .= $key;
}
$arrayText .= ' => ';
}
if (is_string($value)) {
$arrayText .= '"' . static::escapeText($value) . '"';
} else {
$arrayText .= $value;
$arrayText .= static::getValue($key);
$arrayText .= " => ";
}
$arrayText .= static::getValue($value);
if ($index < $count - 1) {
$arrayText .= ', ';
$arrayText .= ", ";
$index++;
}
}
$arrayText .= ']';
return $arrayText;
return $arrayText . "]";
}
/**
* Get the string representation for the given value
*
* @api
* @param mixed $value Value
* @return string
*/
public static function getValue($value)
{
if (is_string($value)) {
return static::escapeText($value);
}
if (is_bool($value)) {
return static::getBoolean($value);
}
return $value;
}
/**
* Get the include command for the given file and namespace
*
* @api
* @param string $file Include file
* @param string $namespace (optional) Include namespace
* @return string
*/
public static function getInclude($file, $namespace = null) {
if (!$namespace && stripos($file, '.') === false) {
public static function getInclude($file, $namespace = null)
{
if (!$namespace && stripos($file, ".") === false) {
$namespace = $file;
}
$file = static::escapeText($file, true);
$file = static::escapeText($file);
$includeText = "#Include {$file}";
if ($namespace) {
$includeText .= " as {$namespace}";
}
$includeText .= PHP_EOL;
return $includeText;
return $includeText . "
";
}
/**
* Get the constant command for the given name and value
*
* @api
* @param string $name Constant name
* @param string $value Constant value
* @return string
*/
public static function getConstant($name, $value) {
if (is_string($value)) {
$value = static::escapeText($value, true);
} else if (is_bool($value)) {
$value = static::getBoolean($value);
}
$constantText = "#Const {$name} {$value}" . PHP_EOL;
return $constantText;
public static function getConstant($name, $value)
{
$value = static::getValue($value);
return "#Const {$name} {$value}
";
}
}

View File

@ -9,81 +9,134 @@ use FML\Script\ScriptLabel;
use FML\Types\Scriptable;
/**
* Script Feature for triggering a manialink page action
* Script Feature for triggering a ManiaLink page action
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ActionTrigger extends ScriptFeature {
/*
* Protected properties
class ActionTrigger extends ScriptFeature
{
/**
* @var string $actionName Triggered action
*/
protected $actionName = null;
/** @var Control $control */
/**
* @var Control $control Action Control
*/
protected $control = null;
/**
* @var string $labelName Script label name
*/
protected $labelName = null;
/**
* Construct a new Action Trigger Feature
* Construct a new Action Trigger
*
* @api
* @param string $actionName (optional) Triggered action
* @param Control $control (optional) Action Control
* @param string $labelName (optional) Script Label name
* @param string $labelName (optional) Script label name
*/
public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
if ($actionName !== null) {
public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK)
{
if ($actionName) {
$this->setActionName($actionName);
}
if ($control !== null) {
if ($control) {
$this->setControl($control);
}
if ($labelName !== null) {
if ($labelName) {
$this->setLabelName($labelName);
}
}
/**
* Get the action to trigger
*
* @api
* @return string
*/
public function getActionName()
{
return $this->actionName;
}
/**
* Set the action to trigger
*
* @param string $actionName
* @api
* @param string $actionName Action name
* @return static
*/
public function setActionName($actionName) {
public function setActionName($actionName)
{
$this->actionName = (string)$actionName;
return $this;
}
/**
* Set the Control
* Get the Control that should trigger the action
*
* @api
* @return Control
*/
public function getControl()
{
return $this->control;
}
/**
* Set the Control that should trigger the action
*
* @api
* @param Control $control Action Control
* @return static
*/
public function setControl(Control $control) {
public function setControl(Control $control = null)
{
if ($control) {
$control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
}
}
$this->control = $control;
return $this;
}
/**
* Set the label name
* Get the script label name
*
* @api
* @return string
*/
public function getLabelName()
{
return $this->labelName;
}
/**
* Set the script label name
*
* @api
* @param string $labelName Script Label name
* @return static
*/
public function setLabelName($labelName) {
public function setLabelName($labelName)
{
$this->labelName = (string)$labelName;
return $this;
}
/**
* @see \FML\Script\Features\ScriptFeature::prepare()
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script) {
public function prepare(Script $script)
{
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
@ -93,11 +146,12 @@ class ActionTrigger extends ScriptFeature {
*
* @return string
*/
protected function getScriptText() {
$actionName = Builder::escapeText($this->actionName, true);
protected function getScriptText()
{
$actionName = Builder::escapeText($this->actionName);
if ($this->control) {
// Control event
$controlId = Builder::escapeText($this->control->getId(), true);
$controlId = Builder::escapeText($this->control->getId());
$scriptText = "
if (Event.Control.ControlId == {$controlId}) {
TriggerPageAction({$actionName});
@ -109,4 +163,5 @@ TriggerPageAction({$actionName});";
}
return $scriptText;
}
}

View File

@ -2,9 +2,9 @@
namespace FML\Script\Features;
use FML\Components\CheckBoxDesign;
use FML\Controls\Entry;
use FML\Controls\Quad;
use FML\Models\CheckBoxDesign;
use FML\Script\Builder;
use FML\Script\Script;
use FML\Script\ScriptInclude;
@ -14,129 +14,196 @@ use FML\Script\ScriptLabel;
* Script Feature for creating a CheckBox behavior
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CheckBoxFeature extends ScriptFeature {
class CheckBoxFeature extends ScriptFeature
{
/*
* Constants
*/
const FUNCTION_UPDATE_QUAD_DESIGN = 'FML_UpdateQuadDesign';
const VAR_CHECKBOX_ENABLED = 'FML_CheckBox_Enabled';
const VAR_CHECKBOX_DESIGNS = 'FML_CheckBox_Designs';
const VAR_CHECKBOX_ENTRY_ID = 'FML_CheckBox_EntryId';
const FUNCTION_UPDATE_QUAD_DESIGN = "FML_UpdateQuadDesign";
const VAR_CHECKBOX_ENABLED = "FML_CheckBox_Enabled";
const VAR_CHECKBOX_DESIGNS = "FML_CheckBox_Designs";
const VAR_CHECKBOX_ENTRY_ID = "FML_CheckBox_EntryId";
/*
* Protected properties
/**
* @var Quad $quad CheckBox Quad
*/
/** @var Quad $quad */
protected $quad = null;
/** @var Entry $entry */
/**
* @var Entry $entry Hidden Entry for submitting the value
*/
protected $entry = null;
/**
* @var bool $default Default value
*/
protected $default = null;
/** @var CheckBoxDesign $enabledDesign */
/**
* @var CheckBoxDesign $enabledDesign Enabled Design
*/
protected $enabledDesign = null;
/** @var CheckBoxDesign $disabledDesign */
/**
* @var CheckBoxDesign $disabledDesign Disabled Design
*/
protected $disabledDesign = null;
/**
* Construct a new CheckBox Feature
*
* @api
* @param Quad $quad (optional) CheckBox Quad
* @param Entry $entry (optional) Hidden Entry
* @param bool $default (optional) Default value
*/
public function __construct(Quad $quad = null, Entry $entry = null, $default = null) {
if ($quad !== null) {
public function __construct(Quad $quad = null, Entry $entry = null, $default = null)
{
if ($quad) {
$this->setQuad($quad);
}
if ($entry !== null) {
if ($entry) {
$this->setEntry($entry);
}
if ($default !== null) {
$this->setDefault($default);
}
$this->setEnabledDesign(CheckBoxDesign::defaultEnabledDesign());
$this->setDisabledDesign(CheckBoxDesign::defaultDisabledDesign());
}
/**
* Set the CheckBox Quad
*
* @param Quad $quad CheckBox Quad
* @return static
*/
public function setQuad(Quad $quad) {
$this->quad = $quad->checkId()->setScriptEvents(true);
return $this;
$this->setEnabledDesign(CheckBoxDesign::defaultDesign());
$this->setDisabledDesign(CheckBoxDesign::defaultDesign());
}
/**
* Get the CheckBox Quad
*
* @return \FML\Controls\Quad
* @api
* @return Quad
*/
public function getQuad() {
public function getQuad()
{
return $this->quad;
}
/**
* Set the CheckBox Entry
* Set the CheckBox Quad
*
* @param Entry $entry CheckBox Entry
* @api
* @param Quad $quad CheckBox Quad
* @return static
*/
public function setEntry(Entry $entry) {
$this->entry = $entry->checkId();
public function setQuad(Quad $quad)
{
$quad->checkId();
$quad->setScriptEvents(true);
$this->quad = $quad;
return $this;
}
/**
* Get the managed Entry
* Get the hidden Entry
*
* @return \FML\Controls\Entry
* @api
* @return Entry
*/
public function getEntry() {
public function getEntry()
{
return $this->entry;
}
/**
* Set the hidden Entry
*
* @api
* @param Entry $entry Hidden Entry
* @return static
*/
public function setEntry(Entry $entry)
{
$entry->checkId();
$this->entry = $entry;
return $this;
}
/**
* Get the default value
*
* @api
* @return bool
*/
public function getDefault()
{
return $this->default;
}
/**
* Set the default value
*
* @api
* @param bool $default Default value
* @return static
*/
public function setDefault($default) {
public function setDefault($default)
{
$this->default = (bool)$default;
return $this;
}
/**
* Get the enabled Design
*
* @api
* @return CheckBoxDesign
*/
public function getEnabledDesign()
{
return $this->enabledDesign;
}
/**
* Set the enabled Design
*
* @api
* @param CheckBoxDesign $checkBoxDesign Enabled CheckBox Design
* @return static
*/
public function setEnabledDesign(CheckBoxDesign $checkBoxDesign) {
public function setEnabledDesign(CheckBoxDesign $checkBoxDesign)
{
$this->enabledDesign = $checkBoxDesign;
return $this;
}
/**
* Get the disabled Design
*
* @api
* @return CheckBoxDesign
*/
public function getDisabledDesign()
{
return $this->disabledDesign;
}
/**
* Set the disabled Design
*
* @api
* @param CheckBoxDesign $checkBoxDesign Disabled CheckBox Design
* @return static
*/
public function setDisabledDesign(CheckBoxDesign $checkBoxDesign) {
public function setDisabledDesign(CheckBoxDesign $checkBoxDesign)
{
$this->disabledDesign = $checkBoxDesign;
return $this;
}
/**
* @see \FML\Script\Features\ScriptFeature::prepare()
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script) {
public function prepare(Script $script)
{
if ($this->getQuad()) {
$script->setScriptInclude(ScriptInclude::TEXTLIB);
$script->addScriptFunction(self::FUNCTION_UPDATE_QUAD_DESIGN, $this->buildUpdateQuadDesignFunction());
@ -151,7 +218,8 @@ class CheckBoxFeature extends ScriptFeature {
*
* @return string
*/
protected function buildUpdateQuadDesignFunction() {
protected function buildUpdateQuadDesignFunction()
{
return "
Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) {
declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True;
@ -160,20 +228,22 @@ Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) {
declare " . self::VAR_CHECKBOX_DESIGNS . " as Designs for _Quad = Text[Boolean];
declare Design = Designs[Enabled];
declare DesignParts = TextLib::Split(\"|\", Design);
if (DesignParts.count > 1) {
if (DesignParts.count == 2) {
_Quad.Style = DesignParts[0];
_Quad.Substyle = DesignParts[1];
} else {
_Quad.ImageUrl = Design;
}
declare " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for _Quad = " . Builder::EMPTY_STRING . ";
if (EntryId != " . Builder::EMPTY_STRING . ") {
declare Value = \"0\";
if (Enabled) {
Value = \"1\";
}
declare " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for _Quad = \"\";
if (EntryId != \"\") {
declare Entry <=> (Page.GetFirstChild(EntryId) as CMlEntry);
Entry.Value = Value;
if (Entry != Null) {
if (Enabled) {
Entry.Value = \"1\";
} else {
Entry.Value = \"0\";
}
}
}
}";
}
@ -183,24 +253,27 @@ Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) {
*
* @return string
*/
protected function buildInitScriptText() {
$quadId = $this->getQuad()->getId(true, true);
$entryId = '""';
protected function buildInitScriptText()
{
$quadId = Builder::getId($this->getQuad());
$entryId = Builder::EMPTY_STRING;
if ($this->entry) {
$entryId = $this->entry->getId(true, true);
$entryId = Builder::getId($this->getEntry());
}
$default = Builder::getBoolean($this->default);
$enabledDesignString = $this->enabledDesign->getDesignString();
$disabledDesignString = $this->disabledDesign->getDesignString();
return "
declare Quad_CheckBox <=> (Page.GetFirstChild({$quadId}) as CMlQuad);
declare Quad_CheckBox <=> (Page.GetFirstChild(\"{$quadId}\") as CMlQuad);
declare Text[Boolean] " . self::VAR_CHECKBOX_DESIGNS . " as Designs for Quad_CheckBox;
Designs[True] = {$enabledDesignString};
Designs[False] = {$disabledDesignString};
Designs[True] = \"{$enabledDesignString}\";
Designs[False] = \"{$disabledDesignString}\";
declare Boolean " . self::VAR_CHECKBOX_ENABLED . " as Enabled for Quad_CheckBox;
Enabled = !{$default};
declare Text " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for Quad_CheckBox;
EntryId = {$entryId};
EntryId = \"{$entryId}\";
" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox);
";
}
@ -210,12 +283,14 @@ EntryId = {$entryId};
*
* @return string
*/
protected function buildClickScriptText() {
$quadId = $this->getQuad()->getId(true, true);
protected function buildClickScriptText()
{
$quadId = Builder::getId($this->getQuad());
return "
if (Event.ControlId == {$quadId}) {
if (Event.ControlId == \"{$quadId}\") {
declare Quad_CheckBox <=> (Event.Control as CMlQuad);
" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox);
}";
}
}

View File

@ -3,6 +3,7 @@
namespace FML\Script\Features;
use FML\Controls\Label;
use FML\Script\Builder;
use FML\Script\Script;
use FML\Script\ScriptInclude;
use FML\Script\ScriptLabel;
@ -11,72 +12,124 @@ use FML\Script\ScriptLabel;
* Script Feature showing the current time on a Label
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Clock extends ScriptFeature {
/*
* Protected properties
class Clock extends ScriptFeature
{
/**
* @var Label $label Clock Label
*/
/** @var Label $label */
protected $label = null;
/**
* @var bool $showSeconds Show the seconds
*/
protected $showSeconds = null;
/**
* @var bool $showFullDate Show the date
*/
protected $showFullDate = null;
/**
* Construct a new Clock Feature
* Construct a new Clock
*
* @api
* @param Label $label (optional) Clock Label
* @param bool $showSeconds (optional) Whether the seconds should be shown
* @param bool $showFullDate (optional) Whether the date should be shown
* @param bool $showSeconds (optional) Show the seconds
* @param bool $showFullDate (optional) Show the date
*/
public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) {
if ($label !== null) {
public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false)
{
if ($label) {
$this->setLabel($label);
}
$this->setShowSeconds($showSeconds);
$this->setShowFullDate($showFullDate);
$this->setShowSeconds($showSeconds)
->setShowFullDate($showFullDate);
}
/**
* Get the Label
*
* @api
* @return Label
*/
public function getLabel()
{
return $this->label;
}
/**
* Set the Label
*
* @api
* @param Label $label Clock Label
* @return static
*/
public function setLabel(Label $label) {
$this->label = $label->checkId();
public function setLabel(Label $label)
{
$label->checkId();
$this->label = $label;
return $this;
}
/**
* Set whether seconds should be shown
* Get if seconds should be shown
*
* @param bool $showSeconds Whether seconds should be shown
* @api
* @return bool
*/
public function getShowSeconds()
{
return $this->showSeconds;
}
/**
* Set if seconds should be shown
*
* @api
* @param bool $showSeconds If seconds should be shown
* @return static
*/
public function setShowSeconds($showSeconds) {
public function setShowSeconds($showSeconds)
{
$this->showSeconds = (bool)$showSeconds;
return $this;
}
/**
* Set whether the full date should be shown
* Get if the full date should be shown
*
* @param bool $showFullDate Whether the full date should be shown
* @api
* @return bool
*/
public function getShowFullDate()
{
return $this->showFullDate;
}
/**
* Set if the full date should be shown
*
* @api
* @param bool $showFullDate If the full date should be shown
* @return static
*/
public function setShowFullDate($showFullDate) {
public function setShowFullDate($showFullDate)
{
$this->showFullDate = (bool)$showFullDate;
return $this;
}
/**
* @see \FML\Script\Features\ScriptFeature::prepare()
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->setScriptInclude(ScriptInclude::TEXTLIB);
$script->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true);
public function prepare(Script $script)
{
$script->setScriptInclude(ScriptInclude::TEXTLIB)
->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true);
return $this;
}
@ -85,8 +138,9 @@ class Clock extends ScriptFeature {
*
* @return string
*/
protected function getScriptText() {
$controlId = $this->label->getId(true, true);
protected function getScriptText()
{
$controlId = Builder::escapeText($this->label->getId());
$scriptText = "
declare ClockLabel <=> (Page.GetFirstChild({$controlId}) as CMlLabel);
declare TimeText = CurrentLocalDateText;";
@ -102,4 +156,5 @@ TimeText = TextLib::SubText(TimeText, 11, 9);";
ClockLabel.Value = TimeText;";
return $scriptText;
}
}

View File

@ -3,6 +3,7 @@
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Builder;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Types\Scriptable;
@ -11,61 +12,118 @@ use FML\Types\Scriptable;
* Script Feature for a Control related script
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ControlScript extends ScriptFeature {
/*
* Protected properties
class ControlScript extends ScriptFeature
{
/**
* @var Control $control Control
*/
/** @var Control $control */
protected $control = null;
/**
* @var string $labelName Script Label name
*/
protected $labelName = null;
protected $text = null;
/**
* @var string $scriptText Script text
*/
protected $scriptText = null;
/**
* Construct a new Control Script
*
* @param Control $control Event Control
* @param string $text Script text
* @api
* @param Control $control (optional) Control
* @param string $scriptText (optional) Script text
* @param string $labelName (optional) Script Label name
*/
public function __construct(Control $control, $text, $labelName = ScriptLabel::MOUSECLICK) {
public function __construct(Control $control = null, $scriptText = null, $labelName = ScriptLabel::MOUSECLICK)
{
if ($control) {
$this->setControl($control);
$this->setText($text);
}
if ($scriptText) {
$this->setScriptText($scriptText);
}
if ($labelName) {
$this->setLabelName($labelName);
}
}
/**
* Get the Control
*
* @api
* @return Control
*/
public function getControl()
{
return $this->control;
}
/**
* Set the Control
*
* @param Control $control Event Control
* @api
* @param Control $control Control
* @return static
*/
public function setControl(Control $control) {
$this->control = $control->checkId();
public function setControl(Control $control)
{
$control->checkId();
$this->control = $control;
$this->updateScriptEvents();
return $this;
}
/**
* Get the script text
*
* @api
* @return string
*/
public function getScriptText()
{
return $this->scriptText;
}
/**
* Set the script text
*
* @param string $text Script text
* @api
* @param string $scriptText Script text
* @return static
*/
public function setText($text) {
$this->text = (string)$text;
public function setScriptText($scriptText)
{
$this->scriptText = (string)$scriptText;
return $this;
}
/**
* Set the label name
* Get the Script Label name
*
* @api
* @return string
*/
public function getLabelName()
{
return $this->labelName;
}
/**
* Set the Script Label name
*
* @api
* @param string $labelName Script Label name
* @return static
*/
public function setLabelName($labelName) {
public function setLabelName($labelName)
{
$this->labelName = (string)$labelName;
$this->updateScriptEvents();
return $this;
@ -73,20 +131,25 @@ class ControlScript extends ScriptFeature {
/**
* Enable Script Events on the Control if needed
*
* @return static
*/
protected function updateScriptEvents() {
protected function updateScriptEvents()
{
if (!$this->control || !ScriptLabel::isEventLabel($this->labelName)) {
return;
return $this;
}
if ($this->control instanceof Scriptable) {
$this->control->setScriptEvents(true);
}
return $this;
}
/**
* @see \FML\Script\Features\ScriptFeature::prepare()
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script) {
public function prepare(Script $script)
{
$isolated = !ScriptLabel::isEventLabel($this->labelName);
$script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), $isolated);
return $this;
@ -97,29 +160,31 @@ class ControlScript extends ScriptFeature {
*
* @return string
*/
protected function buildScriptText() {
$controlId = $this->control->getId(true);
protected function buildScriptText()
{
$controlId = Builder::escapeText($this->control->getId());
$scriptText = '';
$closeBlock = false;
if (ScriptLabel::isEventLabel($this->labelName)) {
$scriptText .= '
if (Event.ControlId == "' . $controlId . '") {
declare Control <=> Event.Control;';
$scriptText .= "
if (Event.ControlId == {$controlId}) {
declare Control <=> Event.Control;";
$closeBlock = true;
} else {
$scriptText .= '
declare Control <=> Page.GetFirstChild("' . $controlId . '");';
$scriptText .= "
declare Control <=> Page.GetFirstChild({$controlId});";
}
$class = $this->control->getManiaScriptClass();
$name = preg_replace('/^CMl/', '', $class, 1);
$scriptText .= '
declare ' . $name . ' <=> (Control as ' . $class . ');
';
$scriptText .= $this->text . '
';
$scriptText .= "
declare {$name} <=> (Control as {$class});
";
$scriptText .= $this->scriptText . "
";
if ($closeBlock) {
$scriptText .= '}';
$scriptText .= "}";
}
return $scriptText;
}
}

View File

@ -12,56 +12,94 @@ use FML\Script\ScriptLabel;
* Script Feature for submitting an Entry
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class EntrySubmit extends ScriptFeature {
/*
* Protected properties
class EntrySubmit extends ScriptFeature
{
/**
* @var Entry $entry Entry
*/
/** @var Entry $entry */
protected $entry = null;
/**
* @var string $url Sumit url
*/
protected $url = null;
/**
* Construct a new Entry Submit Feature
* Construct a new Entry Submit
*
* @api
* @param Entry $entry (optional) Entry Control
* @param string $url (optional) Submit url
*/
public function __construct(Entry $entry = null, $url = null) {
if ($entry !== null) {
public function __construct(Entry $entry = null, $url = null)
{
if ($entry) {
$this->setEntry($entry);
}
if ($url) {
$this->setUrl($url);
}
}
/**
* Get the Entry
*
* @api
* @return Entry
*/
public function getEntry()
{
return $this->entry;
}
/**
* Set the Entry
*
* @api
* @param Entry $entry Entry Control
* @return static
*/
public function setEntry(Entry $entry) {
$this->entry = $entry->checkId()->setScriptEvents(true);
public function setEntry(Entry $entry)
{
$entry->setScriptEvents(true)
->checkId();
$this->entry = $entry;
return $this;
}
/**
* Get the submit url
*
* @api
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the submit url
*
* @api
* @param string $url Submit url
* @return static
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string)$url;
return $this;
}
/**
* @see \FML\Script\Features\ScriptFeature::prepare()
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script) {
public function prepare(Script $script)
{
$script->setScriptInclude(ScriptInclude::TEXTLIB);
$controlScript = new ControlScript($this->entry, $this->getScriptText(), ScriptLabel::ENTRYSUBMIT);
$controlScript->prepare($script);
@ -73,10 +111,11 @@ class EntrySubmit extends ScriptFeature {
*
* @return string
*/
protected function getScriptText() {
protected function getScriptText()
{
$url = $this->buildCompatibleUrl();
$entryName = $this->entry->getName();
$link = Builder::escapeText($entryName . $url . '=', true);
$link = Builder::escapeText($entryName . $url . "=");
return "
declare Value = TextLib::URLEncode(Entry.Value);
OpenLink({$link}^Value, CMlScript::LinkType::Goto);
@ -88,7 +127,8 @@ OpenLink({$link}^Value, CMlScript::LinkType::Goto);
*
* @return string
*/
protected function buildCompatibleUrl() {
protected function buildCompatibleUrl()
{
$url = $this->url;
$paramsBegin = stripos($url, '?');
if (!is_int($paramsBegin) || $paramsBegin < 0) {
@ -98,4 +138,5 @@ OpenLink({$link}^Value, CMlScript::LinkType::Goto);
}
return $url;
}
}

View File

@ -0,0 +1,303 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Graph;
use FML\Script\Builder;
use FML\Script\Script;
use FML\Script\ScriptLabel;
/**
* Script Feature adding a Curve to a Graph
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class GraphCurve extends ScriptFeature
{
/**
* @var Graph $graph Graph
*/
protected $graph = null;
/**
* @var array[] $points Points
*/
protected $points = array();
/**
* @var bool $sortPoints Sort points
*/
protected $sortPoints = false;
/**
* @var float[] $color Color
*/
protected $color = null;
/**
* @var string $style Style
*/
protected $style = null;
/**
* @var float $width Width
*/
protected $width = -1.;
/**
* Construct a new Graph Curve
*
* @api
* @param Graph $graph (optional) Graph
* @param array[] $points (optional) Points
*/
public function __construct(Graph $graph = null, array $points = null)
{
if ($graph) {
$this->setGraph($graph);
}
if ($points) {
$this->setPoints($points);
}
}
/**
* Get the Graph
*
* @api
* @return Graph
*/
public function getGraph()
{
return $this->graph;
}
/**
* Set the Graph
*
* @api
* @param Graph $graph Graph
* @return static
*/
public function setGraph(Graph $graph)
{
$graph->checkId();
$this->graph = $graph;
return $this;
}
/**
* Get the points
*
* @api
* @return array[]
*/
public function getPoints()
{
return $this->points;
}
/**
* Add point
*
* @api
* @param float|float[] $coordX X-coordinate or point
* @param float $coordY (optional) Y-coordinate
* @return static
*/
public function addPoint($coordX, $coordY = null)
{
if (is_array($coordX)) {
$coordY = (isset($coordX[1]) ? $coordX[1] : 0.);
$coordX = (isset($coordX[0]) ? $coordX[0] : 0.);
}
array_push($this->points, array($coordX, $coordY));
return $this;
}
/**
* Add points
*
* @api
* @param array[] $points Points
* @return static
*/
public function addPoints(array $points)
{
foreach ($points as $point) {
$this->addPoint($point);
}
return $this;
}
/**
* Set the points
*
* @api
* @param array[] $points Points
* @return static
*/
public function setPoints(array $points)
{
return $this->removeAllPoints()
->addPoints($points);
}
/**
* Remove all points
*
* @api
* @return static
*/
public function removeAllPoints()
{
$this->points = array();
return $this;
}
/**
* Get if point should be sorted
*
* @api
* @return bool
*/
public function getSortPoints()
{
return $this->sortPoints;
}
/**
* Set if point should be sorted
*
* @api
* @param bool $sortPoints If point should be sorted
* @return static
*/
public function setSortPoints($sortPoints)
{
$this->sortPoints = (bool)$sortPoints;
return $this;
}
/**
* Get the color
*
* @api
* @return float[]
*/
public function getColor()
{
return $this->color;
}
/**
* Set the color
*
* @api
* @param float[] $color (optional) Color
* @return static
*/
public function setColor(array $color = null)
{
$this->color = $color;
return $this;
}
/**
* Get the style
*
* @api
* @return string
*/
public function getStyle()
{
return $this->style;
}
/**
* Set the style
*
* @api
* @return static
*/
public function setStyle($style)
{
$this->style = (string)$style;
return $this;
}
/**
* Get the width
*
* @api
* @return float
*/
public function getWidth()
{
return $this->width;
}
/**
* Set the width
*
* @api
* @return static
*/
public function setWidth($width)
{
$this->width = (float)$width;
return $this;
}
/**
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script)
{
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->getScriptText(), true);
return $this;
}
/**
* Get the script text
*
* @return string
*/
protected function getScriptText()
{
$graphId = Builder::escapeText($this->graph->getId(), false);
$scriptText = "
declare Graph <=> (Page.GetFirstChild(\"{$graphId}\") as CMlGraph);
if (Graph != Null) {
declare GraphCurve <=> Graph.AddCurve();
";
foreach ($this->points as $point) {
$pointVec2 = Builder::getVec2($point);
$scriptText .= "
GraphCurve.Points.add({$pointVec2});";
}
if ($this->sortPoints) {
$scriptText .= "
GraphCurve.SortPoints();";
}
if ($this->color) {
$colorVec3 = Builder::getVec3($this->color);
$scriptText .= "
GraphCurve.Color = {$colorVec3};";
}
if ($this->style) {
$scriptText .= "
GraphCurve.Style = {$this->style};";
}
if ($this->width > 0) {
$scriptText .= "
GraphCurve.Width = {$this->width};";
}
return $scriptText . "
}";
}
}

View File

@ -11,87 +11,156 @@ use FML\Script\ScriptLabel;
*
* @author steeffeen
* @link http://destroflyer.mania-community.de/maniascript/keycharid_table.php
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class KeyAction extends ScriptFeature {
/*
* Protected properties
class KeyAction extends ScriptFeature
{
/**
* @var string $actionName Action name
*/
protected $actionName = null;
/**
* @var string $keyName Key name
*/
protected $keyName = null;
/**
* @var int $keyCode Key code
*/
protected $keyCode = null;
/**
* @var string $charPressed Pressed character
*/
protected $charPressed = null;
/**
* Construct a new Key Action Feature
* Construct a new Key Action
*
* @api
* @param string $actionName (optional) Triggered action
* @param string $keyName (optional) Key name
*/
public function __construct($actionName = null, $keyName = null) {
if ($actionName !== null) {
public function __construct($actionName = null, $keyName = null)
{
if ($actionName) {
$this->setActionName($actionName);
}
if ($keyName !== null) {
if ($keyName) {
$this->setKeyName($keyName);
}
}
/**
* Get the action to trigger
*
* @api
* @return string
*/
public function getActionName()
{
return $this->actionName;
}
/**
* Set the action to trigger
*
* @api
* @param string $actionName Triggered action
* @return static
*/
public function setActionName($actionName) {
public function setActionName($actionName)
{
$this->actionName = (string)$actionName;
return $this;
}
/**
* Get the key name for triggering the action
*
* @api
* @return string
*/
public function getKeyName()
{
return $this->keyName;
}
/**
* Set the key name for triggering the action
*
* @api
* @param string $keyName Key Name
* @return static
*/
public function setKeyName($keyName) {
public function setKeyName($keyName)
{
$this->keyName = (string)$keyName;
$this->keyCode = null;
$this->charPressed = null;
return $this;
}
/**
* Get the key code for triggering the action
*
* @api
* @return int
*/
public function getKeyCode()
{
return $this->keyCode;
}
/**
* Set the key code for triggering the action
*
* @api
* @param int $keyCode Key Code
* @return static
*/
public function setKeyCode($keyCode) {
$this->keyCode = (int)$keyCode;
public function setKeyCode($keyCode)
{
$this->keyName = null;
$this->keyCode = (int)$keyCode;
$this->charPressed = null;
return $this;
}
/**
* Set the char to press for triggering the action
* Get the character to press for triggering the action
*
* @param string $charPressed Pressed char
* @api
* @return string
*/
public function getCharPressed()
{
return $this->charPressed;
}
/**
* Set the character to press for triggering the action
*
* @api
* @param string $charPressed Pressed character
* @return static
*/
public function setCharPressed($charPressed) {
$this->charPressed = (string)$charPressed;
public function setCharPressed($charPressed)
{
$this->keyName = null;
$this->keyCode = null;
$this->charPressed = (string)$charPressed;
return $this;
}
/**
* @see \FML\Script\Features\ScriptFeature::prepare()
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script) {
public function prepare(Script $script)
{
$script->appendGenericScriptLabel(ScriptLabel::KEYPRESS, $this->getScriptText());
return $this;
}
@ -101,24 +170,26 @@ class KeyAction extends ScriptFeature {
*
* @return string
*/
protected function getScriptText() {
$actionName = Builder::escapeText($this->actionName, true);
protected function getScriptText()
{
$actionName = Builder::escapeText($this->actionName);
$key = null;
$value = null;
if ($this->keyName !== null) {
$key = 'KeyName';
$key = "KeyName";
$value = $this->keyName;
} else if ($this->keyCode !== null) {
$key = 'KeyCode';
$key = "KeyCode";
$value = $this->keyCode;
} else if ($this->charPressed !== null) {
$key = 'CharPressed';
$key = "CharPressed";
$value = $this->charPressed;
}
$value = Builder::escapeText($value, true);
$value = Builder::escapeText($value);
return "
if (Event.{$key} == {$value}) {
TriggerPageAction({$actionName});
}";
}
}

View File

@ -12,35 +12,59 @@ use FML\Types\Scriptable;
* Script Feature for opening the map info
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class MapInfo extends ScriptFeature {
/*
* Protected properties
class MapInfo extends ScriptFeature
{
/**
* @var Control $control Map Info Control
*/
/** @var Control $control */
protected $control = null;
/**
* @var string $labelName Script Label name
*/
protected $labelName = null;
/**
* Construct a new Map Info Feature
* Construct a new Map Info
*
* @api
* @param Control $control (optional) Map Info Control
* @param string $labelName (optional) Script Label name
*/
public function __construct(Control $control, $labelName = ScriptLabel::MOUSECLICK) {
public function __construct(Control $control = null, $labelName = ScriptLabel::MOUSECLICK)
{
if ($control) {
$this->setControl($control);
}
if ($labelName) {
$this->setLabelName($labelName);
}
}
/**
* Get the Control
*
* @api
* @return Control
*/
public function getControl()
{
return $this->control;
}
/**
* Set the Control
*
* @api
* @param Control $control Map Info Control
* @return static
*/
public function setControl(Control $control) {
public function setControl(Control $control)
{
$control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
@ -50,20 +74,34 @@ class MapInfo extends ScriptFeature {
}
/**
* Set the label name
* Get the Script Label name
*
* @api
* @return string
*/
public function getLabelName()
{
return $this->labelName;
}
/**
* Set the Script Label name
*
* @api
* @param string $labelName Script Label name
* @return static
*/
public function setLabelName($labelName) {
public function setLabelName($labelName)
{
$this->labelName = (string)$labelName;
return $this;
}
/**
* @see \FML\Script\Features\ScriptFeature::prepare()
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script) {
public function prepare(Script $script)
{
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
@ -73,19 +111,20 @@ class MapInfo extends ScriptFeature {
*
* @return string
*/
protected function getScriptText() {
protected function getScriptText()
{
if ($this->control) {
// Control event
$controlId = Builder::escapeText($this->control->getId(), true);
$scriptText = "
$controlId = Builder::escapeText($this->control->getId());
return "
if (Event.Control.ControlId == {$controlId}) {
ShowCurChallengeCard();
}";
} else {
// Other
$scriptText = "
}
// Other events
return "
ShowCurChallengeCard();";
}
return $scriptText;
}
}

View File

@ -11,92 +11,131 @@ use FML\Script\ScriptLabel;
* Script Feature realising a Menu showing specific Controls for the different items
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Menu extends ScriptFeature {
class Menu extends ScriptFeature
{
/*
* Constants
*/
const FUNCTION_UPDATE_MENU = 'FML_UpdateMenu';
const FUNCTION_UPDATE_MENU = "FML_UpdateMenu";
/*
* Protected properties
/**
* @var MenuElement[] $elements Menu Elements
*/
/** @var MenuElement[] $elements */
protected $elements = array();
/** @var MenuElement $startElement */
/**
* @var MenuElement $startElement Start Element
*/
protected $startElement = null;
/**
* Construct a new Menu Feature
* Construct a new Menu
*
* @api
* @param Control $item (optional) Item Control in the Menu bar
* @param Control $control (optional) Toggled Menu Control
* @param bool $isStartElement (optional) Whether the Menu should start with the given Element
*/
public function __construct(Control $item = null, Control $control = null) {
public function __construct(Control $item = null, Control $control = null, $isStartElement = true)
{
if ($item && $control) {
$this->addElement($item, $control);
$this->addItem($item, $control, $isStartElement);
}
}
/**
* Add a new Element to the Menu
* Get the Menu Elements
*
* @api
* @return MenuElement[]
*/
public function getElements()
{
return $this->elements;
}
/**
* Add a Menu item
*
* @api
* @param Control $item Item Control in the Menu bar
* @param Control $control Toggled Menu Control
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
* @return static
*/
public function addElement(Control $item, Control $control, $isStartElement = false) {
public function addItem(Control $item, Control $control, $isStartElement = false)
{
$menuElement = new MenuElement($item, $control);
$this->appendElement($menuElement, $isStartElement);
$this->addElement($menuElement, $isStartElement);
return $this;
}
/**
* Append an Element to the Menu
* Add a Menu Element
*
* @api
* @param MenuElement $menuElement Menu Element
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
* @return static
*/
public function appendElement(MenuElement $menuElement, $isStartElement = false) {
public function addElement(MenuElement $menuElement, $isStartElement = false)
{
if (!in_array($menuElement, $this->elements, true)) {
array_push($this->elements, $menuElement);
if ($isStartElement) {
// new start element
$this->setStartElement($menuElement);
} else if (count($this->elements) > 1) {
$menuElement->getControl()->setVisible(false);
} else {
// additional element - set invisible
$menuElement->getControl()
->setVisible(false);
}
}
return $this;
}
/**
* Get the Element to start with
*
* @api
* @return MenuElement
*/
public function getStartElement()
{
return $this->startElement;
}
/**
* Set the Element to start with
*
* @param MenuElement $startElement Starting Element
* @api
* @param MenuElement $startElement Start Element
* @return static
*/
public function setStartElement(MenuElement $startElement) {
public function setStartElement(MenuElement $startElement = null)
{
$this->startElement = $startElement;
if (!in_array($startElement, $this->elements, true)) {
if ($startElement && !in_array($startElement, $this->elements, true)) {
array_push($this->elements, $startElement);
}
return $this;
}
/**
* @see \FML\Script\Features\ScriptFeature::prepare()
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script) {
public function prepare(Script $script)
{
$updateFunctionName = self::FUNCTION_UPDATE_MENU;
$elementsArrayText = $this->getElementsArrayText();
// OnInit
if ($this->startElement) {
$startControlId = $this->startElement->getControl()->getId(true, true);
$startControlId = Builder::escapeText($this->startElement->getControl()->getId());
$initScriptText = "
{$updateFunctionName}({$elementsArrayText}, {$startControlId});";
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
@ -129,12 +168,16 @@ Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {
*
* @return string
*/
protected function getElementsArrayText() {
protected function getElementsArrayText()
{
$elements = array();
foreach ($this->elements as $element) {
$elementId = $element->getItem()->getId();
$elements[$elementId] = $element->getControl()->getId();
$elementId = $element->getItem()
->getId();
$elements[$elementId] = $element->getControl()
->getId();
}
return Builder::getArray($elements, true);
}
}

View File

@ -9,38 +9,59 @@ use FML\Types\Scriptable;
* Menu Element for the Menu Feature
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class MenuElement {
/*
* Protected properties
class MenuElement
{
/**
* @var Control $item Menu Item
*/
protected $item = null;
/**
* @var Control $control Menu Control
*/
protected $control = null;
/**
* Create a new Menu Element
*
* @api
* @param Control $item (optional) Item Control in the Menu bar
* @param Control $control (optional) Toggled Menu Control
*/
public function __construct(Control $item = null, Control $control = null) {
if ($item !== null) {
public function __construct(Control $item = null, Control $control = null)
{
if ($item) {
$this->setItem($item);
}
if ($control !== null) {
if ($control) {
$this->setControl($control);
}
}
/**
* Get the Item Control
*
* @api
* @return Control
*/
public function getItem()
{
return $this->item;
}
/**
* Set the Item Control
*
* @param Control $item Item Control in the Menu bar
* @api
* @param Control $item Item Control
* @return static
*/
public function setItem(Control $item) {
public function setItem(Control $item)
{
$item->checkId();
if ($item instanceof Scriptable) {
$item->setScriptEvents(true);
@ -50,31 +71,28 @@ class MenuElement {
}
/**
* Get the Item Control
* Get the Menu Control
*
* @return \FML\Controls\Control
* @api
* @return Control
*/
public function getItem() {
return $this->item;
public function getControl()
{
return $this->control;
}
/**
* Set the Menu Control
*
* @param Control $control Toggled Menu Control
* @api
* @param Control $control Menu Control
* @return static
*/
public function setControl(Control $control) {
$this->control = $control->checkId();
public function setControl(Control $control)
{
$control->checkId();
$this->control = $control;
return $this;
}
/**
* Get the Menu Control
*
* @return \FML\Controls\Control
*/
public function getControl() {
return $this->control;
}
}

View File

@ -10,68 +10,144 @@ use FML\Script\ScriptInclude;
use FML\Script\ScriptLabel;
/**
* Script Feature realising a mechanism for browsing through Pages
* Script Feature realizing a mechanism for browsing through Pages
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Paging extends ScriptFeature {
class Paging extends ScriptFeature
{
/*
* Constants
*/
const VAR_CURRENT_PAGE = 'FML_Paging_CurrentPage';
const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage';
const VAR_CURRENT_PAGE = "FML_Paging_CurrentPage";
const FUNCTION_UPDATE_CURRENT_PAGE = "FML_UpdateCurrentPage";
/*
* Protected properties
/**
* @var Label $label Page number Label
*/
/** @var PagingPage[] $pages */
protected $pages = array();
/** @var PagingButton[] $buttons */
protected $buttons = array();
/** @var Label $label */
protected $label = null;
/**
* @var PagingPage[] $pages Pages
*/
protected $pages = array();
/**
* @var PagingButton[] $buttons Paging Buttons
*/
protected $buttons = array();
/**
* @var int $startPageNumber Start Page number
*/
protected $startPageNumber = null;
/**
* @var int $customMaxPageNumber Custom maximum page number
*/
protected $customMaxPageNumber = null;
/**
* @var string $previousChunkAction Previous chunk action name
*/
protected $previousChunkAction = null;
/**
* @var string $nextChunkAction Next chunk action name
*/
protected $nextChunkAction = null;
/**
* @var bool $chunkActionAppendsPageNumber Chunk action appended with Page number
*/
protected $chunkActionAppendsPageNumber = null;
/**
* Construct a new Paging Script Feature
* Construct a new Paging
*
* @api
* @param Label $label (optional) Page number Label
* @param PagingPage[] $pages (optional) Pages
* @param PagingButton[] $buttons (optional) Pageing Buttons
*/
public function __construct(Label $label = null) {
if ($label !== null) {
public function __construct(Label $label = null, array $pages = null, array $buttons = null)
{
if ($label) {
$this->setLabel($label);
}
if ($pages) {
$this->setPages($pages);
}
if ($buttons) {
$this->setButtons($buttons);
}
}
/**
* Get the Label showing the Page number
*
* @api
* @return Label
*/
public function getLabel()
{
return $this->label;
}
/**
* Set the Label showing the Page number
*
* @api
* @param Label $label Page number Label
* @return static
*/
public function setLabel(Label $label)
{
$label->checkId();
$this->label = $label;
return $this;
}
/**
* Get the Pages
*
* @api
* @return PagingPage[]
*/
public function getPages()
{
return $this->pages;
}
/**
* Add a new Page Control
*
* @api
* @param Control $pageControl Page Control
* @param string $pageNumber (optional) Page number
* @return static
*/
public function addPage(Control $pageControl, $pageNumber = null) {
public function addPageControl(Control $pageControl, $pageNumber = null)
{
if ($pageNumber === null) {
$pageNumber = count($this->pages) + 1;
}
$page = new PagingPage($pageControl, $pageNumber);
$this->appendPage($page);
return $this;
return $this->addPage($page);
}
/**
* Append a Page
* Add a new Page
*
* @param PagingPage $page Paging Page
* @api
* @param PagingPage $page Page
* @return static
*/
public function appendPage(PagingPage $page) {
public function addPage(PagingPage $page)
{
if (!in_array($page, $this->pages, true)) {
array_push($this->pages, $page);
}
@ -79,13 +155,42 @@ class Paging extends ScriptFeature {
}
/**
* Add a new Button to browse through the Pages
* Add new Pages
*
* @api
* @param PagingPage[] $pages Pages
* @return static
*/
public function setPages(array $pages)
{
$this->pages = array();
foreach ($pages as $page) {
$this->addPage($page);
}
return $this;
}
/**
* Get the Buttons
*
* @api
* @return PagingButton[]
*/
public function getButtons()
{
return $this->buttons;
}
/**
* Add a new Button Control to browse through the Pages
*
* @api
* @param Control $buttonControl Button used for browsing
* @param int $browseAction (optional) Number of browsed Pages per click
* @return static
*/
public function addButton(Control $buttonControl, $browseAction = null) {
public function addButtonControl(Control $buttonControl, $browseAction = null)
{
if ($browseAction === null) {
$buttonCount = count($this->buttons);
if ($buttonCount % 2 === 0) {
@ -95,17 +200,18 @@ class Paging extends ScriptFeature {
}
}
$button = new PagingButton($buttonControl, $browseAction);
$this->appendButton($button);
return $this;
return $this->addButton($button);
}
/**
* Append a Button to browse through Pages
* Add a new Button to browse through Pages
*
* @api
* @param PagingButton $button Paging Button
* @return static
*/
public function appendButton(PagingButton $button) {
public function addButton(PagingButton $button)
{
if (!in_array($button, $this->buttons, true)) {
array_push($this->buttons, $button);
}
@ -113,55 +219,113 @@ class Paging extends ScriptFeature {
}
/**
* Set the Label showing the Page number
* Set the Paging Buttons
*
* @param Label $label Page number Label
* @api
* @param PagingButton[] $buttons Paging Buttons
* @return static
*/
public function setLabel(Label $label) {
$this->label = $label->checkId();
public function setButtons(array $buttons)
{
$this->buttons = array();
foreach ($buttons as $button) {
$this->addButton($button);
}
return $this;
}
/**
* Set the Start Page number
* Get the start Page number
*
* @api
* @return int
*/
public function getStartPageNumber()
{
return $this->startPageNumber;
}
/**
* Set the start Page number
*
* @api
* @param int $startPageNumber Page number to start with
* @return static
*/
public function setStartPageNumber($startPageNumber) {
public function setStartPageNumber($startPageNumber)
{
$this->startPageNumber = (int)$startPageNumber;
return $this;
}
/**
* Get a custom maximum Page number for using chunks
*
* @api
* @return int
*/
public function getCustomMaxPageNumber()
{
return $this->customMaxPageNumber;
}
/**
* Set a custom maximum Page number for using chunks
*
* @api
* @param int $maxPageNumber Custom maximum Page number
* @return static
*/
public function setCustomMaxPageNumber($maxPageNumber) {
public function setCustomMaxPageNumber($maxPageNumber)
{
$this->customMaxPageNumber = (int)$maxPageNumber;
return $this;
}
/**
* Get the action triggered when the previous chunk is needed
*
* @api
* @return string
*/
public function getPreviousChunkAction()
{
return $this->previousChunkAction;
}
/**
* Set the action triggered when the previous chunk is needed
*
* @api
* @param string $previousChunkAction Triggered action
* @return static
*/
public function setPreviousChunkAction($previousChunkAction) {
public function setPreviousChunkAction($previousChunkAction)
{
$this->previousChunkAction = (string)$previousChunkAction;
return $this;
}
/**
* Get the action triggered when the next chunk is needed
*
* @api
* @return string
*/
public function getNextChunkAction()
{
return $this->nextChunkAction;
}
/**
* Set the action triggered when the next chunk is needed
*
* @api
* @param string $nextChunkAction Triggered action
* @return static
*/
public function setNextChunkAction($nextChunkAction) {
public function setNextChunkAction($nextChunkAction)
{
$this->nextChunkAction = (string)$nextChunkAction;
return $this;
}
@ -169,30 +333,45 @@ class Paging extends ScriptFeature {
/**
* Set the actions triggered when another chunk is needed
*
* @api
* @param string $chunkAction Triggered action
* @return static
*/
public function setChunkActions($chunkAction) {
$this->setNextChunkAction($chunkAction);
$this->setPreviousChunkAction($chunkAction);
return $this;
public function setChunkActions($chunkAction)
{
return $this->setNextChunkAction($chunkAction)
->setPreviousChunkAction($chunkAction);
}
/**
* Set if the chunk action should get the needed Page number appended
* Get if the chunk action should append the needed Page number
*
* @param bool $appendPageNumber Whether to append the needed Page number
* @api
* @return bool
*/
public function getChunkActionAppendsPageNumber()
{
return $this->chunkActionAppendsPageNumber;
}
/**
* Set if the chunk action should append the needed Page number
*
* @api
* @param bool $appendPageNumber Append the needed Page number
* @return static
*/
public function setChunkActionAppendsPageNumber($appendPageNumber) {
public function setChunkActionAppendsPageNumber($appendPageNumber)
{
$this->chunkActionAppendsPageNumber = (bool)$appendPageNumber;
return $this;
}
/**
* @see \FML\Script\Features\ScriptFeature::prepare()
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script) {
public function prepare(Script $script)
{
if (empty($this->pages)) {
return $this;
}
@ -209,16 +388,20 @@ class Paging extends ScriptFeature {
$maxPageNumber = $maxPage->getPageNumber();
}
$pagingId = $maxPage->getControl()->getId(true, true);
$pageLabelId = '""';
$pagingId = $maxPage->getControl()
->getId(true, true);
$pagingId = Builder::escapeText($maxPage->getControl()
->getId());
$pageLabelId = Builder::EMPTY_STRING;
if ($this->label) {
$pageLabelId = $this->label->getId(true, true);
$pageLabelId = Builder::escapeText($this->label->getId());
}
$pagesArrayText = $this->getPagesArrayText();
$pageButtonsArrayText = $this->getPageButtonsArrayText();
$previousChunkAction = Builder::escapeText($this->previousChunkAction, true);
$nextChunkAction = Builder::escapeText($this->nextChunkAction, true);
$previousChunkAction = Builder::escapeText($this->previousChunkAction);
$nextChunkAction = Builder::escapeText($this->nextChunkAction);
$chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber);
// Init
@ -281,9 +464,10 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
/**
* Get the minimum Page
*
* @return \FML\Script\Features\PagingPage
* @return PagingPage
*/
protected function getMinPage() {
protected function getMinPage()
{
$minPageNumber = null;
$minPage = null;
foreach ($this->pages as $page) {
@ -299,9 +483,10 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
/**
* Get the maximum Page
*
* @return \FML\Script\Features\PagingPage
* @return PagingPage
*/
protected function getMaxPage() {
protected function getMaxPage()
{
$maxPageNumber = null;
$maxPage = null;
foreach ($this->pages as $page) {
@ -319,13 +504,15 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
*
* @return string
*/
protected function getPagesArrayText() {
protected function getPagesArrayText()
{
if (empty($this->pages)) {
return Builder::getArray(array(0 => ''), true);
}
$pages = array();
foreach ($this->pages as $page) {
$pages[$page->getPageNumber()] = $page->getControl()->getId();
$pages[$page->getPageNumber()] = $page->getControl()
->getId();
}
return Builder::getArray($pages, true);
}
@ -335,14 +522,17 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
*
* @return string
*/
protected function getPageButtonsArrayText() {
protected function getPageButtonsArrayText()
{
if (empty($this->buttons)) {
return Builder::getArray(array('' => 0), true);
}
$pageButtons = array();
foreach ($this->buttons as $pageButton) {
$pageButtons[$pageButton->getControl()->getId()] = $pageButton->getBrowseAction();
$pageButtons[$pageButton->getControl()
->getId()] = $pageButton->getPagingCount();
}
return Builder::getArray($pageButtons, true);
}
}

View File

@ -9,39 +9,59 @@ use FML\Types\Scriptable;
* Paging Button for browsing through Pages
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PagingButton {
/*
* Protected properties
class PagingButton
{
/**
* @var Control $control Paging Control
*/
/** @var Control $control */
protected $control = null;
protected $browseAction = null;
/**
* @var int Paging count
*/
protected $pagingCount = 1;
/**
* Construct a new Paging Button
*
* @param Control $control (optional) Browse Control
* @param int $browseAction (optional) Number of browsed Pages per Click
* @api
* @param Control $control (optional) Paging Control
* @param int $pagingCount (optional) Number of browsed pages per click
*/
public function __construct(Control $control = null, $browseAction = null) {
if ($control !== null) {
public function __construct(Control $control = null, $pagingCount = 1)
{
if ($control) {
$this->setControl($control);
}
if ($browseAction !== null) {
$this->setBrowseAction($browseAction);
if ($pagingCount) {
$this->setPagingCount($pagingCount);
}
}
/**
* Set the Button Control
* Get the paging Control
*
* @param Control $control Browse Control
* @api
* @return Control
*/
public function getControl()
{
return $this->control;
}
/**
* Set the paging Control
*
* @api
* @param Control $control Paging Control
* @return static
*/
public function setControl(Control $control) {
public function setControl(Control $control)
{
$control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
@ -51,31 +71,27 @@ class PagingButton {
}
/**
* Get the Button Control
* Get the paging count
*
* @return \FML\Controls\Control
* @api
* @return int
*/
public function getControl() {
return $this->control;
public function getPagingCount()
{
return $this->pagingCount;
}
/**
* Set the browse action
* Set the paging count
*
* @param int $browseAction Number of browsed Pages per click
* @api
* @param int $pagingCount Number of browsed pages per click
* @return static
*/
public function setBrowseAction($browseAction) {
$this->browseAction = (int)$browseAction;
public function setPagingCount($pagingCount)
{
$this->pagingCount = (int)$pagingCount;
return $this;
}
/**
* Get the browse action
*
* @return int
*/
public function getBrowseAction() {
return $this->browseAction;
}
}

View File

@ -8,67 +8,86 @@ use FML\Controls\Control;
* Paging Page
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PagingPage {
/*
* Protected properties
class PagingPage
{
/**
* @var Control $control Page Control
*/
/** @var Control $control */
protected $control = null;
protected $number = null;
/**
* @var int $pageNumber Page number
*/
protected $pageNumber = null;
/**
* Construct a new Paging Page
*
* @api
* @param Control $control (optional) Page Control
* @param int $pageNumber (optional) Number of the Page
*/
public function __construct(Control $control = null, $pageNumber = 1) {
if ($control !== null) {
public function __construct(Control $control = null, $pageNumber = null)
{
if ($control) {
$this->setControl($control);
}
if ($pageNumber) {
$this->setPageNumber($pageNumber);
}
/**
* Set the Page Control
*
* @param Control $control Page Control
* @return static
*/
public function setControl(Control $control) {
$this->control = $control->checkId();
return $this;
}
/**
* Get the Page Control
*
* @return \FML\Controls\Control
* @api
* @return Control
*/
public function getControl() {
public function getControl()
{
return $this->control;
}
/**
* Set the Page number
* Set the Page Control
*
* @param int $pageNumber Number of the Page
* @api
* @param Control $control Page Control
* @return static
*/
public function setPageNumber($pageNumber) {
$this->number = (int)$pageNumber;
public function setControl(Control $control)
{
$control->checkId();
$this->control = $control;
return $this;
}
/**
* Get the Page number
*
* @api
* @return int
*/
public function getPageNumber() {
return $this->number;
public function getPageNumber()
{
return $this->pageNumber;
}
/**
* Set the Page number
*
* @api
* @param int $pageNumber Number of the Page
* @return static
*/
public function setPageNumber($pageNumber)
{
$this->pageNumber = (int)$pageNumber;
return $this;
}
}

View File

@ -12,51 +12,92 @@ use FML\Types\Scriptable;
* Script Feature for opening a player profile
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayerProfile extends ScriptFeature {
/*
* Protected properties
class PlayerProfile extends ScriptFeature
{
/**
* @var string $login Player login
*/
protected $login = null;
/** @var Control $control */
/**
* @var Control $control Profile Control
*/
protected $control = null;
/**
* @var string $labelName Script Label name
*/
protected $labelName = null;
/**
* Construct a new Player Profile Feature
* Construct a new Player Profile
*
* @api
* @param string $login (optional) Player login
* @param Control $control (optional) Action Control
* @param Control $control (optional) Profile Control
* @param string $labelName (optional) Script Label name
*/
public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK)
{
if ($login) {
$this->setLogin($login);
if ($control !== null) {
}
if ($control) {
$this->setControl($control);
}
if ($labelName) {
$this->setLabelName($labelName);
}
}
/**
* Get the login of the opened player
*
* @api
* @return string
*/
public function getLogin()
{
return $this->login;
}
/**
* Set the login of the opened player
*
* @api
* @param string $login Player login
* @return static
*/
public function setLogin($login) {
$this->login = $login;
public function setLogin($login)
{
$this->login = (string)$login;
return $this;
}
/**
* Set the Control
* Get the Profile Control
*
* @api
* @return Control
*/
public function getControl()
{
return $this->control;
}
/**
* Set the Profile Control
*
* @api
* @param Control $control Profile Control
* @return static
*/
public function setControl(Control $control) {
public function setControl(Control $control)
{
$control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
@ -66,20 +107,34 @@ class PlayerProfile extends ScriptFeature {
}
/**
* Set the label name
* Get the Script Label name
*
* @api
* @return string
*/
public function getLabelName()
{
return $this->labelName;
}
/**
* Set the Script Label name
*
* @api
* @param string $labelName Script Label name
* @return static
*/
public function setLabelName($labelName) {
public function setLabelName($labelName)
{
$this->labelName = (string)$labelName;
return $this;
}
/**
* @see \FML\Script\Features\ScriptFeature::prepare()
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script) {
public function prepare(Script $script)
{
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
@ -89,20 +144,22 @@ class PlayerProfile extends ScriptFeature {
*
* @return string
*/
protected function getScriptText() {
$login = Builder::escapeText($this->login, true);
protected function getScriptText()
{
$login = Builder::escapeText($this->login);
if ($this->control) {
// Control event
$controlId = Builder::escapeText($this->control->getId(), true);
$scriptText = "
$controlId = Builder::escapeText($this->control->getId());
return "
if (Event.Control.ControlId == {$controlId}) {
ShowProfile({$login});
}";
} else {
// Other
$scriptText = "
}
// Other events
return "
ShowProfile({$login});";
}
return $scriptText;
}
}

View File

@ -0,0 +1,113 @@
<?php
namespace FML\Script\Features;
use FML\Script\Builder;
use FML\Script\Script;
use FML\Script\ScriptLabel;
/**
* Script Feature for Image Preloading
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Preload extends ScriptFeature
{
/**
* @var string[] $imageUrls Image urls
*/
protected $imageUrls = array();
/**
* Construct a new Preload
*
* @api
* @param string[] $imageUrls (optional) Image urls
*/
public function __construct(array $imageUrls = null)
{
if ($imageUrls) {
$this->setImageUrls($imageUrls);
}
}
/**
* Get Image Urls to preload
*
* @api
* @return string[]
*/
public function getImageUrls()
{
return $this->imageUrls;
}
/**
* Add an Image Url to preload
*
* @api
* @param string $imageUrl Image Url
* @return static
*/
public function addImageUrl($imageUrl)
{
if (!in_array($imageUrl, $this->imageUrls)) {
array_push($this->imageUrls, $imageUrl);
}
return $this;
}
/**
* Set Image Urls to preload
*
* @api
* @param string[] $imageUrls Image Urls
* @return static
*/
public function setImageUrls(array $imageUrls = array())
{
$this->imageUrls = $imageUrls;
return $this;
}
/**
* Remove all Image Urls
*
* @api
* @return static
*/
public function removeAllImageUrls()
{
$this->imageUrls = array();
return $this;
}
/**
* @see ScriptFeature::prepare()
*/
public function prepare(Script $script)
{
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->getScriptText());
return $this;
}
/**
* Get the script text
*
* @return string
*/
protected function getScriptText()
{
$scriptText = "";
foreach ($this->imageUrls as $imageUrl) {
$escapedImageUrl = Builder::escapeText($imageUrl);
$scriptText .= "
PreloadImage({$escapedImageUrl});";
}
return $scriptText;
}
}

Some files were not shown because too many files have changed in this diff Show More