FML Update
This commit is contained in:
		| @@ -3,20 +3,24 @@ | ||||
| namespace FML\Script; | ||||
|  | ||||
| /** | ||||
|  * Builder Class offering Methods to build ManiaScript | ||||
|  * ManiaScript Builder class | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
| abstract class Builder { | ||||
| 	/* | ||||
| 	 * Constants | ||||
| 	 */ | ||||
| 	const EMPTY_STRING = '""'; | ||||
|  | ||||
| 	/** | ||||
| 	 * Build a Label Implementation Block | ||||
| 	 * 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 | ||||
| 	 * @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) { | ||||
| @@ -28,10 +32,10 @@ abstract class Builder { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Escape dangerous Characters in the given Text | ||||
| 	 * 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 | ||||
| 	 * @param bool   $addApostrophes (optional) Whether to add apostrophes before and after the text | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public static function escapeText($text, $addApostrophes = false) { | ||||
| @@ -45,9 +49,9 @@ abstract class Builder { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Real String-Representation of the given Value | ||||
| 	 * Get the 'Real' string representation of the given value | ||||
| 	 * | ||||
| 	 * @param float $value The Float Value to convert to a ManiaScript Real | ||||
| 	 * @param float $value Float value to convert to a ManiaScript 'Real' | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public static function getReal($value) { | ||||
| @@ -60,24 +64,24 @@ abstract class Builder { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Boolean String-Representation of the given Value | ||||
| 	 * Get the 'Boolean' string representation of the given value | ||||
| 	 * | ||||
| 	 * @param bool $value The Value to convert to a ManiaScript Boolean | ||||
| 	 * @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 'True'; | ||||
| 		} | ||||
| 		return "False"; | ||||
| 		return 'False'; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the String-Representation of the given Array | ||||
| 	 * 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 | ||||
| 	 * @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) { | ||||
| @@ -87,14 +91,14 @@ abstract class Builder { | ||||
| 		foreach ($array as $key => $value) { | ||||
| 			if ($associative) { | ||||
| 				if (is_string($key)) { | ||||
| 					$arrayText .= '"' . self::escapeText($key) . '"'; | ||||
| 					$arrayText .= '"' . static::escapeText($key) . '"'; | ||||
| 				} else { | ||||
| 					$arrayText .= $key; | ||||
| 				} | ||||
| 				$arrayText .= ' => '; | ||||
| 			} | ||||
| 			if (is_string($value)) { | ||||
| 				$arrayText .= '"' . self::escapeText($value) . '"'; | ||||
| 				$arrayText .= '"' . static::escapeText($value) . '"'; | ||||
| 			} else { | ||||
| 				$arrayText .= $value; | ||||
| 			} | ||||
| @@ -108,17 +112,18 @@ abstract class Builder { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Include Command for the given File and Namespace | ||||
| 	 * Get the include command for the given file and namespace | ||||
| 	 * | ||||
| 	 * @param string $file      Include File | ||||
| 	 * @param string $namespace (optional) Include 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; | ||||
| 		} | ||||
| 		$includeText = "#Include	\"{$file}\""; | ||||
| 		$file        = static::escapeText($file, true); | ||||
| 		$includeText = "#Include	{$file}"; | ||||
| 		if ($namespace) { | ||||
| 			$includeText .= "	as {$namespace}"; | ||||
| 		} | ||||
| @@ -127,15 +132,17 @@ abstract class Builder { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Constant Command for the given Name and Value | ||||
| 	 * Get the constant command for the given name and value | ||||
| 	 * | ||||
| 	 * @param string $name  Constant Name | ||||
| 	 * @param string $value Constant Value | ||||
| 	 * @param string $name  Constant name | ||||
| 	 * @param string $value Constant value | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public static function getConstant($name, $value) { | ||||
| 		if (is_string($value)) { | ||||
| 			$value = '"' . $value . '"'; | ||||
| 			$value = static::escapeText($value, true); | ||||
| 		} else if (is_bool($value)) { | ||||
| 			$value = static::getBoolean($value); | ||||
| 		} | ||||
| 		$constantText = "#Const	{$name}	{$value}" . PHP_EOL; | ||||
| 		return $constantText; | ||||
|   | ||||
| @@ -9,7 +9,7 @@ use FML\Script\ScriptLabel; | ||||
| use FML\Types\Scriptable; | ||||
|  | ||||
| /** | ||||
|  * Script Feature for triggering a Page Action | ||||
|  * Script Feature for triggering a manialink page action | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -17,7 +17,7 @@ use FML\Types\Scriptable; | ||||
|  */ | ||||
| class ActionTrigger extends ScriptFeature { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $actionName = null; | ||||
| 	/** @var Control $control */ | ||||
| @@ -27,24 +27,30 @@ class ActionTrigger extends ScriptFeature { | ||||
| 	/** | ||||
| 	 * Construct a new Action Trigger Feature | ||||
| 	 * | ||||
| 	 * @param string  $actionName (optional) Triggered Action | ||||
| 	 * @param string  $actionName (optional) Triggered action | ||||
| 	 * @param Control $control    (optional) Action Control | ||||
| 	 * @param string  $labelName  (optional) Script Label Name | ||||
| 	 * @param string  $labelName  (optional) Script Label name | ||||
| 	 */ | ||||
| 	public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) { | ||||
| 		$this->setActionName($actionName); | ||||
| 		$this->setControl($control); | ||||
| 		$this->setLabelName($labelName); | ||||
| 		if (!is_null($actionName)) { | ||||
| 			$this->setActionName($actionName); | ||||
| 		} | ||||
| 		if (!is_null($control)) { | ||||
| 			$this->setControl($control); | ||||
| 		} | ||||
| 		if (!is_null($labelName)) { | ||||
| 			$this->setLabelName($labelName); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Action to trigger | ||||
| 	 * Set the action to trigger | ||||
| 	 * | ||||
| 	 * @param string $actionName | ||||
| 	 * @return \FML\Script\Features\ActionTrigger | ||||
| 	 * @return \FML\Script\Features\ActionTrigger|static | ||||
| 	 */ | ||||
| 	public function setActionName($actionName) { | ||||
| 		$this->actionName = $actionName; | ||||
| 		$this->actionName = (string)$actionName; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -52,7 +58,7 @@ class ActionTrigger extends ScriptFeature { | ||||
| 	 * Set the Control | ||||
| 	 * | ||||
| 	 * @param Control $control Action Control | ||||
| 	 * @return \FML\Script\Features\ActionTrigger | ||||
| 	 * @return \FML\Script\Features\ActionTrigger|static | ||||
| 	 */ | ||||
| 	public function setControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| @@ -64,13 +70,13 @@ class ActionTrigger extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Label Name | ||||
| 	 * Set the label name | ||||
| 	 * | ||||
| 	 * @param string $labelName Script Label Name | ||||
| 	 * @return \FML\Script\Features\ActionTrigger | ||||
| 	 * @param string $labelName Script Label name | ||||
| 	 * @return \FML\Script\Features\ActionTrigger|static | ||||
| 	 */ | ||||
| 	public function setLabelName($labelName) { | ||||
| 		$this->labelName = $labelName; | ||||
| 		$this->labelName = (string)$labelName; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -83,23 +89,23 @@ class ActionTrigger extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Script Text | ||||
| 	 * Get the script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getScriptText() { | ||||
| 		$actionName = Builder::escapeText($this->actionName); | ||||
| 		$actionName = Builder::escapeText($this->actionName, true); | ||||
| 		if ($this->control) { | ||||
| 			// Control event | ||||
| 			$controlId  = Builder::escapeText($this->control->getId()); | ||||
| 			$controlId  = Builder::escapeText($this->control->getId(), true); | ||||
| 			$scriptText = " | ||||
| if (Event.Control.ControlId == \"{$controlId}\") { | ||||
| 	TriggerPageAction(\"{$actionName}\"); | ||||
| if (Event.Control.ControlId == {$controlId}) { | ||||
| 	TriggerPageAction({$actionName}); | ||||
| }"; | ||||
| 		} else { | ||||
| 			// Other | ||||
| 			$scriptText = " | ||||
| TriggerPageAction(\"{$actionName}\");"; | ||||
| TriggerPageAction({$actionName});"; | ||||
| 		} | ||||
| 		return $scriptText; | ||||
| 	} | ||||
|   | ||||
| @@ -11,7 +11,7 @@ use FML\Script\ScriptInclude; | ||||
| use FML\Script\ScriptLabel; | ||||
|  | ||||
| /** | ||||
|  * Script Feature for creating a CheckBox Behavior | ||||
|  * Script Feature for creating a CheckBox behavior | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -27,7 +27,7 @@ class CheckBoxFeature extends ScriptFeature { | ||||
| 	const VAR_CHECKBOX_ENTRY_ID       = 'FML_CheckBox_EntryId'; | ||||
|  | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var Quad $quad */ | ||||
| 	protected $quad = null; | ||||
| @@ -44,12 +44,18 @@ class CheckBoxFeature extends ScriptFeature { | ||||
| 	 * | ||||
| 	 * @param Quad  $quad    (optional) CheckBox Quad | ||||
| 	 * @param Entry $entry   (optional) Hidden Entry | ||||
| 	 * @param bool  $default (optional) Default Value | ||||
| 	 * @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); | ||||
| 		if (!is_null($quad)) { | ||||
| 			$this->setQuad($quad); | ||||
| 		} | ||||
| 		if (!is_null($entry)) { | ||||
| 			$this->setEntry($entry); | ||||
| 		} | ||||
| 		if (!is_null($default)) { | ||||
| 			$this->setDefault($default); | ||||
| 		} | ||||
| 		$this->setEnabledDesign(CheckBoxDesign::defaultEnabledDesign()); | ||||
| 		$this->setDisabledDesign(CheckBoxDesign::defaultDisabledDesign()); | ||||
| 	} | ||||
| @@ -58,14 +64,10 @@ class CheckBoxFeature extends ScriptFeature { | ||||
| 	 * Set the CheckBox Quad | ||||
| 	 * | ||||
| 	 * @param Quad $quad CheckBox Quad | ||||
| 	 * @return \FML\Script\Features\CheckBoxFeature | ||||
| 	 * @return \FML\Script\Features\CheckBoxFeature|static | ||||
| 	 */ | ||||
| 	public function setQuad(Quad $quad = null) { | ||||
| 		if ($quad) { | ||||
| 			$quad->checkId(); | ||||
| 			$quad->setScriptEvents(true); | ||||
| 		} | ||||
| 		$this->quad = $quad; | ||||
| 	public function setQuad(Quad $quad) { | ||||
| 		$this->quad = $quad->checkId()->setScriptEvents(true); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -82,13 +84,10 @@ class CheckBoxFeature extends ScriptFeature { | ||||
| 	 * Set the CheckBox Entry | ||||
| 	 * | ||||
| 	 * @param Entry $entry CheckBox Entry | ||||
| 	 * @return \FML\Script\Features\CheckBoxFeature | ||||
| 	 * @return \FML\Script\Features\CheckBoxFeature|static | ||||
| 	 */ | ||||
| 	public function setEntry(Entry $entry = null) { | ||||
| 		if ($entry) { | ||||
| 			$entry->checkId(); | ||||
| 		} | ||||
| 		$this->entry = $entry; | ||||
| 	public function setEntry(Entry $entry) { | ||||
| 		$this->entry = $entry->checkId(); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -102,10 +101,10 @@ class CheckBoxFeature extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the default Value | ||||
| 	 * Set the default value | ||||
| 	 * | ||||
| 	 * @param bool $default Default Value | ||||
| 	 * @return \FML\Script\Features\CheckBoxFeature | ||||
| 	 * @param bool $default Default value | ||||
| 	 * @return \FML\Script\Features\CheckBoxFeature|static | ||||
| 	 */ | ||||
| 	public function setDefault($default) { | ||||
| 		$this->default = (bool)$default; | ||||
| @@ -113,10 +112,10 @@ class CheckBoxFeature extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Enabled Design | ||||
| 	 * Set the enabled Design | ||||
| 	 * | ||||
| 	 * @param CheckBoxDesign $checkBoxDesign Enabled CheckBox Design | ||||
| 	 * @return \FML\Script\Features\CheckBoxFeature | ||||
| 	 * @return \FML\Script\Features\CheckBoxFeature|static | ||||
| 	 */ | ||||
| 	public function setEnabledDesign(CheckBoxDesign $checkBoxDesign) { | ||||
| 		$this->enabledDesign = $checkBoxDesign; | ||||
| @@ -124,10 +123,10 @@ class CheckBoxFeature extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Disabled Design | ||||
| 	 * Set the disabled Design | ||||
| 	 * | ||||
| 	 * @param CheckBoxDesign $checkBoxDesign Disabled CheckBox Design | ||||
| 	 * @return \FML\Script\Features\CheckBoxFeature | ||||
| 	 * @return \FML\Script\Features\CheckBoxFeature|static | ||||
| 	 */ | ||||
| 	public function setDisabledDesign(CheckBoxDesign $checkBoxDesign) { | ||||
| 		$this->disabledDesign = $checkBoxDesign; | ||||
| @@ -148,12 +147,12 @@ class CheckBoxFeature extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Function Text | ||||
| 	 * Build the function text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function buildUpdateQuadDesignFunction() { | ||||
| 		$functionText = " | ||||
| 		return " | ||||
| Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) { | ||||
| 	declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True; | ||||
| 	Enabled = !Enabled; | ||||
| @@ -167,8 +166,8 @@ Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) { | ||||
| 	} else { | ||||
| 		_Quad.ImageUrl = Design; | ||||
| 	} | ||||
| 	declare " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for _Quad = \"\"; | ||||
| 	if (EntryId != \"\") { | ||||
| 	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\"; | ||||
| @@ -177,49 +176,46 @@ Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) { | ||||
| 		Entry.Value = Value; | ||||
| 	} | ||||
| }"; | ||||
| 		return $functionText; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Init Script Text | ||||
| 	 * Build the init script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function buildInitScriptText() { | ||||
| 		$quadId  = $this->getQuad()->getId(true); | ||||
| 		$entryId = ''; | ||||
| 		$quadId  = $this->getQuad()->getId(true, true); | ||||
| 		$entryId = '""'; | ||||
| 		if ($this->entry) { | ||||
| 			$entryId = $this->entry->getId(true); | ||||
| 			$entryId = $this->entry->getId(true, true); | ||||
| 		} | ||||
| 		$default              = Builder::getBoolean($this->default); | ||||
| 		$enabledDesignString  = $this->enabledDesign->getDesignString(); | ||||
| 		$disabledDesignString = $this->disabledDesign->getDesignString(); | ||||
| 		$scriptText           = " | ||||
| declare Quad_CheckBox <=> (Page.GetFirstChild(\"{$quadId}\") as CMlQuad); | ||||
| 		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); | ||||
| "; | ||||
| 		return $scriptText; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Script Text for Quad Clicks | ||||
| 	 * Build the script text for Quad clicks | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function buildClickScriptText() { | ||||
| 		$quadId     = $this->getQuad()->getId(true); | ||||
| 		$scriptText = " | ||||
| if (Event.ControlId == \"{$quadId}\") { | ||||
| 		$quadId = $this->getQuad()->getId(true, true); | ||||
| 		return " | ||||
| if (Event.ControlId == {$quadId}) { | ||||
| 	declare Quad_CheckBox <=> (Event.Control as CMlQuad); | ||||
| 	" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox); | ||||
| }"; | ||||
| 		return $scriptText; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -8,7 +8,7 @@ use FML\Script\ScriptInclude; | ||||
| use FML\Script\ScriptLabel; | ||||
|  | ||||
| /** | ||||
|  * Script Feature showing the current Time on a Label | ||||
|  * Script Feature showing the current time on a Label | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -16,7 +16,7 @@ use FML\Script\ScriptLabel; | ||||
|  */ | ||||
| class Clock extends ScriptFeature { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var Label $label */ | ||||
| 	protected $label = null; | ||||
| @@ -27,11 +27,13 @@ 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 | ||||
| 	 * @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) { | ||||
| 		$this->setLabel($label); | ||||
| 		if (!is_null($label)) { | ||||
| 			$this->setLabel($label); | ||||
| 		} | ||||
| 		$this->setShowSeconds($showSeconds); | ||||
| 		$this->setShowFullDate($showFullDate); | ||||
| 	} | ||||
| @@ -40,19 +42,18 @@ class Clock extends ScriptFeature { | ||||
| 	 * Set the Label | ||||
| 	 * | ||||
| 	 * @param Label $label Clock Label | ||||
| 	 * @return \FML\Script\Features\Clock | ||||
| 	 * @return \FML\Script\Features\Clock|static | ||||
| 	 */ | ||||
| 	public function setLabel(Label $label) { | ||||
| 		$label->checkId(); | ||||
| 		$this->label = $label; | ||||
| 		$this->label = $label->checkId(); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set whether the Seconds should be shown | ||||
| 	 * Set whether seconds should be shown | ||||
| 	 * | ||||
| 	 * @param bool $showSeconds Whether the Seconds should be shown | ||||
| 	 * @return \FML\Script\Features\Clock | ||||
| 	 * @param bool $showSeconds Whether seconds should be shown | ||||
| 	 * @return \FML\Script\Features\Clock|static | ||||
| 	 */ | ||||
| 	public function setShowSeconds($showSeconds) { | ||||
| 		$this->showSeconds = (bool)$showSeconds; | ||||
| @@ -60,10 +61,10 @@ class Clock extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set whether the Full Date should be shown | ||||
| 	 * Set whether the full date should be shown | ||||
| 	 * | ||||
| 	 * @param bool $showFullDate Whether the Full Date should be shown | ||||
| 	 * @return \FML\Script\Features\Clock | ||||
| 	 * @param bool $showFullDate Whether the full date should be shown | ||||
| 	 * @return \FML\Script\Features\Clock|static | ||||
| 	 */ | ||||
| 	public function setShowFullDate($showFullDate) { | ||||
| 		$this->showFullDate = (bool)$showFullDate; | ||||
| @@ -80,14 +81,14 @@ class Clock extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Script Text | ||||
| 	 * Get the script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getScriptText() { | ||||
| 		$controlId  = $this->label->getId(true); | ||||
| 		$controlId  = $this->label->getId(true, true); | ||||
| 		$scriptText = " | ||||
| declare ClockLabel <=> (Page.GetFirstChild(\"{$controlId}\") as CMlLabel); | ||||
| declare ClockLabel <=> (Page.GetFirstChild({$controlId}) as CMlLabel); | ||||
| declare TimeText = CurrentLocalDateText;"; | ||||
| 		if (!$this->showSeconds) { | ||||
| 			$scriptText .= " | ||||
|   | ||||
| @@ -8,7 +8,7 @@ use FML\Script\ScriptLabel; | ||||
| use FML\Types\Scriptable; | ||||
|  | ||||
| /** | ||||
|  * Script Feature for a Control-related Script | ||||
|  * Script Feature for a Control related script | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -16,7 +16,7 @@ use FML\Types\Scriptable; | ||||
|  */ | ||||
| class ControlScript extends ScriptFeature { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var Control $control */ | ||||
| 	protected $control = null; | ||||
| @@ -24,11 +24,11 @@ class ControlScript extends ScriptFeature { | ||||
| 	protected $text = null; | ||||
|  | ||||
| 	/** | ||||
| 	 * Construct a new Custom Script Text | ||||
| 	 * Construct a new Control Script | ||||
| 	 * | ||||
| 	 * @param Control $control   Event Control | ||||
| 	 * @param string  $text      Script Text | ||||
| 	 * @param string  $labelName (optional) Script Label Name | ||||
| 	 * @param string  $text      Script text | ||||
| 	 * @param string  $labelName (optional) Script Label name | ||||
| 	 */ | ||||
| 	public function __construct(Control $control, $text, $labelName = ScriptLabel::MOUSECLICK) { | ||||
| 		$this->setControl($control); | ||||
| @@ -39,21 +39,20 @@ class ControlScript extends ScriptFeature { | ||||
| 	/** | ||||
| 	 * Set the Control | ||||
| 	 * | ||||
| 	 * @param Control $control Custom Control | ||||
| 	 * @return \FML\Script\Features\ControlScript | ||||
| 	 * @param Control $control Event Control | ||||
| 	 * @return \FML\Script\Features\ControlScript|static | ||||
| 	 */ | ||||
| 	public function setControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| 		$this->control = $control; | ||||
| 		$this->control = $control->checkId(); | ||||
| 		$this->updateScriptEvents(); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Script Text | ||||
| 	 * Set the script text | ||||
| 	 * | ||||
| 	 * @param string $text Script Text | ||||
| 	 * @return \FML\Script\Features\ControlScript | ||||
| 	 * @param string $text Script text | ||||
| 	 * @return \FML\Script\Features\ControlScript|static | ||||
| 	 */ | ||||
| 	public function setText($text) { | ||||
| 		$this->text = (string)$text; | ||||
| @@ -61,13 +60,13 @@ class ControlScript extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Label Name | ||||
| 	 * Set the label name | ||||
| 	 * | ||||
| 	 * @param string $labelName Script Label Name | ||||
| 	 * @return \FML\Script\Features\ControlScript | ||||
| 	 * @param string $labelName Script Label name | ||||
| 	 * @return \FML\Script\Features\ControlScript|static | ||||
| 	 */ | ||||
| 	public function setLabelName($labelName) { | ||||
| 		$this->labelName = $labelName; | ||||
| 		$this->labelName = (string)$labelName; | ||||
| 		$this->updateScriptEvents(); | ||||
| 		return $this; | ||||
| 	} | ||||
| @@ -76,10 +75,7 @@ class ControlScript extends ScriptFeature { | ||||
| 	 * Enable Script Events on the Control if needed | ||||
| 	 */ | ||||
| 	protected function updateScriptEvents() { | ||||
| 		if (!$this->control) { | ||||
| 			return; | ||||
| 		} | ||||
| 		if (!ScriptLabel::isEventLabel($this->labelName)) { | ||||
| 		if (!$this->control || !ScriptLabel::isEventLabel($this->labelName)) { | ||||
| 			return; | ||||
| 		} | ||||
| 		if ($this->control instanceof Scriptable) { | ||||
| @@ -97,7 +93,7 @@ class ControlScript extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Script Text for the Control | ||||
| 	 * Build the script text for the Control | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| @@ -105,7 +101,6 @@ class ControlScript extends ScriptFeature { | ||||
| 		$controlId  = $this->control->getId(true); | ||||
| 		$scriptText = ''; | ||||
| 		$closeBlock = false; | ||||
|  | ||||
| 		if (ScriptLabel::isEventLabel($this->labelName)) { | ||||
| 			$scriptText .= ' | ||||
| if (Event.ControlId == "' . $controlId . '") { | ||||
| @@ -115,20 +110,16 @@ declare Control <=> Event.Control;'; | ||||
| 			$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; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -17,7 +17,7 @@ use FML\Script\ScriptLabel; | ||||
|  */ | ||||
| class EntrySubmit extends ScriptFeature { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var Entry $entry */ | ||||
| 	protected $entry = null; | ||||
| @@ -27,10 +27,12 @@ class EntrySubmit extends ScriptFeature { | ||||
| 	 * Construct a new Entry Submit Feature | ||||
| 	 * | ||||
| 	 * @param Entry  $entry (optional) Entry Control | ||||
| 	 * @param string $url   (optional) Submit Url | ||||
| 	 * @param string $url   (optional) Submit url | ||||
| 	 */ | ||||
| 	public function __construct(Entry $entry = null, $url = null) { | ||||
| 		$this->setEntry($entry); | ||||
| 		if (!is_null($entry)) { | ||||
| 			$this->setEntry($entry); | ||||
| 		} | ||||
| 		$this->setUrl($url); | ||||
| 	} | ||||
|  | ||||
| @@ -38,20 +40,18 @@ class EntrySubmit extends ScriptFeature { | ||||
| 	 * Set the Entry | ||||
| 	 * | ||||
| 	 * @param Entry $entry Entry Control | ||||
| 	 * @return \FML\Script\Features\EntrySubmit | ||||
| 	 * @return \FML\Script\Features\EntrySubmit|static | ||||
| 	 */ | ||||
| 	public function setEntry(Entry $entry) { | ||||
| 		$entry->checkId(); | ||||
| 		$entry->setScriptEvents(true); | ||||
| 		$this->entry = $entry; | ||||
| 		$this->entry = $entry->checkId()->setScriptEvents(true); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Submit Url | ||||
| 	 * Set the submit url | ||||
| 	 * | ||||
| 	 * @param string $url Submit Url | ||||
| 	 * @return \FML\Script\Features\EntrySubmit | ||||
| 	 * @param string $url Submit url | ||||
| 	 * @return \FML\Script\Features\EntrySubmit|static | ||||
| 	 */ | ||||
| 	public function setUrl($url) { | ||||
| 		$this->url = (string)$url; | ||||
| @@ -69,22 +69,22 @@ class EntrySubmit extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Script Text | ||||
| 	 * Get the script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getScriptText() { | ||||
| 		$url        = $this->buildCompatibleUrl(); | ||||
| 		$entryName  = Builder::escapeText($this->entry->getName()); | ||||
| 		$scriptText = " | ||||
| 		$url       = $this->buildCompatibleUrl(); | ||||
| 		$entryName = $this->entry->getName(); | ||||
| 		$link      = Builder::escapeText($entryName . $url . '=', true); | ||||
| 		return " | ||||
| declare Value = TextLib::URLEncode(Entry.Value); | ||||
| OpenLink(\"{$url}{$entryName}=\"^Value, CMlScript::LinkType::Goto); | ||||
| OpenLink({$link}^Value, CMlScript::LinkType::Goto); | ||||
| "; | ||||
| 		return $scriptText; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Submit Url compatible for the Entry Parameter | ||||
| 	 * Build the submit url compatible for the Entry parameter | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ use FML\Script\Script; | ||||
| use FML\Script\ScriptLabel; | ||||
|  | ||||
| /** | ||||
|  * Script Feature for triggering a Page Action on Key Press | ||||
|  * Script Feature for triggering a manialink page action on key press | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @link      http://destroflyer.mania-community.de/maniascript/keycharid_table.php | ||||
| @@ -16,7 +16,7 @@ use FML\Script\ScriptLabel; | ||||
|  */ | ||||
| class KeyAction extends ScriptFeature { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $actionName = null; | ||||
| 	protected $keyName = null; | ||||
| @@ -26,23 +26,23 @@ class KeyAction extends ScriptFeature { | ||||
| 	/** | ||||
| 	 * Construct a new Key Action Feature | ||||
| 	 * | ||||
| 	 * @param string $actionName  (optional) Triggered Action | ||||
| 	 * @param string $keyName     (optional) Key Name | ||||
| 	 * @param int    $keyCode     (optional) Key Code | ||||
| 	 * @param string $charPressed (optional) Pressed Char | ||||
| 	 * @param string $actionName (optional) Triggered action | ||||
| 	 * @param string $keyName    (optional) Key name | ||||
| 	 */ | ||||
| 	public function __construct($actionName = null, $keyName = null, $keyCode = null, $charPressed = null) { | ||||
| 		$this->setActionName($actionName); | ||||
| 		$this->setKeyName($keyName); | ||||
| 		$this->setKeyCode($keyCode); | ||||
| 		$this->setCharPressed($charPressed); | ||||
| 	public function __construct($actionName = null, $keyName = null) { | ||||
| 		if (!is_null($actionName)) { | ||||
| 			$this->setActionName($actionName); | ||||
| 		} | ||||
| 		if (!is_null($keyName)) { | ||||
| 			$this->setKeyName($keyName); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Action to trigger | ||||
| 	 * Set the action to trigger | ||||
| 	 * | ||||
| 	 * @param string $actionName Triggered Action | ||||
| 	 * @return \FML\Script\Features\KeyAction | ||||
| 	 * @param string $actionName Triggered action | ||||
| 	 * @return \FML\Script\Features\KeyAction|static | ||||
| 	 */ | ||||
| 	public function setActionName($actionName) { | ||||
| 		$this->actionName = (string)$actionName; | ||||
| @@ -50,35 +50,41 @@ class KeyAction extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Key Name for triggering the Action | ||||
| 	 * Set the key name for triggering the action | ||||
| 	 * | ||||
| 	 * @param string $keyName Key Name | ||||
| 	 * @return \FML\Script\Features\KeyAction | ||||
| 	 * @return \FML\Script\Features\KeyAction|static | ||||
| 	 */ | ||||
| 	public function setKeyName($keyName) { | ||||
| 		$this->keyName = (string)$keyName; | ||||
| 		$this->keyName     = (string)$keyName; | ||||
| 		$this->keyCode     = null; | ||||
| 		$this->charPressed = null; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Key Code for triggering the Action | ||||
| 	 * Set the key code for triggering the action | ||||
| 	 * | ||||
| 	 * @param int $keyCode Key Code | ||||
| 	 * @return \FML\Script\Features\KeyAction | ||||
| 	 * @return \FML\Script\Features\KeyAction|static | ||||
| 	 */ | ||||
| 	public function setKeyCode($keyCode) { | ||||
| 		$this->keyCode = $keyCode; | ||||
| 		$this->keyCode     = (int)$keyCode; | ||||
| 		$this->keyName     = null; | ||||
| 		$this->charPressed = null; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Char to press for triggering the Action | ||||
| 	 * Set the char to press for triggering the action | ||||
| 	 * | ||||
| 	 * @param string $charPressed Pressed Char | ||||
| 	 * @return \FML\Script\Features\KeyAction | ||||
| 	 * @param string $charPressed Pressed char | ||||
| 	 * @return \FML\Script\Features\KeyAction|static | ||||
| 	 */ | ||||
| 	public function setCharPressed($charPressed) { | ||||
| 		$this->charPressed = $charPressed; | ||||
| 		$this->charPressed = (string)$charPressed; | ||||
| 		$this->keyName     = null; | ||||
| 		$this->keyCode     = null; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -91,25 +97,28 @@ class KeyAction extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Script Text | ||||
| 	 * Get the script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getScriptText() { | ||||
| 		$actionName = Builder::escapeText($this->actionName); | ||||
| 		$key        = 'KeyName'; | ||||
| 		$value      = $this->keyName; | ||||
| 		if ($this->keyCode !== null) { | ||||
| 		$actionName = Builder::escapeText($this->actionName, true); | ||||
| 		$key        = null; | ||||
| 		$value      = null; | ||||
| 		if (!is_null($this->keyName)) { | ||||
| 			$key   = 'KeyName'; | ||||
| 			$value = $this->keyName; | ||||
| 		} else if (!is_null($this->keyCode)) { | ||||
| 			$key   = 'KeyCode'; | ||||
| 			$value = (int)$this->keyCode; | ||||
| 		} else if ($this->charPressed !== null) { | ||||
| 			$value = $this->keyCode; | ||||
| 		} else if (!is_null($this->charPressed)) { | ||||
| 			$key   = 'CharPressed'; | ||||
| 			$value = (string)$this->charPressed; | ||||
| 			$value = $this->charPressed; | ||||
| 		} | ||||
| 		$scriptText = " | ||||
| if (Event.{$key} == \"{$value}\") { | ||||
| 	TriggerPageAction(\"{$actionName}\"); | ||||
| 		$value = Builder::escapeText($value, true); | ||||
| 		return " | ||||
| if (Event.{$key} == {$value}) { | ||||
| 	TriggerPageAction({$actionName}); | ||||
| }"; | ||||
| 		return $scriptText; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -9,7 +9,7 @@ use FML\Script\ScriptLabel; | ||||
| use FML\Types\Scriptable; | ||||
|  | ||||
| /** | ||||
|  * Script Feature for opening the Map Info | ||||
|  * Script Feature for opening the map info | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -17,7 +17,7 @@ use FML\Types\Scriptable; | ||||
|  */ | ||||
| class MapInfo extends ScriptFeature { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var Control $control */ | ||||
| 	protected $control = null; | ||||
| @@ -27,7 +27,7 @@ class MapInfo extends ScriptFeature { | ||||
| 	 * Construct a new Map Info Feature | ||||
| 	 * | ||||
| 	 * @param Control $control   (optional) Map Info Control | ||||
| 	 * @param string  $labelName (optional) Script Label Name | ||||
| 	 * @param string  $labelName (optional) Script Label name | ||||
| 	 */ | ||||
| 	public function __construct(Control $control, $labelName = ScriptLabel::MOUSECLICK) { | ||||
| 		$this->setControl($control); | ||||
| @@ -38,7 +38,7 @@ class MapInfo extends ScriptFeature { | ||||
| 	 * Set the Control | ||||
| 	 * | ||||
| 	 * @param Control $control Map Info Control | ||||
| 	 * @return \FML\Script\Features\MapInfo | ||||
| 	 * @return \FML\Script\Features\MapInfo|static | ||||
| 	 */ | ||||
| 	public function setControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| @@ -50,13 +50,13 @@ class MapInfo extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Label Name | ||||
| 	 * Set the label name | ||||
| 	 * | ||||
| 	 * @param string $labelName Script Label Name | ||||
| 	 * @return \FML\Script\Features\MapInfo | ||||
| 	 * @param string $labelName Script Label name | ||||
| 	 * @return \FML\Script\Features\MapInfo|static | ||||
| 	 */ | ||||
| 	public function setLabelName($labelName) { | ||||
| 		$this->labelName = $labelName; | ||||
| 		$this->labelName = (string)$labelName; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -69,16 +69,16 @@ class MapInfo extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Script Text | ||||
| 	 * Get the script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getScriptText() { | ||||
| 		if ($this->control) { | ||||
| 			// Control event | ||||
| 			$controlId  = Builder::escapeText($this->control->getId()); | ||||
| 			$controlId  = Builder::escapeText($this->control->getId(), true); | ||||
| 			$scriptText = " | ||||
| if (Event.Control.ControlId == \"{$controlId}\") { | ||||
| if (Event.Control.ControlId == {$controlId}) { | ||||
| 	ShowCurChallengeCard(); | ||||
| }"; | ||||
| 		} else { | ||||
|   | ||||
| @@ -8,7 +8,7 @@ use FML\Script\Script; | ||||
| use FML\Script\ScriptLabel; | ||||
|  | ||||
| /** | ||||
|  * Script Feature realising a Menu showing specific Controls for the different Item Controls | ||||
|  * Script Feature realising a Menu showing specific Controls for the different items | ||||
|  * | ||||
|  * @author    steeffeen | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -21,8 +21,9 @@ class Menu extends ScriptFeature { | ||||
| 	const FUNCTION_UPDATE_MENU = 'FML_UpdateMenu'; | ||||
|  | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var MenuElement[] $elements */ | ||||
| 	protected $elements = array(); | ||||
| 	/** @var MenuElement $startElement */ | ||||
| 	protected $startElement = null; | ||||
| @@ -30,7 +31,7 @@ class Menu extends ScriptFeature { | ||||
| 	/** | ||||
| 	 * Construct a new Menu Feature | ||||
| 	 * | ||||
| 	 * @param Control $item    (optional) Item Control in the Menu Bar | ||||
| 	 * @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) { | ||||
| @@ -42,10 +43,10 @@ class Menu extends ScriptFeature { | ||||
| 	/** | ||||
| 	 * Add a new Element to the Menu | ||||
| 	 * | ||||
| 	 * @param Control $item           Item Control in the Menu Bar | ||||
| 	 * @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 \FML\Script\Features\Menu | ||||
| 	 * @return \FML\Script\Features\Menu|static | ||||
| 	 */ | ||||
| 	public function addElement(Control $item, Control $control, $isStartElement = false) { | ||||
| 		$menuElement = new MenuElement($item, $control); | ||||
| @@ -58,14 +59,16 @@ class Menu extends ScriptFeature { | ||||
| 	 * | ||||
| 	 * @param MenuElement $menuElement    Menu Element | ||||
| 	 * @param bool        $isStartElement (optional) Whether the Menu should start with this Element | ||||
| 	 * @return \FML\Script\Features\Menu | ||||
| 	 * @return \FML\Script\Features\Menu|static | ||||
| 	 */ | ||||
| 	public function appendElement(MenuElement $menuElement, $isStartElement = false) { | ||||
| 		array_push($this->elements, $menuElement); | ||||
| 		if ($isStartElement) { | ||||
| 			$this->setStartElement($menuElement); | ||||
| 		} else if (count($this->elements) > 1) { | ||||
| 			$menuElement->getControl()->setVisible(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; | ||||
| 	} | ||||
| @@ -74,7 +77,7 @@ class Menu extends ScriptFeature { | ||||
| 	 * Set the Element to start with | ||||
| 	 * | ||||
| 	 * @param MenuElement $startElement Starting Element | ||||
| 	 * @return \FML\Script\Features\Menu | ||||
| 	 * @return \FML\Script\Features\Menu|static | ||||
| 	 */ | ||||
| 	public function setStartElement(MenuElement $startElement) { | ||||
| 		$this->startElement = $startElement; | ||||
| @@ -93,9 +96,9 @@ class Menu extends ScriptFeature { | ||||
|  | ||||
| 		// OnInit | ||||
| 		if ($this->startElement) { | ||||
| 			$startControlId = $this->startElement->getControl()->getId(true); | ||||
| 			$startControlId = $this->startElement->getControl()->getId(true, true); | ||||
| 			$initScriptText = " | ||||
| {$updateFunctionName}({$elementsArrayText}, \"{$startControlId}\");"; | ||||
| {$updateFunctionName}({$elementsArrayText}, {$startControlId});"; | ||||
| 			$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); | ||||
| 		} | ||||
|  | ||||
| @@ -122,14 +125,13 @@ Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Array Text for the Elements | ||||
| 	 * Build the array text for the Elements | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getElementsArrayText() { | ||||
| 		$elements = array(); | ||||
| 		foreach ($this->elements as $element) { | ||||
| 			/** @var MenuElement $element */ | ||||
| 			$elementId            = $element->getItem()->getId(); | ||||
| 			$elements[$elementId] = $element->getControl()->getId(); | ||||
| 		} | ||||
|   | ||||
| @@ -6,7 +6,7 @@ use FML\Controls\Control; | ||||
| use FML\Types\Scriptable; | ||||
|  | ||||
| /** | ||||
|  * An Element for the Menu Feature | ||||
|  * Menu Element for the Menu Feature | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -14,7 +14,7 @@ use FML\Types\Scriptable; | ||||
|  */ | ||||
| class MenuElement { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $item = null; | ||||
| 	protected $control = null; | ||||
| @@ -22,19 +22,23 @@ class MenuElement { | ||||
| 	/** | ||||
| 	 * Create a new Menu Element | ||||
| 	 * | ||||
| 	 * @param Control $item    (optional) Item Control in the Menu Bar | ||||
| 	 * @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) { | ||||
| 		$this->setItem($item); | ||||
| 		$this->setControl($control); | ||||
| 		if (!is_null($item)) { | ||||
| 			$this->setItem($item); | ||||
| 		} | ||||
| 		if (!is_null($control)) { | ||||
| 			$this->setControl($control); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Item Control | ||||
| 	 * | ||||
| 	 * @param Control $item Item Control in the Menu Bar | ||||
| 	 * @return \FML\Script\Features\MenuElement | ||||
| 	 * @param Control $item Item Control in the Menu bar | ||||
| 	 * @return \FML\Script\Features\MenuElement|static | ||||
| 	 */ | ||||
| 	public function setItem(Control $item) { | ||||
| 		$item->checkId(); | ||||
| @@ -58,11 +62,10 @@ class MenuElement { | ||||
| 	 * Set the Menu Control | ||||
| 	 * | ||||
| 	 * @param Control $control Toggled Menu Control | ||||
| 	 * @return \FML\Script\Features\MenuElement | ||||
| 	 * @return \FML\Script\Features\MenuElement|static | ||||
| 	 */ | ||||
| 	public function setControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| 		$this->control = $control; | ||||
| 		$this->control = $control->checkId(); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -10,7 +10,7 @@ use FML\Script\ScriptInclude; | ||||
| use FML\Script\ScriptLabel; | ||||
|  | ||||
| /** | ||||
|  * Script Feature realising a Mechanism for browsing through Pages | ||||
|  * Script Feature realising a mechanism for browsing through Pages | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -24,9 +24,11 @@ class Paging extends ScriptFeature { | ||||
| 	const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage'; | ||||
|  | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var PagingPage[] $pages */ | ||||
| 	protected $pages = array(); | ||||
| 	/** @var PagingButton[] $buttons */ | ||||
| 	protected $buttons = array(); | ||||
| 	/** @var Label $label */ | ||||
| 	protected $label = null; | ||||
| @@ -39,10 +41,10 @@ class Paging extends ScriptFeature { | ||||
| 	/** | ||||
| 	 * Construct a new Paging Script Feature | ||||
| 	 * | ||||
| 	 * @param Label $label (optional) Page Number Label | ||||
| 	 * @param Label $label (optional) Page number Label | ||||
| 	 */ | ||||
| 	public function __construct(Label $label = null) { | ||||
| 		if ($label) { | ||||
| 		if (!is_null($label)) { | ||||
| 			$this->setLabel($label); | ||||
| 		} | ||||
| 	} | ||||
| @@ -51,11 +53,11 @@ class Paging extends ScriptFeature { | ||||
| 	 * Add a new Page Control | ||||
| 	 * | ||||
| 	 * @param Control $pageControl Page Control | ||||
| 	 * @param string  $pageNumber  (optional) Page Number | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * @param string  $pageNumber  (optional) Page number | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function addPage(Control $pageControl, $pageNumber = null) { | ||||
| 		if ($pageNumber === null) { | ||||
| 		if (is_null($pageNumber)) { | ||||
| 			$pageNumber = count($this->pages) + 1; | ||||
| 		} | ||||
| 		$page = new PagingPage($pageControl, $pageNumber); | ||||
| @@ -67,22 +69,24 @@ class Paging extends ScriptFeature { | ||||
| 	 * Append a Page | ||||
| 	 * | ||||
| 	 * @param PagingPage $page Paging Page | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function appendPage(PagingPage $page) { | ||||
| 		array_push($this->pages, $page); | ||||
| 		if (!in_array($page, $this->pages, true)) { | ||||
| 			array_push($this->pages, $page); | ||||
| 		} | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 \FML\Script\Features\Paging | ||||
| 	 * @param Control $buttonControl Button used for browsing | ||||
| 	 * @param int     $browseAction  (optional) Number of browsed Pages per click | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function addButton(Control $buttonControl, $browseAction = null) { | ||||
| 		if ($browseAction === null) { | ||||
| 		if (is_null($browseAction)) { | ||||
| 			$buttonCount = count($this->buttons); | ||||
| 			if ($buttonCount % 2 === 0) { | ||||
| 				$browseAction = $buttonCount / 2 + 1; | ||||
| @@ -99,40 +103,41 @@ class Paging extends ScriptFeature { | ||||
| 	 * Append a Button to browse through Pages | ||||
| 	 * | ||||
| 	 * @param PagingButton $button Paging Button | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function appendButton(PagingButton $button) { | ||||
| 		array_push($this->buttons, $button); | ||||
| 		if (!in_array($button, $this->buttons, true)) { | ||||
| 			array_push($this->buttons, $button); | ||||
| 		} | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Label showing the Page Number | ||||
| 	 * Set the Label showing the Page number | ||||
| 	 * | ||||
| 	 * @param Label $label Page Number Label | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * @param Label $label Page number Label | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function setLabel(Label $label) { | ||||
| 		$label->checkId(); | ||||
| 		$this->label = $label; | ||||
| 		$this->label = $label->checkId(); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Start Page Number | ||||
| 	 * Set the Start Page number | ||||
| 	 * | ||||
| 	 * @param int $startPageNumber Page Number to start with | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * @param int $startPageNumber Page number to start with | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function setStartPageNumber($startPageNumber) { | ||||
| 		$this->startPageNumber = (int)$startPageNumber; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set a custom Maximum Page Number for using Chunks | ||||
| 	 * Set a custom maximum Page number for using chunks | ||||
| 	 * | ||||
| 	 * @param int $maxPageNumber Custom Maximum Page Number | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * @param int $maxPageNumber Custom maximum Page number | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function setCustomMaxPageNumber($maxPageNumber) { | ||||
| 		$this->customMaxPageNumber = (int)$maxPageNumber; | ||||
| @@ -140,10 +145,10 @@ class Paging extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Action triggered when the previous Chunk is needed | ||||
| 	 * Set the action triggered when the previous chunk is needed | ||||
| 	 * | ||||
| 	 * @param string $previousChunkAction Triggered Action | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * @param string $previousChunkAction Triggered action | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function setPreviousChunkAction($previousChunkAction) { | ||||
| 		$this->previousChunkAction = (string)$previousChunkAction; | ||||
| @@ -151,10 +156,10 @@ class Paging extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Action triggered when the next Chunk is needed | ||||
| 	 * Set the action triggered when the next chunk is needed | ||||
| 	 * | ||||
| 	 * @param string $nextChunkAction Triggered Action | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * @param string $nextChunkAction Triggered action | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function setNextChunkAction($nextChunkAction) { | ||||
| 		$this->nextChunkAction = (string)$nextChunkAction; | ||||
| @@ -162,10 +167,10 @@ class Paging extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Actions triggered when another Chunk is needed | ||||
| 	 * Set the actions triggered when another chunk is needed | ||||
| 	 * | ||||
| 	 * @param string $chunkAction Triggered Action | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * @param string $chunkAction Triggered action | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function setChunkActions($chunkAction) { | ||||
| 		$this->setNextChunkAction($chunkAction); | ||||
| @@ -174,10 +179,10 @@ class Paging extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set if the Chunk Action should get the needed Page Number appended | ||||
| 	 * Set if the chunk action should get the needed Page number appended | ||||
| 	 * | ||||
| 	 * @param bool $appendPageNumber Whether to append the needed Page Number | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * @param bool $appendPageNumber Whether to append the needed Page number | ||||
| 	 * @return \FML\Script\Features\Paging|static | ||||
| 	 */ | ||||
| 	public function setChunkActionAppendsPageNumber($appendPageNumber) { | ||||
| 		$this->chunkActionAppendsPageNumber = (bool)$appendPageNumber; | ||||
| @@ -188,7 +193,7 @@ class Paging extends ScriptFeature { | ||||
| 	 * @see \FML\Script\Features\ScriptFeature::prepare() | ||||
| 	 */ | ||||
| 	public function prepare(Script $script) { | ||||
| 		if (!$this->pages) { | ||||
| 		if (empty($this->pages)) { | ||||
| 			return $this; | ||||
| 		} | ||||
| 		$script->setScriptInclude(ScriptInclude::TEXTLIB); | ||||
| @@ -204,23 +209,23 @@ class Paging extends ScriptFeature { | ||||
| 			$maxPageNumber = $maxPage->getPageNumber(); | ||||
| 		} | ||||
|  | ||||
| 		$pagingId    = $maxPage->getControl()->getId(true); | ||||
| 		$pageLabelId = ''; | ||||
| 		$pagingId    = $maxPage->getControl()->getId(true, true); | ||||
| 		$pageLabelId = '""'; | ||||
| 		if ($this->label) { | ||||
| 			$pageLabelId = $this->label->getId(true); | ||||
| 			$pageLabelId = $this->label->getId(true, true); | ||||
| 		} | ||||
| 		$pagesArrayText       = $this->getPagesArrayText(); | ||||
| 		$pageButtonsArrayText = $this->getPageButtonsArrayText(); | ||||
|  | ||||
| 		$previousChunkAction          = Builder::escapeText($this->previousChunkAction); | ||||
| 		$nextChunkAction              = Builder::escapeText($this->nextChunkAction); | ||||
| 		$previousChunkAction          = Builder::escapeText($this->previousChunkAction, true); | ||||
| 		$nextChunkAction              = Builder::escapeText($this->nextChunkAction, true); | ||||
| 		$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});"; | ||||
| {$currentPageVariable}[{$pagingId}] = {$startPageNumber}; | ||||
| {$updatePageFunction}({$pagingId}, {$pageLabelId}, 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber});"; | ||||
| 		$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); | ||||
|  | ||||
| 		// MouseClick | ||||
| @@ -228,7 +233,7 @@ declare {$currentPageVariable} for This = Integer[Text]; | ||||
| 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}); | ||||
| 	{$updatePageFunction}({$pagingId}, {$pageLabelId}, BrowseAction, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber}); | ||||
| }"; | ||||
| 		$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true); | ||||
|  | ||||
| @@ -264,7 +269,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct | ||||
| 		} | ||||
| 		TriggerPageAction(ChunkAction); | ||||
| 	} | ||||
| 	if (_PageLabelId == \"\") return; | ||||
| 	if (_PageLabelId == " . Builder::EMPTY_STRING . ") return; | ||||
| 	declare PageLabel <=> (Page.GetFirstChild(_PageLabelId) as CMlLabel); | ||||
| 	if (PageLabel == Null) return; | ||||
| 	PageLabel.Value = CurrentPage^\"/\"^_MaxPageNumber; | ||||
| @@ -282,9 +287,8 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct | ||||
| 		$minPageNumber = null; | ||||
| 		$minPage       = null; | ||||
| 		foreach ($this->pages as $page) { | ||||
| 			/** @var PagingPage $page */ | ||||
| 			$pageNumber = $page->getPageNumber(); | ||||
| 			if ($minPageNumber === null || $pageNumber < $minPageNumber) { | ||||
| 			if (is_null($minPageNumber) || $pageNumber < $minPageNumber) { | ||||
| 				$minPageNumber = $pageNumber; | ||||
| 				$minPage       = $page; | ||||
| 			} | ||||
| @@ -301,9 +305,8 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct | ||||
| 		$maxPageNumber = null; | ||||
| 		$maxPage       = null; | ||||
| 		foreach ($this->pages as $page) { | ||||
| 			/** @var PagingPage $page */ | ||||
| 			$pageNumber = $page->getPageNumber(); | ||||
| 			if ($maxPageNumber === null || $pageNumber > $maxPageNumber) { | ||||
| 			if (is_null($maxPageNumber) || $pageNumber > $maxPageNumber) { | ||||
| 				$maxPageNumber = $pageNumber; | ||||
| 				$maxPage       = $page; | ||||
| 			} | ||||
| @@ -312,34 +315,33 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Array Text for the Pages | ||||
| 	 * 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) { | ||||
| 			/** @var PagingPage $page */ | ||||
| 			$pageNumber         = $page->getPageNumber(); | ||||
| 			$pages[$pageNumber] = $page->getControl()->getId(); | ||||
| 			$pages[$page->getPageNumber()] = $page->getControl()->getId(); | ||||
| 		} | ||||
| 		return Builder::getArray($pages, true); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Array Text for the Page Buttons | ||||
| 	 * Build the array text for the Page Buttons | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getPageButtonsArrayText() { | ||||
| 		if (!$this->buttons) { | ||||
| 			return Builder::getArray(array("" => 0), true); | ||||
| 		if (empty($this->buttons)) { | ||||
| 			return Builder::getArray(array('' => 0), true); | ||||
| 		} | ||||
| 		$pageButtons = array(); | ||||
| 		foreach ($this->buttons as $pageButton) { | ||||
| 			/** @var PagingButton $pageButton */ | ||||
| 			$pageButtonId               = $pageButton->getControl()->getId(); | ||||
| 			$pageButtons[$pageButtonId] = $pageButton->getBrowseAction(); | ||||
| 			$pageButtons[$pageButton->getControl()->getId()] = $pageButton->getBrowseAction(); | ||||
| 		} | ||||
| 		return Builder::getArray($pageButtons, true); | ||||
| 	} | ||||
|   | ||||
| @@ -6,7 +6,7 @@ use FML\Controls\Control; | ||||
| use FML\Types\Scriptable; | ||||
|  | ||||
| /** | ||||
|  * A Button for browsing through Pages | ||||
|  * Paging Button for browsing through Pages | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -14,8 +14,9 @@ use FML\Types\Scriptable; | ||||
|  */ | ||||
| class PagingButton { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var Control $control */ | ||||
| 	protected $control = null; | ||||
| 	protected $browseAction = null; | ||||
|  | ||||
| @@ -26,15 +27,19 @@ class PagingButton { | ||||
| 	 * @param int     $browseAction (optional) Number of browsed Pages per Click | ||||
| 	 */ | ||||
| 	public function __construct(Control $control = null, $browseAction = null) { | ||||
| 		$this->setControl($control); | ||||
| 		$this->setBrowseAction($browseAction); | ||||
| 		if (!is_null($control)) { | ||||
| 			$this->setControl($control); | ||||
| 		} | ||||
| 		if (!is_null($browseAction)) { | ||||
| 			$this->setBrowseAction($browseAction); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Button Control | ||||
| 	 * | ||||
| 	 * @param Control $control Browse Control | ||||
| 	 * @return \FML\Script\Features\PagingButton | ||||
| 	 * @return \FML\Script\Features\PagingButton|static | ||||
| 	 */ | ||||
| 	public function setControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| @@ -55,10 +60,10 @@ class PagingButton { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Browse Action | ||||
| 	 * Set the browse action | ||||
| 	 * | ||||
| 	 * @param int $browseAction Number of browsed Pages per Click | ||||
| 	 * @return \FML\Script\Features\PagingButton | ||||
| 	 * @param int $browseAction Number of browsed Pages per click | ||||
| 	 * @return \FML\Script\Features\PagingButton|static | ||||
| 	 */ | ||||
| 	public function setBrowseAction($browseAction) { | ||||
| 		$this->browseAction = (int)$browseAction; | ||||
| @@ -66,7 +71,7 @@ class PagingButton { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Browse Action | ||||
| 	 * Get the browse action | ||||
| 	 * | ||||
| 	 * @return int | ||||
| 	 */ | ||||
|   | ||||
| @@ -5,7 +5,7 @@ namespace FML\Script\Features; | ||||
| use FML\Controls\Control; | ||||
|  | ||||
| /** | ||||
|  * A Page Control | ||||
|  * Paging Page | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -13,8 +13,9 @@ use FML\Controls\Control; | ||||
|  */ | ||||
| class PagingPage { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var Control $control */ | ||||
| 	protected $control = null; | ||||
| 	protected $number = null; | ||||
|  | ||||
| @@ -25,7 +26,9 @@ class PagingPage { | ||||
| 	 * @param int     $pageNumber (optional) Number of the Page | ||||
| 	 */ | ||||
| 	public function __construct(Control $control = null, $pageNumber = 1) { | ||||
| 		$this->setControl($control); | ||||
| 		if (!is_null($control)) { | ||||
| 			$this->setControl($control); | ||||
| 		} | ||||
| 		$this->setPageNumber($pageNumber); | ||||
| 	} | ||||
|  | ||||
| @@ -33,11 +36,10 @@ class PagingPage { | ||||
| 	 * Set the Page Control | ||||
| 	 * | ||||
| 	 * @param Control $control Page Control | ||||
| 	 * @return \FML\Script\Features\PagingPage | ||||
| 	 * @return \FML\Script\Features\PagingPage|static | ||||
| 	 */ | ||||
| 	public function setControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| 		$this->control = $control; | ||||
| 		$this->control = $control->checkId(); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -51,10 +53,10 @@ class PagingPage { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Page Number | ||||
| 	 * Set the Page number | ||||
| 	 * | ||||
| 	 * @param int $pageNumber Number of the Page | ||||
| 	 * @return \FML\Script\Features\PagingPage | ||||
| 	 * @return \FML\Script\Features\PagingPage|static | ||||
| 	 */ | ||||
| 	public function setPageNumber($pageNumber) { | ||||
| 		$this->number = (int)$pageNumber; | ||||
| @@ -62,7 +64,7 @@ class PagingPage { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Page Number | ||||
| 	 * Get the Page number | ||||
| 	 * | ||||
| 	 * @return int | ||||
| 	 */ | ||||
|   | ||||
| @@ -9,7 +9,7 @@ use FML\Script\ScriptLabel; | ||||
| use FML\Types\Scriptable; | ||||
|  | ||||
| /** | ||||
|  * Script Feature for opening a Player Profile | ||||
|  * Script Feature for opening a player profile | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -17,7 +17,7 @@ use FML\Types\Scriptable; | ||||
|  */ | ||||
| class PlayerProfile extends ScriptFeature { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $login = null; | ||||
| 	/** @var Control $control */ | ||||
| @@ -27,21 +27,23 @@ class PlayerProfile extends ScriptFeature { | ||||
| 	/** | ||||
| 	 * Construct a new Player Profile Feature | ||||
| 	 * | ||||
| 	 * @param string  $login     (optional) Player Login | ||||
| 	 * @param string  $login     (optional) Player login | ||||
| 	 * @param Control $control   (optional) Action Control | ||||
| 	 * @param string  $labelName (optional) Script Label Name | ||||
| 	 * @param string  $labelName (optional) Script Label name | ||||
| 	 */ | ||||
| 	public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) { | ||||
| 		$this->setLogin($login); | ||||
| 		$this->setControl($control); | ||||
| 		if (!is_null($control)) { | ||||
| 			$this->setControl($control); | ||||
| 		} | ||||
| 		$this->setLabelName($labelName); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Login of the Player | ||||
| 	 * Set the login of the opened player | ||||
| 	 * | ||||
| 	 * @param string $login Player Login | ||||
| 	 * @return \FML\Script\Features\PlayerProfile | ||||
| 	 * @param string $login Player login | ||||
| 	 * @return \FML\Script\Features\PlayerProfile|static | ||||
| 	 */ | ||||
| 	public function setLogin($login) { | ||||
| 		$this->login = $login; | ||||
| @@ -52,7 +54,7 @@ class PlayerProfile extends ScriptFeature { | ||||
| 	 * Set the Control | ||||
| 	 * | ||||
| 	 * @param Control $control Profile Control | ||||
| 	 * @return \FML\Script\Features\PlayerProfile | ||||
| 	 * @return \FML\Script\Features\PlayerProfile|static | ||||
| 	 */ | ||||
| 	public function setControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| @@ -64,13 +66,13 @@ class PlayerProfile extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Label Name | ||||
| 	 * Set the label name | ||||
| 	 * | ||||
| 	 * @param string $labelName Script Label Name | ||||
| 	 * @return \FML\Script\Features\PlayerProfile | ||||
| 	 * @param string $labelName Script Label name | ||||
| 	 * @return \FML\Script\Features\PlayerProfile|static | ||||
| 	 */ | ||||
| 	public function setLabelName($labelName) { | ||||
| 		$this->labelName = $labelName; | ||||
| 		$this->labelName = (string)$labelName; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -83,23 +85,23 @@ class PlayerProfile extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Script Text | ||||
| 	 * Get the script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getScriptText() { | ||||
| 		$login = Builder::escapeText($this->login); | ||||
| 		$login = Builder::escapeText($this->login, true); | ||||
| 		if ($this->control) { | ||||
| 			// Control event | ||||
| 			$controlId  = Builder::escapeText($this->control->getId()); | ||||
| 			$controlId  = Builder::escapeText($this->control->getId(), true); | ||||
| 			$scriptText = " | ||||
| if (Event.Control.ControlId == \"{$controlId}\") { | ||||
| 	ShowProfile(\"{$login}\"); | ||||
| if (Event.Control.ControlId == {$controlId}) { | ||||
| 	ShowProfile({$login}); | ||||
| }"; | ||||
| 		} else { | ||||
| 			// Other | ||||
| 			$scriptText = " | ||||
| ShowProfile(\"{$login}\");"; | ||||
| ShowProfile({$login});"; | ||||
| 		} | ||||
| 		return $scriptText; | ||||
| 	} | ||||
|   | ||||
| @@ -13,15 +13,13 @@ use FML\Types\ScriptFeatureable; | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
| abstract class ScriptFeature { | ||||
|  | ||||
| 	/** | ||||
| 	 * Collect the Script Features of the given Objects | ||||
| 	 * Collect the Script Features of the given objects | ||||
| 	 * | ||||
| 	 * @param object $scriptFeatureable ScriptFeatureable Object | ||||
| 	 * @param object $_                 (optional) Various Amount of additional Objects | ||||
| 	 * @return array | ||||
| 	 * @param ScriptFeatureable $objects (optional) Various amount of ScriptFeatureable objects | ||||
| 	 * @return ScriptFeature[] | ||||
| 	 */ | ||||
| 	public static function collect($scriptFeatureable, $_ = null) { | ||||
| 	public static function collect() { | ||||
| 		$params         = func_get_args(); | ||||
| 		$scriptFeatures = array(); | ||||
| 		foreach ($params as $object) { | ||||
| @@ -35,10 +33,10 @@ abstract class ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Prepare the given Script for Rendering by adding the needed Labels, etc. | ||||
| 	 * Prepare the given Script for rendering by adding the needed Labels, etc. | ||||
| 	 * | ||||
| 	 * @param Script $script Script to prepare | ||||
| 	 * @return \FML\Script\Features\ScriptFeature | ||||
| 	 * @return \FML\Script\Features\ScriptFeature|static | ||||
| 	 */ | ||||
| 	public abstract function prepare(Script $script); | ||||
| } | ||||
|   | ||||
| @@ -16,7 +16,7 @@ use FML\Types\Scriptable; | ||||
|  */ | ||||
| class Toggle extends ScriptFeature { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var Control $togglingControl */ | ||||
| 	protected $togglingControl = null; | ||||
| @@ -31,23 +31,28 @@ class Toggle extends ScriptFeature { | ||||
| 	 * | ||||
| 	 * @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 | ||||
| 	 * @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) { | ||||
| 		$this->setTogglingControl($togglingControl); | ||||
| 		$this->setToggledControl($toggledControl); | ||||
| 	public function __construct(Control $togglingControl = null, Control $toggledControl = null, $labelName = ScriptLabel::MOUSECLICK, | ||||
| 	                            $onlyShow = false, $onlyHide = false) { | ||||
| 		if (!is_null($togglingControl)) { | ||||
| 			$this->setTogglingControl($togglingControl); | ||||
| 		} | ||||
| 		if (!is_null($toggledControl)) { | ||||
| 			$this->setToggledControl($toggledControl); | ||||
| 		} | ||||
| 		$this->setLabelName($labelName); | ||||
| 		$this->setOnlyShow($onlyShow); | ||||
| 		$this->setOnlyHide($onlyHide); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Toggling Control | ||||
| 	 * Set the toggling Control | ||||
| 	 * | ||||
| 	 * @param Control $control Toggling Control | ||||
| 	 * @return \FML\Script\Features\Toggle | ||||
| 	 * @return \FML\Script\Features\Toggle|static | ||||
| 	 */ | ||||
| 	public function setTogglingControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| @@ -59,22 +64,21 @@ class Toggle extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Toggled Control | ||||
| 	 * Set the toggled Control | ||||
| 	 * | ||||
| 	 * @param Control $control Toggling Control | ||||
| 	 * @return \FML\Script\Features\Toggle | ||||
| 	 * @return \FML\Script\Features\Toggle|static | ||||
| 	 */ | ||||
| 	public function setToggledControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| 		$this->toggledControl = $control; | ||||
| 		$this->toggledControl = $control->checkId(); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Label Name | ||||
| 	 * Set the label name | ||||
| 	 * | ||||
| 	 * @param string $labelName Script Label Name | ||||
| 	 * @return \FML\Script\Features\Toggle | ||||
| 	 * @return \FML\Script\Features\Toggle|static | ||||
| 	 */ | ||||
| 	public function setLabelName($labelName) { | ||||
| 		$this->labelName = (string)$labelName; | ||||
| @@ -82,10 +86,10 @@ class Toggle extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set only Show | ||||
| 	 * Set to only show | ||||
| 	 * | ||||
| 	 * @param bool $onlyShow Whether it should only Show the Control but not toggle | ||||
| 	 * @return \FML\Script\Features\Toggle | ||||
| 	 * @param bool $onlyShow Whether it should only show the Control but not toggle | ||||
| 	 * @return \FML\Script\Features\Toggle|static | ||||
| 	 */ | ||||
| 	public function setOnlyShow($onlyShow) { | ||||
| 		$this->onlyShow = (bool)$onlyShow; | ||||
| @@ -93,10 +97,10 @@ class Toggle extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set only Hide | ||||
| 	 * Set to only hide | ||||
| 	 * | ||||
| 	 * @param bool $onlyHide Whether it should only Hide the Control but not toggle | ||||
| 	 * @return \FML\Script\Features\Toggle | ||||
| 	 * @param bool $onlyHide Whether it should only hide the Control but not toggle | ||||
| 	 * @return \FML\Script\Features\Toggle|static | ||||
| 	 */ | ||||
| 	public function setOnlyHide($onlyHide) { | ||||
| 		$this->onlyHide = (bool)$onlyHide; | ||||
| @@ -112,24 +116,23 @@ class Toggle extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Script Text | ||||
| 	 * Get the script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getScriptText() { | ||||
| 		$togglingControlId = $this->togglingControl->getId(true); | ||||
| 		$toggledControlId  = $this->toggledControl->getId(true); | ||||
| 		$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'; | ||||
| 		} | ||||
| 		$scriptText = " | ||||
| if (Event.Control.ControlId == \"{$togglingControlId}\") { | ||||
| 	declare ToggleControl = Page.GetFirstChild(\"{$toggledControlId}\"); | ||||
| 		return " | ||||
| if (Event.Control.ControlId == {$togglingControlId}) { | ||||
| 	declare ToggleControl = Page.GetFirstChild({$toggledControlId}); | ||||
| 	ToggleControl.Visible = {$visibility}; | ||||
| }"; | ||||
| 		return $scriptText; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -10,7 +10,7 @@ use FML\Script\ScriptLabel; | ||||
| use FML\Types\Scriptable; | ||||
|  | ||||
| /** | ||||
|  * Script Feature for Showing Tooltips | ||||
|  * Script Feature for showing Tooltips | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -18,7 +18,7 @@ use FML\Types\Scriptable; | ||||
|  */ | ||||
| class Tooltip extends ScriptFeature { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var Control $hoverControl */ | ||||
| 	protected $hoverControl = null; | ||||
| @@ -33,23 +33,29 @@ class Tooltip extends ScriptFeature { | ||||
| 	 * | ||||
| 	 * @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) The Text to display if the TooltipControl is a Label | ||||
| 	 * @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) { | ||||
| 		$this->setHoverControl($hoverControl); | ||||
| 		$this->setTooltipControl($tooltipControl); | ||||
| 		if (!is_null($hoverControl)) { | ||||
| 			$this->setHoverControl($hoverControl); | ||||
| 		} | ||||
| 		if (!is_null($tooltipControl)) { | ||||
| 			$this->setTooltipControl($tooltipControl); | ||||
| 		} | ||||
| 		$this->setStayOnClick($stayOnClick); | ||||
| 		$this->setInvert($invert); | ||||
| 		$this->setText($text); | ||||
| 		if (!is_null($text)) { | ||||
| 			$this->setText($text); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Hover Control | ||||
| 	 * | ||||
| 	 * @param Control $hoverControl Hover Control | ||||
| 	 * @return \FML\Script\Features\Tooltip | ||||
| 	 * @return \FML\Script\Features\Tooltip|static | ||||
| 	 */ | ||||
| 	public function setHoverControl(Control $hoverControl) { | ||||
| 		$hoverControl->checkId(); | ||||
| @@ -64,20 +70,18 @@ class Tooltip extends ScriptFeature { | ||||
| 	 * Set the Tooltip Control | ||||
| 	 * | ||||
| 	 * @param Control $tooltipControl Tooltip Control | ||||
| 	 * @return \FML\Script\Features\Tooltip | ||||
| 	 * @return \FML\Script\Features\Tooltip|static | ||||
| 	 */ | ||||
| 	public function setTooltipControl(Control $tooltipControl) { | ||||
| 		$tooltipControl->checkId(); | ||||
| 		$tooltipControl->setVisible(false); | ||||
| 		$this->tooltipControl = $tooltipControl; | ||||
| 		$this->tooltipControl = $tooltipControl->checkId()->setVisible(false); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set only Show | ||||
| 	 * Set to only show | ||||
| 	 * | ||||
| 	 * @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click | ||||
| 	 * @return \FML\Script\Features\Tooltip | ||||
| 	 * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click | ||||
| 	 * @return \FML\Script\Features\Tooltip|static | ||||
| 	 */ | ||||
| 	public function setStayOnClick($stayOnClick) { | ||||
| 		$this->stayOnClick = (bool)$stayOnClick; | ||||
| @@ -85,10 +89,10 @@ class Tooltip extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set only Hide | ||||
| 	 * Set to only hide | ||||
| 	 * | ||||
| 	 * @param bool $invert (optional) Whether the Visibility Toggling should be inverted | ||||
| 	 * @return \FML\Script\Features\Tooltip | ||||
| 	 * @param bool $invert (optional) Whether the visibility toggling should be inverted | ||||
| 	 * @return \FML\Script\Features\Tooltip|static | ||||
| 	 */ | ||||
| 	public function setInvert($invert) { | ||||
| 		$this->invert = (bool)$invert; | ||||
| @@ -96,13 +100,13 @@ class Tooltip extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set Text | ||||
| 	 * Set text | ||||
| 	 * | ||||
| 	 * @param string $text (optional) The Text to display if the TooltipControl is a Label | ||||
| 	 * @return \FML\Script\Features\Tooltip | ||||
| 	 * @param string $text (optional) Text to display if the TooltipControl is a Label | ||||
| 	 * @return \FML\Script\Features\Tooltip|static | ||||
| 	 */ | ||||
| 	public function setText($text) { | ||||
| 		$this->text = $text; | ||||
| 		$this->text = (string)$text; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -110,20 +114,20 @@ class Tooltip extends ScriptFeature { | ||||
| 	 * @see \FML\Script\Features\ScriptFeature::prepare() | ||||
| 	 */ | ||||
| 	public function prepare(Script $script) { | ||||
| 		$hoverControlId   = $this->hoverControl->getId(true); | ||||
| 		$tooltipControlId = $this->tooltipControl->getId(true); | ||||
| 		$hoverControlId   = $this->hoverControl->getId(true, true); | ||||
| 		$tooltipControlId = $this->tooltipControl->getId(true, true); | ||||
|  | ||||
| 		// MouseOver | ||||
| 		$visibility = ($this->invert ? 'False' : 'True'); | ||||
| 		$scriptText = " | ||||
| if (Event.Control.ControlId == \"{$hoverControlId}\") { | ||||
| 	declare TooltipControl = Page.GetFirstChild(\"{$tooltipControlId}\"); | ||||
| 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); | ||||
| 			$tooltipText = Builder::escapeText($this->text, true); | ||||
| 			$scriptText .= " | ||||
| 	declare TooltipLabel = (TooltipControl as CMlLabel); | ||||
| 	TooltipLabel.Value = \"{$tooltipText}\";"; | ||||
| 	TooltipLabel.Value = {$tooltipText};"; | ||||
| 		} | ||||
| 		$scriptText .= " | ||||
| }"; | ||||
| @@ -132,8 +136,8 @@ if (Event.Control.ControlId == \"{$hoverControlId}\") { | ||||
| 		// MouseOut | ||||
| 		$visibility = ($this->invert ? 'True' : 'False'); | ||||
| 		$scriptText = " | ||||
| if (Event.Control.ControlId == \"{$hoverControlId}\") { | ||||
| 	declare TooltipControl = Page.GetFirstChild(\"{$tooltipControlId}\");"; | ||||
| if (Event.Control.ControlId == {$hoverControlId}) { | ||||
| 	declare TooltipControl = Page.GetFirstChild({$tooltipControlId});"; | ||||
| 		if ($this->stayOnClick) { | ||||
| 			$scriptText .= " | ||||
| 	declare FML_Clicked for Event.Control = False; | ||||
| @@ -147,7 +151,7 @@ if (Event.Control.ControlId == \"{$hoverControlId}\") { | ||||
| 		// MouseClick | ||||
| 		if ($this->stayOnClick) { | ||||
| 			$scriptText = " | ||||
| if (Event.Control.ControlId == \"{$hoverControlId}\") { | ||||
| if (Event.Control.ControlId == {$hoverControlId}) { | ||||
| 	declare FML_Clicked for Event.Control = False; | ||||
| 	FML_Clicked = !FML_Clicked; | ||||
| }"; | ||||
|   | ||||
| @@ -9,7 +9,7 @@ use FML\Script\ScriptLabel; | ||||
| use FML\Types\Scriptable; | ||||
|  | ||||
| /** | ||||
|  * Script Feature for playing an UI Sound | ||||
|  * Script Feature for playing a UISound | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -50,7 +50,7 @@ class UISound extends ScriptFeature { | ||||
| 	const Warning          = 'Warning'; | ||||
|  | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $soundName = null; | ||||
| 	/** @var Control $control */ | ||||
| @@ -62,23 +62,27 @@ class UISound extends ScriptFeature { | ||||
| 	/** | ||||
| 	 * Construct a new UISound Feature | ||||
| 	 * | ||||
| 	 * @param string  $soundName (optional) Played Sound | ||||
| 	 * @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 | ||||
| 	 * @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) { | ||||
| 		$this->setSoundName($soundName); | ||||
| 		$this->setControl($control); | ||||
| 		if (!is_null($soundName)) { | ||||
| 			$this->setSoundName($soundName); | ||||
| 		} | ||||
| 		if (!is_null($control)) { | ||||
| 			$this->setControl($control); | ||||
| 		} | ||||
| 		$this->setVariant($variant); | ||||
| 		$this->setLabelName($labelName); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Sound to play | ||||
| 	 * Set the sound to play | ||||
| 	 * | ||||
| 	 * @param string $soundName Sound Name | ||||
| 	 * @return \FML\Script\Features\UISound | ||||
| 	 * @param string $soundName Sound name | ||||
| 	 * @return \FML\Script\Features\UISound|static | ||||
| 	 */ | ||||
| 	public function setSoundName($soundName) { | ||||
| 		$this->soundName = (string)$soundName; | ||||
| @@ -89,7 +93,7 @@ class UISound extends ScriptFeature { | ||||
| 	 * Set the Control | ||||
| 	 * | ||||
| 	 * @param Control $control Action Control | ||||
| 	 * @return \FML\Script\Features\UISound | ||||
| 	 * @return \FML\Script\Features\UISound|static | ||||
| 	 */ | ||||
| 	public function setControl(Control $control) { | ||||
| 		$control->checkId(); | ||||
| @@ -101,10 +105,10 @@ class UISound extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Sound Variant | ||||
| 	 * Set the sound variant | ||||
| 	 * | ||||
| 	 * @param int $variant Sound Variant | ||||
| 	 * @return \FML\Script\Features\UISound | ||||
| 	 * @param int $variant Sound variant | ||||
| 	 * @return \FML\Script\Features\UISound|static | ||||
| 	 */ | ||||
| 	public function setVariant($variant) { | ||||
| 		$this->variant = (int)$variant; | ||||
| @@ -112,10 +116,10 @@ class UISound extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Volume | ||||
| 	 * Set the volume | ||||
| 	 * | ||||
| 	 * @param float $volume Sound Volume | ||||
| 	 * @return \FML\Script\Features\UISound | ||||
| 	 * @param float $volume Sound volume | ||||
| 	 * @return \FML\Script\Features\UISound|static | ||||
| 	 */ | ||||
| 	public function setVolume($volume) { | ||||
| 		$this->volume = (float)$volume; | ||||
| @@ -123,10 +127,10 @@ class UISound extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Label Name | ||||
| 	 * Set the label name | ||||
| 	 * | ||||
| 	 * @param string $labelName Script Label Name | ||||
| 	 * @return \FML\Script\Features\UISound | ||||
| 	 * @param string $labelName Script Label name | ||||
| 	 * @return \FML\Script\Features\UISound|static | ||||
| 	 */ | ||||
| 	public function setLabelName($labelName) { | ||||
| 		$this->labelName = (string)$labelName; | ||||
| @@ -142,16 +146,16 @@ class UISound extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Script Text | ||||
| 	 * Get the script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getScriptText() { | ||||
| 		if ($this->control) { | ||||
| 			// Control event | ||||
| 			$controlId  = Builder::escapeText($this->control->getId()); | ||||
| 			$controlId  = Builder::escapeText($this->control->getId(), true); | ||||
| 			$scriptText = " | ||||
| if (Event.Control.ControlId == \"{$controlId}\") { | ||||
| if (Event.Control.ControlId == {$controlId}) { | ||||
| 	PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume}); | ||||
| }"; | ||||
| 		} else { | ||||
|   | ||||
| @@ -10,7 +10,7 @@ use FML\Script\ScriptInclude; | ||||
| use FML\Script\ScriptLabel; | ||||
|  | ||||
| /** | ||||
|  * Script Feature for creating a ValuePicker Behavior | ||||
|  * Script Feature for creating a ValuePicker behavior | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -26,13 +26,13 @@ class ValuePickerFeature extends ScriptFeature { | ||||
| 	const VAR_PICKER_ENTRY_ID          = 'FML_Picker_EntryId'; | ||||
|  | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	/** @var Label $label */ | ||||
| 	protected $label = null; | ||||
| 	/** @var Entry $entry */ | ||||
| 	protected $entry = null; | ||||
| 	protected $values = null; | ||||
| 	protected $values = array(); | ||||
| 	protected $default = null; | ||||
|  | ||||
| 	/** | ||||
| @@ -40,28 +40,32 @@ class ValuePickerFeature extends ScriptFeature { | ||||
| 	 * | ||||
| 	 * @param Label  $label   (optional) ValuePicker Label | ||||
| 	 * @param Entry  $entry   (optional) Hidden Entry | ||||
| 	 * @param array  $values  (optional) Possible Values | ||||
| 	 * @param string $default (optional) Default Value | ||||
| 	 * @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) { | ||||
| 		$this->setLabel($label); | ||||
| 		$this->setEntry($entry); | ||||
| 		$this->setValues($values); | ||||
| 		$this->setDefault($default); | ||||
| 		if (!is_null($label)) { | ||||
| 			$this->setLabel($label); | ||||
| 		} | ||||
| 		if (!is_null($entry)) { | ||||
| 			$this->setEntry($entry); | ||||
| 		} | ||||
| 		if (!empty($values)) { | ||||
| 			$this->setValues($values); | ||||
| 		} | ||||
| 		if (!is_null($default)) { | ||||
| 			$this->setDefault($default); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the ValuePicker Label | ||||
| 	 * | ||||
| 	 * @param Label $label ValuePicker Label | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature|static | ||||
| 	 */ | ||||
| 	public function setLabel(Label $label = null) { | ||||
| 		if ($label) { | ||||
| 			$label->checkId(); | ||||
| 			$label->setScriptEvents(true); | ||||
| 		} | ||||
| 		$this->label = $label; | ||||
| 	public function setLabel(Label $label) { | ||||
| 		$this->label = $label->checkId()->setScriptEvents(true); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -78,13 +82,10 @@ class ValuePickerFeature extends ScriptFeature { | ||||
| 	 * Set the hidden Entry | ||||
| 	 * | ||||
| 	 * @param Entry $entry Hidden Entry | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature|static | ||||
| 	 */ | ||||
| 	public function setEntry(Entry $entry = null) { | ||||
| 		if ($entry) { | ||||
| 			$entry->checkId(); | ||||
| 		} | ||||
| 		$this->entry = $entry; | ||||
| 	public function setEntry(Entry $entry) { | ||||
| 		$this->entry = $entry->checkId(); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -98,10 +99,10 @@ class ValuePickerFeature extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the possible Values | ||||
| 	 * Set the possible values | ||||
| 	 * | ||||
| 	 * @param array $values Possible Values | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature | ||||
| 	 * @param array $values Possible values | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature|static | ||||
| 	 */ | ||||
| 	public function setValues(array $values) { | ||||
| 		$this->values = array(); | ||||
| @@ -112,17 +113,17 @@ class ValuePickerFeature extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the default Value | ||||
| 	 * Set the default value | ||||
| 	 * | ||||
| 	 * @param string $default Default Value | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature | ||||
| 	 * @param string $default Default value | ||||
| 	 * @return \FML\Script\Features\ValuePickerFeature|static | ||||
| 	 */ | ||||
| 	public function setDefault($default) { | ||||
| 		$this->default = (string)$default; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the default Value | ||||
| 	 * Get the default value | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| @@ -130,7 +131,7 @@ class ValuePickerFeature extends ScriptFeature { | ||||
| 		if ($this->default) { | ||||
| 			return $this->default; | ||||
| 		} | ||||
| 		if ($this->values) { | ||||
| 		if (!empty($this->values)) { | ||||
| 			return reset($this->values); | ||||
| 		} | ||||
| 		return null; | ||||
| @@ -150,12 +151,12 @@ class ValuePickerFeature extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Function Text | ||||
| 	 * Build the function text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function buildUpdatePickerValueFunction() { | ||||
| 		$functionText = " | ||||
| 		return " | ||||
| Void " . self::FUNCTION_UPDATE_PICKER_VALUE . "(CMlLabel _Label) { | ||||
| 	declare " . self::VAR_PICKER_VALUES . " as Values for _Label = Text[]; | ||||
| 	declare NewValueIndex = -1; | ||||
| @@ -168,61 +169,58 @@ Void " . self::FUNCTION_UPDATE_PICKER_VALUE . "(CMlLabel _Label) { | ||||
| 			NewValueIndex = 0; | ||||
| 		} | ||||
| 	} | ||||
| 	declare NewValue = \"\"; | ||||
| 	declare NewValue = " . Builder::EMPTY_STRING . "; | ||||
| 	if (Values.existskey(NewValueIndex)) { | ||||
| 		NewValue = Values[NewValueIndex]; | ||||
| 	} else { | ||||
| 		declare " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for _Label = \"\"; | ||||
| 		declare " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for _Label = " . Builder::EMPTY_STRING . "; | ||||
| 		NewValue = Default; | ||||
| 	} | ||||
| 	_Label.Value = NewValue; | ||||
| 	declare " . self::VAR_PICKER_ENTRY_ID . " as EntryId for _Label = \"\"; | ||||
| 	if (EntryId != \"\") { | ||||
| 	declare " . self::VAR_PICKER_ENTRY_ID . " as EntryId for _Label = " . Builder::EMPTY_STRING . "; | ||||
| 	if (EntryId != " . Builder::EMPTY_STRING . ") { | ||||
| 		declare Entry <=> (Page.GetFirstChild(EntryId) as CMlEntry); | ||||
| 		Entry.Value = NewValue; | ||||
| 	} | ||||
| }"; | ||||
| 		return $functionText; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Init Script Text | ||||
| 	 * Build the init script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function buildInitScriptText() { | ||||
| 		$labelId = $this->label->getId(true); | ||||
| 		$entryId = ''; | ||||
| 		$labelId = $this->label->getId(true, true); | ||||
| 		$entryId = '""'; | ||||
| 		if ($this->entry) { | ||||
| 			$entryId = $this->entry->getId(true); | ||||
| 			$entryId = $this->entry->getId(true, true); | ||||
| 		} | ||||
| 		$values     = Builder::getArray($this->values); | ||||
| 		$default    = $this->getDefault(); | ||||
| 		$scriptText = " | ||||
| declare Label_Picker <=> (Page.GetFirstChild(\"{$labelId}\") as CMlLabel); | ||||
| 		$values  = Builder::getArray($this->values); | ||||
| 		$default = Builder::escapeText($this->getDefault(), true); | ||||
| 		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}\"; | ||||
| 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); | ||||
| "; | ||||
| 		return $scriptText; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Script Text for Label Clicks | ||||
| 	 * Build the script text for Label clicks | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function buildClickScriptText() { | ||||
| 		$labelId    = $this->label->getId(true); | ||||
| 		$scriptText = " | ||||
| if (Event.ControlId == \"{$labelId}\") { | ||||
| 		$labelId = $this->label->getId(true, true); | ||||
| 		return " | ||||
| if (Event.ControlId == {$labelId}) { | ||||
| 	declare Label_Picker <=> (Event.Control as CMlLabel); | ||||
| 	" . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker); | ||||
| }"; | ||||
| 		return $scriptText; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -21,7 +21,7 @@ class Script { | ||||
| 	const VAR_LastTick    = 'FML_LastTick'; | ||||
|  | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $tagName = 'script'; | ||||
| 	protected $features = array(); | ||||
| @@ -34,9 +34,9 @@ class Script { | ||||
| 	/** | ||||
| 	 * Set a Script Include | ||||
| 	 * | ||||
| 	 * @param string $file      Include File | ||||
| 	 * @param string $namespace Include Namespace | ||||
| 	 * @return \FML\Script\Script | ||||
| 	 * @param string $file      Include file | ||||
| 	 * @param string $namespace Include namespace | ||||
| 	 * @return \FML\Script\Script|static | ||||
| 	 */ | ||||
| 	public function setScriptInclude($file, $namespace = null) { | ||||
| 		if (is_object($file) && ($file instanceof ScriptInclude)) { | ||||
| @@ -44,17 +44,16 @@ class Script { | ||||
| 		} else { | ||||
| 			$scriptInclude = new ScriptInclude($file, $namespace); | ||||
| 		} | ||||
| 		$namespace                  = $scriptInclude->getNamespace(); | ||||
| 		$this->includes[$namespace] = $scriptInclude; | ||||
| 		$this->includes[$scriptInclude->getNamespace()] = $scriptInclude; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a Script Constant | ||||
| 	 * | ||||
| 	 * @param string $name  Constant Name | ||||
| 	 * @param string $value Constant Value | ||||
| 	 * @return \FML\Script\Script | ||||
| 	 * @param string $name  Constant name | ||||
| 	 * @param string $value Constant value | ||||
| 	 * @return \FML\Script\Script|static | ||||
| 	 */ | ||||
| 	public function addScriptConstant($name, $value = null) { | ||||
| 		if (is_object($name) && ($name instanceof ScriptConstant)) { | ||||
| @@ -62,16 +61,18 @@ class Script { | ||||
| 		} else { | ||||
| 			$scriptConstant = new ScriptConstant($name, $value); | ||||
| 		} | ||||
| 		array_push($this->constants, $scriptConstant); | ||||
| 		if (!in_array($scriptConstant, $this->constants)) { | ||||
| 			array_push($this->constants, $scriptConstant); | ||||
| 		} | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a Script Function | ||||
| 	 * | ||||
| 	 * @param string $name Function Name | ||||
| 	 * @param string $text Function Text | ||||
| 	 * @return \FML\Script\Script | ||||
| 	 * @param string $name Function name | ||||
| 	 * @param string $text Function text | ||||
| 	 * @return \FML\Script\Script|static | ||||
| 	 */ | ||||
| 	public function addScriptFunction($name, $text = null) { | ||||
| 		if (is_object($name) && ($name instanceof ScriptFunction)) { | ||||
| @@ -86,11 +87,11 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a custom Script Text | ||||
| 	 * Add a custom Script text | ||||
| 	 * | ||||
| 	 * @param string $name Label Name | ||||
| 	 * @param string $text Script Text | ||||
| 	 * @return \FML\Script\Script | ||||
| 	 * @param string $name Label name | ||||
| 	 * @param string $text Script text | ||||
| 	 * @return \FML\Script\Script|static | ||||
| 	 */ | ||||
| 	public function addCustomScriptLabel($name, $text = null) { | ||||
| 		if (is_object($name) && ($name instanceof ScriptLabel)) { | ||||
| @@ -103,12 +104,12 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Append a generic Script Text for the next Rendering | ||||
| 	 * Append a generic Script text for the next rendering | ||||
| 	 * | ||||
| 	 * @param string $name     Label Name | ||||
| 	 * @param string $text     Script Text | ||||
| 	 * @param string $name     Label name | ||||
| 	 * @param string $text     Script text | ||||
| 	 * @param bool   $isolated (optional) Whether to isolate the Label Script | ||||
| 	 * @return \FML\Script\Script | ||||
| 	 * @return \FML\Script\Script|static | ||||
| 	 */ | ||||
| 	public function appendGenericScriptLabel($name, $text = null, $isolated = false) { | ||||
| 		if (is_object($name) && ($name instanceof ScriptLabel)) { | ||||
| @@ -121,9 +122,9 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Remove all generic Script Texts | ||||
| 	 * Remove all generic Script texts | ||||
| 	 * | ||||
| 	 * @return \FML\Script\Script | ||||
| 	 * @return \FML\Script\Script|static | ||||
| 	 */ | ||||
| 	public function resetGenericScriptLabels() { | ||||
| 		$this->genericLabels = array(); | ||||
| @@ -131,13 +132,15 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Add an own Script Feature | ||||
| 	 * Add a Script Feature | ||||
| 	 * | ||||
| 	 * @param ScriptFeature $feature Script Feature | ||||
| 	 * @return \FML\Script\Script | ||||
| 	 * @return \FML\Script\Script|static | ||||
| 	 */ | ||||
| 	public function addFeature(ScriptFeature $feature) { | ||||
| 		array_push($this->features, $feature); | ||||
| 		if (!in_array($feature, $this->features, true)) { | ||||
| 			array_push($this->features, $feature); | ||||
| 		} | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| @@ -145,7 +148,7 @@ class Script { | ||||
| 	 * Load the given Script Feature | ||||
| 	 * | ||||
| 	 * @param ScriptFeature $scriptFeature Script Feature to load | ||||
| 	 * @return \FML\Script\Script | ||||
| 	 * @return \FML\Script\Script|static | ||||
| 	 */ | ||||
| 	public function loadFeature(ScriptFeature $scriptFeature) { | ||||
| 		$scriptFeature->prepare($this); | ||||
| @@ -155,8 +158,8 @@ class Script { | ||||
| 	/** | ||||
| 	 * Load the given Script Features | ||||
| 	 * | ||||
| 	 * @param array $scriptFeatures Script Features to load | ||||
| 	 * @return \FML\Script\Script | ||||
| 	 * @param ScriptFeature[] $scriptFeatures Script Features to load | ||||
| 	 * @return \FML\Script\Script|static | ||||
| 	 */ | ||||
| 	public function loadFeatures(array $scriptFeatures) { | ||||
| 		foreach ($scriptFeatures as $scriptFeature) { | ||||
| @@ -166,7 +169,7 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Check if the Script has Stuff so that it needs to be rendered | ||||
| 	 * Check if the Script has content so that it needs to be rendered | ||||
| 	 * | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| @@ -178,7 +181,7 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the complete Script Text | ||||
| 	 * Build the complete Script text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| @@ -194,9 +197,9 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Create the Script XML Tag | ||||
| 	 * Build the Script XML element | ||||
| 	 * | ||||
| 	 * @param \DOMDocument $domDocument DOMDocument for which the XML Element should be created | ||||
| 	 * @param \DOMDocument $domDocument DOMDocument for which the XML element should be created | ||||
| 	 * @return \DOMElement | ||||
| 	 */ | ||||
| 	public function render(\DOMDocument $domDocument) { | ||||
| @@ -209,7 +212,7 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Header Comment | ||||
| 	 * Get the header comment | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| @@ -224,7 +227,7 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Includes | ||||
| 	 * Get the Includes text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| @@ -234,7 +237,7 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Constants | ||||
| 	 * Get the Constants text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| @@ -244,7 +247,7 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Functions | ||||
| 	 * Get the Functions text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| @@ -254,7 +257,7 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Labels | ||||
| 	 * Get the Labels text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| @@ -265,7 +268,7 @@ class Script { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Main Function | ||||
| 	 * Get the main function text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
|   | ||||
| @@ -11,7 +11,7 @@ namespace FML\Script; | ||||
|  */ | ||||
| class ScriptConstant { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $name = null; | ||||
| 	protected $value = null; | ||||
| @@ -19,8 +19,8 @@ class ScriptConstant { | ||||
| 	/** | ||||
| 	 * Construct a new Script Constant | ||||
| 	 * | ||||
| 	 * @param string $name  (optional) Constant Name | ||||
| 	 * @param string $value (optional) Constant Value | ||||
| 	 * @param string $name  (optional) Constant name | ||||
| 	 * @param string $value (optional) Constant value | ||||
| 	 */ | ||||
| 	public function __construct($name = null, $value = null) { | ||||
| 		$this->setName($name); | ||||
| @@ -28,21 +28,21 @@ class ScriptConstant { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Name | ||||
| 	 * Set the name | ||||
| 	 * | ||||
| 	 * @param string $name Constant Name | ||||
| 	 * @return \FML\Script\ScriptConstant | ||||
| 	 * @param string $name Constant name | ||||
| 	 * @return \FML\Script\ScriptConstant|static | ||||
| 	 */ | ||||
| 	public function setName($name) { | ||||
| 		$this->name = $name; | ||||
| 		$this->name = (string)$name; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Value | ||||
| 	 * Set the value | ||||
| 	 * | ||||
| 	 * @param string $value Constant Value | ||||
| 	 * @return \FML\Script\ScriptConstant | ||||
| 	 * @param string $value Constant value | ||||
| 	 * @return \FML\Script\ScriptConstant|static | ||||
| 	 */ | ||||
| 	public function setValue($value) { | ||||
| 		$this->value = $value; | ||||
| @@ -50,12 +50,11 @@ class ScriptConstant { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Script Constant Text | ||||
| 	 * Build the Script Constant text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function __toString() { | ||||
| 		$scriptText = Builder::getConstant($this->name, $this->value); | ||||
| 		return $scriptText; | ||||
| 		return Builder::getConstant($this->name, $this->value); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -11,7 +11,7 @@ namespace FML\Script; | ||||
|  */ | ||||
| class ScriptFunction { | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $name = null; | ||||
| 	protected $text = null; | ||||
| @@ -19,8 +19,8 @@ class ScriptFunction { | ||||
| 	/** | ||||
| 	 * Construct a new Script Function | ||||
| 	 * | ||||
| 	 * @param string $name (optional) Function Name | ||||
| 	 * @param string $text (optional) Function Text | ||||
| 	 * @param string $name (optional) Function name | ||||
| 	 * @param string $text (optional) Function text | ||||
| 	 */ | ||||
| 	public function __construct($name = null, $text = null) { | ||||
| 		$this->setName($name); | ||||
| @@ -28,10 +28,10 @@ class ScriptFunction { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Name | ||||
| 	 * Set the name | ||||
| 	 * | ||||
| 	 * @param string $name Function Name | ||||
| 	 * @return \FML\Script\ScriptFunction | ||||
| 	 * @param string $name Function name | ||||
| 	 * @return \FML\Script\ScriptFunction|static | ||||
| 	 */ | ||||
| 	public function setName($name) { | ||||
| 		$this->name = (string)$name; | ||||
| @@ -39,10 +39,10 @@ class ScriptFunction { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Text | ||||
| 	 * Set the text | ||||
| 	 * | ||||
| 	 * @param string $text Function Text | ||||
| 	 * @return \FML\Script\ScriptFunction | ||||
| 	 * @param string $text Function text | ||||
| 	 * @return \FML\Script\ScriptFunction|static | ||||
| 	 */ | ||||
| 	public function setText($text) { | ||||
| 		$this->text = (string)$text; | ||||
| @@ -50,7 +50,7 @@ class ScriptFunction { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Script Function Text | ||||
| 	 * Get the Script Function text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
|   | ||||
| @@ -17,7 +17,7 @@ class ScriptInclude { | ||||
| 	const TEXTLIB = 'TextLib'; | ||||
|  | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $file = null; | ||||
| 	protected $namespace = null; | ||||
| @@ -25,8 +25,8 @@ class ScriptInclude { | ||||
| 	/** | ||||
| 	 * Construct a new Script Include | ||||
| 	 * | ||||
| 	 * @param string $file      (optional) Include File | ||||
| 	 * @param string $namespace (optional) Include Namespace | ||||
| 	 * @param string $file      (optional) Include file | ||||
| 	 * @param string $namespace (optional) Include namespace | ||||
| 	 */ | ||||
| 	public function __construct($file = null, $namespace = null) { | ||||
| 		$this->setFile($file); | ||||
| @@ -34,10 +34,10 @@ class ScriptInclude { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the File | ||||
| 	 * Set the file | ||||
| 	 * | ||||
| 	 * @param string $file Include File | ||||
| 	 * @return \FML\Script\ScriptInclude | ||||
| 	 * @param string $file Include file | ||||
| 	 * @return \FML\Script\ScriptInclude|static | ||||
| 	 */ | ||||
| 	public function setFile($file) { | ||||
| 		$this->file = (string)$file; | ||||
| @@ -45,10 +45,10 @@ class ScriptInclude { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Namespace | ||||
| 	 * Set the namespace | ||||
| 	 * | ||||
| 	 * @param string $namespace Include Namespace | ||||
| 	 * @return \FML\Script\ScriptInclude | ||||
| 	 * @param string $namespace Include namespace | ||||
| 	 * @return \FML\Script\ScriptInclude|static | ||||
| 	 */ | ||||
| 	public function setNamespace($namespace) { | ||||
| 		$this->namespace = (string)$namespace; | ||||
| @@ -56,7 +56,7 @@ class ScriptInclude { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Namespace | ||||
| 	 * Get the namespace | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| @@ -65,12 +65,11 @@ class ScriptInclude { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Script Include Text | ||||
| 	 * Build the Script Include text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function __toString() { | ||||
| 		$scriptText = Builder::getInclude($this->file, $this->namespace); | ||||
| 		return $scriptText; | ||||
| 		return Builder::getInclude($this->file, $this->namespace); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| namespace FML\Script; | ||||
|  | ||||
| /** | ||||
|  * Class representing a Part of the ManiaLink Script | ||||
|  * Class representing a part of the ManiaLink Script | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
| @@ -23,7 +23,7 @@ class ScriptLabel { | ||||
| 	const MOUSEOVER   = 'FML_MouseOver'; | ||||
|  | ||||
| 	/* | ||||
| 	 * Protected Properties | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $name = null; | ||||
| 	protected $text = null; | ||||
| @@ -32,21 +32,21 @@ class ScriptLabel { | ||||
| 	/** | ||||
| 	 * Construct a new ScriptLabel | ||||
| 	 * | ||||
| 	 * @param string $name     (optional) Label Name | ||||
| 	 * @param string $text     (optional) Script Text | ||||
| 	 * @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 = '', $isolated = false) { | ||||
| 	public function __construct($name = self::LOOP, $text = null, $isolated = false) { | ||||
| 		$this->setName($name); | ||||
| 		$this->setText($text); | ||||
| 		$this->setIsolated($isolated); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Name | ||||
| 	 * Set the name | ||||
| 	 * | ||||
| 	 * @param string $name Label Name | ||||
| 	 * @return \FML\Script\ScriptLabel | ||||
| 	 * @param string $name Label name | ||||
| 	 * @return \FML\Script\ScriptLabel|static | ||||
| 	 */ | ||||
| 	public function setName($name) { | ||||
| 		$this->name = (string)$name; | ||||
| @@ -54,10 +54,10 @@ class ScriptLabel { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Text | ||||
| 	 * Set the text | ||||
| 	 * | ||||
| 	 * @param string $text Script Text | ||||
| 	 * @return \FML\Script\ScriptLabel | ||||
| 	 * @param string $text Script text | ||||
| 	 * @return \FML\Script\ScriptLabel|static | ||||
| 	 */ | ||||
| 	public function setText($text) { | ||||
| 		$this->text = (string)$text; | ||||
| @@ -65,10 +65,10 @@ class ScriptLabel { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set Isolation | ||||
| 	 * Set isolation | ||||
| 	 * | ||||
| 	 * @param bool $isolated Whether the Code should be isolated in an own Block | ||||
| 	 * @return \FML\Script\ScriptLabel | ||||
| 	 * @param bool $isolated Whether the code should be isolated in an own block | ||||
| 	 * @return \FML\Script\ScriptLabel|static | ||||
| 	 */ | ||||
| 	public function setIsolated($isolated) { | ||||
| 		$this->isolated = (bool)$isolated; | ||||
| @@ -76,35 +76,33 @@ class ScriptLabel { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Check if the given Label is an Event Label | ||||
| 	 * Check if the given label is an event label | ||||
| 	 * | ||||
| 	 * @param string $label Label Name | ||||
| 	 * @param string $label Label name | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public static function isEventLabel($label) { | ||||
| 		$eventLabels = self::getEventLabels(); | ||||
| 		if (in_array($label, $eventLabels)) { | ||||
| 		if (in_array($label, static::getEventLabels())) { | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the possible Event Label Names | ||||
| 	 * Get the possible event label names | ||||
| 	 * | ||||
| 	 * @return array | ||||
| 	 * @return string[] | ||||
| 	 */ | ||||
| 	public static function getEventLabels() { | ||||
| 		return array(self::ENTRYSUBMIT, self::KEYPRESS, self::MOUSECLICK, self::MOUSEOUT, self::MOUSEOVER); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the full Script Label Text | ||||
| 	 * Build the full Script Label text | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function __toString() { | ||||
| 		$scriptText = Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated); | ||||
| 		return $scriptText; | ||||
| 		return Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated); | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user