fml update (1.2 final)
This commit is contained in:
		| @@ -42,12 +42,14 @@ class CheckBoxFeature extends ScriptFeature { | ||||
| 	/** | ||||
| 	 * Construct a new CheckBox Feature | ||||
| 	 * | ||||
| 	 * @param Quad  $quad  (optional) CheckBox Quad | ||||
| 	 * @param Entry $entry (optional) Hidden Entry | ||||
| 	 * @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) { | ||||
| 		$this->setQuad($quad); | ||||
| 		$this->setEntry($entry); | ||||
| 		$this->setDefault($default); | ||||
| 		$this->setEnabledDesign(CheckBoxDesign::defaultEnabledDesign()); | ||||
| 		$this->setDisabledDesign(CheckBoxDesign::defaultDisabledDesign()); | ||||
| 	} | ||||
|   | ||||
| @@ -44,10 +44,8 @@ class ControlScript extends ScriptFeature { | ||||
| 	 */ | ||||
| 	public function setControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| 		if ($control instanceof Scriptable) { | ||||
| 			$control->setScriptEvents(true); | ||||
| 		} | ||||
| 		$this->control = $control; | ||||
| 		$this->updateScriptEvents(); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -70,14 +68,31 @@ class ControlScript extends ScriptFeature { | ||||
| 	 */ | ||||
| 	public function setLabelName($labelName) { | ||||
| 		$this->labelName = $labelName; | ||||
| 		$this->updateScriptEvents(); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Enable Script Events on the Control if needed | ||||
| 	 */ | ||||
| 	protected function updateScriptEvents() { | ||||
| 		if (!$this->control) { | ||||
| 			return; | ||||
| 		} | ||||
| 		if (!ScriptLabel::isEventLabel($this->labelName)) { | ||||
| 			return; | ||||
| 		} | ||||
| 		if ($this->control instanceof Scriptable) { | ||||
| 			$this->control->setScriptEvents(true); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @see \FML\Script\Features\ScriptFeature::prepare() | ||||
| 	 */ | ||||
| 	public function prepare(Script $script) { | ||||
| 		$script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), true); | ||||
| 		$isolated = !ScriptLabel::isEventLabel($this->labelName); | ||||
| 		$script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), $isolated); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -63,7 +63,8 @@ class EntrySubmit extends ScriptFeature { | ||||
| 	 */ | ||||
| 	public function prepare(Script $script) { | ||||
| 		$script->setScriptInclude(ScriptInclude::TEXTLIB); | ||||
| 		$script->appendGenericScriptLabel(ScriptLabel::ENTRYSUBMIT, $this->getScriptText()); | ||||
| 		$controlScript = new ControlScript($this->entry, $this->getScriptText(), ScriptLabel::ENTRYSUBMIT); | ||||
| 		$controlScript->prepare($script); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -73,15 +74,12 @@ class EntrySubmit extends ScriptFeature { | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getScriptText() { | ||||
| 		$controlId  = $this->entry->getId(true); | ||||
| 		$url        = $this->buildCompatibleUrl(); | ||||
| 		$entryName  = Builder::escapeText($this->entry->getName()); | ||||
| 		$scriptText = " | ||||
| if (Event.Control.ControlId == \"{$controlId}\") { | ||||
| 	declare Entry <=> (Event.Control as CMlEntry); | ||||
| 	declare Value = TextLib::URLEncode(Entry.Value); | ||||
| 	OpenLink(\"{$url}{$entryName}=\"^Value, CMlScript::LinkType::Goto); | ||||
| }"; | ||||
| declare Value = TextLib::URLEncode(Entry.Value); | ||||
| OpenLink(\"{$url}{$entryName}=\"^Value, CMlScript::LinkType::Goto); | ||||
| "; | ||||
| 		return $scriptText; | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -8,7 +8,7 @@ use FML\Types\Scriptable; | ||||
| /** | ||||
|  * An Element for the Menu Feature | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
|   | ||||
| @@ -12,7 +12,7 @@ use FML\Script\ScriptLabel; | ||||
| /** | ||||
|  * Script Feature realising a Mechanism for browsing through Pages | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
|   | ||||
| @@ -8,7 +8,7 @@ use FML\Types\Scriptable; | ||||
| /** | ||||
|  * A Button for browsing through Pages | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ use FML\Controls\Control; | ||||
| /** | ||||
|  * A Page Control | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
|   | ||||
| @@ -11,7 +11,7 @@ use FML\Types\Scriptable; | ||||
| /** | ||||
|  * Script Feature for opening a Player Profile | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
|   | ||||
| @@ -8,7 +8,7 @@ use FML\Types\ScriptFeatureable; | ||||
| /** | ||||
|  * ManiaLink Script Feature Class | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
|   | ||||
| @@ -10,7 +10,7 @@ use FML\Types\Scriptable; | ||||
| /** | ||||
|  * Script Feature for toggling Controls | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
|   | ||||
| @@ -12,7 +12,7 @@ use FML\Types\Scriptable; | ||||
| /** | ||||
|  * Script Feature for Showing Tooltips | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
|   | ||||
| @@ -11,7 +11,7 @@ use FML\Types\Scriptable; | ||||
| /** | ||||
|  * Script Feature for playing an UI Sound | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
|   | ||||
| @@ -12,7 +12,7 @@ use FML\Script\ScriptLabel; | ||||
| /** | ||||
|  * Script Feature for creating a ValuePicker Behavior | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
| @@ -50,29 +50,6 @@ class ValuePickerFeature extends ScriptFeature { | ||||
| 		$this->setDefault($default); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the possible Values | ||||
| 	 * | ||||
| 	 * @param array $values Possible Values | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature | ||||
| 	 */ | ||||
| 	public function setValues(array $values) { | ||||
| 		$this->values = array(); | ||||
| 		foreach ($values as $value) { | ||||
| 			array_push($this->values, (string)$value); | ||||
| 		} | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the ValuePicker Label | ||||
| 	 * | ||||
| 	 * @return \FML\Controls\Label | ||||
| 	 */ | ||||
| 	public function getLabel() { | ||||
| 		return $this->label; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the ValuePicker Label | ||||
| 	 * | ||||
| @@ -89,12 +66,12 @@ class ValuePickerFeature extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the hidden Entry | ||||
| 	 * Get the ValuePicker Label | ||||
| 	 * | ||||
| 	 * @return \FML\Controls\Entry | ||||
| 	 * @return \FML\Controls\Label | ||||
| 	 */ | ||||
| 	public function getEntry() { | ||||
| 		return $this->entry; | ||||
| 	public function getLabel() { | ||||
| 		return $this->label; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| @@ -111,6 +88,54 @@ class ValuePickerFeature extends ScriptFeature { | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the hidden Entry | ||||
| 	 * | ||||
| 	 * @return \FML\Controls\Entry | ||||
| 	 */ | ||||
| 	public function getEntry() { | ||||
| 		return $this->entry; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the possible Values | ||||
| 	 * | ||||
| 	 * @param array $values Possible Values | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature | ||||
| 	 */ | ||||
| 	public function setValues(array $values) { | ||||
| 		$this->values = array(); | ||||
| 		foreach ($values as $value) { | ||||
| 			array_push($this->values, (string)$value); | ||||
| 		} | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the default Value | ||||
| 	 * | ||||
| 	 * @param string $default Default Value | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature | ||||
| 	 */ | ||||
| 	public function setDefault($default) { | ||||
| 		$this->default = (string)$default; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the default Value | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getDefault() { | ||||
| 		if ($this->default) { | ||||
| 			return $this->default; | ||||
| 		} | ||||
| 		if ($this->values) { | ||||
| 			return reset($this->values); | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @see \FML\Script\Features\ScriptFeature::prepare() | ||||
| 	 */ | ||||
| @@ -186,31 +211,6 @@ EntryId = \"{$entryId}\"; | ||||
| 		return $scriptText; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the default Value | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getDefault() { | ||||
| 		if ($this->default) { | ||||
| 			return $this->default; | ||||
| 		} | ||||
| 		if ($this->values) { | ||||
| 			return reset($this->values); | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the default Value | ||||
| 	 * | ||||
| 	 * @param string $default Default Value | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature | ||||
| 	 */ | ||||
| 	public function setDefault($default) { | ||||
| 		$this->default = (string)$default; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Script Text for Label Clicks | ||||
| 	 * | ||||
|   | ||||
		Reference in New Issue
	
	Block a user