From 2a70e840e20fd4dcc6f52a2187c4fd9ecd63e56a Mon Sep 17 00:00:00 2001 From: Jocy Date: Fri, 12 May 2017 11:04:26 +0200 Subject: [PATCH] Updated FML https://github.com/ManiaControl/ManiaControl/issues/115 --- core/Manialinks/SidebarMenuEntryRenderable.php | 2 +- libs/FML/Components/CheckBox.php | 14 +++++++++----- libs/FML/Components/ValuePicker.php | 1 - libs/FML/Controls/Label.php | 4 ++-- libs/FML/Controls/Quad.php | 4 +++- libs/FML/Script/Builder.php | 5 ++++- libs/FML/Script/Script.php | 11 ++++++----- libs/FML/Script/ScriptLabel.php | 1 + 8 files changed, 26 insertions(+), 16 deletions(-) diff --git a/core/Manialinks/SidebarMenuEntryRenderable.php b/core/Manialinks/SidebarMenuEntryRenderable.php index 1144a3cb..db54dc93 100644 --- a/core/Manialinks/SidebarMenuEntryRenderable.php +++ b/core/Manialinks/SidebarMenuEntryRenderable.php @@ -15,7 +15,7 @@ namespace ManiaControl\Manialinks; interface SidebarMenuEntryRenderable { /** - * Call here the function which updates the MenuIcon Manialink + * Call here the function which updates the MenuIcon ManiaLink */ public function renderMenuEntry(); } \ No newline at end of file diff --git a/libs/FML/Components/CheckBox.php b/libs/FML/Components/CheckBox.php index 3955d9a7..a5ca4fdc 100644 --- a/libs/FML/Components/CheckBox.php +++ b/libs/FML/Components/CheckBox.php @@ -13,7 +13,6 @@ use FML\Types\ScriptFeatureable; /** * CheckBox Component * - * @uses Quad * @author steeffeen * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 @@ -74,6 +73,8 @@ class CheckBox implements Renderable, ScriptFeatureable public function setName($name) { $this->name = (string)$name; + $this->getEntry() + ->setName($this->name); return $this; } @@ -221,6 +222,7 @@ class CheckBox implements Renderable, ScriptFeatureable * * @param Entry $entry Hidden Entry * @return static + * @deprecated */ public function setEntry(Entry $entry) { @@ -236,9 +238,11 @@ class CheckBox implements Renderable, ScriptFeatureable protected function createEntry() { $entry = new Entry(); - $entry->setVisible(false) - ->setName($this->name); - $this->setEntry($entry); + $entry->setVisible(false); + if ($this->name) { + $entry->setName($this->name); + } + $this->feature->setEntry($entry); return $entry; } @@ -247,7 +251,7 @@ class CheckBox implements Renderable, ScriptFeatureable */ public function getScriptFeatures() { - return ScriptFeature::collect($this->feature, $this->getQuad(), $this->feature->getEntry()); + return ScriptFeature::collect($this->feature, $this->getQuad(), $this->getEntry()); } /** diff --git a/libs/FML/Components/ValuePicker.php b/libs/FML/Components/ValuePicker.php index 0a9e4df2..149536e7 100644 --- a/libs/FML/Components/ValuePicker.php +++ b/libs/FML/Components/ValuePicker.php @@ -13,7 +13,6 @@ use FML\Types\ScriptFeatureable; /** * ValuePicker Component * - * @uses Entry * @author steeffeen * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 diff --git a/libs/FML/Controls/Label.php b/libs/FML/Controls/Label.php index 0462ba28..61b50043 100644 --- a/libs/FML/Controls/Label.php +++ b/libs/FML/Controls/Label.php @@ -65,7 +65,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, MultiL /** * @var int $actionKey Action key */ - protected $actionKey = -1; + protected $actionKey = null; /** * @var string $url Url @@ -651,7 +651,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, MultiL if ($this->action) { $domElement->setAttribute("action", $this->action); } - if ($this->actionKey >= 0) { + if ($this->actionKey) { $domElement->setAttribute("actionkey", $this->actionKey); } if ($this->url) { diff --git a/libs/FML/Controls/Quad.php b/libs/FML/Controls/Quad.php index 96de66e6..c0fecc6a 100644 --- a/libs/FML/Controls/Quad.php +++ b/libs/FML/Controls/Quad.php @@ -98,7 +98,7 @@ class Quad extends Control implements Actionable, BackgroundColorable, BgColorab /** * @var int $actionKey Action key */ - protected $actionKey = -1; + protected $actionKey = null; /** * @var string $url Link url @@ -676,6 +676,8 @@ class Quad extends Control implements Actionable, BackgroundColorable, BgColorab * @api * @param CheckBoxDesign $checkBoxDesign CheckBox Design * @return static + * @deprecated Use CheckBoxDesign::applyToQuad() + * @see CheckBoxDesign::applyToQuad() */ public function applyCheckBoxDesign(CheckBoxDesign $checkBoxDesign) { diff --git a/libs/FML/Script/Builder.php b/libs/FML/Script/Builder.php index 225370d2..61dfb49e 100644 --- a/libs/FML/Script/Builder.php +++ b/libs/FML/Script/Builder.php @@ -146,7 +146,7 @@ abstract class Builder * @param bool $associative (optional) Whether the array should be associative * @return string */ - public static function getArray(array $array, $associative = false) + public static function getArray(array $array, $associative = true) { $arrayText = "["; $index = 0; @@ -180,6 +180,9 @@ abstract class Builder if (is_bool($value)) { return static::getBoolean($value); } + if (is_array($value)) { + return static::getArray($value); + } return $value; } diff --git a/libs/FML/Script/Script.php b/libs/FML/Script/Script.php index 6498a897..57c1027c 100644 --- a/libs/FML/Script/Script.php +++ b/libs/FML/Script/Script.php @@ -265,14 +265,14 @@ class Script */ protected function getHeaderComment() { - $headerComment = '/**************************************************** -* FancyManiaLinks'; + $headerComment = '/************************************************** +* FancyManiaLinks'; if (defined('FML_VERSION')) { $headerComment .= ' v' . FML_VERSION; } - $headerComment .= ' by steeffeen * -* http://github.com/steeffeen/FancyManiaLinks * -****************************************************/ + $headerComment .= ' by steeffeen * +* http://github.com/steeffeen/FancyManiaLinks * +**************************************************/ '; return $headerComment; @@ -349,6 +349,7 @@ main() { } case CMlEvent::Type::MouseClick: { +++' . ScriptLabel::MOUSECLICK . '+++ + +++' . ScriptLabel::MOUSECLICK2 . '+++ } case CMlEvent::Type::MouseOut: { +++' . ScriptLabel::MOUSEOUT . '+++ diff --git a/libs/FML/Script/ScriptLabel.php b/libs/FML/Script/ScriptLabel.php index 689f749b..385e1382 100644 --- a/libs/FML/Script/ScriptLabel.php +++ b/libs/FML/Script/ScriptLabel.php @@ -21,6 +21,7 @@ class ScriptLabel const ENTRYSUBMIT = 'FML_EntrySubmit'; const KEYPRESS = 'FML_KeyPress'; const MOUSECLICK = 'FML_MouseClick'; + const MOUSECLICK2 = 'FML_MouseClick2'; const MOUSEOUT = 'FML_MouseOut'; const MOUSEOVER = 'FML_MouseOver';