diff --git a/core/Admin/AdminLists.php b/core/Admin/AdminLists.php index dff133f2..e667b577 100644 --- a/core/Admin/AdminLists.php +++ b/core/Admin/AdminLists.php @@ -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; } diff --git a/core/Configurator/Configurator.php b/core/Configurator/Configurator.php index f3a9ed83..da3cb229 100644 --- a/core/Configurator/Configurator.php +++ b/core/Configurator/Configurator.php @@ -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; } diff --git a/core/Configurator/ManiaControlSettings.php b/core/Configurator/ManiaControlSettings.php index f964508b..0a26e7f3 100644 --- a/core/Configurator/ManiaControlSettings.php +++ b/core/Configurator/ManiaControlSettings.php @@ -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(); diff --git a/core/Configurator/ScriptSettings.php b/core/Configurator/ScriptSettings.php index 6dbd0115..2c1eb2f5 100644 --- a/core/Configurator/ScriptSettings.php +++ b/core/Configurator/ScriptSettings.php @@ -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; } diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index c10c8e97..a88d5f73 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -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 diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index 71200c87..7d4ba59b 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -27,10 +27,11 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener /* * Constants */ - const MAIN_MLID = 'Main.ManiaLinkId'; - const ACTION_CLOSEWIDGET = 'ManiaLinkManager.CloseWidget'; - const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed'; - const CB_MAIN_WINDOW_OPENED = 'ManialinkManagerCallback.MainWindowOpened'; + const MAIN_MLID = 'Main.ManiaLinkId'; + 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; } diff --git a/core/Manialinks/StyleManager.php b/core/Manialinks/StyleManager.php index 8fc1886e..6d8faaed 100644 --- a/core/Manialinks/StyleManager.php +++ b/core/Manialinks/StyleManager.php @@ -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); } } diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index 2494543d..068166eb 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -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++; } diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index f01b6456..c324691b 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -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; } diff --git a/core/Plugins/InstallMenu.php b/core/Plugins/InstallMenu.php index 7dccd77b..21e667d9 100644 --- a/core/Plugins/InstallMenu.php +++ b/core/Plugins/InstallMenu.php @@ -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) { } diff --git a/core/Plugins/PluginMenu.php b/core/Plugins/PluginMenu.php index 92a6b43e..c42ce1a1 100644 --- a/core/Plugins/PluginMenu.php +++ b/core/Plugins/PluginMenu.php @@ -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) diff --git a/core/Server/ServerOptionsMenu.php b/core/Server/ServerOptionsMenu.php index 5d73f495..4e92497d 100644 --- a/core/Server/ServerOptionsMenu.php +++ b/core/Server/ServerOptionsMenu.php @@ -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)) { diff --git a/libs/FML/Components/CheckBox.php b/libs/FML/Components/CheckBox.php index 04703262..3955d9a7 100644 --- a/libs/FML/Components/CheckBox.php +++ b/libs/FML/Components/CheckBox.php @@ -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,144 +13,257 @@ use FML\Types\ScriptFeatureable; /** * CheckBox Component * + * @uses Quad * @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 CheckBox implements Renderable, ScriptFeatureable { - /* - * Protected properties - */ - protected $name = null; - protected $feature = null; +class CheckBox implements Renderable, ScriptFeatureable +{ - /** - * Create a new CheckBox Component - * - * @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) { - $this->feature = new CheckBoxFeature(); - $this->setName($name); - $this->setDefault($default); - $this->setQuad($quad); - } + /** + * @var string $name CheckBox name + */ + protected $name = null; - /** - * Set the name - * - * @param string $name CheckBox name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var CheckBoxFeature $feature CheckBox Feature + */ + protected $feature = null; - /** - * Set the default value - * - * @param bool $default Default value - * @return static - */ - public function setDefault($default) { - $this->feature->setDefault($default); - return $this; - } + /** + * 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) + { + $this->feature = new CheckBoxFeature(); + if ($name) { + $this->setName($name); + } + if ($default !== null) { + $this->setDefault($default); + } + if ($quad) { + $this->setQuad($quad); + } + } - /** - * Set the enabled Design - * - * @param string $style Style name or image url - * @param string $subStyle SubStyle name - * @return static - */ - public function setEnabledDesign($style, $subStyle = null) { - if ($style instanceof CheckBoxDesign) { - $this->feature->setEnabledDesign($style); - } else { - $checkBoxDesign = new CheckBoxDesign($style, $subStyle); - $this->feature->setEnabledDesign($checkBoxDesign); - } - return $this; - } + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Set the disabled Design - * - * @param string $style Style name or image url - * @param string $subStyle SubStyle name - * @return static - */ - public function setDisabledDesign($style, $subStyle = null) { - if ($style instanceof CheckBoxDesign) { - $this->feature->setDisabledDesign($style); - } else { - $checkBoxDesign = new CheckBoxDesign($style, $subStyle); - $this->feature->setDisabledDesign($checkBoxDesign); - } - return $this; - } + /** + * Set the name + * + * @api + * @param string $name CheckBox name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } - /** - * Set the CheckBox Quad - * - * @param Quad $quad CheckBox Quad - * @return static - */ - public function setQuad(Quad $quad = null) { - $this->feature->setQuad($quad); - return $this; - } + /** + * Get the default value + * + * @api + * @return bool + */ + public function getDefault() + { + return $this->feature->getDefault(); + } - /** - * @see \FML\Types\ScriptFeatureable::getScriptFeatures() - */ - public function getScriptFeatures() { - return ScriptFeature::collect($this->feature, $this->getQuad(), $this->feature->getEntry()); - } + /** + * Set the default value + * + * @api + * @param bool $default Default value + * @return static + */ + public function setDefault($default) + { + $this->feature->setDefault($default); + return $this; + } - /** - * Get the CheckBox Quad - * - * @param bool $createIfEmpty (optional) Create the Quad if it's not set - * @return \FML\Controls\Quad - */ - public function getQuad($createIfEmpty = true) { - if (!$this->feature->getQuad() && $createIfEmpty) { - $quad = new Quad(); - $quad->setSize(10, 10); - $this->setQuad($quad); - } - return $this->feature->getQuad(); - } + /** + * Get the enabled design + * + * @api + * @return CheckBoxDesign + */ + public function getEnabledDesign() + { + return $this->feature->getEnabledDesign(); + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $frame = new Frame(); + /** + * 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) + { + if ($style instanceof CheckBoxDesign) { + $this->feature->setEnabledDesign($style); + } else { + $checkBoxDesign = new CheckBoxDesign($style, $subStyle); + $this->feature->setEnabledDesign($checkBoxDesign); + } + return $this; + } - $quad = $this->getQuad(); - $frame->add($quad); + /** + * Get the disabled design + * + * @api + * @return CheckBoxDesign + */ + public function getDisabledDesign() + { + return $this->feature->getDisabledDesign(); + } - $entry = $this->buildEntry(); - $frame->add($entry); - $this->feature->setEntry($entry); + /** + * 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) + { + if ($style instanceof CheckBoxDesign) { + $this->feature->setDisabledDesign($style); + } else { + $checkBoxDesign = new CheckBoxDesign($style, $subStyle); + $this->feature->setDisabledDesign($checkBoxDesign); + } + return $this; + } - return $frame->render($domDocument); - } + /** + * 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) + { + $this->feature->setQuad($quad); + return $this; + } + + /** + * Create the CheckBox Quad + * + * @return Quad + */ + 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()); + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $frame = new Frame(); + + $quad = $this->getQuad(); + $frame->addChild($quad); + + $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; - } } diff --git a/libs/FML/Components/CheckBoxDesign.php b/libs/FML/Components/CheckBoxDesign.php new file mode 100644 index 00000000..54eee25a --- /dev/null +++ b/libs/FML/Components/CheckBoxDesign.php @@ -0,0 +1,163 @@ + + * @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; + } + +} diff --git a/libs/FML/Components/ValuePicker.php b/libs/FML/Components/ValuePicker.php index c7e8bba7..0a9e4df2 100644 --- a/libs/FML/Components/ValuePicker.php +++ b/libs/FML/Components/ValuePicker.php @@ -13,122 +13,224 @@ use FML\Types\ScriptFeatureable; /** * ValuePicker Component * + * @uses 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 ValuePicker implements Renderable, ScriptFeatureable { - /* - * Protected properties - */ - protected $name = null; - protected $feature = null; +class ValuePicker implements Renderable, ScriptFeatureable +{ - /** - * Create a new ValuePicker Component - * - * @param string $name (optional) CheckBox name - * @param array $values (optional) Possible values - * @param bool $default (optional) Default value - * @param Label $label (optional) ValuePicker label - */ - public function __construct($name = null, array $values = array(), $default = null, Label $label = null) { - $this->feature = new ValuePickerFeature(); - $this->setName($name); - $this->setValues($values); - $this->setDefault($default); - $this->setLabel($label); - } + /** + * @var string $name ValuePicker name + */ + protected $name = null; - /** - * Set Name - * - * @param string $name ValuePicker name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var ValuePickerFeature $feature ValuePicker Feature + */ + protected $feature = null; - /** - * Set the possible values - * - * @param array $values Possible values - * @return static - */ - public function setValues(array $values) { - $this->feature->setValues($values); - return $this; - } + /** + * Create a new ValuePicker + * + * @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 = 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 the default value - * - * @param bool $default Default value - * @return static - */ - public function setDefault($default) { - $this->feature->setDefault($default); - return $this; - } + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Set the ValuePicker Label - * - * @param Label $label ValuePicker Label - * @return static - */ - public function setLabel(Label $label = null) { - $this->feature->setLabel($label); - return $this; - } + /** + * Set the name + * + * @api + * @param string $name ValuePicker name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } - /** - * Get the ValuePicker Label - * - * @param bool $createIfEmpty (optional) Create the Label if it's not set - * @return \FML\Controls\Label - */ - public function getLabel($createIfEmpty = true) { - if (!$this->feature->getLabel() && $createIfEmpty) { - $label = new Label(); - $this->setLabel($label); - } - return $this->feature->getLabel(); - } + /** + * Get the possible values + * + * @api + * @return string[] + */ + public function getValues() + { + return $this->feature->getValues(); + } - /** - * @see \FML\Types\ScriptFeatureable::getScriptFeatures() - */ - public function getScriptFeatures() { - return ScriptFeature::collect($this->feature, $this->getLabel(), $this->feature->getEntry()); - } + /** + * Set the possible values + * + * @api + * @param array $values Possible values + * @return static + */ + public function setValues(array $values) + { + $this->feature->setValues($values); + return $this; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $frame = new Frame(); + /** + * Get the default value + * + * @api + * @return string + */ + public function getDefault() + { + return $this->feature->getDefault(); + } - $label = $this->getLabel(); - $frame->add($label); + /** + * Set the default value + * + * @api + * @param bool $default Default value + * @return static + */ + public function setDefault($default) + { + $this->feature->setDefault($default); + return $this; + } - $entry = $this->buildEntry(); - $frame->add($entry); - $this->feature->setEntry($entry); + /** + * Get the Label + * + * @api + * @return Label + */ + public function getLabel() + { + $label = $this->feature->getLabel(); + if ($label) { + return $label; + } + return $this->createLabel(); + } - return $frame->render($domDocument); - } + /** + * Set the Label + * + * @api + * @param Label $label ValuePicker Label + * @return static + */ + public function setLabel(Label $label) + { + $this->feature->setLabel($label); + return $this; + } + + /** + * Create the Label + * + * @return Label + */ + protected function createLabel() + { + $label = new Label(); + $this->setLabel($label); + return $label; + } + + /** + * 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->getLabel(), $this->feature->getEntry()); + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $frame = new Frame(); + + $label = $this->getLabel(); + $frame->addChild($label); + + $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; - } } diff --git a/libs/FML/Controls/Audio.php b/libs/FML/Controls/Audio.php index d640709e..9f2d4deb 100644 --- a/libs/FML/Controls/Audio.php +++ b/libs/FML/Controls/Audio.php @@ -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 - */ - protected $tagName = 'audio'; - protected $data = null; - protected $dataId = null; - protected $play = null; - protected $looping = true; - protected $music = null; - protected $volume = 1.; - protected $scriptEvents = null; +class Audio extends Control implements Playable, Scriptable +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlMediaPlayer'; - } + /** + * @var string $data Data url + */ + protected $data = null; - /** - * @see \FML\Types\Playable::setData() - */ - public function setData($data) { - $this->data = (string)$data; - return $this; - } + /** + * @var string $dataId Data id + */ + protected $dataId = null; - /** - * @see \FML\Types\Playable::setDataId() - */ - public function setDataId($dataId) { - $this->dataId = (string)$dataId; - return $this; - } + /** + * @var bool $play Play automaticcaly + */ + protected $play = null; - /** - * @see \FML\Types\Playable::setPlay() - */ - public function setPlay($play) { - $this->play = ($play ? 1 : 0); - return $this; - } + /** + * @var bool $looping Looping + */ + protected $looping = true; - /** - * @see \FML\Types\Playable::setLooping() - */ - public function setLooping($looping) { - $this->looping = ($looping ? 1 : 0); - return $this; - } + /** + * @var bool $music Music type + */ + protected $music = null; - /** - * @see \FML\Types\Playable::setMusic() - */ - public function setMusic($music) { - $this->music = ($music ? 1 : 0); - return $this; - } + /** + * @var float $volume Volume + */ + protected $volume = 1.; - /** - * @see \FML\Types\Playable::setVolume() - */ - public function setVolume($volume) { - $this->volume = (float)$volume; - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; + + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; + + /** + * @see Playable::getData() + */ + public function getData() + { + return $this->data; + } + + /** + * @see Playable::setData() + */ + public function setData($data) + { + $this->data = (string)$data; + return $this; + } + + /** + * @see Playable::getDataId() + */ + public function getDataId() + { + return $this->dataId; + } + + /** + * @see Playable::setDataId() + */ + public function setDataId($dataId) + { + $this->dataId = (string)$dataId; + return $this; + } + + /** + * @see Playable::getPlay() + */ + public function getPlay() + { + return $this->play; + } + + /** + * @see Playable::setPlay() + */ + public function setPlay($play) + { + $this->play = (bool)$play; + return $this; + } + + /** + * @see Playable::getLooping() + */ + public function getLooping() + { + return $this->looping; + } + + /** + * @see Playable::setLooping() + */ + public function setLooping($looping) + { + $this->looping = (bool)$looping; + return $this; + } + + /** + * @see Playable::getMusic() + */ + public function getMusic() + { + return $this->music; + } + + /** + * @see Playable::setMusic() + */ + public function setMusic($music) + { + $this->music = (bool)$music; + return $this; + } + + /** + * @see Playable::getVolume() + */ + public function getVolume() + { + return $this->volume; + } + + /** + * @see Playable::setVolume() + */ + public function setVolume($volume) + { + $this->volume = (float)$volume; + 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 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) { + $domElement->setAttribute("data", $this->data); + } + if ($this->dataId) { + $domElement->setAttribute("dataid", $this->dataId); + } + if ($this->play) { + $domElement->setAttribute("play", 1); + } + if (!$this->looping) { + $domElement->setAttribute("looping", 0); + } + if ($this->music) { + $domElement->setAttribute("music", 1); + } + if ($this->volume != 1.) { + $domElement->setAttribute("volume", $this->volume); + } + 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)); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->data) { - $xmlElement->setAttribute('data', $this->data); - } - if ($this->play) { - $xmlElement->setAttribute('play', $this->play); - } - if (!$this->looping) { - $xmlElement->setAttribute('looping', $this->looping); - } - if ($this->music) { - $xmlElement->setAttribute('music', $this->music); - } - if ($this->volume != 1.) { - $xmlElement->setAttribute('volume', $this->volume); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Control.php b/libs/FML/Controls/Control.php index 054dc76d..d9600db4 100644 --- a/libs/FML/Controls/Control.php +++ b/libs/FML/Controls/Control.php @@ -2,7 +2,6 @@ namespace FML\Controls; -use FML\Script\Builder; use FML\Script\Features\ActionTrigger; use FML\Script\Features\ControlScript; use FML\Script\Features\MapInfo; @@ -12,6 +11,7 @@ use FML\Script\Features\Toggle; use FML\Script\Features\Tooltip; use FML\Script\Features\UISound; use FML\Script\ScriptLabel; +use FML\Types\Identifiable; use FML\Types\Renderable; use FML\Types\ScriptFeatureable; use FML\UniqueID; @@ -21,485 +21,865 @@ use FML\UniqueID; * (CMlControl) * * @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 Control implements Renderable, ScriptFeatureable { - /* - * Constants - */ - const CENTER = 'center'; - const CENTER2 = 'center2'; - const TOP = 'top'; - const RIGHT = 'right'; - const BOTTOM = 'bottom'; - const LEFT = 'left'; +abstract class Control implements Identifiable, Renderable, ScriptFeatureable +{ - /* - * Protected properties - */ - protected $tagName = 'control'; - protected $controlId = null; - protected $posX = 0.; - protected $posY = 0.; - protected $posZ = 0.; - protected $width = -1.; - protected $height = -1.; - protected $hAlign = self::CENTER; - protected $vAlign = self::CENTER2; - protected $scale = 1.; - protected $hidden = null; - protected $rotation = 0.; - /** @var string[] $classes */ - protected $classes = array(); - /** @var ScriptFeature[] $scriptFeatures */ - protected $scriptFeatures = array(); + /* + * Constants + */ + const CENTER = 'center'; + const CENTER2 = 'center2'; + const TOP = 'top'; + const RIGHT = 'right'; + const BOTTOM = 'bottom'; + const LEFT = 'left'; - /** - * Create a new Control object - * - * @param string $controlId (optional) Control id - * @return static - */ - public static function create($controlId = null) { - return new static($controlId); - } + /** + * @var string $controlId Control Id + */ + protected $controlId = null; - /** - * Construct a new Control object - * - * @param string $controlId (optional) Control id - */ - public function __construct($controlId = null) { - if ($controlId !== null) { - $this->setId($controlId); - } - } + /** + * @var float $posX X position + */ + protected $posX = 0.; - /** - * Check Id for dangerous characters and assign a new unique id if necessary - * - * @param bool $forceNewId (optional) Whether to force setting a newly generated id - * @return static - */ - public function checkId($forceNewId = false) { - if ($forceNewId || !$this->getId()) { - $this->setId(new UniqueID()); - return $this; - } - $dangerousCharacters = array(' ', ' ', '.', '|', '-', PHP_EOL); - $idCharacters = str_split($this->getId()); - $danger = false; - foreach ($idCharacters as $character) { - if (!in_array($character, $dangerousCharacters)) { - continue; - } - $danger = true; - break; - } - if ($danger) { - trigger_error("Please don't use special characters in ids, they might cause problems! (I stripped them for you.)"); - $controlId = str_ireplace($dangerousCharacters, '', $this->getId()); - $this->setId($controlId); - } - return $this; - } + /** + * @var float $posY Y position + */ + protected $posY = 0.; - /** - * Get the Control id - * - * @param bool $escaped (optional) Whether the id should be escaped for ManiaScript - * @param bool $addApostrophes (optional) Whether to add apostrophes before and after the text - * @return string - */ - public function getId($escaped = false, $addApostrophes = false) { - if ($escaped) { - return Builder::escapeText($this->controlId, $addApostrophes); - } - return $this->controlId; - } + /** + * @var float $posZ Z position + */ + protected $posZ = 0.; - /** - * Set Control id - * - * @param string $controlId Control id - * @return static - */ - public function setId($controlId) { - $this->controlId = (string)$controlId; - return $this; - } + /** + * @var float $width Width + */ + protected $width = -1.; - /** - * Set Control position - * - * @param float $posX Horizontal position - * @param float $posY Vertical position - * @param float $posZ (optional) Depth - * @return static - */ - public function setPosition($posX, $posY, $posZ = null) { - $this->setX($posX); - $this->setY($posY); - if ($posZ !== null) { - $this->setZ($posZ); - } - return $this; - } + /** + * @var float $height Height + */ + protected $height = -1.; - /** - * Set X position - * - * @param float $posX Horizontal position - * @return static - */ - public function setX($posX) { - $this->posX = (float)$posX; - return $this; - } + /** + * @var string $horizontalAlign Horizontal alignment + */ + protected $horizontalAlign = self::CENTER; - /** - * Set Y position - * - * @param float $posY Vertical position - * @return static - */ - public function setY($posY) { - $this->posY = (float)$posY; - return $this; - } + /** + * @var string $verticalAlign Vertical alignment + */ + protected $verticalAlign = self::CENTER2; - /** - * Set Z position - * - * @param float $posZ Depth - * @return static - */ - public function setZ($posZ) { - $this->posZ = (float)$posZ; - return $this; - } + /** + * @var float $scale Scale + */ + protected $scale = 1.; - /** - * Set Control size - * - * @param float $width Control width - * @param float $height Control height - * @return static - */ - public function setSize($width, $height) { - $this->setWidth($width); - $this->setHeight($height); - return $this; - } + /** + * @var bool $visible Visibility + */ + protected $visible = true; - /** - * Set Control width - * - * @param float $width Control width - * @return static - */ - public function setWidth($width) { - $this->width = (float)$width; - return $this; - } + /** + * @var float $rotation Rotation + */ + protected $rotation = 0.; - /** - * Set Control height - * - * @param float $height Control height - * @return static - */ - public function setHeight($height) { - $this->height = (float)$height; - return $this; - } + /** + * @var string[] $classes Style classes + */ + protected $classes = array(); - /** - * Center alignment - * - * @return static - */ - public function centerAlign() { - $this->setAlign(self::CENTER, self::CENTER2); - return $this; - } + /** + * @var mixed[] $dataAttributes Data attributes + */ + protected $dataAttributes = array(); - /** - * Set horizontal and vertical alignment - * - * @param string $hAlign Horizontal alignment - * @param string $vAlign Vertical alignment - * @return static - */ - public function setAlign($hAlign, $vAlign) { - $this->setHAlign($hAlign); - $this->setVAlign($vAlign); - return $this; - } + /** + * @var ScriptFeature[] $scriptFeatures Script Features + */ + protected $scriptFeatures = array(); - /** - * Set horizontal alignment - * - * @param string $hAlign Horizontal alignment - * @return static - */ - public function setHAlign($hAlign) { - $this->hAlign = (string)$hAlign; - return $this; - } + /** + * Create a new Control + * + * @api + * @param string $controlId (optional) Control Id + * @return static + */ + public static function create($controlId = null) + { + return new static($controlId); + } - /** - * Set vertical alignment - * - * @param string $vAlign Vertical alignment - * @return static - */ - public function setVAlign($vAlign) { - $this->vAlign = (string)$vAlign; - return $this; - } + /** + * Construct a new Control + * + * @api + * @param string $controlId (optional) Control Id + */ + public function __construct($controlId = null) + { + if ($controlId) { + $this->setId($controlId); + } + } - /** - * Reset alignment - * - * @return static - */ - public function resetAlign() { - $this->setAlign(null, null); - return $this; - } + /** + * @see Identifiable::getId() + */ + public function getId() + { + return $this->controlId; + } - /** - * Set Control scale - * - * @param float $scale Control scale - * @return static - */ - public function setScale($scale) { - $this->scale = (float)$scale; - return $this; - } + /** + * @see Identifiable::setId() + */ + public function setId($controlId) + { + $this->controlId = (string)$controlId; + return $this; + } - /** - * Set visibility - * - * @param bool $visible Whether the Control should be visible - * @return static - */ - public function setVisible($visible = true) { - $this->hidden = ($visible ? 0 : 1); - return $this; - } + /** + * @see Identifiable::checkId() + */ + public function checkId() + { + return UniqueID::check($this); + } - /** - * Set Control rotation - * - * @param float $rotation Control rotation - * @return static - */ - public function setRotation($rotation) { - $this->rotation = (float)$rotation; - return $this; - } + /** + * Get the X position + * + * @api + * @return float + */ + public function getX() + { + return $this->posX; + } - /** - * Add a new class name - * - * @param string $class Class name - * @return static - */ - public function addClass($class) { - $class = (string)$class; - if (!in_array($class, $this->classes)) { - array_push($this->classes, $class); - } - return $this; - } + /** + * Set the X position + * + * @api + * @param float $posX Horizontal position + * @return static + */ + public function setX($posX) + { + $this->posX = (float)$posX; + return $this; + } - /** - * Add a dynamic Action Trigger - * - * @param string $actionName Action to trigger - * @param string $eventLabel (optional) Event on which the action is triggered - * @return static - */ - public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) { - if ($actionName instanceof ActionTrigger) { - $this->addScriptFeature($actionName); - } else { - $actionTrigger = new ActionTrigger($actionName, $this, $eventLabel); - $this->addScriptFeature($actionTrigger); - } - return $this; - } + /** + * Get the Y position + * + * @api + * @return float + */ + public function getY() + { + return $this->posY; + } - /** - * Add a new Script Feature - * - * @param ScriptFeature $scriptFeature Script Feature - * @return static - */ - public function addScriptFeature(ScriptFeature $scriptFeature) { - if (!in_array($scriptFeature, $this->scriptFeatures, true)) { - array_push($this->scriptFeatures, $scriptFeature); - } - return $this; - } + /** + * Set the Y position + * + * @api + * @param float $posY Vertical position + * @return static + */ + public function setY($posY) + { + $this->posY = (float)$posY; + return $this; + } - /** - * Add a dynamic Feature opening the current map info - * - * @param string $eventLabel (optional) Event on which the map info will be opened - * @return static - */ - public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) { - $mapInfo = new MapInfo($this, $eventLabel); - $this->addScriptFeature($mapInfo); - return $this; - } + /** + * Get the Z position + * + * @api + * @return float + */ + public function getZ() + { + return $this->posZ; + } - /** - * Add a dynamic Feature to open a specific player profile - * - * @param string $login Login of the player - * @param string $eventLabel (optional) Event on which the player profile will be opened - * @return static - */ - public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) { - $playerProfile = new PlayerProfile($login, $this, $eventLabel); - $this->addScriptFeature($playerProfile); - return $this; - } + /** + * Set the Z position + * + * @api + * @param float $posZ Depth + * @return static + */ + public function setZ($posZ) + { + $this->posZ = (float)$posZ; + return $this; + } - /** - * Add a dynamic Feature playing a UISound - * - * @param string $soundName UISound name - * @param int $variant (optional) Sound variant - * @param string $eventLabel (optional) Event on which the sound will be played - * @return static - */ - public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) { - $uiSound = new UISound($soundName, $this, $variant, $eventLabel); - $this->addScriptFeature($uiSound); - return $this; - } + /** + * Set the Control position + * + * @api + * @param float $posX Horizontal position + * @param float $posY Vertical position + * @param float $posZ (optional) Depth + * @return static + */ + public function setPosition($posX, $posY, $posZ = null) + { + $this->setX($posX) + ->setY($posY); + if ($posZ !== null) { + $this->setZ($posZ); + } + return $this; + } - /** - * Add a dynamic Feature toggling another Control - * - * @param Control $toggledControl Toggled Control - * @param string $labelName (optional) Script label name - * @param bool $onlyShow (optional) Whether it should only show the Control but not toggle - * @param bool $onlyHide (optional) Whether it should only hide the Control but not toggle - * @return static - */ - public function addToggleFeature(Control $toggledControl, $labelName = Scriptlabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) { - $toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide); - $this->addScriptFeature($toggle); - return $this; - } + /** + * Get the width + * + * @api + * @return float + */ + public function getWidth() + { + return $this->width; + } - /** - * Add a dynamic Feature showing a Tooltip on hovering - * - * @param Control $tooltipControl Tooltip Control - * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click - * @param bool $invert (optional) Whether the visibility toggling should be inverted - * @return static - */ - public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) { - $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert); - $this->addScriptFeature($tooltip); - return $this; - } + /** + * Set the width + * + * @api + * @param float $width Control width + * @return static + */ + public function setWidth($width) + { + $this->width = (float)$width; + return $this; + } - /** - * Add a dynamic Feature showing a Tooltip on hovering - * - * @param Label $tooltipControl Tooltip Control - * @param string $text Text to display on the Tooltip Label - * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click - * @param bool $invert (optional) Whether the visibility toggling should be inverted - * @return static - */ - public function addTooltipLabelFeature(Label $tooltipControl, $text, $stayOnClick = false, $invert = false) { - $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert, $text); - $this->addScriptFeature($tooltip); - return $this; - } + /** + * Get the height + * + * @api + * @return float + */ + public function getHeight() + { + return $this->height; + } - /** - * Add a custom Control Script text part - * - * @param string $scriptText Script text - * @param string $label (optional) Script label name - * @return static - */ - public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK) { - $customText = new ControlScript($this, $scriptText, $label); - $this->addScriptFeature($customText); - return $this; - } + /** + * Set the height + * + * @api + * @param float $height Control height + * @return static + */ + public function setHeight($height) + { + $this->height = (float)$height; + return $this; + } - /** - * Remove all Script Features - * - * @return static - */ - public function removeScriptFeatures() { - $this->scriptFeatures = array(); - return $this; - } + /** + * Set the size + * + * @api + * @param float $width Control width + * @param float $height Control height + * @return static + */ + public function setSize($width, $height) + { + return $this->setWidth($width) + ->setHeight($height); + } - /** - * @see \FML\Types\ScriptFeatureable::getScriptFeatures() - */ - public function getScriptFeatures() { - return $this->scriptFeatures; - } + /** + * Get the horizontal alignment + * + * @api + * @return string + */ + public function getHorizontalAlign() + { + return $this->horizontalAlign; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - if ($this->controlId) { - $xmlElement->setAttribute('id', $this->controlId); - } - if ($this->posX || $this->posY || $this->posZ) { - $xmlElement->setAttribute('posn', "{$this->posX} {$this->posY} {$this->posZ}"); - } - if ($this->width >= 0. || $this->height >= 0.) { - $xmlElement->setAttribute('sizen', "{$this->width} {$this->height}"); - } - if ($this->hAlign !== self::LEFT) { - $xmlElement->setAttribute('halign', $this->hAlign); - } - if ($this->vAlign !== self::TOP) { - $xmlElement->setAttribute('valign', $this->vAlign); - } - if ($this->scale != 1.) { - $xmlElement->setAttribute('scale', $this->scale); - } - if ($this->hidden) { - $xmlElement->setAttribute('hidden', $this->hidden); - } - if ($this->rotation) { - $xmlElement->setAttribute('rot', $this->rotation); - } - if (!empty($this->classes)) { - $classes = implode(' ', $this->classes); - $xmlElement->setAttribute('class', $classes); - } - return $xmlElement; - } + /** + * Set the horizontal alignment + * + * @api + * @param string $horizontalAlign Horizontal alignment + * @return static + * @deprecated Use setHorizontalAlign() instead + */ + public function setHAlign($horizontalAlign) + { + return $this->setHorizontalAlign($horizontalAlign); + } + + /** + * Set the horizontal alignment + * + * @api + * @param string $horizontalAlign Horizontal alignment + * @return static + */ + public function setHorizontalAlign($horizontalAlign) + { + $this->horizontalAlign = (string)$horizontalAlign; + return $this; + } + + /** + * Get the vertical alignment + * + * @api + * @return string + */ + public function getVerticalAlign() + { + return $this->verticalAlign; + } + + /** + * Set the vertical alignment + * + * @api + * @param string $verticalAlign Vertical alignment + * @return static + * @deprecated + */ + public function setVAlign($verticalAlign) + { + return $this->setVerticalAlign($verticalAlign); + } + + /** + * Set the vertical alignment + * + * @api + * @param string $verticalAlign Vertical alignment + * @return static + */ + public function setVerticalAlign($verticalAlign) + { + $this->verticalAlign = (string)$verticalAlign; + return $this; + } + + /** + * Set the horizontal and the vertical alignment + * + * @api + * @param string $horizontalAlign Horizontal alignment + * @param string $verticalAlign Vertical alignment + * @return static + */ + public function setAlign($horizontalAlign, $verticalAlign) + { + return $this->setHorizontalAlign($horizontalAlign) + ->setVerticalAlign($verticalAlign); + } + + /** + * Center the alignment + * + * @api + * @return static + */ + public function centerAlign() + { + return $this->setAlign(self::CENTER, self::CENTER2); + } + + /** + * Clear the alignment + * + * @api + * @return static + */ + public function clearAlign() + { + $this->horizontalAlign = null; + $this->verticalAlign = null; + return $this; + } + + /** + * Get the scale + * + * @api + * @return float + */ + public function getScale() + { + return $this->scale; + } + + /** + * Set the scale + * + * @api + * @param float $scale Control scale + * @return static + */ + public function setScale($scale) + { + $this->scale = (float)$scale; + return $this; + } + + /** + * Get the visibility + * + * @api + * @return bool + */ + public function getVisible() + { + return $this->visible; + } + + /** + * Set the visibility + * + * @api + * @param bool $visible If the Control should be visible + * @return static + */ + public function setVisible($visible) + { + $this->visible = $visible; + return $this; + } + + /** + * Get the rotation + * + * @api + * @return float + */ + public function getRotation() + { + return $this->rotation; + } + + /** + * Set the rotation + * + * @api + * @param float $rotation Control rotation + * @return static + */ + public function setRotation($rotation) + { + $this->rotation = (float)$rotation; + return $this; + } + + /** + * Get style classes + * + * @api + * @return string[] + */ + public function getClasses() + { + return $this->classes; + } + + /** + * Add a new style class + * + * @api + * @param string $class Style class + * @return static + */ + public function addClass($class) + { + $class = (string)$class; + if (!in_array($class, $this->classes)) { + array_push($this->classes, $class); + } + return $this; + } + + /** + * Add new style classes + * + * @api + * @param string[] $classes Style classes + * @return static + */ + public function addClasses(array $classes) + { + foreach ($classes as $class) { + $this->addClass($class); + } + return $this; + } + + /** + * Remove all style classes + * + * @api + * @return static + */ + public function removeAllClasses() + { + $this->classes = array(); + return $this; + } + + /** + * Check if a data attribute is set + * + * @api + * @param string $name Name + * @return bool + */ + public function hasDataAttribute($name) + { + return isset($this->dataAttributes[$name]); + } + + /** + * Get data attribute + * + * @api + * @param string $name Name + * @return mixed + */ + public function getDataAttribute($name) + { + if (isset($this->dataAttributes[$name])) { + return $this->dataAttributes[$name]; + } + return null; + } + + /** + * Get data attributes + * + * @api + * @return mixed[] + */ + public function getDataAttributes() + { + return $this->dataAttributes; + } + + /** + * Add data attribute + * + * @api + * @param string $name Name + * @param mixed $value Value + * @return static + */ + public function addDataAttribute($name, $value) + { + $this->dataAttributes[$name] = $value; + return $this; + } + + /** + * Add multiple data attributes + * + * @api + * @param mixed[] $dataAttributes Data attributes + * @return static + */ + public function addDataAttributes(array $dataAttributes) + { + foreach ($dataAttributes as $name => $value) { + $this->addDataAttribute($name, $value); + } + return $this; + } + + /** + * Set data attributes (replacing all previous attributes) + * + * @api + * @param mixed[] $dataAttributes Data attributes + * @return static + */ + public function setDataAttributes(array $dataAttributes) + { + return $this->removeAllDataAttributes() + ->addDataAttributes($dataAttributes); + } + + /** + * Remove data attribute + * + * @api + * @param string $name Name + * @return static + */ + public function removeDataAttribute($name) + { + unset($this->dataAttributes[$name]); + return $this; + } + + /** + * Remove all data attributes + * + * @api + * @return static + */ + public function removeAllDataAttributes() + { + $this->dataAttributes = array(); + return $this; + } + + /** + * @see ScriptFeatureable::getScriptFeatures() + */ + public function getScriptFeatures() + { + return $this->scriptFeatures; + } + + /** + * Add a new Script Feature + * + * @api + * @param ScriptFeature $scriptFeature Script Feature + * @return static + */ + public function addScriptFeature(ScriptFeature $scriptFeature) + { + if (!in_array($scriptFeature, $this->scriptFeatures, true)) { + array_push($this->scriptFeatures, $scriptFeature); + } + return $this; + } + + /** + * Remove all Script Features + * + * @api + * @return static + * @deprecated use removeAllScriptFeatures() instead + */ + public function removeScriptFeatures() + { + return $this->removeAllScriptFeatures(); + } + + /** + * Remove all Script Features + * + * @api + * @return static + */ + public function removeAllScriptFeatures() + { + $this->scriptFeatures = array(); + return $this; + } + + /** + * Add a dynamic Action Trigger + * + * @api + * @param string $actionName Action to trigger + * @param string $eventLabel (optional) Event on which the action is triggered + * @return static + */ + public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) + { + $actionTrigger = new ActionTrigger($actionName, $this, $eventLabel); + $this->addScriptFeature($actionTrigger); + return $this; + } + + /** + * Add a dynamic Feature opening the current map info + * + * @api + * @param string $eventLabel (optional) Event on which the map info will be opened + * @return static + */ + public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) + { + $mapInfo = new MapInfo($this, $eventLabel); + $this->addScriptFeature($mapInfo); + return $this; + } + + /** + * Add a dynamic Feature to open a specific player profile + * + * @api + * @param string $login Login of the player + * @param string $eventLabel (optional) Event on which the player profile will be opened + * @return static + */ + public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) + { + $playerProfile = new PlayerProfile($login, $this, $eventLabel); + $this->addScriptFeature($playerProfile); + return $this; + } + + /** + * Add a dynamic Feature playing a UISound + * + * @api + * @param string $soundName UISound name + * @param int $variant (optional) Sound variant + * @param string $eventLabel (optional) Event on which the sound will be played + * @return static + */ + public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) + { + $uiSound = new UISound($soundName, $this, $variant, $eventLabel); + $this->addScriptFeature($uiSound); + return $this; + } + + /** + * Add a dynamic Feature toggling another Control + * + * @api + * @param Control $toggledControl Toggled Control + * @param string $labelName (optional) Script label name + * @param bool $onlyShow (optional) If it should only show the Control but not toggle + * @param bool $onlyHide (optional) If it should only hide the Control but not toggle + * @return static + */ + public function addToggleFeature(Control $toggledControl, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) + { + $toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide); + $this->addScriptFeature($toggle); + return $this; + } + + /** + * Add a dynamic Feature showing a Tooltip on hovering + * + * @api + * @param Control $tooltipControl Tooltip Control + * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click + * @param bool $invert (optional) Whether the visibility toggling should be inverted + * @return static + */ + public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) + { + $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert); + $this->addScriptFeature($tooltip); + return $this; + } + + /** + * Add a dynamic Feature showing a Tooltip on hovering + * + * @api + * @param Label $tooltipLabel Tooltip Label + * @param string $text Text to display on the Tooltip Label + * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click + * @param bool $invert (optional) Whether the visibility toggling should be inverted + * @return static + */ + public function addTooltipLabelFeature(Label $tooltipLabel, $text, $stayOnClick = false, $invert = false) + { + $tooltip = new Tooltip($this, $tooltipLabel, $stayOnClick, $invert, $text); + $this->addScriptFeature($tooltip); + return $this; + } + + /** + * Add a custom Control Script text part + * + * @api + * @param string $scriptText Script text + * @param string $label (optional) Script label name + * @return static + */ + public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK) + { + $customText = new ControlScript($this, $scriptText, $label); + $this->addScriptFeature($customText); + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement($this->getTagName()); + if ($this->controlId) { + $domElement->setAttribute("id", $this->controlId); + } + if ($this->posX || $this->posY || $this->posZ) { + $domElement->setAttribute("posn", "{$this->posX} {$this->posY} {$this->posZ}"); + } + if ($this->posZ) { + $domElement->setAttribute("z-index", $this->posZ); + } + if ($this->width >= 0. || $this->height >= 0.) { + $domElement->setAttribute("sizen", "{$this->width} {$this->height}"); + } + if ($this->horizontalAlign) { + $domElement->setAttribute("halign", $this->horizontalAlign); + } + if ($this->verticalAlign) { + $domElement->setAttribute("valign", $this->verticalAlign); + } + if ($this->scale != 1.) { + $domElement->setAttribute("scale", $this->scale); + } + if (!$this->visible) { + $domElement->setAttribute("hidden", "1"); + } + if ($this->rotation) { + $domElement->setAttribute("rot", $this->rotation); + } + if (!empty($this->classes)) { + $classes = implode(" ", $this->classes); + $domElement->setAttribute("class", $classes); + } + foreach ($this->dataAttributes as $dataAttributeName => $dataAttributeValue) { + $domElement->setAttribute("data-" . $dataAttributeName, $dataAttributeValue); + } + return $domElement; + } + + /** + * Get the tag name of the Control + * + * @return string + */ + abstract public function getTagName(); + + /** + * Get the ManiaScript class of the Control + * + * @return string + */ + abstract public function getManiaScriptClass(); - /** - * Get the ManiaScript class of the Control - * - * @return string - */ - public abstract function getManiaScriptClass(); } diff --git a/libs/FML/Controls/Entry.php b/libs/FML/Controls/Entry.php index 210e3df8..67258a6b 100644 --- a/libs/FML/Controls/Entry.php +++ b/libs/FML/Controls/Entry.php @@ -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,205 +14,470 @@ use FML\Types\TextFormatable; * (CMlEntry) * * @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 Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable { - /* - * Protected properties - */ - protected $tagName = 'entry'; - protected $name = null; - protected $default = null; - protected $autoNewLine = null; - protected $scriptEvents = null; - protected $style = null; - protected $textColor = null; - protected $textSize = -1; - protected $textFont = null; - protected $focusAreaColor1 = null; - protected $focusAreaColor2 = null; - protected $autoComplete = null; +class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlEntry'; - } + /* + * Constants + */ + const FORMAT_Default = "Default"; + const FORMAT_Password = "Password"; + const FORMAT_NewPassword = "NewPassword"; - /** - * Get the Entry name - * - * @return string - */ - public function getName() { - return $this->name; - } + /** + * @var string $name Entry name + */ + protected $name = null; - /** - * Set Entry name - * - * @param string $name Entry name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $default Default value + */ + protected $default = null; - /** - * Get the default value - * - * @return mixed - */ - public function getDefault() { - return $this->default; - } + /** + * @var bool $selectText Select text + */ + protected $selectText = null; - /** - * Set default value - * - * @param string $default Default value - * @return static - */ - public function setDefault($default) { - $this->default = $default; - return $this; - } + /** + * @deprecated + * @var bool $autoNewLine Auto new line + */ + protected $autoNewLine = null; - /** - * @see \FML\Types\NewLineable::setAutoNewLine() - */ - public function setAutoNewLine($autoNewLine) { - $this->autoNewLine = ($autoNewLine ? 1 : 0); - return $this; - } + /** + * @var string $textFormat Text format + */ + protected $textFormat = null; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - return $this; - } + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; - /** - * @see \FML\Types\TextFormatable::setTextColor() - */ - public function setTextColor($textColor) { - $this->textColor = (string)$textColor; - return $this; - } + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; - /** - * @see \FML\Types\TextFormatable::setTextSize() - */ - public function setTextSize($textSize) { - $this->textSize = (int)$textSize; - return $this; - } + /** + * @var string $style Style + */ + protected $style = null; - /** - * @see \FML\Types\TextFormatable::setTextFont() - */ - public function setTextFont($textFont) { - $this->textFont = (string)$textFont; - return $this; - } + /** + * @var string $textColor Text color + */ + protected $textColor = null; - /** - * @see \FML\Types\TextFormatable::setAreaColor() - */ - public function setAreaColor($areaColor) { - $this->focusAreaColor1 = (string)$areaColor; - return $this; - } + /** + * @var int $textSize Text size + */ + protected $textSize = null; - /** - * @see \FML\Types\TextFormatable::setAreaFocusColor() - */ - public function setAreaFocusColor($areaFocusColor) { - $this->focusAreaColor2 = (string)$areaFocusColor; - return $this; - } + /** + * @var string $textFont Text font + */ + protected $textFont = null; - /** - * Set auto completion - * - * @param bool $autoComplete Whether the default value should be automatically completed based on the current request parameters - * @return static - */ - public function setAutoComplete($autoComplete) { - $this->autoComplete = (bool)$autoComplete; - return $this; - } + /** + * @var string $areaColor Area color + */ + protected $areaColor = null; - /** - * Add a dynamic Feature submitting the Entry - * - * @param string $url Submit url - * @return static - */ - public function addSubmitFeature($url) { - $entrySubmit = new EntrySubmit($this, $url); - $this->addScriptFeature($entrySubmit); - return $this; - } + /** + * @var string $focusAreaColor Focus area color + */ + protected $focusAreaColor = null; + + /** + * @var bool $autoComplete Auto complete + */ + protected $autoComplete = null; + + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the name + * + * @api + * @param string $name Entry name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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; + } + + /** + * Get select text + * + * @api + * @return bool + */ + 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 NewLineable::getAutoNewLine() + */ + public function getAutoNewLine() + { + return $this->autoNewLine; + } + + /** + * @see NewLineable::setAutoNewLine() + */ + public function setAutoNewLine($autoNewLine) + { + $this->autoNewLine = (bool)$autoNewLine; + 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 = $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; + } + + /** + * Get auto completion + * + * @api + * @return bool + */ + public function getAutoComplete() + { + return $this->autoComplete; + } + + /** + * Set auto completion + * + * @api + * @param bool $autoComplete Automatically complete the default value based on the current request parameters + * @return static + */ + public function setAutoComplete($autoComplete) + { + $this->autoComplete = (bool)$autoComplete; + return $this; + } + + /** + * Add a dynamic Feature submitting the Entry + * + * @api + * @param string $url Submit url + * @return static + */ + public function addSubmitFeature($url) + { + $entrySubmit = new EntrySubmit($this, $url); + return $this->addScriptFeature($entrySubmit); + } + + /** + * @see Control::getTagName() + */ + 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) { + $domElement->setAttribute("name", $this->name); + } + if ($this->default !== null) { + $domElement->setAttribute("default", $this->default); + } else if ($this->autoComplete) { + $value = Parameters::getValue($this->name); + if ($value) { + $domElement->setAttribute("default", $value); + } + } + if ($this->selectText) { + $domElement->setAttribute("selecttext", 1); + } + if ($this->autoNewLine) { + $domElement->setAttribute("autonewline", 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; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->name) { - $xmlElement->setAttribute('name', $this->name); - } - if ($this->default !== null) { - $xmlElement->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]; - } - if ($value) { - $xmlElement->setAttribute('default', $value); - } - } - if ($this->autoNewLine) { - $xmlElement->setAttribute('autonewline', $this->autoNewLine); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - if ($this->style) { - $xmlElement->setAttribute('style', $this->style); - } - if ($this->textColor) { - $xmlElement->setAttribute('textcolor', $this->textColor); - } - if ($this->textSize >= 0.) { - $xmlElement->setAttribute('textsize', $this->textSize); - } - if ($this->textFont) { - $xmlElement->setAttribute('textfont', $this->textFont); - } - if ($this->focusAreaColor1) { - $xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1); - } - if ($this->focusAreaColor2) { - $xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/FileEntry.php b/libs/FML/Controls/FileEntry.php index 8ccbf2a7..3fc5fe69 100644 --- a/libs/FML/Controls/FileEntry.php +++ b/libs/FML/Controls/FileEntry.php @@ -7,42 +7,67 @@ namespace FML\Controls; * (CMlFileEntry) * * @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 FileEntry extends Entry { - /* - * Protected properties - */ - protected $tagName = 'fileentry'; - protected $folder = null; +class FileEntry extends Entry +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlFileEntry'; - } + /** + * @var string $folder Folder + */ + protected $folder = null; - /** - * Set the base folder - * - * @param string $folder Base folder - * @return static - */ - public function setFolder($folder) { - $this->folder = (string)$folder; - return $this; - } + /** + * Get the folder + * + * @api + * @return string + */ + public function getFolder() + { + return $this->folder; + } + + /** + * Set the folder + * + * @api + * @param string $folder Base folder + * @return static + */ + public function setFolder($folder) + { + $this->folder = (string)$folder; + return $this; + } + + /** + * @see Control::getTagName() + */ + 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) { + $domElement->setAttribute("folder", $this->folder); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->folder) { - $xmlElement->setAttribute('folder', $this->folder); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Frame.php b/libs/FML/Controls/Frame.php index fbb677cb..2ab8a5e8 100644 --- a/libs/FML/Controls/Frame.php +++ b/libs/FML/Controls/Frame.php @@ -12,88 +12,132 @@ use FML\Types\ScriptFeatureable; * (CMlFrame) * * @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 Frame extends Control implements Container { - /* - * Protected properties - */ - protected $tagName = 'frame'; - /** @var Renderable[] $children */ - protected $children = array(); - /** @var Format $format */ - protected $format = null; +class Frame extends Control implements Container +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlFrame'; - } + /** + * @var Renderable[] $children Children + */ + protected $children = array(); - /** - * @see \FML\Types\Container::add() - */ - public function add(Renderable $child) { - if (!in_array($child, $this->children, true)) { - array_push($this->children, $child); - } - return $this; - } + /** + * @var Format $format Format + */ + protected $format = null; - /** - * @see \FML\Types\Container::removeChildren() - */ - public function removeChildren() { - $this->children = array(); - return $this; - } + /** + * @see Container::getChildren() + */ + public function getChildren() + { + return $this->children; + } - /** - * @see \FML\Types\Container::getFormat() - */ - public function getFormat($createIfEmpty = true) { - if (!$this->format && $createIfEmpty) { - $this->setFormat(new Format()); - } - return $this->format; - } + /** + * @see Container::addChild() + * @deprecated use addChild() instead + */ + public function add(Renderable $child) + { + return $this->addChild($child); + } - /** - * @see \FML\Types\Container::setFormat() - */ - public function setFormat(Format $format) { - $this->format = $format; - return $this; - } + /** + * @see Container::addChild() + */ + public function addChild(Renderable $child) + { + if (!in_array($child, $this->children, true)) { + array_push($this->children, $child); + } + return $this; + } - /** - * @see \FML\Controls\Control::getScriptFeatures() - */ - public function getScriptFeatures() { - $scriptFeatures = $this->scriptFeatures; - foreach ($this->children as $child) { - if ($child instanceof ScriptFeatureable) { - $scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures()); - } - } - return $scriptFeatures; - } + /** + * @see Container::addChildren() + */ + public function addChildren(array $children) + { + foreach ($children as $child) { + $this->addChild($child); + } + return $this; + } + + /** + * @see Container::removeAllChildren() + */ + public function removeAllChildren() + { + $this->children = array(); + return $this; + } + + /** + * @see Container::getFormat() + */ + public function getFormat() + { + return $this->format; + } + + /** + * @see Container::setFormat() + */ + public function setFormat(Format $format = null) + { + $this->format = $format; + return $this; + } + + /** + * @see Control::getTagName() + */ + 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) { + $scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures()); + } + } + return $scriptFeatures; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->format) { + $formatXml = $this->format->render($domDocument); + $domElement->appendChild($formatXml); + } + foreach ($this->children as $child) { + $childXmlElement = $child->render($domDocument); + $domElement->appendChild($childXmlElement); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->format) { - $formatXml = $this->format->render($domDocument); - $xmlElement->appendChild($formatXml); - } - foreach ($this->children as $child) { - $childXmlElement = $child->render($domDocument); - $xmlElement->appendChild($childXmlElement); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Frame3d.php b/libs/FML/Controls/Frame3d.php index 36e6b506..8449005e 100644 --- a/libs/FML/Controls/Frame3d.php +++ b/libs/FML/Controls/Frame3d.php @@ -10,79 +10,184 @@ use FML\Types\Scriptable; * (CMlFrame) * * @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 Frame3d extends Frame implements Scriptable { - /* - * Constants - */ - const STYLE_BaseStation = 'BaseStation'; - const STYLE_BaseBoxCase = 'BaseBoxCase'; - const STYLE_Titlelogo = 'Titlelogo'; - const STYLE_ButtonBack = 'ButtonBack'; - const STYLE_ButtonNav = 'ButtonNav'; - const STYLE_ButtonH = 'ButtonH'; - const STYLE_Station3x3 = 'Station3x3'; - const STYLE_Title = 'Title'; - const STYLE_TitleEditor = 'TitleEditor'; - const STYLE_Window = 'Window'; +class Frame3d extends Frame implements Scriptable +{ - /* - * Protected properties - */ - protected $tagName = 'frame3d'; - protected $style3dId = null; - /** @var Style3d $style3d */ - protected $style3d = null; - protected $scriptEvents = null; + /* + * Constants + */ + const STYLE_BaseStation = 'BaseStation'; + const STYLE_BaseBoxCase = 'BaseBoxCase'; + const STYLE_TitleLogo = 'Titlelogo'; + const STYLE_ButtonBack = 'ButtonBack'; + const STYLE_ButtonNav = 'ButtonNav'; + const STYLE_ButtonH = 'ButtonH'; + const STYLE_Station3x3 = 'Station3x3'; + const STYLE_Title = 'Title'; + const STYLE_TitleEditor = 'TitleEditor'; + const STYLE_Window = 'Window'; - /** - * Set Style3d id - * - * @param string $style3dId Style3d id - * @return static - */ - public function setStyle3dId($style3dId) { - $this->style3dId = (string)$style3dId; - $this->style3d = null; - return $this; - } + /** + * @var string $style3dId Style3d id + */ + protected $style3dId = null; - /** - * Set Style3d - * - * @param Style3d $style3d Style3d object - * @return static - */ - public function setStyle3d(Style3d $style3d) { - $this->style3d = $style3d; - $this->style3dId = null; - return $this; - } + /** + * @var Style3d $style3d Style3d + */ + protected $style3d = null; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; + + /** + * @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) + { + $this->style3dId = (string)$style3dId; + $this->style3d = null; + return $this; + } + + /** + * Get the Style3d + * + * @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->style3dId = null; + $this->style3d = $style3d; + 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 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(); + $domElement->setAttribute("style3d", $this->style3d->getId()); + } else if ($this->style3dId) { + $domElement->setAttribute("style3d", $this->style3dId); + } + 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)); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->style3d) { - $this->style3d->checkId(); - $xmlElement->setAttribute('style3d', $this->style3d->getId()); - } else if ($this->style3dId) { - $xmlElement->setAttribute('style3d', $this->style3dId); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/FrameInstance.php b/libs/FML/Controls/FrameInstance.php index 30914afc..c4bf2200 100644 --- a/libs/FML/Controls/FrameInstance.php +++ b/libs/FML/Controls/FrameInstance.php @@ -9,84 +9,101 @@ use FML\Elements\FrameModel; * (CMlFrame) * * @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 FrameInstance extends Control { - /* - * Protected properties - */ - protected $tagName = 'frameinstance'; - protected $modelId = null; - /** @var FrameModel $model */ - protected $model = null; +class FrameInstance extends Control +{ - /** - * Create a new Frame Instance object - * - * @param string $modelId (optional) Frame Model id - * @param string $controlId (optional) Frame id - * @return static - */ - public static function create($modelId = null, $controlId = null) { - return new static($modelId, $controlId); - } + /** + * @var string $modelId FrameModel id + */ + protected $modelId = null; - /** - * Construct a new Frame Instance object - * - * @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); - } - } + /** + * @var FrameModel $model FrameModel + */ + protected $model = null; - /** - * Set Frame Model id - * - * @param string $modelId Frame Model id - * @return static - */ - public function setModelId($modelId) { - $this->modelId = (string)$modelId; - $this->model = null; - return $this; - } + /** + * Get the FrameModel id + * + * @api + * @return string + */ + public function getModelId() + { + return $this->modelId; + } - /** - * Set Frame Model - * - * @param FrameModel $frameModel Frame Model - * @return static - */ - public function setModel(FrameModel $frameModel) { - $this->model = $frameModel; - $this->modelId = null; - return $this; - } + /** + * Set the FrameModel id + * + * @api + * @param string $modelId FrameModel id + * @return static + */ + public function setModelId($modelId) + { + $this->modelId = (string)$modelId; + $this->model = null; + return $this; + } - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlFrame'; - } + /** + * Get the FrameModel + * + * @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->modelId = null; + $this->model = $frameModel; + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "frameinstance"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlFrame"; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->model) { + $this->model->checkId(); + $domElement->setAttribute("modelid", $this->model->getId()); + } else if ($this->modelId) { + $domElement->setAttribute("modelid", $this->modelId); + } + return $domElement; + } - /** - * @see \FML\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->model) { - $this->model->checkId(); - $xmlElement->setAttribute('modelid', $this->model->getId()); - } else if ($this->modelId) { - $xmlElement->setAttribute('modelid', $this->modelId); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Gauge.php b/libs/FML/Controls/Gauge.php index 9c24780a..b3338eb5 100644 --- a/libs/FML/Controls/Gauge.php +++ b/libs/FML/Controls/Gauge.php @@ -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 - * @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 { - /* - * Constants - */ - const STYLE_BgCard = 'BgCard'; - const STYLE_EnergyBar = 'EnergyBar'; - const STYLE_ProgressBar = 'ProgressBar'; - const STYLE_ProgressBarSmall = 'ProgressBarSmall'; +class Gauge extends Control implements Colorable, Styleable +{ - /* - * Protected properties - */ - protected $tagName = 'gauge'; - protected $ratio = 0.; - protected $grading = 1.; - protected $color = null; - protected $centered = null; - protected $clan = null; - protected $drawBg = 1; - protected $drawBlockBg = 1; - protected $style = null; + /* + * Constants + */ + const STYLE_BgCard = "BgCard"; + const STYLE_EnergyBar = "EnergyBar"; + const STYLE_ProgressBar = "ProgressBar"; + const STYLE_ProgressBarSmall = "ProgressBarSmall"; - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlGauge'; - } + /** + * @var float $ratio Ratio + */ + protected $ratio = 0.0; - /** - * Set ratio - * - * @param float $ratio Ratio value - * @return static - */ - public function setRatio($ratio) { - $this->ratio = (float)$ratio; - return $this; - } + /** + * @var float $grading Grading + */ + protected $grading = 1.; - /** - * Set grading - * - * @param float $grading Grading value - * @return static - */ - public function setGrading($grading) { - $this->grading = (float)$grading; - return $this; - } + /** + * @var string $color Color + */ + protected $color = null; - /** - * Set color - * - * @param string $color Gauge color - * @return static - */ - public function setColor($color) { - $this->color = (string)$color; - return $this; - } + /** + * @var bool $centered Centered + */ + protected $centered = null; - /** - * Set centered - * - * @param bool $centered Whether the Gauge is centered - * @return static - */ - public function setCentered($centered) { - $this->centered = ($centered ? 1 : 0); - return $this; - } + /** + * @var int $clan Clan number + */ + protected $clan = null; - /** - * Set clan - * - * @param int $clan Clan number - * @return static - */ - public function setClan($clan) { - $this->clan = (int)$clan; - return $this; - } + /** + * @var bool $drawBackground Draw background + */ + protected $drawBackground = true; - /** - * Set draw background - * - * @param bool $drawBg Whether the Gauges background should be drawn - * @return static - */ - public function setDrawBg($drawBg) { - $this->drawBg = ($drawBg ? 1 : 0); - return $this; - } + /** + * @var bool $drawBlockBackground Draw block background + */ + protected $drawBlockBackground = true; - /** - * Set draw block background - * - * @param bool $drawBlockBg Whether the Gauges block background should be drawn - * @return static - */ - public function setDrawBlockBg($drawBlockBg) { - $this->drawBlockBg = ($drawBlockBg ? 1 : 0); - return $this; - } + /** + * @var string $style Style + */ + protected $style = null; - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - return $this; - } + /** + * Get the ratio + * + * @api + * @return float + */ + public function getRatio() + { + return $this->ratio; + } + + /** + * Set the ratio + * + * @api + * @param float $ratio Ratio value + * @return static + */ + public function setRatio($ratio) + { + $this->ratio = (float)$ratio; + return $this; + } + + /** + * 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) + { + $this->grading = (float)$grading; + return $this; + } + + /** + * @see Colorable::getColor + */ + 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 + * + * @api + * @param bool $centered If the Gauge should be centered + * @return static + */ + public function setCentered($centered) + { + $this->centered = (bool)$centered; + return $this; + } + + /** + * 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) + { + $this->clan = (int)$clan; + return $this; + } + + /** + * Get draw background + * + * @api + * @return bool + */ + public function getDrawBackground() + { + return $this->drawBackground; + } + + /** + * Set draw background + * + * @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 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 + * + * @api + * @param bool $drawBlockBackground If the Gauges block background should be drawn + * @return static + */ + public function setDrawBlockBackground($drawBlockBackground) + { + $this->drawBlockBackground = (bool)$drawBlockBackground; + 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 Control::getTagName() + */ + 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) { + $domElement->setAttribute("ratio", $this->ratio); + } + if ($this->grading != 1.) { + $domElement->setAttribute("grading", $this->grading); + } + if ($this->color) { + $domElement->setAttribute("color", $this->color); + } + if ($this->centered) { + $domElement->setAttribute("centered", 1); + } + if ($this->clan) { + $domElement->setAttribute("clan", $this->clan); + } + if (!$this->drawBackground) { + $domElement->setAttribute("drawbg", 0); + } + if (!$this->drawBlockBackground) { + $domElement->setAttribute("drawblockbg", 0); + } + if ($this->style) { + $domElement->setAttribute("style", $this->style); + } + return $domElement; + } - /** - * @see \FML\Control::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->ratio) { - $xmlElement->setAttribute('ratio', $this->ratio); - } - if ($this->grading != 1.) { - $xmlElement->setAttribute('grading', $this->grading); - } - if ($this->color) { - $xmlElement->setAttribute('color', $this->color); - } - if ($this->centered) { - $xmlElement->setAttribute('centered', $this->centered); - } - if ($this->clan) { - $xmlElement->setAttribute('clan', $this->clan); - } - if (!$this->drawBg) { - $xmlElement->setAttribute('drawbg', $this->drawBg); - } - if (!$this->drawBlockBg) { - $xmlElement->setAttribute('drawblockbg', $this->drawBlockBg); - } - if ($this->style) { - $xmlElement->setAttribute('style', $this->style); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Graph.php b/libs/FML/Controls/Graph.php new file mode 100644 index 00000000..6d84b5de --- /dev/null +++ b/libs/FML/Controls/Graph.php @@ -0,0 +1,82 @@ +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"; + } + +} diff --git a/libs/FML/Controls/Label.php b/libs/FML/Controls/Label.php index 887b47c5..5bcd9532 100644 --- a/libs/FML/Controls/Label.php +++ b/libs/FML/Controls/Label.php @@ -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 - * @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() - */ - public function getManiaScriptClass() { - return 'CMlLabel'; - } + /** + * @var string $text Text + */ + protected $text = null; - /** - * Set text - * - * @param string $text Text value - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * @var string $textId Text ID + */ + protected $textId = null; - /** - * Set text id to use from Dico - * - * @param string $textId Text id - * @return static - */ - public function setTextId($textId) { - $this->textId = (string)$textId; - return $this; - } + /** + * @var string $textPrefix Text prefix + */ + protected $textPrefix = null; - /** - * Set text prefix - * - * @param string $textPrefix Text prefix - * @return static - */ - public function setTextPrefix($textPrefix) { - $this->textPrefix = (string)$textPrefix; - return $this; - } + /** + * @var bool $textEmboss Text emboss + */ + protected $textEmboss = null; - /** - * Set text emboss - * - * @param bool $textEmboss Whether the text should be embossed - * @return static - */ - public function setTextEmboss($textEmboss) { - $this->textEmboss = ($textEmboss ? 1 : 0); - return $this; - } + /** + * @var bool $translate Translate text + */ + protected $translate = null; - /** - * Set translate - * - * @param bool $translate Whether the text should be translated - * @return static - */ - public function setTranslate($translate) { - $this->translate = ($translate ? 1 : 0); - return $this; - } + /** + * @var int $maxLines Maximum lines + */ + protected $maxLines = -1; - /** - * Set max lines count - * - * @param int $maxLines Max lines count - * @return static - */ - public function setMaxLines($maxLines) { - $this->maxLines = (int)$maxLines; - return $this; - } + /** + * @var float $opacity Opacity + */ + protected $opacity = 1.; - /** - * @see \FML\Types\Actionable::getAction() - */ - public function getAction() { - return $this->action; - } + /** + * @var string $action Action + */ + protected $action = null; - /** - * @see \FML\Types\Actionable::setAction() - */ - public function setAction($action) { - $this->action = (string)$action; - return $this; - } + /** + * @var int $actionKey Action key + */ + protected $actionKey = -1; - /** - * @see \FML\Types\Actionable::setActionKey() - */ - public function setActionKey($actionKey) { - $this->actionKey = (int)$actionKey; - return $this; - } + /** + * @var string $url Url + */ + protected $url = null; - /** - * @see \FML\Types\Linkable::setUrl() - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * @var string $urlId Url ID + */ + protected $urlId = null; - /** - * @see \FML\Types\Linkable::setUrlId() - */ - public function setUrlId($urlId) { - $this->urlId = (string)$urlId; - return $this; - } + /** + * @var string $manialink Manialink + */ + protected $manialink = null; - /** - * @see \FML\Types\Linkable::setManialink() - */ - public function setManialink($manialink) { - $this->manialink = (string)$manialink; - return $this; - } + /** + * @var string $manialinkId Manialink ID + */ + protected $manialinkId = null; - /** - * @see \FML\Types\Linkable::setManialinkId() - */ - public function setManialinkId($manialinkId) { - $this->manialinkId = (string)$manialinkId; - return $this; - } + /** + * @var bool $autoNewLine Automatic new line + */ + protected $autoNewLine = null; - /** - * @see \FML\Types\NewLineable::setAutoNewLine() - */ - public function setAutoNewLine($autoNewLine) { - $this->autoNewLine = ($autoNewLine ? 1 : 0); - return $this; - } + /** + * @var float $lineSpacing Line spacing + */ + protected $lineSpacing = -1.; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - return $this; - } + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; - /** - * @see \FML\Types\TextFormatable::setTextSize() - */ - public function setTextSize($textSize) { - $this->textSize = (int)$textSize; - return $this; - } + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; - /** - * @see \FML\Types\TextFormatable::setTextFont() - */ - public function setTextFont($textFont) { - $this->textFont = (string)$textFont; - return $this; - } + /** + * @var string $style Style + */ + protected $style = null; - /** - * @see \FML\Types\TextFormatable::setTextColor() - */ - public function setTextColor($textColor) { - $this->textColor = (string)$textColor; - return $this; - } + /** + * @var int $textSize Text size + */ + protected $textSize = -1; - /** - * @see \FML\Types\TextFormatable::setAreaColor() - */ - public function setAreaColor($areaColor) { - $this->focusAreaColor1 = (string)$areaColor; - return $this; - } + /** + * @var string $textFont Text font + */ + protected $textFont = null; - /** - * @see \FML\Types\TextFormatable::setAreaFocusColor() - */ - public function setAreaFocusColor($areaFocusColor) { - $this->focusAreaColor2 = (string)$areaFocusColor; - return $this; - } + /** + * @var string $textColor Text color + */ + protected $textColor = null; - /** - * 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 - * @return static - */ - public function addClockFeature($showSeconds = true, $showFullDate = false) { - $clock = new Clock($this, $showSeconds, $showFullDate); - $this->addScriptFeature($clock); - return $this; - } + /** + * @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 the text + * + * @api + * @param string $text Text value + * @return static + */ + public function setText($text) + { + $this->text = (string)$text; + return $this; + } + + /** + * 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) + { + $this->textId = (string)$textId; + return $this; + } + + /** + * 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) + { + $this->textPrefix = (string)$textPrefix; + return $this; + } + + /** + * Get text emboss + * + * @api + * @return bool + */ + public function getTextEmboss() + { + return $this->textEmboss; + } + + /** + * Set text emboss + * + * @api + * @param bool $textEmboss If the text should be embossed + * @return static + */ + public function setTextEmboss($textEmboss) + { + $this->textEmboss = (bool)$textEmboss; + return $this; + } + + /** + * Get translate + * + * @api + * @return bool + */ + public function getTranslate() + { + return $this->translate; + } + + /** + * Set translate + * + * @api + * @param bool $translate If the text should be translated + * @return static + */ + public function setTranslate($translate) + { + $this->translate = (bool)$translate; + return $this; + } + + /** + * Get the opacity + * + * @api + * @return float + */ + public function getOpacity() + { + return $this->opacity; + } + + /** + * Set the opacity + * + * @api + * @param float $opacity Opacity + * @return static + */ + public function setOpacity($opacity) + { + $this->opacity = (float)$opacity; + return $this; + } + + /** + * @see Actionable::getAction() + */ + 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 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; + } + + /** + * @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::getTextSize() + */ + public function getTextSize() + { + return $this->textSize; + } + + /** + * @see TextFormatable::setTextSize() + */ + public function setTextSize($textSize) + { + $this->textSize = (int)$textSize; + return $this; + } + + /** + * @see TextFormatable::getTextFont() + */ + public function getTextFont() + { + return $this->textFont; + } + + /** + * @see TextFormatable::setTextFont() + */ + public function setTextFont($textFont) + { + $this->textFont = (string)$textFont; + return $this; + } + + /** + * @see TextFormatable::getTextColor() + */ + public function getTextColor() + { + return $this->textColor; + } + + /** + * @see TextFormatable::setTextColor() + */ + public function setTextColor($textColor) + { + $this->textColor = (string)$textColor; + return $this; + } + + /** + * @see TextFormatable::getAreaColor() + */ + public function getAreaColor() + { + return $this->areaColor; + } + + /** + * @see TextFormatable::setAreaColor() + */ + public function setAreaColor($areaColor) + { + $this->areaColor = (string)$areaColor; + return $this; + } + + /** + * @see TextFormatable::getAreaFocusColor() + */ + public function getAreaFocusColor() + { + return $this->focusAreaColor; + } + + /** + * @see TextFormatable::setAreaFocusColor() + */ + public function setAreaFocusColor($areaFocusColor) + { + $this->focusAreaColor = (string)$areaFocusColor; + return $this; + } + + /** + * Add a dynamic Feature showing the current time + * + * @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) + { + $clock = new Clock($this, $showSeconds, $showFullDate); + $this->addScriptFeature($clock); + return $this; + } + + /** + * @see Control::getTagName() + */ + 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) { + $domElement->setAttribute("textid", $this->textId); + } + if ($this->textPrefix) { + $domElement->setAttribute("textprefix", $this->textPrefix); + } + if ($this->textEmboss) { + $domElement->setAttribute("textemboss", $this->textEmboss); + } + if ($this->translate) { + $domElement->setAttribute("translate", $this->translate); + } + if ($this->opacity != 1.) { + $domElement->setAttribute("opacity", $this->opacity); + } + if ($this->action) { + $domElement->setAttribute("action", $this->action); + } + if ($this->actionKey >= 0) { + $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->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) { + $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) { + $domElement->setAttribute("style", $this->style); + } + if ($this->textSize >= 0) { + $domElement->setAttribute("textsize", $this->textSize); + } + if ($this->textFont) { + $domElement->setAttribute("textfont", $this->textFont); + } + if ($this->textColor) { + $domElement->setAttribute("textcolor", $this->textColor); + } + if ($this->areaColor) { + $domElement->setAttribute("focusareacolor1", $this->areaColor); + } + if ($this->focusAreaColor) { + $domElement->setAttribute("focusareacolor2", $this->focusAreaColor); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if (strlen($this->text) > 0) { - $xmlElement->setAttribute('text', $this->text); - } - if ($this->textId) { - $xmlElement->setAttribute('textid', $this->textId); - } - if ($this->textPrefix) { - $xmlElement->setAttribute('textprefix', $this->textPrefix); - } - if ($this->textEmboss) { - $xmlElement->setAttribute('textemboss', $this->textEmboss); - } - if ($this->translate) { - $xmlElement->setAttribute('translate', $this->translate); - } - if ($this->maxLines >= 0) { - $xmlElement->setAttribute('maxlines', $this->maxLines); - } - if ($this->opacity != 1.) { - $xmlElement->setAttribute('opacity', $this->opacity); - } - if (strlen($this->action) > 0) { - $xmlElement->setAttribute('action', $this->action); - } - if ($this->actionKey >= 0) { - $xmlElement->setAttribute('actionkey', $this->actionKey); - } - if ($this->url) { - $xmlElement->setAttribute('url', $this->url); - } - if ($this->manialink) { - $xmlElement->setAttribute('manialink', $this->manialink); - } - if ($this->autoNewLine) { - $xmlElement->setAttribute('autonewline', $this->autoNewLine); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - if ($this->style) { - $xmlElement->setAttribute('style', $this->style); - } - if ($this->textSize >= 0) { - $xmlElement->setAttribute('textsize', $this->textSize); - } - if ($this->textFont) { - $xmlElement->setAttribute('textfont', $this->textFont); - } - if ($this->textColor) { - $xmlElement->setAttribute('textcolor', $this->textColor); - } - if ($this->focusAreaColor1) { - $xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1); - } - if ($this->focusAreaColor2) { - $xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Labels/Label_Button.php b/libs/FML/Controls/Labels/Label_Button.php index da2da5c8..f97bdbf1 100644 --- a/libs/FML/Controls/Labels/Label_Button.php +++ b/libs/FML/Controls/Labels/Label_Button.php @@ -8,31 +8,34 @@ use FML\Controls\Label; * Label class for button 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 Label_Button extends Label { - /* - * Constants - */ - const STYLE_CardButtonMedium = 'CardButtonMedium'; - const STYLE_CardButtonMediumL = 'CardButtonMediumL'; - const STYLE_CardButtonMediumS = 'CardButtonMediumS'; - const STYLE_CardButtonMediumWide = 'CardButtonMediumWide'; - const STYLE_CardButtonMediumXL = 'CardButtonMediumXL'; - const STYLE_CardButtonMediumXS = 'CardButtonMediumXS'; - const STYLE_CardButtonMediumXXL = 'CardButtonMediumXXL'; - const STYLE_CardButtonMediumXXXL = 'CardButtonMediumXXXL'; - const STYLE_CardButtonSmall = 'CardButtonSmall'; - const STYLE_CardButtonSmallL = 'CardButtonSmallL'; - const STYLE_CardButtonSmallS = 'CardButtonSmallS'; - const STYLE_CardButtonSmallWide = 'CardButtonSmallWide'; - const STYLE_CardButtonSmallXL = 'CardButtonSmallXL'; - const STYLE_CardButtonSmallXS = 'CardButtonSmallXS'; - const STYLE_CardButtonSmallXXL = 'CardButtonSmallXXL'; - const STYLE_CardButtonSmallXXXL = 'CardButtonSmallXXXL'; - const STYLE_CardMain_Quit = 'CardMain_Quit'; - const STYLE_CardMain_Tool = 'CardMain_Tool'; - const STYLE_CardMain_Tool_NoBg = 'CardMain_Tool_NoBg'; - const STYLE_CardMain_Tool_NoBg2 = 'CardMain_Tool_NoBg2'; +class Label_Button extends Label +{ + + /* + * Constants + */ + const STYLE_CardButtonMedium = 'CardButtonMedium'; + const STYLE_CardButtonMediumL = 'CardButtonMediumL'; + const STYLE_CardButtonMediumS = 'CardButtonMediumS'; + const STYLE_CardButtonMediumWide = 'CardButtonMediumWide'; + const STYLE_CardButtonMediumXL = 'CardButtonMediumXL'; + const STYLE_CardButtonMediumXS = 'CardButtonMediumXS'; + const STYLE_CardButtonMediumXXL = 'CardButtonMediumXXL'; + const STYLE_CardButtonMediumXXXL = 'CardButtonMediumXXXL'; + const STYLE_CardButtonSmall = 'CardButtonSmall'; + const STYLE_CardButtonSmallL = 'CardButtonSmallL'; + const STYLE_CardButtonSmallS = 'CardButtonSmallS'; + const STYLE_CardButtonSmallWide = 'CardButtonSmallWide'; + const STYLE_CardButtonSmallXL = 'CardButtonSmallXL'; + const STYLE_CardButtonSmallXS = 'CardButtonSmallXS'; + const STYLE_CardButtonSmallXXL = 'CardButtonSmallXXL'; + const STYLE_CardButtonSmallXXXL = 'CardButtonSmallXXXL'; + const STYLE_CardMain_Quit = 'CardMain_Quit'; + const STYLE_CardMain_Tool = 'CardMain_Tool'; + const STYLE_CardMain_Tool_NoBg = 'CardMain_Tool_NoBg'; + const STYLE_CardMain_Tool_NoBg2 = 'CardMain_Tool_NoBg2'; + } diff --git a/libs/FML/Controls/Labels/Label_Text.php b/libs/FML/Controls/Labels/Label_Text.php index 4ad26344..fedfb7b6 100644 --- a/libs/FML/Controls/Labels/Label_Text.php +++ b/libs/FML/Controls/Labels/Label_Text.php @@ -8,90 +8,93 @@ use FML\Controls\Label; * Label class for text 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 Label_Text extends Label { - /* - * Constants - */ - const STYLE_AvatarButtonNormal = 'AvatarButtonNormal'; - const STYLE_BgMainMenuTitleHeader = 'BgMainMenuTitleHeader'; - const STYLE_Default = 'Default'; - const STYLE_FrameTransitionFromLeft = 'FrameTransitionFromLeft'; - const STYLE_FrameTransitionsFromRight = 'FrameTransitionsFromRight'; - const STYLE_ListItemMedal = 'ListItemMedal'; - const STYLE_Manialink_Body = 'Manialink_Body'; - const STYLE_ProgressBar = 'ProgressBar'; - const STYLE_ProgressBarSmall = 'ProgressBarSmall'; - const STYLE_SliderSmall = 'SliderSmall'; - const STYLE_SliderVolume = 'SliderVolume'; - const STYLE_StyleTextScriptEditor = 'StyleTextScriptEditor'; - const STYLE_StyleValueYellowSmall = 'StyleValueYellowSmall'; - const STYLE_TextActionMaker = 'TextActionMaker'; - const STYLE_TextButtonBig = 'TextButtonBig'; - const STYLE_TextButtonMedium = 'TextButtonMedium'; - const STYLE_TextButtonNav = 'TextButtonNav'; - const STYLE_TextButtonNavBack = 'TextButtonNavBack'; - const STYLE_TextButtonSmall = 'TextButtonSmall'; - const STYLE_TextCardInfoSmall = 'TextCardInfoSmall'; - const STYLE_TextCardInfoVerySmall = 'TextCardInfoVerySmall'; - const STYLE_TextCardMedium = 'TextCardMedium'; - const STYLE_TextCardMediumWhite = 'TextCardMediumWhite'; - const STYLE_TextCardRaceRank = 'TextCardRaceRank'; - const STYLE_TextCardScores2 = 'TextCardScores2'; - const STYLE_TextCardSmall = 'TextCardSmall'; - const STYLE_TextCardSmallScores2 = 'TextCardSmallScores2'; - const STYLE_TextCardSmallScores2Rank = 'TextCardSmallScores2Rank'; - const STYLE_TextChallengeNameMedal = 'TextChallengeNameMedal'; - const STYLE_TextChallengeNameMedalNone = 'TextChallengeNameMedalNone'; - const STYLE_TextChallengeNameMedium = 'TextChallengeNameMedium'; - const STYLE_TextChallengeNameSmall = 'TextChallengeNameSmall'; - const STYLE_TextCongratsBig = 'TextCongratsBig'; - const STYLE_TextCredits = 'TextCredits'; - const STYLE_TextCreditsTitle = 'TextCreditsTitle'; - const STYLE_TextEditorArticle = 'TextEditorArticle'; - const STYLE_TextInfoMedium = 'TextInfoMedium'; - const STYLE_TextInfoSmall = 'TextInfoSmall'; - const STYLE_TextPlayerCardName = 'TextPlayerCardName'; - const STYLE_TextPlayerCardScore = 'TextPlayerCardScore'; - const STYLE_TextRaceChat = 'TextRaceChat'; - const STYLE_TextRaceChrono = 'TextRaceChrono'; - const STYLE_TextRaceChronoError = 'TextRaceChronoError'; - const STYLE_TextRaceChronoOfficial = 'TextRaceChronoOfficial'; - const STYLE_TextRaceChronoWarning = 'TextRaceChronoWarning'; - const STYLE_TextRaceMessage = 'TextRaceMessage'; - const STYLE_TextRaceMessageBig = 'TextRaceMessageBig'; - const STYLE_TextRaceStaticSmall = 'TextRaceStaticSmall'; - const STYLE_TextRaceValueSmall = 'TextRaceValueSmall'; - const STYLE_TextRankingsBig = 'TextRankingsBig'; - const STYLE_TextSPScoreBig = 'TextSPScoreBig'; - const STYLE_TextSPScoreMedium = 'TextSPScoreMedium'; - const STYLE_TextSPScoreSmall = 'TextSPScoreSmall'; - const STYLE_TextStaticMedium = 'TextStaticMedium'; - const STYLE_TextStaticSmall = 'TextStaticSmall'; - const STYLE_TextStaticVerySmall = 'TextStaticVerySmall'; - const STYLE_TextSubTitle1 = 'TextSubTitle1'; - const STYLE_TextSubTitle2 = 'TextSubTitle2'; - const STYLE_TextTips = 'TextTips'; - const STYLE_TextTitle1 = 'TextTitle1'; - const STYLE_TextTitle2 = 'TextTitle2'; - const STYLE_TextTitle2Blink = 'TextTitle2Blink'; - const STYLE_TextTitle3 = 'TextTitle3'; - const STYLE_TextTitle3Header = 'TextTitle3Header'; - const STYLE_TextTitleError = 'TextTitleError'; - const STYLE_TextToolTipAM = 'TextToolTipAM'; - const STYLE_TextToolTipAMBig = 'TextToolTipAMBig'; - const STYLE_TextValueBig = 'TextValueBig'; - const STYLE_TextValueMedium = 'TextValueMedium'; - const STYLE_TextValueMediumSm = 'TextValueMediumSm'; - const STYLE_TextValueSmall = 'TextValueSmall'; - const STYLE_TextValueSmallSm = 'TextValueSmallSm'; - const STYLE_TrackerText = 'TrackerText'; - const STYLE_TrackerTextBig = 'TrackerTextBig'; - const STYLE_TrackListItem = 'TrackListItem'; - const STYLE_TrackListLine = 'TrackListLine'; - const STYLE_UiDriving_BgBottom = 'UiDriving_BgBottom'; - const STYLE_UiDriving_BgCard = 'UiDriving_BgCard'; - const STYLE_UiDriving_BgCenter = 'UiDriving_BgCenter'; +class Label_Text extends Label +{ + + /* + * Constants + */ + const STYLE_AvatarButtonNormal = 'AvatarButtonNormal'; + const STYLE_BgMainMenuTitleHeader = 'BgMainMenuTitleHeader'; + const STYLE_Default = 'Default'; + const STYLE_FrameTransitionFromLeft = 'FrameTransitionFromLeft'; + const STYLE_FrameTransitionsFromRight = 'FrameTransitionsFromRight'; + const STYLE_ListItemMedal = 'ListItemMedal'; + const STYLE_Manialink_Body = 'Manialink_Body'; + const STYLE_ProgressBar = 'ProgressBar'; + const STYLE_ProgressBarSmall = 'ProgressBarSmall'; + const STYLE_SliderSmall = 'SliderSmall'; + const STYLE_SliderVolume = 'SliderVolume'; + const STYLE_StyleTextScriptEditor = 'StyleTextScriptEditor'; + const STYLE_StyleValueYellowSmall = 'StyleValueYellowSmall'; + const STYLE_TextActionMaker = 'TextActionMaker'; + const STYLE_TextButtonBig = 'TextButtonBig'; + const STYLE_TextButtonMedium = 'TextButtonMedium'; + const STYLE_TextButtonNav = 'TextButtonNav'; + const STYLE_TextButtonNavBack = 'TextButtonNavBack'; + const STYLE_TextButtonSmall = 'TextButtonSmall'; + const STYLE_TextCardInfoSmall = 'TextCardInfoSmall'; + const STYLE_TextCardInfoVerySmall = 'TextCardInfoVerySmall'; + const STYLE_TextCardMedium = 'TextCardMedium'; + const STYLE_TextCardMediumWhite = 'TextCardMediumWhite'; + const STYLE_TextCardRaceRank = 'TextCardRaceRank'; + const STYLE_TextCardScores2 = 'TextCardScores2'; + const STYLE_TextCardSmall = 'TextCardSmall'; + const STYLE_TextCardSmallScores2 = 'TextCardSmallScores2'; + const STYLE_TextCardSmallScores2Rank = 'TextCardSmallScores2Rank'; + const STYLE_TextChallengeNameMedal = 'TextChallengeNameMedal'; + const STYLE_TextChallengeNameMedalNone = 'TextChallengeNameMedalNone'; + const STYLE_TextChallengeNameMedium = 'TextChallengeNameMedium'; + const STYLE_TextChallengeNameSmall = 'TextChallengeNameSmall'; + const STYLE_TextCongratsBig = 'TextCongratsBig'; + const STYLE_TextCredits = 'TextCredits'; + const STYLE_TextCreditsTitle = 'TextCreditsTitle'; + const STYLE_TextEditorArticle = 'TextEditorArticle'; + const STYLE_TextInfoMedium = 'TextInfoMedium'; + const STYLE_TextInfoSmall = 'TextInfoSmall'; + const STYLE_TextPlayerCardName = 'TextPlayerCardName'; + const STYLE_TextPlayerCardScore = 'TextPlayerCardScore'; + const STYLE_TextRaceChat = 'TextRaceChat'; + const STYLE_TextRaceChrono = 'TextRaceChrono'; + const STYLE_TextRaceChronoError = 'TextRaceChronoError'; + const STYLE_TextRaceChronoOfficial = 'TextRaceChronoOfficial'; + const STYLE_TextRaceChronoWarning = 'TextRaceChronoWarning'; + const STYLE_TextRaceMessage = 'TextRaceMessage'; + const STYLE_TextRaceMessageBig = 'TextRaceMessageBig'; + const STYLE_TextRaceStaticSmall = 'TextRaceStaticSmall'; + const STYLE_TextRaceValueSmall = 'TextRaceValueSmall'; + const STYLE_TextRankingsBig = 'TextRankingsBig'; + const STYLE_TextSPScoreBig = 'TextSPScoreBig'; + const STYLE_TextSPScoreMedium = 'TextSPScoreMedium'; + const STYLE_TextSPScoreSmall = 'TextSPScoreSmall'; + const STYLE_TextStaticMedium = 'TextStaticMedium'; + const STYLE_TextStaticSmall = 'TextStaticSmall'; + const STYLE_TextStaticVerySmall = 'TextStaticVerySmall'; + const STYLE_TextSubTitle1 = 'TextSubTitle1'; + const STYLE_TextSubTitle2 = 'TextSubTitle2'; + const STYLE_TextTips = 'TextTips'; + const STYLE_TextTitle1 = 'TextTitle1'; + const STYLE_TextTitle2 = 'TextTitle2'; + const STYLE_TextTitle2Blink = 'TextTitle2Blink'; + const STYLE_TextTitle3 = 'TextTitle3'; + const STYLE_TextTitle3Header = 'TextTitle3Header'; + const STYLE_TextTitleError = 'TextTitleError'; + const STYLE_TextToolTipAM = 'TextToolTipAM'; + const STYLE_TextToolTipAMBig = 'TextToolTipAMBig'; + const STYLE_TextValueBig = 'TextValueBig'; + const STYLE_TextValueMedium = 'TextValueMedium'; + const STYLE_TextValueMediumSm = 'TextValueMediumSm'; + const STYLE_TextValueSmall = 'TextValueSmall'; + const STYLE_TextValueSmallSm = 'TextValueSmallSm'; + const STYLE_TrackerText = 'TrackerText'; + const STYLE_TrackerTextBig = 'TrackerTextBig'; + const STYLE_TrackListItem = 'TrackListItem'; + const STYLE_TrackListLine = 'TrackListLine'; + const STYLE_UiDriving_BgBottom = 'UiDriving_BgBottom'; + const STYLE_UiDriving_BgCard = 'UiDriving_BgCard'; + const STYLE_UiDriving_BgCenter = 'UiDriving_BgCenter'; + } diff --git a/libs/FML/Controls/Quad.php b/libs/FML/Controls/Quad.php index f263f711..9064201f 100644 --- a/libs/FML/Controls/Quad.php +++ b/libs/FML/Controls/Quad.php @@ -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 - * @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 { - /* - * Constants - */ - const KEEP_RATIO_INACTIVE = 'inactive'; - const KEEP_RATIO_CLIP = 'Clip'; - const KEEP_RATIO_FIT = 'Fit'; +class Quad extends Control implements Actionable, BackgroundColorable, Imageable, Linkable, Scriptable, Styleable, SubStyleable +{ - /* - * 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; + /* + * Constants + */ + const KEEP_RATIO_INACTIVE = "inactive"; + const KEEP_RATIO_CLIP = "Clip"; + const KEEP_RATIO_FIT = "Fit"; - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlQuad'; - } + /** + * @var string $imageUrl Image url + */ + protected $imageUrl = null; - /** - * Set image url - * - * @param string $image Image url - * @return static - */ - public function setImage($image) { - $this->image = (string)$image; - return $this; - } + /** + * @var string $imageId Image ID + */ + protected $imageId = null; - /** - * Set image id to use from Dico - * - * @param string $imageId Image id - * @return static - */ - public function setImageId($imageId) { - $this->imageId = (string)$imageId; - return $this; - } + /** + * @var string $imageFocusUrl Focus image url + */ + protected $imageFocusUrl = null; - /** - * Set focus image url - * - * @param string $imageFocus Focus image url - * @return static - */ - public function setImageFocus($imageFocus) { - $this->imageFocus = (string)$imageFocus; - return $this; - } + /** + * @var string $imageFocusId Focus image ID + */ + protected $imageFocusId = null; - /** - * Set focus image id to use from Dico - * - * @param string $imageFocusId Focus image id - * @return static - */ - public function setImageFocusId($imageFocusId) { - $this->imageFocusId = (string)$imageFocusId; - return $this; - } + /** + * @var string $colorize Colorize value + */ + protected $colorize = null; - /** - * Set colorization - * - * @param string $colorize Colorize value - * @return static - */ - public function setColorize($colorize) { - $this->colorize = (string)$colorize; - return $this; - } + /** + * @var string $modulizeColor Modulization color + */ + protected $modulizeColor = null; - /** - * Set modulization - * - * @param string $modulizeColor Modulize value - * @return static - */ - public function setModulizeColor($modulizeColor) { - $this->modulizeColor = (string)$modulizeColor; - return $this; - } + /** + * @var bool $autoScale Automatic scaling + */ + protected $autoScale = true; - /** - * Disable the automatic image scaling - * - * @param bool $autoScale Whether the image should scale automatically - * @return static - */ - public function setAutoScale($autoScale) { - $this->autoScale = ($autoScale ? 1 : 0); - return $this; - } + /** + * @var float $autoScaleFixedWidth Fixed width for automatic scaling + */ + protected $autoScaleFixedWidth = -1.; - /** - * Set Keep Ratio Mode - * - * @param string $keepRatio Keep Ratio Mode - * @return static - */ - public function setKeepRatio($keepRatio) { - $this->keepRatio = (string)$keepRatio; - return $this; - } + /** + * @var string $keepRatio Keep ratio mode + */ + protected $keepRatio = null; - /** - * @see \FML\Types\Actionable::getAction() - */ - public function getAction() { - return $this->action; - } + /** + * @var float $opacity Opacity + */ + protected $opacity = 1.; - /** - * @see \FML\Types\Actionable::setAction() - */ - public function setAction($action) { - $this->action = (string)$action; - return $this; - } + /** + * @var string $backgroundColor Background color + */ + protected $backgroundColor = null; - /** - * @see \FML\Types\Actionable::setActionKey() - */ - public function setActionKey($actionKey) { - $this->actionKey = (int)$actionKey; - return $this; - } + /** + * @var string $action Action name + */ + protected $action = null; - /** - * @see \FML\Types\BgColorable::setBgColor() - */ - public function setBgColor($bgColor) { - $this->bgColor = (string)$bgColor; - return $this; - } + /** + * @var int $actionKey Action key + */ + protected $actionKey = -1; - /** - * @see \FML\Types\Linkable::setUrl() - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * @var string $url Link url + */ + protected $url = null; - /** - * @see \FML\Types\Linkable::setUrlId() - */ - public function setUrlId($urlId) { - $this->urlId = (string)$urlId; - return $this; - } + /** + * @var string $urlId Link url ID + */ + protected $urlId = null; - /** - * @see \FML\Types\Linkable::setManialink() - */ - public function setManialink($manialink) { - $this->manialink = (string)$manialink; - return $this; - } + /** + * @var string $manialink Manialink + */ + protected $manialink = null; - /** - * @see \FML\Types\Linkable::setManialinkId() - */ - public function setManialinkId($manialinkId) { - $this->manialinkId = (string)$manialinkId; - return $this; - } + /** + * @var string $manialinkId Manialink ID + */ + protected $manialinkId = null; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; - /** - * @see \FML\Types\SubStyleable::setStyles() - */ - public function setStyles($style, $subStyle) { - $this->setStyle($style); - $this->setSubStyle($subStyle); - return $this; - } + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - return $this; - } + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; - /** - * @see \FML\Types\SubStyleable::setSubStyle() - */ - public function setSubStyle($subStyle) { - $this->subStyle = (string)$subStyle; - return $this; - } + /** + * @var string $style Style + */ + protected $style = null; - /** - * Set selected mode - * - * @param bool $styleSelected - * @return static - */ - public function setStyleSelected($styleSelected) { - $this->styleSelected = ($styleSelected ? 1 : 0); - return $this; - } + /** + * @var string $subStyle SubStyle + */ + protected $subStyle = null; - /** - * Set opacity - * - * @param float $opacity - * @return static - */ - public function setOpacity($opacity) { - $this->opacity = (float)$opacity; - return $this; - } + /** + * @var bool $styleSelected Style selected + */ + protected $styleSelected = null; - /** - * Apply the given CheckBox Design - * - * @param CheckBoxDesign $checkBoxDesign CheckBox Design - * @return static - */ - public function applyCheckBoxDesign(CheckBoxDesign $checkBoxDesign) { - $checkBoxDesign->applyToQuad($this); - return $this; - } + /** + * @see Imageable::getImageUrl() + */ + public function getImageUrl() + { + return $this->imageUrl; + } + + /** + * @deprecated use setImageUrl() instead + */ + public function setImage($imageUrl) + { + return $this->setImageUrl($imageUrl); + } + + /** + * @see Imageable::setImageUrl() + */ + public function setImageUrl($imageUrl) + { + $this->imageUrl = (string)$imageUrl; + return $this; + } + + /** + * 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) + { + $this->imageId = (string)$imageId; + return $this; + } + + /** + * Get the 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 setImageFocusUrl($imageFocusUrl) + { + $this->imageFocusUrl = (string)$imageFocusUrl; + return $this; + } + + /** + * 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) + { + $this->imageFocusId = (string)$imageFocusId; + return $this; + } + + /** + * 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) + { + $this->colorize = (string)$colorize; + return $this; + } + + /** + * Get the modulization color + * + * @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) + { + $this->modulizeColor = (string)$modulizeColor; + return $this; + } + + /** + * Get the automatic image scaling + * + * @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 = (bool)$autoScale; + return $this; + } + + /** + * Get the fixed width for automatic image scaling + * + * @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 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; + } + + /** + * Get the opacity + * + * @api + * @return float + */ + public function getOpacity() + { + return $this->opacity; + } + + /** + * Set the opacity + * + * @api + * @param float $opacity Opacity value + * @return static + */ + public function setOpacity($opacity) + { + $this->opacity = (float)$opacity; + return $this; + } + + /** + * @see BackgroundColorable::getBackgroundColor() + */ + public function getBackgroundColor() + { + return $this->backgroundColor; + } + + /** + * @see BackgroundColorable::setBgColor() + */ + public function setBackgroundColor($backgroundColor) + { + $this->backgroundColor = (string)$backgroundColor; + return $this; + } + + /** + * @see Actionable::getAction() + */ + 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) { + $domElement->setAttribute("imageid", $this->imageId); + } + if ($this->imageFocusUrl) { + $domElement->setAttribute("imagefocus", $this->imageFocusUrl); + } + if ($this->imageFocusId) { + $domElement->setAttribute("imagefocusid", $this->imageFocusId); + } + if ($this->colorize) { + $domElement->setAttribute("colorize", $this->colorize); + } + if ($this->modulizeColor) { + $domElement->setAttribute("modulizecolor", $this->modulizeColor); + } + if (!$this->autoScale) { + $domElement->setAttribute("autoscale", 0); + } + if ($this->autoScaleFixedWidth > 0.) { + $domElement->setAttribute("autoscalefixedWidth", $this->autoScaleFixedWidth); + } + if ($this->keepRatio) { + $domElement->setAttribute("keepratio", $this->keepRatio); + } + if ($this->opacity !== 1.) { + $domElement->setAttribute("opacity", $this->opacity); + } + 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; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->image) { - $xmlElement->setAttribute('image', $this->image); - } - if ($this->imageId) { - $xmlElement->setAttribute('imageid', $this->imageId); - } - if ($this->imageFocus) { - $xmlElement->setAttribute('imagefocus', $this->imageFocus); - } - if ($this->imageFocusId) { - $xmlElement->setAttribute('imagefocusid', $this->imageFocusId); - } - if ($this->colorize) { - $xmlElement->setAttribute('colorize', $this->colorize); - } - if ($this->modulizeColor) { - $xmlElement->setAttribute('modulizecolor', $this->modulizeColor); - } - if (!$this->autoScale) { - $xmlElement->setAttribute('autoscale', $this->autoScale); - } - 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); - } - if ($this->opacity !== 1.) { - $xmlElement->setAttribute('opacity', $this->opacity); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Quads/Quad_321Go.php b/libs/FML/Controls/Quads/Quad_321Go.php index d4525e20..81f6aaef 100644 --- a/libs/FML/Controls/Quads/Quad_321Go.php +++ b/libs/FML/Controls/Quads/Quad_321Go.php @@ -8,21 +8,24 @@ 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 { - /* - * Constants - */ - const STYLE = '321Go'; - const SUBSTYLE_3 = '3'; - const SUBSTYLE_2 = '2'; - const SUBSTYLE_1 = '1'; - const SUBSTYLE_Go = 'Go!'; +class Quad_321Go extends Quad +{ + + /* + * Constants + */ + const STYLE = '321Go'; + const SUBSTYLE_3 = '3'; + const SUBSTYLE_2 = '2'; + const SUBSTYLE_1 = '1'; + const SUBSTYLE_Go = 'Go!'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_BgRaceScore2.php b/libs/FML/Controls/Quads/Quad_BgRaceScore2.php index c0db325e..82f0d21d 100644 --- a/libs/FML/Controls/Quads/Quad_BgRaceScore2.php +++ b/libs/FML/Controls/Quads/Quad_BgRaceScore2.php @@ -8,44 +8,47 @@ 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 { - /* - * Constants - */ - const STYLE = 'BgRaceScore2'; - const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; - const SUBSTYLE_BgCardServer = 'BgCardServer'; - const SUBSTYLE_BgScores = 'BgScores'; - const SUBSTYLE_Cartouche = 'Cartouche'; - const SUBSTYLE_CartoucheLine = 'CartoucheLine'; - const SUBSTYLE_CupFinisher = 'CupFinisher'; - const SUBSTYLE_CupPotentialFinisher = 'CupPotentialFinisher'; - const SUBSTYLE_Fame = 'Fame'; - const SUBSTYLE_Handle = 'Handle'; - const SUBSTYLE_HandleBlue = 'HandleBlue'; - const SUBSTYLE_HandleRed = 'HandleRed'; - const SUBSTYLE_HandleSelectable = 'HandleSelectable'; - const SUBSTYLE_IsLadderDisabled = 'IsLadderDisabled'; - const SUBSTYLE_IsLocalPlayer = 'IsLocalPlayer'; - const SUBSTYLE_LadderPoints = 'LadderPoints'; - const SUBSTYLE_LadderRank = 'LadderRank'; - const SUBSTYLE_Laps = 'Laps'; - const SUBSTYLE_Podium = 'Podium'; - const SUBSTYLE_Points = 'Points'; - const SUBSTYLE_SandTimer = 'SandTimer'; - const SUBSTYLE_ScoreLink = 'ScoreLink'; - const SUBSTYLE_ScoreReplay = 'ScoreReplay'; - const SUBSTYLE_SendScore = 'SendScore'; - const SUBSTYLE_Speaking = 'Speaking'; - const SUBSTYLE_Spectator = 'Spectator'; - const SUBSTYLE_Tv = 'Tv'; - const SUBSTYLE_Warmup = 'Warmup'; +class Quad_BgRaceScore2 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'BgRaceScore2'; + const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; + const SUBSTYLE_BgCardServer = 'BgCardServer'; + const SUBSTYLE_BgScores = 'BgScores'; + const SUBSTYLE_Cartouche = 'Cartouche'; + const SUBSTYLE_CartoucheLine = 'CartoucheLine'; + const SUBSTYLE_CupFinisher = 'CupFinisher'; + const SUBSTYLE_CupPotentialFinisher = 'CupPotentialFinisher'; + const SUBSTYLE_Fame = 'Fame'; + const SUBSTYLE_Handle = 'Handle'; + const SUBSTYLE_HandleBlue = 'HandleBlue'; + const SUBSTYLE_HandleRed = 'HandleRed'; + const SUBSTYLE_HandleSelectable = 'HandleSelectable'; + const SUBSTYLE_IsLadderDisabled = 'IsLadderDisabled'; + const SUBSTYLE_IsLocalPlayer = 'IsLocalPlayer'; + const SUBSTYLE_LadderPoints = 'LadderPoints'; + const SUBSTYLE_LadderRank = 'LadderRank'; + const SUBSTYLE_Laps = 'Laps'; + const SUBSTYLE_Podium = 'Podium'; + const SUBSTYLE_Points = 'Points'; + const SUBSTYLE_SandTimer = 'SandTimer'; + const SUBSTYLE_ScoreLink = 'ScoreLink'; + const SUBSTYLE_ScoreReplay = 'ScoreReplay'; + const SUBSTYLE_SendScore = 'SendScore'; + const SUBSTYLE_Speaking = 'Speaking'; + const SUBSTYLE_Spectator = 'Spectator'; + const SUBSTYLE_Tv = 'Tv'; + const SUBSTYLE_Warmup = 'Warmup'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Bgs1.php b/libs/FML/Controls/Quads/Quad_Bgs1.php index 7e03f281..5edba09d 100644 --- a/libs/FML/Controls/Quads/Quad_Bgs1.php +++ b/libs/FML/Controls/Quads/Quad_Bgs1.php @@ -8,86 +8,89 @@ 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 { - /* - * Constants - */ - const STYLE = 'Bgs1'; - const SUBSTYLE_ArrowDown = 'ArrowDown'; - const SUBSTYLE_ArrowLeft = 'ArrowLeft'; - const SUBSTYLE_ArrowRight = 'ArrowRight'; - const SUBSTYLE_ArrowUp = 'ArrowUp'; - const SUBSTYLE_BgButton = 'BgButton'; - const SUBSTYLE_BgButtonBig = 'BgButtonBig'; - const SUBSTYLE_BgButtonGlow = 'BgButtonGlow'; - const SUBSTYLE_BgButtonGrayed = 'BgButtonGrayed'; - const SUBSTYLE_BgButtonOff = 'BgButtonOff'; - const SUBSTYLE_BgButtonShadow = 'BgButtonShadow'; - const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; - const SUBSTYLE_BgCard = 'BgCard'; - const SUBSTYLE_BgCard1 = 'BgCard1'; - const SUBSTYLE_BgCard2 = 'BgCard2'; - const SUBSTYLE_BgCard3 = 'BgCard3'; - const SUBSTYLE_BgCardBuddy = 'BgCardBuddy'; - const SUBSTYLE_BgCardChallenge = 'BgCardChallenge'; - const SUBSTYLE_BgCardFolder = 'BgCardFolder'; - const SUBSTYLE_BgCardInventoryItem = 'BgCardInventoryItem'; - const SUBSTYLE_BgCardList = 'BgCardList'; - const SUBSTYLE_BgCardOnline = 'BgCardOnline'; - const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; - const SUBSTYLE_BgCardProperty = 'BgCardProperty'; - const SUBSTYLE_BgCardSystem = 'BgCardSystem'; - const SUBSTYLE_BgCardZone = 'BgCardZone'; - const SUBSTYLE_BgColorContour = 'BgColorContour'; - const SUBSTYLE_BgDialogBlur = 'BgDialogBlur'; - const SUBSTYLE_BgEmpty = 'BgEmpty'; - const SUBSTYLE_BgGlow2 = 'BgGlow2'; - const SUBSTYLE_BgGradBottom = 'BgGradBottom'; - const SUBSTYLE_BgGradLeft = 'BgGradLeft'; - const SUBSTYLE_BgGradRight = 'BgGradRight'; - const SUBSTYLE_BgGradTop = 'BgGradTop'; - const SUBSTYLE_BgGradV = 'BgGradV'; - const SUBSTYLE_BgHealthBar = 'BgHealthBar'; - const SUBSTYLE_BgIconBorder = 'BgIconBorder'; - const SUBSTYLE_BgList = 'BgList'; - const SUBSTYLE_BgListLine = 'BgListLine'; - const SUBSTYLE_BgMetalBar = 'BgMetalBar'; - const SUBSTYLE_BgPager = 'BgPager'; - const SUBSTYLE_BgProgressBar = 'BgProgressBar'; - const SUBSTYLE_BgShadow = 'BgShadow'; - const SUBSTYLE_BgSlider = 'BgSlider'; - const SUBSTYLE_BgSystemBar = 'BgSystemBar'; - const SUBSTYLE_BgTitle = 'BgTitle'; - const SUBSTYLE_BgTitle2 = 'BgTitle2'; - const SUBSTYLE_BgTitle3 = 'BgTitle3'; - const SUBSTYLE_BgTitle3_1 = 'BgTitle3_1'; - const SUBSTYLE_BgTitle3_2 = 'BgTitle3_2'; - const SUBSTYLE_BgTitle3_3 = 'BgTitle3_3'; - const SUBSTYLE_BgTitle3_4 = 'BgTitle3_4'; - const SUBSTYLE_BgTitle3_5 = 'BgTitle3_5'; - const SUBSTYLE_BgTitleGlow = 'BgTitleGlow'; - const SUBSTYLE_BgTitlePage = 'BgTitlePage'; - const SUBSTYLE_BgTitleShadow = 'BgTitleShadow'; - const SUBSTYLE_BgWindow1 = 'BgWindow1'; - const SUBSTYLE_BgWindow2 = 'BgWindow2'; - const SUBSTYLE_BgWindow3 = 'BgWindow3'; - const SUBSTYLE_BgWindow4 = 'BgWindow4'; - const SUBSTYLE_EnergyBar = 'EnergyBar'; - const SUBSTYLE_EnergyTeam2 = 'EnergyTeam2'; - const SUBSTYLE_Glow = 'Glow'; - const SUBSTYLE_HealthBar = 'HealthBar'; - const SUBSTYLE_NavButton = 'NavButton'; - const SUBSTYLE_NavButtonBlink = 'NavButtonBlink'; - const SUBSTYLE_NavButtonQuit = 'NavButtonQuit'; - const SUBSTYLE_ProgressBar = 'ProgressBar'; - const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall'; - const SUBSTYLE_Shadow = 'Shadow'; +class Quad_Bgs1 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Bgs1'; + const SUBSTYLE_ArrowDown = 'ArrowDown'; + const SUBSTYLE_ArrowLeft = 'ArrowLeft'; + const SUBSTYLE_ArrowRight = 'ArrowRight'; + const SUBSTYLE_ArrowUp = 'ArrowUp'; + const SUBSTYLE_BgButton = 'BgButton'; + const SUBSTYLE_BgButtonBig = 'BgButtonBig'; + const SUBSTYLE_BgButtonGlow = 'BgButtonGlow'; + const SUBSTYLE_BgButtonGrayed = 'BgButtonGrayed'; + const SUBSTYLE_BgButtonOff = 'BgButtonOff'; + const SUBSTYLE_BgButtonShadow = 'BgButtonShadow'; + const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; + const SUBSTYLE_BgCard = 'BgCard'; + const SUBSTYLE_BgCard1 = 'BgCard1'; + const SUBSTYLE_BgCard2 = 'BgCard2'; + const SUBSTYLE_BgCard3 = 'BgCard3'; + const SUBSTYLE_BgCardBuddy = 'BgCardBuddy'; + const SUBSTYLE_BgCardChallenge = 'BgCardChallenge'; + const SUBSTYLE_BgCardFolder = 'BgCardFolder'; + const SUBSTYLE_BgCardInventoryItem = 'BgCardInventoryItem'; + const SUBSTYLE_BgCardList = 'BgCardList'; + const SUBSTYLE_BgCardOnline = 'BgCardOnline'; + const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; + const SUBSTYLE_BgCardProperty = 'BgCardProperty'; + const SUBSTYLE_BgCardSystem = 'BgCardSystem'; + const SUBSTYLE_BgCardZone = 'BgCardZone'; + const SUBSTYLE_BgColorContour = 'BgColorContour'; + const SUBSTYLE_BgDialogBlur = 'BgDialogBlur'; + const SUBSTYLE_BgEmpty = 'BgEmpty'; + const SUBSTYLE_BgGlow2 = 'BgGlow2'; + const SUBSTYLE_BgGradBottom = 'BgGradBottom'; + const SUBSTYLE_BgGradLeft = 'BgGradLeft'; + const SUBSTYLE_BgGradRight = 'BgGradRight'; + const SUBSTYLE_BgGradTop = 'BgGradTop'; + const SUBSTYLE_BgGradV = 'BgGradV'; + const SUBSTYLE_BgHealthBar = 'BgHealthBar'; + const SUBSTYLE_BgIconBorder = 'BgIconBorder'; + const SUBSTYLE_BgList = 'BgList'; + const SUBSTYLE_BgListLine = 'BgListLine'; + const SUBSTYLE_BgMetalBar = 'BgMetalBar'; + const SUBSTYLE_BgPager = 'BgPager'; + const SUBSTYLE_BgProgressBar = 'BgProgressBar'; + const SUBSTYLE_BgShadow = 'BgShadow'; + const SUBSTYLE_BgSlider = 'BgSlider'; + const SUBSTYLE_BgSystemBar = 'BgSystemBar'; + const SUBSTYLE_BgTitle = 'BgTitle'; + const SUBSTYLE_BgTitle2 = 'BgTitle2'; + const SUBSTYLE_BgTitle3 = 'BgTitle3'; + const SUBSTYLE_BgTitle3_1 = 'BgTitle3_1'; + const SUBSTYLE_BgTitle3_2 = 'BgTitle3_2'; + const SUBSTYLE_BgTitle3_3 = 'BgTitle3_3'; + const SUBSTYLE_BgTitle3_4 = 'BgTitle3_4'; + const SUBSTYLE_BgTitle3_5 = 'BgTitle3_5'; + const SUBSTYLE_BgTitleGlow = 'BgTitleGlow'; + const SUBSTYLE_BgTitlePage = 'BgTitlePage'; + const SUBSTYLE_BgTitleShadow = 'BgTitleShadow'; + const SUBSTYLE_BgWindow1 = 'BgWindow1'; + const SUBSTYLE_BgWindow2 = 'BgWindow2'; + const SUBSTYLE_BgWindow3 = 'BgWindow3'; + const SUBSTYLE_BgWindow4 = 'BgWindow4'; + const SUBSTYLE_EnergyBar = 'EnergyBar'; + const SUBSTYLE_EnergyTeam2 = 'EnergyTeam2'; + const SUBSTYLE_Glow = 'Glow'; + const SUBSTYLE_HealthBar = 'HealthBar'; + const SUBSTYLE_NavButton = 'NavButton'; + const SUBSTYLE_NavButtonBlink = 'NavButtonBlink'; + const SUBSTYLE_NavButtonQuit = 'NavButtonQuit'; + const SUBSTYLE_ProgressBar = 'ProgressBar'; + const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall'; + const SUBSTYLE_Shadow = 'Shadow'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Bgs1InRace.php b/libs/FML/Controls/Quads/Quad_Bgs1InRace.php index 5081d706..a1c0a2ba 100644 --- a/libs/FML/Controls/Quads/Quad_Bgs1InRace.php +++ b/libs/FML/Controls/Quads/Quad_Bgs1InRace.php @@ -8,86 +8,89 @@ 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 { - /* - * Constants - */ - const STYLE = 'Bgs1InRace'; - const SUBSTYLE_ArrowDown = 'ArrowDown'; - const SUBSTYLE_ArrowLeft = 'ArrowLeft'; - const SUBSTYLE_ArrowRight = 'ArrowRight'; - const SUBSTYLE_ArrowUp = 'ArrowUp'; - const SUBSTYLE_BgButton = 'BgButton'; - const SUBSTYLE_BgButtonBig = 'BgButtonBig'; - const SUBSTYLE_BgButtonGlow = 'BgButtonGlow'; - const SUBSTYLE_BgButtonGrayed = 'BgButtonGrayed'; - const SUBSTYLE_BgButtonOff = 'BgButtonOff'; - const SUBSTYLE_BgButtonShadow = 'BgButtonShadow'; - const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; - const SUBSTYLE_BgCard = 'BgCard'; - const SUBSTYLE_BgCard1 = 'BgCard1'; - const SUBSTYLE_BgCard2 = 'BgCard2'; - const SUBSTYLE_BgCard3 = 'BgCard3'; - const SUBSTYLE_BgCardBuddy = 'BgCardBuddy'; - const SUBSTYLE_BgCardChallenge = 'BgCardChallenge'; - const SUBSTYLE_BgCardFolder = 'BgCardFolder'; - const SUBSTYLE_BgCardInventoryItem = 'BgCardInventoryItem'; - const SUBSTYLE_BgCardList = 'BgCardList'; - const SUBSTYLE_BgCardOnline = 'BgCardOnline'; - const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; - const SUBSTYLE_BgCardProperty = 'BgCardProperty'; - const SUBSTYLE_BgCardSystem = 'BgCardSystem'; - const SUBSTYLE_BgCardZone = 'BgCardZone'; - const SUBSTYLE_BgColorContour = 'BgColorContour'; - const SUBSTYLE_BgDialogBlur = 'BgDialogBlur'; - const SUBSTYLE_BgEmpty = 'BgEmpty'; - const SUBSTYLE_BgGlow2 = 'BgGlow2'; - const SUBSTYLE_BgGradBottom = 'BgGradBottom'; - const SUBSTYLE_BgGradLeft = 'BgGradLeft'; - const SUBSTYLE_BgGradRight = 'BgGradRight'; - const SUBSTYLE_BgGradTop = 'BgGradTop'; - const SUBSTYLE_BgGradV = 'BgGradV'; - const SUBSTYLE_BgHealthBar = 'BgHealthBar'; - const SUBSTYLE_BgIconBorder = 'BgIconBorder'; - const SUBSTYLE_BgList = 'BgList'; - const SUBSTYLE_BgListLine = 'BgListLine'; - const SUBSTYLE_BgMetalBar = 'BgMetalBar'; - const SUBSTYLE_BgPager = 'BgPager'; - const SUBSTYLE_BgProgressBar = 'BgProgressBar'; - const SUBSTYLE_BgShadow = 'BgShadow'; - const SUBSTYLE_BgSlider = 'BgSlider'; - const SUBSTYLE_BgSystemBar = 'BgSystemBar'; - const SUBSTYLE_BgTitle = 'BgTitle'; - const SUBSTYLE_BgTitle2 = 'BgTitle2'; - const SUBSTYLE_BgTitle3 = 'BgTitle3'; - const SUBSTYLE_BgTitle3_1 = 'BgTitle3_1'; - const SUBSTYLE_BgTitle3_2 = 'BgTitle3_2'; - const SUBSTYLE_BgTitle3_3 = 'BgTitle3_3'; - const SUBSTYLE_BgTitle3_4 = 'BgTitle3_4'; - const SUBSTYLE_BgTitle3_5 = 'BgTitle3_5'; - const SUBSTYLE_BgTitleGlow = 'BgTitleGlow'; - const SUBSTYLE_BgTitlePage = 'BgTitlePage'; - const SUBSTYLE_BgTitleShadow = 'BgTitleShadow'; - const SUBSTYLE_BgWindow1 = 'BgWindow1'; - const SUBSTYLE_BgWindow2 = 'BgWindow2'; - const SUBSTYLE_BgWindow3 = 'BgWindow3'; - const SUBSTYLE_BgWindow4 = 'BgWindow4'; - const SUBSTYLE_EnergyBar = 'EnergyBar'; - const SUBSTYLE_EnergyTeam2 = 'EnergyTeam2'; - const SUBSTYLE_Glow = 'Glow'; - const SUBSTYLE_HealthBar = 'HealthBar'; - const SUBSTYLE_NavButton = 'NavButton'; - const SUBSTYLE_NavButtonBlink = 'NavButtonBlink'; - const SUBSTYLE_NavButtonQuit = 'NavButtonQuit'; - const SUBSTYLE_ProgressBar = 'ProgressBar'; - const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall'; - const SUBSTYLE_Shadow = 'Shadow'; +class Quad_Bgs1InRace extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Bgs1InRace'; + const SUBSTYLE_ArrowDown = 'ArrowDown'; + const SUBSTYLE_ArrowLeft = 'ArrowLeft'; + const SUBSTYLE_ArrowRight = 'ArrowRight'; + const SUBSTYLE_ArrowUp = 'ArrowUp'; + const SUBSTYLE_BgButton = 'BgButton'; + const SUBSTYLE_BgButtonBig = 'BgButtonBig'; + const SUBSTYLE_BgButtonGlow = 'BgButtonGlow'; + const SUBSTYLE_BgButtonGrayed = 'BgButtonGrayed'; + const SUBSTYLE_BgButtonOff = 'BgButtonOff'; + const SUBSTYLE_BgButtonShadow = 'BgButtonShadow'; + const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; + const SUBSTYLE_BgCard = 'BgCard'; + const SUBSTYLE_BgCard1 = 'BgCard1'; + const SUBSTYLE_BgCard2 = 'BgCard2'; + const SUBSTYLE_BgCard3 = 'BgCard3'; + const SUBSTYLE_BgCardBuddy = 'BgCardBuddy'; + const SUBSTYLE_BgCardChallenge = 'BgCardChallenge'; + const SUBSTYLE_BgCardFolder = 'BgCardFolder'; + const SUBSTYLE_BgCardInventoryItem = 'BgCardInventoryItem'; + const SUBSTYLE_BgCardList = 'BgCardList'; + const SUBSTYLE_BgCardOnline = 'BgCardOnline'; + const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; + const SUBSTYLE_BgCardProperty = 'BgCardProperty'; + const SUBSTYLE_BgCardSystem = 'BgCardSystem'; + const SUBSTYLE_BgCardZone = 'BgCardZone'; + const SUBSTYLE_BgColorContour = 'BgColorContour'; + const SUBSTYLE_BgDialogBlur = 'BgDialogBlur'; + const SUBSTYLE_BgEmpty = 'BgEmpty'; + const SUBSTYLE_BgGlow2 = 'BgGlow2'; + const SUBSTYLE_BgGradBottom = 'BgGradBottom'; + const SUBSTYLE_BgGradLeft = 'BgGradLeft'; + const SUBSTYLE_BgGradRight = 'BgGradRight'; + const SUBSTYLE_BgGradTop = 'BgGradTop'; + const SUBSTYLE_BgGradV = 'BgGradV'; + const SUBSTYLE_BgHealthBar = 'BgHealthBar'; + const SUBSTYLE_BgIconBorder = 'BgIconBorder'; + const SUBSTYLE_BgList = 'BgList'; + const SUBSTYLE_BgListLine = 'BgListLine'; + const SUBSTYLE_BgMetalBar = 'BgMetalBar'; + const SUBSTYLE_BgPager = 'BgPager'; + const SUBSTYLE_BgProgressBar = 'BgProgressBar'; + const SUBSTYLE_BgShadow = 'BgShadow'; + const SUBSTYLE_BgSlider = 'BgSlider'; + const SUBSTYLE_BgSystemBar = 'BgSystemBar'; + const SUBSTYLE_BgTitle = 'BgTitle'; + const SUBSTYLE_BgTitle2 = 'BgTitle2'; + const SUBSTYLE_BgTitle3 = 'BgTitle3'; + const SUBSTYLE_BgTitle3_1 = 'BgTitle3_1'; + const SUBSTYLE_BgTitle3_2 = 'BgTitle3_2'; + const SUBSTYLE_BgTitle3_3 = 'BgTitle3_3'; + const SUBSTYLE_BgTitle3_4 = 'BgTitle3_4'; + const SUBSTYLE_BgTitle3_5 = 'BgTitle3_5'; + const SUBSTYLE_BgTitleGlow = 'BgTitleGlow'; + const SUBSTYLE_BgTitlePage = 'BgTitlePage'; + const SUBSTYLE_BgTitleShadow = 'BgTitleShadow'; + const SUBSTYLE_BgWindow1 = 'BgWindow1'; + const SUBSTYLE_BgWindow2 = 'BgWindow2'; + const SUBSTYLE_BgWindow3 = 'BgWindow3'; + const SUBSTYLE_BgWindow4 = 'BgWindow4'; + const SUBSTYLE_EnergyBar = 'EnergyBar'; + const SUBSTYLE_EnergyTeam2 = 'EnergyTeam2'; + const SUBSTYLE_Glow = 'Glow'; + const SUBSTYLE_HealthBar = 'HealthBar'; + const SUBSTYLE_NavButton = 'NavButton'; + const SUBSTYLE_NavButtonBlink = 'NavButtonBlink'; + const SUBSTYLE_NavButtonQuit = 'NavButtonQuit'; + const SUBSTYLE_ProgressBar = 'ProgressBar'; + const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall'; + const SUBSTYLE_Shadow = 'Shadow'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_BgsButtons.php b/libs/FML/Controls/Quads/Quad_BgsButtons.php index 95edb26f..0d184f83 100644 --- a/libs/FML/Controls/Quads/Quad_BgsButtons.php +++ b/libs/FML/Controls/Quads/Quad_BgsButtons.php @@ -8,24 +8,27 @@ 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 { - /* - * Constants - */ - const STYLE = 'BgsButtons'; - const SUBSTYLE_BgButtonLarge = 'BgButtonLarge'; - const SUBSTYLE_BgButtonMedium = 'BgButtonMedium'; - const SUBSTYLE_BgButtonMediumSelector = 'BgButtonMediumSelector'; - const SUBSTYLE_BgButtonMediumSpecial = 'BgButtonMediumSpecial'; - const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; - const SUBSTYLE_BgButtonSmall2 = 'BgButtonSmall2'; - const SUBSTYLE_BgButtonXSmall = 'BgButtonXSmall'; +class Quad_BgsButtons extends Quad +{ + + /* + * Constants + */ + const STYLE = 'BgsButtons'; + const SUBSTYLE_BgButtonLarge = 'BgButtonLarge'; + const SUBSTYLE_BgButtonMedium = 'BgButtonMedium'; + const SUBSTYLE_BgButtonMediumSelector = 'BgButtonMediumSelector'; + const SUBSTYLE_BgButtonMediumSpecial = 'BgButtonMediumSpecial'; + const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; + const SUBSTYLE_BgButtonSmall2 = 'BgButtonSmall2'; + const SUBSTYLE_BgButtonXSmall = 'BgButtonXSmall'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_BgsChallengeMedals.php b/libs/FML/Controls/Quads/Quad_BgsChallengeMedals.php index b0c9800c..2b462799 100644 --- a/libs/FML/Controls/Quads/Quad_BgsChallengeMedals.php +++ b/libs/FML/Controls/Quads/Quad_BgsChallengeMedals.php @@ -8,23 +8,26 @@ 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 { - /* - * Constants - */ - const STYLE = 'BgsChallengeMedals'; - const SUBSTYLE_BgBronze = 'BgBronze'; - const SUBSTYLE_BgGold = 'BgGold'; - const SUBSTYLE_BgNadeo = 'BgNadeo'; - const SUBSTYLE_BgNotPlayed = 'BgNotPlayed'; - const SUBSTYLE_BgPlayed = 'BgPlayed'; - const SUBSTYLE_BgSilver = 'BgSilver'; +class Quad_BgsChallengeMedals extends Quad +{ + + /* + * Constants + */ + const STYLE = 'BgsChallengeMedals'; + const SUBSTYLE_BgBronze = 'BgBronze'; + const SUBSTYLE_BgGold = 'BgGold'; + const SUBSTYLE_BgNadeo = 'BgNadeo'; + const SUBSTYLE_BgNotPlayed = 'BgNotPlayed'; + const SUBSTYLE_BgPlayed = 'BgPlayed'; + const SUBSTYLE_BgSilver = 'BgSilver'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_BgsPlayerCard.php b/libs/FML/Controls/Quads/Quad_BgsPlayerCard.php index e18612df..509d9a54 100644 --- a/libs/FML/Controls/Quads/Quad_BgsPlayerCard.php +++ b/libs/FML/Controls/Quads/Quad_BgsPlayerCard.php @@ -8,31 +8,34 @@ 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 { - /* - * Constants - */ - const STYLE = 'BgsPlayerCard'; - const SUBSTYLE_BgActivePlayerCard = 'BgActivePlayerCard'; - const SUBSTYLE_BgActivePlayerName = 'BgActivePlayerName'; - const SUBSTYLE_BgActivePlayerScore = 'BgActivePlayerScore'; - const SUBSTYLE_BgCard = 'BgCard'; - const SUBSTYLE_BgCardSystem = 'BgCardSystem'; - const SUBSTYLE_BgMediaTracker = 'BgMediaTracker'; - const SUBSTYLE_BgPlayerCard = 'BgPlayerCard'; - const SUBSTYLE_BgPlayerCardBig = 'BgPlayerCardBig'; - const SUBSTYLE_BgPlayerCardSmall = 'BgPlayerCardSmall'; - const SUBSTYLE_BgPlayerName = 'BgPlayerName'; - const SUBSTYLE_BgPlayerScore = 'BgPlayerScore'; - const SUBSTYLE_BgRacePlayerLine = 'BgRacePlayerLine'; - const SUBSTYLE_BgRacePlayerName = 'BgRacePlayerName'; - const SUBSTYLE_ProgressBar = 'ProgressBar'; +class Quad_BgsPlayerCard extends Quad +{ + + /* + * Constants + */ + const STYLE = 'BgsPlayerCard'; + const SUBSTYLE_BgActivePlayerCard = 'BgActivePlayerCard'; + const SUBSTYLE_BgActivePlayerName = 'BgActivePlayerName'; + const SUBSTYLE_BgActivePlayerScore = 'BgActivePlayerScore'; + const SUBSTYLE_BgCard = 'BgCard'; + const SUBSTYLE_BgCardSystem = 'BgCardSystem'; + const SUBSTYLE_BgMediaTracker = 'BgMediaTracker'; + const SUBSTYLE_BgPlayerCard = 'BgPlayerCard'; + const SUBSTYLE_BgPlayerCardBig = 'BgPlayerCardBig'; + const SUBSTYLE_BgPlayerCardSmall = 'BgPlayerCardSmall'; + const SUBSTYLE_BgPlayerName = 'BgPlayerName'; + const SUBSTYLE_BgPlayerScore = 'BgPlayerScore'; + const SUBSTYLE_BgRacePlayerLine = 'BgRacePlayerLine'; + const SUBSTYLE_BgRacePlayerName = 'BgRacePlayerName'; + const SUBSTYLE_ProgressBar = 'ProgressBar'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Copilot.php b/libs/FML/Controls/Quads/Quad_Copilot.php index 6e16cc41..22d7a9ff 100644 --- a/libs/FML/Controls/Quads/Quad_Copilot.php +++ b/libs/FML/Controls/Quads/Quad_Copilot.php @@ -8,29 +8,32 @@ 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 { - /* - * Constants - */ - const STYLE = 'Copilot'; - const SUBSTYLE_Down = 'Down'; - const SUBSTYLE_DownGood = 'DownGood'; - const SUBSTYLE_DownWrong = 'DownWrong'; - const SUBSTYLE_Left = 'Left'; - const SUBSTYLE_LeftGood = 'LeftGood'; - const SUBSTYLE_LeftWrong = 'LeftWrong'; - const SUBSTYLE_Right = 'Right'; - const SUBSTYLE_RightGood = 'RightGood'; - const SUBSTYLE_RightWrong = 'RightWrong'; - const SUBSTYLE_Up = 'Up'; - const SUBSTYLE_UpGood = 'UpGood'; - const SUBSTYLE_UpWrong = 'UpWrong'; +class Quad_Copilot extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Copilot'; + const SUBSTYLE_Down = 'Down'; + const SUBSTYLE_DownGood = 'DownGood'; + const SUBSTYLE_DownWrong = 'DownWrong'; + const SUBSTYLE_Left = 'Left'; + const SUBSTYLE_LeftGood = 'LeftGood'; + const SUBSTYLE_LeftWrong = 'LeftWrong'; + const SUBSTYLE_Right = 'Right'; + const SUBSTYLE_RightGood = 'RightGood'; + const SUBSTYLE_RightWrong = 'RightWrong'; + const SUBSTYLE_Up = 'Up'; + const SUBSTYLE_UpGood = 'UpGood'; + const SUBSTYLE_UpWrong = 'UpWrong'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Emblems.php b/libs/FML/Controls/Quads/Quad_Emblems.php index 2c1d91dd..b97c2a88 100644 --- a/libs/FML/Controls/Quads/Quad_Emblems.php +++ b/libs/FML/Controls/Quads/Quad_Emblems.php @@ -8,20 +8,23 @@ 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 { - /* - * Constants - */ - const STYLE = 'Emblems'; - const SUBSTYLE_0 = '#0'; - const SUBSTYLE_1 = '#1'; - const SUBSTYLE_2 = '#2'; +class Quad_Emblems extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Emblems'; + const SUBSTYLE_0 = '#0'; + const SUBSTYLE_1 = '#1'; + const SUBSTYLE_2 = '#2'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_EnergyBar.php b/libs/FML/Controls/Quads/Quad_EnergyBar.php index 24433c23..86eccfa9 100644 --- a/libs/FML/Controls/Quads/Quad_EnergyBar.php +++ b/libs/FML/Controls/Quads/Quad_EnergyBar.php @@ -8,23 +8,26 @@ 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 { - /* - * Constants - */ - const STYLE = 'EnergyBar'; - const SUBSTYLE_BgText = 'BgText'; - const SUBSTYLE_EnergyBar = 'EnergyBar'; - const SUBSTYLE_EnergyBar_0_25 = 'EnergyBar_0.25'; - const SUBSTYLE_EnergyBar_Thin = 'EnergyBar_Thin'; - const SUBSTYLE_HeaderGaugeLeft = 'HeaderGaugeLeft'; - const SUBSTYLE_HeaderGaugeRight = 'HeaderGaugeRight'; +class Quad_EnergyBar extends Quad +{ + + /* + * Constants + */ + const STYLE = 'EnergyBar'; + const SUBSTYLE_BgText = 'BgText'; + const SUBSTYLE_EnergyBar = 'EnergyBar'; + const SUBSTYLE_EnergyBar_0_25 = 'EnergyBar_0.25'; + const SUBSTYLE_EnergyBar_Thin = 'EnergyBar_Thin'; + const SUBSTYLE_HeaderGaugeLeft = 'HeaderGaugeLeft'; + const SUBSTYLE_HeaderGaugeRight = 'HeaderGaugeRight'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Hud3dEchelons.php b/libs/FML/Controls/Quads/Quad_Hud3dEchelons.php index 994a61e3..c21f293c 100644 --- a/libs/FML/Controls/Quads/Quad_Hud3dEchelons.php +++ b/libs/FML/Controls/Quads/Quad_Hud3dEchelons.php @@ -8,26 +8,29 @@ 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 { - /* - * Constants - */ - const STYLE = 'Hud3dEchelons'; - const SUBSTYLE_EchelonBronze1 = 'EchelonBronze1'; - const SUBSTYLE_EchelonBronze2 = 'EchelonBronze2'; - const SUBSTYLE_EchelonBronze3 = 'EchelonBronze3'; - const SUBSTYLE_EchelonGold1 = 'EchelonGold1'; - const SUBSTYLE_EchelonGold2 = 'EchelonGold2'; - const SUBSTYLE_EchelonGold3 = 'EchelonGold3'; - const SUBSTYLE_EchelonSilver1 = 'EchelonSilver1'; - const SUBSTYLE_EchelonSilver2 = 'EchelonSilver2'; - const SUBSTYLE_EchelonSilver3 = 'EchelonSilver3'; +class Quad_Hud3dEchelons extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Hud3dEchelons'; + const SUBSTYLE_EchelonBronze1 = 'EchelonBronze1'; + const SUBSTYLE_EchelonBronze2 = 'EchelonBronze2'; + const SUBSTYLE_EchelonBronze3 = 'EchelonBronze3'; + const SUBSTYLE_EchelonGold1 = 'EchelonGold1'; + const SUBSTYLE_EchelonGold2 = 'EchelonGold2'; + const SUBSTYLE_EchelonGold3 = 'EchelonGold3'; + const SUBSTYLE_EchelonSilver1 = 'EchelonSilver1'; + const SUBSTYLE_EchelonSilver2 = 'EchelonSilver2'; + const SUBSTYLE_EchelonSilver3 = 'EchelonSilver3'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Hud3dIcons.php b/libs/FML/Controls/Quads/Quad_Hud3dIcons.php index 84bd8801..4385cdc7 100644 --- a/libs/FML/Controls/Quads/Quad_Hud3dIcons.php +++ b/libs/FML/Controls/Quads/Quad_Hud3dIcons.php @@ -8,25 +8,28 @@ 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 { - /* - * Constants - */ - const STYLE = 'Hud3dIcons'; - const SUBSTYLE_Cross = 'Cross'; - const SUBSTYLE_CrossTargeted = 'CrossTargeted'; - const SUBSTYLE_Player1 = 'Player1'; - const SUBSTYLE_Player2 = 'Player2'; - const SUBSTYLE_Player3 = 'Player3'; - const SUBSTYLE_PointA = 'PointA'; - const SUBSTYLE_PointB = 'PointB'; - const SUBSTYLE_PointC = 'PointC'; +class Quad_Hud3dIcons extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Hud3dIcons'; + const SUBSTYLE_Cross = 'Cross'; + const SUBSTYLE_CrossTargeted = 'CrossTargeted'; + const SUBSTYLE_Player1 = 'Player1'; + const SUBSTYLE_Player2 = 'Player2'; + const SUBSTYLE_Player3 = 'Player3'; + const SUBSTYLE_PointA = 'PointA'; + const SUBSTYLE_PointB = 'PointB'; + const SUBSTYLE_PointC = 'PointC'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Icons128x128_1.php b/libs/FML/Controls/Quads/Quad_Icons128x128_1.php index 7953b336..926fd32f 100644 --- a/libs/FML/Controls/Quads/Quad_Icons128x128_1.php +++ b/libs/FML/Controls/Quads/Quad_Icons128x128_1.php @@ -8,81 +8,84 @@ use FML\Controls\Quad; * Quad class for 'Icons128x128_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_Icons128x128_1 extends Quad { - /* - * Constants - */ - const STYLE = 'Icons128x128_1'; - const SUBSTYLE_Advanced = 'Advanced'; - const SUBSTYLE_Back = 'Back'; - const SUBSTYLE_BackFocusable = 'BackFocusable'; - const SUBSTYLE_Beginner = 'Beginner'; - const SUBSTYLE_Browse = 'Browse'; - const SUBSTYLE_Buddies = 'Buddies'; - const SUBSTYLE_Challenge = 'Challenge'; - const SUBSTYLE_ChallengeAuthor = 'ChallengeAuthor'; - const SUBSTYLE_Coppers = 'Coppers'; - const SUBSTYLE_Create = 'Create'; - const SUBSTYLE_Credits = 'Credits'; - const SUBSTYLE_Custom = 'Custom'; - const SUBSTYLE_CustomStars = 'CustomStars'; - const SUBSTYLE_Default = 'Default'; - const SUBSTYLE_Download = 'Download'; - const SUBSTYLE_Easy = 'Easy'; - const SUBSTYLE_Editor = 'Editor'; - const SUBSTYLE_Event = 'Event'; - const SUBSTYLE_Extreme = 'Extreme'; - const SUBSTYLE_Forever = 'Forever'; - const SUBSTYLE_GhostEditor = 'GhostEditor'; - const SUBSTYLE_Hard = 'Hard'; - const SUBSTYLE_Hotseat = 'Hotseat'; - const SUBSTYLE_Inputs = 'Inputs'; - const SUBSTYLE_Invite = 'Invite'; - const SUBSTYLE_LadderPoints = 'LadderPoints'; - const SUBSTYLE_Lan = 'Lan'; - const SUBSTYLE_Launch = 'Launch'; - const SUBSTYLE_Load = 'Load'; - const SUBSTYLE_LoadTrack = 'LoadTrack'; - const SUBSTYLE_Manialink = 'Manialink'; - const SUBSTYLE_ManiaZones = 'ManiaZones'; - const SUBSTYLE_MedalCount = 'MedalCount'; - const SUBSTYLE_MediaTracker = 'MediaTracker'; - const SUBSTYLE_Medium = 'Medium'; - const SUBSTYLE_Multiplayer = 'Multiplayer'; - const SUBSTYLE_Nations = 'Nations'; - const SUBSTYLE_NewTrack = 'NewTrack'; - const SUBSTYLE_Options = 'Options'; - const SUBSTYLE_Padlock = 'Padlock'; - const SUBSTYLE_Paint = 'Paint'; - const SUBSTYLE_Platform = 'Platform'; - const SUBSTYLE_PlayerPage = 'PlayerPage'; - const SUBSTYLE_Profile = 'Profile'; - const SUBSTYLE_ProfileAdvanced = 'ProfileAdvanced'; - const SUBSTYLE_ProfileVehicle = 'ProfileVehicle'; - const SUBSTYLE_Puzzle = 'Puzzle'; - const SUBSTYLE_Quit = 'Quit'; - const SUBSTYLE_Race = 'Race'; - const SUBSTYLE_Rankings = 'Rankings'; - const SUBSTYLE_Replay = 'Replay'; - const SUBSTYLE_Save = 'Save'; - const SUBSTYLE_ServersAll = 'ServersAll'; - const SUBSTYLE_ServersFavorites = 'ServersFavorites'; - const SUBSTYLE_ServersSuggested = 'ServersSuggested'; - const SUBSTYLE_Share = 'Share'; - const SUBSTYLE_ShareBlink = 'ShareBlink'; - const SUBSTYLE_SkillPoints = 'SkillPoints'; - const SUBSTYLE_Solo = 'Solo'; - const SUBSTYLE_Statistics = 'Statistics'; - const SUBSTYLE_Stunts = 'Stunts'; - const SUBSTYLE_United = 'United'; - const SUBSTYLE_Upload = 'Upload'; - const SUBSTYLE_Vehicles = 'Vehicles'; +class Quad_Icons128x128_1 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Icons128x128_1'; + const SUBSTYLE_Advanced = 'Advanced'; + const SUBSTYLE_Back = 'Back'; + const SUBSTYLE_BackFocusable = 'BackFocusable'; + const SUBSTYLE_Beginner = 'Beginner'; + const SUBSTYLE_Browse = 'Browse'; + const SUBSTYLE_Buddies = 'Buddies'; + const SUBSTYLE_Challenge = 'Challenge'; + const SUBSTYLE_ChallengeAuthor = 'ChallengeAuthor'; + const SUBSTYLE_Coppers = 'Coppers'; + const SUBSTYLE_Create = 'Create'; + const SUBSTYLE_Credits = 'Credits'; + const SUBSTYLE_Custom = 'Custom'; + const SUBSTYLE_CustomStars = 'CustomStars'; + const SUBSTYLE_Default = 'Default'; + const SUBSTYLE_Download = 'Download'; + const SUBSTYLE_Easy = 'Easy'; + const SUBSTYLE_Editor = 'Editor'; + const SUBSTYLE_Event = 'Event'; + const SUBSTYLE_Extreme = 'Extreme'; + const SUBSTYLE_Forever = 'Forever'; + const SUBSTYLE_GhostEditor = 'GhostEditor'; + const SUBSTYLE_Hard = 'Hard'; + const SUBSTYLE_Hotseat = 'Hotseat'; + const SUBSTYLE_Inputs = 'Inputs'; + const SUBSTYLE_Invite = 'Invite'; + const SUBSTYLE_LadderPoints = 'LadderPoints'; + const SUBSTYLE_Lan = 'Lan'; + const SUBSTYLE_Launch = 'Launch'; + const SUBSTYLE_Load = 'Load'; + const SUBSTYLE_LoadTrack = 'LoadTrack'; + const SUBSTYLE_Manialink = 'Manialink'; + const SUBSTYLE_ManiaZones = 'ManiaZones'; + const SUBSTYLE_MedalCount = 'MedalCount'; + const SUBSTYLE_MediaTracker = 'MediaTracker'; + const SUBSTYLE_Medium = 'Medium'; + const SUBSTYLE_Multiplayer = 'Multiplayer'; + const SUBSTYLE_Nations = 'Nations'; + const SUBSTYLE_NewTrack = 'NewTrack'; + const SUBSTYLE_Options = 'Options'; + const SUBSTYLE_Padlock = 'Padlock'; + const SUBSTYLE_Paint = 'Paint'; + const SUBSTYLE_Platform = 'Platform'; + const SUBSTYLE_PlayerPage = 'PlayerPage'; + const SUBSTYLE_Profile = 'Profile'; + const SUBSTYLE_ProfileAdvanced = 'ProfileAdvanced'; + const SUBSTYLE_ProfileVehicle = 'ProfileVehicle'; + const SUBSTYLE_Puzzle = 'Puzzle'; + const SUBSTYLE_Quit = 'Quit'; + const SUBSTYLE_Race = 'Race'; + const SUBSTYLE_Rankings = 'Rankings'; + const SUBSTYLE_Replay = 'Replay'; + const SUBSTYLE_Save = 'Save'; + const SUBSTYLE_ServersAll = 'ServersAll'; + const SUBSTYLE_ServersFavorites = 'ServersFavorites'; + const SUBSTYLE_ServersSuggested = 'ServersSuggested'; + const SUBSTYLE_Share = 'Share'; + const SUBSTYLE_ShareBlink = 'ShareBlink'; + const SUBSTYLE_SkillPoints = 'SkillPoints'; + const SUBSTYLE_Solo = 'Solo'; + const SUBSTYLE_Statistics = 'Statistics'; + const SUBSTYLE_Stunts = 'Stunts'; + const SUBSTYLE_United = 'United'; + const SUBSTYLE_Upload = 'Upload'; + const SUBSTYLE_Vehicles = 'Vehicles'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Icons128x128_Blink.php b/libs/FML/Controls/Quads/Quad_Icons128x128_Blink.php index f0c797fe..65a6cb92 100644 --- a/libs/FML/Controls/Quads/Quad_Icons128x128_Blink.php +++ b/libs/FML/Controls/Quads/Quad_Icons128x128_Blink.php @@ -8,81 +8,84 @@ use FML\Controls\Quad; * Quad class for 'Icons128x128_Blink' 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_Icons128x128_Blink extends Quad { - /* - * Constants - */ - const STYLE = 'Icons128x128_Blink'; - const SUBSTYLE_Advanced = 'Advanced'; - const SUBSTYLE_Back = 'Back'; - const SUBSTYLE_BackFocusable = 'BackFocusable'; - const SUBSTYLE_Beginner = 'Beginner'; - const SUBSTYLE_Browse = 'Browse'; - const SUBSTYLE_Buddies = 'Buddies'; - const SUBSTYLE_Challenge = 'Challenge'; - const SUBSTYLE_ChallengeAuthor = 'ChallengeAuthor'; - const SUBSTYLE_Coppers = 'Coppers'; - const SUBSTYLE_Create = 'Create'; - const SUBSTYLE_Credits = 'Credits'; - const SUBSTYLE_Custom = 'Custom'; - const SUBSTYLE_CustomStars = 'CustomStars'; - const SUBSTYLE_Default = 'Default'; - const SUBSTYLE_Download = 'Download'; - const SUBSTYLE_Easy = 'Easy'; - const SUBSTYLE_Editor = 'Editor'; - const SUBSTYLE_Event = 'Event'; - const SUBSTYLE_Extreme = 'Extreme'; - const SUBSTYLE_Forever = 'Forever'; - const SUBSTYLE_GhostEditor = 'GhostEditor'; - const SUBSTYLE_Hard = 'Hard'; - const SUBSTYLE_Hotseat = 'Hotseat'; - const SUBSTYLE_Inputs = 'Inputs'; - const SUBSTYLE_Invite = 'Invite'; - const SUBSTYLE_LadderPoints = 'LadderPoints'; - const SUBSTYLE_Lan = 'Lan'; - const SUBSTYLE_Launch = 'Launch'; - const SUBSTYLE_Load = 'Load'; - const SUBSTYLE_LoadTrack = 'LoadTrack'; - const SUBSTYLE_Manialink = 'Manialink'; - const SUBSTYLE_ManiaZones = 'ManiaZones'; - const SUBSTYLE_MedalCount = 'MedalCount'; - const SUBSTYLE_MediaTracker = 'MediaTracker'; - const SUBSTYLE_Medium = 'Medium'; - const SUBSTYLE_Multiplayer = 'Multiplayer'; - const SUBSTYLE_Nations = 'Nations'; - const SUBSTYLE_NewTrack = 'NewTrack'; - const SUBSTYLE_Options = 'Options'; - const SUBSTYLE_Padlock = 'Padlock'; - const SUBSTYLE_Paint = 'Paint'; - const SUBSTYLE_Platform = 'Platform'; - const SUBSTYLE_PlayerPage = 'PlayerPage'; - const SUBSTYLE_Profile = 'Profile'; - const SUBSTYLE_ProfileAdvanced = 'ProfileAdvanced'; - const SUBSTYLE_ProfileVehicle = 'ProfileVehicle'; - const SUBSTYLE_Puzzle = 'Puzzle'; - const SUBSTYLE_Quit = 'Quit'; - const SUBSTYLE_Race = 'Race'; - const SUBSTYLE_Rankings = 'Rankings'; - const SUBSTYLE_Replay = 'Replay'; - const SUBSTYLE_Save = 'Save'; - const SUBSTYLE_ServersAll = 'ServersAll'; - const SUBSTYLE_ServersFavorites = 'ServersFavorites'; - const SUBSTYLE_ServersSuggested = 'ServersSuggested'; - const SUBSTYLE_Share = 'Share'; - const SUBSTYLE_ShareBlink = 'ShareBlink'; - const SUBSTYLE_SkillPoints = 'SkillPoints'; - const SUBSTYLE_Solo = 'Solo'; - const SUBSTYLE_Statistics = 'Statistics'; - const SUBSTYLE_Stunts = 'Stunts'; - const SUBSTYLE_United = 'United'; - const SUBSTYLE_Upload = 'Upload'; - const SUBSTYLE_Vehicles = 'Vehicles'; +class Quad_Icons128x128_Blink extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Icons128x128_Blink'; + const SUBSTYLE_Advanced = 'Advanced'; + const SUBSTYLE_Back = 'Back'; + const SUBSTYLE_BackFocusable = 'BackFocusable'; + const SUBSTYLE_Beginner = 'Beginner'; + const SUBSTYLE_Browse = 'Browse'; + const SUBSTYLE_Buddies = 'Buddies'; + const SUBSTYLE_Challenge = 'Challenge'; + const SUBSTYLE_ChallengeAuthor = 'ChallengeAuthor'; + const SUBSTYLE_Coppers = 'Coppers'; + const SUBSTYLE_Create = 'Create'; + const SUBSTYLE_Credits = 'Credits'; + const SUBSTYLE_Custom = 'Custom'; + const SUBSTYLE_CustomStars = 'CustomStars'; + const SUBSTYLE_Default = 'Default'; + const SUBSTYLE_Download = 'Download'; + const SUBSTYLE_Easy = 'Easy'; + const SUBSTYLE_Editor = 'Editor'; + const SUBSTYLE_Event = 'Event'; + const SUBSTYLE_Extreme = 'Extreme'; + const SUBSTYLE_Forever = 'Forever'; + const SUBSTYLE_GhostEditor = 'GhostEditor'; + const SUBSTYLE_Hard = 'Hard'; + const SUBSTYLE_Hotseat = 'Hotseat'; + const SUBSTYLE_Inputs = 'Inputs'; + const SUBSTYLE_Invite = 'Invite'; + const SUBSTYLE_LadderPoints = 'LadderPoints'; + const SUBSTYLE_Lan = 'Lan'; + const SUBSTYLE_Launch = 'Launch'; + const SUBSTYLE_Load = 'Load'; + const SUBSTYLE_LoadTrack = 'LoadTrack'; + const SUBSTYLE_Manialink = 'Manialink'; + const SUBSTYLE_ManiaZones = 'ManiaZones'; + const SUBSTYLE_MedalCount = 'MedalCount'; + const SUBSTYLE_MediaTracker = 'MediaTracker'; + const SUBSTYLE_Medium = 'Medium'; + const SUBSTYLE_Multiplayer = 'Multiplayer'; + const SUBSTYLE_Nations = 'Nations'; + const SUBSTYLE_NewTrack = 'NewTrack'; + const SUBSTYLE_Options = 'Options'; + const SUBSTYLE_Padlock = 'Padlock'; + const SUBSTYLE_Paint = 'Paint'; + const SUBSTYLE_Platform = 'Platform'; + const SUBSTYLE_PlayerPage = 'PlayerPage'; + const SUBSTYLE_Profile = 'Profile'; + const SUBSTYLE_ProfileAdvanced = 'ProfileAdvanced'; + const SUBSTYLE_ProfileVehicle = 'ProfileVehicle'; + const SUBSTYLE_Puzzle = 'Puzzle'; + const SUBSTYLE_Quit = 'Quit'; + const SUBSTYLE_Race = 'Race'; + const SUBSTYLE_Rankings = 'Rankings'; + const SUBSTYLE_Replay = 'Replay'; + const SUBSTYLE_Save = 'Save'; + const SUBSTYLE_ServersAll = 'ServersAll'; + const SUBSTYLE_ServersFavorites = 'ServersFavorites'; + const SUBSTYLE_ServersSuggested = 'ServersSuggested'; + const SUBSTYLE_Share = 'Share'; + const SUBSTYLE_ShareBlink = 'ShareBlink'; + const SUBSTYLE_SkillPoints = 'SkillPoints'; + const SUBSTYLE_Solo = 'Solo'; + const SUBSTYLE_Statistics = 'Statistics'; + const SUBSTYLE_Stunts = 'Stunts'; + const SUBSTYLE_United = 'United'; + const SUBSTYLE_Upload = 'Upload'; + const SUBSTYLE_Vehicles = 'Vehicles'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Icons128x32_1.php b/libs/FML/Controls/Quads/Quad_Icons128x32_1.php index 33388e97..eadf34d8 100644 --- a/libs/FML/Controls/Quads/Quad_Icons128x32_1.php +++ b/libs/FML/Controls/Quads/Quad_Icons128x32_1.php @@ -8,47 +8,50 @@ 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 { - /* - * Constants - */ - const STYLE = 'Icons128x32_1'; - const SUBSTYLE_ArrowUp = 'ArrowUp'; - const SUBSTYLE_BgQuadWhite = 'BgQuadWhite'; - // TODO: validate existence of 'close' - const SUBSTYLE_Close = 'Close'; - const SUBSTYLE_Empty = 'Empty'; - const SUBSTYLE_ManiaLinkHome = 'ManiaLinkHome'; - const SUBSTYLE_ManiaLinkSwitch = 'ManiaLinkSwitch'; - const SUBSTYLE_ManiaPlanet = 'ManiaPlanet'; - const SUBSTYLE_Minimize = 'Minimize'; - const SUBSTYLE_Music = 'Music'; - const SUBSTYLE_PainterBrush = 'PainterBrush'; - const SUBSTYLE_PainterFill = 'PainterFill'; - const SUBSTYLE_PainterLayer = 'PainterLayer'; - const SUBSTYLE_PainterMirror = 'PainterMirror'; - const SUBSTYLE_PainterSticker = 'PainterSticker'; - const SUBSTYLE_PainterTeam = 'PainterTeam'; - const SUBSTYLE_RT_Cup = 'RT_Cup'; - const SUBSTYLE_RT_Laps = 'RT_Laps'; - const SUBSTYLE_RT_Rounds = 'RT_Rounds'; - const SUBSTYLE_RT_Script = 'RT_Script'; - const SUBSTYLE_RT_Team = 'RT_Team'; - const SUBSTYLE_RT_TimeAttack = 'RT_TimeAttack'; - const SUBSTYLE_RT_Stunts = 'RT_Stunts'; - const SUBSTYLE_Settings = 'Settings'; - const SUBSTYLE_SliderBar = 'SliderBar'; - const SUBSTYLE_SliderBar2 = 'SliderBar2'; - const SUBSTYLE_SliderCursor = 'SliderCursor'; - const SUBSTYLE_Sound = 'Sound'; - const SUBSTYLE_UrlBg = 'UrlBg'; - const SUBSTYLE_Windowed = 'Windowed'; +class Quad_Icons128x32_1 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Icons128x32_1'; + const SUBSTYLE_ArrowUp = 'ArrowUp'; + const SUBSTYLE_BgQuadWhite = 'BgQuadWhite'; + // TODO: validate existence of 'close' + const SUBSTYLE_Close = 'Close'; + const SUBSTYLE_Empty = 'Empty'; + const SUBSTYLE_ManiaLinkHome = 'ManiaLinkHome'; + const SUBSTYLE_ManiaLinkSwitch = 'ManiaLinkSwitch'; + const SUBSTYLE_ManiaPlanet = 'ManiaPlanet'; + const SUBSTYLE_Minimize = 'Minimize'; + const SUBSTYLE_Music = 'Music'; + const SUBSTYLE_PainterBrush = 'PainterBrush'; + const SUBSTYLE_PainterFill = 'PainterFill'; + const SUBSTYLE_PainterLayer = 'PainterLayer'; + const SUBSTYLE_PainterMirror = 'PainterMirror'; + const SUBSTYLE_PainterSticker = 'PainterSticker'; + const SUBSTYLE_PainterTeam = 'PainterTeam'; + const SUBSTYLE_RT_Cup = 'RT_Cup'; + const SUBSTYLE_RT_Laps = 'RT_Laps'; + const SUBSTYLE_RT_Rounds = 'RT_Rounds'; + const SUBSTYLE_RT_Script = 'RT_Script'; + const SUBSTYLE_RT_Team = 'RT_Team'; + const SUBSTYLE_RT_TimeAttack = 'RT_TimeAttack'; + const SUBSTYLE_RT_Stunts = 'RT_Stunts'; + const SUBSTYLE_Settings = 'Settings'; + const SUBSTYLE_SliderBar = 'SliderBar'; + const SUBSTYLE_SliderBar2 = 'SliderBar2'; + const SUBSTYLE_SliderCursor = 'SliderCursor'; + const SUBSTYLE_Sound = 'Sound'; + const SUBSTYLE_UrlBg = 'UrlBg'; + const SUBSTYLE_Windowed = 'Windowed'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Icons64x64_1.php b/libs/FML/Controls/Quads/Quad_Icons64x64_1.php index 1462d947..6e925893 100644 --- a/libs/FML/Controls/Quads/Quad_Icons64x64_1.php +++ b/libs/FML/Controls/Quads/Quad_Icons64x64_1.php @@ -8,103 +8,106 @@ 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 { - /* - * Constants - */ - const STYLE = 'Icons64x64_1'; - const SUBSTYLE_3DStereo = '3DStereo'; - const SUBSTYLE_Add = 'Add'; - const SUBSTYLE_ArrowBlue = 'ArrowBlue'; - const SUBSTYLE_ArrowDisabled = 'ArrowDisabled'; - const SUBSTYLE_ArrowDown = 'ArrowDown'; - const SUBSTYLE_ArrowFastNext = 'ArrowFastNext'; - const SUBSTYLE_ArrowFastPrev = 'ArrowFastPrev'; - const SUBSTYLE_ArrowFirst = 'ArrowFirst'; - const SUBSTYLE_ArrowGreen = 'ArrowGreen'; - const SUBSTYLE_ArrowLast = 'ArrowLast'; - const SUBSTYLE_ArrowNext = 'ArrowNext'; - const SUBSTYLE_ArrowPrev = 'ArrowPrev'; - const SUBSTYLE_ArrowRed = 'ArrowRed'; - const SUBSTYLE_ArrowUp = 'ArrowUp'; - const SUBSTYLE_Browser = 'Browser'; - const SUBSTYLE_Buddy = 'Buddy'; - const SUBSTYLE_ButtonLeagues = 'ButtonLeagues'; - const SUBSTYLE_Camera = 'Camera'; - const SUBSTYLE_CameraLocal = 'CameraLocal'; - const SUBSTYLE_Check = 'Check'; - const SUBSTYLE_ClipPause = 'ClipPause'; - const SUBSTYLE_ClipPlay = 'ClipPlay'; - const SUBSTYLE_ClipRewind = 'ClipRewind'; - const SUBSTYLE_Close = 'Close'; - const SUBSTYLE_Empty = 'Empty'; - const SUBSTYLE_Finish = 'Finish'; - const SUBSTYLE_FinishGrey = 'FinishGrey'; - const SUBSTYLE_First = 'First'; - const SUBSTYLE_GenericButton = 'GenericButton'; - const SUBSTYLE_Green = 'Green'; - const SUBSTYLE_IconLeaguesLadder = 'IconLeaguesLadder'; - const SUBSTYLE_IconPlayers = 'IconPlayers'; - const SUBSTYLE_IconPlayersLadder = 'IconPlayersLadder'; - const SUBSTYLE_IconServers = 'IconServers'; - const SUBSTYLE_Inbox = 'Inbox'; - const SUBSTYLE_LvlGreen = 'LvlGreen'; - const SUBSTYLE_LvlRed = 'LvlRed'; - const SUBSTYLE_LvlYellow = 'LvlYellow'; - const SUBSTYLE_ManiaLinkNext = 'ManiaLinkNext'; - const SUBSTYLE_ManiaLinkPrev = 'ManiaLinkPrev'; - const SUBSTYLE_Maximize = 'Maximize'; - const SUBSTYLE_MediaAudioDownloading = 'MediaAudioDownloading'; - const SUBSTYLE_MediaPlay = 'MediaPlay'; - const SUBSTYLE_MediaStop = 'MediaStop'; - const SUBSTYLE_MediaVideoDownloading = 'MediaVideoDownloading'; - const SUBSTYLE_NewMessage = 'NewMessage'; - const SUBSTYLE_NotBuddy = 'NotBuddy'; - const SUBSTYLE_OfficialRace = 'OfficialRace'; - const SUBSTYLE_Opponents = 'Opponents'; - const SUBSTYLE_Outbox = 'Outbox'; - const SUBSTYLE_QuitRace = 'QuitRace'; - const SUBSTYLE_RedHigh = 'RedHigh'; - const SUBSTYLE_RedLow = 'RedLow'; - const SUBSTYLE_Refresh = 'Refresh'; - const SUBSTYLE_RestartRace = 'RestartRace'; - const SUBSTYLE_Save = 'Save'; - const SUBSTYLE_Second = 'Second'; - const SUBSTYLE_ShowDown = 'ShowDown'; - const SUBSTYLE_ShowDown2 = 'ShowDown2'; - const SUBSTYLE_ShowLeft = 'ShowLeft'; - const SUBSTYLE_ShowLeft2 = 'ShowLeft2'; - const SUBSTYLE_ShowRight = 'ShowRight'; - const SUBSTYLE_ShowRight2 = 'ShowRight2'; - const SUBSTYLE_ShowUp = 'ShowUp'; - const SUBSTYLE_ShowUp2 = 'ShowUp2'; - const SUBSTYLE_ShowUpChanging = 'ShowUpChanging'; - const SUBSTYLE_SliderCursor = 'SliderCursor'; - const SUBSTYLE_SliderCursor2 = 'SliderCursor2'; - const SUBSTYLE_StateFavourite = 'StateFavourite'; - const SUBSTYLE_StatePrivate = 'StatePrivate'; - const SUBSTYLE_StateSuggested = 'StateSuggested'; - const SUBSTYLE_Sub = 'Sub'; - const SUBSTYLE_TagTypeBronze = 'TagTypeBronze'; - const SUBSTYLE_TagTypeGold = 'TagTypeGold'; - const SUBSTYLE_TagTypeNadeo = 'TagTypeNadeo'; - const SUBSTYLE_TagTypeNone = 'TagTypeNone'; - const SUBSTYLE_TagTypeSilver = 'TagTypeSilver'; - const SUBSTYLE_Third = 'Third'; - const SUBSTYLE_ToolLeague1 = 'ToolLeague1'; - const SUBSTYLE_ToolRoot = 'ToolRoot'; - const SUBSTYLE_ToolTree = 'ToolTree'; - const SUBSTYLE_ToolUp = 'ToolUp'; - const SUBSTYLE_TrackInfo = 'TrackInfo'; - const SUBSTYLE_TV = 'TV'; - const SUBSTYLE_YellowHigh = 'YellowHigh'; - const SUBSTYLE_YellowLow = 'YellowLow'; +class Quad_Icons64x64_1 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Icons64x64_1'; + const SUBSTYLE_3DStereo = '3DStereo'; + const SUBSTYLE_Add = 'Add'; + const SUBSTYLE_ArrowBlue = 'ArrowBlue'; + const SUBSTYLE_ArrowDisabled = 'ArrowDisabled'; + const SUBSTYLE_ArrowDown = 'ArrowDown'; + const SUBSTYLE_ArrowFastNext = 'ArrowFastNext'; + const SUBSTYLE_ArrowFastPrev = 'ArrowFastPrev'; + const SUBSTYLE_ArrowFirst = 'ArrowFirst'; + const SUBSTYLE_ArrowGreen = 'ArrowGreen'; + const SUBSTYLE_ArrowLast = 'ArrowLast'; + const SUBSTYLE_ArrowNext = 'ArrowNext'; + const SUBSTYLE_ArrowPrev = 'ArrowPrev'; + const SUBSTYLE_ArrowRed = 'ArrowRed'; + const SUBSTYLE_ArrowUp = 'ArrowUp'; + const SUBSTYLE_Browser = 'Browser'; + const SUBSTYLE_Buddy = 'Buddy'; + const SUBSTYLE_ButtonLeagues = 'ButtonLeagues'; + const SUBSTYLE_Camera = 'Camera'; + const SUBSTYLE_CameraLocal = 'CameraLocal'; + const SUBSTYLE_Check = 'Check'; + const SUBSTYLE_ClipPause = 'ClipPause'; + const SUBSTYLE_ClipPlay = 'ClipPlay'; + const SUBSTYLE_ClipRewind = 'ClipRewind'; + const SUBSTYLE_Close = 'Close'; + const SUBSTYLE_Empty = 'Empty'; + const SUBSTYLE_Finish = 'Finish'; + const SUBSTYLE_FinishGrey = 'FinishGrey'; + const SUBSTYLE_First = 'First'; + const SUBSTYLE_GenericButton = 'GenericButton'; + const SUBSTYLE_Green = 'Green'; + const SUBSTYLE_IconLeaguesLadder = 'IconLeaguesLadder'; + const SUBSTYLE_IconPlayers = 'IconPlayers'; + const SUBSTYLE_IconPlayersLadder = 'IconPlayersLadder'; + const SUBSTYLE_IconServers = 'IconServers'; + const SUBSTYLE_Inbox = 'Inbox'; + const SUBSTYLE_LvlGreen = 'LvlGreen'; + const SUBSTYLE_LvlRed = 'LvlRed'; + const SUBSTYLE_LvlYellow = 'LvlYellow'; + const SUBSTYLE_ManiaLinkNext = 'ManiaLinkNext'; + const SUBSTYLE_ManiaLinkPrev = 'ManiaLinkPrev'; + const SUBSTYLE_Maximize = 'Maximize'; + const SUBSTYLE_MediaAudioDownloading = 'MediaAudioDownloading'; + const SUBSTYLE_MediaPlay = 'MediaPlay'; + const SUBSTYLE_MediaStop = 'MediaStop'; + const SUBSTYLE_MediaVideoDownloading = 'MediaVideoDownloading'; + const SUBSTYLE_NewMessage = 'NewMessage'; + const SUBSTYLE_NotBuddy = 'NotBuddy'; + const SUBSTYLE_OfficialRace = 'OfficialRace'; + const SUBSTYLE_Opponents = 'Opponents'; + const SUBSTYLE_Outbox = 'Outbox'; + const SUBSTYLE_QuitRace = 'QuitRace'; + const SUBSTYLE_RedHigh = 'RedHigh'; + const SUBSTYLE_RedLow = 'RedLow'; + const SUBSTYLE_Refresh = 'Refresh'; + const SUBSTYLE_RestartRace = 'RestartRace'; + const SUBSTYLE_Save = 'Save'; + const SUBSTYLE_Second = 'Second'; + const SUBSTYLE_ShowDown = 'ShowDown'; + const SUBSTYLE_ShowDown2 = 'ShowDown2'; + const SUBSTYLE_ShowLeft = 'ShowLeft'; + const SUBSTYLE_ShowLeft2 = 'ShowLeft2'; + const SUBSTYLE_ShowRight = 'ShowRight'; + const SUBSTYLE_ShowRight2 = 'ShowRight2'; + const SUBSTYLE_ShowUp = 'ShowUp'; + const SUBSTYLE_ShowUp2 = 'ShowUp2'; + const SUBSTYLE_ShowUpChanging = 'ShowUpChanging'; + const SUBSTYLE_SliderCursor = 'SliderCursor'; + const SUBSTYLE_SliderCursor2 = 'SliderCursor2'; + const SUBSTYLE_StateFavourite = 'StateFavourite'; + const SUBSTYLE_StatePrivate = 'StatePrivate'; + const SUBSTYLE_StateSuggested = 'StateSuggested'; + const SUBSTYLE_Sub = 'Sub'; + const SUBSTYLE_TagTypeBronze = 'TagTypeBronze'; + const SUBSTYLE_TagTypeGold = 'TagTypeGold'; + const SUBSTYLE_TagTypeNadeo = 'TagTypeNadeo'; + const SUBSTYLE_TagTypeNone = 'TagTypeNone'; + const SUBSTYLE_TagTypeSilver = 'TagTypeSilver'; + const SUBSTYLE_Third = 'Third'; + const SUBSTYLE_ToolLeague1 = 'ToolLeague1'; + const SUBSTYLE_ToolRoot = 'ToolRoot'; + const SUBSTYLE_ToolTree = 'ToolTree'; + const SUBSTYLE_ToolUp = 'ToolUp'; + const SUBSTYLE_TrackInfo = 'TrackInfo'; + const SUBSTYLE_TV = 'TV'; + const SUBSTYLE_YellowHigh = 'YellowHigh'; + const SUBSTYLE_YellowLow = 'YellowLow'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Icons64x64_2.php b/libs/FML/Controls/Quads/Quad_Icons64x64_2.php index 5482bcc7..153a805f 100644 --- a/libs/FML/Controls/Quads/Quad_Icons64x64_2.php +++ b/libs/FML/Controls/Quads/Quad_Icons64x64_2.php @@ -8,32 +8,35 @@ 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 { - /* - * Constants - */ - const STYLE = 'Icons64x64_2'; - const SUBSTYLE_ArrowElimination = 'ArrowElimination'; - const SUBSTYLE_ArrowHit = 'ArrowHit'; - const SUBSTYLE_Calendar = 'Calendar'; - const SUBSTYLE_Disconnected = 'Disconnected'; - const SUBSTYLE_DisconnectedLight = 'DisconnectedLight'; - const SUBSTYLE_LaserElimination = 'LaserElimination'; - const SUBSTYLE_LaserHit = 'LaserHit'; - const SUBSTYLE_NucleusElimination = 'NucleusElimination'; - const SUBSTYLE_NucleusHit = 'NucleusHit'; - const SUBSTYLE_RocketElimination = 'RocketElimination'; - const SUBSTYLE_RocketHit = 'RocketHit'; - const SUBSTYLE_ServerNotice = 'ServerNotice'; - const SUBSTYLE_SortBy = 'SortBy'; - const SUBSTYLE_UnknownElimination = 'UnknownElimination'; - const SUBSTYLE_UnknownHit = 'UnknownHit'; +class Quad_Icons64x64_2 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Icons64x64_2'; + const SUBSTYLE_ArrowElimination = 'ArrowElimination'; + const SUBSTYLE_ArrowHit = 'ArrowHit'; + const SUBSTYLE_Calendar = 'Calendar'; + const SUBSTYLE_Disconnected = 'Disconnected'; + const SUBSTYLE_DisconnectedLight = 'DisconnectedLight'; + const SUBSTYLE_LaserElimination = 'LaserElimination'; + const SUBSTYLE_LaserHit = 'LaserHit'; + const SUBSTYLE_NucleusElimination = 'NucleusElimination'; + const SUBSTYLE_NucleusHit = 'NucleusHit'; + const SUBSTYLE_RocketElimination = 'RocketElimination'; + const SUBSTYLE_RocketHit = 'RocketHit'; + const SUBSTYLE_ServerNotice = 'ServerNotice'; + const SUBSTYLE_SortBy = 'SortBy'; + const SUBSTYLE_UnknownElimination = 'UnknownElimination'; + const SUBSTYLE_UnknownHit = 'UnknownHit'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_ManiaPlanetLogos.php b/libs/FML/Controls/Quads/Quad_ManiaPlanetLogos.php index 5ed4b67c..3ed1b967 100644 --- a/libs/FML/Controls/Quads/Quad_ManiaPlanetLogos.php +++ b/libs/FML/Controls/Quads/Quad_ManiaPlanetLogos.php @@ -8,24 +8,27 @@ use FML\Controls\Quad; * Quad class for 'ManiaPlanetLogos' 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_ManiaPlanetLogos extends Quad { - /* - * Constants - */ - const STYLE = 'ManiaPlanetLogos'; - const SUBSTYLE_IconPlanets = 'IconPlanets'; - const SUBSTYLE_IconPlanetsPerspective = 'IconPlanetsPerspective'; - const SUBSTYLE_IconPlanetsSmall = 'IconPlanetsSmall'; - const SUBSTYLE_ManiaPlanetLogoBlack = 'ManiaPlanetLogoBlack'; - const SUBSTYLE_ManiaPlanetLogoBlackSmall = 'ManiaPlanetLogoBlackSmall'; - const SUBSTYLE_ManiaPlanetLogoWhite = 'ManiaPlanetLogoWhite'; - const SUBSTYLE_ManiaPlanetLogoWhiteSmall = 'ManiaPlanetLogoWhiteSmall'; +class Quad_ManiaPlanetLogos extends Quad +{ + + /* + * Constants + */ + const STYLE = 'ManiaPlanetLogos'; + const SUBSTYLE_IconPlanets = 'IconPlanets'; + const SUBSTYLE_IconPlanetsPerspective = 'IconPlanetsPerspective'; + const SUBSTYLE_IconPlanetsSmall = 'IconPlanetsSmall'; + const SUBSTYLE_ManiaPlanetLogoBlack = 'ManiaPlanetLogoBlack'; + const SUBSTYLE_ManiaPlanetLogoBlackSmall = 'ManiaPlanetLogoBlackSmall'; + const SUBSTYLE_ManiaPlanetLogoWhite = 'ManiaPlanetLogoWhite'; + const SUBSTYLE_ManiaPlanetLogoWhiteSmall = 'ManiaPlanetLogoWhiteSmall'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_ManiaPlanetMainMenu.php b/libs/FML/Controls/Quads/Quad_ManiaPlanetMainMenu.php index abf750bd..b8c3b5f2 100644 --- a/libs/FML/Controls/Quads/Quad_ManiaPlanetMainMenu.php +++ b/libs/FML/Controls/Quads/Quad_ManiaPlanetMainMenu.php @@ -8,28 +8,31 @@ use FML\Controls\Quad; * Quad class for 'ManiaPlanetMainMenu' 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_ManiaPlanetMainMenu extends Quad { - /* - * Constants - */ - const STYLE = 'ManiaPlanetMainMenu'; - const SUBSTYLE_BottomBar = 'BottomBar'; - const SUBSTYLE_Highlight = 'Highlight'; - const SUBSTYLE_IconAdd = 'IconAdd'; - const SUBSTYLE_IconHome = 'IconHome'; - const SUBSTYLE_IconPlay = 'IconPlay'; - const SUBSTYLE_IconQuit = 'IconQuit'; - const SUBSTYLE_IconSettings = 'IconSettings'; - const SUBSTYLE_IconStore = 'IconStore'; - const SUBSTYLE_MainBg = 'MainBg'; - const SUBSTYLE_TitleBg = 'TitleBg'; - const SUBSTYLE_TopBar = 'TopBar'; +class Quad_ManiaPlanetMainMenu extends Quad +{ + + /* + * Constants + */ + const STYLE = 'ManiaPlanetMainMenu'; + const SUBSTYLE_BottomBar = 'BottomBar'; + const SUBSTYLE_Highlight = 'Highlight'; + const SUBSTYLE_IconAdd = 'IconAdd'; + const SUBSTYLE_IconHome = 'IconHome'; + const SUBSTYLE_IconPlay = 'IconPlay'; + const SUBSTYLE_IconQuit = 'IconQuit'; + const SUBSTYLE_IconSettings = 'IconSettings'; + const SUBSTYLE_IconStore = 'IconStore'; + const SUBSTYLE_MainBg = 'MainBg'; + const SUBSTYLE_TitleBg = 'TitleBg'; + const SUBSTYLE_TopBar = 'TopBar'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_ManiaplanetSystem.php b/libs/FML/Controls/Quads/Quad_ManiaplanetSystem.php index 82d3fb29..4217d4ec 100644 --- a/libs/FML/Controls/Quads/Quad_ManiaplanetSystem.php +++ b/libs/FML/Controls/Quads/Quad_ManiaplanetSystem.php @@ -8,23 +8,26 @@ use FML\Controls\Quad; * Quad class for 'ManiaplanetSystem' 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_ManiaplanetSystem extends Quad { - /* - * Constants - */ - const STYLE = 'ManiaplanetSystem'; - const SUBSTYLE_BgDialog = 'BgDialog'; - const SUBSTYLE_BgDialogAnchor = 'BgDialogAnchor'; - const SUBSTYLE_BgFloat = 'BgFloat'; - const SUBSTYLE_Events = 'Events'; - const SUBSTYLE_Medals = 'Medals'; - const SUBSTYLE_Statistics = 'Statistics'; +class Quad_ManiaplanetSystem extends Quad +{ + + /* + * Constants + */ + const STYLE = 'ManiaplanetSystem'; + const SUBSTYLE_BgDialog = 'BgDialog'; + const SUBSTYLE_BgDialogAnchor = 'BgDialogAnchor'; + const SUBSTYLE_BgFloat = 'BgFloat'; + const SUBSTYLE_Events = 'Events'; + const SUBSTYLE_Medals = 'Medals'; + const SUBSTYLE_Statistics = 'Statistics'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_MedalsBig.php b/libs/FML/Controls/Quads/Quad_MedalsBig.php index 1628ecbe..708a74ba 100644 --- a/libs/FML/Controls/Quads/Quad_MedalsBig.php +++ b/libs/FML/Controls/Quads/Quad_MedalsBig.php @@ -8,24 +8,27 @@ use FML\Controls\Quad; * Quad class for 'MedalsBig' 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_MedalsBig extends Quad { - /* - * Constants - */ - const STYLE = 'MedalsBig'; - const SUBSTYLE_MedalBronze = 'MedalBronze'; - const SUBSTYLE_MedalGold = 'MedalGold'; - const SUBSTYLE_MedalGoldPerspective = 'MedalGoldPerspective'; - const SUBSTYLE_MedalNadeo = 'MedalNadeo'; - const SUBSTYLE_MedalNadeoPerspective = 'MedalNadeoPerspective'; - const SUBSTYLE_MedalSilver = 'MedalSilver'; - const SUBSTYLE_MedalSlot = 'MedalSlot'; +class Quad_MedalsBig extends Quad +{ + + /* + * Constants + */ + const STYLE = 'MedalsBig'; + const SUBSTYLE_MedalBronze = 'MedalBronze'; + const SUBSTYLE_MedalGold = 'MedalGold'; + const SUBSTYLE_MedalGoldPerspective = 'MedalGoldPerspective'; + const SUBSTYLE_MedalNadeo = 'MedalNadeo'; + const SUBSTYLE_MedalNadeoPerspective = 'MedalNadeoPerspective'; + const SUBSTYLE_MedalSilver = 'MedalSilver'; + const SUBSTYLE_MedalSlot = 'MedalSlot'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_TitleLogos.php b/libs/FML/Controls/Quads/Quad_TitleLogos.php index f97fb628..3c10dc8d 100644 --- a/libs/FML/Controls/Quads/Quad_TitleLogos.php +++ b/libs/FML/Controls/Quads/Quad_TitleLogos.php @@ -8,21 +8,24 @@ use FML\Controls\Quad; * Quad class for 'TitleLogos' 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_TitleLogos extends Quad { - /* - * Constants - */ - const STYLE = 'TitleLogos'; - const SUBSTYLE_Author = 'Author'; - const SUBSTYLE_Collection = 'Collection'; - const SUBSTYLE_Icon = 'Icon'; - const SUBSTYLE_Title = 'Title'; +class Quad_TitleLogos extends Quad +{ + + /* + * Constants + */ + const STYLE = 'TitleLogos'; + const SUBSTYLE_Author = 'Author'; + const SUBSTYLE_Collection = 'Collection'; + const SUBSTYLE_Icon = 'Icon'; + const SUBSTYLE_Title = 'Title'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_UIConstructionBullet_Buttons.php b/libs/FML/Controls/Quads/Quad_UIConstructionBullet_Buttons.php index 88288389..18396137 100644 --- a/libs/FML/Controls/Quads/Quad_UIConstructionBullet_Buttons.php +++ b/libs/FML/Controls/Quads/Quad_UIConstructionBullet_Buttons.php @@ -8,40 +8,43 @@ use FML\Controls\Quad; * Quad class for 'UIConstructionBullet_Buttons' 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_UIConstructionBullet_Buttons extends Quad { - /* - * Constants - */ - const STYLE = 'UIConstructionBullet_Buttons'; - const SUBSTYLE_AnimMode = 'AnimMode'; - const SUBSTYLE_BlocMode = 'BlocMode'; - const SUBSTYLE_BulletEditorMode = 'BulletEditorMode'; - const SUBSTYLE_Circle = 'Circle'; - const SUBSTYLE_Core = 'Core'; - const SUBSTYLE_CoreFolder = 'CoreFolder'; - const SUBSTYLE_DeltaMode = 'DeltaMode'; - const SUBSTYLE_Disc = 'Disc'; - const SUBSTYLE_ExplosionMode = 'ExplosionMode'; - const SUBSTYLE_NewBullet = 'NewBullet'; - const SUBSTYLE_NewRandomBullet = 'NewRandomBullet'; - const SUBSTYLE_Point = 'Point'; - const SUBSTYLE_Power = 'Power'; - const SUBSTYLE_PowerFolder = 'PowerFolder'; - const SUBSTYLE_PreviewMode = 'PreviewMode'; - const SUBSTYLE_RootMotionMode = 'RootMotionMode'; - const SUBSTYLE_SmokeDebris = 'SmokeDebris'; - const SUBSTYLE_SmokeDebrisFolder = 'SmokeDebrisFolder'; - const SUBSTYLE_SoundMode = 'SoundMode'; - const SUBSTYLE_SphereEmpty = 'SphereEmpty'; - const SUBSTYLE_SphereFull = 'SphereFull'; - const SUBSTYLE_Trail = 'Trail'; - const SUBSTYLE_TrailFolder = 'TrailFolder'; +class Quad_UIConstructionBullet_Buttons extends Quad +{ + + /* + * Constants + */ + const STYLE = 'UIConstructionBullet_Buttons'; + const SUBSTYLE_AnimMode = 'AnimMode'; + const SUBSTYLE_BlocMode = 'BlocMode'; + const SUBSTYLE_BulletEditorMode = 'BulletEditorMode'; + const SUBSTYLE_Circle = 'Circle'; + const SUBSTYLE_Core = 'Core'; + const SUBSTYLE_CoreFolder = 'CoreFolder'; + const SUBSTYLE_DeltaMode = 'DeltaMode'; + const SUBSTYLE_Disc = 'Disc'; + const SUBSTYLE_ExplosionMode = 'ExplosionMode'; + const SUBSTYLE_NewBullet = 'NewBullet'; + const SUBSTYLE_NewRandomBullet = 'NewRandomBullet'; + const SUBSTYLE_Point = 'Point'; + const SUBSTYLE_Power = 'Power'; + const SUBSTYLE_PowerFolder = 'PowerFolder'; + const SUBSTYLE_PreviewMode = 'PreviewMode'; + const SUBSTYLE_RootMotionMode = 'RootMotionMode'; + const SUBSTYLE_SmokeDebris = 'SmokeDebris'; + const SUBSTYLE_SmokeDebrisFolder = 'SmokeDebrisFolder'; + const SUBSTYLE_SoundMode = 'SoundMode'; + const SUBSTYLE_SphereEmpty = 'SphereEmpty'; + const SUBSTYLE_SphereFull = 'SphereFull'; + const SUBSTYLE_Trail = 'Trail'; + const SUBSTYLE_TrailFolder = 'TrailFolder'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons.php b/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons.php index 55744b9a..a768467e 100644 --- a/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons.php +++ b/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons.php @@ -8,74 +8,77 @@ use FML\Controls\Quad; * Quad class for 'UIConstruction_Buttons' 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_UIConstruction_Buttons extends Quad { - /* - * Constants - */ - const STYLE = 'UIConstruction_Buttons'; - const SUBSTYLE_ActionMaker = 'ActionMaker'; - const SUBSTYLE_Add = 'Add'; - const SUBSTYLE_AirMapping = 'AirMapping'; - const SUBSTYLE_Author = 'Author'; - const SUBSTYLE_AuthorTime = 'AuthorTime'; - const SUBSTYLE_BgEditors = 'BgEditors'; - const SUBSTYLE_BgIcons = 'BgIcons'; - const SUBSTYLE_BgMain = 'BgMain'; - const SUBSTYLE_BgTools = 'BgTools'; - const SUBSTYLE_BlockEditor = 'BlockEditor'; - const SUBSTYLE_Camera = 'Camera'; - const SUBSTYLE_Challenge = 'Challenge'; - const SUBSTYLE_CopyPaste = 'CopyPaste'; - const SUBSTYLE_DecalEditor = 'DecalEditor'; - const SUBSTYLE_Delete = 'Delete'; - const SUBSTYLE_Directory = 'Directory'; - const SUBSTYLE_Down = 'Down'; - const SUBSTYLE_Drive = 'Drive'; - const SUBSTYLE_Erase = 'Erase'; - const SUBSTYLE_FreeItems = 'FreeItems'; - const SUBSTYLE_GhostBlocks = 'GhostBlocks'; - const SUBSTYLE_Help = 'Help'; - const SUBSTYLE_Item = 'Item'; - const SUBSTYLE_Left = 'Left'; - const SUBSTYLE_MacroBlockEditor = 'MacroBlockEditor'; - const SUBSTYLE_MediaTracker = 'MediaTracker'; - const SUBSTYLE_ObjectEditor = 'ObjectEditor'; - const SUBSTYLE_OffZone = 'OffZone'; - const SUBSTYLE_Options = 'Options'; - const SUBSTYLE_Paint = 'Paint'; - const SUBSTYLE_Pick = 'Pick'; - const SUBSTYLE_Plugins = 'Plugins'; - const SUBSTYLE_Quit = 'Quit'; - const SUBSTYLE_Redo = 'Redo'; - const SUBSTYLE_Reload = 'Reload'; - const SUBSTYLE_Right = 'Right'; - const SUBSTYLE_Save = 'Save'; - const SUBSTYLE_SaveAs = 'SaveAs'; - const SUBSTYLE_ScriptEditor = 'ScriptEditor'; - const SUBSTYLE_SpotModelClearUnused = 'SpotModelClearUnused'; - const SUBSTYLE_SpotModelDuplicate = 'SpotModelDuplicate'; - const SUBSTYLE_SpotModelNew = 'SpotModelNew'; - const SUBSTYLE_SpotModelRename = 'SpotModelRename'; - const SUBSTYLE_Square = 'Square'; - const SUBSTYLE_Stats = 'Stats'; - const SUBSTYLE_Sub = 'Sub'; - const SUBSTYLE_TerrainEditor = 'TerrainEditor'; - const SUBSTYLE_TestSm = 'TestSm'; - const SUBSTYLE_Text = 'Text'; - const SUBSTYLE_Tools = 'Tools'; - const SUBSTYLE_Underground = 'Underground'; - const SUBSTYLE_Undo = 'Undo'; - const SUBSTYLE_Up = 'Up'; - const SUBSTYLE_Validate = 'Validate'; - const SUBSTYLE_Validate_Step1 = 'Validate_Step1'; - const SUBSTYLE_Validate_Step2 = 'Validate_Step2'; - const SUBSTYLE_Validate_Step3 = 'Validate_Step3'; +class Quad_UIConstruction_Buttons extends Quad +{ + + /* + * Constants + */ + const STYLE = 'UIConstruction_Buttons'; + const SUBSTYLE_ActionMaker = 'ActionMaker'; + const SUBSTYLE_Add = 'Add'; + const SUBSTYLE_AirMapping = 'AirMapping'; + const SUBSTYLE_Author = 'Author'; + const SUBSTYLE_AuthorTime = 'AuthorTime'; + const SUBSTYLE_BgEditors = 'BgEditors'; + const SUBSTYLE_BgIcons = 'BgIcons'; + const SUBSTYLE_BgMain = 'BgMain'; + const SUBSTYLE_BgTools = 'BgTools'; + const SUBSTYLE_BlockEditor = 'BlockEditor'; + const SUBSTYLE_Camera = 'Camera'; + const SUBSTYLE_Challenge = 'Challenge'; + const SUBSTYLE_CopyPaste = 'CopyPaste'; + const SUBSTYLE_DecalEditor = 'DecalEditor'; + const SUBSTYLE_Delete = 'Delete'; + const SUBSTYLE_Directory = 'Directory'; + const SUBSTYLE_Down = 'Down'; + const SUBSTYLE_Drive = 'Drive'; + const SUBSTYLE_Erase = 'Erase'; + const SUBSTYLE_FreeItems = 'FreeItems'; + const SUBSTYLE_GhostBlocks = 'GhostBlocks'; + const SUBSTYLE_Help = 'Help'; + const SUBSTYLE_Item = 'Item'; + const SUBSTYLE_Left = 'Left'; + const SUBSTYLE_MacroBlockEditor = 'MacroBlockEditor'; + const SUBSTYLE_MediaTracker = 'MediaTracker'; + const SUBSTYLE_ObjectEditor = 'ObjectEditor'; + const SUBSTYLE_OffZone = 'OffZone'; + const SUBSTYLE_Options = 'Options'; + const SUBSTYLE_Paint = 'Paint'; + const SUBSTYLE_Pick = 'Pick'; + const SUBSTYLE_Plugins = 'Plugins'; + const SUBSTYLE_Quit = 'Quit'; + const SUBSTYLE_Redo = 'Redo'; + const SUBSTYLE_Reload = 'Reload'; + const SUBSTYLE_Right = 'Right'; + const SUBSTYLE_Save = 'Save'; + const SUBSTYLE_SaveAs = 'SaveAs'; + const SUBSTYLE_ScriptEditor = 'ScriptEditor'; + const SUBSTYLE_SpotModelClearUnused = 'SpotModelClearUnused'; + const SUBSTYLE_SpotModelDuplicate = 'SpotModelDuplicate'; + const SUBSTYLE_SpotModelNew = 'SpotModelNew'; + const SUBSTYLE_SpotModelRename = 'SpotModelRename'; + const SUBSTYLE_Square = 'Square'; + const SUBSTYLE_Stats = 'Stats'; + const SUBSTYLE_Sub = 'Sub'; + const SUBSTYLE_TerrainEditor = 'TerrainEditor'; + const SUBSTYLE_TestSm = 'TestSm'; + const SUBSTYLE_Text = 'Text'; + const SUBSTYLE_Tools = 'Tools'; + const SUBSTYLE_Underground = 'Underground'; + const SUBSTYLE_Undo = 'Undo'; + const SUBSTYLE_Up = 'Up'; + const SUBSTYLE_Validate = 'Validate'; + const SUBSTYLE_Validate_Step1 = 'Validate_Step1'; + const SUBSTYLE_Validate_Step2 = 'Validate_Step2'; + const SUBSTYLE_Validate_Step3 = 'Validate_Step3'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons2.php b/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons2.php index f9249629..f638d4b4 100644 --- a/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons2.php +++ b/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons2.php @@ -8,29 +8,32 @@ use FML\Controls\Quad; * Quad class for 'UIConstruction_Buttons2' 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_UIConstruction_Buttons2 extends Quad { - /* - * Constants - */ - const STYLE = 'UIConstruction_Buttons2'; - const SUBSTYLE_AirMapping = 'AirMapping'; - const SUBSTYLE_BlockEditor = 'BlockEditor'; - const SUBSTYLE_Copy = 'Copy'; - const SUBSTYLE_Cut = 'Cut'; - const SUBSTYLE_GhostBlocks = 'GhostBlocks'; - const SUBSTYLE_KeysAdd = 'KeysAdd'; - const SUBSTYLE_KeysCopy = 'KeysCopy'; - const SUBSTYLE_KeysDelete = 'KeysDelete'; - const SUBSTYLE_KeysPaste = 'KeysPaste'; - const SUBSTYLE_New = 'New'; - const SUBSTYLE_Open = 'Open'; - const SUBSTYLE_Symmetry = 'Symmetry'; +class Quad_UIConstruction_Buttons2 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'UIConstruction_Buttons2'; + const SUBSTYLE_AirMapping = 'AirMapping'; + const SUBSTYLE_BlockEditor = 'BlockEditor'; + const SUBSTYLE_Copy = 'Copy'; + const SUBSTYLE_Cut = 'Cut'; + const SUBSTYLE_GhostBlocks = 'GhostBlocks'; + const SUBSTYLE_KeysAdd = 'KeysAdd'; + const SUBSTYLE_KeysCopy = 'KeysCopy'; + const SUBSTYLE_KeysDelete = 'KeysDelete'; + const SUBSTYLE_KeysPaste = 'KeysPaste'; + const SUBSTYLE_New = 'New'; + const SUBSTYLE_Open = 'Open'; + const SUBSTYLE_Symmetry = 'Symmetry'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php b/libs/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php index 1852184e..3cc144fc 100644 --- a/libs/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php +++ b/libs/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php @@ -8,38 +8,41 @@ use FML\Controls\Quad; * Quad class for 'UiSMSpectatorScoreBig' 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_UiSMSpectatorScoreBig extends Quad { - /* - * Constants - */ - const STYLE = 'UiSMSpectatorScoreBig'; - CONST SUBSTYLE_BotLeft = 'BotLeft'; - CONST SUBSTYLE_BotLeftGlass = 'BotLeftGlass'; - CONST SUBSTYLE_BotRight = 'BotRight'; - CONST SUBSTYLE_BotRightGlass = 'BotRightGlass'; - CONST SUBSTYLE_CenterShield = 'CenterShield'; - CONST SUBSTYLE_CenterShieldSmall = 'CenterShieldSmall'; - CONST SUBSTYLE_HandleLeft = 'HandleLeft'; - CONST SUBSTYLE_HandleRight = 'HandleRight'; - CONST SUBSTYLE_PlayerGlass = 'PlayerGlass'; - CONST SUBSTYLE_PlayerIconBg = 'PlayerIconBg'; - CONST SUBSTYLE_PlayerJunction = 'PlayerJunction'; - CONST SUBSTYLE_PlayerSlot = 'PlayerSlot'; - CONST SUBSTYLE_PlayerSlotCenter = 'PlayerSlotCenter'; - CONST SUBSTYLE_PlayerSlotRev = 'PlayerSlotRev'; - CONST SUBSTYLE_PlayerSlotSmall = 'PlayerSlotSmall'; - CONST SUBSTYLE_PlayerSlotSmallRev = 'PlayerSlotSmallRev'; - CONST SUBSTYLE_TableBgHoriz = 'TableBgHoriz'; - CONST SUBSTYLE_TableBgVert = 'TableBgVert'; - CONST SUBSTYLE_Top = 'Top'; - CONST SUBSTYLE_UIRange1Bg = 'UIRange1Bg'; - CONST SUBSTYLE_UIRange2Bg = 'UIRange2Bg'; +class Quad_UiSMSpectatorScoreBig extends Quad +{ + + /* + * Constants + */ + const STYLE = 'UiSMSpectatorScoreBig'; + CONST SUBSTYLE_BotLeft = 'BotLeft'; + CONST SUBSTYLE_BotLeftGlass = 'BotLeftGlass'; + CONST SUBSTYLE_BotRight = 'BotRight'; + CONST SUBSTYLE_BotRightGlass = 'BotRightGlass'; + CONST SUBSTYLE_CenterShield = 'CenterShield'; + CONST SUBSTYLE_CenterShieldSmall = 'CenterShieldSmall'; + CONST SUBSTYLE_HandleLeft = 'HandleLeft'; + CONST SUBSTYLE_HandleRight = 'HandleRight'; + CONST SUBSTYLE_PlayerGlass = 'PlayerGlass'; + CONST SUBSTYLE_PlayerIconBg = 'PlayerIconBg'; + CONST SUBSTYLE_PlayerJunction = 'PlayerJunction'; + CONST SUBSTYLE_PlayerSlot = 'PlayerSlot'; + CONST SUBSTYLE_PlayerSlotCenter = 'PlayerSlotCenter'; + CONST SUBSTYLE_PlayerSlotRev = 'PlayerSlotRev'; + CONST SUBSTYLE_PlayerSlotSmall = 'PlayerSlotSmall'; + CONST SUBSTYLE_PlayerSlotSmallRev = 'PlayerSlotSmallRev'; + CONST SUBSTYLE_TableBgHoriz = 'TableBgHoriz'; + CONST SUBSTYLE_TableBgVert = 'TableBgVert'; + CONST SUBSTYLE_Top = 'Top'; + CONST SUBSTYLE_UIRange1Bg = 'UIRange1Bg'; + CONST SUBSTYLE_UIRange2Bg = 'UIRange2Bg'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/TextEdit.php b/libs/FML/Controls/TextEdit.php new file mode 100644 index 00000000..e1241e05 --- /dev/null +++ b/libs/FML/Controls/TextEdit.php @@ -0,0 +1,452 @@ + + * @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; + } + +} diff --git a/libs/FML/Controls/Video.php b/libs/FML/Controls/Video.php index 94f94bdd..614a9b92 100644 --- a/libs/FML/Controls/Video.php +++ b/libs/FML/Controls/Video.php @@ -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 Video extends Control implements Playable, Scriptable { - /* - * Protected properties - */ - protected $tagName = 'video'; - protected $data = null; - protected $dataId = null; - protected $play = null; - protected $looping = true; - protected $music = null; - protected $volume = 1.; - protected $scriptEvents = null; +class Video extends Control implements Playable, Scriptable +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlMediaPlayer'; - } + /** + * @var string $data Data url + */ + protected $data = null; - /** - * @see \FML\Types\Playable::setData() - */ - public function setData($data) { - $this->data = (string)$data; - return $this; - } + /** + * @var string $dataId Data id + */ + protected $dataId = null; - /** - * @see \FML\Types\Playable::setDataId() - */ - public function setDataId($dataId) { - $this->dataId = (string)$dataId; - return $this; - } + /** + * @var bool $play Play automaticcaly + */ + protected $play = null; - /** - * @see \FML\Types\Playable::setPlay() - */ - public function setPlay($play) { - $this->play = ($play ? 1 : 0); - return $this; - } + /** + * @var bool $looping Looping + */ + protected $looping = true; - /** - * @see \FML\Types\Playable::setLooping() - */ - public function setLooping($looping) { - $this->looping = ($looping ? 1 : 0); - return $this; - } + /** + * @var bool $music Music type + */ + protected $music = null; - /** - * @see \FML\Types\Playable::setMusic() - */ - public function setMusic($music) { - $this->music = ($music ? 1 : 0); - return $this; - } + /** + * @var float $volume Volume + */ + protected $volume = 1.; - /** - * @see \FML\Types\Playable::setVolume() - */ - public function setVolume($volume) { - $this->volume = (float)$volume; - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; + + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; + + /** + * @see Playable::getData() + */ + public function getData() + { + return $this->data; + } + + /** + * @see Playable::setData() + */ + public function setData($data) + { + $this->data = (string)$data; + return $this; + } + + /** + * @see Playable::getDataId() + */ + public function getDataId() + { + return $this->dataId; + } + + /** + * @see Playable::setDataId() + */ + public function setDataId($dataId) + { + $this->dataId = (string)$dataId; + return $this; + } + + /** + * @see Playable::getPlay() + */ + public function getPlay() + { + return $this->play; + } + + /** + * @see Playable::setPlay() + */ + public function setPlay($play) + { + $this->play = (bool)$play; + return $this; + } + + /** + * @see Playable::getLooping() + */ + public function getLooping() + { + return $this->looping; + } + + /** + * @see Playable::setLooping() + */ + public function setLooping($looping) + { + $this->looping = (bool)$looping; + return $this; + } + + /** + * @see Playable::getMusic() + */ + public function getMusic() + { + return $this->music; + } + + /** + * @see Playable::setMusic() + */ + public function setMusic($music) + { + $this->music = (bool)$music; + return $this; + } + + /** + * @see Playable::getVolume() + */ + public function getVolume() + { + return $this->volume; + } + + /** + * @see Playable::setVolume() + */ + public function setVolume($volume) + { + $this->volume = (float)$volume; + 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 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) { + $domElement->setAttribute("data", $this->data); + } + if ($this->dataId) { + $domElement->setAttribute("dataid", $this->dataId); + } + if ($this->play) { + $domElement->setAttribute("play", 1); + } + if (!$this->looping) { + $domElement->setAttribute("looping", 0); + } + if ($this->music) { + $domElement->setAttribute("music", 1); + } + if ($this->volume != 1.) { + $domElement->setAttribute("volume", $this->volume); + } + 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)); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->data) { - $xmlElement->setAttribute('data', $this->data); - } - if ($this->play) { - $xmlElement->setAttribute('play', $this->play); - } - if (!$this->looping) { - $xmlElement->setAttribute('looping', $this->looping); - } - if ($this->music) { - $xmlElement->setAttribute('music', $this->music); - } - if ($this->volume != 1.) { - $xmlElement->setAttribute('volume', $this->volume); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - return $xmlElement; - } } diff --git a/libs/FML/CustomUI.php b/libs/FML/CustomUI.php index a4137684..831b8678 100644 --- a/libs/FML/CustomUI.php +++ b/libs/FML/CustomUI.php @@ -6,187 +6,323 @@ 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 - */ - 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; +class CustomUI +{ - /** - * Create a new CustomUI object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var bool $globalVisible If the UI should be shown at all + */ + protected $globalVisible = null; - /** - * Set XML encoding - * - * @param string $encoding XML encoding - * @return static - */ - public function setXMLEncoding($encoding) { - $this->encoding = (string)$encoding; - return $this; - } + /** + * @var bool $challengeInfoVisible If the challenge info should be shown + */ + protected $challengeInfoVisible = null; - /** - * Set showing of notices - * - * @param bool $visible Whether notices should be shown - * @return static - */ - public function setNoticeVisible($visible) { - $this->noticeVisible = $visible; - return $this; - } + /** + * @var bool $chatVisible If the chat should be shown + */ + protected $chatVisible = null; - /** - * 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; - } + /** + * @var bool $checkpointListVisible If the checkpoint list should be shown + */ + protected $checkpointListVisible = null; - /** - * 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; - } + /** + * @var bool $netInfosVisible If the net infos should be shown + */ + protected $netInfosVisible = null; - /** - * 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; - } + /** + * @var bool $noticeVisible If notices should be shown + */ + protected $noticeVisible = null; - /** - * 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; - } + /** + * @var bool $roundScoresVisible If round scores should be shown + */ + protected $roundScoresVisible = null; - /** - * 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; - } + /** + * @var bool $scoretableVisible If the score table should be shown + */ + protected $scoretableVisible = null; - /** - * 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; - } + /** + * Create a new CustomUI + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Set global showing - * - * @param bool $visible Whether the UI should be disabled completely - * @return static - */ - public function setGlobalVisible($visible) { - $this->globalVisible = $visible; - return $this; - } + /** + * Get global visibility + * + * @api + * @return bool + */ + public function getGlobalVisible() + { + return $this->globalVisible; + } - /** - * Render the XML document - * - * @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); - $domDocument->xmlStandalone = true; - } - $xmlElement = $domDocument->createElement($this->tagName); - if (!$isChild) { - $domDocument->appendChild($xmlElement); - } - $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); - } - if ($isChild) { - return $xmlElement; - } - return $domDocument; - } + /** + * Set global visibility + * + * @api + * @param bool $visible If the UI should be shown at all + * @return static + */ + public function setGlobalVisible($visible) + { + $this->globalVisible = $visible; + return $this; + } - /** - * Get string representation - * - * @return string - */ - public function __toString() { - return $this->render()->saveXML(); - } + /** + * 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 + * + * @return \DOMDocument + */ + public function renderStandalone() + { + $domDocument = new \DOMDocument("1.0", "utf-8"); + $domDocument->xmlStandalone = true; + + $domElement = $this->render($domDocument); + $domDocument->appendChild($domElement); + + return $domDocument; + } + + /** + * 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; + } + + $settingDomElement = $domDocument->createElement($setting); + $settingDomElement->setAttribute("visible", ($value ? 1 : 0)); + $domElement->appendChild($settingDomElement); + } + + return $domElement; + } + + /** + * Get string representation + * + * @return string + */ + public function __toString() + { + return $this->renderStandalone() + ->saveXML(); + } + + /** + * Get associative array of all CustomUI settings + * + * @return array + */ + 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 + ); + } - /** - * Get associative array of all CustomUI settings - * - * @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; - } } diff --git a/libs/FML/Elements/Dico.php b/libs/FML/Elements/Dico.php index f948d2ba..a7f809c5 100644 --- a/libs/FML/Elements/Dico.php +++ b/libs/FML/Elements/Dico.php @@ -6,261 +6,276 @@ namespace FML\Elements; * Dictionary 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 */ -class Dico { - /** - * Czech language - * - * @var string - */ - const LANG_CZECH = 'cz'; +class Dico +{ - /** - * Danish language - * - * @var string - */ - const LANG_DANISH = 'da'; + /** + * Czech language + * + * @var string + */ + const LANG_CZECH = 'cz'; - /** - * German language - * - * @var string - */ - const LANG_GERMAN = 'de'; + /** + * Danish language + * + * @var string + */ + const LANG_DANISH = 'da'; - /** - * English language - * - * @var string - */ - const LANG_ENGLISH = 'en'; + /** + * German language + * + * @var string + */ + const LANG_GERMAN = 'de'; - /** - * Spanish language - * - * @var string - */ - const LANG_SPANISH = 'es'; + /** + * English language + * + * @var string + */ + const LANG_ENGLISH = 'en'; - /** - * French language - * - * @var string - */ - const LANG_FRENCH = 'fr'; + /** + * Spanish language + * + * @var string + */ + const LANG_SPANISH = 'es'; - /** - * Hungarian language - * - * @var string - */ - const LANG_HUNGARIAN = 'hu'; + /** + * French language + * + * @var string + */ + const LANG_FRENCH = 'fr'; - /** - * Italian language - * - * @var string - */ - const LANG_ITALIAN = 'it'; + /** + * Hungarian language + * + * @var string + */ + const LANG_HUNGARIAN = 'hu'; - /** - * Japanese language - * - * @var string - */ - const LANG_JAPANESE = 'jp'; + /** + * Italian language + * + * @var string + */ + const LANG_ITALIAN = 'it'; - /** - * Korean language - * - * @var string - */ - const LANG_KOREAN = 'kr'; + /** + * Japanese language + * + * @var string + */ + const LANG_JAPANESE = 'jp'; - /** - * Norwegian language - * - * @var string - */ - const LANG_NORWEGIAN = 'nb'; + /** + * Korean language + * + * @var string + */ + const LANG_KOREAN = 'kr'; - /** - * Dutch language - * - * @var string - */ - const LANG_DUTCH = 'nl'; + /** + * Norwegian language + * + * @var string + */ + const LANG_NORWEGIAN = 'nb'; - /** - * Polish language - * - * @var string - */ - const LANG_POLISH = 'pl'; + /** + * Dutch language + * + * @var string + */ + const LANG_DUTCH = 'nl'; - /** - * Portuguese language - * - * @var string - */ - const LANG_PORTUGUESE = 'pt'; + /** + * Polish language + * + * @var string + */ + const LANG_POLISH = 'pl'; - /** - * Brazilian Portuguese language - * - * @var string - */ - const LANG_BRAZILIAN_PORTUGUESE = 'pt_BR'; + /** + * Portuguese language + * + * @var string + */ + const LANG_PORTUGUESE = 'pt'; - /** - * Romanian language - * - * @var string - */ - const LANG_ROMANIAN = 'ro'; + /** + * Brazilian Portuguese language + * + * @var string + */ + const LANG_BRAZILIAN_PORTUGUESE = 'pt_BR'; - /** - * Russian language - * - * @var string - */ - const LANG_RUSSIAN = 'ru'; + /** + * Romanian language + * + * @var string + */ + const LANG_ROMANIAN = 'ro'; - /** - * Slovak language - * - * @var string - */ - const LANG_SLOVAK = 'sk'; + /** + * Russian language + * + * @var string + */ + const LANG_RUSSIAN = 'ru'; - /** - * Turkish language - * - * @var string - */ - const LANG_TURKISH = 'tr'; + /** + * Slovak language + * + * @var string + */ + const LANG_SLOVAK = 'sk'; - /** - * Chinese language - * - * @var string - */ - const LANG_CHINESE = 'zh'; + /** + * Turkish language + * + * @var string + */ + const LANG_TURKISH = 'tr'; - /* - * Protected properties - */ - protected $tagName = 'dico'; - protected $entries = array(); + /** + * Chinese language + * + * @var string + */ + const LANG_CHINESE = 'zh'; - /** - * Create a new Dictionary object - * - * @return static - */ - public static function create() { - return new static(); - } + /* + * Protected properties + */ + protected $entries = array(); - /** - * Set the translatable entry for the specific language - * - * @param string $language Language id - * @param string $entryId Entry id - * @param string $entryValue Translated entry value - * @return static - */ - public function setEntry($language, $entryId, $entryValue) { - $language = (string)$language; - $entryId = (string)$entryId; - $entryValue = (string)$entryValue; - if (!isset($this->entries[$language]) && $entryValue) { - $this->entries[$language] = array(); - } - if ($entryValue) { - $this->entries[$language][$entryId] = $entryValue; - } else { - if (isset($this->entries[$language][$entryId])) { - unset($this->entries[$language][$entryId]); - } - } - return $this; - } + /** + * Create a new Dico + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Remove entries of the given id - * - * @param string $entryId Entry id that should be removed - * @param string $language (optional) Only remove entries of the given language - * @return static - */ - public function removeEntry($entryId, $language = null) { - $entryId = (string)$entryId; - if ($language) { - $language = (string)$language; - if (isset($this->entries[$language])) { - unset($this->entries[$language][$entryId]); - } - } else { - foreach ($this->entries as $language => $entries) { - if (isset($entries[$entryId])) { - unset($entries[$language][$entryId]); - } - } - } - return $this; - } + /** + * Get the translatable entry + * + * @api + * @param string $language Language id + * @param string $entryId Entry id + * @return string + */ + public function getEntry($language, $entryId) + { + if (isset($this->entries[$language]) && isset($this->entries[$language][$entryId])) { + return $this->entries[$language][$entryId]; + } + return null; + } - /** - * Remove entries of the given language - * - * @param string $language Language which entries should be removed - * @param string $entryId (optional) Only remove the given entry id - * @return static - */ - public function removeLanguage($language, $entryId = null) { - $language = (string)$language; - if (isset($this->entries[$language])) { - if ($entryId) { - $entryId = (string)$entryId; - unset($this->entries[$language][$entryId]); - } else { - unset($this->entries[$language]); - } - } - return $this; - } + /** + * Set the translatable entry for the specific language + * + * @api + * @param string $language Language id + * @param string $entryId Entry id + * @param string $entryValue Translated entry value + * @return static + */ + public function setEntry($language, $entryId, $entryValue) + { + $language = (string)$language; + $entryId = (string)$entryId; + $entryValue = (string)$entryValue; + if (!isset($this->entries[$language]) && $entryValue) { + $this->entries[$language] = array(); + } + if ($entryValue) { + $this->entries[$language][$entryId] = $entryValue; + } else { + if (isset($this->entries[$language][$entryId])) { + unset($this->entries[$language][$entryId]); + } + } + return $this; + } - /** - * Remove all entries from the Dictionary - * - * @return static - */ - public function removeEntries() { - $this->entries = array(); - return $this; - } + /** + * Remove entries of the given id + * + * @api + * @param string $entryId Entry id that should be removed + * @return static + */ + public function removeEntry($entryId) + { + $entryId = (string)$entryId; + foreach ($this->entries as $language => $entries) { + if (isset($this->entries[$language][$entryId])) { + unset($this->entries[$language][$entryId]); + } + } + return $this; + } + + /** + * Remove entries of the given language + * + * @api + * @param string $language Language which entries should be removed + * @return static + */ + public function removeLanguage($language) + { + $language = (string)$language; + if (isset($this->entries[$language])) { + unset($this->entries[$language]); + } + return $this; + } + + /** + * Remove all entries + * + * @api + * @return static + */ + public function removeAllEntries() + { + $this->entries = array(); + return $this; + } + + /** + * Render the Dico + * + * @param \DOMDocument $domDocument DOMDocument for which the Dico should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("dico"); + foreach ($this->entries as $language => $entries) { + $languageElement = $domDocument->createElement("language"); + $languageElement->setAttribute("id", $language); + foreach ($entries as $entryId => $entryValue) { + $entryElement = $domDocument->createElement($entryId, $entryValue); + $languageElement->appendChild($entryElement); + } + $domElement->appendChild($languageElement); + } + return $domElement; + } - /** - * Render the Dico XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the Dico XML element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - foreach ($this->entries as $language => $entries) { - $languageElement = $domDocument->createElement('language'); - $languageElement->setAttribute('id', $language); - foreach ($entries as $entryId => $entryValue) { - $entryElement = $domDocument->createElement($entryId, $entryValue); - $languageElement->appendChild($entryElement); - } - $xmlElement->appendChild($languageElement); - } - return $xmlElement; - } } diff --git a/libs/FML/Elements/Format.php b/libs/FML/Elements/Format.php index 41649fc5..3631e434 100644 --- a/libs/FML/Elements/Format.php +++ b/libs/FML/Elements/Format.php @@ -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 - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Format implements BgColorable, Renderable, Styleable, TextFormatable { - /* - * Protected properties - */ - protected $tagName = 'format'; - protected $bgColor = null; - protected $style = null; - protected $textSize = -1; - protected $textFont = null; - protected $textColor = null; - protected $focusAreaColor1 = null; - protected $focusAreaColor2 = null; +class Format implements BackgroundColorable, Renderable, Styleable, TextFormatable +{ - /** - * Create a new Format Element - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var string $backgroundColor Background color + */ + protected $backgroundColor = null; - /** - * @see \FML\Types\BgColorable::setBgColor() - */ - public function setBgColor($bgColor) { - $this->bgColor = (string)$bgColor; - return $this; - } + /** + * @var string $style Style + */ + protected $style = null; - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - return $this; - } + /** + * @var int $textSize Text size + */ + protected $textSize = null; - /** - * @see \FML\Types\TextFormatable::setTextSize() - */ - public function setTextSize($textSize) { - $this->textSize = (int)$textSize; - return $this; - } + /** + * @var string $textFont Text font + */ + protected $textFont = null; - /** - * @see \FML\Types\TextFormatable::setTextFont() - */ - public function setTextFont($textFont) { - $this->textFont = (string)$textFont; - return $this; - } + /** + * @var string $textColor Text color + */ + protected $textColor = null; - /** - * @see \FML\Types\TextFormatable::setTextColor() - */ - public function setTextColor($textColor) { - $this->textColor = (string)$textColor; - return $this; - } + /** + * @var string $areaColor Area color + */ + protected $areaColor = null; - /** - * @see \FML\Types\TextFormatable::setAreaColor() - */ - public function setAreaColor($areaColor) { - $this->focusAreaColor1 = (string)$areaColor; - return $this; - } + /** + * @var string $focusAreaColor Focus area color + */ + protected $focusAreaColor = null; - /** - * @see \FML\Types\TextFormatable::setAreaFocusColor() - */ - public function setAreaFocusColor($areaFocusColor) { - $this->focusAreaColor2 = (string)$areaFocusColor; - return $this; - } + /** + * Create a new Format + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } + + /** + * @see BgColorable::getBackgroundColor() + */ + public function getBackgroundColor() + { + return $this->backgroundColor; + } + + /** + * @see BgColorable::setBackgroundColor() + */ + public function setBackgroundColor($backgroundColor) + { + $this->backgroundColor = (string)$backgroundColor; + return $this; + } + + /** + * @see Styleable::getStyle() + */ + public function getStyle() + { + return $this->style; + } + + /** + * @see Styleable::setStyle() + */ + public function setStyle($style) + { + $this->style = (string)$style; + return $this; + } + + /** + * @see TextFormatable::getTextSize() + */ + public function getTextSize() + { + return $this->textSize; + } + + /** + * @see TextFormatable::setTextSize() + */ + public function setTextSize($textSize) + { + $this->textSize = (int)$textSize; + return $this; + } + + /** + * @see TextFormatable::getTextFont() + */ + public function getTextFont() + { + return $this->textFont; + } + + /** + * @see TextFormatable::setTextFont() + */ + public function setTextFont($textFont) + { + $this->textFont = (string)$textFont; + return $this; + } + + /** + * @see TextFormatable::getTextColor() + */ + public function getTextColor() + { + return $this->textColor; + } + + /** + * @see TextFormatable::setTextColor() + */ + public function setTextColor($textColor) + { + $this->textColor = (string)$textColor; + return $this; + } + + /** + * @see TextFormatable::getAreaColor() + */ + public function getAreaColor() + { + return $this->areaColor; + } + + /** + * @see TextFormatable::setAreaColor() + */ + public function setAreaColor($areaColor) + { + $this->areaColor = (string)$areaColor; + return $this; + } + + /** + * @see TextFormatable::getAreaFocusColor() + */ + public function getAreaFocusColor() + { + return $this->focusAreaColor; + } + + /** + * @see TextFormatable::setAreaFocusColor() + */ + public function setAreaFocusColor($areaFocusColor) + { + $this->focusAreaColor = (string)$areaFocusColor; + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("format"); + if ($this->backgroundColor) { + $domElement->setAttribute("bgcolor", $this->backgroundColor); + } + if ($this->style) { + $domElement->setAttribute("style", $this->style); + } + if ($this->textSize) { + $domElement->setAttribute("textsize", $this->textSize); + } + if ($this->textFont) { + $domElement->setAttribute("textfont", $this->textFont); + } + if ($this->textColor) { + $domElement->setAttribute("textcolor", $this->textColor); + } + if ($this->areaColor) { + $domElement->setAttribute("focusareacolor1", $this->areaColor); + } + if ($this->focusAreaColor) { + $domElement->setAttribute("focusareacolor2", $this->focusAreaColor); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $formatXmlElement = $domDocument->createElement($this->tagName); - if ($this->bgColor) { - $formatXmlElement->setAttribute('bgcolor', $this->bgColor); - } - if ($this->style) { - $formatXmlElement->setAttribute('style', $this->style); - } - if ($this->textSize >= 0) { - $formatXmlElement->setAttribute('textsize', $this->textSize); - } - if ($this->textFont) { - $formatXmlElement->setAttribute('textfont', $this->textFont); - } - if ($this->textColor) { - $formatXmlElement->setAttribute('textcolor', $this->textColor); - } - if ($this->focusAreaColor1) { - $formatXmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1); - } - if ($this->focusAreaColor2) { - $formatXmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2); - } - return $formatXmlElement; - } } diff --git a/libs/FML/Elements/FrameModel.php b/libs/FML/Elements/FrameModel.php index 19ff4433..152a5c37 100644 --- a/libs/FML/Elements/FrameModel.php +++ b/libs/FML/Elements/FrameModel.php @@ -3,6 +3,7 @@ namespace FML\Elements; use FML\Types\Container; +use FML\Types\Identifiable; use FML\Types\Renderable; use FML\UniqueID; @@ -10,103 +11,172 @@ use FML\UniqueID; * Class representing a Frame Model * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class FrameModel implements Container, Renderable { - /* - * Protected properties - */ - protected $tagName = 'framemodel'; - protected $modelId = null; - /** @var Renderable[] $children */ - protected $children = array(); - /** @var Format $format */ - protected $format = null; +class FrameModel implements Container, Identifiable, Renderable +{ - /** - * Set Model id - * - * @param string $modelId Model id - * @return static - */ - public function setId($modelId) { - $this->modelId = (string)$modelId; - return $this; - } + /** + * @var string $modelId Model id + */ + protected $modelId = null; - /** - * Get Model id - * - * @return string - */ - public function getId() { - return $this->modelId; - } + /** + * @var Renderable[] $children Children + */ + protected $children = array(); - /** - * Assign an id if necessary - * - * @return string - */ - public function checkId() { - if (!$this->modelId) { - $this->setId(UniqueID::create()); - } - return $this; - } + /** + * @var Format $format Format + */ + protected $format = null; - /** - * @see \FML\Types\Container::add() - */ - public function add(Renderable $childElement) { - if (!in_array($childElement, $this->children, true)) { - array_push($this->children, $childElement); - } - return $this; - } + /** + * Create a new Frame Model + * + * @api + * @param string $modelId Model id + * @param Renderable[] $children Children + * @return static + */ + public static function create($modelId = null, array $children = null) + { + return new static($modelId, $children); + } - /** - * @see \FML\Types\Container::removeChildren() - */ - public function removeChildren() { - $this->children = array(); - return $this; - } + /** + * Construct a new Frame Model + * + * @api + * @param string $modelId Model id + * @param Renderable[] $children Children + */ + public function __construct($modelId = null, array $children = null) + { + if ($modelId) { + $this->setId($modelId); + } + if ($children) { + $this->addChildren($children); + } + } - /** - * @see \FML\Types\Container::setFormat() - */ - public function setFormat(Format $format) { - $this->format = $format; - return $this; - } + /** + * @see Identifiable::getId() + */ + public function getId() + { + if (!$this->modelId) { + return $this->createId(); + } + return $this->modelId; + } - /** - * @see \FML\Types\Container::getFormat() - */ - public function getFormat($createIfEmpty = true) { - if (!$this->format && $createIfEmpty) { - $this->setFormat(new Format()); - } - return $this->format; - } + /** + * @see Identifiable::setId() + */ + public function setId($modelId) + { + $this->modelId = (string)$modelId; + return $this; + } + + /** + * @see Identifiable::checkId() + */ + public function checkId() + { + return UniqueID::check($this); + } + + /** + * Create a new model id + * + * @return string + */ + protected function createId() + { + $modelId = UniqueID::create(); + $this->setId($modelId); + return $this->getId(); + } + + /** + * @see Container::getChildren() + */ + public function getChildren() + { + return $this->children; + } + + /** + * @see Container::addChild() + */ + public function addChild(Renderable $childElement) + { + if (!in_array($childElement, $this->children, true)) { + array_push($this->children, $childElement); + } + return $this; + } + + /** + * @see Container::addChildren() + */ + public function addChildren(array $children) + { + foreach ($children as $child) { + $this->addChild($child); + } + return $this; + } + + /** + * @see Container::removeAllChildren() + */ + public function removeAllChildren() + { + $this->children = array(); + return $this; + } + + /** + * @see Container::getFormat() + */ + public function getFormat() + { + return $this->format; + } + + /** + * @see Container::setFormat() + */ + public function setFormat(Format $format = null) + { + $this->format = $format; + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("framemodel"); + $domElement->setAttribute("id", $this->getId()); + + if ($this->format) { + $formatElement = $this->format->render($domDocument); + $domElement->appendChild($formatElement); + } + + foreach ($this->children as $child) { + $childElement = $child->render($domDocument); + $domElement->appendChild($childElement); + } + + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - $this->checkId(); - $xmlElement->setAttribute('id', $this->getId()); - if ($this->format) { - $formatXml = $this->format->render($domDocument); - $xmlElement->appendChild($formatXml); - } - foreach ($this->children as $child) { - $childElement = $child->render($domDocument); - $xmlElement->appendChild($childElement); - } - return $xmlElement; - } } diff --git a/libs/FML/Elements/Including.php b/libs/FML/Elements/Including.php index 4d5979ef..b984cf65 100644 --- a/libs/FML/Elements/Including.php +++ b/libs/FML/Elements/Including.php @@ -8,56 +8,76 @@ use FML\Types\Renderable; * Include 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 */ -class Including implements Renderable { - /* - * Protected properties - */ - protected $tagName = 'include'; - protected $url = null; +class Including implements Renderable +{ - /** - * Create a new Include object - * - * @param string $url (optional) Include url - * @return static - */ - public static function create($url = null) { - return new static($url); - } + /** + * @var string $url Include url + */ + protected $url = null; - /** - * Construct a new Include object - * - * @param string $url (optional) Include url - */ - public function __construct($url = null) { - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * Create a new Include + * + * @api + * @param string $url (optional) Include url + * @return static + */ + public static function create($url = null) + { + return new static($url); + } - /** - * Set url - * - * @param string $url Include url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new Include + * + * @api + * @param string $url (optional) Include url + */ + public function __construct($url = null) + { + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the url + * + * @api + * @param string $url Include url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("include"); + if ($this->url) { + $domElement->setAttribute("url", $this->url); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - if ($this->url) { - $xmlElement->setAttribute('url', $this->url); - } - return $xmlElement; - } } diff --git a/libs/FML/Elements/Music.php b/libs/FML/Elements/Music.php index 1daefc9c..3cab9dd4 100644 --- a/libs/FML/Elements/Music.php +++ b/libs/FML/Elements/Music.php @@ -8,56 +8,76 @@ use FML\Types\Renderable; * Music 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 */ -class Music implements Renderable { - /* - * Protected properties - */ - protected $tagName = 'music'; - protected $data = null; +class Music implements Renderable +{ - /** - * Create a new Music object - * - * @param string $data (optional) Media url - * @return static - */ - public static function create($data = null) { - return new static($data); - } + /** + * @var string $data Media url + */ + protected $data = null; - /** - * Construct a new Music object - * - * @param string $data (optional) Media url - */ - public function __construct($data = null) { - if ($data !== null) { - $this->setData($data); - } - } + /** + * Create a new Music + * + * @api + * @param string $data (optional) Media url + * @return static + */ + public static function create($data = null) + { + return new static($data); + } - /** - * Set data url - * - * @param string $data Data url - * @return static - */ - public function setData($data) { - $this->data = (string)$data; - return $this; - } + /** + * Construct a new Music + * + * @api + * @param string $data (optional) Media url + */ + public function __construct($data = null) + { + if ($data) { + $this->setData($data); + } + } + + /** + * Get the media url + * + * @api + * @return string + */ + public function getData() + { + return $this->data; + } + + /** + * Set the media url + * + * @api + * @param string $data Media url + * @return static + */ + public function setData($data) + { + $this->data = (string)$data; + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("music"); + if ($this->data) { + $domElement->setAttribute("data", $this->data); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - if ($this->data) { - $xmlElement->setAttribute('data', $this->data); - } - return $xmlElement; - } } diff --git a/libs/FML/Elements/SimpleScript.php b/libs/FML/Elements/SimpleScript.php index 871c250d..dc271be2 100644 --- a/libs/FML/Elements/SimpleScript.php +++ b/libs/FML/Elements/SimpleScript.php @@ -8,57 +8,77 @@ use FML\Types\Renderable; * Class representing a ManiaLink script tag with a simple script text * * @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 SimpleScript implements Renderable { - /* - * Protected properties - */ - protected $tagName = 'script'; - protected $text = null; +class SimpleScript implements Renderable +{ - /** - * Create a new SimpleScript object - * - * @param string $text (optional) Script text - * @return static - */ - public static function create($text = null) { - return new static($text); - } + /** + * @var string $text Script text + */ + protected $text = null; - /** - * Construct a new SimpleScript object - * - * @param string $text (optional) Script text - */ - public function __construct($text = null) { - if ($text !== null) { - $this->setText($text); - } - } + /** + * Create a new SimpleScript + * + * @api + * @param string $text (optional) Script text + * @return static + */ + public static function create($text = null) + { + return new static($text); + } - /** - * Set script text - * - * @param string $text Complete script text - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * Construct a new SimpleScript + * + * @api + * @param string $text (optional) Script text + */ + public function __construct($text = null) + { + if ($text) { + $this->setText($text); + } + } + + /** + * Get the script text + * + * @api + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set the script text + * + * @api + * @param string $text Complete script text + * @return static + */ + public function setText($text) + { + $this->text = (string)$text; + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("script"); + if ($this->text) { + $scriptComment = $domDocument->createComment($this->text); + $domElement->appendChild($scriptComment); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - if ($this->text) { - $scriptComment = $domDocument->createComment($this->text); - $xmlElement->appendChild($scriptComment); - } - return $xmlElement; - } } diff --git a/libs/FML/Form/Parameters.php b/libs/FML/Form/Parameters.php new file mode 100644 index 00000000..036c69f3 --- /dev/null +++ b/libs/FML/Form/Parameters.php @@ -0,0 +1,32 @@ + - * @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 - */ - protected $encoding = 'utf-8'; - protected $tagName = 'maniacode'; - protected $noConfirmation = null; - /** @var Element[] $elements */ - protected $elements = array(); +class ManiaCode +{ - /** - * Create a new ManiaCode object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var bool $disableConfirmation Disable the confirmation + */ + protected $disableConfirmation = null; - /** - * Set XML encoding - * - * @param string $encoding XML encoding - * @return static - */ - public function setXmlEncoding($encoding) { - $this->encoding = (string)$encoding; - return $this; - } + /** + * @var Element[] $elements ManiaCode Elements + */ + protected $elements = array(); - /** - * Disable the showing of the confirmation at the end of the ManiaCode - * - * @param bool $disable Whether the confirmation should be shown - * @return static - */ - public function disableConfirmation($disable) { - $this->noConfirmation = ($disable ? 1 : 0); - return $this; - } + /** + * Create a new ManiaCode + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Show a message - * - * @param string $message Message text - * @return static - */ - public function addShowMessage($message) { - $messageElement = new ShowMessage($message); - $this->addElement($messageElement); - return $this; - } + /** + * Get if the confirmation is disabled + * + * @api + * @return bool + */ + public function getDisableConfirmation() + { + return $this->disableConfirmation; + } - /** - * Install a Macroblock - * - * @param string $name Macroblock name - * @param string $file Macroblock file - * @param string $url Macroblock url - * @return static - */ - public function addInstallMacroblock($name, $file, $url) { - $macroblockElement = new InstallMacroblock($name, $file, $url); - $this->addElement($macroblockElement); - return $this; - } + /** + * Disable the showing of the confirmation at the end of the ManiaCode + * + * @api + * @param bool $disableConfirmation If the confirmation should be disabled + * @return static + */ + public function setDisableConfirmation($disableConfirmation) + { + $this->disableConfirmation = (bool)$disableConfirmation; + return $this; + } - /** - * Install a map - * - * @param string $name Map name - * @param string $url Map url - * @return static - */ - public function addInstallMap($name, $url) { - $mapElement = new InstallMap($name, $url); - $this->addElement($mapElement); - return $this; - } + /** + * Show a message + * + * @api + * @param string $message Message text + * @return static + */ + public function addShowMessage($message) + { + $messageElement = new ShowMessage($message); + return $this->addElement($messageElement); + } - /** - * Play a map - * - * @param string $name Map name - * @param string $url Map url - * @return static - */ - public function addPlayMap($name, $url) { - $mapElement = new PlayMap($name, $url); - $this->addElement($mapElement); - return $this; - } + /** + * 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) + { + $macroblockElement = new InstallMacroblock($name, $file, $url); + return $this->addElement($macroblockElement); + } - /** - * Install a replay - * - * @param string $name Replay name - * @param string $url Replay url - * @return static - */ - public function addInstallReplay($name, $url) { - $replayElement = new InstallReplay($name, $url); - $this->addElement($replayElement); - return $this; - } + /** + * Install a map + * + * @api + * @param string $name Map name + * @param string $url Map url + * @return static + */ + public function addInstallMap($name, $url) + { + $mapElement = new InstallMap($name, $url); + return $this->addElement($mapElement); + } - /** - * View a replay - * - * @param string $name Replay name - * @param string $url Replay url - * @return static - */ - public function addViewReplay($name, $url) { - $replayElement = new ViewReplay($name, $url); - $this->addElement($replayElement); - return $this; - } + /** + * Play a map + * + * @api + * @param string $name Map name + * @param string $url Map url + * @return static + */ + public function addPlayMap($name, $url) + { + $mapElement = new PlayMap($name, $url); + return $this->addElement($mapElement); + } - /** - * Play a replay - * - * @param string $name Replay name - * @param string $url Replay url - * @return static - */ - public function addPlayReplay($name, $url) { - $replayElement = new PlayReplay($name, $url); - $this->addElement($replayElement); - return $this; - } + /** + * Install a replay + * + * @api + * @param string $name Replay name + * @param string $url Replay url + * @return static + */ + public function addInstallReplay($name, $url) + { + $replayElement = new InstallReplay($name, $url); + return $this->addElement($replayElement); + } - /** - * Install a skin - * - * @param string $name Skin name - * @param string $file Skin file - * @param string $url Skin url - * @return static - */ - public function addInstallSkin($name, $file, $url) { - $skinElement = new InstallSkin($name, $file, $url); - $this->addElement($skinElement); - return $this; - } + /** + * View a replay + * + * @api + * @param string $name Replay name + * @param string $url Replay url + * @return static + */ + public function addViewReplay($name, $url) + { + $replayElement = new ViewReplay($name, $url); + return $this->addElement($replayElement); + } - /** - * Get a skin - * - * @param string $name Skin name - * @param string $file Skin file - * @param string $url Skin url - * @return static - */ - public function addGetSkin($name, $file, $url) { - $skinElement = new GetSkin($name, $file, $url); - $this->addElement($skinElement); - return $this; - } + /** + * Play a replay + * + * @api + * @param string $name Replay name + * @param string $url Replay url + * @return static + */ + public function addPlayReplay($name, $url) + { + $replayElement = new PlayReplay($name, $url); + return $this->addElement($replayElement); + } - /** - * Add a buddy - * - * @param string $login Buddy login - * @return static - */ - public function addAddBuddy($login) { - $buddyElement = new AddBuddy($login); - $this->addElement($buddyElement); - return $this; - } + /** + * 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) + { + $skinElement = new InstallSkin($name, $file, $url); + return $this->addElement($skinElement); + } - /** - * Go to a link - * - * @param string $link Goto link - * @return static - */ - public function addGoto($link) { - $gotoElement = new Go_To($link); - $this->addElement($gotoElement); - return $this; - } + /** + * 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) + { + $skinElement = new GetSkin($name, $file, $url); + return $this->addElement($skinElement); + } - /** - * Join a server - * - * @param string $login Server login - * @return static - */ - public function addJoinServer($login) { - $serverElement = new JoinServer($login); - $this->addElement($serverElement); - return $this; - } + /** + * Add a buddy + * + * @api + * @param string $login Buddy login + * @return static + */ + public function addAddBuddy($login) + { + $buddyElement = new AddBuddy($login); + return $this->addElement($buddyElement); + } - /** - * Add a server as favorite - * - * @param string $login Server login - * @return static - */ - public function addAddFavorite($login) { - $favoriteElement = new AddFavorite($login); - $this->addElement($favoriteElement); - return $this; - } + /** + * Go to a link + * + * @api + * @param string $link Goto link + * @return static + */ + public function addGoto($link) + { + $gotoElement = new Go_To($link); + return $this->addElement($gotoElement); + } - /** - * Install a script - * - * @param string $name Script name - * @param string $file Script file - * @param string $url Script url - * @return static - */ - public function addInstallScript($name, $file, $url) { - $scriptElement = new InstallScript($name, $file, $url); - $this->addElement($scriptElement); - return $this; - } + /** + * Join a server + * + * @api + * @param string $login Server login + * @return static + */ + public function addJoinServer($login) + { + $serverElement = new JoinServer($login); + return $this->addElement($serverElement); + } - /** - * Install a title pack - * - * @param string $name Pack name - * @param string $file Pack file - * @param string $url Pack url - * @return static - */ - public function addInstallPack($name, $file, $url) { - $packElement = new InstallPack($name, $file, $url); - $this->addElement($packElement); - return $this; - } + /** + * Add a server as favorite + * + * @api + * @param string $login Server login + * @return static + */ + public function addAddFavorite($login) + { + $favoriteElement = new AddFavorite($login); + return $this->addElement($favoriteElement); + } - /** - * Add a ManiaCode element - * - * @param Element $element Element to add - * @return static - */ - public function addElement(Element $element) { - array_push($this->elements, $element); - return $this; - } + /** + * 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) + { + $scriptElement = new InstallScript($name, $file, $url); + return $this->addElement($scriptElement); + } - /** - * Remove all elements from the ManiaCode - * - * @return static - */ - public function removeElements() { - $this->elements = array(); - return $this; - } + /** + * 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) + { + $packElement = new InstallPack($name, $file, $url); + return $this->addElement($packElement); + } - /** - * Render the XML document - * - * @param bool $echo (optional) Whether 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); - $domDocument->xmlStandalone = true; - $maniaCode = $domDocument->createElement($this->tagName); - $domDocument->appendChild($maniaCode); - if ($this->noConfirmation) { - $maniaCode->setAttribute('noconfirmation', $this->noConfirmation); - } - foreach ($this->elements as $element) { - $xmlElement = $element->render($domDocument); - $maniaCode->appendChild($xmlElement); - } - if ($echo) { - header('Content-Type: application/xml; charset=utf-8;'); - echo $domDocument->saveXML(); - } - return $domDocument; - } + /** + * 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) + { + if (!in_array($element, $this->elements, true)) { + array_push($this->elements, $element); + } + return $this; + } + + /** + * 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 removeAllElements() + { + $this->elements = array(); + return $this; + } + + /** + * Render the ManiaCode + * + * @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", "utf-8"); + $domDocument->xmlStandalone = true; + + $domElement = $domDocument->createElement("maniacode"); + $domDocument->appendChild($domElement); + + if ($this->disableConfirmation) { + $domElement->setAttribute("noconfirmation", 1); + } + + foreach ($this->elements as $element) { + $childDomElement = $element->render($domDocument); + $domElement->appendChild($childDomElement); + } + + if ($echo) { + header("Content-Type: application/xml; charset=utf-8;"); + echo $domDocument->saveXML(); + } + + return $domDocument; + } + + /** + * Get the string representation + * + * @return string + */ + public function __toString() + { + return $this->render() + ->saveXML(); + } - /** - * Get string representation - * - * @return string - */ - public function __toString() { - return $this->render()->saveXML(); - } } diff --git a/libs/FML/ManiaCode/AddBuddy.php b/libs/FML/ManiaCode/AddBuddy.php index fe36815c..02ad07d5 100644 --- a/libs/FML/ManiaCode/AddBuddy.php +++ b/libs/FML/ManiaCode/AddBuddy.php @@ -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 - */ - protected $tagName = 'add_buddy'; - protected $login = null; +class AddBuddy implements Element +{ - /** - * Create a new AddBuddy Element - * - * @param string $login (optional) Buddy login - * @return static - */ - public static function create($login = null) { - return new static($login); - } + /** + * @var string $login Buddy login + */ + protected $login = null; - /** - * Construct a new AddBuddy Element - * - * @param string $login (optional) Buddy login - */ - public function __construct($login = null) { - if ($login !== null) { - $this->setLogin($login); - } - } + /** + * Create a new AddBuddy Element + * + * @api + * @param string $login (optional) Buddy login + * @return static + */ + public static function create($login = null) + { + return new static($login); + } - /** - * Set the buddy login - * - * @param string $login Buddy login - * @return static - */ - public function setLogin($login) { - $this->login = (string)$login; - return $this; - } + /** + * Construct a new AddBuddy Element + * + * @api + * @param string $login (optional) Buddy login + */ + 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) + { + $this->login = (string)$login; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("add_buddy"); + + $loginElement = $domDocument->createElement("login", $this->login); + $domElement->appendChild($loginElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $loginElement = $domDocument->createElement('login', $this->login); - $xmlElement->appendChild($loginElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/AddFavorite.php b/libs/FML/ManiaCode/AddFavorite.php index f1b19591..b3a1122a 100644 --- a/libs/FML/ManiaCode/AddFavorite.php +++ b/libs/FML/ManiaCode/AddFavorite.php @@ -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 - * - * @param string $login (optional) Server login - * @return static - */ - public static function create($login = null) { - return new static($login); - } + /** + * @var string $login Server login + */ + protected $login = null; - /** - * Construct a new AddFavorite object - * - * @param string $login (optional) Server login - */ - public function __construct($login = null) { - if ($login !== null) { - $this->setLogin($login); - } - } + /** + * @var string $ip Server ip + */ + protected $ip = null; - /** - * Set the server login - * - * @param string $login Server login - * @return static - */ - public function setLogin($login) { - $this->login = (string)$login; - $this->serverIp = null; - $this->serverPort = null; - return $this; - } + /** + * @var int $port Server port + */ + protected $port = null; - /** - * Set the server ip and port - * - * @param string $serverIp Server ip - * @param int $serverPort Server port - * @return static - */ - public function setIp($serverIp, $serverPort) { - $this->serverIp = (string)$serverIp; - $this->serverPort = (int)$serverPort; - $this->login = null; - return $this; - } + /** + * Create a new AddFavorite Element + * + * @api + * @param string $loginOrIp (optional) Server login or ip + * @param int $port (optional) Server port + * @return static + */ + public static function create($loginOrIp = null, $port = null) + { + return new static($loginOrIp, $port); + } + + /** + * Construct a new AddFavorite Element + * + * @api + * @param string $loginOrIp (optional) Server login or ip + * @param int $port (optional) Server port + */ + 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) + { + $this->login = (string)$login; + $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 + * + * @api + * @param string $ip Server ip + * @param int $port (optional) Server port + * @return static + */ + public function setIp($ip, $port = null) + { + $this->login = null; + $this->ip = (string)$ip; + if ($port) { + $this->setPort($port); + } + return $this; + } + + /** + * Get the server port + * + * @api + * @return int + */ + 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->ip . ":" . $this->port); + $domElement->appendChild($ipElement); + } + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->serverIp === null) { - $loginElement = $domDocument->createElement('login', $this->login); - $xmlElement->appendChild($loginElement); - } else { - $ipElement = $domDocument->createElement('ip', $this->serverIp . ':' . $this->serverPort); - $xmlElement->appendChild($ipElement); - } - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/Element.php b/libs/FML/ManiaCode/Element.php index cde49572..300506cd 100644 --- a/libs/FML/ManiaCode/Element.php +++ b/libs/FML/ManiaCode/Element.php @@ -6,23 +6,18 @@ 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 + * + * @param \DOMDocument $domDocument The DOMDocument for which the Element should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument); - /** - * Render the ManiaCode 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; - } } diff --git a/libs/FML/ManiaCode/GetSkin.php b/libs/FML/ManiaCode/GetSkin.php index 958c72b8..fb6d7841 100644 --- a/libs/FML/ManiaCode/GetSkin.php +++ b/libs/FML/ManiaCode/GetSkin.php @@ -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 - */ - protected $tagName = 'get_skin'; - protected $name = null; - protected $file = null; - protected $url = null; +class GetSkin implements Element +{ - /** - * Create a new GetSkin object - * - * @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) { - return new static($name, $file, $url); - } + /** + * @var string $name Skin name + */ + protected $name = null; - /** - * Construct a new GetSkin object - * - * @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) { - $this->setName($name); - } - if ($file !== null) { - $this->setFile($file); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $file Skin file + */ + protected $file = null; - /** - * Set the name of the skin - * - * @param string $name Skin name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $url Skin url + */ + protected $url = null; - /** - * Set the file of the skin - * - * @param string $file Skin file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * 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) + { + return new static($name, $file, $url); + } - /** - * Set the url of the skin - * - * @param string $url Skin url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setName($name); + } + if ($file) { + $this->setFile($file); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * 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) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->file = (string)$file; + return $this; + } + + /** + * 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + 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; + } - /** - * @see \FML\ManiaCode\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; - } } diff --git a/libs/FML/ManiaCode/Go_To.php b/libs/FML/ManiaCode/Go_To.php index 3b511fc4..5636e394 100644 --- a/libs/FML/ManiaCode/Go_To.php +++ b/libs/FML/ManiaCode/Go_To.php @@ -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 - */ - protected $tagName = 'goto'; - protected $link = null; +class Go_To implements Element +{ - /** - * Create a new Go_To object - * - * @param string $link (optional) Goto link - * @return static - */ - public static function create($link = null) { - return new static($link); - } + /** + * @var string $link Link + */ + protected $link = null; - /** - * Construct a new Go_To object - * - * @param string $link (optional) Goto link - */ - public function __construct($link = null) { - if ($link !== null) { - $this->setLink($link); - } - } + /** + * Create a new Go_To Element + * + * @api + * @param string $link (optional) Link + * @return static + */ + public static function create($link = null) + { + return new static($link); + } - /** - * Set link - * - * @param string $link Goto link - * @return static - */ - public function setLink($link) { - $this->link = (string)$link; - return $this; - } + /** + * Construct a new Go_To Element + * + * @api + * @param string $link (optional) Link + */ + public function __construct($link = null) + { + if ($link) { + $this->setLink($link); + } + } + + /** + * Get the link + * + * @api + * @return string + */ + public function getLink() + { + return $this->link; + } + + /** + * Set the link + * + * @api + * @param string $link Link + * @return static + */ + public function setLink($link) + { + $this->link = (string)$link; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("goto"); + + $linkElement = $domDocument->createElement("link", $this->link); + $domElement->appendChild($linkElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $linkElement = $domDocument->createElement('link', $this->link); - $xmlElement->appendChild($linkElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/InstallMacroblock.php b/libs/FML/ManiaCode/InstallMacroblock.php index a8d20ba1..0b973153 100644 --- a/libs/FML/ManiaCode/InstallMacroblock.php +++ b/libs/FML/ManiaCode/InstallMacroblock.php @@ -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 - */ - protected $tagName = 'install_macroblock'; - protected $name = null; - protected $file = null; - protected $url = null; +class InstallMacroblock implements Element +{ - /** - * Create a new InstallMacroblock object - * - * @param string $name (optional) Macroblock name - * @param string $url (optional) Macroblock url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /** + * @var string $name Macroblock name + */ + protected $name = null; - /** - * Construct a new InstallMacroblock object - * - * @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) { - $this->setName($name); - } - if ($file !== null) { - $this->setFile($file); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $file Macroblock file + */ + protected $file = null; - /** - * Set the name of the macroblock - * - * @param string $name Macroblock name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $url Macroblock url + */ + protected $url = null; - /** - * Set the file of the macroblock - * - * @param string $file Macroblock file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * 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, $file = null, $url = null) + { + return new static($name, $file, $url); + } - /** - * Set the url of the macroblock - * - * @param string $url Macroblock url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setName($name); + } + if ($file) { + $this->setFile($file); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * 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) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->file = (string)$file; + return $this; + } + + /** + * 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + 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; + } - /** - * @see \FML\ManiaCode\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; - } } diff --git a/libs/FML/ManiaCode/InstallMap.php b/libs/FML/ManiaCode/InstallMap.php index 10be08a2..764ed3be 100644 --- a/libs/FML/ManiaCode/InstallMap.php +++ b/libs/FML/ManiaCode/InstallMap.php @@ -6,74 +6,114 @@ namespace FML\ManiaCode; * ManiaCode Element installing a map * * @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 InstallMap extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_map'; - protected $name = null; - protected $url = null; +class InstallMap implements Element +{ - /** - * Create a new InstallMap object - * - * @param string $name (optional) Map name - * @param string $url (optional) Map url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /** + * @var string $name Map name + */ + protected $name = null; - /** - * Construct a new InstallMap object - * - * @param string $name (optional) Map name - * @param string $url (optional) Map url - */ - public function __construct($name = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $url Map url + */ + protected $url = null; - /** - * Set the name of the map - * - * @param string $name Map name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * 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) + { + return new static($name, $url); + } - /** - * Set the url of the map - * - * @param string $url Map url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setName($name); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * 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) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + 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; + } - /** - * @see \FML\ManiaCode\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; - } } diff --git a/libs/FML/ManiaCode/InstallPack.php b/libs/FML/ManiaCode/InstallPack.php index 33781e59..870d7e18 100644 --- a/libs/FML/ManiaCode/InstallPack.php +++ b/libs/FML/ManiaCode/InstallPack.php @@ -6,93 +6,151 @@ namespace FML\ManiaCode; * ManiaCode Element installing a title pack * * @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 InstallPack extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_pack'; - protected $name = null; - protected $file = null; - protected $url = null; +class InstallPack implements Element +{ - /** - * Create a new InstallPack object - * - * @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) { - return new static($name, $file, $url); - } + /** + * @var string $name Pack name + */ + protected $name = null; - /** - * Construct a new InstallPack object - * - * @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) { - $this->setName($name); - } - if ($file !== null) { - $this->setFile($file); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $file Pack file + */ + protected $file = null; - /** - * Set the name of the pack - * - * @param string $name Pack name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $url Pack url + */ + protected $url = null; - /** - * Set the file of the pack - * - * @param string $file Pack file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * 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) + { + return new static($name, $file, $url); + } - /** - * Set the url of the pack - * - * @param string $url Pack url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setName($name); + } + if ($file) { + $this->setFile($file); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * 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) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->file = (string)$file; + return $this; + } + + /** + * 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + 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; + } - /** - * @see \FML\ManiaCode\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; - } } diff --git a/libs/FML/ManiaCode/InstallReplay.php b/libs/FML/ManiaCode/InstallReplay.php index b851ec72..ba97d900 100644 --- a/libs/FML/ManiaCode/InstallReplay.php +++ b/libs/FML/ManiaCode/InstallReplay.php @@ -6,74 +6,114 @@ namespace FML\ManiaCode; * ManiaCode Element installing a replay * * @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 InstallReplay extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_replay'; - protected $name = null; - protected $url = null; +class InstallReplay implements Element +{ - /** - * Create a new InstallReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /** + * @var string $name Replay name + */ + protected $name = null; - /** - * Construct a new InstallReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - */ - public function __construct($name = null, $url = null) { - if ($name!== null) { - $this->setName($name); - } - if ($url!== null) { - $this->setUrl($url); - } - } + /** + * @var string $url Replay url + */ + protected $url = null; - /** - * Set the name of the replay - * - * @param string $name Replay name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * 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) + { + return new static($name, $url); + } - /** - * Set the url of the replay - * - * @param string $url Replay url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setName($name); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * 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) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + 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; + } - /** - * @see \FML\ManiaCode\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; - } } diff --git a/libs/FML/ManiaCode/InstallScript.php b/libs/FML/ManiaCode/InstallScript.php index e11e693a..bed4c6ca 100644 --- a/libs/FML/ManiaCode/InstallScript.php +++ b/libs/FML/ManiaCode/InstallScript.php @@ -6,93 +6,151 @@ namespace FML\ManiaCode; * ManiaCode Element installing a 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 InstallScript extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_script'; - protected $name = null; - protected $file = null; - protected $url = null; +class InstallScript implements Element +{ - /** - * Create a new InstallScript object - * - * @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) { - return new static($name, $file, $url); - } + /** + * @var string $name Script name + */ + protected $name = null; - /** - * Construct a new InstallScript object - * - * @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) { - $this->setName($name); - } - if ($file !== null) { - $this->setFile($file); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $file Script file + */ + protected $file = null; - /** - * Set the name of the script - * - * @param string $name Script name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $url Script url + */ + protected $url = null; - /** - * Set the file of the script - * - * @param string $file Script file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * 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) + { + return new static($name, $file, $url); + } - /** - * Set the url of the script - * - * @param string $url Script url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setName($name); + } + if ($file) { + $this->setFile($file); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * 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) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->file = (string)$file; + return $this; + } + + /** + * 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + 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; + } - /** - * @see \FML\ManiaCode\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; - } } diff --git a/libs/FML/ManiaCode/InstallSkin.php b/libs/FML/ManiaCode/InstallSkin.php index a6584ec4..23c29b05 100644 --- a/libs/FML/ManiaCode/InstallSkin.php +++ b/libs/FML/ManiaCode/InstallSkin.php @@ -6,93 +6,151 @@ namespace FML\ManiaCode; * ManiaCode Element installing 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 InstallSkin extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_skin'; - protected $name = null; - protected $file = null; - protected $url = null; +class InstallSkin implements Element +{ - /** - * Create a new InstallSkin object - * - * @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) { - return new static($name, $file, $url); - } + /** + * @var string $name Skin name + */ + protected $name = null; - /** - * Construct a new InstallSkin object - * - * @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) { - $this->setName($name); - } - if ($file !== null) { - $this->setFile($file); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $file Skin file + */ + protected $file = null; - /** - * Set the name of the skin - * - * @param string $name Skin name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $url Skin url + */ + protected $url = null; - /** - * Set the file of the skin - * - * @param string $file Skin file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * 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) + { + return new static($name, $file, $url); + } - /** - * Set the url of the skin - * - * @param string $url Skin url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setName($name); + } + if ($file) { + $this->setFile($file); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * 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) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->file = (string)$file; + return $this; + } + + /** + * 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + 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; + } - /** - * @see \FML\ManiaCode\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; - } } diff --git a/libs/FML/ManiaCode/JoinServer.php b/libs/FML/ManiaCode/JoinServer.php index 2a0299fd..c1fdf5de 100644 --- a/libs/FML/ManiaCode/JoinServer.php +++ b/libs/FML/ManiaCode/JoinServer.php @@ -6,78 +6,150 @@ namespace FML\ManiaCode; * ManiaCode Element for joining a server * * @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 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 - * - * @param string $login (optional) Server login - * @return static - */ - public static function create($login = null) { - return new static($login); - } + /** + * @var string $login Server login + */ + protected $login = null; - /** - * Construct a new JoinServer object - * - * @param string $login (optional) Server login - */ - public function __construct($login = null) { - if ($login !== null) { - $this->setLogin($login); - } - } + /** + * @var string $ip Server ip + */ + protected $ip = null; - /** - * Set the server login - * - * @param string $login Server login - * @return static - */ - public function setLogin($login) { - $this->login = (string)$login; - $this->serverIp = null; - $this->serverPort = null; - return $this; - } + /** + * @var int $port Server port + */ + protected $port = null; - /** - * Set the server ip and port - * - * @param string $serverIp Server ip - * @param int $serverPort Server port - * @return static - */ - public function setIp($serverIp, $serverPort) { - $this->serverIp = (string)$serverIp; - $this->serverPort = (int)$serverPort; - $this->login = null; - return $this; - } + /** + * Create a new JoinServer Element + * + * @api + * @param string $loginOrIp (optional) Server login or ip + * @param int $port (optional) Server port + * @return static + */ + public static function create($loginOrIp = null, $port = null) + { + return new static($loginOrIp, $port); + } + + /** + * Construct a new JoinServer Element + * + * @api + * @param string $loginOrIp (optional) Server login or ip + * @param int $port (optional) Server port + */ + 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) + { + $this->login = (string)$login; + $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 + * + * @api + * @param string $ip Server ip + * @param int $port (optional) Server port + * @return static + */ + public function setIp($ip, $port = null) + { + $this->login = null; + $this->ip = (string)$ip; + if ($port) { + $this->setPort($port); + } + return $this; + } + + /** + * Get the server port + * + * @api + * @return int + */ + 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->ip . ":" . $this->port); + $domElement->appendChild($ipElement); + } + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->serverIp === null) { - $loginElement = $domDocument->createElement('login', $this->login); - $xmlElement->appendChild($loginElement); - } else { - $ipElement = $domDocument->createElement('ip', $this->serverIp . ':' . $this->serverPort); - $xmlElement->appendChild($ipElement); - } - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/PlayMap.php b/libs/FML/ManiaCode/PlayMap.php index 5e0d9406..a1e6053d 100644 --- a/libs/FML/ManiaCode/PlayMap.php +++ b/libs/FML/ManiaCode/PlayMap.php @@ -6,74 +6,114 @@ namespace FML\ManiaCode; * ManiaCode Element for playing a map * * @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 PlayMap extends Element { - /* - * Protected properties - */ - protected $tagName = 'play_map'; - protected $name = null; - protected $url = null; +class PlayMap implements Element +{ - /** - * Create a new PlayMap object - * - * @param string $name (optional) Map name - * @param string $url (optional) Map url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /*+ + * @var string $name Map name + */ + protected $name = null; - /** - * Construct a new PlayMap object - * - * @param string $name (optional) Map name - * @param string $url (optional) Map url - */ - public function __construct($name = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $url Map url + */ + protected $url = null; - /** - * Set the name of the map - * - * @param string $name Map name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * 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) + { + return new static($name, $url); + } - /** - * Set the url of the map - * - * @param string $url Map url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setName($name); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * 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) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + 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; + } - /** - * @see \FML\ManiaCode\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; - } } diff --git a/libs/FML/ManiaCode/PlayReplay.php b/libs/FML/ManiaCode/PlayReplay.php index 667e98ce..dc7157ba 100644 --- a/libs/FML/ManiaCode/PlayReplay.php +++ b/libs/FML/ManiaCode/PlayReplay.php @@ -6,74 +6,114 @@ namespace FML\ManiaCode; * ManiaCode Element playing a replay * * @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 PlayReplay extends Element { - /* - * Protected properties - */ - protected $tagName = 'play_replay'; - protected $name = null; - protected $url = null; +class PlayReplay implements Element +{ - /** - * Create a new PlayReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /** + * @var string $name Replay name + */ + protected $name = null; - /** - * Construct a new PlayReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - */ - public function __construct($name = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $url Replay url + */ + protected $url = null; - /** - * Set the name of the replay - * - * @param string $name Replay name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * 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) + { + return new static($name, $url); + } - /** - * Set the url of the replay - * - * @param string $url Replay url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setName($name); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * 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) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + 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; + } - /** - * @see \FML\ManiaCode\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; - } } diff --git a/libs/FML/ManiaCode/ShowMessage.php b/libs/FML/ManiaCode/ShowMessage.php index 917e6c9a..d534cf81 100644 --- a/libs/FML/ManiaCode/ShowMessage.php +++ b/libs/FML/ManiaCode/ShowMessage.php @@ -6,55 +6,77 @@ namespace FML\ManiaCode; * ManiaCode Element showing a Message * * @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 ShowMessage extends Element { - /* - * Protected properties - */ - protected $tagName = 'show_message'; - protected $message = null; +class ShowMessage implements Element +{ - /** - * Create a new ShowMessage object - * - * @param string $message (optional) Message text - * @return static - */ - public static function create($message = null) { - return new static($message); - } + /** + * @var string $message Message text + */ + protected $message = null; - /** - * Construct a new ShowMessage object - * - * @param string $message (optional) Message text - */ - public function __construct($message = null) { - if ($message !== null) { - $this->setMessage($message); - } - } + /** + * Create a new ShowMessage Element + * + * @api + * @param string $message (optional) Message text + * @return static + */ + public static function create($message = null) + { + return new static($message); + } - /** - * Set the message text - * - * @param string $message Message text - * @return static - */ - public function setMessage($message) { - $this->message = (string)$message; - return $this; - } + /** + * Construct a new ShowMessage Element + * + * @api + * @param string $message (optional) Message text + */ + 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) + { + $this->message = (string)$message; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("show_message"); + + $messageElement = $domDocument->createElement("message", $this->message); + $domElement->appendChild($messageElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $messageElement = $domDocument->createElement('message', $this->message); - $xmlElement->appendChild($messageElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/ViewReplay.php b/libs/FML/ManiaCode/ViewReplay.php index 1ffd9549..2c2088f5 100644 --- a/libs/FML/ManiaCode/ViewReplay.php +++ b/libs/FML/ManiaCode/ViewReplay.php @@ -6,74 +6,114 @@ namespace FML\ManiaCode; * ManiaCode Element for viewing a replay * * @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 ViewReplay extends Element { - /* - * Protected properties - */ - protected $tagName = 'view_replay'; - protected $name = null; - protected $url = null; +class ViewReplay implements Element +{ - /** - * Create a new ViewReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /** + * @var string $name Replay name + */ + protected $name = null; - /** - * Construct a new ViewReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - */ - public function __construct($name = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $url Replay url + */ + protected $url = null; - /** - * Set the name of the replay - * - * @param string $name Replay name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * 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) + { + return new static($name, $url); + } - /** - * Set the url of the replay - * - * @param string $url Replay url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setName($name); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * 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) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + 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; + } - /** - * @see \FML\ManiaCode\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; - } } diff --git a/libs/FML/ManiaLink.php b/libs/FML/ManiaLink.php index 61bb8601..0e9c622c 100644 --- a/libs/FML/ManiaLink.php +++ b/libs/FML/ManiaLink.php @@ -12,317 +12,522 @@ use FML\Types\ScriptFeatureable; * Class representing a ManiaLink * * @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 ManiaLink { - /* - * Constants - */ - const BACKGROUND_0 = '0'; - const BACKGROUND_1 = '1'; - const BACKGROUND_STARS = 'stars'; - const BACKGROUND_STATIONS = 'stations'; - const BACKGROUND_TITLE = 'title'; +class ManiaLink +{ - /* - * Protected properties - */ - protected $encoding = 'utf-8'; - protected $tagName = 'manialink'; - protected $maniaLinkId = null; - protected $version = 1; - protected $background = null; - protected $navigable3d = 1; - protected $name = null; - protected $timeout = 0; - /** @var Renderable[] $children */ - protected $children = array(); - /** @var Dico $dico */ - protected $dico = null; - /** @var Stylesheet $stylesheet */ - protected $stylesheet = null; - /** @var Script $script */ - protected $script = null; + /* + * Constants + */ + const MANIALINK_VERSION = 3; + const BACKGROUND_0 = "0"; + const BACKGROUND_1 = "1"; + const BACKGROUND_STARS = "stars"; + const BACKGROUND_STATIONS = "stations"; + const BACKGROUND_TITLE = "title"; - /** - * Create a new ManiaLink object - * - * @param string $maniaLinkId (optional) ManiaLink id - * @param string $maniaLinkName (optional) ManiaLink Name - * @return static - */ - public static function create($maniaLinkId = null, $maniaLinkName = null) { - return new static($maniaLinkId, $maniaLinkName); - } + /** + * @var string $maniaLinkId ManiaLink ID + */ + protected $maniaLinkId = null; - /** - * Construct a new ManiaLink object - * - * @param string $maniaLinkId (optional) ManiaLink id - * @param string $maniaLinkName (optional) ManiaLink Name - */ - public function __construct($maniaLinkId = null, $maniaLinkName = null) { - if ($maniaLinkId !== null) { - $this->setId($maniaLinkId); - } - if ($maniaLinkName !== false) { - if ($maniaLinkName) { - $this->setName($maniaLinkName); - } else { - $this->setName($maniaLinkId); - } - } - } + /** + * @var int $version ManiaLink version + */ + protected $version = 1; - /** - * Set XML encoding - * - * @param string $encoding XML encoding - * @return static - */ - public function setXmlEncoding($encoding) { - $this->encoding = (string)$encoding; - return $this; - } + /** + * @var string $name ManiaLink name + */ + protected $name = null; - /** - * Set ManiaLink id - * - * @param string $maniaLinkId ManiaLink id - * @return static - */ - public function setId($maniaLinkId) { - $this->maniaLinkId = (string)$maniaLinkId; - return $this; - } + /** + * @var string $background Background + */ + protected $background = null; - /** - * Get ManiaLink id - * - * @return string - */ - public function getId() { - return $this->maniaLinkId; - } + /** + * @var bool $navigable3d 3d navigable + */ + protected $navigable3d = true; - /** - * Set background - * - * @param string $background Background value - * @return static - */ - public function setBackground($background) { - $this->background = (string)$background; - return $this; - } + /** + * @var int $timeout Timeout + */ + protected $timeout = null; - /** - * Set navigable3d - * - * @param bool $navigable3d Whether the manialink should be 3d navigable - * @return static - */ - public function setNavigable3d($navigable3d) { - $this->navigable3d = ($navigable3d ? 1 : 0); - return $this; - } + /** + * @var Renderable[] $children Children + */ + protected $children = array(); - /** - * Set the ManiaLink Name - * - * @param string $name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var Dico $dico Dictionary + */ + protected $dico = null; - /** - * Set timeout - * - * @param int $timeout Timeout duration - * @return static - */ - public function setTimeout($timeout) { - $this->timeout = (int)$timeout; - return $this; - } + /** + * @var Stylesheet $stylesheet Style sheet + */ + protected $stylesheet = null; - /** - * Add an element to the ManiaLink - * - * @param Renderable $child Child element to add - * @return static - */ - public function add(Renderable $child) { - if (!in_array($child, $this->children, true)) { - array_push($this->children, $child); - } - return $this; - } + /** + * @var Script $script Script + */ + protected $script = null; - /** - * Remove all elements from the ManiaLink - * - * @return static - */ - public function removeChildren() { - $this->children = array(); - return $this; - } + /** + * Create a new ManiaLink + * + * @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, $version = null, $name = null, array $children = null) + { + return new static($maniaLinkId, $version, $name, $children); + } - /** - * Set the Dictionary of the ManiaLink - * - * @param Dico $dico Dictionary for the ManiaLink - * @return static - */ - public function setDico(Dico $dico) { - $this->dico = $dico; - return $this; - } + /** + * Construct a new ManiaLink + * + * @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, $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); + } + $this->setVersion(self::MANIALINK_VERSION); + if ($version) { + $this->setVersion($version); + } + if ($name) { + $this->setName($name); + } + if ($children) { + $this->setChildren($children); + } + $this->createScript(); + } - /** - * Get the Dictionary of the ManiaLink - * - * @param bool $createIfEmpty (optional) Whether the Dico object should be created if it's not set - * @return \FML\Elements\Dico - */ - public function getDico($createIfEmpty = true) { - if (!$this->dico && $createIfEmpty) { - $this->setDico(new Dico()); - } - return $this->dico; - } + /** + * Get the ID + * + * @api + * @return string + */ + public function getId() + { + return $this->maniaLinkId; + } - /** - * Set the Stylesheet of the ManiaLink - * - * @param Stylesheet $stylesheet Stylesheet for the ManiaLink - * @return static - */ - public function setStylesheet(Stylesheet $stylesheet) { - $this->stylesheet = $stylesheet; - return $this; - } + /** + * Set the ID + * + * @api + * @param string $maniaLinkId ManiaLink ID + * @return static + */ + public function setId($maniaLinkId) + { + $this->maniaLinkId = (string)$maniaLinkId; + if ($this->maniaLinkId && !$this->name) { + $this->setName($this->maniaLinkId); + } + return $this; + } - /** - * Get the Stylesheet of the ManiaLink - * - * @param bool $createIfEmpty (optional) Whether the Stylesheet object should be created if it's not set - * @return \FML\Stylesheet\Stylesheet - */ - public function getStylesheet($createIfEmpty = true) { - if (!$this->stylesheet && $createIfEmpty) { - $this->setStylesheet(new Stylesheet()); - } - return $this->stylesheet; - } + /** + * Get the version + * + * @api + * @return int + */ + public function getVersion() + { + return $this->version; + } - /** - * Set the Script of the ManiaLink - * - * @param Script $script Script for the ManiaLink - * @return static - */ - public function setScript(Script $script) { - $this->script = $script; - return $this; - } + /** + * Set the version + * + * @api + * @param int $version ManiaLink version + * @return static + */ + public function setVersion($version) + { + $this->version = (int)$version; + return $this; + } - /** - * Get the current Script of the ManiaLink - * - * @param bool $createIfEmpty (optional) Whether the Script object should be created if it's not set - * @return \FML\Script\Script - */ - public function getScript($createIfEmpty = true) { - if (!$this->script && $createIfEmpty) { - $this->setScript(new Script()); - } - return $this->script; - } + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Render the XML document - * - * @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 - * @return \DOMDocument - */ - public function render($echo = false, $domDocument = null) { - $isChild = (bool)$domDocument; - if (!$isChild) { - $domDocument = new \DOMDocument('1.0', $this->encoding); - $domDocument->xmlStandalone = true; - } - $maniaLink = $domDocument->createElement($this->tagName); - if (!$isChild) { - $domDocument->appendChild($maniaLink); - } - if (strlen($this->maniaLinkId) > 0) { - $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->name) { - $maniaLink->setAttribute('name', $this->name); - } - if ($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()); - $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 ($this->script) { - if ($this->script->needsRendering()) { - $scriptXml = $this->script->render($domDocument); - $maniaLink->appendChild($scriptXml); - } - $this->script->resetGenericScriptLabels(); - } - if ($isChild) { - return $maniaLink; - } - if ($echo) { - header('Content-Type: application/xml; charset=utf-8;'); - echo $domDocument->saveXML(); - } - return $domDocument; - } + /** + * Set the name + * + * @api + * @param string $name ManiaLink Name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * 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) + { + $this->timeout = (int)$timeout; + return $this; + } + + /** + * Get children + * + * @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 addChild(Renderable $child) + { + if (!in_array($child, $this->children, true)) { + array_push($this->children, $child); + } + return $this; + } + + /** + * Set children + * + * @api + * @param Renderable[] $children Child Elements + * @return static + */ + 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; + } + + /** + * Get the Dictionary + * + * @api + * @return Dico + */ + public function getDico() + { + return $this->dico; + } + + /** + * Set the Dictionary + * + * @api + * @param Dico $dico Dictionary + * @return static + */ + public function setDico(Dico $dico = null) + { + $this->dico = $dico; + return $this; + } + + /** + * Get the Stylesheet + * + * @api + * @return Stylesheet + */ + public function getStylesheet() + { + return $this->stylesheet; + } + + /** + * Set the Stylesheet + * + * @api + * @param Stylesheet $stylesheet Stylesheet + * @return static + */ + public function setStylesheet(Stylesheet $stylesheet = null) + { + $this->stylesheet = $stylesheet; + return $this; + } + + /** + * Get the Script + * + * @api + * @return Script + */ + public function getScript() + { + return $this->script; + } + + /** + * Set the Script + * + * @api + * @param Script $script Script + * @return static + */ + public function setScript(Script $script = null) + { + $this->script = $script; + return $this; + } + + /** + * Create and assign a new Script if necessary + * + * @api + * @return Script + */ + public function createScript() + { + if ($this->script) { + return $this->script; + } + $script = new Script(); + $this->setScript($script); + return $this->script; + } + + /** + * 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 ManiaLink should be rendered + * @return \DOMDocument + */ + public function render($echo = false, $domDocument = null) + { + $isChild = (bool)$domDocument; + if (!$isChild) { + $domDocument = new \DOMDocument("1.0", "utf-8"); + $domDocument->xmlStandalone = true; + } + $maniaLink = $domDocument->createElement("manialink"); + if (!$isChild) { + $domDocument->appendChild($maniaLink); + } + + if ($this->maniaLinkId) { + $maniaLink->setAttribute("id", $this->maniaLinkId); + } + if ($this->version > 0) { + $maniaLink->setAttribute("version", $this->version); + } + if ($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); + $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); + $maniaLink->appendChild($childXml); + if ($child instanceof ScriptFeatureable) { + $scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures()); + } + } + + 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); + $maniaLink->appendChild($scriptXml); + } + $this->script->resetGenericScriptLabels(); + } + + if ($isChild) { + return $maniaLink; + } + if ($echo) { + header("Content-Type: application/xml; charset=utf-8;"); + echo $domDocument->saveXML(); + } + return $domDocument; + } + + /** + * Get the string representation + * + * @return string + */ + public function __toString() + { + return $this->render() + ->saveXML(); + } - /** - * Get string representation - * - * @return string - */ - public function __toString() { - return $this->render()->saveXML(); - } } diff --git a/libs/FML/ManiaLinks.php b/libs/FML/ManiaLinks.php index 374e21d2..44dc2cf9 100644 --- a/libs/FML/ManiaLinks.php +++ b/libs/FML/ManiaLinks.php @@ -6,119 +6,190 @@ namespace FML; * Class holding several ManiaLinks at once * * @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 ManiaLinks { - /* - * Protected Properties - */ - protected $encoding = 'utf-8'; - protected $tagName = 'manialinks'; - /** @var ManiaLink[] $children */ - protected $children = array(); - /** @var CustomUI $customUI */ - protected $customUI = null; +class ManiaLinks +{ - /** - * Create a new ManiaLinks object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var ManiaLink[] $children ManiaLinks children + */ + protected $children = array(); - /** - * Set XML encoding - * - * @param string $encoding XML encoding - * @return static - */ - public function setXmlEncoding($encoding) { - $this->encoding = (string)$encoding; - return $this; - } + /** + * @var CustomUI $customUI Custom UI + */ + protected $customUI = null; - /** - * Add a child ManiaLink - * - * @param ManiaLink $child Child ManiaLink - * @return static - */ - public function add(ManiaLink $child) { - if (!in_array($child, $this->children, true)) { - array_push($this->children, $child); - } - return $this; - } + /** + * Create a new ManiaLinks object + * + * @api + * @param ManiaLink[] $children ManiaLink children + * @return static + */ + public static function create(array $children = null) + { + return new static($children); + } - /** - * Remove all child ManiaLinks - * - * @return static - */ - public function removeChildren() { - $this->children = array(); - return $this; - } + /** + * Construct a new ManiaLinks object + * + * @api + * @param ManiaLink[] $children ManiaLink children + */ + public function __construct(array $children = null) + { + if ($children) { + $this->setChildren($children); + } + } - /** - * Set the CustomUI - * - * @param CustomUI $customUI CustomUI object - * @return static - */ - public function setCustomUI(CustomUI $customUI) { - $this->customUI = $customUI; - return $this; - } + /** + * Get all child ManiaLinks + * + * @api + * @return ManiaLink[] + */ + public function getChildren() + { + return $this->children; + } - /** - * Get the CustomUI - * - * @param bool $createIfEmpty (optional) Whether the CustomUI object should be created if it's not set - * @return \FML\CustomUI - */ - public function getCustomUI($createIfEmpty = true) { - if (!$this->customUI && $createIfEmpty) { - $this->setCustomUI(new CustomUI()); - } - return $this->customUI; - } + /** + * 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); + } - /** - * Render the XML document - * - * @param bool (optional) $echo Whether 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); - $domDocument->xmlStandalone = true; - $maniaLinks = $domDocument->createElement($this->tagName); - $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); - } - if ($echo) { - header('Content-Type: application/xml; charset=utf-8;'); - echo $domDocument->saveXML(); - } - return $domDocument; - } + /** + * Add a child ManiaLink + * + * @api + * @param ManiaLink $child Child ManiaLink + * @return static + */ + public function addChild(ManiaLink $child) + { + if (!in_array($child, $this->children, true)) { + array_push($this->children, $child); + } + return $this; + } + + /** + * Set ManiaLink children + * + * @api + * @param ManiaLink[] $children ManiaLink children + * @return static + */ + public function setChildren(array $children) + { + $this->children = array(); + foreach ($children as $child) { + $this->addChild($child); + } + return $this; + } + + /** + * Remove all child ManiaLinks + * + * @api + * @return static + * @deprecated use removeAllChildren instead + */ + public function removeChildren() + { + return $this->removeAllChildren(); + } + + /** + * Remove all child ManiaLinks + * + * @api + * @return static + */ + public function removeAllChildren() + { + $this->children = array(); + return $this; + } + + /** + * Get the CustomUI + * + * @api + * @return CustomUI + */ + public function getCustomUI() + { + return $this->customUI; + } + + /** + * Set the CustomUI + * + * @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", "utf-8"); + $domDocument->xmlStandalone = true; + $maniaLinks = $domDocument->createElement("manialinks"); + $domDocument->appendChild($maniaLinks); + + foreach ($this->children as $child) { + $childXml = $child->render(false, $domDocument); + $maniaLinks->appendChild($childXml); + } + + if ($this->customUI) { + $customUIElement = $this->customUI->render($domDocument); + $maniaLinks->appendChild($customUIElement); + } + + if ($echo) { + header("Content-Type: application/xml; charset=utf-8;"); + echo $domDocument->saveXML(); + } + + return $domDocument; + } + + /** + * Get string representation + * + * @return string + */ + public function __toString() + { + return $this->render() + ->saveXML(); + } - /** - * Get string representation - * - * @return string - */ - public function __toString() { - return $this->render()->saveXML(); - } } diff --git a/libs/FML/Models/CheckBoxDesign.php b/libs/FML/Models/CheckBoxDesign.php deleted file mode 100644 index eda65813..00000000 --- a/libs/FML/Models/CheckBoxDesign.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @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; - } -} diff --git a/libs/FML/Script/Builder.php b/libs/FML/Script/Builder.php index a1d97a00..225370d2 100644 --- a/libs/FML/Script/Builder.php +++ b/libs/FML/Script/Builder.php @@ -2,149 +2,222 @@ namespace FML\Script; +use FML\Types\Identifiable; + /** * ManiaScript Builder class * * @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 Builder { - /* - * Constants - */ - const EMPTY_STRING = '""'; +abstract class Builder +{ - /** - * Build a label implementation block - * - * @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 - * @return string - */ - public static function getLabelImplementationBlock($labelName, $implementationCode, $isolate = true) { - if ($isolate) { - $implementationCode = 'if(True){' . $implementationCode . '}'; - } - $labelText = PHP_EOL . "***{$labelName}***" . PHP_EOL . "***{$implementationCode}***" . PHP_EOL; - return $labelText; - } + /* + * Constants + */ + const EMPTY_STRING = '""'; - /** - * Escape dangerous characters in the given text - * - * @param string $text Text to escape - * @param bool $addApostrophes (optional) Whether to add apostrophes before and after the text - * @return string - */ - public static function escapeText($text, $addApostrophes = false) { - $dangers = array('\\', '"', "\n"); - $replacements = array('\\\\', '\\"', '\\n'); - $escapedText = str_ireplace($dangers, $replacements, $text); - if ($addApostrophes) { - $escapedText = '"' . $escapedText . '"'; - } - return $escapedText; - } + /** + * 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 (optional) If the code should be isolated in an own block + * @return string + */ + public static function getLabelImplementationBlock($labelName, $implementationCode, $isolate = true) + { + if ($isolate) { + $implementationCode = "if(True){{$implementationCode}}"; + } + return " +***{$labelName}*** +***{$implementationCode}*** +"; + } - /** - * Get the 'Real' string representation of the given value - * - * @param float $value Float value to convert to a ManiaScript 'Real' - * @return string - */ - public static function getReal($value) { - $value = (float)$value; - $stringVal = (string)$value; - if (!fmod($value, 1)) { - $stringVal .= '.'; - } - return $stringVal; - } + /** + * Escape dangerous characters in the given text + * + * @api + * @param string $text Text to escape + * @param bool $addApostrophes (optional) Add apostrophes before and after the text + * @return string + */ + public static function escapeText($text, $addApostrophes = true) + { + $dangers = array('\\', '"', "\n"); + $replacements = array('\\\\', '\\"', '\\n'); + $escapedText = str_ireplace($dangers, $replacements, $text); + if ($addApostrophes) { + $escapedText = '"' . $escapedText . '"'; + } + return $escapedText; + } - /** - * Get the 'Boolean' string representation of the given value - * - * @param bool $value Value to convert to a ManiaScript 'Boolean' - * @return string - */ - public static function getBoolean($value) { - $bool = (bool)$value; - if ($bool) { - return 'True'; - } - return 'False'; - } + /** + * 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 string representation of the given array - * - * @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 = '['; - $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; - } - if ($index < $count - 1) { - $arrayText .= ', '; - $index++; - } - } - $arrayText .= ']'; - return $arrayText; - } + /** + * 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) + { + $value = (float)$value; + $stringVal = (string)$value; + if (!fmod($value, 1)) { + $stringVal .= "."; + } + return $stringVal; + } - /** - * Get the include command for the given file and namespace - * - * @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) { - $namespace = $file; - } - $file = static::escapeText($file, true); - $includeText = "#Include {$file}"; - if ($namespace) { - $includeText .= " as {$namespace}"; - } - $includeText .= PHP_EOL; - return $includeText; - } + /** + * 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) + { + $bool = (bool)$value; + if ($bool) { + return "True"; + } + 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 = "["; + $index = 0; + $count = count($array); + foreach ($array as $key => $value) { + if ($associative) { + $arrayText .= static::getValue($key); + $arrayText .= " => "; + } + $arrayText .= static::getValue($value); + if ($index < $count - 1) { + $arrayText .= ", "; + $index++; + } + } + 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) { + $namespace = $file; + } + $file = static::escapeText($file); + $includeText = "#Include {$file}"; + if ($namespace) { + $includeText .= " as {$namespace}"; + } + 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) + { + $value = static::getValue($value); + return "#Const {$name} {$value} +"; + } - /** - * Get the constant command for the given name and value - * - * @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; - } } diff --git a/libs/FML/Script/Features/ActionTrigger.php b/libs/FML/Script/Features/ActionTrigger.php index 32aa2d6a..fc6b393b 100644 --- a/libs/FML/Script/Features/ActionTrigger.php +++ b/libs/FML/Script/Features/ActionTrigger.php @@ -9,104 +9,159 @@ 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 - */ - protected $actionName = null; - /** @var Control $control */ - protected $control = null; - protected $labelName = null; +class ActionTrigger extends ScriptFeature +{ - /** - * Construct a new Action Trigger Feature - * - * @param string $actionName (optional) Triggered action - * @param Control $control (optional) Action Control - * @param string $labelName (optional) Script Label name - */ - public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) { - if ($actionName !== null) { - $this->setActionName($actionName); - } - if ($control !== null) { - $this->setControl($control); - } - if ($labelName !== null) { - $this->setLabelName($labelName); - } - } + /** + * @var string $actionName Triggered action + */ + protected $actionName = null; - /** - * Set the action to trigger - * - * @param string $actionName - * @return static - */ - public function setActionName($actionName) { - $this->actionName = (string)$actionName; - return $this; - } + /** + * @var Control $control Action Control + */ + protected $control = null; - /** - * Set the Control - * - * @param Control $control Action Control - * @return static - */ - public function setControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->control = $control; - return $this; - } + /** + * @var string $labelName Script label name + */ + protected $labelName = null; - /** - * Set the label name - * - * @param string $labelName Script Label name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - return $this; - } + /** + * 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 + */ + public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) + { + if ($actionName) { + $this->setActionName($actionName); + } + if ($control) { + $this->setControl($control); + } + if ($labelName) { + $this->setLabelName($labelName); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); - return $this; - } + /** + * Get the action to trigger + * + * @api + * @return string + */ + public function getActionName() + { + return $this->actionName; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $actionName = Builder::escapeText($this->actionName, true); - if ($this->control) { - // Control event - $controlId = Builder::escapeText($this->control->getId(), true); - $scriptText = " + /** + * Set the action to trigger + * + * @api + * @param string $actionName Action name + * @return static + */ + public function setActionName($actionName) + { + $this->actionName = (string)$actionName; + return $this; + } + + /** + * 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 = null) + { + if ($control) { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + } + $this->control = $control; + return $this; + } + + /** + * 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) + { + $this->labelName = (string)$labelName; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $actionName = Builder::escapeText($this->actionName); + if ($this->control) { + // Control event + $controlId = Builder::escapeText($this->control->getId()); + $scriptText = " if (Event.Control.ControlId == {$controlId}) { TriggerPageAction({$actionName}); }"; - } else { - // Other - $scriptText = " + } else { + // Other + $scriptText = " TriggerPageAction({$actionName});"; - } - return $scriptText; - } + } + return $scriptText; + } + } diff --git a/libs/FML/Script/Features/CheckBoxFeature.php b/libs/FML/Script/Features/CheckBoxFeature.php index b4fa40fd..8e57bda0 100644 --- a/libs/FML/Script/Features/CheckBoxFeature.php +++ b/libs/FML/Script/Features/CheckBoxFeature.php @@ -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,145 +14,213 @@ 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 { - /* - * 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'; +class CheckBoxFeature extends ScriptFeature +{ - /* - * Protected properties - */ - /** @var Quad $quad */ - protected $quad = null; - /** @var Entry $entry */ - protected $entry = null; - protected $default = null; - /** @var CheckBoxDesign $enabledDesign */ - protected $enabledDesign = null; - /** @var CheckBoxDesign $disabledDesign */ - protected $disabledDesign = null; + /* + * 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"; - /** - * Construct a new CheckBox Feature - * - * @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) { - $this->setQuad($quad); - } - if ($entry !== null) { - $this->setEntry($entry); - } - if ($default !== null) { - $this->setDefault($default); - } - $this->setEnabledDesign(CheckBoxDesign::defaultEnabledDesign()); - $this->setDisabledDesign(CheckBoxDesign::defaultDisabledDesign()); - } + /** + * @var Quad $quad CheckBox Quad + */ + protected $quad = null; - /** - * Set the CheckBox Quad - * - * @param Quad $quad CheckBox Quad - * @return static - */ - public function setQuad(Quad $quad) { - $this->quad = $quad->checkId()->setScriptEvents(true); - return $this; - } + /** + * @var Entry $entry Hidden Entry for submitting the value + */ + protected $entry = null; - /** - * Get the CheckBox Quad - * - * @return \FML\Controls\Quad - */ - public function getQuad() { - return $this->quad; - } + /** + * @var bool $default Default value + */ + protected $default = null; - /** - * Set the CheckBox Entry - * - * @param Entry $entry CheckBox Entry - * @return static - */ - public function setEntry(Entry $entry) { - $this->entry = $entry->checkId(); - return $this; - } + /** + * @var CheckBoxDesign $enabledDesign Enabled Design + */ + protected $enabledDesign = null; - /** - * Get the managed Entry - * - * @return \FML\Controls\Entry - */ - public function getEntry() { - return $this->entry; - } + /** + * @var CheckBoxDesign $disabledDesign Disabled Design + */ + protected $disabledDesign = null; - /** - * Set the default value - * - * @param bool $default Default value - * @return static - */ - public function setDefault($default) { - $this->default = (bool)$default; - return $this; - } + /** + * 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) { + $this->setQuad($quad); + } + if ($entry) { + $this->setEntry($entry); + } + if ($default !== null) { + $this->setDefault($default); + } + $this->setEnabledDesign(CheckBoxDesign::defaultDesign()); + $this->setDisabledDesign(CheckBoxDesign::defaultDesign()); + } - /** - * Set the enabled Design - * - * @param CheckBoxDesign $checkBoxDesign Enabled CheckBox Design - * @return static - */ - public function setEnabledDesign(CheckBoxDesign $checkBoxDesign) { - $this->enabledDesign = $checkBoxDesign; - return $this; - } + /** + * Get the CheckBox Quad + * + * @api + * @return Quad + */ + public function getQuad() + { + return $this->quad; + } - /** - * Set the disabled Design - * - * @param CheckBoxDesign $checkBoxDesign Disabled CheckBox Design - * @return static - */ - public function setDisabledDesign(CheckBoxDesign $checkBoxDesign) { - $this->disabledDesign = $checkBoxDesign; - return $this; - } + /** + * Set the CheckBox Quad + * + * @api + * @param Quad $quad CheckBox Quad + * @return static + */ + public function setQuad(Quad $quad) + { + $quad->checkId(); + $quad->setScriptEvents(true); + $this->quad = $quad; + return $this; + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - if ($this->getQuad()) { - $script->setScriptInclude(ScriptInclude::TEXTLIB); - $script->addScriptFunction(self::FUNCTION_UPDATE_QUAD_DESIGN, $this->buildUpdateQuadDesignFunction()); - $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true); - $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText()); - } - return $this; - } + /** + * Get the hidden Entry + * + * @api + * @return Entry + */ + public function getEntry() + { + return $this->entry; + } - /** - * Build the function text - * - * @return string - */ - protected function buildUpdateQuadDesignFunction() { - return " + /** + * 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) + { + $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) + { + $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) + { + $this->disabledDesign = $checkBoxDesign; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + if ($this->getQuad()) { + $script->setScriptInclude(ScriptInclude::TEXTLIB); + $script->addScriptFunction(self::FUNCTION_UPDATE_QUAD_DESIGN, $this->buildUpdateQuadDesignFunction()); + $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true); + $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText()); + } + return $this; + } + + /** + * Build the function text + * + * @return string + */ + protected function buildUpdateQuadDesignFunction() + { + return " Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) { declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True; Enabled = !Enabled; @@ -160,62 +228,69 @@ 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\"; + } + } } }"; - } + } - /** - * Build the init script text - * - * @return string - */ - protected function buildInitScriptText() { - $quadId = $this->getQuad()->getId(true, true); - $entryId = '""'; - if ($this->entry) { - $entryId = $this->entry->getId(true, true); - } - $default = Builder::getBoolean($this->default); - $enabledDesignString = $this->enabledDesign->getDesignString(); - $disabledDesignString = $this->disabledDesign->getDesignString(); - return " -declare Quad_CheckBox <=> (Page.GetFirstChild({$quadId}) as CMlQuad); + /** + * Build the init script text + * + * @return string + */ + protected function buildInitScriptText() + { + $quadId = Builder::getId($this->getQuad()); + $entryId = Builder::EMPTY_STRING; + if ($this->entry) { + $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 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); "; - } + } - /** - * Build the script text for Quad clicks - * - * @return string - */ - protected function buildClickScriptText() { - $quadId = $this->getQuad()->getId(true, true); - return " -if (Event.ControlId == {$quadId}) { + /** + * Build the script text for Quad clicks + * + * @return string + */ + protected function buildClickScriptText() + { + $quadId = Builder::getId($this->getQuad()); + return " +if (Event.ControlId == \"{$quadId}\") { declare Quad_CheckBox <=> (Event.Control as CMlQuad); " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox); }"; - } + } + } diff --git a/libs/FML/Script/Features/Clock.php b/libs/FML/Script/Features/Clock.php index 2efd528c..92b25302 100644 --- a/libs/FML/Script/Features/Clock.php +++ b/libs/FML/Script/Features/Clock.php @@ -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,95 +12,149 @@ 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 - */ - /** @var Label $label */ - protected $label = null; - protected $showSeconds = null; - protected $showFullDate = null; +class Clock extends ScriptFeature +{ - /** - * Construct a new Clock Feature - * - * @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 - */ - public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) { - if ($label !== null) { - $this->setLabel($label); - } - $this->setShowSeconds($showSeconds); - $this->setShowFullDate($showFullDate); - } + /** + * @var Label $label Clock Label + */ + protected $label = null; - /** - * Set the Label - * - * @param Label $label Clock Label - * @return static - */ - public function setLabel(Label $label) { - $this->label = $label->checkId(); - return $this; - } + /** + * @var bool $showSeconds Show the seconds + */ + protected $showSeconds = null; - /** - * Set whether seconds should be shown - * - * @param bool $showSeconds Whether seconds should be shown - * @return static - */ - public function setShowSeconds($showSeconds) { - $this->showSeconds = (bool)$showSeconds; - return $this; - } + /** + * @var bool $showFullDate Show the date + */ + protected $showFullDate = null; - /** - * Set whether the full date should be shown - * - * @param bool $showFullDate Whether the full date should be shown - * @return static - */ - public function setShowFullDate($showFullDate) { - $this->showFullDate = (bool)$showFullDate; - return $this; - } + /** + * Construct a new Clock + * + * @api + * @param Label $label (optional) Clock Label + * @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) { + $this->setLabel($label); + } + $this->setShowSeconds($showSeconds) + ->setShowFullDate($showFullDate); + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->setScriptInclude(ScriptInclude::TEXTLIB); - $script->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true); - return $this; - } + /** + * Get the Label + * + * @api + * @return Label + */ + public function getLabel() + { + return $this->label; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $controlId = $this->label->getId(true, true); - $scriptText = " + /** + * Set the Label + * + * @api + * @param Label $label Clock Label + * @return static + */ + public function setLabel(Label $label) + { + $label->checkId(); + $this->label = $label; + return $this; + } + + /** + * Get if 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) + { + $this->showSeconds = (bool)$showSeconds; + return $this; + } + + /** + * Get if 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) + { + $this->showFullDate = (bool)$showFullDate; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->setScriptInclude(ScriptInclude::TEXTLIB) + ->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $controlId = Builder::escapeText($this->label->getId()); + $scriptText = " declare ClockLabel <=> (Page.GetFirstChild({$controlId}) as CMlLabel); declare TimeText = CurrentLocalDateText;"; - if (!$this->showSeconds) { - $scriptText .= " + if (!$this->showSeconds) { + $scriptText .= " TimeText = TextLib::SubText(TimeText, 0, 16);"; - } - if (!$this->showFullDate) { - $scriptText .= " + } + if (!$this->showFullDate) { + $scriptText .= " TimeText = TextLib::SubText(TimeText, 11, 9);"; - } - $scriptText .= " + } + $scriptText .= " ClockLabel.Value = TimeText;"; - return $scriptText; - } + return $scriptText; + } + } diff --git a/libs/FML/Script/Features/ControlScript.php b/libs/FML/Script/Features/ControlScript.php index 30f5782b..1bd2ab29 100644 --- a/libs/FML/Script/Features/ControlScript.php +++ b/libs/FML/Script/Features/ControlScript.php @@ -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,115 +12,179 @@ 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 - */ - /** @var Control $control */ - protected $control = null; - protected $labelName = null; - protected $text = null; +class ControlScript extends ScriptFeature +{ - /** - * Construct a new Control Script - * - * @param Control $control Event Control - * @param string $text Script text - * @param string $labelName (optional) Script Label name - */ - public function __construct(Control $control, $text, $labelName = ScriptLabel::MOUSECLICK) { - $this->setControl($control); - $this->setText($text); - $this->setLabelName($labelName); - } + /** + * @var Control $control Control + */ + protected $control = null; - /** - * Set the Control - * - * @param Control $control Event Control - * @return static - */ - public function setControl(Control $control) { - $this->control = $control->checkId(); - $this->updateScriptEvents(); - return $this; - } + /** + * @var string $labelName Script Label name + */ + protected $labelName = null; - /** - * Set the script text - * - * @param string $text Script text - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * @var string $scriptText Script text + */ + protected $scriptText = null; - /** - * Set the label name - * - * @param string $labelName Script Label name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - $this->updateScriptEvents(); - return $this; - } + /** + * Construct a new Control Script + * + * @api + * @param Control $control (optional) Control + * @param string $scriptText (optional) Script text + * @param string $labelName (optional) Script Label name + */ + public function __construct(Control $control = null, $scriptText = null, $labelName = ScriptLabel::MOUSECLICK) + { + if ($control) { + $this->setControl($control); + } + if ($scriptText) { + $this->setScriptText($scriptText); + } + if ($labelName) { + $this->setLabelName($labelName); + } + } - /** - * Enable Script Events on the Control if needed - */ - protected function updateScriptEvents() { - if (!$this->control || !ScriptLabel::isEventLabel($this->labelName)) { - return; - } - if ($this->control instanceof Scriptable) { - $this->control->setScriptEvents(true); - } - } + /** + * Get the Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $isolated = !ScriptLabel::isEventLabel($this->labelName); - $script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), $isolated); - return $this; - } + /** + * Set the Control + * + * @api + * @param Control $control Control + * @return static + */ + 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 + * + * @api + * @param string $scriptText Script text + * @return static + */ + public function setScriptText($scriptText) + { + $this->scriptText = (string)$scriptText; + return $this; + } + + /** + * 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) + { + $this->labelName = (string)$labelName; + $this->updateScriptEvents(); + return $this; + } + + /** + * Enable Script Events on the Control if needed + * + * @return static + */ + protected function updateScriptEvents() + { + if (!$this->control || !ScriptLabel::isEventLabel($this->labelName)) { + return $this; + } + if ($this->control instanceof Scriptable) { + $this->control->setScriptEvents(true); + } + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $isolated = !ScriptLabel::isEventLabel($this->labelName); + $script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), $isolated); + return $this; + } + + /** + * Build the script text for the Control + * + * @return string + */ + 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;"; + $closeBlock = true; + } else { + $scriptText .= " +declare Control <=> Page.GetFirstChild({$controlId});"; + } + $class = $this->control->getManiaScriptClass(); + $name = preg_replace('/^CMl/', '', $class, 1); + $scriptText .= " +declare {$name} <=> (Control as {$class}); +"; + $scriptText .= $this->scriptText . " +"; + if ($closeBlock) { + $scriptText .= "}"; + } + return $scriptText; + } - /** - * Build the script text for the Control - * - * @return string - */ - protected function buildScriptText() { - $controlId = $this->control->getId(true); - $scriptText = ''; - $closeBlock = false; - if (ScriptLabel::isEventLabel($this->labelName)) { - $scriptText .= ' -if (Event.ControlId == "' . $controlId . '") { -declare Control <=> Event.Control;'; - $closeBlock = true; - } else { - $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 . ' -'; - if ($closeBlock) { - $scriptText .= '}'; - } - return $scriptText; - } } diff --git a/libs/FML/Script/Features/EntrySubmit.php b/libs/FML/Script/Features/EntrySubmit.php index 4ae21094..a1842204 100644 --- a/libs/FML/Script/Features/EntrySubmit.php +++ b/libs/FML/Script/Features/EntrySubmit.php @@ -12,90 +12,131 @@ 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 - */ - /** @var Entry $entry */ - protected $entry = null; - protected $url = null; +class EntrySubmit extends ScriptFeature +{ - /** - * Construct a new Entry Submit Feature - * - * @param Entry $entry (optional) Entry Control - * @param string $url (optional) Submit url - */ - public function __construct(Entry $entry = null, $url = null) { - if ($entry !== null) { - $this->setEntry($entry); - } - $this->setUrl($url); - } + /** + * @var Entry $entry Entry + */ + protected $entry = null; - /** - * Set the Entry - * - * @param Entry $entry Entry Control - * @return static - */ - public function setEntry(Entry $entry) { - $this->entry = $entry->checkId()->setScriptEvents(true); - return $this; - } + /** + * @var string $url Sumit url + */ + protected $url = null; - /** - * Set the submit url - * - * @param string $url Submit url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * 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) { + $this->setEntry($entry); + } + if ($url) { + $this->setUrl($url); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->setScriptInclude(ScriptInclude::TEXTLIB); - $controlScript = new ControlScript($this->entry, $this->getScriptText(), ScriptLabel::ENTRYSUBMIT); - $controlScript->prepare($script); - return $this; - } + /** + * Get the Entry + * + * @api + * @return Entry + */ + public function getEntry() + { + return $this->entry; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $url = $this->buildCompatibleUrl(); - $entryName = $this->entry->getName(); - $link = Builder::escapeText($entryName . $url . '=', true); - return " + /** + * Set the Entry + * + * @api + * @param Entry $entry Entry Control + * @return static + */ + 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) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->setScriptInclude(ScriptInclude::TEXTLIB); + $controlScript = new ControlScript($this->entry, $this->getScriptText(), ScriptLabel::ENTRYSUBMIT); + $controlScript->prepare($script); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $url = $this->buildCompatibleUrl(); + $entryName = $this->entry->getName(); + $link = Builder::escapeText($entryName . $url . "="); + return " declare Value = TextLib::URLEncode(Entry.Value); OpenLink({$link}^Value, CMlScript::LinkType::Goto); "; - } + } + + /** + * Build the submit url compatible for the Entry parameter + * + * @return string + */ + protected function buildCompatibleUrl() + { + $url = $this->url; + $paramsBegin = stripos($url, '?'); + if (!is_int($paramsBegin) || $paramsBegin < 0) { + $url .= '?'; + } else { + $url .= '&'; + } + return $url; + } - /** - * Build the submit url compatible for the Entry parameter - * - * @return string - */ - protected function buildCompatibleUrl() { - $url = $this->url; - $paramsBegin = stripos($url, '?'); - if (!is_int($paramsBegin) || $paramsBegin < 0) { - $url .= '?'; - } else { - $url .= '&'; - } - return $url; - } } diff --git a/libs/FML/Script/Features/GraphCurve.php b/libs/FML/Script/Features/GraphCurve.php new file mode 100644 index 00000000..5dad1ab9 --- /dev/null +++ b/libs/FML/Script/Features/GraphCurve.php @@ -0,0 +1,303 @@ +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 . " +}"; + } + +} diff --git a/libs/FML/Script/Features/KeyAction.php b/libs/FML/Script/Features/KeyAction.php index c5d5e6aa..f51f0524 100644 --- a/libs/FML/Script/Features/KeyAction.php +++ b/libs/FML/Script/Features/KeyAction.php @@ -11,114 +11,185 @@ 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 - */ - protected $actionName = null; - protected $keyName = null; - protected $keyCode = null; - protected $charPressed = null; +class KeyAction extends ScriptFeature +{ - /** - * Construct a new Key Action Feature - * - * @param string $actionName (optional) Triggered action - * @param string $keyName (optional) Key name - */ - public function __construct($actionName = null, $keyName = null) { - if ($actionName !== null) { - $this->setActionName($actionName); - } - if ($keyName !== null) { - $this->setKeyName($keyName); - } - } + /** + * @var string $actionName Action name + */ + protected $actionName = null; - /** - * Set the action to trigger - * - * @param string $actionName Triggered action - * @return static - */ - public function setActionName($actionName) { - $this->actionName = (string)$actionName; - return $this; - } + /** + * @var string $keyName Key name + */ + protected $keyName = null; - /** - * Set the key name for triggering the action - * - * @param string $keyName Key Name - * @return static - */ - public function setKeyName($keyName) { - $this->keyName = (string)$keyName; - $this->keyCode = null; - $this->charPressed = null; - return $this; - } + /** + * @var int $keyCode Key code + */ + protected $keyCode = null; - /** - * Set the key code for triggering the action - * - * @param int $keyCode Key Code - * @return static - */ - public function setKeyCode($keyCode) { - $this->keyCode = (int)$keyCode; - $this->keyName = null; - $this->charPressed = null; - return $this; - } + /** + * @var string $charPressed Pressed character + */ + protected $charPressed = null; - /** - * Set the char to press for triggering the action - * - * @param string $charPressed Pressed char - * @return static - */ - public function setCharPressed($charPressed) { - $this->charPressed = (string)$charPressed; - $this->keyName = null; - $this->keyCode = null; - return $this; - } + /** + * 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) { + $this->setActionName($actionName); + } + if ($keyName) { + $this->setKeyName($keyName); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel(ScriptLabel::KEYPRESS, $this->getScriptText()); - return $this; - } + /** + * Get the action to trigger + * + * @api + * @return string + */ + public function getActionName() + { + return $this->actionName; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $actionName = Builder::escapeText($this->actionName, true); - $key = null; - $value = null; - if ($this->keyName !== null) { - $key = 'KeyName'; - $value = $this->keyName; - } else if ($this->keyCode !== null) { - $key = 'KeyCode'; - $value = $this->keyCode; - } else if ($this->charPressed !== null) { - $key = 'CharPressed'; - $value = $this->charPressed; - } - $value = Builder::escapeText($value, true); - return " + /** + * Set the action to trigger + * + * @api + * @param string $actionName Triggered action + * @return static + */ + 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) + { + $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->keyName = null; + $this->keyCode = (int)$keyCode; + $this->charPressed = null; + return $this; + } + + /** + * Get the character to press for triggering the action + * + * @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->keyName = null; + $this->keyCode = null; + $this->charPressed = (string)$charPressed; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel(ScriptLabel::KEYPRESS, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $actionName = Builder::escapeText($this->actionName); + $key = null; + $value = null; + if ($this->keyName !== null) { + $key = "KeyName"; + $value = $this->keyName; + } else if ($this->keyCode !== null) { + $key = "KeyCode"; + $value = $this->keyCode; + } else if ($this->charPressed !== null) { + $key = "CharPressed"; + $value = $this->charPressed; + } + $value = Builder::escapeText($value); + return " if (Event.{$key} == {$value}) { TriggerPageAction({$actionName}); }"; - } + } + } diff --git a/libs/FML/Script/Features/MapInfo.php b/libs/FML/Script/Features/MapInfo.php index 93ea9e6d..ce29d5e8 100644 --- a/libs/FML/Script/Features/MapInfo.php +++ b/libs/FML/Script/Features/MapInfo.php @@ -12,80 +12,119 @@ 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 - */ - /** @var Control $control */ - protected $control = null; - protected $labelName = null; +class MapInfo extends ScriptFeature +{ - /** - * Construct a new Map Info Feature - * - * @param Control $control (optional) Map Info Control - * @param string $labelName (optional) Script Label name - */ - public function __construct(Control $control, $labelName = ScriptLabel::MOUSECLICK) { - $this->setControl($control); - $this->setLabelName($labelName); - } + /** + * @var Control $control Map Info Control + */ + protected $control = null; - /** - * Set the Control - * - * @param Control $control Map Info Control - * @return static - */ - public function setControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->control = $control; - return $this; - } + /** + * @var string $labelName Script Label name + */ + protected $labelName = null; - /** - * Set the label name - * - * @param string $labelName Script Label name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - return $this; - } + /** + * 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 = null, $labelName = ScriptLabel::MOUSECLICK) + { + if ($control) { + $this->setControl($control); + } + if ($labelName) { + $this->setLabelName($labelName); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); - return $this; - } + /** + * Get the Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - if ($this->control) { - // Control event - $controlId = Builder::escapeText($this->control->getId(), true); - $scriptText = " + /** + * Set the Control + * + * @api + * @param Control $control Map Info Control + * @return static + */ + public function setControl(Control $control) + { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + $this->control = $control; + return $this; + } + + /** + * 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) + { + $this->labelName = (string)$labelName; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + if ($this->control) { + // Control event + $controlId = Builder::escapeText($this->control->getId()); + return " if (Event.Control.ControlId == {$controlId}) { ShowCurChallengeCard(); }"; - } else { - // Other - $scriptText = " + } + + // Other events + return " ShowCurChallengeCard();"; - } - return $scriptText; - } + } + } diff --git a/libs/FML/Script/Features/Menu.php b/libs/FML/Script/Features/Menu.php index 8883f226..9e8ace41 100644 --- a/libs/FML/Script/Features/Menu.php +++ b/libs/FML/Script/Features/Menu.php @@ -11,130 +11,173 @@ 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 { - /* - * Constants - */ - const FUNCTION_UPDATE_MENU = 'FML_UpdateMenu'; +class Menu extends ScriptFeature +{ - /* - * Protected properties - */ - /** @var MenuElement[] $elements */ - protected $elements = array(); - /** @var MenuElement $startElement */ - protected $startElement = null; + /* + * Constants + */ + const FUNCTION_UPDATE_MENU = "FML_UpdateMenu"; - /** - * Construct a new Menu Feature - * - * @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 && $control) { - $this->addElement($item, $control); - } - } + /** + * @var MenuElement[] $elements Menu Elements + */ + protected $elements = array(); - /** - * Add a new Element to the Menu - * - * @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) { - $menuElement = new MenuElement($item, $control); - $this->appendElement($menuElement, $isStartElement); - return $this; - } + /** + * @var MenuElement $startElement Start Element + */ + protected $startElement = null; - /** - * Append an Element to the Menu - * - * @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) { - if (!in_array($menuElement, $this->elements, true)) { - array_push($this->elements, $menuElement); - if ($isStartElement) { - $this->setStartElement($menuElement); - } else if (count($this->elements) > 1) { - $menuElement->getControl()->setVisible(false); - } - } - return $this; - } + /** + * 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, $isStartElement = true) + { + if ($item && $control) { + $this->addItem($item, $control, $isStartElement); + } + } - /** - * Set the Element to start with - * - * @param MenuElement $startElement Starting Element - * @return static - */ - public function setStartElement(MenuElement $startElement) { - $this->startElement = $startElement; - if (!in_array($startElement, $this->elements, true)) { - array_push($this->elements, $startElement); - } - return $this; - } + /** + * Get the Menu Elements + * + * @api + * @return MenuElement[] + */ + public function getElements() + { + return $this->elements; + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $updateFunctionName = self::FUNCTION_UPDATE_MENU; - $elementsArrayText = $this->getElementsArrayText(); + /** + * 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 addItem(Control $item, Control $control, $isStartElement = false) + { + $menuElement = new MenuElement($item, $control); + $this->addElement($menuElement, $isStartElement); + return $this; + } - // OnInit - if ($this->startElement) { - $startControlId = $this->startElement->getControl()->getId(true, true); - $initScriptText = " + /** + * 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 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 { + // 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 + * + * @api + * @param MenuElement $startElement Start Element + * @return static + */ + public function setStartElement(MenuElement $startElement = null) + { + $this->startElement = $startElement; + if ($startElement && !in_array($startElement, $this->elements, true)) { + array_push($this->elements, $startElement); + } + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $updateFunctionName = self::FUNCTION_UPDATE_MENU; + $elementsArrayText = $this->getElementsArrayText(); + + // OnInit + if ($this->startElement) { + $startControlId = Builder::escapeText($this->startElement->getControl()->getId()); + $initScriptText = " {$updateFunctionName}({$elementsArrayText}, {$startControlId});"; - $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); - } + $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); + } - // MouseClick - $scriptText = " + // MouseClick + $scriptText = " declare MenuElements = {$elementsArrayText}; if (MenuElements.existskey(Event.Control.ControlId)) { declare ShownControlId = MenuElements[Event.Control.ControlId]; {$updateFunctionName}(MenuElements, ShownControlId); }"; - $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true); + $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true); - // Update menu function - $updateFunctionText = " + // Update menu function + $updateFunctionText = " Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) { foreach (ItemId => ControlId in _Elements) { declare Control <=> (Page.GetFirstChild(ControlId)); Control.Visible = (ControlId == _ShownControlId); } }"; - $script->addScriptFunction($updateFunctionName, $updateFunctionText); + $script->addScriptFunction($updateFunctionName, $updateFunctionText); - return $this; - } + return $this; + } + + /** + * Build the array text for the Elements + * + * @return string + */ + protected function getElementsArrayText() + { + $elements = array(); + foreach ($this->elements as $element) { + $elementId = $element->getItem() + ->getId(); + $elements[$elementId] = $element->getControl() + ->getId(); + } + return Builder::getArray($elements, true); + } - /** - * Build the array text for the Elements - * - * @return string - */ - protected function getElementsArrayText() { - $elements = array(); - foreach ($this->elements as $element) { - $elementId = $element->getItem()->getId(); - $elements[$elementId] = $element->getControl()->getId(); - } - return Builder::getArray($elements, true); - } } diff --git a/libs/FML/Script/Features/MenuElement.php b/libs/FML/Script/Features/MenuElement.php index d67a113f..a9fb48ef 100644 --- a/libs/FML/Script/Features/MenuElement.php +++ b/libs/FML/Script/Features/MenuElement.php @@ -9,72 +9,90 @@ use FML\Types\Scriptable; * Menu Element for the Menu Feature * * @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 MenuElement { - /* - * Protected properties - */ - protected $item = null; - protected $control = null; +class MenuElement +{ - /** - * Create a new Menu Element - * - * @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) { - $this->setItem($item); - } - if ($control !== null) { - $this->setControl($control); - } - } + /** + * @var Control $item Menu Item + */ + protected $item = null; - /** - * Set the Item Control - * - * @param Control $item Item Control in the Menu bar - * @return static - */ - public function setItem(Control $item) { - $item->checkId(); - if ($item instanceof Scriptable) { - $item->setScriptEvents(true); - } - $this->item = $item; - return $this; - } + /** + * @var Control $control Menu Control + */ + protected $control = null; - /** - * Get the Item Control - * - * @return \FML\Controls\Control - */ - public function getItem() { - return $this->item; - } + /** + * 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) { + $this->setItem($item); + } + if ($control) { + $this->setControl($control); + } + } - /** - * Set the Menu Control - * - * @param Control $control Toggled Menu Control - * @return static - */ - public function setControl(Control $control) { - $this->control = $control->checkId(); - return $this; - } + /** + * Get the Item Control + * + * @api + * @return Control + */ + public function getItem() + { + return $this->item; + } + + /** + * Set the Item Control + * + * @api + * @param Control $item Item Control + * @return static + */ + public function setItem(Control $item) + { + $item->checkId(); + if ($item instanceof Scriptable) { + $item->setScriptEvents(true); + } + $this->item = $item; + return $this; + } + + /** + * Get the Menu Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } + + /** + * Set the Menu Control + * + * @api + * @param Control $control Menu Control + * @return static + */ + 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; - } } diff --git a/libs/FML/Script/Features/Paging.php b/libs/FML/Script/Features/Paging.php index 3a1a743b..fc995309 100644 --- a/libs/FML/Script/Features/Paging.php +++ b/libs/FML/Script/Features/Paging.php @@ -10,235 +10,418 @@ 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 - * @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 { - /* - * Constants - */ - const VAR_CURRENT_PAGE = 'FML_Paging_CurrentPage'; - const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage'; +class Paging extends ScriptFeature +{ - /* - * Protected properties - */ - /** @var PagingPage[] $pages */ - protected $pages = array(); - /** @var PagingButton[] $buttons */ - protected $buttons = array(); - /** @var Label $label */ - protected $label = null; - protected $startPageNumber = null; - protected $customMaxPageNumber = null; - protected $previousChunkAction = null; - protected $nextChunkAction = null; - protected $chunkActionAppendsPageNumber = null; + /* + * Constants + */ + const VAR_CURRENT_PAGE = "FML_Paging_CurrentPage"; + const FUNCTION_UPDATE_CURRENT_PAGE = "FML_UpdateCurrentPage"; - /** - * Construct a new Paging Script Feature - * - * @param Label $label (optional) Page number Label - */ - public function __construct(Label $label = null) { - if ($label !== null) { - $this->setLabel($label); - } - } + /** + * @var Label $label Page number Label + */ + protected $label = null; - /** - * Add a new Page Control - * - * @param Control $pageControl Page Control - * @param string $pageNumber (optional) Page number - * @return static - */ - public function addPage(Control $pageControl, $pageNumber = null) { - if ($pageNumber === null) { - $pageNumber = count($this->pages) + 1; - } - $page = new PagingPage($pageControl, $pageNumber); - $this->appendPage($page); - return $this; - } + /** + * @var PagingPage[] $pages Pages + */ + protected $pages = array(); - /** - * Append a Page - * - * @param PagingPage $page Paging Page - * @return static - */ - public function appendPage(PagingPage $page) { - if (!in_array($page, $this->pages, true)) { - array_push($this->pages, $page); - } - return $this; - } + /** + * @var PagingButton[] $buttons Paging Buttons + */ + protected $buttons = array(); - /** - * Add a new Button to browse through the Pages - * - * @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) { - if ($browseAction === null) { - $buttonCount = count($this->buttons); - if ($buttonCount % 2 === 0) { - $browseAction = $buttonCount / 2 + 1; - } else { - $browseAction = $buttonCount / -2 - 1; - } - } - $button = new PagingButton($buttonControl, $browseAction); - $this->appendButton($button); - return $this; - } + /** + * @var int $startPageNumber Start Page number + */ + protected $startPageNumber = null; - /** - * Append a Button to browse through Pages - * - * @param PagingButton $button Paging Button - * @return static - */ - public function appendButton(PagingButton $button) { - if (!in_array($button, $this->buttons, true)) { - array_push($this->buttons, $button); - } - return $this; - } + /** + * @var int $customMaxPageNumber Custom maximum page number + */ + protected $customMaxPageNumber = null; - /** - * Set the Label showing the Page number - * - * @param Label $label Page number Label - * @return static - */ - public function setLabel(Label $label) { - $this->label = $label->checkId(); - return $this; - } + /** + * @var string $previousChunkAction Previous chunk action name + */ + protected $previousChunkAction = null; - /** - * Set the Start Page number - * - * @param int $startPageNumber Page number to start with - * @return static - */ - public function setStartPageNumber($startPageNumber) { - $this->startPageNumber = (int)$startPageNumber; - } + /** + * @var string $nextChunkAction Next chunk action name + */ + protected $nextChunkAction = null; - /** - * Set a custom maximum Page number for using chunks - * - * @param int $maxPageNumber Custom maximum Page number - * @return static - */ - public function setCustomMaxPageNumber($maxPageNumber) { - $this->customMaxPageNumber = (int)$maxPageNumber; - return $this; - } + /** + * @var bool $chunkActionAppendsPageNumber Chunk action appended with Page number + */ + protected $chunkActionAppendsPageNumber = null; - /** - * Set the action triggered when the previous chunk is needed - * - * @param string $previousChunkAction Triggered action - * @return static - */ - public function setPreviousChunkAction($previousChunkAction) { - $this->previousChunkAction = (string)$previousChunkAction; - return $this; - } + /** + * 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, array $pages = null, array $buttons = null) + { + if ($label) { + $this->setLabel($label); + } + if ($pages) { + $this->setPages($pages); + } + if ($buttons) { + $this->setButtons($buttons); + } + } - /** - * Set the action triggered when the next chunk is needed - * - * @param string $nextChunkAction Triggered action - * @return static - */ - public function setNextChunkAction($nextChunkAction) { - $this->nextChunkAction = (string)$nextChunkAction; - return $this; - } + /** + * Get the Label showing the Page number + * + * @api + * @return Label + */ + public function getLabel() + { + return $this->label; + } - /** - * Set the actions triggered when another chunk is needed - * - * @param string $chunkAction Triggered action - * @return static - */ - public function setChunkActions($chunkAction) { - $this->setNextChunkAction($chunkAction); - $this->setPreviousChunkAction($chunkAction); - return $this; - } + /** + * 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; + } - /** - * Set if the chunk action should get the needed Page number appended - * - * @param bool $appendPageNumber Whether to append the needed Page number - * @return static - */ - public function setChunkActionAppendsPageNumber($appendPageNumber) { - $this->chunkActionAppendsPageNumber = (bool)$appendPageNumber; - return $this; - } + /** + * Get the Pages + * + * @api + * @return PagingPage[] + */ + public function getPages() + { + return $this->pages; + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - if (empty($this->pages)) { - return $this; - } - $script->setScriptInclude(ScriptInclude::TEXTLIB); + /** + * Add a new Page Control + * + * @api + * @param Control $pageControl Page Control + * @param string $pageNumber (optional) Page number + * @return static + */ + public function addPageControl(Control $pageControl, $pageNumber = null) + { + if ($pageNumber === null) { + $pageNumber = count($this->pages) + 1; + } + $page = new PagingPage($pageControl, $pageNumber); + return $this->addPage($page); + } - $currentPageVariable = self::VAR_CURRENT_PAGE; - $updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE; + /** + * Add a new Page + * + * @api + * @param PagingPage $page Page + * @return static + */ + public function addPage(PagingPage $page) + { + if (!in_array($page, $this->pages, true)) { + array_push($this->pages, $page); + } + return $this; + } - $minPageNumber = 1; - $startPageNumber = (is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber); - $maxPage = $this->getMaxPage(); - $maxPageNumber = $this->customMaxPageNumber; - if (!is_int($maxPageNumber)) { - $maxPageNumber = $maxPage->getPageNumber(); - } + /** + * 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; + } - $pagingId = $maxPage->getControl()->getId(true, true); - $pageLabelId = '""'; - if ($this->label) { - $pageLabelId = $this->label->getId(true, true); - } - $pagesArrayText = $this->getPagesArrayText(); - $pageButtonsArrayText = $this->getPageButtonsArrayText(); + /** + * Get the Buttons + * + * @api + * @return PagingButton[] + */ + public function getButtons() + { + return $this->buttons; + } - $previousChunkAction = Builder::escapeText($this->previousChunkAction, true); - $nextChunkAction = Builder::escapeText($this->nextChunkAction, true); - $chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber); + /** + * 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 addButtonControl(Control $buttonControl, $browseAction = null) + { + if ($browseAction === null) { + $buttonCount = count($this->buttons); + if ($buttonCount % 2 === 0) { + $browseAction = $buttonCount / 2 + 1; + } else { + $browseAction = $buttonCount / -2 - 1; + } + } + $button = new PagingButton($buttonControl, $browseAction); + return $this->addButton($button); + } - // Init - $initScriptText = " + /** + * Add a new Button to browse through Pages + * + * @api + * @param PagingButton $button Paging Button + * @return static + */ + public function addButton(PagingButton $button) + { + if (!in_array($button, $this->buttons, true)) { + array_push($this->buttons, $button); + } + return $this; + } + + /** + * Set the Paging Buttons + * + * @api + * @param PagingButton[] $buttons Paging Buttons + * @return static + */ + public function setButtons(array $buttons) + { + $this->buttons = array(); + foreach ($buttons as $button) { + $this->addButton($button); + } + return $this; + } + + /** + * 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) + { + $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) + { + $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) + { + $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) + { + $this->nextChunkAction = (string)$nextChunkAction; + return $this; + } + + /** + * Set the actions triggered when another chunk is needed + * + * @api + * @param string $chunkAction Triggered action + * @return static + */ + public function setChunkActions($chunkAction) + { + return $this->setNextChunkAction($chunkAction) + ->setPreviousChunkAction($chunkAction); + } + + /** + * Get if the chunk action should 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) + { + $this->chunkActionAppendsPageNumber = (bool)$appendPageNumber; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + if (empty($this->pages)) { + return $this; + } + $script->setScriptInclude(ScriptInclude::TEXTLIB); + + $currentPageVariable = self::VAR_CURRENT_PAGE; + $updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE; + + $minPageNumber = 1; + $startPageNumber = (is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber); + $maxPage = $this->getMaxPage(); + $maxPageNumber = $this->customMaxPageNumber; + if (!is_int($maxPageNumber)) { + $maxPageNumber = $maxPage->getPageNumber(); + } + + $pagingId = $maxPage->getControl() + ->getId(true, true); + $pagingId = Builder::escapeText($maxPage->getControl() + ->getId()); + $pageLabelId = Builder::EMPTY_STRING; + if ($this->label) { + $pageLabelId = Builder::escapeText($this->label->getId()); + } + + $pagesArrayText = $this->getPagesArrayText(); + $pageButtonsArrayText = $this->getPageButtonsArrayText(); + + $previousChunkAction = Builder::escapeText($this->previousChunkAction); + $nextChunkAction = Builder::escapeText($this->nextChunkAction); + $chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber); + + // Init + $initScriptText = " declare {$currentPageVariable} for This = Integer[Text]; {$currentPageVariable}[{$pagingId}] = {$startPageNumber}; {$updatePageFunction}({$pagingId}, {$pageLabelId}, 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber});"; - $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); + $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); - // MouseClick - $clickScriptText = " + // MouseClick + $clickScriptText = " declare PageButtons = {$pageButtonsArrayText}; if (PageButtons.existskey(Event.Control.ControlId)) { declare BrowseAction = PageButtons[Event.Control.ControlId]; {$updatePageFunction}({$pagingId}, {$pageLabelId}, BrowseAction, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber}); }"; - $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true); + $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true); - // Update function - $functionText = " + // Update function + $functionText = " Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAction, Integer _MinPageNumber, Integer _MaxPageNumber, Text[Integer] _Pages, Text _PreviousChunkAction, Text _NextChunkAction, Boolean _ChunkActionAppendPageNumber) { declare {$currentPageVariable} for This = Integer[Text]; if (!{$currentPageVariable}.existskey(_PagingId)) return; @@ -274,75 +457,82 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct if (PageLabel == Null) return; PageLabel.Value = CurrentPage^\"/\"^_MaxPageNumber; }"; - $script->addScriptFunction($updatePageFunction, $functionText); - return $this; - } + $script->addScriptFunction($updatePageFunction, $functionText); + return $this; + } - /** - * Get the minimum Page - * - * @return \FML\Script\Features\PagingPage - */ - protected function getMinPage() { - $minPageNumber = null; - $minPage = null; - foreach ($this->pages as $page) { - $pageNumber = $page->getPageNumber(); - if ($minPageNumber === null || $pageNumber < $minPageNumber) { - $minPageNumber = $pageNumber; - $minPage = $page; - } - } - return $minPage; - } + /** + * Get the minimum Page + * + * @return PagingPage + */ + protected function getMinPage() + { + $minPageNumber = null; + $minPage = null; + foreach ($this->pages as $page) { + $pageNumber = $page->getPageNumber(); + if ($minPageNumber === null || $pageNumber < $minPageNumber) { + $minPageNumber = $pageNumber; + $minPage = $page; + } + } + return $minPage; + } - /** - * Get the maximum Page - * - * @return \FML\Script\Features\PagingPage - */ - protected function getMaxPage() { - $maxPageNumber = null; - $maxPage = null; - foreach ($this->pages as $page) { - $pageNumber = $page->getPageNumber(); - if ($maxPageNumber === null || $pageNumber > $maxPageNumber) { - $maxPageNumber = $pageNumber; - $maxPage = $page; - } - } - return $maxPage; - } + /** + * Get the maximum Page + * + * @return PagingPage + */ + protected function getMaxPage() + { + $maxPageNumber = null; + $maxPage = null; + foreach ($this->pages as $page) { + $pageNumber = $page->getPageNumber(); + if ($maxPageNumber === null || $pageNumber > $maxPageNumber) { + $maxPageNumber = $pageNumber; + $maxPage = $page; + } + } + return $maxPage; + } - /** - * Build the array text for the Pages - * - * @return string - */ - 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(); - } - return Builder::getArray($pages, true); - } + /** + * Build the array text for the Pages + * + * @return string + */ + 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(); + } + return Builder::getArray($pages, true); + } + + /** + * Build the array text for the Page Buttons + * + * @return string + */ + 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->getPagingCount(); + } + return Builder::getArray($pageButtons, true); + } - /** - * Build the array text for the Page Buttons - * - * @return string - */ - 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(); - } - return Builder::getArray($pageButtons, true); - } } diff --git a/libs/FML/Script/Features/PagingButton.php b/libs/FML/Script/Features/PagingButton.php index b6cc7af7..010c1aa6 100644 --- a/libs/FML/Script/Features/PagingButton.php +++ b/libs/FML/Script/Features/PagingButton.php @@ -9,73 +9,89 @@ use FML\Types\Scriptable; * Paging Button for browsing through Pages * * @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 PagingButton { - /* - * Protected properties - */ - /** @var Control $control */ - protected $control = null; - protected $browseAction = null; +class PagingButton +{ - /** - * Construct a new Paging Button - * - * @param Control $control (optional) Browse Control - * @param int $browseAction (optional) Number of browsed Pages per Click - */ - public function __construct(Control $control = null, $browseAction = null) { - if ($control !== null) { - $this->setControl($control); - } - if ($browseAction !== null) { - $this->setBrowseAction($browseAction); - } - } + /** + * @var Control $control Paging Control + */ + protected $control = null; - /** - * Set the Button Control - * - * @param Control $control Browse Control - * @return static - */ - public function setControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->control = $control; - return $this; - } + /** + * @var int Paging count + */ + protected $pagingCount = 1; - /** - * Get the Button Control - * - * @return \FML\Controls\Control - */ - public function getControl() { - return $this->control; - } + /** + * Construct a new Paging Button + * + * @api + * @param Control $control (optional) Paging Control + * @param int $pagingCount (optional) Number of browsed pages per click + */ + public function __construct(Control $control = null, $pagingCount = 1) + { + if ($control) { + $this->setControl($control); + } + if ($pagingCount) { + $this->setPagingCount($pagingCount); + } + } - /** - * Set the browse action - * - * @param int $browseAction Number of browsed Pages per click - * @return static - */ - public function setBrowseAction($browseAction) { - $this->browseAction = (int)$browseAction; - return $this; - } + /** + * Get the paging 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) + { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + $this->control = $control; + return $this; + } + + /** + * Get the paging count + * + * @api + * @return int + */ + public function getPagingCount() + { + return $this->pagingCount; + } + + /** + * Set the paging count + * + * @api + * @param int $pagingCount Number of browsed pages per click + * @return static + */ + public function setPagingCount($pagingCount) + { + $this->pagingCount = (int)$pagingCount; + return $this; + } - /** - * Get the browse action - * - * @return int - */ - public function getBrowseAction() { - return $this->browseAction; - } } diff --git a/libs/FML/Script/Features/PagingPage.php b/libs/FML/Script/Features/PagingPage.php index 1f2ef86a..60b9a948 100644 --- a/libs/FML/Script/Features/PagingPage.php +++ b/libs/FML/Script/Features/PagingPage.php @@ -8,67 +8,86 @@ use FML\Controls\Control; * Paging Page * * @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 PagingPage { - /* - * Protected properties - */ - /** @var Control $control */ - protected $control = null; - protected $number = null; +class PagingPage +{ - /** - * Construct a new Paging Page - * - * @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) { - $this->setControl($control); - } - $this->setPageNumber($pageNumber); - } + /** + * @var Control $control Page Control + */ + protected $control = null; - /** - * Set the Page Control - * - * @param Control $control Page Control - * @return static - */ - public function setControl(Control $control) { - $this->control = $control->checkId(); - return $this; - } + /** + * @var int $pageNumber Page number + */ + protected $pageNumber = null; - /** - * Get the Page Control - * - * @return \FML\Controls\Control - */ - public function getControl() { - return $this->control; - } + /** + * 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 = null) + { + if ($control) { + $this->setControl($control); + } + if ($pageNumber) { + $this->setPageNumber($pageNumber); + } + } - /** - * Set the Page number - * - * @param int $pageNumber Number of the Page - * @return static - */ - public function setPageNumber($pageNumber) { - $this->number = (int)$pageNumber; - return $this; - } + /** + * Get the Page Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } + + /** + * Set the Page Control + * + * @api + * @param Control $control Page Control + * @return static + */ + public function setControl(Control $control) + { + $control->checkId(); + $this->control = $control; + return $this; + } + + /** + * Get the Page number + * + * @api + * @return int + */ + 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; + } - /** - * Get the Page number - * - * @return int - */ - public function getPageNumber() { - return $this->number; - } } diff --git a/libs/FML/Script/Features/PlayerProfile.php b/libs/FML/Script/Features/PlayerProfile.php index 08d30274..0ef0f50f 100644 --- a/libs/FML/Script/Features/PlayerProfile.php +++ b/libs/FML/Script/Features/PlayerProfile.php @@ -12,97 +12,154 @@ use FML\Types\Scriptable; * Script Feature for opening a player profile * * @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 PlayerProfile extends ScriptFeature { - /* - * Protected properties - */ - protected $login = null; - /** @var Control $control */ - protected $control = null; - protected $labelName = null; +class PlayerProfile extends ScriptFeature +{ - /** - * Construct a new Player Profile Feature - * - * @param string $login (optional) Player login - * @param Control $control (optional) Action Control - * @param string $labelName (optional) Script Label name - */ - public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) { - $this->setLogin($login); - if ($control !== null) { - $this->setControl($control); - } - $this->setLabelName($labelName); - } + /** + * @var string $login Player login + */ + protected $login = null; - /** - * Set the login of the opened player - * - * @param string $login Player login - * @return static - */ - public function setLogin($login) { - $this->login = $login; - return $this; - } + /** + * @var Control $control Profile Control + */ + protected $control = null; - /** - * Set the Control - * - * @param Control $control Profile Control - * @return static - */ - public function setControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->control = $control; - return $this; - } + /** + * @var string $labelName Script Label name + */ + protected $labelName = null; - /** - * Set the label name - * - * @param string $labelName Script Label name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - return $this; - } + /** + * Construct a new Player Profile + * + * @api + * @param string $login (optional) Player login + * @param Control $control (optional) Profile Control + * @param string $labelName (optional) Script Label name + */ + public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) + { + if ($login) { + $this->setLogin($login); + } + if ($control) { + $this->setControl($control); + } + if ($labelName) { + $this->setLabelName($labelName); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); - return $this; - } + /** + * Get the login of the opened player + * + * @api + * @return string + */ + public function getLogin() + { + return $this->login; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $login = Builder::escapeText($this->login, true); - if ($this->control) { - // Control event - $controlId = Builder::escapeText($this->control->getId(), true); - $scriptText = " + /** + * Set the login of the opened player + * + * @api + * @param string $login Player login + * @return static + */ + public function setLogin($login) + { + $this->login = (string)$login; + return $this; + } + + /** + * 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) + { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + $this->control = $control; + return $this; + } + + /** + * 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) + { + $this->labelName = (string)$labelName; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $login = Builder::escapeText($this->login); + + if ($this->control) { + // Control event + $controlId = Builder::escapeText($this->control->getId()); + return " if (Event.Control.ControlId == {$controlId}) { ShowProfile({$login}); }"; - } else { - // Other - $scriptText = " + } + + // Other events + return " ShowProfile({$login});"; - } - return $scriptText; - } + } + } diff --git a/libs/FML/Script/Features/Preload.php b/libs/FML/Script/Features/Preload.php new file mode 100644 index 00000000..11df0473 --- /dev/null +++ b/libs/FML/Script/Features/Preload.php @@ -0,0 +1,113 @@ + + * @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; + } + +} diff --git a/libs/FML/Script/Features/ScriptFeature.php b/libs/FML/Script/Features/ScriptFeature.php index bf31691d..9cf1dd7f 100644 --- a/libs/FML/Script/Features/ScriptFeature.php +++ b/libs/FML/Script/Features/ScriptFeature.php @@ -9,34 +9,37 @@ use FML\Types\ScriptFeatureable; * ManiaLink Script Feature Class * * @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 ScriptFeature { +abstract class ScriptFeature +{ - /** - * Collect the Script Features of the given objects - * - * @return ScriptFeature[] - */ - public static function collect() { - $params = func_get_args(); - $scriptFeatures = array(); - foreach ($params as $object) { - if ($object instanceof ScriptFeatureable) { - $scriptFeatures = array_merge($scriptFeatures, $object->getScriptFeatures()); - } else if ($object instanceof ScriptFeature) { - array_push($scriptFeatures, $object); - } - } - return $scriptFeatures; - } + /** + * Collect the Script Features of the given objects + * + * @return ScriptFeature[] + */ + public static function collect() + { + $params = func_get_args(); + $scriptFeatures = array(); + foreach ($params as $object) { + if ($object instanceof ScriptFeatureable) { + $scriptFeatures = array_merge($scriptFeatures, $object->getScriptFeatures()); + } else if ($object instanceof ScriptFeature) { + array_push($scriptFeatures, $object); + } + } + return $scriptFeatures; + } + + /** + * Prepare the given Script for rendering by adding the needed Labels, etc. + * + * @param Script $script Script to prepare + * @return static + */ + public abstract function prepare(Script $script); - /** - * Prepare the given Script for rendering by adding the needed Labels, etc. - * - * @param Script $script Script to prepare - * @return static - */ - public abstract function prepare(Script $script); } diff --git a/libs/FML/Script/Features/Toggle.php b/libs/FML/Script/Features/Toggle.php index 3f0c5d27..395c1ac8 100644 --- a/libs/FML/Script/Features/Toggle.php +++ b/libs/FML/Script/Features/Toggle.php @@ -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,128 +12,231 @@ use FML\Types\Scriptable; * Script Feature for toggling Controls * * @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 Toggle extends ScriptFeature { - /* - * Protected properties - */ - /** @var Control $togglingControl */ - protected $togglingControl = null; - /** @var Control $toggledControl */ - protected $toggledControl = null; - protected $labelName = null; - protected $onlyShow = null; - protected $onlyHide = null; +class Toggle extends ScriptFeature +{ - /** - * Construct a new Toggle Feature - * - * @param Control $togglingControl (optional) Toggling Control - * @param Control $toggledControl (optional) Toggled Control - * @param string $labelName (optional) Script Label name - * @param bool $onlyShow (optional) Whether it should only show the Control but not toggle - * @param bool $onlyHide (optional) Whether it should only hide the Control but not toggle - */ - public function __construct(Control $togglingControl = null, Control $toggledControl = null, $labelName = ScriptLabel::MOUSECLICK, - $onlyShow = false, $onlyHide = false) { - if ($togglingControl !== null) { - $this->setTogglingControl($togglingControl); - } - if ($toggledControl !== null) { - $this->setToggledControl($toggledControl); - } - $this->setLabelName($labelName); - $this->setOnlyShow($onlyShow); - $this->setOnlyHide($onlyHide); - } + /** + * @var Control $togglingControl Toggling Control + */ + protected $togglingControl = null; - /** - * Set the toggling Control - * - * @param Control $control Toggling Control - * @return static - */ - public function setTogglingControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->togglingControl = $control; - return $this; - } + /** + * @var Control $toggledControl Toggled Control + */ + protected $toggledControl = null; - /** - * Set the toggled Control - * - * @param Control $control Toggling Control - * @return static - */ - public function setToggledControl(Control $control) { - $this->toggledControl = $control->checkId(); - return $this; - } + /** + * @var $labelName Script Label name + */ + protected $labelName = null; - /** - * Set the label name - * - * @param string $labelName Script Label Name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - return $this; - } + /** + * @var bool $onlyShow Show only + */ + protected $onlyShow = null; - /** - * Set to only show - * - * @param bool $onlyShow Whether it should only show the Control but not toggle - * @return static - */ - public function setOnlyShow($onlyShow) { - $this->onlyShow = (bool)$onlyShow; - return $this; - } + /** + * @var bool $onlyHide Hide only + */ + protected $onlyHide = null; - /** - * Set to only hide - * - * @param bool $onlyHide Whether it should only hide the Control but not toggle - * @return static - */ - public function setOnlyHide($onlyHide) { - $this->onlyHide = (bool)$onlyHide; - return $this; - } + /** + * Construct a new Toggle + * + * @api + * @param Control $togglingControl (optional) Toggling Control + * @param Control $toggledControl (optional) Toggled Control + * @param string $labelName (optional) Script Label name + * @param bool $onlyShow (optional) If it should only show the Control but not toggle + * @param bool $onlyHide (optional) If it should only hide the Control but not toggle + */ + public function __construct( + Control $togglingControl = null, + Control $toggledControl = null, + $labelName = ScriptLabel::MOUSECLICK, + $onlyShow = false, + $onlyHide = false + ) { + if ($togglingControl) { + $this->setTogglingControl($togglingControl); + } + if ($toggledControl) { + $this->setToggledControl($toggledControl); + } + if ($labelName) { + $this->setLabelName($labelName); + } + if ($onlyShow) { + $this->setOnlyShow($onlyShow); + } + if ($onlyHide) { + $this->setOnlyHide($onlyHide); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); - return $this; - } + /** + * Get the toggling Control + * + * @api + * @return Control + */ + public function getTogglingControl() + { + return $this->togglingControl; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $togglingControlId = $this->togglingControl->getId(true, true); - $toggledControlId = $this->toggledControl->getId(true, true); - $visibility = '!ToggleControl.Visible'; - if ($this->onlyShow) { - $visibility = 'True'; - } else if ($this->onlyHide) { - $visibility = 'False'; - } - return " + /** + * Set the toggling Control + * + * @api + * @param Control $control Toggling Control + * @return static + */ + public function setTogglingControl(Control $control) + { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + $this->togglingControl = $control; + return $this; + } + + /** + * Get the toggled Control + * + * @api + * @return Control + */ + public function getToggledControl() + { + return $this->toggledControl; + } + + /** + * Set the toggled Control + * + * @api + * @param Control $control Toggled Control + * @return static + */ + public function setToggledControl(Control $control) + { + $control->checkId(); + $this->toggledControl = $control; + return $this; + } + + /** + * 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) + { + $this->labelName = (string)$labelName; + return $this; + } + + /** + * Get Show Only + * + * @api + * @return bool + */ + public function getOnlyShow() + { + return $this->onlyShow; + } + + /** + * Set Show Only + * + * @api + * @param bool $onlyShow If it should only show the Control but not toggle + * @return static + */ + public function setOnlyShow($onlyShow) + { + $this->onlyShow = (bool)$onlyShow; + if ($this->onlyShow) { + $this->onlyHide = null; + } + return $this; + } + + /** + * Get Hide Only + * + * @api + * @return bool + */ + public function getOnlyHide() + { + return $this->onlyHide; + } + + /** + * Set Hide Only + * + * @api + * @param bool $onlyHide If it should only hide the Control but not toggle + * @return static + */ + public function setOnlyHide($onlyHide) + { + $this->onlyHide = (bool)$onlyHide; + if ($this->onlyHide) { + $this->onlyShow = null; + } + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $togglingControlId = Builder::escapeText($this->togglingControl->getId()); + $toggledControlId = Builder::escapeText($this->toggledControl->getId()); + $visibility = "!ToggleControl.Visible"; + if ($this->onlyShow) { + $visibility = "True"; + } else if ($this->onlyHide) { + $visibility = "False"; + } + return " if (Event.Control.ControlId == {$togglingControlId}) { declare ToggleControl = Page.GetFirstChild({$toggledControlId}); ToggleControl.Visible = {$visibility}; }"; - } + } + } diff --git a/libs/FML/Script/Features/Tooltip.php b/libs/FML/Script/Features/Tooltip.php index 2b640557..ca87b3ff 100644 --- a/libs/FML/Script/Features/Tooltip.php +++ b/libs/FML/Script/Features/Tooltip.php @@ -13,150 +13,241 @@ use FML\Types\Scriptable; * Script Feature for showing Tooltips * * @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 Tooltip extends ScriptFeature { - /* - * Protected properties - */ - /** @var Control $hoverControl */ - protected $hoverControl = null; - /** @var Control $tooltipControl */ - protected $tooltipControl = null; - protected $stayOnClick = null; - protected $invert = null; - protected $text = null; +class Tooltip extends ScriptFeature +{ - /** - * Construct a new Tooltip Feature - * - * @param Control $hoverControl (optional) Hover Control - * @param Control $tooltipControl (optional) Tooltip Control - * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click - * @param bool $invert (optional) Whether the visibility toggling should be inverted - * @param string $text (optional) Text to display if the TooltipControl is a Label - */ - public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = false, $invert = false, $text = null) { - if ($hoverControl !== null) { - $this->setHoverControl($hoverControl); - } - if ($tooltipControl !== null) { - $this->setTooltipControl($tooltipControl); - } - $this->setStayOnClick($stayOnClick); - $this->setInvert($invert); - if ($text !== null) { - $this->setText($text); - } - } + /** + * @var Control $hoverControl Hover Control + */ + protected $hoverControl = null; - /** - * Set the Hover Control - * - * @param Control $hoverControl Hover Control - * @return static - */ - public function setHoverControl(Control $hoverControl) { - $hoverControl->checkId(); - if ($hoverControl instanceof Scriptable) { - $hoverControl->setScriptEvents(true); - } - $this->hoverControl = $hoverControl; - return $this; - } + /** + * @var Control $tooltipControl Tooltip Control + */ + protected $tooltipControl = null; - /** - * Set the Tooltip Control - * - * @param Control $tooltipControl Tooltip Control - * @return static - */ - public function setTooltipControl(Control $tooltipControl) { - $this->tooltipControl = $tooltipControl->checkId()->setVisible(false); - return $this; - } + /** + * @var bool $stayOnClick Stay on click + */ + protected $stayOnClick = null; - /** - * Set to only show - * - * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click - * @return static - */ - public function setStayOnClick($stayOnClick) { - $this->stayOnClick = (bool)$stayOnClick; - return $this; - } + /** + * @var bool $invert Inverted visibility toggling + */ + protected $invert = null; - /** - * Set to only hide - * - * @param bool $invert (optional) Whether the visibility toggling should be inverted - * @return static - */ - public function setInvert($invert) { - $this->invert = (bool)$invert; - return $this; - } + /** + * @var string $text Tooltip Text + */ + protected $text = null; - /** - * Set text - * - * @param string $text (optional) Text to display if the TooltipControl is a Label - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * Construct a new Tooltip + * + * @api + * @param Control $hoverControl (optional) Hover Control + * @param Control $tooltipControl (optional) Tooltip Control + * @param bool $stayOnClick (optional) If the Tooltip should stay on click + * @param bool $invert (optional) If the visibility toggling should be inverted + * @param string $text (optional) Text to display if the TooltipControl is a Label + */ + public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = null, $invert = null, $text = null) + { + if ($hoverControl) { + $this->setHoverControl($hoverControl); + } + if ($tooltipControl) { + $this->setTooltipControl($tooltipControl); + } + if ($stayOnClick) { + $this->setStayOnClick($stayOnClick); + } + if ($invert) { + $this->setInvert($invert); + } + if ($text) { + $this->setText($text); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $hoverControlId = $this->hoverControl->getId(true, true); - $tooltipControlId = $this->tooltipControl->getId(true, true); + /** + * Get the Hover Control + * + * @api + * @return Control + */ + public function getHoverControl() + { + return $this->hoverControl; + } - // MouseOver - $visibility = ($this->invert ? 'False' : 'True'); - $scriptText = " + /** + * Set the Hover Control + * + * @api + * @param Control $hoverControl Hover Control + * @return static + */ + public function setHoverControl(Control $hoverControl) + { + $hoverControl->checkId(); + if ($hoverControl instanceof Scriptable) { + $hoverControl->setScriptEvents(true); + } + $this->hoverControl = $hoverControl; + return $this; + } + + /** + * Get the Tooltip Control + * + * @api + * @return Control + */ + public function getTooltipControl() + { + return $this->tooltipControl; + } + + /** + * Set the Tooltip Control + * + * @api + * @param Control $tooltipControl Tooltip Control + * @return static + */ + public function setTooltipControl(Control $tooltipControl) + { + $tooltipControl->checkId(); + $tooltipControl->setVisible(false); + $this->tooltipControl = $tooltipControl; + return $this; + } + + /** + * Get the staying on click + * + * @api + * @return bool + */ + public function getStayOnClick() + { + return $this->stayOnClick; + } + + /** + * Set the staying on click + * + * @api + * @param bool $stayOnClick If the Tooltip should stay on click + * @return static + */ + public function setStayOnClick($stayOnClick) + { + $this->stayOnClick = (bool)$stayOnClick; + return $this; + } + + /** + * Get inverting of the visibility + * + * @api + * @return bool + */ + public function getInvert() + { + return $this->invert; + } + + /** + * Set inverting of the visibility + * + * @api + * @param bool $invert If the visibility toggling should be inverted + * @return static + */ + public function setInvert($invert) + { + $this->invert = (bool)$invert; + return $this; + } + + /** + * Get the text + * + * @api + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set the text + * + * @api + * @param string $text Text to display if the TooltipControl is a Label + * @return static + */ + public function setText($text) + { + $this->text = (string)$text; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $hoverControlId = Builder::escapeText($this->hoverControl->getId()); + $tooltipControlId = Builder::escapeText($this->tooltipControl->getId()); + + // MouseOver + $visibility = Builder::getBoolean(!$this->invert); + $scriptText = " if (Event.Control.ControlId == {$hoverControlId}) { declare TooltipControl = Page.GetFirstChild({$tooltipControlId}); TooltipControl.Visible = {$visibility};"; - if (is_string($this->text) && ($this->tooltipControl instanceof Label)) { - $tooltipText = Builder::escapeText($this->text, true); - $scriptText .= " + if (is_string($this->text) && ($this->tooltipControl instanceof Label)) { + $tooltipText = Builder::escapeText($this->text); + $scriptText .= " declare TooltipLabel = (TooltipControl as CMlLabel); TooltipLabel.Value = {$tooltipText};"; - } - $scriptText .= " + } + $scriptText .= " }"; - $script->appendGenericScriptLabel(ScriptLabel::MOUSEOVER, $scriptText); + $script->appendGenericScriptLabel(ScriptLabel::MOUSEOVER, $scriptText); - // MouseOut - $visibility = ($this->invert ? 'True' : 'False'); - $scriptText = " + // MouseOut + $visibility = Builder::getBoolean($this->invert); + $scriptText = " if (Event.Control.ControlId == {$hoverControlId}) { declare TooltipControl = Page.GetFirstChild({$tooltipControlId});"; - if ($this->stayOnClick) { - $scriptText .= " + if ($this->stayOnClick) { + $scriptText .= " declare FML_Clicked for Event.Control = False; if (!FML_Clicked) "; - } - $scriptText .= " + } + $scriptText .= " TooltipControl.Visible = {$visibility}; }"; - $script->appendGenericScriptLabel(ScriptLabel::MOUSEOUT, $scriptText); + $script->appendGenericScriptLabel(ScriptLabel::MOUSEOUT, $scriptText); - // MouseClick - if ($this->stayOnClick) { - $scriptText = " + // MouseClick + if ($this->stayOnClick) { + $scriptText = " if (Event.Control.ControlId == {$hoverControlId}) { declare FML_Clicked for Event.Control = False; FML_Clicked = !FML_Clicked; }"; - $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText); - } - return $this; - } + $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText); + } + return $this; + } + } diff --git a/libs/FML/Script/Features/UISound.php b/libs/FML/Script/Features/UISound.php index 70152f67..eba267ae 100644 --- a/libs/FML/Script/Features/UISound.php +++ b/libs/FML/Script/Features/UISound.php @@ -12,157 +12,249 @@ use FML\Types\Scriptable; * Script Feature for playing a UISound * * @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 UISound extends ScriptFeature { - /* - * Constants - */ - const Bonus = 'Bonus'; - const Capture = 'Capture'; - const Checkpoint = 'Checkpoint'; - const Combo = 'Combo'; - const Custom1 = 'Custom1'; - const Custom2 = 'Custom2'; - const Custom3 = 'Custom3'; - const Custom4 = 'Custom4'; - const Default_ = 'Default'; - const EndMatch = 'EndMatch'; - const EndRound = 'EndRound'; - const Finish = 'Finish'; - const FirstHit = 'FirstHit'; - const Notice = 'Notice'; - const PhaseChange = 'PhaseChange'; - const PlayerEliminated = 'PlayerEliminated'; - const PlayerHit = 'PlayerHit'; - const PlayersRemaining = 'PlayersRemaining'; - const RankChange = 'RankChange'; - const Record = 'Record'; - const ScoreProgress = 'ScoreProgress'; - const Silence = 'Silence'; - const StartMatch = 'StartMatch'; - const StartRound = 'StartRound'; - const TieBreakPoint = 'TieBreakPoint'; - const TiePoint = 'TiePoint'; - const TimeOut = 'TimeOut'; - const VictoryPoint = 'VictoryPoint'; - const Warning = 'Warning'; +class UISound extends ScriptFeature +{ - /* - * Protected properties - */ - protected $soundName = null; - /** @var Control $control */ - protected $control = null; - protected $variant = 0; - protected $volume = 1.; - protected $labelName = null; + /* + * Constants + */ + const Bonus = "Bonus"; + const Capture = "Capture"; + const Checkpoint = "Checkpoint"; + const Combo = "Combo"; + const Custom1 = "Custom1"; + const Custom2 = "Custom2"; + const Custom3 = "Custom3"; + const Custom4 = "Custom4"; + const Default_ = "Default"; + const EndMatch = "EndMatch"; + const EndRound = "EndRound"; + const Finish = "Finish"; + const FirstHit = "FirstHit"; + const Notice = "Notice"; + const PhaseChange = "PhaseChange"; + const PlayerEliminated = "PlayerEliminated"; + const PlayerHit = "PlayerHit"; + const PlayersRemaining = "PlayersRemaining"; + const RankChange = "RankChange"; + const Record = "Record"; + const ScoreProgress = "ScoreProgress"; + const Silence = "Silence"; + const StartMatch = "StartMatch"; + const StartRound = "StartRound"; + const TieBreakPoint = "TieBreakPoint"; + const TiePoint = "TiePoint"; + const TimeOut = "TimeOut"; + const VictoryPoint = "VictoryPoint"; + const Warning = "Warning"; - /** - * Construct a new UISound Feature - * - * @param string $soundName (optional) Played sound - * @param Control $control (optional) Action Control - * @param int $variant (optional) Sound variant - * @param string $labelName (optional) Script Label name - */ - public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) { - if ($soundName !== null) { - $this->setSoundName($soundName); - } - if ($control !== null) { - $this->setControl($control); - } - $this->setVariant($variant); - $this->setLabelName($labelName); - } + /** + * @var string $soundName Sound name + */ + protected $soundName = null; - /** - * Set the sound to play - * - * @param string $soundName Sound name - * @return static - */ - public function setSoundName($soundName) { - $this->soundName = (string)$soundName; - return $this; - } + /** + * @var Control $control Sound Control + */ + protected $control = null; - /** - * Set the Control - * - * @param Control $control Action Control - * @return static - */ - public function setControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->control = $control; - return $this; - } + /** + * @var int $variant Sound variant + */ + protected $variant = 0; - /** - * Set the sound variant - * - * @param int $variant Sound variant - * @return static - */ - public function setVariant($variant) { - $this->variant = (int)$variant; - return $this; - } + /** + * @var string $labelName Script Label name + */ + protected $labelName = null; - /** - * Set the volume - * - * @param float $volume Sound volume - * @return static - */ - public function setVolume($volume) { - $this->volume = (float)$volume; - return $this; - } + /** + * @var float $volume Volume + */ + protected $volume = 1.; - /** - * Set the label name - * - * @param string $labelName Script Label name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - return $this; - } + /** + * Construct a new UISound + * + * @api + * @param string $soundName (optional) Sound name + * @param Control $control (optional) Sound Control + * @param int $variant (optional) Sound variant + * @param string $labelName (optional) Script Label name + */ + public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) + { + if ($soundName) { + $this->setSoundName($soundName); + } + if ($control) { + $this->setControl($control); + } + if ($variant) { + $this->setVariant($variant); + } + if ($labelName) { + $this->setLabelName($labelName); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); - return $this; - } + /** + * Get the sound to play + * + * @api + * @return string + */ + public function getSoundName() + { + return $this->soundName; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - if ($this->control) { - // Control event - $controlId = Builder::escapeText($this->control->getId(), true); - $scriptText = " + /** + * Set the sound to play + * + * @api + * @param string $soundName Sound name + * @return static + */ + public function setSoundName($soundName) + { + $this->soundName = (string)$soundName; + return $this; + } + + /** + * Get the sound Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } + + /** + * Set the sound Control + * + * @api + * @param Control $control (optional) Sound Control + * @return static + */ + public function setControl(Control $control = null) + { + if ($control) { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + } + $this->control = $control; + return $this; + } + + /** + * Get the sound variant + * + * @api + * @return int + */ + public function getVariant() + { + return $this->variant; + } + + /** + * Set the sound variant + * + * @api + * @param int $variant Sound variant + * @return static + */ + public function setVariant($variant) + { + $this->variant = (int)$variant; + return $this; + } + + /** + * 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) + { + $this->labelName = (string)$labelName; + return $this; + } + + /** + * Get the volume + * + * @api + * @return float + */ + public function getVolume() + { + return $this->volume; + } + + /** + * Set the volume + * + * @api + * @param float $volume Sound volume + * @return static + */ + public function setVolume($volume) + { + $this->volume = (float)$volume; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + if ($this->control) { + // Control event + $controlId = Builder::escapeText($this->control->getId()); + return " if (Event.Control.ControlId == {$controlId}) { PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume}); }"; - } else { - // Other - $scriptText = " + } + + // Other events + return " PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});"; - } - return $scriptText; - } + } + } diff --git a/libs/FML/Script/Features/ValuePickerFeature.php b/libs/FML/Script/Features/ValuePickerFeature.php index fe12841f..eebe8be5 100644 --- a/libs/FML/Script/Features/ValuePickerFeature.php +++ b/libs/FML/Script/Features/ValuePickerFeature.php @@ -13,150 +13,211 @@ use FML\Script\ScriptLabel; * Script Feature for creating a ValuePicker 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 ValuePickerFeature extends ScriptFeature { - /* - * Constants - */ - const FUNCTION_UPDATE_PICKER_VALUE = 'FML_UpdatePickerValue'; - const VAR_PICKER_VALUES = 'FML_Picker_Values'; - const VAR_PICKER_DEFAULT_VALUE = 'FML_Picker_Default_Value'; - const VAR_PICKER_ENTRY_ID = 'FML_Picker_EntryId'; +class ValuePickerFeature extends ScriptFeature +{ - /* - * Protected properties - */ - /** @var Label $label */ - protected $label = null; - /** @var Entry $entry */ - protected $entry = null; - protected $values = array(); - protected $default = null; + /* + * Constants + */ + const FUNCTION_UPDATE_PICKER_VALUE = "FML_UpdatePickerValue"; + const VAR_PICKER_VALUES = "FML_Picker_Values"; + const VAR_PICKER_DEFAULT_VALUE = "FML_Picker_Default_Value"; + const VAR_PICKER_ENTRY_ID = "FML_Picker_EntryId"; - /** - * Construct a new ValuePicker Feature - * - * @param Label $label (optional) ValuePicker Label - * @param Entry $entry (optional) Hidden Entry - * @param array $values (optional) Possible values - * @param string $default (optional) Default value - */ - public function __construct(Label $label = null, Entry $entry = null, array $values = array(), $default = null) { - if ($label !== null) { - $this->setLabel($label); - } - if ($entry !== null) { - $this->setEntry($entry); - } - if (!empty($values)) { - $this->setValues($values); - } - if ($default !== null) { - $this->setDefault($default); - } - } + /** + * @var Label $label Label + */ + protected $label = null; - /** - * Set the ValuePicker Label - * - * @param Label $label ValuePicker Label - * @return static - */ - public function setLabel(Label $label) { - $this->label = $label->checkId()->setScriptEvents(true); - return $this; - } + /** + * @var Entry $entry Hidden Entry + */ + protected $entry = null; - /** - * Get the ValuePicker Label - * - * @return \FML\Controls\Label - */ - public function getLabel() { - return $this->label; - } + /** + * @var string[] $values Possible values + */ + protected $values = array(); - /** - * Set the hidden Entry - * - * @param Entry $entry Hidden Entry - * @return static - */ - public function setEntry(Entry $entry) { - $this->entry = $entry->checkId(); - return $this; - } + /** + * @var string $default Default value + */ + protected $default = null; - /** - * Get the hidden Entry - * - * @return \FML\Controls\Entry - */ - public function getEntry() { - return $this->entry; - } + /** + * Construct a new ValuePicker Feature + * + * @api + * @param Label $label (optional) Label + * @param Entry $entry (optional) Hidden Entry + * @param string[] $values (optional) Possible values + * @param string $default (optional) Default value + */ + public function __construct(Label $label = null, Entry $entry = null, array $values = null, $default = null) + { + if ($label) { + $this->setLabel($label); + } + if ($entry) { + $this->setEntry($entry); + } + if ($values && !empty($values)) { + $this->setValues($values); + } + if ($default !== null) { + $this->setDefault($default); + } + } - /** - * Set the possible values - * - * @param array $values Possible values - * @return static - */ - public function setValues(array $values) { - $this->values = array(); - foreach ($values as $value) { - array_push($this->values, (string)$value); - } - return $this; - } + /** + * Get the Label + * + * @api + * @return Label + */ + public function getLabel() + { + return $this->label; + } - /** - * Set the default value - * - * @param string $default Default value - * @return static - */ - public function setDefault($default) { - $this->default = (string)$default; - } + /** + * Set the Label + * + * @api + * @param Label $label Label + * @return static + */ + public function setLabel(Label $label) + { + $label->checkId(); + $label->setScriptEvents(true); + $this->label = $label; + return $this; + } - /** - * Get the default value - * - * @return string - */ - public function getDefault() { - if ($this->default) { - return $this->default; - } - if (!empty($this->values)) { - return reset($this->values); - } - return null; - } + /** + * Get the hidden Entry + * + * @api + * @return Entry + */ + public function getEntry() + { + return $this->entry; + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - if ($this->label) { - $script->setScriptInclude(ScriptInclude::TEXTLIB); - $script->addScriptFunction(self::FUNCTION_UPDATE_PICKER_VALUE, $this->buildUpdatePickerValueFunction()); - $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true); - $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText()); - } - return $this; - } + /** + * Set the hidden Entry + * + * @api + * @param Entry $entry Hidden Entry + * @return static + */ + public function setEntry(Entry $entry) + { + $entry->checkId(); + $this->entry = $entry; + return $this; + } - /** - * Build the function text - * - * @return string - */ - protected function buildUpdatePickerValueFunction() { - return " + /** + * Get the possible values + * + * @api + * @return string[] + */ + public function getValues() + { + return $this->values; + } + + /** + * Add a possible value + * + * @api + * @param string $value Possible value + * @return static + */ + public function addValue($value) + { + array_push($this->values, (string)$value); + return $this; + } + + /** + * Set the possible values + * + * @api + * @param string[] $values Possible values + * @return static + */ + public function setValues(array $values) + { + $this->values = array(); + foreach ($values as $value) { + $this->addValue($value); + } + return $this; + } + + /** + * Get the default value + * + * @api + * @return string + */ + public function getDefault() + { + if ($this->default) { + return $this->default; + } + if (!empty($this->values)) { + return reset($this->values); + } + return null; + } + + /** + * Set the default value + * + * @api + * @param string $default Default value + * @return static + */ + public function setDefault($default) + { + $this->default = (string)$default; + if ($this->default && !in_array($this->default, $this->values, true)) { + $this->addValue($this->default); + } + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + if ($this->label) { + $script->setScriptInclude(ScriptInclude::TEXTLIB); + $script->addScriptFunction(self::FUNCTION_UPDATE_PICKER_VALUE, $this->buildUpdatePickerValueFunction()); + $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true); + $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText()); + } + return $this; + } + + /** + * Build the function text + * + * @return string + */ + protected function buildUpdatePickerValueFunction() + { + return " Void " . self::FUNCTION_UPDATE_PICKER_VALUE . "(CMlLabel _Label) { declare " . self::VAR_PICKER_VALUES . " as Values for _Label = Text[]; declare NewValueIndex = -1; @@ -169,58 +230,63 @@ Void " . self::FUNCTION_UPDATE_PICKER_VALUE . "(CMlLabel _Label) { NewValueIndex = 0; } } - declare NewValue = " . Builder::EMPTY_STRING . "; + declare NewValue = \"\"; if (Values.existskey(NewValueIndex)) { NewValue = Values[NewValueIndex]; } else { - declare " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for _Label = " . Builder::EMPTY_STRING . "; + declare " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for _Label = \"\"; NewValue = Default; } _Label.Value = NewValue; - declare " . self::VAR_PICKER_ENTRY_ID . " as EntryId for _Label = " . Builder::EMPTY_STRING . "; - if (EntryId != " . Builder::EMPTY_STRING . ") { + declare " . self::VAR_PICKER_ENTRY_ID . " as EntryId for _Label = \"\"; + if (EntryId != \"\") { declare Entry <=> (Page.GetFirstChild(EntryId) as CMlEntry); Entry.Value = NewValue; } }"; - } + } - /** - * Build the init script text - * - * @return string - */ - protected function buildInitScriptText() { - $labelId = $this->label->getId(true, true); - $entryId = '""'; - if ($this->entry) { - $entryId = $this->entry->getId(true, true); - } - $values = Builder::getArray($this->values); - $default = Builder::escapeText($this->getDefault(), true); - return " -declare Label_Picker <=> (Page.GetFirstChild({$labelId}) as CMlLabel); + /** + * Build the init script text + * + * @return string + */ + protected function buildInitScriptText() + { + $labelId = Builder::getId($this->label); + $entryId = Builder::EMPTY_STRING; + if ($this->entry) { + $entryId = Builder::getId($this->entry); + } + + $values = Builder::getArray($this->values); + $default = Builder::escapeText($this->getDefault()); + + return " +declare Label_Picker <=> (Page.GetFirstChild(\"{$labelId}\") as CMlLabel); declare Text[] " . self::VAR_PICKER_VALUES . " as Values for Label_Picker; Values = {$values}; declare Text " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for Label_Picker; Default = {$default}; declare Text " . self::VAR_PICKER_ENTRY_ID . " as EntryId for Label_Picker; -EntryId = {$entryId}; +EntryId = \"{$entryId}\"; " . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker); "; - } + } - /** - * Build the script text for Label clicks - * - * @return string - */ - protected function buildClickScriptText() { - $labelId = $this->label->getId(true, true); - return " -if (Event.ControlId == {$labelId}) { + /** + * Build the script text for Label clicks + * + * @return string + */ + protected function buildClickScriptText() + { + $labelId = Builder::getId($this->label); + return " +if (Event.ControlId == \"{$labelId}\") { declare Label_Picker <=> (Event.Control as CMlLabel); " . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker); }"; - } + } + } diff --git a/libs/FML/Script/Script.php b/libs/FML/Script/Script.php index 57866cb3..fbb7d1a7 100644 --- a/libs/FML/Script/Script.php +++ b/libs/FML/Script/Script.php @@ -8,276 +8,307 @@ use FML\Script\Features\ScriptFeature; * Class representing the ManiaLink 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 Script { - /* - * Constants - */ - const TICKINTERVAL = 250; - const VAR_ScriptStart = 'FML_ScriptStart'; - const VAR_LoopCounter = 'FML_LoopCounter'; - const VAR_LastTick = 'FML_LastTick'; +class Script +{ - /* - * Protected properties - */ - protected $tagName = 'script'; - protected $features = array(); - protected $includes = array(); - protected $constants = array(); - protected $functions = array(); - protected $customLabels = array(); - protected $genericLabels = array(); + /* + * Constants + */ + const TICKINTERVAL = 250; + const VAR_ScriptStart = 'FML_ScriptStart'; + const VAR_LoopCounter = 'FML_LoopCounter'; + const VAR_LastTick = 'FML_LastTick'; - /** - * Set a Script Include - * - * @param string $file Include file - * @param string $namespace Include namespace - * @return static - */ - public function setScriptInclude($file, $namespace = null) { - if ($file instanceof ScriptInclude) { - $scriptInclude = $file; - } else { - $scriptInclude = new ScriptInclude($file, $namespace); - } - $this->includes[$scriptInclude->getNamespace()] = $scriptInclude; - return $this; - } + /* + * Protected properties + */ + protected $tagName = 'script'; + protected $features = array(); + protected $includes = array(); + protected $constants = array(); + protected $functions = array(); + protected $customLabels = array(); + protected $genericLabels = array(); - /** - * Add a Script Constant - * - * @param string $name Constant name - * @param string $value Constant value - * @return static - */ - public function addScriptConstant($name, $value = null) { - if ($name instanceof ScriptConstant) { - $scriptConstant = $name; - } else { - $scriptConstant = new ScriptConstant($name, $value); - } - if (!in_array($scriptConstant, $this->constants)) { - array_push($this->constants, $scriptConstant); - } - return $this; - } + /** + * Set a Script Include + * + * @api + * @param string|ScriptInclude $file Include file or ScriptInclude + * @param string $namespace Include namespace + * @return static + */ + public function setScriptInclude($file, $namespace = null) + { + if ($file instanceof ScriptInclude) { + $scriptInclude = $file; + } else { + $scriptInclude = new ScriptInclude($file, $namespace); + } + $this->includes[$scriptInclude->getNamespace()] = $scriptInclude; + return $this; + } - /** - * Add a Script Function - * - * @param string $name Function name - * @param string $text Function text - * @return static - */ - public function addScriptFunction($name, $text = null) { - if ($name instanceof ScriptFunction) { - $scriptFunction = $name; - } else { - $scriptFunction = new ScriptFunction($name, $text); - } - if (!in_array($scriptFunction, $this->functions)) { - array_push($this->functions, $scriptFunction); - } - return $this; - } + /** + * Add a Script Constant + * + * @api + * @param string|ScriptConstant $name Constant name or ScriptConstant + * @param string $value Constant value + * @return static + */ + public function addScriptConstant($name, $value = null) + { + if ($name instanceof ScriptConstant) { + $scriptConstant = $name; + } else { + $scriptConstant = new ScriptConstant($name, $value); + } + if (!in_array($scriptConstant, $this->constants)) { + array_push($this->constants, $scriptConstant); + } + return $this; + } - /** - * Add a custom Script text - * - * @param string $name Label name - * @param string $text Script text - * @return static - */ - public function addCustomScriptLabel($name, $text = null) { - if ($name instanceof ScriptLabel) { - $scriptLabel = $name; - } else { - $scriptLabel = new ScriptLabel($name, $text); - } - array_push($this->customLabels, $scriptLabel); - return $this; - } + /** + * Add a Script Function + * + * @api + * @param string|ScriptFunction $name Function name or ScriptFunction + * @param string $text Function text + * @return static + */ + public function addScriptFunction($name, $text = null) + { + if ($name instanceof ScriptFunction) { + $scriptFunction = $name; + } else { + $scriptFunction = new ScriptFunction($name, $text); + } + if (!in_array($scriptFunction, $this->functions)) { + array_push($this->functions, $scriptFunction); + } + return $this; + } - /** - * Append a generic Script text for the next rendering - * - * @param string $name Label name - * @param string $text Script text - * @param bool $isolated (optional) Whether to isolate the Label Script - * @return static - */ - public function appendGenericScriptLabel($name, $text = null, $isolated = false) { - if ($name instanceof ScriptLabel) { - $scriptLabel = $name; - } else { - $scriptLabel = new ScriptLabel($name, $text, $isolated); - } - array_push($this->genericLabels, $scriptLabel); - return $this; - } + /** + * Add a custom Script text + * + * @api + * @param string|ScriptLabel $name Label name or ScriptLabel + * @param string $text Script text + * @return static + */ + public function addCustomScriptLabel($name, $text = null) + { + if ($name instanceof ScriptLabel) { + $scriptLabel = $name; + } else { + $scriptLabel = new ScriptLabel($name, $text); + } + if (!in_array($scriptLabel, $this->customLabels)) { + array_push($this->customLabels, $scriptLabel); + } + return $this; + } - /** - * Remove all generic Script texts - * - * @return static - */ - public function resetGenericScriptLabels() { - $this->genericLabels = array(); - return $this; - } + /** + * Append a generic Script text for the next rendering + * + * @TODO: get rid of generic script labels approach + * @param string|ScriptLabel $name Label name or ScriptLabel + * @param string $text Script text + * @param bool $isolated (optional) Whether to isolate the Label Script + * @return static + */ + public function appendGenericScriptLabel($name, $text = null, $isolated = false) + { + if ($name instanceof ScriptLabel) { + $scriptLabel = $name; + } else { + $scriptLabel = new ScriptLabel($name, $text, $isolated); + } + if (!in_array($scriptLabel, $this->genericLabels)) { + array_push($this->genericLabels, $scriptLabel); + } + return $this; + } - /** - * Add a Script Feature - * - * @param ScriptFeature $feature Script Feature - * @return static - */ - public function addFeature(ScriptFeature $feature) { - if (!in_array($feature, $this->features, true)) { - array_push($this->features, $feature); - } - return $this; - } + /** + * Remove all generic Script texts + * + * @TODO: get rid of generic script labels approach + * @return static + */ + public function resetGenericScriptLabels() + { + $this->genericLabels = array(); + return $this; + } - /** - * Load the given Script Feature - * - * @param ScriptFeature $scriptFeature Script Feature to load - * @return static - */ - public function loadFeature(ScriptFeature $scriptFeature) { - $scriptFeature->prepare($this); - return $this; - } + /** + * Add a Script Feature + * + * @api + * @param ScriptFeature $feature Script Feature + * @return static + */ + public function addFeature(ScriptFeature $feature) + { + if (!in_array($feature, $this->features, true)) { + array_push($this->features, $feature); + } + return $this; + } - /** - * Load the given Script Features - * - * @param ScriptFeature[] $scriptFeatures Script Features to load - * @return static - */ - public function loadFeatures(array $scriptFeatures) { - foreach ($scriptFeatures as $scriptFeature) { - $this->loadFeature($scriptFeature); - } - return $this; - } + /** + * Load the given Script Feature + * + * @param ScriptFeature $scriptFeature Script Feature to load + * @return static + */ + public function loadFeature(ScriptFeature $scriptFeature) + { + $scriptFeature->prepare($this); + return $this; + } - /** - * Check if the Script has content so that it needs to be rendered - * - * @return bool - */ - public function needsRendering() { - if ($this->features || $this->customLabels || $this->genericLabels) { - return true; - } - return false; - } + /** + * Load the given Script Features + * + * @param ScriptFeature[] $scriptFeatures Script Features to load + * @return static + */ + public function loadFeatures(array $scriptFeatures) + { + foreach ($scriptFeatures as $scriptFeature) { + $this->loadFeature($scriptFeature); + } + return $this; + } - /** - * Build the complete Script text - * - * @return string - */ - public function buildScriptText() { - $scriptText = PHP_EOL; - $scriptText .= $this->getHeaderComment(); - $scriptText .= $this->getIncludes(); - $scriptText .= $this->getConstants(); - $scriptText .= $this->getFunctions(); - $scriptText .= $this->getLabels(); - $scriptText .= $this->getMainFunction(); - return $scriptText; - } + /** + * Check if the Script has content so that it needs to be rendered + * + * @return bool + */ + public function needsRendering() + { + if ($this->features || $this->customLabels || $this->genericLabels) { + return true; + } + return false; + } - /** - * Build the Script XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the XML element should be created - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $this->loadFeatures($this->features); - $scriptXml = $domDocument->createElement($this->tagName); - $scriptText = $this->buildScriptText(); - $scriptComment = $domDocument->createComment($scriptText); - $scriptXml->appendChild($scriptComment); - return $scriptXml; - } + /** + * Build the complete Script text + * + * @return string + */ + public function buildScriptText() + { + $scriptText = PHP_EOL; + $scriptText .= $this->getHeaderComment(); + $scriptText .= $this->getIncludes(); + $scriptText .= $this->getConstants(); + $scriptText .= $this->getFunctions(); + $scriptText .= $this->getLabels(); + $scriptText .= $this->getMainFunction(); + return $scriptText; + } - /** - * Get the header comment - * - * @return string - */ - protected function getHeaderComment() { - $headerComment = '/**************************************************** + /** + * Render the Script + * + * @param \DOMDocument $domDocument DOMDocument for which the Script should be created + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $this->loadFeatures($this->features); + $scriptXml = $domDocument->createElement($this->tagName); + $scriptText = $this->buildScriptText(); + $scriptComment = $domDocument->createComment($scriptText); + $scriptXml->appendChild($scriptComment); + return $scriptXml; + } + + /** + * Get the header comment + * + * @return string + */ + protected function getHeaderComment() + { + $headerComment = '/**************************************************** * FancyManiaLinks'; - if (defined('FML_VERSION')) { - $headerComment .= ' v' . FML_VERSION; - } - $headerComment .= ' by steeffeen * + if (defined('FML_VERSION')) { + $headerComment .= ' v' . FML_VERSION; + } + $headerComment .= ' by steeffeen * * http://github.com/steeffeen/FancyManiaLinks * ****************************************************/ '; - return $headerComment; - } + return $headerComment; + } - /** - * Get the Includes text - * - * @return string - */ - protected function getIncludes() { - $includesText = implode(PHP_EOL, $this->includes); - return $includesText; - } + /** + * Get the Includes text + * + * @return string + */ + protected function getIncludes() + { + $includesText = implode(PHP_EOL, $this->includes); + return $includesText; + } - /** - * Get the Constants text - * - * @return string - */ - protected function getConstants() { - $constantsText = implode(PHP_EOL, $this->constants); - return $constantsText; - } + /** + * Get the Constants text + * + * @return string + */ + protected function getConstants() + { + $constantsText = implode(PHP_EOL, $this->constants); + return $constantsText; + } - /** - * Get the Functions text - * - * @return string - */ - protected function getFunctions() { - $functionsText = implode(PHP_EOL, $this->functions); - return $functionsText; - } + /** + * Get the Functions text + * + * @return string + */ + protected function getFunctions() + { + $functionsText = implode(PHP_EOL, $this->functions); + return $functionsText; + } - /** - * Get the Labels text - * - * @return string - */ - protected function getLabels() { - $customLabelsText = implode(PHP_EOL, $this->customLabels); - $genericLabelsText = implode(PHP_EOL, $this->genericLabels); - return $customLabelsText . $genericLabelsText; - } + /** + * Get the Labels text + * + * @return string + */ + protected function getLabels() + { + $customLabelsText = implode(PHP_EOL, $this->customLabels); + $genericLabelsText = implode(PHP_EOL, $this->genericLabels); + return $customLabelsText . $genericLabelsText; + } - /** - * Get the main function text - * - * @return string - */ - protected function getMainFunction() { - $mainFunction = ' + /** + * Get the main function text + * + * @return string + */ + protected function getMainFunction() + { + $mainFunction = ' Void FML_Dummy() {} main() { declare ' . self::VAR_ScriptStart . ' = Now; @@ -312,6 +343,17 @@ main() { ' . self::VAR_LastTick . ' = Now; } }'; - return $mainFunction; - } + return $mainFunction; + } + + /** + * Get the string representation + * + * @return string + */ + public function __toString() + { + return $this->buildScriptText(); + } + } diff --git a/libs/FML/Script/ScriptConstant.php b/libs/FML/Script/ScriptConstant.php index 0f4db636..932d73c0 100644 --- a/libs/FML/Script/ScriptConstant.php +++ b/libs/FML/Script/ScriptConstant.php @@ -6,55 +6,95 @@ namespace FML\Script; * Class representing a Constant of the ManiaLink 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 ScriptConstant { - /* - * Protected properties - */ - protected $name = null; - protected $value = null; +class ScriptConstant +{ - /** - * Construct a new Script Constant - * - * @param string $name (optional) Constant name - * @param string $value (optional) Constant value - */ - public function __construct($name = null, $value = null) { - $this->setName($name); - $this->setValue($value); - } + /** + * @var string $name Name + */ + protected $name = null; - /** - * Set the name - * - * @param string $name Constant name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var mixed $value Value + */ + protected $value = null; - /** - * Set the value - * - * @param string $value Constant value - * @return static - */ - public function setValue($value) { - $this->value = $value; - return $this; - } + /** + * Construct a new Script Constant + * + * @api + * @param string $name (optional) Constant name + * @param mixed $value (optional) Constant value + */ + public function __construct($name = null, $value = null) + { + if ($name) { + $this->setName($name); + } + if ($value !== null) { + $this->setValue($value); + } + } + + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the name + * + * @api + * @param string $name Constant name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the value + * + * @api + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * Set the value + * + * @api + * @param mixed $value Constant value + * @return static + */ + public function setValue($value) + { + $this->value = $value; + return $this; + } + + /** + * Build the Script Constant text + * + * @return string + */ + public function __toString() + { + return Builder::getConstant($this->name, $this->value); + } - /** - * Build the Script Constant text - * - * @return string - */ - public function __toString() { - return Builder::getConstant($this->name, $this->value); - } } diff --git a/libs/FML/Script/ScriptFunction.php b/libs/FML/Script/ScriptFunction.php index c4163285..32e87a15 100644 --- a/libs/FML/Script/ScriptFunction.php +++ b/libs/FML/Script/ScriptFunction.php @@ -6,55 +6,95 @@ namespace FML\Script; * Class representing a Function of the ManiaLink 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 ScriptFunction { - /* - * Protected properties - */ - protected $name = null; - protected $text = null; +class ScriptFunction +{ - /** - * Construct a new Script Function - * - * @param string $name (optional) Function name - * @param string $text (optional) Function text - */ - public function __construct($name = null, $text = null) { - $this->setName($name); - $this->setText($text); - } + /** + * @var string $name Function name + */ + protected $name = null; - /** - * Set the name - * - * @param string $name Function name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $text Function text + */ + protected $text = null; - /** - * Set the text - * - * @param string $text Function text - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * Construct a new Script Function + * + * @api + * @param string $name (optional) Function name + * @param string $text (optional) Function text + */ + public function __construct($name = null, $text = null) + { + if ($name) { + $this->setName($name); + } + if ($text) { + $this->setText($text); + } + } + + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the name + * + * @api + * @param string $name Function name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the text + * + * @api + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set the text + * + * @api + * @param string $text Function text + * @return static + */ + public function setText($text) + { + $this->text = (string)$text; + return $this; + } + + /** + * Get the Script Function text + * + * @return string + */ + public function __toString() + { + return $this->text; + } - /** - * Get the Script Function text - * - * @return string - */ - public function __toString() { - return $this->text; - } } diff --git a/libs/FML/Script/ScriptInclude.php b/libs/FML/Script/ScriptInclude.php index 793a2876..c56695e2 100644 --- a/libs/FML/Script/ScriptInclude.php +++ b/libs/FML/Script/ScriptInclude.php @@ -6,70 +6,101 @@ namespace FML\Script; * Class representing an Include of the ManiaLink 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 ScriptInclude { - /* - * Constants - */ - const MATHLIB = 'MathLib'; - const TEXTLIB = 'TextLib'; +class ScriptInclude +{ - /* - * Protected properties - */ - protected $file = null; - protected $namespace = null; + /* + * Constants + */ + const MATHLIB = 'MathLib'; + const TEXTLIB = 'TextLib'; - /** - * Construct a new Script Include - * - * @param string $file (optional) Include file - * @param string $namespace (optional) Include namespace - */ - public function __construct($file = null, $namespace = null) { - $this->setFile($file); - $this->setNamespace($namespace); - } + /** + * @var string $file File name + */ + protected $file = null; - /** - * Set the file - * - * @param string $file Include file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * @var string $namespace Namespace + */ + protected $namespace = null; - /** - * Set the namespace - * - * @param string $namespace Include namespace - * @return static - */ - public function setNamespace($namespace) { - $this->namespace = (string)$namespace; - return $this; - } + /** + * Construct a new Script Include + * + * @api + * @param string $file (optional) File name + * @param string $namespace (optional) Namespace + */ + public function __construct($file = null, $namespace = null) + { + if ($file) { + $this->setFile($file); + } + if ($namespace) { + $this->setNamespace($namespace); + } + } - /** - * Get the namespace - * - * @return string - */ - public function getNamespace() { - return $this->namespace; - } + /** + * Get the file + * + * @api + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Set the file + * + * @api + * @param string $file File name + * @return static + */ + public function setFile($file) + { + $this->file = (string)$file; + return $this; + } + + /** + * Get the namespace + * + * @api + * @return string + */ + public function getNamespace() + { + return $this->namespace; + } + + /** + * Set the namespace + * + * @api + * @param string $namespace Namespace + * @return static + */ + public function setNamespace($namespace) + { + $this->namespace = (string)$namespace; + return $this; + } + + /** + * Build the Script Include text + * + * @return string + */ + public function __toString() + { + return Builder::getInclude($this->file, $this->namespace); + } - /** - * Build the Script Include text - * - * @return string - */ - public function __toString() { - return Builder::getInclude($this->file, $this->namespace); - } } diff --git a/libs/FML/Script/ScriptLabel.php b/libs/FML/Script/ScriptLabel.php index b85388fe..689f749b 100644 --- a/libs/FML/Script/ScriptLabel.php +++ b/libs/FML/Script/ScriptLabel.php @@ -6,103 +6,164 @@ namespace FML\Script; * Class representing a part of the ManiaLink 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 ScriptLabel { - /* - * Constants - */ - const ONINIT = 'FML_OnInit'; - const LOOP = 'FML_Loop'; - const TICK = 'FML_Tick'; - const ENTRYSUBMIT = 'FML_EntrySubmit'; - const KEYPRESS = 'FML_KeyPress'; - const MOUSECLICK = 'FML_MouseClick'; - const MOUSEOUT = 'FML_MouseOut'; - const MOUSEOVER = 'FML_MouseOver'; +class ScriptLabel +{ - /* - * Protected properties - */ - protected $name = null; - protected $text = null; - protected $isolated = null; + /* + * Constants + */ + const ONINIT = 'FML_OnInit'; + const LOOP = 'FML_Loop'; + const TICK = 'FML_Tick'; + const ENTRYSUBMIT = 'FML_EntrySubmit'; + const KEYPRESS = 'FML_KeyPress'; + const MOUSECLICK = 'FML_MouseClick'; + const MOUSEOUT = 'FML_MouseOut'; + const MOUSEOVER = 'FML_MouseOver'; - /** - * Construct a new ScriptLabel - * - * @param string $name (optional) Label name - * @param string $text (optional) Script text - * @param bool $isolated (optional) Isolate the Label Script - */ - public function __construct($name = self::LOOP, $text = null, $isolated = false) { - $this->setName($name); - $this->setText($text); - $this->setIsolated($isolated); - } + /** + * @var string $name Label name + */ + protected $name = null; - /** - * Set the name - * - * @param string $name Label name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $text Script text + */ + protected $text = null; - /** - * Set the text - * - * @param string $text Script text - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * @var bool $isolated Isolate the script + */ + protected $isolated = null; - /** - * Set isolation - * - * @param bool $isolated Whether the code should be isolated in an own block - * @return static - */ - public function setIsolated($isolated) { - $this->isolated = (bool)$isolated; - return $this; - } + /** + * Construct a new ScriptLabel + * + * @api + * @param string $name (optional) Label name + * @param string $text (optional) Script text + * @param bool $isolated (optional) Isolate the script + */ + public function __construct($name = self::LOOP, $text = null, $isolated = null) + { + if ($name) { + $this->setName($name); + } + if ($text) { + $this->setText($text); + } + if ($isolated) { + $this->setIsolated($isolated); + } + } - /** - * Check if the given label is an event label - * - * @param string $label Label name - * @return bool - */ - public static function isEventLabel($label) { - if (in_array($label, static::getEventLabels())) { - return true; - } - return false; - } + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Get the possible event label names - * - * @return string[] - */ - public static function getEventLabels() { - return array(self::ENTRYSUBMIT, self::KEYPRESS, self::MOUSECLICK, self::MOUSEOUT, self::MOUSEOVER); - } + /** + * Set the name + * + * @api + * @param string $name Label name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the text + * + * @api + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set the text + * + * @api + * @param string $text Script text + * @return static + */ + public function setText($text) + { + $this->text = (string)$text; + return $this; + } + + /** + * Get isolation + * + * @api + * @return bool + */ + public function getIsolated() + { + return $this->isolated; + } + + /** + * Set isolation + * + * @api + * @param bool $isolated If the code should be isolated in an own block + * @return static + */ + public function setIsolated($isolated) + { + $this->isolated = (bool)$isolated; + return $this; + } + + /** + * Build the full Script Label text + * + * @return string + */ + public function __toString() + { + return Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated); + } + + /** + * Get the possible event label names + * + * @return string[] + */ + public static function getEventLabels() + { + return array(self::ENTRYSUBMIT, self::KEYPRESS, self::MOUSECLICK, self::MOUSEOUT, self::MOUSEOVER); + } + + /** + * Check if the given label name describes an event label + * + * @param string $label Label name + * @return bool + */ + public static function isEventLabel($label) + { + if (in_array($label, static::getEventLabels())) { + return true; + } + return false; + } - /** - * Build the full Script Label text - * - * @return string - */ - public function __toString() { - return Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated); - } } diff --git a/libs/FML/Stylesheet/Mood.php b/libs/FML/Stylesheet/Mood.php index 400b1e76..47fdfceb 100644 --- a/libs/FML/Stylesheet/Mood.php +++ b/libs/FML/Stylesheet/Mood.php @@ -2,284 +2,531 @@ namespace FML\Stylesheet; - // Warning: The mood class isn't fully supported yet! - // Missing attributes: LDir1.. - /** * Class representing a Stylesheet Mood + * Warning: The mood class isn't fully supported yet - Missing attributes: LDir1 etc. * * @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 Mood { - /* - * Protected properties - */ - protected $tagName = 'mood'; - protected $lAmbient_LinearRgb = null; - protected $cloudsRgbMinLinear = null; - protected $cloudsRgbMaxLinear = null; - protected $lDir0_LinearRgb = null; - protected $lDir0_Intens = 1.; - protected $lDir0_DirPhi = 0.; - protected $lDir0_DirTheta = 0.; - protected $lBall_LinearRgb = null; - protected $lBall_Intensity = 1.; - protected $lBall_Radius = 0.; - protected $fogColorSrgb = null; - protected $selfIllumColor = null; - protected $skyGradientV_Scale = 1.; - protected $skyGradientKeys = array(); +class Mood +{ - /** - * Create a new Mood object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var string $lightAmbientColor Light ambient color + */ + protected $lightAmbientColor = null; - /** - * Set ambient color in which the Elements reflect the light - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setLightAmbientColor($red, $green, $blue) { - $this->lAmbient_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var string $cloudsMinimumColor Clouds minimum color + */ + protected $cloudsMinimumColor = null; - /** - * Set minimum value for the background color range - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setCloudsColorMin($red, $green, $blue) { - $this->cloudsRgbMinLinear = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var string $cloudsMaximumColor Clouds maximum color + */ + protected $cloudsMaximumColor = null; - /** - * Set maximum value for the background color range - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setCloudsColorMax($red, $green, $blue) { - $this->cloudsRgbMaxLinear = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var string $light0Color Color of light source 0 + */ + protected $light0Color = null; - /** - * Set RGB color of light source 0 - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setLight0Color($red, $green, $blue) { - $this->lDir0_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var float $light0Intensity Intensity of light source 0 + */ + protected $light0Intensity = 1.; - /** - * Set intensity of light source 0 - * - * @param float $intensity Light intensity - * @return static - */ - public function setLight0Intensity($intensity) { - $this->lDir0_Intens = (float)$intensity; - return $this; - } + /** + * @var float $light0PhiAngle Phi angle of light source 0 + */ + protected $light0PhiAngle = 0.; - /** - * Set phi angle of light source 0 - * - * @param float $phiAngle Phi angle - * @return static - */ - public function setLight0PhiAngle($phiAngle) { - $this->lDir0_DirPhi = (float)$phiAngle; - return $this; - } + /** + * @var float $light0ThetaAngle Theta angle of light source 0 + */ + protected $light0ThetaAngle = 0.; - /** - * Set theta angle of light source 0 - * - * @param float $thetaAngle Theta angle - * @return static - */ - public function setLight0ThetaAngle($thetaAngle) { - $this->lDir0_DirTheta = (float)$thetaAngle; - return $this; - } + /** + * @var string $lightBallColor Light ball color + */ + protected $lightBallColor = null; - /** - * Set light ball color - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setLightBallColor($red, $green, $blue) { - $this->lBall_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var float $lightBallIntensity Light ball intensity + */ + protected $lightBallIntensity = 1.; - /** - * Set light ball intensity - * - * @param float $intensity Light ball intensity - * @return static - */ - public function setLightBallIntensity($intensity) { - $this->lBall_Intensity = (float)$intensity; - return $this; - } + /** + * @var float $lightBallRadius Light ball radius + */ + protected $lightBallRadius = 0.; - /** - * Set light ball radius - * - * @param float $radius Light ball radius - * @return static - */ - public function setLightBallRadius($radius) { - $this->lBall_Radius = (float)$radius; - return $this; - } + /** + * @var string $fogColor Fog color + */ + protected $fogColor = null; - /** - * Set fog color - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setFogColor($red, $green, $blue) { - $this->fogColorSrgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var float $selfIlluminationColor Self illumination color + */ + protected $selfIlluminationColor = null; - /** - * Set self illumination color - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setSelfIllumColor($red, $green, $blue) { - $this->selfIllumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var float $skyGradientV_Scale Sky gradient scale + */ + protected $skyGradientScale = 1.; - /** - * Set sky gradient scale - * - * @param float $scale Gradient scale - * @return static - */ - public function setSkyGradientScale($scale) { - $this->skyGradientV_Scale = (float)$scale; - return $this; - } + /** + * @var SkyGradientKey[] $skyGradientKeys Sky Gradient Keys + */ + protected $skyGradientKeys = array(); - /** - * Add a sky gradient key - * - * @param float $gradientX Scale value - * @param string $color Gradient color - * @return static - */ - public function addSkyGradientKey($gradientX, $color) { - $gradientX = (float)$gradientX; - $color = (string)$color; - $gradientKey = array('x' => $gradientX, 'color' => $color); - array_push($this->skyGradientKeys, $gradientKey); - return $this; - } + /** + * Create a new Mood + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Remove all sky gradient keys - * - * @return static - */ - public function removeSkyGradientKeys() { - $this->skyGradientKeys = array(); - return $this; - } + /** + * Get the light ambient color + * + * @api + * @return string + */ + public function getLightAmbientColor() + { + return $this->lightAmbientColor; + } + + /** + * Set the ambient color in which elements reflect the light + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setLightAmbientColor($red, $green, $blue) + { + $this->lightAmbientColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the minimum value for the background color range + * + * @api + * @return string + */ + public function getCloudsMinimumColor() + { + return $this->cloudsMinimumColor; + } + + /** + * Set the minimum value for the background color range + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setCloudsMinimumColor($red, $green, $blue) + { + $this->cloudsMinimumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the maximum value for the background color range + * + * @api + * @return string + */ + public function getCloudsMaximumColor() + { + return $this->cloudsMaximumColor; + } + + /** + * Set the maximum value for the background color range + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setCloudsMaximumColor($red, $green, $blue) + { + $this->cloudsMaximumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the RGB color of light source 0 + * + * @api + * @return string + */ + public function getLight0Color() + { + return $this->light0Color; + } + + /** + * Set the RGB color of light source 0 + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setLight0Color($red, $green, $blue) + { + $this->light0Color = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the intensity of light source 0 + * + * @api + * @return float + */ + public function getLight0Intensity() + { + return $this->light0Intensity; + } + + /** + * Set the intensity of light source 0 + * + * @api + * @param float $intensity Light intensity + * @return static + */ + public function setLight0Intensity($intensity) + { + $this->light0Intensity = (float)$intensity; + return $this; + } + + /** + * Get the phi angle of light source 0 + * + * @api + * @return float + */ + public function getLight0PhiAngle() + { + return $this->light0PhiAngle; + } + + /** + * Set the phi angle of light source 0 + * + * @api + * @param float $phiAngle Phi angle + * @return static + */ + public function setLight0PhiAngle($phiAngle) + { + $this->light0PhiAngle = (float)$phiAngle; + return $this; + } + + /** + * Get the theta angle of light source 0 + * + * @api + * @return float + */ + public function getLight0ThetaAngle() + { + return $this->light0ThetaAngle; + } + + /** + * Set the theta angle of light source 0 + * + * @api + * @param float $thetaAngle Theta angle + * @return static + */ + public function setLight0ThetaAngle($thetaAngle) + { + $this->light0ThetaAngle = (float)$thetaAngle; + return $this; + } + + /** + * Get the light ball color + * + * @api + * @return string + */ + public function getLightBallColor() + { + return $this->lightBallColor; + } + + /** + * Set the light ball color + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setLightBallColor($red, $green, $blue) + { + $this->lightBallColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the light ball intensity + * + * @api + * @return float + */ + public function getLightBallIntensity() + { + return $this->lightBallIntensity; + } + + /** + * Set the light ball intensity + * + * @api + * @param float $intensity Light ball intensity + * @return static + */ + public function setLightBallIntensity($intensity) + { + $this->lightBallIntensity = (float)$intensity; + return $this; + } + + /** + * Get the light ball radius + * + * @api + * @return float + */ + public function getLightBallRadius() + { + return $this->lightBallRadius; + } + + /** + * Set the light ball radius + * + * @api + * @param float $radius Light ball radius + * @return static + */ + public function setLightBallRadius($radius) + { + $this->lightBallRadius = (float)$radius; + return $this; + } + + /** + * Get the fog color + * + * @api + * @return string + */ + public function getFogColor() + { + return $this->fogColor; + } + + /** + * Set the fog color + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setFogColor($red, $green, $blue) + { + $this->fogColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the self illumination color + * + * @api + * @return string + */ + public function getSelfIlluminationColor() + { + return $this->selfIlluminationColor; + } + + /** + * Set the self illumination color + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setSelfIlluminationColor($red, $green, $blue) + { + $this->selfIlluminationColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the sky gradient scale + * + * @api + * @return float + */ + public function getSkyGradientScale() + { + return $this->skyGradientScale; + } + + /** + * Set the sky gradient scale + * + * @api + * @param float $skyGradientScale Sky gradient scale + * @return static + */ + public function setSkyGradientScale($skyGradientScale) + { + $this->skyGradientScale = (float)$skyGradientScale; + return $this; + } + + /** + * Get Sky Gradient Keys + * + * @api + * @return SkyGradientKey[] + */ + public function getSkyGradientKeys() + { + return $this->skyGradientKeys; + } + + /** + * Add a sky gradient key + * + * @api + * @param SkyGradientKey $skyGradientKey Sky Gradient Key + * @return static + */ + public function addSkyGradientKey(SkyGradientKey $skyGradientKey) + { + array_push($this->skyGradientKeys, $skyGradientKey); + return $this; + } + + /** + * Add a sky gradient + * + * @api + * @param float $x X value + * @param string $color Color value + * @return static + */ + public function addSkyGradient($x, $color) + { + $skyGradientKey = new SkyGradientKey($x, $color); + return $this->addSkyGradientKey($skyGradientKey); + } + + /** + * Remove all Sky Gradient Keys + * + * @api + * @return static + */ + public function removeAllSkyGradientKeys() + { + $this->skyGradientKeys = array(); + return $this; + } + + /** + * Render the Mood + * + * @param \DOMDocument $domDocument DOMDocument for which the Mood should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("mood"); + if ($this->lightAmbientColor) { + $domElement->setAttribute("LAmbient_LinearRgb", $this->lightAmbientColor); + } + if ($this->cloudsMinimumColor) { + $domElement->setAttribute("CloudsRgbMinLinear", $this->cloudsMinimumColor); + } + if ($this->cloudsMaximumColor) { + $domElement->setAttribute("CloudsRgbMaxLinear", $this->cloudsMaximumColor); + } + if ($this->light0Color) { + $domElement->setAttribute("LDir0_LinearRgb", $this->light0Color); + } + if ($this->light0Intensity != 1.) { + $domElement->setAttribute("LDir0_Intens", $this->light0Intensity); + } + if ($this->light0PhiAngle) { + $domElement->setAttribute("LDir0_DirPhi", $this->light0PhiAngle); + } + if ($this->light0ThetaAngle) { + $domElement->setAttribute("LDir0_DirTheta", $this->light0ThetaAngle); + } + if ($this->lightBallColor) { + $domElement->setAttribute("LBall_LinearRgb", $this->lightBallColor); + } + if ($this->lightBallIntensity != 1.) { + $domElement->setAttribute("LBall_Intens", $this->lightBallIntensity); + } + if ($this->lightBallRadius) { + $domElement->setAttribute("LBall_Radius", $this->lightBallRadius); + } + if ($this->fogColor) { + $domElement->setAttribute("FogColorSrgb", $this->fogColor); + } + if ($this->selfIlluminationColor) { + $domElement->setAttribute("SelfIllumColor", $this->selfIlluminationColor); + } + if ($this->skyGradientScale != 1.) { + $domElement->setAttribute("SkyGradientV_Scale", $this->skyGradientScale); + } + if ($this->skyGradientKeys) { + $skyGradientElement = $domDocument->createElement("skygradient"); + $domElement->appendChild($skyGradientElement); + foreach ($this->skyGradientKeys as $skyGradientKey) { + $skyGradientKeyElement = $skyGradientKey->render($domDocument); + $skyGradientElement->appendChild($skyGradientKeyElement); + } + } + return $domElement; + } - /** - * Render the Mood XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the Mood XML element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $moodXml = $domDocument->createElement($this->tagName); - if ($this->lAmbient_LinearRgb) { - $moodXml->setAttribute('LAmbient_LinearRgb', $this->lAmbient_LinearRgb); - } - if ($this->cloudsRgbMinLinear) { - $moodXml->setAttribute('CloudsRgbMinLinear', $this->cloudsRgbMinLinear); - } - if ($this->cloudsRgbMaxLinear) { - $moodXml->setAttribute('CloudsRgbMaxLinear', $this->cloudsRgbMaxLinear); - } - if ($this->lDir0_LinearRgb) { - $moodXml->setAttribute('LDir0_LinearRgb', $this->lDir0_LinearRgb); - } - if ($this->lDir0_Intens) { - $moodXml->setAttribute('LDir0_Intens', $this->lDir0_Intens); - } - if ($this->lDir0_DirPhi) { - $moodXml->setAttribute('LDir0_DirPhi', $this->lDir0_DirPhi); - } - if ($this->lDir0_DirTheta) { - $moodXml->setAttribute('LDir0_DirTheta', $this->lDir0_DirTheta); - } - if ($this->lBall_LinearRgb) { - $moodXml->setAttribute('LBall_LinearRgb', $this->lBall_LinearRgb); - } - if ($this->lBall_Intensity) { - $moodXml->setAttribute('LBall_Intens', $this->lBall_Intensity); - } - if ($this->lBall_Radius) { - $moodXml->setAttribute('LBall_Radius', $this->lBall_Radius); - } - if ($this->fogColorSrgb) { - $moodXml->setAttribute('FogColorSrgb', $this->fogColorSrgb); - } - if ($this->selfIllumColor) { - $moodXml->setAttribute('SelfIllumColor', $this->selfIllumColor); - } - if ($this->skyGradientV_Scale) { - $moodXml->setAttribute('SkyGradientV_Scale', $this->skyGradientV_Scale); - } - if ($this->skyGradientKeys) { - $skyGradientXml = $domDocument->createElement('skygradient'); - $moodXml->appendChild($skyGradientXml); - foreach ($this->skyGradientKeys as $gradientKey) { - $keyXml = $domDocument->createElement('key'); - $skyGradientXml->appendChild($keyXml); - $keyXml->setAttribute('x', $gradientKey['x']); - $keyXml->setAttribute('color', $gradientKey['color']); - } - } - return $moodXml; - } } diff --git a/libs/FML/Stylesheet/SkyGradientKey.php b/libs/FML/Stylesheet/SkyGradientKey.php new file mode 100644 index 00000000..8ef7ea9b --- /dev/null +++ b/libs/FML/Stylesheet/SkyGradientKey.php @@ -0,0 +1,117 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class SkyGradientKey +{ + + /** + * @var float $x X value + */ + protected $x = null; + + /** + * @var string $color Color value + */ + protected $color = null; + + /** + * Create a new SkyGradientKey + * + * @api + * @param float $x X value + * @param string $color Color value + * @return static + */ + public static function create($x = null, $color = null) + { + return new static($x, $color); + } + + /** + * Construct a new SkyGradientKey + * + * @api + * @param float $x X value + * @param string $color Color value + */ + public function __construct($x = null, $color = null) + { + if ($x) { + $this->setX($x); + } + if ($color) { + $this->setColor($color); + } + } + + /** + * Get the X value + * + * @api + * @return float + */ + public function getX() + { + return $this->x; + } + + /** + * Set the X value + * + * @api + * @param float $x X value + * @return static + */ + public function setX($x) + { + $this->x = (float)$x; + return $this; + } + + /** + * Get the Color value + * + * @api + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set the Color value + * + * @api + * @param string $color Color value + * @return static + */ + public function setColor($color) + { + $this->color = (string)$color; + return $this; + } + + /** + * Render the SkyGradientKey + * + * @param \DOMDocument $domDocument DOMDocument for which the Sky Gradient Key should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("key"); + $domElement->setAttribute("x", $this->x); + $domElement->setAttribute("color", $this->color); + return $domElement; + } + +} diff --git a/libs/FML/Stylesheet/Style3d.php b/libs/FML/Stylesheet/Style3d.php index 45476ab4..6129845a 100644 --- a/libs/FML/Stylesheet/Style3d.php +++ b/libs/FML/Stylesheet/Style3d.php @@ -8,240 +8,427 @@ use FML\UniqueID; * Class representing a Style3d * * @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 Style3d { - /* - * Constants - */ - const MODEL_Box = 'Box'; - const MODEL_Button = 'Button'; - const MODEL_ButtonH = 'ButtonH'; - const MODEL_Title = 'Title'; - const MODEL_Window = 'Window'; +class Style3d +{ - /* - * Protected properties - */ - protected $tagName = 'style3d'; - protected $styleId = null; - protected $model = self::MODEL_Box; - protected $thickness = null; - protected $color = null; - protected $focusColor = null; - protected $lightColor = null; - protected $focusLightColor = null; - protected $yOffset = null; - protected $focusYOffset = null; - protected $zOffset = null; - protected $focusZOffset = null; + /* + * Constants + */ + const MODEL_Box = "Box"; + const MODEL_Button = "Button"; + const MODEL_ButtonH = "ButtonH"; + const MODEL_Title = "Title"; + const MODEL_Window = "Window"; - /** - * Create a new Style3d object - * - * @param string $styleId (optional) Style id - * @return static - */ - public static function create($styleId = null) { - return new static($styleId); - } + /** + * @var string $styleId Style ID + */ + protected $styleId = null; - /** - * Construct a new Style3d object - * - * @param string $styleId (optional) Style id - */ - public function __construct($styleId = null) { - if ($styleId !== null) { - $this->setId($styleId); - } - } + /** + * @var string $model Style model + */ + protected $model = self::MODEL_Box; - /** - * Set style id - * - * @param string $styleId Style id - * @return static - */ - public function setId($styleId) { - $this->styleId = (string)$styleId; - return $this; - } + /** + * @var float $thickness Thickness + */ + protected $thickness = null; - /** - * Check for id and assign one if necessary - * - * @return static - */ - public function checkId() { - if (!$this->styleId) { - $this->setId(new UniqueID()); - } - return $this; - } + /** + * @var string $color Color + */ + protected $color = null; - /** - * Get style id - * - * @return string - */ - public function getId() { - return $this->styleId; - } + /** + * @var string $focusColor Focus color + */ + protected $focusColor = null; - /** - * Set model - * - * @param string $model Style model - * @return static - */ - public function setModel($model) { - $this->model = (string)$model; - return $this; - } + /** + * @var string $lightColor Light color + */ + protected $lightColor = null; - /** - * Set thickness - * - * @param float $thickness Style thickness - * @return static - */ - public function setThickness($thickness) { - $this->thickness = (float)$thickness; - return $this; - } + /** + * @var string $focusLightColor Focus light color + */ + protected $focusLightColor = null; - /** - * Set color - * - * @param string $color Style color - * @return static - */ - public function setColor($color) { - $this->color = (string)$color; - return $this; - } + /** + * @var float $yOffset Y-offset + */ + protected $yOffset = null; - /** - * Set focus color - * - * @param string $focusColor Style focus color - * @return static - */ - public function setFocusColor($focusColor) { - $this->focusColor = (string)$focusColor; - return $this; - } + /** + * @var float $focusYOffset Focus Y-offset + */ + protected $focusYOffset = null; - /** - * Set light color - * - * @param string $lightColor Light color - * @return static - */ - public function setLightColor($lightColor) { - $this->lightColor = (string)$lightColor; - return $this; - } + /** + * @var float $zOffset Z-offset + */ + protected $zOffset = null; - /** - * Set focus light color - * - * @param string $focusLightColor Focus light color - * @return static - */ - public function setFocusLightColor($focusLightColor) { - $this->focusLightColor = (string)$focusLightColor; - return $this; - } + /** + * @var float $focusZOffset Focus Z-offset + */ + protected $focusZOffset = null; - /** - * Set Y-offset - * - * @param float $yOffset Y-offset - * @return static - */ - public function setYOffset($yOffset) { - $this->yOffset = (float)$yOffset; - return $this; - } + /** + * Create a new Style3d + * + * @api + * @param string $styleId (optional) Style ID + * @param string $model (optional) Style model + * @return static + */ + public static function create($styleId = null, $model = null) + { + return new static($styleId, $model); + } - /** - * Set focus Y-offset - * - * @param float $focusYOffset Focus Y-offset - * @return static - */ - public function setFocusYOffset($focusYOffset) { - $this->focusYOffset = (float)$focusYOffset; - return $this; - } + /** + * Construct a new Style3d + * + * @api + * @param string $styleId (optional) Style ID + * @param string $model (optional) Style model + */ + public function __construct($styleId = null, $model = null) + { + if ($styleId) { + $this->setId($styleId); + } + if ($model) { + $this->setModel($model); + } + } - /** - * Set Z-offset - * - * @param float $zOffset Z-offset - * @return static - */ - public function setZOffset($zOffset) { - $this->zOffset = (float)$zOffset; - return $this; - } + /** + * Get the Style ID + * + * @api + * @return string + */ + public function getId() + { + return $this->styleId; + } - /** - * Set focus Z-offset - * - * @param float $focusZOffset Focus Z-offset - * @return static - */ - public function setFocusZOffset($focusZOffset) { - $this->focusZOffset = (float)$focusZOffset; - return $this; - } + /** + * Set the Style ID + * + * @api + * @param string $styleId Style ID + * @return static + */ + public function setId($styleId) + { + $this->styleId = (string)$styleId; + return $this; + } + + /** + * Check the ID and assign one if necessary + * + * @return static + */ + public function checkId() + { + if (!$this->styleId) { + $this->setId(new UniqueID()); + } + return $this; + } + + /** + * Get the model + * + * @api + * @return string + */ + public function getModel() + { + return $this->model; + } + + /** + * Set the model + * + * @api + * @param string $model Style model + * @return static + */ + public function setModel($model) + { + $this->model = (string)$model; + return $this; + } + + /** + * Get the thickness + * + * @api + * @return float + */ + public function getThickness() + { + return $this->thickness; + } + + /** + * Set the thickness + * + * @api + * @param float $thickness Style thickness + * @return static + */ + public function setThickness($thickness) + { + $this->thickness = (float)$thickness; + return $this; + } + + /** + * Get the color + * + * @api + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set the color + * + * @api + * @param string $color Style color + * @return static + */ + public function setColor($color) + { + $this->color = (string)$color; + return $this; + } + + /** + * Get the focus color + * + * @api + * @return string + */ + public function getFocusColor() + { + return $this->focusColor; + } + + /** + * Set the focus color + * + * @api + * @param string $focusColor Style focus color + * @return static + */ + public function setFocusColor($focusColor) + { + $this->focusColor = (string)$focusColor; + return $this; + } + + /** + * Get the light color + * + * @api + * @return string + */ + public function getLightColor() + { + return $this->lightColor; + } + + /** + * Set the light color + * + * @api + * @param string $lightColor Light color + * @return static + */ + public function setLightColor($lightColor) + { + $this->lightColor = (string)$lightColor; + return $this; + } + + /** + * Get the focus light color + * + * @api + * @return string + */ + public function getFocusLightColor() + { + return $this->focusLightColor; + } + + /** + * Set the focus light color + * + * @api + * @param string $focusLightColor Focus light color + * @return static + */ + public function setFocusLightColor($focusLightColor) + { + $this->focusLightColor = (string)$focusLightColor; + return $this; + } + + /** + * Get the Y-offset + * + * @api + * @return float + */ + public function getYOffset() + { + return $this->yOffset; + } + + /** + * Set the Y-offset + * + * @api + * @param float $yOffset Y-offset + * @return static + */ + public function setYOffset($yOffset) + { + $this->yOffset = (float)$yOffset; + return $this; + } + + /** + * Get the focus Y-offset + * + * @api + * @return float + */ + public function getFocusYOffset() + { + return $this->focusYOffset; + } + + /** + * Set the focus Y-offset + * + * @api + * @param float $focusYOffset Focus Y-offset + * @return static + */ + public function setFocusYOffset($focusYOffset) + { + $this->focusYOffset = (float)$focusYOffset; + return $this; + } + + /** + * Get the Z-offset + * + * @api + * @return float + */ + public function getZOffset() + { + return $this->zOffset; + } + + /** + * Set the Z-offset + * + * @api + * @param float $zOffset Z-offset + * @return static + */ + public function setZOffset($zOffset) + { + $this->zOffset = (float)$zOffset; + return $this; + } + + /** + * Get the focus Z-offset + * + * @api + * @return float + */ + public function getFocusZOffset() + { + return $this->focusZOffset; + } + + /** + * Set the focus Z-offset + * + * @api + * @param float $focusZOffset Focus Z-offset + * @return static + */ + public function setFocusZOffset($focusZOffset) + { + $this->focusZOffset = (float)$focusZOffset; + return $this; + } + + /** + * Render the Style3d + * + * @param \DOMDocument $domDocument DOMDocument for which the Style3d should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $style3dXml = $domDocument->createElement("style3d"); + $this->checkId(); + if ($this->styleId) { + $style3dXml->setAttribute("id", $this->styleId); + } + if ($this->model) { + $style3dXml->setAttribute("model", $this->model); + } + if ($this->thickness) { + $style3dXml->setAttribute("thickness", $this->thickness); + } + if ($this->color) { + $style3dXml->setAttribute("color", $this->color); + } + if ($this->focusColor) { + $style3dXml->setAttribute("fcolor", $this->focusColor); + } + if ($this->lightColor) { + $style3dXml->setAttribute("lightcolor", $this->lightColor); + } + if ($this->focusLightColor) { + $style3dXml->setAttribute("flightcolor", $this->focusLightColor); + } + if ($this->yOffset) { + $style3dXml->setAttribute("yoffset", $this->yOffset); + } + if ($this->focusYOffset) { + $style3dXml->setAttribute("fyoffset", $this->focusYOffset); + } + if ($this->zOffset) { + $style3dXml->setAttribute("zoffset", $this->zOffset); + } + if ($this->focusZOffset) { + $style3dXml->setAttribute("fzoffset", $this->focusZOffset); + } + return $style3dXml; + } - /** - * Render the Style3d XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the Style3d XML element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $style3dXml = $domDocument->createElement($this->tagName); - $this->checkId(); - if ($this->styleId) { - $style3dXml->setAttribute('id', $this->styleId); - } - if ($this->model) { - $style3dXml->setAttribute('model', $this->model); - } - if ($this->thickness) { - $style3dXml->setAttribute('thickness', $this->thickness); - } - if ($this->color) { - $style3dXml->setAttribute('color', $this->color); - } - if ($this->focusColor) { - $style3dXml->setAttribute('fcolor', $this->focusColor); - } - if ($this->lightColor) { - $style3dXml->setAttribute('lightcolor', $this->lightColor); - } - if ($this->focusLightColor) { - $style3dXml->setAttribute('flightcolor', $this->focusLightColor); - } - if ($this->yOffset) { - $style3dXml->setAttribute('yoffset', $this->yOffset); - } - if ($this->focusYOffset) { - $style3dXml->setAttribute('fyoffset', $this->focusYOffset); - } - if ($this->zOffset) { - $style3dXml->setAttribute('zoffset', $this->zOffset); - } - if ($this->focusZOffset) { - $style3dXml->setAttribute('fzoffset', $this->focusZOffset); - } - return $style3dXml; - } } diff --git a/libs/FML/Stylesheet/Stylesheet.php b/libs/FML/Stylesheet/Stylesheet.php index bc62900f..40865290 100644 --- a/libs/FML/Stylesheet/Stylesheet.php +++ b/libs/FML/Stylesheet/Stylesheet.php @@ -6,95 +6,133 @@ namespace FML\Stylesheet; * Class representing a ManiaLink Stylesheet * * @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 Stylesheet { - /* - * Protected properties - */ - protected $tagName = 'stylesheet'; - /** @var Style3d[] $styles3d */ - protected $styles3d = array(); - /** @var Mood $mood */ - protected $mood = null; +class Stylesheet +{ - /** - * Create a new Stylesheet object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var Style3d[] $styles3d 3d Styles + */ + protected $styles3d = array(); - /** - * Add a new Style3d - * - * @param Style3d $style3d Style3d object - * @return static - */ - public function addStyle3d(Style3d $style3d) { - if (!in_array($style3d, $this->styles3d, true)) { - array_push($this->styles3d, $style3d); - } - return $this; - } + /** + * @var Mood $mood Mood + */ + protected $mood = null; - /** - * Remove all Style3ds - * - * @return static - */ - public function removeStyles() { - $this->styles3d = array(); - return $this; - } + /** + * Create a new Stylesheet + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Set the Mood object of the Stylesheet - * - * @param Mood $mood Mood object - * @return static - */ - public function setMood(Mood $mood) { - $this->mood = $mood; - return $this; - } + /** + * Get the Styles3d + * + * @api + * @return Style3d[] + */ + public function getStyles3d() + { + return $this->styles3d; + } - /** - * Get the Mood object - * - * @param bool $createIfEmpty (optional) Whether the Mood object should be created if it's not set - * @return \FML\Stylesheet\Mood - */ - public function getMood($createIfEmpty = true) { - if (!$this->mood && $createIfEmpty) { - $this->setMood(new Mood()); - } - return $this->mood; - } + /** + * Add a new Style3d + * + * @api + * @param Style3d $style3d The Style3d to be added + * @return static + */ + public function addStyle3d(Style3d $style3d) + { + if (!in_array($style3d, $this->styles3d, true)) { + array_push($this->styles3d, $style3d); + } + return $this; + } + + /** + * Remove all Style3ds + * + * @api + * @return static + */ + public function removeAllStyles3d() + { + $this->styles3d = array(); + return $this; + } + + /** + * Get the Mood + * + * @api + * @return Mood + */ + public function getMood() + { + return $this->mood; + } + + /** + * Set the Mood + * + * @api + * @param Mood $mood Mood + * @return static + */ + public function setMood(Mood $mood = null) + { + $this->mood = $mood; + return $this; + } + + /** + * Create a new Mood if necessary + * + * @api + * @return Mood + */ + public function createMood() + { + if ($this->mood) { + return $this->mood; + } + $mood = new Mood(); + $this->setMood($mood); + return $this->mood; + } + + /** + * Render the Stylesheet + * + * @param \DOMDocument $domDocument DOMDocument for which the Stylesheet should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $stylesheetXml = $domDocument->createElement("stylesheet"); + if ($this->styles3d) { + $stylesXml = $domDocument->createElement("frame3dstyles"); + $stylesheetXml->appendChild($stylesXml); + foreach ($this->styles3d as $style3d) { + $style3dXml = $style3d->render($domDocument); + $stylesXml->appendChild($style3dXml); + } + } + if ($this->mood) { + $moodXml = $this->mood->render($domDocument); + $stylesheetXml->appendChild($moodXml); + } + return $stylesheetXml; + } - /** - * Render the Stylesheet XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the Stylesheet XML element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $stylesheetXml = $domDocument->createElement($this->tagName); - if ($this->styles3d) { - $stylesXml = $domDocument->createElement('frame3dstyles'); - $stylesheetXml->appendChild($stylesXml); - foreach ($this->styles3d as $style3d) { - $style3dXml = $style3d->render($domDocument); - $stylesXml->appendChild($style3dXml); - } - } - if ($this->mood) { - $moodXml = $this->mood->render($domDocument); - $stylesheetXml->appendChild($moodXml); - } - return $stylesheetXml; - } } diff --git a/libs/FML/Types/Actionable.php b/libs/FML/Types/Actionable.php index e6d5a16b..2ca61d61 100644 --- a/libs/FML/Types/Actionable.php +++ b/libs/FML/Types/Actionable.php @@ -6,52 +6,66 @@ namespace FML\Types; * Interface for Elements that support the action attribute * * @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 */ -interface Actionable { - /* - * Constants - */ - const ACTION_0 = '0'; - const ACTION_BACK = 'back'; - const ACTION_ENTER = 'enter'; - const ACTION_HOME = 'home'; - const ACTION_MENU_SOLO = 'menu_solo'; - const ACTION_MENU_COMPETITIONS = 'menu_competitions'; - const ACTION_MENU_LOCAL = 'menu_local'; - const ACTION_MENU_INTERNET = 'menu_internet'; - const ACTION_MENU_EDITORS = 'menu_editors'; - const ACTION_MENU_PROFILE = 'menu_profile'; - const ACTION_QUIT = 'quit'; - const ACTION_QUITSERVER = 'maniaplanet:quitserver'; - const ACTION_SAVEREPLAY = 'maniaplanet:savereplay'; - const ACTION_TOGGLESPEC = 'maniaplanet:togglespec'; - const ACTIONKEY_F5 = 1; - const ACTIONKEY_F6 = 2; - const ACTIONKEY_F7 = 3; - const ACTIONKEY_F8 = 4; +interface Actionable +{ - /** - * Set action - * - * @param string $action Action name - * @return static - */ - public function setAction($action); + /* + * Constants + */ + const ACTION_0 = '0'; + const ACTION_BACK = 'back'; + const ACTION_ENTER = 'enter'; + const ACTION_HOME = 'home'; + const ACTION_MENU_SOLO = 'menu_solo'; + const ACTION_MENU_COMPETITIONS = 'menu_competitions'; + const ACTION_MENU_LOCAL = 'menu_local'; + const ACTION_MENU_INTERNET = 'menu_internet'; + const ACTION_MENU_EDITORS = 'menu_editors'; + const ACTION_MENU_PROFILE = 'menu_profile'; + const ACTION_QUIT = 'quit'; + const ACTION_QUITSERVER = 'maniaplanet:quitserver'; + const ACTION_SAVEREPLAY = 'maniaplanet:savereplay'; + const ACTION_TOGGLESPEC = 'maniaplanet:togglespec'; + const ACTIONKEY_F5 = 1; + const ACTIONKEY_F6 = 2; + const ACTIONKEY_F7 = 3; + const ACTIONKEY_F8 = 4; - /** - * Get the assigned action - * - * @return string - */ - public function getAction(); + /** + * Set the action + * + * @api + * @param string $action Action name + * @return static + */ + public function setAction($action); + + /** + * Get the action + * + * @api + * @return string + */ + public function getAction(); + + /** + * Get the action key + * + * @api + * @return int + */ + public function getActionKey(); + + /** + * Set the action key + * + * @api + * @param int $actionKey Action key + * @return static + */ + public function setActionKey($actionKey); - /** - * Set action key - * - * @param int $actionKey Action key - * @return static - */ - public function setActionKey($actionKey); } diff --git a/libs/FML/Types/BackgroundColorable.php b/libs/FML/Types/BackgroundColorable.php new file mode 100644 index 00000000..191f2dc8 --- /dev/null +++ b/libs/FML/Types/BackgroundColorable.php @@ -0,0 +1,32 @@ + - * @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 */ -interface Container { +interface Container +{ - /** - * Add a new child Element - * - * @param Renderable $child Child Control to add - * @return static - */ - public function add(Renderable $child); + /** + * Get the children + * + * @api + * @return Renderable[] + */ + public function getChildren(); - /** - * Remove all children - * - * @return static - */ - public function removeChildren(); + /** + * Add a new child + * + * @api + * @param Renderable $child Child Control to add + * @return static + */ + public function addChild(Renderable $child); - /** - * Set the Format object of the Container - * - * @param Format $format New Format object - * @return static - */ - public function setFormat(Format $format); + /** + * Add new children + * + * @api + * @param Renderable[] $children Child Controls to add + * @return static + */ + public function addChildren(array $children); + + /** + * Remove all children + * + * @api + * @return static + */ + public function removeAllChildren(); + + /** + * Get the Format + * + * @api + * @return Format + */ + public function getFormat(); + + /** + * Set the Format + * + * @api + * @param Format $format New Format + * @return static + */ + public function setFormat(Format $format = null); - /** - * Get the Format object of the Container - * - * @param bool $createIfEmpty (optional) Whether the Format object should be created if it's not set - * @return \FML\Elements\Format - */ - public function getFormat($createIfEmpty = true); } diff --git a/libs/FML/Types/Identifiable.php b/libs/FML/Types/Identifiable.php new file mode 100644 index 00000000..a7d284dc --- /dev/null +++ b/libs/FML/Types/Identifiable.php @@ -0,0 +1,39 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +interface Identifiable +{ + + /** + * Get the Id + * + * @api + * @return string + */ + public function getId(); + + /** + * Set the Id + * + * @api + * @param string $id ID + * @return static + */ + public function setId($id); + + /** + * Check and return the Id + * + * @return string + */ + public function checkId(); + +} diff --git a/libs/FML/Types/Imageable.php b/libs/FML/Types/Imageable.php new file mode 100644 index 00000000..4adcb328 --- /dev/null +++ b/libs/FML/Types/Imageable.php @@ -0,0 +1,32 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +interface Imageable +{ + + /** + * Get the image url + * + * @api + * @return string + */ + public function getImageUrl(); + + /** + * Set the image url + * + * @api + * @param string $imageUrl Image url + * @return static + */ + public function setImageUrl($imageUrl); + +} diff --git a/libs/FML/Types/Linkable.php b/libs/FML/Types/Linkable.php index c029c51e..a2149e36 100644 --- a/libs/FML/Types/Linkable.php +++ b/libs/FML/Types/Linkable.php @@ -6,40 +6,78 @@ namespace FML\Types; * Interface for Elements with url attributes * * @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 */ -interface Linkable { +interface Linkable +{ - /** - * Set url - * - * @param string $url Link url - * @return static - */ - public function setUrl($url); + /** + * Get the url + * + * @api + * @return string + */ + public function getUrl(); - /** - * Set url id to use from Dico - * - * @param string $urlId Url id - * @return static - */ - public function setUrlId($urlId); + /** + * Set the url + * + * @api + * @param string $url Link url + * @return static + */ + public function setUrl($url); - /** - * Set manialink - * - * @param string $manialink Manialink name - * @return static - */ - public function setManialink($manialink); + /** + * Get the url id to use from Dico + * + * @api + * @return string + */ + public function getUrlId(); + + /** + * Set the url id to use from Dico + * + * @api + * @param string $urlId Url id + * @return static + */ + public function setUrlId($urlId); + + /** + * Get the manialink + * + * @api + * @return string + */ + public function getManialink(); + + /** + * Set the manialink + * + * @api + * @param string $manialink Manialink name + * @return static + */ + public function setManialink($manialink); + + /** + * Get the manialink id to use from Dico + * + * @api + * @return string + */ + public function getManialinkId(); + + /** + * Set the manialink id to use from Dico + * + * @api + * @param string $manialinkId Manialink id + * @return static + */ + public function setManialinkId($manialinkId); - /** - * Set manialink id to use from Dico - * - * @param string $manialinkId Manialink id - * @return static - */ - public function setManialinkId($manialinkId); } diff --git a/libs/FML/Types/MultiLineable.php b/libs/FML/Types/MultiLineable.php new file mode 100644 index 00000000..573f8590 --- /dev/null +++ b/libs/FML/Types/MultiLineable.php @@ -0,0 +1,66 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +interface MultiLineable +{ + + /** + * Get auto new line + * + * @api + * @return bool + */ + public function getAutoNewLine(); + + /** + * Set auto new line + * + * @api + * @param bool $autoNewLine If the Element should insert new lines automatically + * @return static + */ + public function setAutoNewLine($autoNewLine); + + /** + * Get line spacing + * + * @api + * @return float + */ + public function getLineSpacing(); + + /** + * Set line spacing + * + * @api + * @param float $lineSpacing Line spacing + * @return static + */ + public function setLineSpacing($lineSpacing); + + /** + * Get the maximum number of lines + * + * @api + * @return int + */ + public function getMaxLines(); + + /** + * Set the maximum number of lines + * + * @api + * @param int $maxLines Maximum number of lines + * @return static + */ + public function setMaxLines($maxLines); + +} diff --git a/libs/FML/Types/NewLineable.php b/libs/FML/Types/NewLineable.php index cf85856e..1c72a594 100644 --- a/libs/FML/Types/NewLineable.php +++ b/libs/FML/Types/NewLineable.php @@ -5,17 +5,32 @@ namespace FML\Types; /** * Interface for Elements with autonewline attribute * - * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder - * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + * @deprecated Use MultiLineable + * @see MultiLineable + * @author steeffeen + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface NewLineable { +interface NewLineable +{ + + /** + * Get auto new line + * + * @api + * @deprecated + * @return bool + */ + public function getAutoNewLine(); + + /** + * Set auto new line + * + * @api + * @deprecated + * @param bool $autoNewLine If the Element should insert new lines automatically + * @return static + */ + public function setAutoNewLine($autoNewLine); - /** - * Set auto new line - * - * @param bool $autoNewLine Whether the Control should insert new lines automatically - * @return static - */ - public function setAutoNewLine($autoNewLine); } diff --git a/libs/FML/Types/Playable.php b/libs/FML/Types/Playable.php index 9bb18230..89c9c26e 100644 --- a/libs/FML/Types/Playable.php +++ b/libs/FML/Types/Playable.php @@ -6,56 +6,112 @@ namespace FML\Types; * Interface for Elements with media attributes * * @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 */ -interface Playable { +interface Playable +{ - /** - * Set data - * - * @param string $data Media url - * @return static - */ - public function setData($data); + /** + * Get the data url + * + * @api + * @return string + */ + public function getData(); - /** - * Set data id to use from Dico - * - * @param string $dataId Data id - * @return static - */ - public function setDataId($dataId); + /** + * Set the data url + * + * @api + * @param string $data Data url + * @return static + */ + public function setData($data); - /** - * Set play - * - * @param bool $play Whether the Control should start playing automatically - * @return static - */ - public function setPlay($play); + /** + * Get the data id to use from Dico + * + * @api + * @return string + */ + public function getDataId(); - /** - * Set looping - * - * @param bool $looping Whether the Control should play looping - * @return static - */ - public function setLooping($looping); + /** + * Set the data id to use from Dico + * + * @api + * @param string $dataId Data id + * @return static + */ + public function setDataId($dataId); - /** - * Set music - * - * @param bool $music Whether the Control represents background music - * @return static - */ - public function setMusic($music); + /** + * Get play + * + * @api + * @return bool + */ + public function getPlay(); + + /** + * Set play + * + * @api + * @param bool $play If the Control should start playing automatically + * @return static + */ + public function setPlay($play); + + /** + * Get looping + * + * @api + * @return bool + */ + public function getLooping(); + + /** + * Set looping + * + * @api + * @param bool $looping If the Control should play looping + * @return static + */ + public function setLooping($looping); + + /** + * Get music + * + * @api + * @return bool + */ + public function getMusic(); + + /** + * Set music + * + * @api + * @param bool $music If the Control represents background music + * @return static + */ + public function setMusic($music); + + /** + * Get the volume + * + * @api + * @return float + */ + public function getVolume(); + + /** + * Set the volume + * + * @api + * @param float $volume Media volume + * @return static + */ + public function setVolume($volume); - /** - * Set volume - * - * @param float $volume Media volume - * @return static - */ - public function setVolume($volume); } diff --git a/libs/FML/Types/Renderable.php b/libs/FML/Types/Renderable.php index 24e54240..2733b082 100644 --- a/libs/FML/Types/Renderable.php +++ b/libs/FML/Types/Renderable.php @@ -6,16 +6,18 @@ namespace FML\Types; * Interface for renderable Elements * * @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 */ -interface Renderable { +interface Renderable +{ + + /** + * Render the XML element + * + * @param \DOMDocument $domDocument DOMDocument for which the XML element should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument); - /** - * Render the XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the XML element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument); } diff --git a/libs/FML/Types/ScriptFeatureable.php b/libs/FML/Types/ScriptFeatureable.php index 2c6db6ba..83d401b5 100644 --- a/libs/FML/Types/ScriptFeatureable.php +++ b/libs/FML/Types/ScriptFeatureable.php @@ -2,19 +2,23 @@ namespace FML\Types; +use FML\Script\Features\ScriptFeature; + /** * Interface for Elements supporting ScriptFeatures * * @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 */ -interface ScriptFeatureable { +interface ScriptFeatureable +{ + + /** + * Get the Script Features + * + * @return ScriptFeature[] + */ + public function getScriptFeatures(); - /** - * Get the assigned Script Features of the Element - * - * @return \FML\Script\Features\ScriptFeature[] - */ - public function getScriptFeatures(); } diff --git a/libs/FML/Types/Scriptable.php b/libs/FML/Types/Scriptable.php index 3dc585c6..ce4fbe34 100644 --- a/libs/FML/Types/Scriptable.php +++ b/libs/FML/Types/Scriptable.php @@ -3,19 +3,65 @@ namespace FML\Types; /** - * Interface for Elements with scriptevents attribute + * Interface for Elements with script event attributes * * @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 */ -interface Scriptable { +interface Scriptable +{ + + /** + * Get script events + * + * @api + * @return bool + */ + public function getScriptEvents(); + + /** + * Set script events + * + * @api + * @param bool $scriptEvents If script events should be enabled + * @return static + */ + public function setScriptEvents($scriptEvents); + + /** + * Get script action + * + * @api + * @return string + */ + public function getScriptAction(); + + /** + * Set script action + * + * @api + * @param string $scriptAction Script action to be triggered + * @param string[] $scriptActionParameters (optional) Script action parameters + * @return static + */ + public function setScriptAction($scriptAction, array $scriptActionParameters = null); + + /** + * Get script action parameters + * + * @api + * @return string[] + */ + public function getScriptActionParameters(); + + /** + * Set script action parameters + * + * @api + * @param string[] $scriptActionParameters (optional) Script action parameters + * @return static + */ + public function setScriptActionParameters(array $scriptActionParameters = null); - /** - * Set script events - * - * @param bool $scriptEvents Whether script events should be enabled - * @return static - */ - public function setScriptEvents($scriptEvents); } diff --git a/libs/FML/Types/Styleable.php b/libs/FML/Types/Styleable.php index 7ca8755f..43831192 100644 --- a/libs/FML/Types/Styleable.php +++ b/libs/FML/Types/Styleable.php @@ -6,16 +6,27 @@ namespace FML\Types; * Interface for Elements with style attribute * * @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 */ -interface Styleable { +interface Styleable +{ + + /** + * Get the style + * + * @api + * @return string + */ + public function getStyle(); + + /** + * Set the style + * + * @api + * @param string $style Style name + * @return static + */ + public function setStyle($style); - /** - * Set style - * - * @param string $style Style name - * @return static - */ - public function setStyle($style); } diff --git a/libs/FML/Types/SubStyleable.php b/libs/FML/Types/SubStyleable.php index 337ae0fc..f0d103c1 100644 --- a/libs/FML/Types/SubStyleable.php +++ b/libs/FML/Types/SubStyleable.php @@ -6,25 +6,37 @@ namespace FML\Types; * Interface for Elements with substyle attribute * * @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 */ -interface SubStyleable { +interface SubStyleable +{ - /** - * Set sub style - * - * @param string $subStyle SubStyle name - * @return static - */ - public function setSubStyle($subStyle); + /** + * Get the sub style + * + * @api + * @return string + */ + public function getSubStyle(); + + /** + * Set the sub style + * + * @api + * @param string $subStyle SubStyle name + * @return static + */ + public function setSubStyle($subStyle); + + /** + * Set the style and the sub style + * + * @api + * @param string $style Style name + * @param string $subStyle SubStyle name + * @return static + */ + public function setStyles($style, $subStyle); - /** - * Set style and sub style - * - * @param string $style Style name - * @param string $subStyle SubStyle name - * @return static - */ - public function setStyles($style, $subStyle); } diff --git a/libs/FML/Types/TextFormatable.php b/libs/FML/Types/TextFormatable.php index 161a8298..5ecff9ca 100644 --- a/libs/FML/Types/TextFormatable.php +++ b/libs/FML/Types/TextFormatable.php @@ -6,48 +6,95 @@ namespace FML\Types; * Interface for Elements with formatable text * * @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 */ -interface TextFormatable { +interface TextFormatable +{ - /** - * Set text size - * - * @param int $textSize Text size - * @return static - */ - public function setTextSize($textSize); + /** + * Get the text size + * + * @api + * @return int + */ + public function getTextSize(); - /** - * Set text font - * - * @param string $textFont - * @return static - */ - public function setTextFont($textFont); + /** + * Set the text size + * + * @api + * @param int $textSize Text size + * @return static + */ + public function setTextSize($textSize); - /** - * Set text color - * - * @param string $textColor Text color - * @return static - */ - public function setTextColor($textColor); + /** + * Get the text font + * + * @api + * @return string + */ + public function getTextFont(); - /** - * Set area color - * - * @param string $areaColor Area color - * @return static - */ - public function setAreaColor($areaColor); + /** + * Set the text font + * + * @api + * @param string $textFont + * @return static + */ + public function setTextFont($textFont); + + /** + * Get the text color + * + * @api + * @return string + */ + public function getTextColor(); + + /** + * Set the text color + * + * @api + * @param string $textColor Text color + * @return static + */ + public function setTextColor($textColor); + + /** + * Get the area color + * + * @api + * @return string + */ + public function getAreaColor(); + + /** + * Set the area color + * + * @api + * @param string $areaColor Area color + * @return static + */ + public function setAreaColor($areaColor); + + /** + * Get the area focus color + * + * @api + * @return string + */ + public function getAreaFocusColor(); + + /** + * Set the area focus color + * + * @api + * @param string $areaFocusColor Area focus color + * @return static + */ + public function setAreaFocusColor($areaFocusColor); - /** - * Set area focus color - * - * @param string $areaFocusColor Area focus color - * @return static - */ - public function setAreaFocusColor($areaFocusColor); } diff --git a/libs/FML/UniqueID.php b/libs/FML/UniqueID.php index 4efa151b..add7285a 100644 --- a/libs/FML/UniqueID.php +++ b/libs/FML/UniqueID.php @@ -2,70 +2,123 @@ namespace FML; +use FML\Types\Identifiable; + /** * Unique ID Model Class * * @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 UniqueID { - /* - * Constants - */ - const PREFIX = 'FML_ID_'; +class UniqueID +{ - /* - * Static properties - */ - protected static $currentIndex = 0; + /* + * Constants + */ + const PREFIX = 'FML_ID_'; - /* - * Protected properties - */ - protected $index = null; + /** + * @var int $currentIndex Current global id index + */ + protected static $currentIndex = 0; - /** - * Create a new Unique ID object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var int $index Unique id index + */ + protected $index = null; - /** - * Get a new unique index - * - * @return int - */ - protected static function newIndex() { - self::$currentIndex++; - return self::$currentIndex; - } + /** + * Create a new Unique ID + * + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Construct a Unique ID object - */ - public function __construct() { - $this->index = static::newIndex(); - } + /** + * Check and return the Id of an Identifable Element + * + * @param Identifiable $element Identifable element + * @return string + */ + public static function check(Identifiable $element) + { + $elementId = $element->getId(); - /** - * Get the Unique ID value - * - * @return string - */ - public function getValue() { - return self::PREFIX . $this->index; - } + if (!$elementId) { + $element->setId(new static()); + return $element->getId(); + } + + $dangerousCharacters = array(' ', '|', PHP_EOL); + $danger = false; + foreach ($dangerousCharacters as $dangerousCharacter) { + if (stripos($elementId, $dangerousCharacter) !== false) { + $danger = true; + break; + } + } + + if ($danger) { + trigger_error("Don't use special characters in IDs, they might cause problems! Stripping them for you..."); + $elementId = str_ireplace($dangerousCharacters, '', $elementId); + $element->setId($elementId); + } + + return $element->getId(); + } + + /** + * Get a new global unique index + * + * @return int + */ + protected static function newIndex() + { + self::$currentIndex++; + return self::$currentIndex; + } + + /** + * Construct a Unique ID + */ + public function __construct() + { + $this->index = static::newIndex(); + } + + /** + * Get the Unique ID index + * + * @return int + */ + public function getIndex() + { + return $this->index; + } + + /** + * Get the Unique ID value + * + * @return string + */ + public function getValue() + { + return self::PREFIX . $this->getIndex(); + } + + /** + * Get the string representation + * + * @return string + */ + public function __toString() + { + return $this->getValue(); + } - /** - * Get the string representation - * - * @return string - */ - public function __toString() { - return $this->getValue(); - } } diff --git a/libs/FML/autoload.php b/libs/FML/autoload.php deleted file mode 100644 index ffa9b429..00000000 --- a/libs/FML/autoload.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @version 1.4 - * @link http://github.com/steeffeen/FancyManiaLinks - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder - * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 - */ -if (!defined('FML_PATH')) { - define('FML_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR); -} -if (!defined('FML_VERSION')) { - define('FML_VERSION', '1.4'); -} - -/* - * Autoload function that loads FML class files on demand - */ -if (!defined('FML_AUTOLOAD_DEFINED')) { - define('FML_AUTOLOAD_DEFINED', true); - spl_autoload_register(function ($className) { - $classPath = str_replace('\\', DIRECTORY_SEPARATOR, $className); - $filePath = FML_PATH . $classPath . '.php'; - if (file_exists($filePath)) { - require_once $filePath; - } - }); -}