FML Update

This commit is contained in:
Steffen Schröder 2014-06-21 03:18:21 +02:00
parent 816ff486ef
commit c8d599189c
107 changed files with 2484 additions and 3099 deletions

View File

@ -20,7 +20,7 @@ use FML\Types\ScriptFeatureable;
*/ */
class CheckBox implements Renderable, ScriptFeatureable { class CheckBox implements Renderable, ScriptFeatureable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $name = null; protected $name = null;
protected $feature = null; protected $feature = null;
@ -28,9 +28,9 @@ class CheckBox implements Renderable, ScriptFeatureable {
/** /**
* Create a new CheckBox Component * Create a new CheckBox Component
* *
* @param string $name (optional) CheckBox Name * @param string $name (optional) CheckBox name
* @param bool $default (optional) Default Value * @param bool $default (optional) Default value
* @param Quad $quad (optional) CheckBox Quad * @param Quad $quad (optional) CheckBox quad
*/ */
public function __construct($name = null, $default = null, Quad $quad = null) { public function __construct($name = null, $default = null, Quad $quad = null) {
$this->feature = new CheckBoxFeature(); $this->feature = new CheckBoxFeature();
@ -40,10 +40,10 @@ class CheckBox implements Renderable, ScriptFeatureable {
} }
/** /**
* Set the Name * Set the name
* *
* @param string $name CheckBox Name * @param string $name CheckBox name
* @return \FML\Components\CheckBox * @return \FML\Components\CheckBox|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -51,10 +51,10 @@ class CheckBox implements Renderable, ScriptFeatureable {
} }
/** /**
* Set the Default Value * Set the default value
* *
* @param bool $default Default Value * @param bool $default Default value
* @return \FML\Components\CheckBox * @return \FML\Components\CheckBox|static
*/ */
public function setDefault($default) { public function setDefault($default) {
$this->feature->setDefault($default); $this->feature->setDefault($default);
@ -62,28 +62,36 @@ class CheckBox implements Renderable, ScriptFeatureable {
} }
/** /**
* Set the Enabled Design * Set the enabled Design
* *
* @param string $style Style Name or Image Url * @param string $style Style name or image url
* @param string $subStyle SubStyle Name * @param string $subStyle SubStyle name
* @return \FML\Components\CheckBox * @return \FML\Components\CheckBox|static
*/ */
public function setEnabledDesign($style, $subStyle = null) { public function setEnabledDesign($style, $subStyle = null) {
if (is_object($style) && ($style instanceof CheckBoxDesign)) {
$this->feature->setEnabledDesign($style);
} else {
$checkBoxDesign = new CheckBoxDesign($style, $subStyle); $checkBoxDesign = new CheckBoxDesign($style, $subStyle);
$this->feature->setEnabledDesign($checkBoxDesign); $this->feature->setEnabledDesign($checkBoxDesign);
}
return $this; return $this;
} }
/** /**
* Set the Disabled Design * Set the disabled Design
* *
* @param string $style Style Name or Image Url * @param string $style Style name or image url
* @param string $subStyle SubStyle Name * @param string $subStyle SubStyle name
* @return \FML\Components\CheckBox * @return \FML\Components\CheckBox|static
*/ */
public function setDisabledDesign($style, $subStyle = null) { public function setDisabledDesign($style, $subStyle = null) {
if (is_object($style) && ($style instanceof CheckBoxDesign)) {
$this->feature->setDisabledDesign($style);
} else {
$checkBoxDesign = new CheckBoxDesign($style, $subStyle); $checkBoxDesign = new CheckBoxDesign($style, $subStyle);
$this->feature->setDisabledDesign($checkBoxDesign); $this->feature->setDisabledDesign($checkBoxDesign);
}
return $this; return $this;
} }
@ -91,7 +99,7 @@ class CheckBox implements Renderable, ScriptFeatureable {
* Set the CheckBox Quad * Set the CheckBox Quad
* *
* @param Quad $quad CheckBox Quad * @param Quad $quad CheckBox Quad
* @return \FML\Components\CheckBox * @return \FML\Components\CheckBox|static
*/ */
public function setQuad(Quad $quad = null) { public function setQuad(Quad $quad = null) {
$this->feature->setQuad($quad); $this->feature->setQuad($quad);
@ -143,8 +151,7 @@ class CheckBox implements Renderable, ScriptFeatureable {
*/ */
protected function buildEntry() { protected function buildEntry() {
$entry = new Entry(); $entry = new Entry();
$entry->setVisible(false); $entry->setVisible(false)->setName($this->name);
$entry->setName($this->name);
return $entry; return $entry;
} }
} }

View File

@ -19,7 +19,7 @@ use FML\Types\ScriptFeatureable;
*/ */
class ValuePicker implements Renderable, ScriptFeatureable { class ValuePicker implements Renderable, ScriptFeatureable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $name = null; protected $name = null;
protected $feature = null; protected $feature = null;
@ -27,10 +27,10 @@ class ValuePicker implements Renderable, ScriptFeatureable {
/** /**
* Create a new ValuePicker Component * Create a new ValuePicker Component
* *
* @param string $name (optional) CheckBox Name * @param string $name (optional) CheckBox name
* @param array $values (optional) Possible Values * @param array $values (optional) Possible values
* @param bool $default (optional) Default Value * @param bool $default (optional) Default value
* @param Label $label (optional) ValuePicker Label * @param Label $label (optional) ValuePicker label
*/ */
public function __construct($name = null, array $values = array(), $default = null, Label $label = null) { public function __construct($name = null, array $values = array(), $default = null, Label $label = null) {
$this->feature = new ValuePickerFeature(); $this->feature = new ValuePickerFeature();
@ -41,10 +41,10 @@ class ValuePicker implements Renderable, ScriptFeatureable {
} }
/** /**
* Set the Name * Set Name
* *
* @param string $name ValuePicker Name * @param string $name ValuePicker name
* @return \FML\Components\ValuePicker * @return \FML\Components\ValuePicker|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -52,10 +52,10 @@ class ValuePicker implements Renderable, ScriptFeatureable {
} }
/** /**
* Set the possible Values * Set the possible values
* *
* @param array $values Possible Values * @param array $values Possible values
* @return \FML\Components\ValuePicker * @return \FML\Components\ValuePicker|static
*/ */
public function setValues(array $values) { public function setValues(array $values) {
$this->feature->setValues($values); $this->feature->setValues($values);
@ -63,10 +63,10 @@ class ValuePicker implements Renderable, ScriptFeatureable {
} }
/** /**
* Set the Default Value * Set the default value
* *
* @param bool $default Default Value * @param bool $default Default value
* @return \FML\Components\ValuePicker * @return \FML\Components\ValuePicker|static
*/ */
public function setDefault($default) { public function setDefault($default) {
$this->feature->setDefault($default); $this->feature->setDefault($default);
@ -77,7 +77,7 @@ class ValuePicker implements Renderable, ScriptFeatureable {
* Set the ValuePicker Label * Set the ValuePicker Label
* *
* @param Label $label ValuePicker Label * @param Label $label ValuePicker Label
* @return \FML\Components\ValuePicker * @return \FML\Components\ValuePicker|static
*/ */
public function setLabel(Label $label = null) { public function setLabel(Label $label = null) {
$this->feature->setLabel($label); $this->feature->setLabel($label);
@ -128,8 +128,7 @@ class ValuePicker implements Renderable, ScriptFeatureable {
*/ */
protected function buildEntry() { protected function buildEntry() {
$entry = new Entry(); $entry = new Entry();
$entry->setVisible(false); $entry->setVisible(false)->setName($this->name);
$entry->setName($this->name);
return $entry; return $entry;
} }
} }

View File

@ -15,36 +15,16 @@ use FML\Types\Scriptable;
*/ */
class Audio extends Control implements Playable, Scriptable { class Audio extends Control implements Playable, Scriptable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $data = ''; protected $tagName = 'audio';
protected $dataId = ''; protected $data = null;
protected $play = 0; protected $dataId = null;
protected $looping = 0; protected $play = null;
protected $music = 0; protected $looping = true;
protected $music = null;
protected $volume = 1.; protected $volume = 1.;
protected $scriptEvents = 0; protected $scriptEvents = null;
/**
* Construct a new Audio Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'audio';
}
/**
* Create a new Audio Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Audio
*/
public static function create($id = null) {
$audio = new Audio($id);
return $audio;
}
/** /**
* @see \FML\Controls\Control::getManiaScriptClass() * @see \FML\Controls\Control::getManiaScriptClass()
@ -110,7 +90,7 @@ class Audio extends Control implements Playable, Scriptable {
} }
/** /**
* @see \FML\Control::render() * @see \FML\Types\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument); $xmlElement = parent::render($domDocument);

View File

@ -14,6 +14,7 @@ use FML\Script\Features\UISound;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
use FML\Types\Renderable; use FML\Types\Renderable;
use FML\Types\ScriptFeatureable; use FML\Types\ScriptFeatureable;
use FML\UniqueID;
/** /**
* Base Control * Base Control
@ -35,48 +36,55 @@ abstract class Control implements Renderable, ScriptFeatureable {
const LEFT = 'left'; const LEFT = 'left';
/* /*
* Static Properties * Protected properties
*/
protected static $currentIndex = 0;
/*
* Protected Properties
*/ */
protected $tagName = 'control'; protected $tagName = 'control';
protected $id = ''; protected $controlId = null;
protected $x = 0.; protected $posX = 0.;
protected $y = 0.; protected $posY = 0.;
protected $z = 0.; protected $posZ = 0.;
protected $width = -1.; protected $width = -1.;
protected $height = -1.; protected $height = -1.;
protected $hAlign = self::CENTER; protected $hAlign = self::CENTER;
protected $vAlign = self::CENTER2; protected $vAlign = self::CENTER2;
protected $scale = 1.; protected $scale = 1.;
protected $hidden = 0; protected $hidden = null;
protected $rotation = 0.;
/** @var string[] $classes */
protected $classes = array(); protected $classes = array();
/** @var ScriptFeature[] $scriptFeatures */
protected $scriptFeatures = array(); protected $scriptFeatures = array();
/** /**
* Construct a new Control * Create a new Control object
* *
* @param string $id (optional) Control Id * @param string $controlId (optional) Control id
* @return \FML\Controls\Control|static
*/ */
public function __construct($id = null) { public static function create($controlId = null) {
if ($id !== null) { return new static($controlId);
$this->setId($id); }
/**
* Construct a new Control object
*
* @param string $controlId (optional) Control id
*/
public function __construct($controlId = null) {
if (!is_null($controlId)) {
$this->setId($controlId);
} }
} }
/** /**
* Check Id for dangerous Characters and assign a unique Id if necessary * Check Id for dangerous characters and assign a new unique id if necessary
* *
* @param bool $forceNewId Whether to force setting a newly generated Id * @param bool $forceNewId (optional) Whether to force setting a newly generated id
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function checkId($forceNewId = false) { public function checkId($forceNewId = false) {
if ($forceNewId || !$this->getId()) { if ($forceNewId || !$this->getId()) {
$this->setId('FML_ID_' . self::$currentIndex); $this->setId(new UniqueID());
self::$currentIndex++;
return $this; return $this;
} }
$dangerousCharacters = array(' ', ' ', '.', '|', '-', PHP_EOL); $dangerousCharacters = array(' ', ' ', '.', '|', '-', PHP_EOL);
@ -90,93 +98,94 @@ abstract class Control implements Renderable, ScriptFeatureable {
break; break;
} }
if ($danger) { if ($danger) {
trigger_error("Please don't use special Characters in Ids, they might cause Problems! (I stripped them for You.)"); trigger_error("Please don't use special characters in ids, they might cause problems! (I stripped them for you.)");
$id = str_ireplace($dangerousCharacters, '', $this->getId()); $controlId = str_ireplace($dangerousCharacters, '', $this->getId());
$this->setId($id); $this->setId($controlId);
} }
return $this; return $this;
} }
/** /**
* Get Control Id * Get the Control id
* *
* @param bool $escaped (optional) Whether the Id should be escaped for ManiaScript * @param bool $escaped (optional) Whether the id should be escaped for ManiaScript
* @param bool $addApostrophes (optional) Whether to add apostrophes before and after the text
* @return string * @return string
*/ */
public function getId($escaped = false) { public function getId($escaped = false, $addApostrophes = false) {
if ($escaped) { if ($escaped) {
return Builder::escapeText($this->id); return Builder::escapeText($this->controlId, $addApostrophes);
} }
return $this->id; return $this->controlId;
} }
/** /**
* Set Control Id * Set Control id
* *
* @param string $id Control Id * @param string $controlId Control id
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setId($id) { public function setId($controlId) {
$this->id = (string)$id; $this->controlId = (string)$controlId;
return $this; return $this;
} }
/** /**
* Set Control Position * Set Control position
* *
* @param float $x Horizontal Position * @param float $posX Horizontal position
* @param float $y Vertical Position * @param float $posY Vertical position
* @param float $z (optional) Depth * @param float $posZ (optional) Depth
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setPosition($x, $y, $z = null) { public function setPosition($posX, $posY, $posZ = null) {
$this->setX($x); $this->setX($posX);
$this->setY($y); $this->setY($posY);
if ($z !== null) { if (!is_null($posZ)) {
$this->setZ($z); $this->setZ($posZ);
} }
return $this; return $this;
} }
/** /**
* Set X Position * Set X position
* *
* @param float $x Horizontal Position * @param float $posX Horizontal position
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setX($x) { public function setX($posX) {
$this->x = (float)$x; $this->posX = (float)$posX;
return $this; return $this;
} }
/** /**
* Set Y Position * Set Y position
* *
* @param float $y Vertical Position * @param float $posY Vertical position
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setY($y) { public function setY($posY) {
$this->y = (float)$y; $this->posY = (float)$posY;
return $this; return $this;
} }
/** /**
* Set Z Position * Set Z position
* *
* @param float $z Depth * @param float $posZ Depth
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setZ($z) { public function setZ($posZ) {
$this->z = (float)$z; $this->posZ = (float)$posZ;
return $this; return $this;
} }
/** /**
* Set Control Size * Set Control size
* *
* @param float $width Control Width * @param float $width Control width
* @param float $height Control Height * @param float $height Control height
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setSize($width, $height) { public function setSize($width, $height) {
$this->setWidth($width); $this->setWidth($width);
@ -185,10 +194,10 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Set Control Width * Set Control width
* *
* @param float $width Control Width * @param float $width Control width
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setWidth($width) { public function setWidth($width) {
$this->width = (float)$width; $this->width = (float)$width;
@ -196,10 +205,10 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Set Control Height * Set Control height
* *
* @param float $height Control Height * @param float $height Control height
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setHeight($height) { public function setHeight($height) {
$this->height = (float)$height; $this->height = (float)$height;
@ -207,9 +216,9 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Center Alignment * Center alignment
* *
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function centerAlign() { public function centerAlign() {
$this->setAlign(self::CENTER, self::CENTER2); $this->setAlign(self::CENTER, self::CENTER2);
@ -217,11 +226,11 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Set Horizontal and Vertical Alignment * Set horizontal and vertical alignment
* *
* @param string $hAlign Horizontal Alignment * @param string $hAlign Horizontal alignment
* @param string $vAlign Vertical Alignment * @param string $vAlign Vertical alignment
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setAlign($hAlign, $vAlign) { public function setAlign($hAlign, $vAlign) {
$this->setHAlign($hAlign); $this->setHAlign($hAlign);
@ -230,10 +239,10 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Set Horizontal Alignment * Set horizontal alignment
* *
* @param string $hAlign Horizontal Alignment * @param string $hAlign Horizontal alignment
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setHAlign($hAlign) { public function setHAlign($hAlign) {
$this->hAlign = (string)$hAlign; $this->hAlign = (string)$hAlign;
@ -241,10 +250,10 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Set Vertical Alignment * Set vertical alignment
* *
* @param string $vAlign Vertical Alignment * @param string $vAlign Vertical alignment
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setVAlign($vAlign) { public function setVAlign($vAlign) {
$this->vAlign = (string)$vAlign; $this->vAlign = (string)$vAlign;
@ -252,9 +261,9 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Reset Alignment * Reset alignment
* *
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function resetAlign() { public function resetAlign() {
$this->setAlign(null, null); $this->setAlign(null, null);
@ -262,10 +271,10 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Set Control Scale * Set Control scale
* *
* @param float $scale Control Scale * @param float $scale Control scale
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setScale($scale) { public function setScale($scale) {
$this->scale = (float)$scale; $this->scale = (float)$scale;
@ -273,10 +282,10 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Set Visibility * Set visibility
* *
* @param bool $visible Whether Control should be visible * @param bool $visible Whether the Control should be visible
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function setVisible($visible = true) { public function setVisible($visible = true) {
$this->hidden = ($visible ? 0 : 1); $this->hidden = ($visible ? 0 : 1);
@ -284,10 +293,21 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Add new Class Name * Set Control rotation
* *
* @param string $class Class Name * @param float $rotation
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/
public function setRotation($rotation) {
$this->rotation = (float)$rotation;
return $this;
}
/**
* Add a new class name
*
* @param string $class Class name
* @return \FML\Controls\Control|static
*/ */
public function addClass($class) { public function addClass($class) {
$class = (string)$class; $class = (string)$class;
@ -301,31 +321,37 @@ abstract class Control implements Renderable, ScriptFeatureable {
* Add a dynamic Action Trigger * Add a dynamic Action Trigger
* *
* @param string $actionName Action to trigger * @param string $actionName Action to trigger
* @param string $eventLabel (optional) Event on which the Action is triggered * @param string $eventLabel (optional) Event on which the action is triggered
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) { public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) {
if (is_object($actionName) && ($actionName instanceof ActionTrigger)) {
$this->addScriptFeature($actionName);
} else {
$actionTrigger = new ActionTrigger($actionName, $this, $eventLabel); $actionTrigger = new ActionTrigger($actionName, $this, $eventLabel);
$this->addScriptFeature($actionTrigger); $this->addScriptFeature($actionTrigger);
}
return $this; return $this;
} }
/** /**
* Add a Script Feature * Add a new Script Feature
* *
* @param ScriptFeature $scriptFeature Script Feature * @param ScriptFeature $scriptFeature Script Feature
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function addScriptFeature(ScriptFeature $scriptFeature) { public function addScriptFeature(ScriptFeature $scriptFeature) {
if (!in_array($scriptFeature, $this->scriptFeatures, true)) {
array_push($this->scriptFeatures, $scriptFeature); array_push($this->scriptFeatures, $scriptFeature);
}
return $this; return $this;
} }
/** /**
* Add a dynamic Feature opening the current Map Info * Add a dynamic Feature opening the current map info
* *
* @param string $eventLabel (optional) Event on which the Map Info will be opened * @param string $eventLabel (optional) Event on which the map info will be opened
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) { public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) {
$mapInfo = new MapInfo($this, $eventLabel); $mapInfo = new MapInfo($this, $eventLabel);
@ -334,11 +360,11 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Add a dynamic Feature to open a specific Player Profile * Add a dynamic Feature to open a specific player profile
* *
* @param string $login The Login of the Player * @param string $login Login of the player
* @param string $eventLabel (optional) Event on which the Player Profile will be opened * @param string $eventLabel (optional) Event on which the player profile will be opened
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) { public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) {
$playerProfile = new PlayerProfile($login, $this, $eventLabel); $playerProfile = new PlayerProfile($login, $this, $eventLabel);
@ -347,12 +373,12 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Add a dynamic Feature playing an UISound * Add a dynamic Feature playing a UISound
* *
* @param string $soundName UISound Name * @param string $soundName UISound name
* @param int $variant (optional) Sound Variant * @param int $variant (optional) Sound variant
* @param string $eventLabel (optional) Event on which the Sound will be played * @param string $eventLabel (optional) Event on which the sound will be played
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) { public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) {
$uiSound = new UISound($soundName, $this, $variant, $eventLabel); $uiSound = new UISound($soundName, $this, $variant, $eventLabel);
@ -364,10 +390,10 @@ abstract class Control implements Renderable, ScriptFeatureable {
* Add a dynamic Feature toggling another Control * Add a dynamic Feature toggling another Control
* *
* @param Control $toggledControl Toggled Control * @param Control $toggledControl Toggled Control
* @param string $labelName (optional) Script Label Name * @param string $labelName (optional) Script label name
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle * @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 bool $onlyHide (optional) Whether it should only hide the Control but not toggle
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function addToggleFeature(Control $toggledControl, $labelName = Scriptlabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) { public function addToggleFeature(Control $toggledControl, $labelName = Scriptlabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) {
$toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide); $toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide);
@ -379,9 +405,9 @@ abstract class Control implements Renderable, ScriptFeatureable {
* Add a dynamic Feature showing a Tooltip on hovering * Add a dynamic Feature showing a Tooltip on hovering
* *
* @param Control $tooltipControl Tooltip Control * @param Control $tooltipControl Tooltip Control
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted * @param bool $invert (optional) Whether the visibility toggling should be inverted
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) { public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) {
$tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert); $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert);
@ -393,10 +419,10 @@ abstract class Control implements Renderable, ScriptFeatureable {
* Add a dynamic Feature showing a Tooltip on hovering * Add a dynamic Feature showing a Tooltip on hovering
* *
* @param Label $tooltipControl Tooltip Control * @param Label $tooltipControl Tooltip Control
* @param string $text The Text to display on the Tooltip Label * @param string $text Text to display on the Tooltip Label
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted * @param bool $invert (optional) Whether the visibility toggling should be inverted
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function addTooltipLabelFeature(Label $tooltipControl, $text, $stayOnClick = false, $invert = false) { public function addTooltipLabelFeature(Label $tooltipControl, $text, $stayOnClick = false, $invert = false) {
$tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert, $text); $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert, $text);
@ -405,11 +431,11 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Add a Custom Control Script Text Part * Add a custom Control Script text part
* *
* @param string $scriptText Script Text * @param string $scriptText Script text
* @param string $label (optional) Script Label Name * @param string $label (optional) Script label name
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK) { public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK) {
$customText = new ControlScript($this, $scriptText, $label); $customText = new ControlScript($this, $scriptText, $label);
@ -420,7 +446,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
/** /**
* Remove all Script Features * Remove all Script Features
* *
* @return \FML\Controls\Control * @return \FML\Controls\Control|static
*/ */
public function removeScriptFeatures() { public function removeScriptFeatures() {
$this->scriptFeatures = array(); $this->scriptFeatures = array();
@ -439,19 +465,19 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName); $xmlElement = $domDocument->createElement($this->tagName);
if ($this->id) { if ($this->controlId) {
$xmlElement->setAttribute('id', $this->id); $xmlElement->setAttribute('id', $this->controlId);
} }
if ($this->x != 0. || $this->y != 0. || $this->z != 0.) { if ($this->posX || $this->posY || $this->posZ) {
$xmlElement->setAttribute('posn', "{$this->x} {$this->y} {$this->z}"); $xmlElement->setAttribute('posn', "{$this->posX} {$this->posY} {$this->posZ}");
} }
if ($this->width >= 0. || $this->height >= 0.) { if ($this->width >= 0. || $this->height >= 0.) {
$xmlElement->setAttribute('sizen', "{$this->width} {$this->height}"); $xmlElement->setAttribute('sizen', "{$this->width} {$this->height}");
} }
if ($this->hAlign) { if ($this->hAlign !== self::LEFT) {
$xmlElement->setAttribute('halign', $this->hAlign); $xmlElement->setAttribute('halign', $this->hAlign);
} }
if ($this->vAlign) { if ($this->vAlign !== self::TOP) {
$xmlElement->setAttribute('valign', $this->vAlign); $xmlElement->setAttribute('valign', $this->vAlign);
} }
if ($this->scale != 1.) { if ($this->scale != 1.) {
@ -460,6 +486,9 @@ abstract class Control implements Renderable, ScriptFeatureable {
if ($this->hidden) { if ($this->hidden) {
$xmlElement->setAttribute('hidden', $this->hidden); $xmlElement->setAttribute('hidden', $this->hidden);
} }
if ($this->rotation) {
$xmlElement->setAttribute('rot', $this->rotation);
}
if (!empty($this->classes)) { if (!empty($this->classes)) {
$classes = implode(' ', $this->classes); $classes = implode(' ', $this->classes);
$xmlElement->setAttribute('class', $classes); $xmlElement->setAttribute('class', $classes);
@ -468,7 +497,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Get the ManiaScript Class of the Control * Get the ManiaScript class of the Control
* *
* @return string * @return string
*/ */

View File

@ -18,40 +18,20 @@ use FML\Types\TextFormatable;
*/ */
class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable { class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $name = ''; protected $tagName = 'entry';
protected $name = null;
protected $default = null; protected $default = null;
protected $autoNewLine = 0; protected $autoNewLine = null;
protected $scriptEvents = 0; protected $scriptEvents = null;
protected $style = ''; protected $style = null;
protected $textColor = ''; protected $textColor = null;
protected $textSize = -1; protected $textSize = -1;
protected $focusAreaColor1 = ''; protected $focusAreaColor1 = null;
protected $focusAreaColor2 = ''; protected $focusAreaColor2 = null;
protected $autoComplete = null; protected $autoComplete = null;
/**
* Construct a new Entry Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'entry';
}
/**
* Create a new Entry Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Entry
*/
public static function create($id = null) {
$entry = new Entry($id);
return $entry;
}
/** /**
* @see \FML\Controls\Control::getManiaScriptClass() * @see \FML\Controls\Control::getManiaScriptClass()
*/ */
@ -60,7 +40,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
* Get the Entry Name * Get the Entry name
* *
* @return string * @return string
*/ */
@ -69,9 +49,9 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
* Set Entry Name * Set Entry name
* *
* @param string $name Entry Name * @param string $name Entry name
* @return \FML\Controls\Entry * @return \FML\Controls\Entry
*/ */
public function setName($name) { public function setName($name) {
@ -80,7 +60,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
* Get the Default Value * Get the default value
* *
* @return mixed * @return mixed
*/ */
@ -89,10 +69,10 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
* Set Default Value * Set default value
* *
* @param string $default Default Value * @param string $default Default value
* @return \FML\Controls\Entry * @return \FML\Controls\Entry|static
*/ */
public function setDefault($default) { public function setDefault($default) {
$this->default = $default; $this->default = $default;
@ -156,10 +136,10 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
* Set Auto Completion * Set auto completion
* *
* @param bool $autoComplete Whether the Default Value should be automatically completed based on the current Request Parameters * @param bool $autoComplete Whether the default value should be automatically completed based on the current request parameters
* @return \FML\Controls\Entry * @return \FML\Controls\Entry|static
*/ */
public function setAutoComplete($autoComplete) { public function setAutoComplete($autoComplete) {
$this->autoComplete = (bool)$autoComplete; $this->autoComplete = (bool)$autoComplete;
@ -169,8 +149,8 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/** /**
* Add a dynamic Feature submitting the Entry * Add a dynamic Feature submitting the Entry
* *
* @param string $url Submit Url * @param string $url Submit url
* @return \FML\Controls\Entry * @return \FML\Controls\Entry|static
*/ */
public function addSubmitFeature($url) { public function addSubmitFeature($url) {
$entrySubmit = new EntrySubmit($this, $url); $entrySubmit = new EntrySubmit($this, $url);
@ -186,7 +166,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
if ($this->name) { if ($this->name) {
$xmlElement->setAttribute('name', $this->name); $xmlElement->setAttribute('name', $this->name);
} }
if ($this->default !== null) { if (!is_null($this->default)) {
$xmlElement->setAttribute('default', $this->default); $xmlElement->setAttribute('default', $this->default);
} else if ($this->autoComplete) { } else if ($this->autoComplete) {
$value = null; $value = null;

View File

@ -12,30 +12,10 @@ namespace FML\Controls;
*/ */
class FileEntry extends Entry { class FileEntry extends Entry {
/* /*
* Protected Properties * Protected properties
*/ */
protected $folder = ''; protected $tagName = 'fileentry';
protected $folder = null;
/**
* Construct a new FileEntry Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'fileentry';
}
/**
* Create a new FileEntry Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\FileEntry
*/
public static function create($id = null) {
$fileEntry = new FileEntry($id);
return $fileEntry;
}
/** /**
* @see \FML\Controls\Control::getManiaScriptClass() * @see \FML\Controls\Control::getManiaScriptClass()
@ -45,10 +25,10 @@ class FileEntry extends Entry {
} }
/** /**
* Set Folder * Set the base folder
* *
* @param string $folder Base Folder * @param string $folder Base folder
* @return \FML\Controls\FileEntry * @return \FML\Controls\FileEntry|static
*/ */
public function setFolder($folder) { public function setFolder($folder) {
$this->folder = (string)$folder; $this->folder = (string)$folder;

View File

@ -17,33 +17,14 @@ use FML\Types\ScriptFeatureable;
*/ */
class Frame extends Control implements Container { class Frame extends Control implements Container {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'frame';
/** @var Renderable[] $children */
protected $children = array(); protected $children = array();
/** @var Format $format */ /** @var Format $format */
protected $format = null; protected $format = null;
/**
* Construct a new Frame Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'frame';
}
/**
* Create a new Frame Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Frame
*/
public static function create($id = null) {
$frame = new Frame($id);
return $frame;
}
/** /**
* @see \FML\Controls\Control::getManiaScriptClass() * @see \FML\Controls\Control::getManiaScriptClass()
*/ */
@ -110,7 +91,6 @@ class Frame extends Control implements Container {
$xmlElement->appendChild($formatXml); $xmlElement->appendChild($formatXml);
} }
foreach ($this->children as $child) { foreach ($this->children as $child) {
/** @var Renderable $child */
$childXmlElement = $child->render($domDocument); $childXmlElement = $child->render($domDocument);
$xmlElement->appendChild($childXmlElement); $xmlElement->appendChild($childXmlElement);
} }

View File

@ -29,39 +29,19 @@ class Frame3d extends Frame implements Scriptable {
const STYLE_Window = 'Window'; const STYLE_Window = 'Window';
/* /*
* Protected Properties * Protected properties
*/ */
protected $style3dId = ''; protected $tagName = 'frame3d';
protected $style3dId = null;
/** @var Style3d $style3d */ /** @var Style3d $style3d */
protected $style3d = null; protected $style3d = null;
protected $scriptEvents = 0; protected $scriptEvents = null;
/** /**
* Create a new Frame3d Control * Set Style3d id
* *
* @param string $id (optional) Control Id * @param string $style3dId Style3d id
* @return \FML\Controls\Frame3d * @return \FML\Controls\Frame3d|static
*/
public static function create($id = null) {
$frame3d = new Frame3d($id);
return $frame3d;
}
/**
* Construct a new Frame3d Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'frame3d';
}
/**
* Set Style3d Id
*
* @param string $style3dId Style3d Id
* @return \FML\Controls\Frame3d
*/ */
public function setStyle3dId($style3dId) { public function setStyle3dId($style3dId) {
$this->style3dId = (string)$style3dId; $this->style3dId = (string)$style3dId;
@ -72,11 +52,12 @@ class Frame3d extends Frame implements Scriptable {
/** /**
* Set Style3d * Set Style3d
* *
* @param Style3d $style3d Style3d Object * @param Style3d $style3d Style3d object
* @return \FML\Controls\Frame3d * @return \FML\Controls\Frame3d|static
*/ */
public function setStyle3d(Style3d $style3d) { public function setStyle3d(Style3d $style3d) {
$this->style3d = $style3d; $this->style3d = $style3d;
$this->style3dId = null;
return $this; return $this;
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls;
use FML\Elements\FrameModel; use FML\Elements\FrameModel;
/** /**
* Class representing an Instance of a Frame Model * Class representing an instance of a Frame Model
* (CMlFrame) * (CMlFrame)
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
@ -14,31 +14,42 @@ use FML\Elements\FrameModel;
*/ */
class FrameInstance extends Control { class FrameInstance extends Control {
/* /*
* Protected Properties * Protected properties
*/ */
protected $modelId = ''; protected $tagName = 'frameinstance';
protected $modelId = null;
/** @var FrameModel $model */ /** @var FrameModel $model */
protected $model = null; protected $model = null;
/** /**
* Construct a new Frame Instance * Create a new Frame Instance object
* *
* @param string $modelId (optional) Frame Model Id * @param string $modelId (optional) Frame Model id
* @param string $controlId (optional) Control Id * @param string $controlId (optional) Frame id
* @return \FML\Controls\FrameInstance|static
*/
public static function create($modelId = null, $controlId = null) {
return new static($modelId, $controlId);
}
/**
* Construct a new Frame Instance object
*
* @param string $modelId (optional) Frame Model id
* @param string $controlId (optional) Frame id
*/ */
public function __construct($modelId = null, $controlId = null) { public function __construct($modelId = null, $controlId = null) {
parent::__construct($controlId); parent::__construct($controlId);
$this->tagName = 'frameinstance'; if (!is_null($modelId)) {
if ($modelId !== null) {
$this->setModelId($modelId); $this->setModelId($modelId);
} }
} }
/** /**
* Set Model Id * Set Frame Model id
* *
* @param string $modelId Model Id * @param string $modelId Frame Model id
* @return \FML\Controls\FrameInstance * @return \FML\Controls\FrameInstance|static
*/ */
public function setModelId($modelId) { public function setModelId($modelId) {
$this->modelId = (string)$modelId; $this->modelId = (string)$modelId;
@ -47,15 +58,15 @@ class FrameInstance extends Control {
} }
/** /**
* Create a new Frame Instance * Set Frame Model
* *
* @param string $modelId (optional) Frame Model Id * @param FrameModel $frameModel Frame Model
* @param string $controlId (optional) Control Id * @return \FML\Controls\FrameInstance|static
* @return \FML\Controls\Frame
*/ */
public static function create($modelId = null, $controlId = null) { public function setModel(FrameModel $frameModel) {
$frameInstance = new FrameInstance($modelId, $controlId); $this->model = $frameModel;
return $frameInstance; $this->modelId = null;
return $this;
} }
/** /**
@ -65,18 +76,6 @@ class FrameInstance extends Control {
return 'CMlFrame'; return 'CMlFrame';
} }
/**
* Set Frame Model to use
*
* @param FrameModel $frameModel Frame Model
* @return \FML\Controls\FrameInstance
*/
public function setModel(FrameModel $frameModel) {
$this->model = $frameModel;
$this->modelId = '';
return $this;
}
/** /**
* @see \FML\Renderable::render() * @see \FML\Renderable::render()
*/ */

View File

@ -22,38 +22,18 @@ class Gauge extends Control implements Styleable {
const STYLE_ProgressBarSmall = 'ProgressBarSmall'; const STYLE_ProgressBarSmall = 'ProgressBarSmall';
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'gauge';
protected $ratio = 0.; protected $ratio = 0.;
protected $grading = 1.; protected $grading = 1.;
protected $color = ''; protected $color = null;
protected $rotation = 0.; protected $rotation = 0.;
protected $centered = 0; protected $centered = null;
protected $clan = 0; protected $clan = null;
protected $drawBg = 1; protected $drawBg = 1;
protected $drawBlockBg = 1; protected $drawBlockBg = 1;
protected $style = ''; protected $style = null;
/**
* Construct a new Gauge Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'gauge';
}
/**
* Create a new Gauge Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Gauge
*/
public static function create($id = null) {
$gauge = new Gauge($id);
return $gauge;
}
/** /**
* @see \FML\Controls\Control::getManiaScriptClass() * @see \FML\Controls\Control::getManiaScriptClass()
@ -63,10 +43,10 @@ class Gauge extends Control implements Styleable {
} }
/** /**
* Set Ratio * Set ratio
* *
* @param float $ratio Ratio Value * @param float $ratio Ratio value
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge|static
*/ */
public function setRatio($ratio) { public function setRatio($ratio) {
$this->ratio = (float)$ratio; $this->ratio = (float)$ratio;
@ -74,10 +54,10 @@ class Gauge extends Control implements Styleable {
} }
/** /**
* Set Grading * Set grading
* *
* @param float $grading Grading Value * @param float $grading Grading value
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge|static
*/ */
public function setGrading($grading) { public function setGrading($grading) {
$this->grading = (float)$grading; $this->grading = (float)$grading;
@ -85,10 +65,10 @@ class Gauge extends Control implements Styleable {
} }
/** /**
* Set Color * Set color
* *
* @param string $color Gauge Color * @param string $color Gauge color
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge|static
*/ */
public function setColor($color) { public function setColor($color) {
$this->color = (string)$color; $this->color = (string)$color;
@ -96,10 +76,10 @@ class Gauge extends Control implements Styleable {
} }
/** /**
* Set Rotation * Set rotation
* *
* @param float $rotation Gauge Rotation * @param float $rotation Gauge rotation
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge|static
*/ */
public function setRotation($rotation) { public function setRotation($rotation) {
$this->rotation = (float)$rotation; $this->rotation = (float)$rotation;
@ -107,10 +87,10 @@ class Gauge extends Control implements Styleable {
} }
/** /**
* Set Centered * Set centered
* *
* @param bool $centered Whether Gauge is centered * @param bool $centered Whether the Gauge is centered
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge|static
*/ */
public function setCentered($centered) { public function setCentered($centered) {
$this->centered = ($centered ? 1 : 0); $this->centered = ($centered ? 1 : 0);
@ -118,10 +98,10 @@ class Gauge extends Control implements Styleable {
} }
/** /**
* Set Clan * Set clan
* *
* @param int $clan Clan number * @param int $clan Clan number
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge|static
*/ */
public function setClan($clan) { public function setClan($clan) {
$this->clan = (int)$clan; $this->clan = (int)$clan;
@ -129,10 +109,10 @@ class Gauge extends Control implements Styleable {
} }
/** /**
* Set Draw Background * Set draw background
* *
* @param bool $drawBg Whether Gauge Background should be drawn * @param bool $drawBg Whether the Gauges background should be drawn
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge|static
*/ */
public function setDrawBg($drawBg) { public function setDrawBg($drawBg) {
$this->drawBg = ($drawBg ? 1 : 0); $this->drawBg = ($drawBg ? 1 : 0);
@ -140,10 +120,10 @@ class Gauge extends Control implements Styleable {
} }
/** /**
* Set Draw Block Background * Set draw block background
* *
* @param bool $drawBlockBg Whether Gauge Block Background should be drawn * @param bool $drawBlockBg Whether the Gauges block background should be drawn
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge|static
*/ */
public function setDrawBlockBg($drawBlockBg) { public function setDrawBlockBg($drawBlockBg) {
$this->drawBlockBg = ($drawBlockBg ? 1 : 0); $this->drawBlockBg = ($drawBlockBg ? 1 : 0);

View File

@ -20,49 +20,29 @@ use FML\Types\TextFormatable;
*/ */
class Label extends Control implements Actionable, Linkable, NewLineable, Scriptable, Styleable, TextFormatable { class Label extends Control implements Actionable, Linkable, NewLineable, Scriptable, Styleable, TextFormatable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $text = ''; protected $tagName = 'label';
protected $textId = ''; protected $text = null;
protected $textPrefix = ''; protected $textId = null;
protected $textEmboss = 0; protected $textPrefix = null;
protected $translate = 0; protected $textEmboss = null;
protected $translate = null;
protected $maxLines = -1; protected $maxLines = -1;
protected $action = ''; protected $opacity = 1.;
protected $action = null;
protected $actionKey = -1; protected $actionKey = -1;
protected $url = ''; protected $url = null;
protected $urlId = ''; protected $urlId = null;
protected $manialink = ''; protected $manialink = null;
protected $manialinkId = ''; protected $manialinkId = null;
protected $autoNewLine = 0; protected $autoNewLine = null;
protected $scriptEvents = 0; protected $scriptEvents = null;
protected $style = ''; protected $style = null;
protected $textSize = -1; protected $textSize = -1;
protected $textColor = ''; protected $textColor = null;
protected $focusAreaColor1 = ''; protected $focusAreaColor1 = null;
protected $focusAreaColor2 = ''; protected $focusAreaColor2 = null;
/**
* Construct a new Label Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'label';
$this->setZ(1);
}
/**
* Create a new Label Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Label
*/
public static function create($id = null) {
$label = new Label($id);
return $label;
}
/** /**
* @see \FML\Controls\Control::getManiaScriptClass() * @see \FML\Controls\Control::getManiaScriptClass()
@ -72,10 +52,10 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
* Set Text * Set text
* *
* @param string $text Text Value * @param string $text Text value
* @return \FML\Controls\Label * @return \FML\Controls\Label|static
*/ */
public function setText($text) { public function setText($text) {
$this->text = (string)$text; $this->text = (string)$text;
@ -83,10 +63,10 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
* Set Text Id to use from the Dico * Set text id to use from Dico
* *
* @param string $textId Text Id * @param string $textId Text id
* @return \FML\Controls\Label * @return \FML\Controls\Label|static
*/ */
public function setTextId($textId) { public function setTextId($textId) {
$this->textId = (string)$textId; $this->textId = (string)$textId;
@ -94,10 +74,10 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
* Set Text Prefix * Set text prefix
* *
* @param string $textPrefix Text Prefix * @param string $textPrefix Text prefix
* @return \FML\Controls\Label * @return \FML\Controls\Label|static
*/ */
public function setTextPrefix($textPrefix) { public function setTextPrefix($textPrefix) {
$this->textPrefix = (string)$textPrefix; $this->textPrefix = (string)$textPrefix;
@ -105,10 +85,10 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
* Set Text Emboss * Set text emboss
* *
* @param bool $textEmboss Whether Text should be embossed * @param bool $textEmboss Whether the text should be embossed
* @return \FML\Controls\Label * @return \FML\Controls\Label|static
*/ */
public function setTextEmboss($textEmboss) { public function setTextEmboss($textEmboss) {
$this->textEmboss = ($textEmboss ? 1 : 0); $this->textEmboss = ($textEmboss ? 1 : 0);
@ -116,10 +96,10 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
* Set Translate * Set translate
* *
* @param bool $translate Whether Text should be translated * @param bool $translate Whether the text should be translated
* @return \FML\Controls\Label * @return \FML\Controls\Label|static
*/ */
public function setTranslate($translate) { public function setTranslate($translate) {
$this->translate = ($translate ? 1 : 0); $this->translate = ($translate ? 1 : 0);
@ -127,10 +107,10 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
* Set Max Lines Count * Set max lines count
* *
* @param int $maxLines Max Lines Count * @param int $maxLines Max lines count
* @return \FML\Controls\Label * @return \FML\Controls\Label|static
*/ */
public function setMaxLines($maxLines) { public function setMaxLines($maxLines) {
$this->maxLines = (int)$maxLines; $this->maxLines = (int)$maxLines;
@ -249,11 +229,11 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
* Add a dynamic Feature showing the current Time * Add a dynamic Feature showing the current time
* *
* @param bool $showSeconds (optional) Whether the Seconds should be shown * @param bool $showSeconds (optional) Whether the seconds should be shown
* @param bool $showFullDate (optional) Whether the Date should be shown * @param bool $showFullDate (optional) Whether the date should be shown
* @return \FML\Controls\Label * @return \FML\Controls\Label|static
*/ */
public function addClockFeature($showSeconds = true, $showFullDate = false) { public function addClockFeature($showSeconds = true, $showFullDate = false) {
$clock = new Clock($this, $showSeconds, $showFullDate); $clock = new Clock($this, $showSeconds, $showFullDate);
@ -262,7 +242,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
* @see \FML\Control::render() * @see \FML\Types\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument); $xmlElement = parent::render($domDocument);
@ -284,6 +264,9 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
if ($this->maxLines >= 0) { if ($this->maxLines >= 0) {
$xmlElement->setAttribute('maxlines', $this->maxLines); $xmlElement->setAttribute('maxlines', $this->maxLines);
} }
if ($this->opacity != 1.) {
$xmlElement->setAttribute('opacity', $this->opacity);
}
if (strlen($this->action) > 0) { if (strlen($this->action) > 0) {
$xmlElement->setAttribute('action', $this->action); $xmlElement->setAttribute('action', $this->action);
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Labels;
use FML\Controls\Label; use FML\Controls\Label;
/** /**
* Label Class for Button Styles * Label class for button styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -33,24 +33,4 @@ class Label_Button extends Label {
const STYLE_CardButtonSmallXXXL = 'CardButtonSmallXXXL'; const STYLE_CardButtonSmallXXXL = 'CardButtonSmallXXXL';
const STYLE_CardMain_Quit = 'CardMain_Quit'; const STYLE_CardMain_Quit = 'CardMain_Quit';
const STYLE_CardMain_Tool = 'CardMain_Tool'; const STYLE_CardMain_Tool = 'CardMain_Tool';
/**
* Create a new Label_Button Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Labels\Label_Button
*/
public static function create($id = null) {
$labelButton = new Label_Button($id);
return $labelButton;
}
/**
* Construct a new Label_Button Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Labels;
use FML\Controls\Label; use FML\Controls\Label;
/** /**
* Label Class for Text Styles * Label class for text styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -94,24 +94,4 @@ class Label_Text extends Label {
const STYLE_UiDriving_BgBottom = 'UiDriving_BgBottom'; const STYLE_UiDriving_BgBottom = 'UiDriving_BgBottom';
const STYLE_UiDriving_BgCard = 'UiDriving_BgCard'; const STYLE_UiDriving_BgCard = 'UiDriving_BgCard';
const STYLE_UiDriving_BgCenter = 'UiDriving_BgCenter'; const STYLE_UiDriving_BgCenter = 'UiDriving_BgCenter';
/**
* Create a new Label_Text Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Labels\Label_Text
*/
public static function create($id = null) {
$labelText = new Label_Text($id);
return $labelText;
}
/**
* Construct a new Label_Text Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
}
} }

View File

@ -20,47 +20,26 @@ use FML\Types\SubStyleable;
*/ */
class Quad extends Control implements Actionable, BgColorable, Linkable, Scriptable, Styleable, SubStyleable { class Quad extends Control implements Actionable, BgColorable, Linkable, Scriptable, Styleable, SubStyleable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $image = ''; protected $tagName = 'quad';
protected $imageId = ''; protected $image = null;
protected $imageFocus = ''; protected $imageId = null;
protected $imageFocusId = ''; protected $imageFocus = null;
protected $colorize = ''; protected $imageFocusId = null;
protected $modulizeColor = ''; protected $colorize = null;
protected $modulizeColor = null;
protected $autoScale = 1; protected $autoScale = 1;
protected $action = ''; protected $action = null;
protected $actionKey = -1; protected $actionKey = -1;
protected $bgColor = ''; protected $bgColor = null;
protected $url = ''; protected $url = null;
protected $urlId = ''; protected $urlId = null;
protected $manialink = ''; protected $manialink = null;
protected $manialinkId = ''; protected $manialinkId = null;
protected $scriptEvents = 0; protected $scriptEvents = null;
protected $style = ''; protected $style = null;
protected $subStyle = ''; protected $subStyle = null;
/**
* Construct a new Quad Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'quad';
$this->setZ(-1);
}
/**
* Create a new Quad Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quad
*/
public static function create($id = null) {
$quad = new Quad($id);
return $quad;
}
/** /**
* @see \FML\Controls\Control::getManiaScriptClass() * @see \FML\Controls\Control::getManiaScriptClass()
@ -70,10 +49,10 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
* Set Image Url * Set image url
* *
* @param string $image Image Url * @param string $image Image url
* @return \FML\Controls\Quad * @return \FML\Controls\Quad|static
*/ */
public function setImage($image) { public function setImage($image) {
$this->image = (string)$image; $this->image = (string)$image;
@ -81,10 +60,10 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
* Set Image Id to use from the Dico * Set image id to use from Dico
* *
* @param string $imageId Image Id * @param string $imageId Image id
* @return \FML\Controls\Quad * @return \FML\Controls\Quad|static
*/ */
public function setImageId($imageId) { public function setImageId($imageId) {
$this->imageId = (string)$imageId; $this->imageId = (string)$imageId;
@ -92,10 +71,10 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
* Set Focus Image Url * Set focus image url
* *
* @param string $imageFocus Focus Image Url * @param string $imageFocus Focus image url
* @return \FML\Controls\Quad * @return \FML\Controls\Quad|static
*/ */
public function setImageFocus($imageFocus) { public function setImageFocus($imageFocus) {
$this->imageFocus = (string)$imageFocus; $this->imageFocus = (string)$imageFocus;
@ -103,10 +82,10 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
* Set Focus Image Id to use from the Dico * Set focus image id to use from Dico
* *
* @param string $imageFocusId Focus Image Id * @param string $imageFocusId Focus image id
* @return \FML\Controls\Quad * @return \FML\Controls\Quad|static
*/ */
public function setImageFocusId($imageFocusId) { public function setImageFocusId($imageFocusId) {
$this->imageFocusId = (string)$imageFocusId; $this->imageFocusId = (string)$imageFocusId;
@ -114,10 +93,10 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
* Set Colorization * Set colorization
* *
* @param string $colorize Colorize Value * @param string $colorize Colorize value
* @return \FML\Controls\Quad * @return \FML\Controls\Quad|static
*/ */
public function setColorize($colorize) { public function setColorize($colorize) {
$this->colorize = (string)$colorize; $this->colorize = (string)$colorize;
@ -125,10 +104,10 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
* Set Modulization * Set modulization
* *
* @param string $modulizeColor Modulize Value * @param string $modulizeColor Modulize value
* @return \FML\Controls\Quad * @return \FML\Controls\Quad|static
*/ */
public function setModulizeColor($modulizeColor) { public function setModulizeColor($modulizeColor) {
$this->modulizeColor = (string)$modulizeColor; $this->modulizeColor = (string)$modulizeColor;
@ -136,10 +115,10 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
* Disable the automatic Image Scaling * Disable the automatic image scaling
* *
* @param bool $autoScale Whether the Image should scale automatically * @param bool $autoScale Whether the image should scale automatically
* @return \FML\Controls\Quad * @return \FML\Controls\Quad|static
*/ */
public function setAutoScale($autoScale) { public function setAutoScale($autoScale) {
$this->autoScale = ($autoScale ? 1 : 0); $this->autoScale = ($autoScale ? 1 : 0);
@ -246,7 +225,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* Apply the given CheckBox Design * Apply the given CheckBox Design
* *
* @param CheckBoxDesign $checkBoxDesign CheckBox Design * @param CheckBoxDesign $checkBoxDesign CheckBox Design
* @return \FML\Controls\Quad * @return \FML\Controls\Quad|static
*/ */
public function applyCheckBoxDesign(CheckBoxDesign $checkBoxDesign) { public function applyCheckBoxDesign(CheckBoxDesign $checkBoxDesign) {
$checkBoxDesign->applyToQuad($this); $checkBoxDesign->applyToQuad($this);
@ -254,7 +233,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
* @see \FML\Control::render() * @see \FML\Types\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument); $xmlElement = parent::render($domDocument);

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for '321Go' Style * Quad class for '321Go' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -21,24 +21,8 @@ class Quad_321Go extends Quad {
const SUBSTYLE_1 = '1'; const SUBSTYLE_1 = '1';
const SUBSTYLE_Go = 'Go!'; const SUBSTYLE_Go = 'Go!';
/** /*
* Create a new Quad_321Go Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_321Go
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quad321Go = new Quad_321Go($id);
return $quad321Go;
}
/**
* Construct a new Quad_321Go Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'BgRaceScore2' Style * Quad class for 'BgRaceScore2' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -44,24 +44,8 @@ class Quad_BgRaceScore2 extends Quad {
const SUBSTYLE_Tv = 'Tv'; const SUBSTYLE_Tv = 'Tv';
const SUBSTYLE_Warmup = 'Warmup'; const SUBSTYLE_Warmup = 'Warmup';
/** /*
* Create a new Quad_BgRaceScore2 Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_BgRaceScore2
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadBgRaceScore2 = new Quad_BgRaceScore2($id);
return $quadBgRaceScore2;
}
/**
* Construct a new Quad_BgRaceScore2 Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Bgs1' Style * Quad class for 'Bgs1' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -83,24 +83,8 @@ class Quad_Bgs1 extends Quad {
const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall'; const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall';
const SUBSTYLE_Shadow = 'Shadow'; const SUBSTYLE_Shadow = 'Shadow';
/** /*
* Create a new Quad_Bgs1 Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Bgs1
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadBgs1 = new Quad_Bgs1($id);
return $quadBgs1;
}
/**
* Construct a new Quad_Bgs1 Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Bgs1InRace' Style * Quad class for 'Bgs1InRace' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -83,24 +83,8 @@ class Quad_Bgs1InRace extends Quad {
const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall'; const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall';
const SUBSTYLE_Shadow = 'Shadow'; const SUBSTYLE_Shadow = 'Shadow';
/** /*
* Create a new Quad_Bgs1InRace Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Bgs1InRace
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadBgs1InRace = new Quad_Bgs1InRace($id);
return $quadBgs1InRace;
}
/**
* Construct a new Quad_Bgs1InRace Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'BgsChallengeMedals' Style * Quad class for 'BgsChallengeMedals' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -23,24 +23,8 @@ class Quad_BgsChallengeMedals extends Quad {
const SUBSTYLE_BgPlayed = 'BgPlayed'; const SUBSTYLE_BgPlayed = 'BgPlayed';
const SUBSTYLE_BgSilver = 'BgSilver'; const SUBSTYLE_BgSilver = 'BgSilver';
/** /*
* Create a new Quad_BgsChallengeMedals Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_BgsChallengeMedals
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadBgsChallengeMedals = new Quad_BgsChallengeMedals($id);
return $quadBgsChallengeMedals;
}
/**
* Construct a new Quad_BgsChallengeMedals Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'BgsPlayerCard' Style * Quad class for 'BgsPlayerCard' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -31,24 +31,8 @@ class Quad_BgsPlayerCard extends Quad {
const SUBSTYLE_BgRacePlayerName = 'BgRacePlayerName'; const SUBSTYLE_BgRacePlayerName = 'BgRacePlayerName';
const SUBSTYLE_ProgressBar = 'ProgressBar'; const SUBSTYLE_ProgressBar = 'ProgressBar';
/** /*
* Create a new Quad_BgsPlayerCard Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_BgsPlayerCard
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadBgsPlayerCard = new Quad_BgsPlayerCard($id);
return $quadBgsPlayerCard;
}
/**
* Construct a new Quad_BgsPlayerCard Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Copilot' Style * Quad class for 'Copilot' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -29,24 +29,8 @@ class Quad_Copilot extends Quad {
const SUBSTYLE_UpGood = 'UpGood'; const SUBSTYLE_UpGood = 'UpGood';
const SUBSTYLE_UpWrong = 'UpWrong'; const SUBSTYLE_UpWrong = 'UpWrong';
/** /*
* Create a new Quad_Copilot Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Copilot
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadCopilot = new Quad_Copilot($id);
return $quadCopilot;
}
/**
* Construct a new Quad_Copilot Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Emblems' Style * Quad class for 'Emblems' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -20,24 +20,8 @@ class Quad_Emblems extends Quad {
const SUBSTYLE_1 = '#1'; const SUBSTYLE_1 = '#1';
const SUBSTYLE_2 = '#2'; const SUBSTYLE_2 = '#2';
/** /*
* Create a new Quad_Emblems Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Emblems
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadEmblems = new Quad_Emblems($id);
return $quadEmblems;
}
/**
* Construct a new Quad_Emblems Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'EnergyBar' Style * Quad class for 'EnergyBar' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -23,24 +23,8 @@ class Quad_EnergyBar extends Quad {
const SUBSTYLE_HeaderGaugeLeft = 'HeaderGaugeLeft'; const SUBSTYLE_HeaderGaugeLeft = 'HeaderGaugeLeft';
const SUBSTYLE_HeaderGaugeRight = 'HeaderGaugeRight'; const SUBSTYLE_HeaderGaugeRight = 'HeaderGaugeRight';
/** /*
* Create a new Quad_EnergyBar Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_EnergyBar
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadEnergybar = new Quad_EnergyBar($id);
return $quadEnergybar;
}
/**
* Construct a new Quad_EnergyBar Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Hud3dEchelons' Style * Quad class for 'Hud3dEchelons' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -26,24 +26,8 @@ class Quad_Hud3dEchelons extends Quad {
const SUBSTYLE_EchelonSilver2 = 'EchelonSilver2'; const SUBSTYLE_EchelonSilver2 = 'EchelonSilver2';
const SUBSTYLE_EchelonSilver3 = 'EchelonSilver3'; const SUBSTYLE_EchelonSilver3 = 'EchelonSilver3';
/** /*
* Create a new Quad_Hud3dEchelons Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Hud3dEchelons
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadHud3dEchelons = new Quad_Hud3dEchelons($id);
return $quadHud3dEchelons;
}
/**
* Construct a new Quad_Hud3dEchelons Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Hud3dIcons' Style * Quad class for 'Hud3dIcons' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -25,24 +25,8 @@ class Quad_Hud3dIcons extends Quad {
const SUBSTYLE_PointB = 'PointB'; const SUBSTYLE_PointB = 'PointB';
const SUBSTYLE_PointC = 'PointC'; const SUBSTYLE_PointC = 'PointC';
/** /*
* Create a new Quad_Hud3dIcons Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Hud3dIcons
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadHud3dIcons = new Quad_Hud3dIcons($id);
return $quadHud3dIcons;
}
/**
* Construct a new Quad_Hud3dIcons Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Icons128x128_1' Style * Quad class for 'Icons128x128_1' styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -81,24 +81,8 @@ class Quad_Icons128x128_1 extends Quad {
const SUBSTYLE_Upload = 'Upload'; const SUBSTYLE_Upload = 'Upload';
const SUBSTYLE_Vehicles = 'Vehicles'; const SUBSTYLE_Vehicles = 'Vehicles';
/** /*
* Create a new Quad_Icons128x128_1 Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Icons128x128_1
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadIcons128x128_1 = new Quad_Icons128x128_1($id);
return $quadIcons128x128_1;
}
/**
* Construct a new Quad_Icons128x128_1 Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Icons128x128_Blink' Style * Quad class for 'Icons128x128_Blink' styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -81,24 +81,8 @@ class Quad_Icons128x128_Blink extends Quad {
const SUBSTYLE_Upload = 'Upload'; const SUBSTYLE_Upload = 'Upload';
const SUBSTYLE_Vehicles = 'Vehicles'; const SUBSTYLE_Vehicles = 'Vehicles';
/** /*
* Create a new Quad_Icons128x128_Blink Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Icons128x128_Blink
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadIcons128x128_Blink = new Quad_Icons128x128_Blink($id);
return $quadIcons128x128_Blink;
}
/**
* Construct a new Quad_Icons128x128_Blink Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Icons128x32_1' Style * Quad class for 'Icons128x32_1' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -43,24 +43,8 @@ class Quad_Icons128x32_1 extends Quad {
const SUBSTYLE_UrlBg = 'UrlBg'; const SUBSTYLE_UrlBg = 'UrlBg';
const SUBSTYLE_Windowed = 'Windowed'; const SUBSTYLE_Windowed = 'Windowed';
/** /*
* Create a new Quad_Icons128x32_1 Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Icons128x32_1
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadIcons128x32_1 = new Quad_Icons128x32_1($id);
return $quadIcons128x32_1;
}
/**
* Construct a new Quad_Icons128x32_1 Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Icons64x64_1' Style * Quad class for 'Icons64x64_1' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -103,24 +103,8 @@ class Quad_Icons64x64_1 extends Quad {
const SUBSTYLE_YellowHigh = 'YellowHigh'; const SUBSTYLE_YellowHigh = 'YellowHigh';
const SUBSTYLE_YellowLow = 'YellowLow'; const SUBSTYLE_YellowLow = 'YellowLow';
/** /*
* Create a new Quad_Icons64x64_1 Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Icons64x64_1
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadIcons64x64_1 = new Quad_Icons64x64_1($id);
return $quadIcons64x64_1;
}
/**
* Construct a new Quad_Icons64x64_1 Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'Icons64x64_2' Style * Quad class for 'Icons64x64_2' styles
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -31,24 +31,8 @@ class Quad_Icons64x64_2 extends Quad {
const SUBSTYLE_UnknownElimination = 'UnknownElimination'; const SUBSTYLE_UnknownElimination = 'UnknownElimination';
const SUBSTYLE_UnknownHit = 'UnknownHit'; const SUBSTYLE_UnknownHit = 'UnknownHit';
/** /*
* Create a new Quad_Icons64x64_2 Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_Icons64x64_2
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadIcons64x64_2 = new Quad_Icons64x64_2($id);
return $quadIcons64x64_2;
}
/**
* Construct a new Quad_Icons64x64_2 Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'ManiaPlanetLogos' Style * Quad class for 'ManiaPlanetLogos' styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -24,24 +24,8 @@ class Quad_ManiaPlanetLogos extends Quad {
const SUBSTYLE_ManiaPlanetLogoWhite = 'ManiaPlanetLogoWhite'; const SUBSTYLE_ManiaPlanetLogoWhite = 'ManiaPlanetLogoWhite';
const SUBSTYLE_ManiaPlanetLogoWhiteSmall = 'ManiaPlanetLogoWhiteSmall'; const SUBSTYLE_ManiaPlanetLogoWhiteSmall = 'ManiaPlanetLogoWhiteSmall';
/** /*
* Create a new Quad_ManiaPlanetLogos Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_ManiaPlanetLogos
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadManiaPlanetLogos = new Quad_ManiaPlanetLogos($id);
return $quadManiaPlanetLogos;
}
/**
* Construct a new Quad_ManiaPlanetLogos Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'ManiaPlanetMainMenu' Style * Quad class for 'ManiaPlanetMainMenu' styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -28,24 +28,8 @@ class Quad_ManiaPlanetMainMenu extends Quad {
const SUBSTYLE_TitleBg = 'TitleBg'; const SUBSTYLE_TitleBg = 'TitleBg';
const SUBSTYLE_TopBar = 'TopBar'; const SUBSTYLE_TopBar = 'TopBar';
/** /*
* Create a new Quad_ManiaPlanetMainMenu Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_ManiaPlanetMainMenu
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadManiaPlanetMainMenu = new Quad_ManiaPlanetMainMenu($id);
return $quadManiaPlanetMainMenu;
}
/**
* Construct a new Quad_ManiaPlanetMainMenu Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'ManiaplanetSystem' Style * Quad class for 'ManiaplanetSystem' styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -23,24 +23,8 @@ class Quad_ManiaplanetSystem extends Quad {
const SUBSTYLE_Medals = 'Medals'; const SUBSTYLE_Medals = 'Medals';
const SUBSTYLE_Statistics = 'Statistics'; const SUBSTYLE_Statistics = 'Statistics';
/** /*
* Create a new Quad_ManiaplanetSystem Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_ManiaplanetSystem
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadManiaplanetSystem = new Quad_ManiaplanetSystem($id);
return $quadManiaplanetSystem;
}
/**
* Construct a new Quad_ManiaplanetSystem Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'MedalsBig' Style * Quad class for 'MedalsBig' styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -24,24 +24,8 @@ class Quad_MedalsBig extends Quad {
const SUBSTYLE_MedalSilver = 'MedalSilver'; const SUBSTYLE_MedalSilver = 'MedalSilver';
const SUBSTYLE_MedalSlot = 'MedalSlot'; const SUBSTYLE_MedalSlot = 'MedalSlot';
/** /*
* Create a new Quad_MedalsBig Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_MedalsBig
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadMedalsBig = new Quad_MedalsBig($id);
return $quadMedalsBig;
}
/**
* Construct a new Quad_MedalsBig Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'TitleLogos' Style * Quad class for 'TitleLogos' styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -21,24 +21,8 @@ class Quad_TitleLogos extends Quad {
const SUBSTYLE_Icon = 'Icon'; const SUBSTYLE_Icon = 'Icon';
const SUBSTYLE_Title = 'Title'; const SUBSTYLE_Title = 'Title';
/** /*
* Create a new Quad_TitleLogos Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_TitleLogos
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadTitleLogos = new Quad_TitleLogos($id);
return $quadTitleLogos;
}
/**
* Construct a new Quad_TitleLogos Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'UIConstruction_Buttons' Style * Quad class for 'UIConstruction_Buttons' styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -73,24 +73,8 @@ class Quad_UIConstruction_Buttons extends Quad {
const SUBSTYLE_Validate_Step2 = 'Validate_Step2'; const SUBSTYLE_Validate_Step2 = 'Validate_Step2';
const SUBSTYLE_Validate_Step3 = 'Validate_Step3'; const SUBSTYLE_Validate_Step3 = 'Validate_Step3';
/** /*
* Create a new Quad_UIConstruction_Buttons Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_UIConstruction_Buttons
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadUIConstructionButtons = new Quad_UIConstruction_Buttons($id);
return $quadUIConstructionButtons;
}
/**
* Construct a new Quad_UIConstruction_Buttons Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'UIConstruction_Buttons2' Style * Quad class for 'UIConstruction_Buttons2' styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -29,24 +29,8 @@ class Quad_UIConstruction_Buttons2 extends Quad {
const SUBSTYLE_Open = 'Open'; const SUBSTYLE_Open = 'Open';
const SUBSTYLE_Symmetry = 'Symmetry'; const SUBSTYLE_Symmetry = 'Symmetry';
/** /*
* Create a new Quad_UIConstruction_Buttons2 Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_UIConstruction_Buttons2
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadUIConstructionButtons2 = new Quad_UIConstruction_Buttons2($id);
return $quadUIConstructionButtons2;
}
/**
* Construct a new Quad_UIConstruction_Buttons2 Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad Class for 'UiSMSpectatorScoreBig' Style * Quad class for 'UiSMSpectatorScoreBig' styles
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -38,24 +38,8 @@ class Quad_UiSMSpectatorScoreBig extends Quad {
CONST SUBSTYLE_UIRange1Bg = 'UIRange1Bg'; CONST SUBSTYLE_UIRange1Bg = 'UIRange1Bg';
CONST SUBSTYLE_UIRange2Bg = 'UIRange2Bg'; CONST SUBSTYLE_UIRange2Bg = 'UIRange2Bg';
/** /*
* Create a new Quad_UiSMSpectatorScoreBig Control * Protected properties
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quads\Quad_UiSMSpectatorScoreBig
*/ */
public static function create($id = null) { protected $style = self::STYLE;
$quadUiSMSpectatorScoreBig = new Quad_UiSMSpectatorScoreBig($id);
return $quadUiSMSpectatorScoreBig;
}
/**
* Construct a new Quad_UiSMSpectatorScoreBig Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->setStyle(self::STYLE);
}
} }

View File

@ -15,36 +15,16 @@ use FML\Types\Scriptable;
*/ */
class Video extends Control implements Playable, Scriptable { class Video extends Control implements Playable, Scriptable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $data = ''; protected $tagName = 'video';
protected $dataId = ''; protected $data = null;
protected $play = 0; protected $dataId = null;
protected $looping = 0; protected $play = null;
protected $music = 0; protected $looping = true;
protected $music = null;
protected $volume = 1.; protected $volume = 1.;
protected $scriptEvents = 0; protected $scriptEvents = null;
/**
* Construct a new Video Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'video';
}
/**
* Create a new Video Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Video
*/
public static function create($id = null) {
$video = new Video($id);
return $video;
}
/** /**
* @see \FML\Controls\Control::getManiaScriptClass() * @see \FML\Controls\Control::getManiaScriptClass()
@ -110,7 +90,7 @@ class Video extends Control implements Playable, Scriptable {
} }
/** /**
* @see \FML\Control::render() * @see \FML\Types\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument); $xmlElement = parent::render($domDocument);

View File

@ -11,7 +11,7 @@ namespace FML;
*/ */
class CustomUI { class CustomUI {
/* /*
* Protected Properties * Protected properties
*/ */
protected $encoding = 'utf-8'; protected $encoding = 'utf-8';
protected $tagName = 'custom_ui'; protected $tagName = 'custom_ui';
@ -25,26 +25,19 @@ class CustomUI {
protected $globalVisible = null; protected $globalVisible = null;
/** /**
* Create a new CustomUI Object * Create a new CustomUI object
* *
* @return \FML\CustomUI * @return \FML\CustomUI|static
*/ */
public static function create() { public static function create() {
$customUI = new CustomUI(); return new static();
return $customUI;
} }
/** /**
* Construct a new CustomUI Object * Set XML encoding
*/
public function __construct() {
}
/**
* Set XML Encoding
* *
* @param string $encoding XML Encoding * @param string $encoding XML encoding
* @return \FML\CustomUI * @return \FML\CustomUI|static
*/ */
public function setXMLEncoding($encoding) { public function setXMLEncoding($encoding) {
$this->encoding = (string)$encoding; $this->encoding = (string)$encoding;
@ -52,10 +45,10 @@ class CustomUI {
} }
/** /**
* Set Showing of Notices * Set showing of notices
* *
* @param bool $visible Whether Notices should be shown * @param bool $visible Whether notices should be shown
* @return \FML\CustomUI * @return \FML\CustomUI|static
*/ */
public function setNoticeVisible($visible) { public function setNoticeVisible($visible) {
$this->noticeVisible = $visible; $this->noticeVisible = $visible;
@ -63,10 +56,10 @@ class CustomUI {
} }
/** /**
* Set Showing of the Challenge Info * Set showing of the challenge info
* *
* @param bool $visible Whether the Challenge Info should be shown * @param bool $visible Whether the challenge info should be shown
* @return \FML\CustomUI * @return \FML\CustomUI|static
*/ */
public function setChallengeInfoVisible($visible) { public function setChallengeInfoVisible($visible) {
$this->challengeInfoVisible = $visible; $this->challengeInfoVisible = $visible;
@ -74,10 +67,10 @@ class CustomUI {
} }
/** /**
* Set Showing of the Net Infos * Set showing of the net infos
* *
* @param bool $visible Whether the Net Infos should be shown * @param bool $visible Whether the net infos should be shown
* @return \FML\CustomUI * @return \FML\CustomUI|static
*/ */
public function setNetInfosVisible($visible) { public function setNetInfosVisible($visible) {
$this->netInfosVisible = $visible; $this->netInfosVisible = $visible;
@ -85,10 +78,10 @@ class CustomUI {
} }
/** /**
* Set Showing of the Chat * Set showing of the chat
* *
* @param bool $visible Whether the Chat should be shown * @param bool $visible Whether the chat should be shown
* @return \FML\CustomUI * @return \FML\CustomUI|static
*/ */
public function setChatVisible($visible) { public function setChatVisible($visible) {
$this->chatVisible = $visible; $this->chatVisible = $visible;
@ -96,10 +89,10 @@ class CustomUI {
} }
/** /**
* Set Showing of the Checkpoint List * Set showing of the checkpoint list
* *
* @param bool $visible Whether the Checkpoint should be shown * @param bool $visible Whether the checkpoint should be shown
* @return \FML\CustomUI * @return \FML\CustomUI|static
*/ */
public function setCheckpointListVisible($visible) { public function setCheckpointListVisible($visible) {
$this->checkpointListVisible = $visible; $this->checkpointListVisible = $visible;
@ -107,10 +100,10 @@ class CustomUI {
} }
/** /**
* Set Showing of Round Scores * Set showing of round scores
* *
* @param bool $visible Whether the Round Scores should be shown * @param bool $visible Whether the round scores should be shown
* @return \FML\CustomUI * @return \FML\CustomUI|static
*/ */
public function setRoundScoresVisible($visible) { public function setRoundScoresVisible($visible) {
$this->roundScoresVisible = $visible; $this->roundScoresVisible = $visible;
@ -118,10 +111,10 @@ class CustomUI {
} }
/** /**
* Set Showing of the Scoretable * Set showing of the scoretable
* *
* @param bool $visible Whether the Scoretable should be shown * @param bool $visible Whether the scoretable should be shown
* @return \FML\CustomUI * @return \FML\CustomUI|static
*/ */
public function setScoretableVisible($visible) { public function setScoretableVisible($visible) {
$this->scoretableVisible = $visible; $this->scoretableVisible = $visible;
@ -129,10 +122,10 @@ class CustomUI {
} }
/** /**
* Set Global Showing * Set global showing
* *
* @param bool $visible Whether the UI should be disabled completely * @param bool $visible Whether the UI should be disabled completely
* @return \FML\CustomUI * @return \FML\CustomUI|static
*/ */
public function setGlobalVisible($visible) { public function setGlobalVisible($visible) {
$this->globalVisible = $visible; $this->globalVisible = $visible;
@ -140,9 +133,9 @@ class CustomUI {
} }
/** /**
* Render the XML Document * Render the XML document
* *
* @param \DOMDocument $domDocument (optional) DomDocument for which the XML Element should be rendered * @param \DOMDocument $domDocument (optional) DOMDocument for which the XML element should be rendered
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($domDocument = null) { public function render($domDocument = null) {
@ -157,7 +150,7 @@ class CustomUI {
} }
$settings = $this->getSettings(); $settings = $this->getSettings();
foreach ($settings as $setting => $value) { foreach ($settings as $setting => $value) {
if ($value === null) { if (is_null($value)) {
continue; continue;
} }
$xmlSubElement = $domDocument->createElement($setting); $xmlSubElement = $domDocument->createElement($setting);
@ -171,18 +164,16 @@ class CustomUI {
} }
/** /**
* Get String Representation * Get string representation
* *
* @return string * @return string
*/ */
public function __toString() { public function __toString() {
$domDocument = $this->render(); return $this->render()->saveXML();
$xmlText = $domDocument->saveXML();
return $xmlText;
} }
/** /**
* Get associative Array of all CustomUI Settings * Get associative array of all CustomUI settings
* *
* @return array * @return array
*/ */

View File

@ -11,174 +11,167 @@ namespace FML\Elements;
*/ */
class Dico { class Dico {
/** /**
* Czech Language * Czech language
* *
* @var string * @var string
*/ */
const LANG_CZECH = 'cz'; const LANG_CZECH = 'cz';
/** /**
* Danish Language * Danish language
* *
* @var string * @var string
*/ */
const LANG_DANISH = 'da'; const LANG_DANISH = 'da';
/** /**
* German Language * German language
* *
* @var string * @var string
*/ */
const LANG_GERMAN = 'de'; const LANG_GERMAN = 'de';
/** /**
* English Language * English language
* *
* @var string * @var string
*/ */
const LANG_ENGLISH = 'en'; const LANG_ENGLISH = 'en';
/** /**
* Spanish Language * Spanish language
* *
* @var string * @var string
*/ */
const LANG_SPANISH = 'es'; const LANG_SPANISH = 'es';
/** /**
* French Language * French language
* *
* @var string * @var string
*/ */
const LANG_FRENCH = 'fr'; const LANG_FRENCH = 'fr';
/** /**
* Hungarian Language * Hungarian language
* *
* @var string * @var string
*/ */
const LANG_HUNGARIAN = 'hu'; const LANG_HUNGARIAN = 'hu';
/** /**
* Italian Language * Italian language
* *
* @var string * @var string
*/ */
const LANG_ITALIAN = 'it'; const LANG_ITALIAN = 'it';
/** /**
* Japanese Language * Japanese language
* *
* @var string * @var string
*/ */
const LANG_JAPANESE = 'jp'; const LANG_JAPANESE = 'jp';
/** /**
* Korean Language * Korean language
* *
* @var string * @var string
*/ */
const LANG_KOREAN = 'kr'; const LANG_KOREAN = 'kr';
/** /**
* Norwegian Language * Norwegian language
* *
* @var string * @var string
*/ */
const LANG_NORWEGIAN = 'nb'; const LANG_NORWEGIAN = 'nb';
/** /**
* Dutch Language * Dutch language
* *
* @var string * @var string
*/ */
const LANG_DUTCH = 'nl'; const LANG_DUTCH = 'nl';
/** /**
* Polish Language * Polish language
* *
* @var string * @var string
*/ */
const LANG_POLISH = 'pl'; const LANG_POLISH = 'pl';
/** /**
* Portuguese Language * Portuguese language
* *
* @var string * @var string
*/ */
const LANG_PORTUGUESE = 'pt'; const LANG_PORTUGUESE = 'pt';
/** /**
* Brazilian Portuguese Language * Brazilian Portuguese language
* *
* @var string * @var string
*/ */
const LANG_BRAZILIAN_PORTUGUESE = 'pt_BR'; const LANG_BRAZILIAN_PORTUGUESE = 'pt_BR';
/** /**
* Romanian Language * Romanian language
* *
* @var string * @var string
*/ */
const LANG_ROMANIAN = 'ro'; const LANG_ROMANIAN = 'ro';
/** /**
* Russian Language * Russian language
* *
* @var string * @var string
*/ */
const LANG_RUSSIAN = 'ru'; const LANG_RUSSIAN = 'ru';
/** /**
* Slovak Language * Slovak language
* *
* @var string * @var string
*/ */
const LANG_SLOVAK = 'sk'; const LANG_SLOVAK = 'sk';
/** /**
* Turkish Language * Turkish language
* *
* @var string * @var string
*/ */
const LANG_TURKISH = 'tr'; const LANG_TURKISH = 'tr';
/** /**
* Chinese Language * Chinese language
* *
* @var string * @var string
*/ */
const LANG_CHINESE = 'zh'; const LANG_CHINESE = 'zh';
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'dico'; protected $tagName = 'dico';
protected $entries = array(); protected $entries = array();
/** /**
* Create a new Dictionary Object * Create a new Dictionary object
* *
* @return \FML\Elements\Dico * @return \FML\Elements\Dico|static
*/ */
public static function create() { public static function create() {
$dico = new Dico(); return new static();
return $dico;
} }
/** /**
* Construct a new Dictionary Object * Set the translatable entry for the specific language
*/
public function __construct() {
}
/**
* Set the translatable Entry for the specific Language
* *
* @param string $language Language Id * @param string $language Language id
* @param string $entryId Entry Id * @param string $entryId Entry id
* @param string $entryValue Translated Entry Value * @param string $entryValue Translated entry value
* @return \FML\Elements\Dico * @return \FML\Elements\Dico|static
*/ */
public function setEntry($language, $entryId, $entryValue) { public function setEntry($language, $entryId, $entryValue) {
$language = (string)$language; $language = (string)$language;
@ -198,11 +191,11 @@ class Dico {
} }
/** /**
* Remove Entries of the given Id * Remove entries of the given id
* *
* @param string $entryId Entry Id that should be removed * @param string $entryId Entry id that should be removed
* @param string $language (optional) Only remove Entries of the given Language * @param string $language (optional) Only remove entries of the given language
* @return \FML\Elements\Dico * @return \FML\Elements\Dico|static
*/ */
public function removeEntry($entryId, $language = null) { public function removeEntry($entryId, $language = null) {
$entryId = (string)$entryId; $entryId = (string)$entryId;
@ -222,11 +215,11 @@ class Dico {
} }
/** /**
* Remove Entries of the given Language * Remove entries of the given language
* *
* @param string $language Language of which all Entries should be removed * @param string $language Language which entries should be removed
* @param string $entryId (optional) Only remove the given Entry Id * @param string $entryId (optional) Only remove the given entry id
* @return \FML\Elements\Dico * @return \FML\Elements\Dico|static
*/ */
public function removeLanguage($language, $entryId = null) { public function removeLanguage($language, $entryId = null) {
$language = (string)$language; $language = (string)$language;
@ -242,9 +235,9 @@ class Dico {
} }
/** /**
* Remove all Entries from the Dictionary * Remove all entries from the Dictionary
* *
* @return \FML\Elements\Dico * @return \FML\Elements\Dico|static
*/ */
public function removeEntries() { public function removeEntries() {
$this->entries = array(); $this->entries = array();
@ -252,9 +245,9 @@ class Dico {
} }
/** /**
* Render the Dico XML Element * Render the Dico XML element
* *
* @param \DOMDocument $domDocument DomDocument for which the Dico XML Element should be rendered * @param \DOMDocument $domDocument DOMDocument for which the Dico XML element should be rendered
* @return \DOMElement * @return \DOMElement
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -16,30 +16,23 @@ use FML\Types\TextFormatable;
*/ */
class Format implements BgColorable, Renderable, Styleable, TextFormatable { class Format implements BgColorable, Renderable, Styleable, TextFormatable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'format'; protected $tagName = 'format';
protected $bgColor = ''; protected $bgColor = null;
protected $style = ''; protected $style = null;
protected $textSize = -1; protected $textSize = -1;
protected $textColor = ''; protected $textColor = null;
protected $focusAreaColor1 = ''; protected $focusAreaColor1 = null;
protected $focusAreaColor2 = ''; protected $focusAreaColor2 = null;
/** /**
* Create a new Format Element * Create a new Format Element
* *
* @return \FML\Elements\Format * @return \FML\Elements\Format|static
*/ */
public static function create() { public static function create() {
$format = new Format(); return new static();
return $format;
}
/**
* Construct a new Format Element
*/
public function __construct() {
} }
/** /**

View File

@ -4,6 +4,7 @@ namespace FML\Elements;
use FML\Types\Container; use FML\Types\Container;
use FML\Types\Renderable; use FML\Types\Renderable;
use FML\UniqueID;
/** /**
* Class representing a Frame Model * Class representing a Frame Model
@ -14,42 +15,43 @@ use FML\Types\Renderable;
*/ */
class FrameModel implements Container, Renderable { class FrameModel implements Container, Renderable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'framemodel'; protected $tagName = 'framemodel';
protected $id = ''; protected $modelId = null;
/** @var Renderable[] $children */
protected $children = array(); protected $children = array();
/** @var Format $format */ /** @var Format $format */
protected $format = null; protected $format = null;
/** /**
* Set Model Id * Set Model id
* *
* @param string $id Model Id * @param string $modelId Model id
* @return \FML\Elements\FrameModel * @return \FML\Elements\FrameModel|static
*/ */
public function setId($id) { public function setId($modelId) {
$this->id = (string)$id; $this->modelId = (string)$modelId;
return $this; return $this;
} }
/** /**
* Get Model Id * Get Model id
* *
* @return string * @return string
*/ */
public function getId() { public function getId() {
return $this->id; return $this->modelId;
} }
/** /**
* Assign an Id if necessary * Assign an id if necessary
* *
* @return string * @return string
*/ */
public function checkId() { public function checkId() {
if (!$this->id) { if (!$this->modelId) {
$this->id = uniqid(); $this->setId(new UniqueID());
} }
return $this; return $this;
} }
@ -102,7 +104,6 @@ class FrameModel implements Container, Renderable {
$xmlElement->appendChild($formatXml); $xmlElement->appendChild($formatXml);
} }
foreach ($this->children as $child) { foreach ($this->children as $child) {
/** @var Renderable $child */
$childElement = $child->render($domDocument); $childElement = $child->render($domDocument);
$xmlElement->appendChild($childElement); $xmlElement->appendChild($childElement);
} }

View File

@ -13,40 +13,41 @@ use FML\Types\Renderable;
*/ */
class Including implements Renderable { class Including implements Renderable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'include'; protected $tagName = 'include';
protected $url = ''; protected $url = null;
/** /**
* Construct a new Include Element * Create a new Include object
* *
* @param string $url (optional) Include Url * @param string $url (optional) Include url
* @return \FML\Elements\Including * @return \FML\Elements\Including|static
*/ */
public static function create($url = null) { public static function create($url = null) {
$including = new Including($url); return new static($url);
return $including;
} }
/** /**
* Construct a new Include Element * Construct a new Include object
* *
* @param string $url (optional) Include Url * @param string $url (optional) Include url
*/ */
public function __construct($url = null) { public function __construct($url = null) {
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set Url * Set url
* *
* @param string $url Include Url * @param string $url Include url
* @return \FML\Elements\Including|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;
return $this;
} }
/** /**

View File

@ -13,38 +13,37 @@ use FML\Types\Renderable;
*/ */
class Music implements Renderable { class Music implements Renderable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'music'; protected $tagName = 'music';
protected $data = ''; protected $data = null;
/** /**
* Create a new Music Element * Create a new Music object
* *
* @param string $data (optional) Media Url * @param string $data (optional) Media url
* @return \FML\Elements\Music * @return \FML\Elements\Music|static
*/ */
public static function create($data = null) { public static function create($data = null) {
$music = new Music($data); return new static($data);
return $music;
} }
/** /**
* Construct a new Music Element * Construct a new Music object
* *
* @param string $data (optional) Media Url * @param string $data (optional) Media url
*/ */
public function __construct($data = null) { public function __construct($data = null) {
if ($data !== null) { if (!is_null($data)) {
$this->setData($data); $this->setData($data);
} }
} }
/** /**
* Set Data Url * Set data url
* *
* @param string $data Media Url * @param string $data Data url
* @return \FML\Elements\Music * @return \FML\Elements\Music|static
*/ */
public function setData($data) { public function setData($data) {
$this->data = (string)$data; $this->data = (string)$data;

View File

@ -5,7 +5,7 @@ namespace FML\Elements;
use FML\Types\Renderable; use FML\Types\Renderable;
/** /**
* Class representing a ManiaLink Script Tag with a simple Script Text * Class representing a ManiaLink script tag with a simple script text
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -13,38 +13,37 @@ use FML\Types\Renderable;
*/ */
class SimpleScript implements Renderable { class SimpleScript implements Renderable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'script'; protected $tagName = 'script';
protected $text = ''; protected $text = null;
/** /**
* Create a new SimpleScript Element * Create a new SimpleScript object
* *
* @param string $text (optional) Script Text * @param string $text (optional) Script text
* @return \FML\Elements\SimpleScript * @return \FML\Elements\SimpleScript|static
*/ */
public static function create($text = null) { public static function create($text = null) {
$simpleScript = new SimpleScript($text); return new static($text);
return $simpleScript;
} }
/** /**
* Construct a new SimpleScript Element * Construct a new SimpleScript object
* *
* @param string $text (optional) Script Text * @param string $text (optional) Script text
*/ */
public function __construct($text = null) { public function __construct($text = null) {
if ($text !== null) { if (!is_null($text)) {
$this->setText($text); $this->setText($text);
} }
} }
/** /**
* Set Script Text * Set script text
* *
* @param string $text The Complete Script Text * @param string $text Complete script text
* @return \FML\Script\Script * @return \FML\Script\Script|static
*/ */
public function setText($text) { public function setText($text) {
$this->text = (string)$text; $this->text = (string)$text;

View File

@ -28,34 +28,28 @@ use FML\ManiaCode\ViewReplay;
*/ */
class ManiaCode { class ManiaCode {
/* /*
* Protected Properties * Protected properties
*/ */
protected $encoding = 'utf-8'; protected $encoding = 'utf-8';
protected $tagName = 'maniacode'; protected $tagName = 'maniacode';
protected $noConfirmation = null; protected $noConfirmation = null;
/** @var Element[] $elements */
protected $elements = array(); protected $elements = array();
/** /**
* Create a new ManiaCode Object * Create a new ManiaCode object
* *
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public static function create() { public static function create() {
$maniaCode = new ManiaCode(); return new static();
return $maniaCode;
} }
/** /**
* Construct a new ManiaCode Object * Set XML encoding
*/
public function __construct() {
}
/**
* Set XML Encoding
* *
* @param string $encoding XML Encoding * @param string $encoding XML encoding
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function setXmlEncoding($encoding) { public function setXmlEncoding($encoding) {
$this->encoding = (string)$encoding; $this->encoding = (string)$encoding;
@ -63,10 +57,10 @@ class ManiaCode {
} }
/** /**
* Disable the Showing of the Confirmation at the End of the ManiaCode * Disable the showing of the confirmation at the end of the ManiaCode
* *
* @param bool $disable Whether the Confirmation should be shown * @param bool $disable Whether the confirmation should be shown
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function disableConfirmation($disable) { public function disableConfirmation($disable) {
$this->noConfirmation = ($disable ? 1 : 0); $this->noConfirmation = ($disable ? 1 : 0);
@ -74,10 +68,10 @@ class ManiaCode {
} }
/** /**
* Show a Message * Show a message
* *
* @param string $message Message Text * @param string $message Message text
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addShowMessage($message) { public function addShowMessage($message) {
$messageElement = new ShowMessage($message); $messageElement = new ShowMessage($message);
@ -88,10 +82,10 @@ class ManiaCode {
/** /**
* Install a Macroblock * Install a Macroblock
* *
* @param string $name Macroblock Name * @param string $name Macroblock name
* @param string $file Macroblock File * @param string $file Macroblock file
* @param string $url Macroblock Url * @param string $url Macroblock url
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addInstallMacroblock($name, $file, $url) { public function addInstallMacroblock($name, $file, $url) {
$macroblockElement = new InstallMacroblock($name, $file, $url); $macroblockElement = new InstallMacroblock($name, $file, $url);
@ -100,11 +94,11 @@ class ManiaCode {
} }
/** /**
* Install a Map * Install a map
* *
* @param string $name Map Name * @param string $name Map name
* @param string $url Map Url * @param string $url Map url
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addInstallMap($name, $url) { public function addInstallMap($name, $url) {
$mapElement = new InstallMap($name, $url); $mapElement = new InstallMap($name, $url);
@ -113,11 +107,11 @@ class ManiaCode {
} }
/** /**
* Play a Map * Play a map
* *
* @param string $name Map Name * @param string $name Map name
* @param string $url Map Url * @param string $url Map url
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addPlayMap($name, $url) { public function addPlayMap($name, $url) {
$mapElement = new PlayMap($name, $url); $mapElement = new PlayMap($name, $url);
@ -126,11 +120,11 @@ class ManiaCode {
} }
/** /**
* Install a Replay * Install a replay
* *
* @param string $name Replay Name * @param string $name Replay name
* @param string $url Replay Url * @param string $url Replay url
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addInstallReplay($name, $url) { public function addInstallReplay($name, $url) {
$replayElement = new InstallReplay($name, $url); $replayElement = new InstallReplay($name, $url);
@ -139,11 +133,11 @@ class ManiaCode {
} }
/** /**
* View a Replay * View a replay
* *
* @param string $name Replay Name * @param string $name Replay name
* @param string $url Replay Url * @param string $url Replay url
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addViewReplay($name, $url) { public function addViewReplay($name, $url) {
$replayElement = new ViewReplay($name, $url); $replayElement = new ViewReplay($name, $url);
@ -152,11 +146,11 @@ class ManiaCode {
} }
/** /**
* Play a Replay * Play a replay
* *
* @param string $name Replay Name * @param string $name Replay name
* @param string $url Replay Url * @param string $url Replay url
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addPlayReplay($name, $url) { public function addPlayReplay($name, $url) {
$replayElement = new PlayReplay($name, $url); $replayElement = new PlayReplay($name, $url);
@ -165,12 +159,12 @@ class ManiaCode {
} }
/** /**
* Install a Skin * Install a skin
* *
* @param string $name Skin Name * @param string $name Skin name
* @param string $file Skin File * @param string $file Skin file
* @param string $url Skin Url * @param string $url Skin url
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addInstallSkin($name, $file, $url) { public function addInstallSkin($name, $file, $url) {
$skinElement = new InstallSkin($name, $file, $url); $skinElement = new InstallSkin($name, $file, $url);
@ -179,12 +173,12 @@ class ManiaCode {
} }
/** /**
* Get a Skin * Get a skin
* *
* @param string $name Skin Name * @param string $name Skin name
* @param string $file Skin File * @param string $file Skin file
* @param string $url Skin Url * @param string $url Skin url
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addGetSkin($name, $file, $url) { public function addGetSkin($name, $file, $url) {
$skinElement = new GetSkin($name, $file, $url); $skinElement = new GetSkin($name, $file, $url);
@ -193,10 +187,10 @@ class ManiaCode {
} }
/** /**
* Add a Buddy * Add a buddy
* *
* @param string $login Buddy Login * @param string $login Buddy login
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addAddBuddy($login) { public function addAddBuddy($login) {
$buddyElement = new AddBuddy($login); $buddyElement = new AddBuddy($login);
@ -205,10 +199,10 @@ class ManiaCode {
} }
/** /**
* Go to a Link * Go to a link
* *
* @param string $link Goto Link * @param string $link Goto link
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addGoto($link) { public function addGoto($link) {
$gotoElement = new Go_To($link); $gotoElement = new Go_To($link);
@ -217,10 +211,10 @@ class ManiaCode {
} }
/** /**
* Join a Server * Join a server
* *
* @param string $login Server Login * @param string $login Server login
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addJoinServer($login) { public function addJoinServer($login) {
$serverElement = new JoinServer($login); $serverElement = new JoinServer($login);
@ -229,10 +223,10 @@ class ManiaCode {
} }
/** /**
* Add a Server as Favorite * Add a server as favorite
* *
* @param string $login Server Login * @param string $login Server login
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addAddFavorite($login) { public function addAddFavorite($login) {
$favoriteElement = new AddFavorite($login); $favoriteElement = new AddFavorite($login);
@ -241,12 +235,12 @@ class ManiaCode {
} }
/** /**
* Install a Script * Install a script
* *
* @param string $name Script Name * @param string $name Script name
* @param string $file Script File * @param string $file Script file
* @param string $url Script Url * @param string $url Script url
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addInstallScript($name, $file, $url) { public function addInstallScript($name, $file, $url) {
$scriptElement = new InstallScript($name, $file, $url); $scriptElement = new InstallScript($name, $file, $url);
@ -255,12 +249,12 @@ class ManiaCode {
} }
/** /**
* Install a Title Pack * Install a title pack
* *
* @param string $name Pack Name * @param string $name Pack name
* @param string $file Pack File * @param string $file Pack file
* @param string $url Pack Url * @param string $url Pack url
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addInstallPack($name, $file, $url) { public function addInstallPack($name, $file, $url) {
$packElement = new InstallPack($name, $file, $url); $packElement = new InstallPack($name, $file, $url);
@ -269,10 +263,10 @@ class ManiaCode {
} }
/** /**
* Add a ManiaCode Element * Add a ManiaCode element
* *
* @param Element $element The Element to add * @param Element $element Element to add
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function addElement(Element $element) { public function addElement(Element $element) {
array_push($this->elements, $element); array_push($this->elements, $element);
@ -280,9 +274,9 @@ class ManiaCode {
} }
/** /**
* Removes all Elements from the ManiaCode * Remove all elements from the ManiaCode
* *
* @return \FML\ManiaCode * @return \FML\ManiaCode|static
*/ */
public function removeElements() { public function removeElements() {
$this->elements = array(); $this->elements = array();
@ -290,9 +284,9 @@ class ManiaCode {
} }
/** /**
* Render the XML Document * Render the XML document
* *
* @param bool (optional) $echo Whether the XML Text should be echoed and the Content-Type Header should be set * @param bool $echo (optional) Whether the XML text should be echoed and the Content-Type header should be set
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($echo = false) { public function render($echo = false) {
@ -304,7 +298,6 @@ class ManiaCode {
$maniaCode->setAttribute('noconfirmation', $this->noConfirmation); $maniaCode->setAttribute('noconfirmation', $this->noConfirmation);
} }
foreach ($this->elements as $element) { foreach ($this->elements as $element) {
/** @var Element $element */
$xmlElement = $element->render($domDocument); $xmlElement = $element->render($domDocument);
$maniaCode->appendChild($xmlElement); $maniaCode->appendChild($xmlElement);
} }
@ -316,13 +309,11 @@ class ManiaCode {
} }
/** /**
* Get String Representation * Get string representation
* *
* @return string * @return string
*/ */
public function __toString() { public function __toString() {
$domDocument = $this->render(); return $this->render()->saveXML();
$xmlText = $domDocument->saveXML();
return $xmlText;
} }
} }

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element adding a Buddy * ManiaCode Element adding a buddy
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,46 +11,44 @@ namespace FML\ManiaCode;
*/ */
class AddBuddy implements Element { class AddBuddy implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'add_buddy'; protected $tagName = 'add_buddy';
protected $login = ''; protected $login = null;
/** /**
* Construct a new AddBuddy Element * Create a new AddBuddy Element
* *
* @param string $login (optional) Buddy Login * @param string $login (optional) Buddy login
* @return \FML\ManiaCode\AddBuddy * @return \FML\ManiaCode\AddBuddy|static
*/ */
public static function create($login = null) { public static function create($login = null) {
$addBuddy = new AddBuddy($login); return new static($login);
return $addBuddy;
} }
/** /**
* Construct a new AddBuddy Element * Construct a new AddBuddy Element
* *
* @param string $login (optional) Buddy Login * @param string $login (optional) Buddy login
*/ */
public function __construct($login = null) { public function __construct($login = null) {
if ($login !== null) { if (!is_null($login)) {
$this->setLogin($login); $this->setLogin($login);
} }
} }
/** /**
* Set the Buddy Login * Set the buddy login
* *
* @param string $login Buddy Login * @param string $login Buddy login
* @return \FML\ManiaCode\AddBuddy * @return \FML\ManiaCode\AddBuddy|static
*/ */
public function setLogin($login) { public function setLogin($login) {
$this->login = (string) $login; $this->login = (string)$login;
return $this; return $this;
} }
/** /**
*
* @see \FML\ManiaCode\Element::render() * @see \FML\ManiaCode\Element::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element adding a Server as Favorite * ManiaCode Element adding a server as favorite
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,74 +11,71 @@ namespace FML\ManiaCode;
*/ */
class AddFavorite implements Element { class AddFavorite implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'add_favourite'; protected $tagName = 'add_favourite';
protected $login = ''; protected $login = null;
protected $ip = null; protected $serverIp = null;
protected $port = null; protected $serverPort = null;
/** /**
* Construct a new AddFavorite Element * Create a new AddFavorite object
* *
* @param string $login (optional) Server Login * @param string $login (optional) Server login
* @return \FML\ManiaCode\AddFavorite * @return \FML\ManiaCode\AddFavorite|static
*/ */
public static function create($login = null) { public static function create($login = null) {
$addFavorite = new AddFavorite($login); return new static($login);
return $addFavorite;
} }
/** /**
* Construct a new AddFavorite Element * Construct a new AddFavorite object
* *
* @param string $login (optional) Server Login * @param string $login (optional) Server login
*/ */
public function __construct($login = null) { public function __construct($login = null) {
if ($login !== null) { if (!is_null($login)) {
$this->setLogin($login); $this->setLogin($login);
} }
} }
/** /**
* Set the Server Login * Set the server login
* *
* @param string $login Server Login * @param string $login Server login
* @return \FML\ManiaCode\AddFavorite * @return \FML\ManiaCode\AddFavorite|static
*/ */
public function setLogin($login) { public function setLogin($login) {
$this->login = (string) $login; $this->login = (string)$login;
$this->ip = null; $this->serverIp = null;
$this->port = null; $this->serverPort = null;
return $this; return $this;
} }
/** /**
* Set the Server Ip and Port * Set the server ip and port
* *
* @param string $ip Server Ip * @param string $serverIp Server ip
* @param int $port Server Port * @param int $serverPort Server port
* @return \FML\ManiaCode\AddFavorite * @return \FML\ManiaCode\AddFavorite|static
*/ */
public function setIp($ip, $port) { public function setIp($serverIp, $serverPort) {
$this->ip = (string) $ip; $this->serverIp = (string)$serverIp;
$this->port = (int) $port; $this->serverPort = (int)$serverPort;
$this->login = null; $this->login = null;
return $this; return $this;
} }
/** /**
*
* @see \FML\ManiaCode\Element::render() * @see \FML\ManiaCode\Element::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName); $xmlElement = $domDocument->createElement($this->tagName);
if ($this->ip === null) { if (is_null($this->serverIp)) {
$loginElement = $domDocument->createElement('login', $this->login); $loginElement = $domDocument->createElement('login', $this->login);
$xmlElement->appendChild($loginElement); $xmlElement->appendChild($loginElement);
} } else {
else { $ipElement = $domDocument->createElement('ip', $this->serverIp . ':' . $this->serverPort);
$ipElement = $domDocument->createElement('ip', $this->ip . ':' . $this->port);
$xmlElement->appendChild($ipElement); $xmlElement->appendChild($ipElement);
} }
return $xmlElement; return $xmlElement;

View File

@ -14,7 +14,7 @@ interface Element {
/** /**
* Render the ManiaCode Element * Render the ManiaCode Element
* *
* @param \DOMDocument $domDocument The DomDocument for which the Element should be rendered * @param \DOMDocument $domDocument The DOMDocument for which the Element should be rendered
* @return \DOMElement * @return \DOMElement
*/ */
public function render(\DOMDocument $domDocument); public function render(\DOMDocument $domDocument);

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element downloading a Skin * ManiaCode Element downloading a skin
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,80 +11,78 @@ namespace FML\ManiaCode;
*/ */
class GetSkin implements Element { class GetSkin implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'get_skin'; protected $tagName = 'get_skin';
protected $name = ''; protected $name = null;
protected $file = ''; protected $file = null;
protected $url = ''; protected $url = null;
/** /**
* Create a new GetSkin Element * Create a new GetSkin object
* *
* @param string $name (optional) Skin Name * @param string $name (optional) Skin name
* @param string $file (optional) Skin File * @param string $file (optional) Skin file
* @param string $url (optional) Skin Url * @param string $url (optional) Skin url
* @return \FML\ManiaCode\GetSkin * @return \FML\ManiaCode\GetSkin|static
*/ */
public static function create($name = null, $file = null, $url = null) { public static function create($name = null, $file = null, $url = null) {
$getSkin = new GetSkin($name, $file, $url); return new static($name, $file, $url);
return $getSkin;
} }
/** /**
* Construct a new GetSkin Element * Construct a new GetSkin object
* *
* @param string $name (optional) Skin Name * @param string $name (optional) Skin name
* @param string $file (optional) Skin File * @param string $file (optional) Skin file
* @param string $url (optional) Skin Url * @param string $url (optional) Skin url
*/ */
public function __construct($name = null, $file = null, $url = null) { public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) { if (!is_null($name)) {
$this->setName($name); $this->setName($name);
} }
if ($file !== null) { if (!is_null($file)) {
$this->setFile($file); $this->setFile($file);
} }
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set the Name of the Skin * Set the name of the skin
* *
* @param string $name Skin Name * @param string $name Skin name
* @return \FML\ManiaCode\GetSkin * @return \FML\ManiaCode\GetSkin|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string) $name; $this->name = (string)$name;
return $this; return $this;
} }
/** /**
* Set the File of the Skin * Set the file of the skin
* *
* @param string $file Skin File * @param string $file Skin file
* @return \FML\ManiaCode\GetSkin * @return \FML\ManiaCode\GetSkin|static
*/ */
public function setFile($file) { public function setFile($file) {
$this->file = (string) $file; $this->file = (string)$file;
return $this; return $this;
} }
/** /**
* Set the Url of the Skin * Set the url of the skin
* *
* @param string $url Skin Url * @param string $url Skin url
* @return \FML\ManiaCode\GetSkin * @return \FML\ManiaCode\GetSkin|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string) $url; $this->url = (string)$url;
return $this; return $this;
} }
/** /**
*
* @see \FML\ManiaCode\Element::render() * @see \FML\ManiaCode\Element::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element going to a Link * ManiaCode Element for going to a link
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,46 +11,44 @@ namespace FML\ManiaCode;
*/ */
class Go_To implements Element { class Go_To implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'goto'; protected $tagName = 'goto';
protected $link = ''; protected $link = null;
/** /**
* Create a new Go_To Element * Create a new Go_To object
* *
* @param string $link (optional) Goto Link * @param string $link (optional) Goto link
* @return \FML\ManiaCode\Go_To * @return \FML\ManiaCode\Go_To|static
*/ */
public static function create($link = null) { public static function create($link = null) {
$goTo = new Go_To($link); return new static($link);
return $goTo;
} }
/** /**
* Construct a new Go_To Element * Construct a new Go_To object
* *
* @param string $link (optional) Goto Link * @param string $link (optional) Goto link
*/ */
public function __construct($link = null) { public function __construct($link = null) {
if ($link !== null) { if (!is_null($link)) {
$this->setLink($link); $this->setLink($link);
} }
} }
/** /**
* Set the Goto Link * Set link
* *
* @param string $link Goto Link * @param string $link Goto link
* @return \FML\ManiaCode\Go_To * @return \FML\ManiaCode\Go_To|static
*/ */
public function setLink($link) { public function setLink($link) {
$this->link = (string) $link; $this->link = (string)$link;
return $this; return $this;
} }
/** /**
*
* @see \FML\ManiaCode\Element::render() * @see \FML\ManiaCode\Element::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element installing a Macroblock * ManiaCode Element installing a macroblock
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,79 +11,77 @@ namespace FML\ManiaCode;
*/ */
class InstallMacroblock implements Element { class InstallMacroblock implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'install_macroblock'; protected $tagName = 'install_macroblock';
protected $name = ''; protected $name = null;
protected $file = ''; protected $file = null;
protected $url = ''; protected $url = null;
/** /**
* Create a new InstallMacroblock Element * Create a new InstallMacroblock object
* *
* @param string $name (optional) Macroblock Name * @param string $name (optional) Macroblock name
* @param string $url (optional) Macroblock Url * @param string $url (optional) Macroblock url
* @return \FML\ManiaCode\InstallMacroblock * @return \FML\ManiaCode\InstallMacroblock|static
*/ */
public static function create($name = null, $url = null) { public static function create($name = null, $url = null) {
$installMacroblock = new InstallMacroblock($name, $url); return new static($name, $url);
return $installMacroblock;
} }
/** /**
* Construct a new InstallMacroblock Element * Construct a new InstallMacroblock object
* *
* @param string $name (optional) Macroblock Name * @param string $name (optional) Macroblock name
* @param string $file (optional) Macroblock File * @param string $file (optional) Macroblock file
* @param string $url (optional) Macroblock Url * @param string $url (optional) Macroblock url
*/ */
public function __construct($name = null, $file = null, $url = null) { public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) { if (!is_null($name)) {
$this->setName($name); $this->setName($name);
} }
if ($file !== null) { if (!is_null($file)) {
$this->setFile($file); $this->setFile($file);
} }
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set the Name of the Macroblock * Set the name of the macroblock
* *
* @param string $name Macroblock Name * @param string $name Macroblock name
* @return \FML\ManiaCode\InstallMacroblock * @return \FML\ManiaCode\InstallMacroblock|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string) $name; $this->name = (string)$name;
return $this; return $this;
} }
/** /**
* Set the File of the Macroblock * Set the file of the macroblock
* *
* @param string $file Macroblock File * @param string $file Macroblock file
* @return \FML\ManiaCode\InstallMacroblock * @return \FML\ManiaCode\InstallMacroblock|static
*/ */
public function setFile($file) { public function setFile($file) {
$this->file = (string) $file; $this->file = (string)$file;
return $this; return $this;
} }
/** /**
* Set the Url of the Macroblock * Set the url of the macroblock
* *
* @param string $url Macroblock Url * @param string $url Macroblock url
* @return \FML\ManiaCode\InstallMacroblock * @return \FML\ManiaCode\InstallMacroblock|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string) $url; $this->url = (string)$url;
return $this; return $this;
} }
/** /**
*
* @see \FML\ManiaCode\Element::render() * @see \FML\ManiaCode\Element::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element installing a Map * ManiaCode Element installing a map
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,44 +11,43 @@ namespace FML\ManiaCode;
*/ */
class InstallMap implements Element { class InstallMap implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'install_map'; protected $tagName = 'install_map';
protected $name = ''; protected $name = null;
protected $url = ''; protected $url = null;
/** /**
* Create a new InstallMap Element * Create a new InstallMap object
* *
* @param string $name (optional) Map Name * @param string $name (optional) Map name
* @param string $url (optional) Map Url * @param string $url (optional) Map url
* @return \FML\ManiaCode\InstallMap * @return \FML\ManiaCode\InstallMap|static
*/ */
public static function create($name = null, $url = null) { public static function create($name = null, $url = null) {
$installMap = new InstallMap($name, $url); return new static($name, $url);
return $installMap;
} }
/** /**
* Construct a new InstallMap Element * Construct a new InstallMap object
* *
* @param string $name (optional) Map Name * @param string $name (optional) Map name
* @param string $url (optional) Map Url * @param string $url (optional) Map url
*/ */
public function __construct($name = null, $url = null) { public function __construct($name = null, $url = null) {
if ($name !== null) { if (!is_null($name)) {
$this->setName($name); $this->setName($name);
} }
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set the Name of the Map * Set the name of the map
* *
* @param string $name Map Name * @param string $name Map name
* @return \FML\ManiaCode\InstallMap * @return \FML\ManiaCode\InstallMap|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -56,10 +55,10 @@ class InstallMap implements Element {
} }
/** /**
* Set the Url of the Map * Set the url of the map
* *
* @param string $url Map Url * @param string $url Map url
* @return \FML\ManiaCode\InstallMap * @return \FML\ManiaCode\InstallMap|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element installing a Title Pack * ManiaCode Element installing a title pack
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,50 +11,49 @@ namespace FML\ManiaCode;
*/ */
class InstallPack implements Element { class InstallPack implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'install_pack'; protected $tagName = 'install_pack';
protected $name = ''; protected $name = null;
protected $file = ''; protected $file = null;
protected $url = ''; protected $url = null;
/** /**
* Create a new InstallPack Element * Create a new InstallPack object
* *
* @param string $name (optional) Pack Name * @param string $name (optional) Pack name
* @param string $file (optional) Pack File * @param string $file (optional) Pack file
* @param string $url (optional) Pack Url * @param string $url (optional) Pack url
* @return \FML\ManiaCode\InstallPack * @return \FML\ManiaCode\InstallPack|static
*/ */
public static function create($name = null, $file = null, $url = null) { public static function create($name = null, $file = null, $url = null) {
$installPack = new InstallPack($name, $file, $url); return new static($name, $file, $url);
return $installPack;
} }
/** /**
* Construct a new InstallPack Element * Construct a new InstallPack object
* *
* @param string $name (optional) Pack Name * @param string $name (optional) Pack name
* @param string $file (optional) Pack File * @param string $file (optional) Pack file
* @param string $url (optional) Pack Url * @param string $url (optional) Pack url
*/ */
public function __construct($name = null, $file = null, $url = null) { public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) { if (!is_null($name)) {
$this->setName($name); $this->setName($name);
} }
if ($file !== null) { if (!is_null($file)) {
$this->setFile($file); $this->setFile($file);
} }
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set the Name of the Pack * Set the name of the pack
* *
* @param string $name Pack Name * @param string $name Pack name
* @return \FML\ManiaCode\InstallPack * @return \FML\ManiaCode\InstallPack|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -62,10 +61,10 @@ class InstallPack implements Element {
} }
/** /**
* Set the File of the Pack * Set the file of the pack
* *
* @param string $file Pack File * @param string $file Pack file
* @return \FML\ManiaCode\InstallPack * @return \FML\ManiaCode\InstallPack|static
*/ */
public function setFile($file) { public function setFile($file) {
$this->file = (string)$file; $this->file = (string)$file;
@ -73,10 +72,10 @@ class InstallPack implements Element {
} }
/** /**
* Set the Url of the Pack * Set the url of the pack
* *
* @param string $url Pack Url * @param string $url Pack url
* @return \FML\ManiaCode\InstallPack * @return \FML\ManiaCode\InstallPack|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element installing a Replay * ManiaCode Element installing a replay
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,44 +11,43 @@ namespace FML\ManiaCode;
*/ */
class InstallReplay implements Element { class InstallReplay implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'install_replay'; protected $tagName = 'install_replay';
protected $name = ''; protected $name = null;
protected $url = ''; protected $url = null;
/** /**
* Create a new InstallReplay Element * Create a new InstallReplay object
* *
* @param string $name (optional) Replay Name * @param string $name (optional) Replay name
* @param string $url (optional) Replay Url * @param string $url (optional) Replay url
* @return \FML\ManiaCode\InstallReplay * @return \FML\ManiaCode\InstallReplay|static
*/ */
public static function create($name = null, $url = null) { public static function create($name = null, $url = null) {
$installReplay = new InstallReplay($name, $url); return new static($name, $url);
return $installReplay;
} }
/** /**
* Construct a new InstallReplay Element * Construct a new InstallReplay object
* *
* @param string $name (optional) Replay Name * @param string $name (optional) Replay name
* @param string $url (optional) Replay Url * @param string $url (optional) Replay url
*/ */
public function __construct($name = null, $url = null) { public function __construct($name = null, $url = null) {
if ($name !== null) { if (!is_null($name)) {
$this->setName($name); $this->setName($name);
} }
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set the Name of the Replay * Set the name of the replay
* *
* @param string $name Replay Name * @param string $name Replay name
* @return \FML\ManiaCode\InstallReplay * @return \FML\ManiaCode\InstallReplay|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -56,10 +55,10 @@ class InstallReplay implements Element {
} }
/** /**
* Set the Url of the Replay * Set the url of the replay
* *
* @param string $url Replay Url * @param string $url Replay url
* @return \FML\ManiaCode\InstallReplay * @return \FML\ManiaCode\InstallReplay|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element installing a Script * ManiaCode Element installing a script
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,50 +11,49 @@ namespace FML\ManiaCode;
*/ */
class InstallScript implements Element { class InstallScript implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'install_script'; protected $tagName = 'install_script';
protected $name = ''; protected $name = null;
protected $file = ''; protected $file = null;
protected $url = ''; protected $url = null;
/** /**
* Create a new InstallScript Element * Create a new InstallScript object
* *
* @param string $name (optional) Script Name * @param string $name (optional) Script name
* @param string $file (optional) Script File * @param string $file (optional) Script file
* @param string $url (optional) Script Url * @param string $url (optional) Script url
* @return \FML\ManiaCode\InstallScript * @return \FML\ManiaCode\InstallScript|static
*/ */
public static function create($name = null, $file = null, $url = null) { public static function create($name = null, $file = null, $url = null) {
$installScript = new InstallScript($name, $file, $url); return new static($name, $file, $url);
return $installScript;
} }
/** /**
* Construct a new InstallScript Element * Construct a new InstallScript object
* *
* @param string $name (optional) Script Name * @param string $name (optional) Script name
* @param string $file (optional) Script File * @param string $file (optional) Script file
* @param string $url (optional) Script Url * @param string $url (optional) Script url
*/ */
public function __construct($name = null, $file = null, $url = null) { public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) { if (!is_null($name)) {
$this->setName($name); $this->setName($name);
} }
if ($file !== null) { if (!is_null($file)) {
$this->setFile($file); $this->setFile($file);
} }
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set the Name of the Script * Set the name of the script
* *
* @param string $name Script Name * @param string $name Script name
* @return \FML\ManiaCode\InstallScript * @return \FML\ManiaCode\InstallScript|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -62,10 +61,10 @@ class InstallScript implements Element {
} }
/** /**
* Set the File of the Script * Set the file of the script
* *
* @param string $file Script File * @param string $file Script file
* @return \FML\ManiaCode\InstallScript * @return \FML\ManiaCode\InstallScript|static
*/ */
public function setFile($file) { public function setFile($file) {
$this->file = (string)$file; $this->file = (string)$file;
@ -73,10 +72,10 @@ class InstallScript implements Element {
} }
/** /**
* Set the Url of the Script * Set the url of the script
* *
* @param string $url Script Url * @param string $url Script url
* @return \FML\ManiaCode\InstallScript * @return \FML\ManiaCode\InstallScript|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element installing a Skin * ManiaCode Element installing a skin
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,50 +11,49 @@ namespace FML\ManiaCode;
*/ */
class InstallSkin implements Element { class InstallSkin implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'install_skin'; protected $tagName = 'install_skin';
protected $name = ''; protected $name = null;
protected $file = ''; protected $file = null;
protected $url = ''; protected $url = null;
/** /**
* Create a new InstallSkin Element * Create a new InstallSkin object
* *
* @param string $name (optional) Skin Name * @param string $name (optional) Skin name
* @param string $file (optional) Skin File * @param string $file (optional) Skin file
* @param string $url (optional) Skin Url * @param string $url (optional) Skin url
* @return \FML\ManiaCode\InstallSkin * @return \FML\ManiaCode\InstallSkin|static
*/ */
public static function create($name = null, $file = null, $url = null) { public static function create($name = null, $file = null, $url = null) {
$installSkin = new InstallSkin($name, $file, $url); return new static($name, $file, $url);
return $installSkin;
} }
/** /**
* Construct a new InstallSkin Element * Construct a new InstallSkin object
* *
* @param string $name (optional) Skin Name * @param string $name (optional) Skin name
* @param string $file (optional) Skin File * @param string $file (optional) Skin file
* @param string $url (optional) Skin Url * @param string $url (optional) Skin url
*/ */
public function __construct($name = null, $file = null, $url = null) { public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) { if (!is_null($name)) {
$this->setName($name); $this->setName($name);
} }
if ($file !== null) { if (!is_null($file)) {
$this->setFile($file); $this->setFile($file);
} }
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set the Name of the Skin * Set the name of the skin
* *
* @param string $name Skin Name * @param string $name Skin name
* @return \FML\ManiaCode\InstallSkin * @return \FML\ManiaCode\InstallSkin|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -62,10 +61,10 @@ class InstallSkin implements Element {
} }
/** /**
* Set the File of the Skin * Set the file of the skin
* *
* @param string $file Skin File * @param string $file Skin file
* @return \FML\ManiaCode\InstallSkin * @return \FML\ManiaCode\InstallSkin|static
*/ */
public function setFile($file) { public function setFile($file) {
$this->file = (string)$file; $this->file = (string)$file;
@ -73,10 +72,10 @@ class InstallSkin implements Element {
} }
/** /**
* Set the Url of the Skin * Set the url of the skin
* *
* @param string $url Skin Url * @param string $url Skin url
* @return \FML\ManiaCode\InstallSkin * @return \FML\ManiaCode\InstallSkin|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element joining a Server * ManiaCode Element for joining a server
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,58 +11,57 @@ namespace FML\ManiaCode;
*/ */
class JoinServer implements Element { class JoinServer implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'join_server'; protected $tagName = 'join_server';
protected $login = ''; protected $login = null;
protected $ip = null; protected $serverIp = null;
protected $port = null; protected $serverPort = null;
/** /**
* Create a new JoinServer Element * Create a new JoinServer object
* *
* @param string $login (optional) Server Login * @param string $login (optional) Server login
* @return \FML\ManiaCode\JoinServer * @return \FML\ManiaCode\JoinServer|static
*/ */
public static function create($login = null) { public static function create($login = null) {
$joinServer = new JoinServer($login); return new static($login);
return $joinServer;
} }
/** /**
* Construct a new JoinServer Element * Construct a new JoinServer object
* *
* @param string $login (optional) Server Login * @param string $login (optional) Server login
*/ */
public function __construct($login = null) { public function __construct($login = null) {
if ($login !== null) { if (!is_null($login)) {
$this->setLogin($login); $this->setLogin($login);
} }
} }
/** /**
* Set the Server Login * Set the server login
* *
* @param string $login Server Login * @param string $login Server login
* @return \FML\ManiaCode\JoinServer * @return \FML\ManiaCode\JoinServer|static
*/ */
public function setLogin($login) { public function setLogin($login) {
$this->login = (string)$login; $this->login = (string)$login;
$this->ip = null; $this->serverIp = null;
$this->port = null; $this->serverPort = null;
return $this; return $this;
} }
/** /**
* Set the Server Ip and Port * Set the server ip and port
* *
* @param string $ip Server Ip * @param string $serverIp Server ip
* @param int $port Server Port * @param int $serverPort Server port
* @return \FML\ManiaCode\JoinServer * @return \FML\ManiaCode\JoinServer|static
*/ */
public function setIp($ip, $port) { public function setIp($serverIp, $serverPort) {
$this->ip = (string)$ip; $this->serverIp = (string)$serverIp;
$this->port = (int)$port; $this->serverPort = (int)$serverPort;
$this->login = null; $this->login = null;
return $this; return $this;
} }
@ -72,11 +71,11 @@ class JoinServer implements Element {
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName); $xmlElement = $domDocument->createElement($this->tagName);
if ($this->ip === null) { if (is_null($this->serverIp)) {
$loginElement = $domDocument->createElement('login', $this->login); $loginElement = $domDocument->createElement('login', $this->login);
$xmlElement->appendChild($loginElement); $xmlElement->appendChild($loginElement);
} else { } else {
$ipElement = $domDocument->createElement('ip', $this->ip . ':' . $this->port); $ipElement = $domDocument->createElement('ip', $this->serverIp . ':' . $this->serverPort);
$xmlElement->appendChild($ipElement); $xmlElement->appendChild($ipElement);
} }
return $xmlElement; return $xmlElement;

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element playing a Map * ManiaCode Element for playing a map
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,44 +11,43 @@ namespace FML\ManiaCode;
*/ */
class PlayMap implements Element { class PlayMap implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'play_map'; protected $tagName = 'play_map';
protected $name = ''; protected $name = null;
protected $url = ''; protected $url = null;
/** /**
* Create a new PlayMap Element * Create a new PlayMap object
* *
* @param string $name (optional) Map Name * @param string $name (optional) Map name
* @param string $url (optional) Map Url * @param string $url (optional) Map url
* @return \FML\ManiaCode\PlayMap * @return \FML\ManiaCode\PlayMap|static
*/ */
public static function create($name = null, $url = null) { public static function create($name = null, $url = null) {
$playMap = new PlayMap($name, $url); return new static($name, $url);
return $playMap;
} }
/** /**
* Construct a new PlayMap Element * Construct a new PlayMap object
* *
* @param string $name (optional) Map Name * @param string $name (optional) Map name
* @param string $url (optional) Map Url * @param string $url (optional) Map url
*/ */
public function __construct($name = null, $url = null) { public function __construct($name = null, $url = null) {
if ($name !== null) { if (!is_null($name)) {
$this->setName($name); $this->setName($name);
} }
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set the Name of the Map * Set the name of the map
* *
* @param string $name Map Name * @param string $name Map name
* @return \FML\ManiaCode\PlayMap * @return \FML\ManiaCode\PlayMap|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -56,10 +55,10 @@ class PlayMap implements Element {
} }
/** /**
* Set the Url of the Map * Set the url of the map
* *
* @param string $url Map Url * @param string $url Map url
* @return \FML\ManiaCode\PlayMap * @return \FML\ManiaCode\PlayMap|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element playing a Replay * ManiaCode Element playing a replay
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,44 +11,43 @@ namespace FML\ManiaCode;
*/ */
class PlayReplay implements Element { class PlayReplay implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'play_replay'; protected $tagName = 'play_replay';
protected $name = ''; protected $name = null;
protected $url = ''; protected $url = null;
/** /**
* Create a new PlayReplay Element * Create a new PlayReplay object
* *
* @param string $name (optional) Replay Name * @param string $name (optional) Replay name
* @param string $url (optional) Replay Url * @param string $url (optional) Replay url
* @return \FML\ManiaCode\PlayReplay * @return \FML\ManiaCode\PlayReplay|static
*/ */
public static function create($name = null, $url = null) { public static function create($name = null, $url = null) {
$playReplay = new PlayReplay($name, $url); return new static($name, $url);
return $playReplay;
} }
/** /**
* Construct a new PlayReplay Element * Construct a new PlayReplay object
* *
* @param string $name (optional) Replay Name * @param string $name (optional) Replay name
* @param string $url (optional) Replay Url * @param string $url (optional) Replay url
*/ */
public function __construct($name = null, $url = null) { public function __construct($name = null, $url = null) {
if ($name !== null) { if (!is_null($name)) {
$this->setName($name); $this->setName($name);
} }
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set the Name of the Replay * Set the name of the replay
* *
* @param string $name Replay Name * @param string $name Replay name
* @return \FML\ManiaCode\PlayReplay * @return \FML\ManiaCode\PlayReplay|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -56,10 +55,10 @@ class PlayReplay implements Element {
} }
/** /**
* Set the Url of the Replay * Set the url of the replay
* *
* @param string $url Replay Url * @param string $url Replay url
* @return \FML\ManiaCode\PlayReplay * @return \FML\ManiaCode\PlayReplay|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;

View File

@ -11,38 +11,37 @@ namespace FML\ManiaCode;
*/ */
class ShowMessage implements Element { class ShowMessage implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'show_message'; protected $tagName = 'show_message';
protected $message = ''; protected $message = null;
/** /**
* Create a new ShowMessage Element * Create a new ShowMessage object
* *
* @param string $message (optional) Message Text * @param string $message (optional) Message text
* @return \FML\ManiaCode\ShowMessage * @return \FML\ManiaCode\ShowMessage|static
*/ */
public static function create($message = null) { public static function create($message = null) {
$showMessage = new ShowMessage($message); return new static($message);
return $showMessage;
} }
/** /**
* Construct a new ShowMessage Element * Construct a new ShowMessage object
* *
* @param string $message (optional) Message Text * @param string $message (optional) Message text
*/ */
public function __construct($message = null) { public function __construct($message = null) {
if ($message !== null) { if (!is_null($message)) {
$this->setMessage($message); $this->setMessage($message);
} }
} }
/** /**
* Set the displayed Message Text * Set the message text
* *
* @param string $message Message Text * @param string $message Message text
* @return \FML\ManiaCode\ShowMessage * @return \FML\ManiaCode\ShowMessage|static
*/ */
public function setMessage($message) { public function setMessage($message) {
$this->message = (string)$message; $this->message = (string)$message;

View File

@ -3,7 +3,7 @@
namespace FML\ManiaCode; namespace FML\ManiaCode;
/** /**
* ManiaCode Element viewing a Replay * ManiaCode Element for viewing a replay
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,44 +11,43 @@ namespace FML\ManiaCode;
*/ */
class ViewReplay implements Element { class ViewReplay implements Element {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'view_replay'; protected $tagName = 'view_replay';
protected $name = ''; protected $name = null;
protected $url = ''; protected $url = null;
/** /**
* Create a new ViewReplay Element * Create a new ViewReplay object
* *
* @param string $name (optional) Replay Name * @param string $name (optional) Replay name
* @param string $url (optional) Replay Url * @param string $url (optional) Replay url
* @return \FML\ManiaCode\ViewReplay * @return \FML\ManiaCode\ViewReplay|static
*/ */
public static function create($name = null, $url = null) { public static function create($name = null, $url = null) {
$viewReplay = new ViewReplay($name, $url); return new static($name, $url);
return $viewReplay;
} }
/** /**
* Construct a new ViewReplay Element * Construct a new ViewReplay object
* *
* @param string $name (optional) Replay Name * @param string $name (optional) Replay name
* @param string $url (optional) Replay Url * @param string $url (optional) Replay url
*/ */
public function __construct($name = null, $url = null) { public function __construct($name = null, $url = null) {
if ($name !== null) { if (!is_null($name)) {
$this->setName($name); $this->setName($name);
} }
if ($url !== null) { if (!is_null($url)) {
$this->setUrl($url); $this->setUrl($url);
} }
} }
/** /**
* Set the Name of the Replay * Set the name of the replay
* *
* @param string $name Replay Name * @param string $name Replay name
* @return \FML\ManiaCode\ViewReplay * @return \FML\ManiaCode\ViewReplay|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -56,10 +55,10 @@ class ViewReplay implements Element {
} }
/** /**
* Set the Url of the Replay * Set the url of the replay
* *
* @param string $url Replay Url * @param string $url Replay url
* @return \FML\ManiaCode\ViewReplay * @return \FML\ManiaCode\ViewReplay|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;

View File

@ -26,15 +26,16 @@ class ManiaLink {
const BACKGROUND_TITLE = 'title'; const BACKGROUND_TITLE = 'title';
/* /*
* Protected Properties * Protected properties
*/ */
protected $encoding = 'utf-8'; protected $encoding = 'utf-8';
protected $tagName = 'manialink'; protected $tagName = 'manialink';
protected $id = ''; protected $maniaLinkId = null;
protected $version = 1; protected $version = 1;
protected $background = ''; protected $background = null;
protected $navigable3d = 1; protected $navigable3d = 1;
protected $timeout = 0; protected $timeout = 0;
/** @var Renderable[] $children */
protected $children = array(); protected $children = array();
/** @var Dico $dico */ /** @var Dico $dico */
protected $dico = null; protected $dico = null;
@ -44,32 +45,31 @@ class ManiaLink {
protected $script = null; protected $script = null;
/** /**
* Create a new ManiaLink Object * Create a new ManiaLink object
* *
* @param string $id (optional) ManiaLink Id * @param string $maniaLinkId (optional) ManiaLink id
* @return \FML\ManiaLink * @return \FML\ManiaLink|static
*/ */
public static function create($id = null) { public static function create($maniaLinkId = null) {
$maniaLink = new ManiaLink($id); return new static($maniaLinkId);
return $maniaLink;
} }
/** /**
* Construct a new ManiaLink Object * Construct a new ManiaLink object
* *
* @param string $id (optional) ManiaLink Id * @param string $maniaLinkId (optional) ManiaLink id
*/ */
public function __construct($id = null) { public function __construct($maniaLinkId = null) {
if ($id !== null) { if (!is_null($maniaLinkId)) {
$this->setId($id); $this->setId($maniaLinkId);
} }
} }
/** /**
* Set XML Encoding * Set XML encoding
* *
* @param string $encoding XML Encoding * @param string $encoding XML encoding
* @return \FML\ManiaLink * @return \FML\ManiaLink|static
*/ */
public function setXmlEncoding($encoding) { public function setXmlEncoding($encoding) {
$this->encoding = (string)$encoding; $this->encoding = (string)$encoding;
@ -77,30 +77,30 @@ class ManiaLink {
} }
/** /**
* Set ManiaLink Id * Set ManiaLink id
* *
* @param string $id ManiaLink Id * @param string $maniaLinkId ManiaLink id
* @return \FML\ManiaLink * @return \FML\ManiaLink|static
*/ */
public function setId($id) { public function setId($maniaLinkId) {
$this->id = (string)$id; $this->maniaLinkId = (string)$maniaLinkId;
return $this; return $this;
} }
/** /**
* Get ManiaLink Id * Get ManiaLink id
* *
* @return string * @return string
*/ */
public function getId() { public function getId() {
return $this->id; return $this->maniaLinkId;
} }
/** /**
* Set Background * Set background
* *
* @param string $background Background Value * @param string $background Background value
* @return \FML\ManiaLink * @return \FML\ManiaLink|static
*/ */
public function setBackground($background) { public function setBackground($background) {
$this->background = (string)$background; $this->background = (string)$background;
@ -108,10 +108,10 @@ class ManiaLink {
} }
/** /**
* Set Navigable3d * Set navigable3d
* *
* @param bool $navigable3d Whether the manialink should be 3d navigable * @param bool $navigable3d Whether the manialink should be 3d navigable
* @return \FML\ManiaLink * @return \FML\ManiaLink|static
*/ */
public function setNavigable3d($navigable3d) { public function setNavigable3d($navigable3d) {
$this->navigable3d = ($navigable3d ? 1 : 0); $this->navigable3d = ($navigable3d ? 1 : 0);
@ -119,10 +119,10 @@ class ManiaLink {
} }
/** /**
* Set Timeout * Set timeout
* *
* @param int $timeout Timeout Duration * @param int $timeout Timeout duration
* @return \FML\ManiaLink * @return \FML\ManiaLink|static
*/ */
public function setTimeout($timeout) { public function setTimeout($timeout) {
$this->timeout = (int)$timeout; $this->timeout = (int)$timeout;
@ -130,10 +130,10 @@ class ManiaLink {
} }
/** /**
* Add an Element to the ManiaLink * Add an element to the ManiaLink
* *
* @param Renderable $child Child Element to add * @param Renderable $child Child element to add
* @return \FML\ManiaLink * @return \FML\ManiaLink|static
*/ */
public function add(Renderable $child) { public function add(Renderable $child) {
if (!in_array($child, $this->children, true)) { if (!in_array($child, $this->children, true)) {
@ -143,9 +143,9 @@ class ManiaLink {
} }
/** /**
* Remove all Elements from the ManiaLinks * Remove all elements from the ManiaLink
* *
* @return \FML\ManiaLink * @return \FML\ManiaLink|static
*/ */
public function removeChildren() { public function removeChildren() {
$this->children = array(); $this->children = array();
@ -155,7 +155,7 @@ class ManiaLink {
/** /**
* Set the Dictionary of the ManiaLink * Set the Dictionary of the ManiaLink
* *
* @param Dico $dico The Dictionary to use * @param Dico $dico Dictionary for the ManiaLink
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setDico(Dico $dico) { public function setDico(Dico $dico) {
@ -164,9 +164,9 @@ class ManiaLink {
} }
/** /**
* Get the current Dictionary of the ManiaLink * Get the Dictionary of the ManiaLink
* *
* @param bool $createIfEmpty (optional) Whether the Dico Object should be created if it's not set yet * @param bool $createIfEmpty (optional) Whether the Dico object should be created if it's not set
* @return \FML\Elements\Dico * @return \FML\Elements\Dico
*/ */
public function getDico($createIfEmpty = true) { public function getDico($createIfEmpty = true) {
@ -179,8 +179,8 @@ class ManiaLink {
/** /**
* Set the Stylesheet of the ManiaLink * Set the Stylesheet of the ManiaLink
* *
* @param Stylesheet $stylesheet Stylesheet Object * @param Stylesheet $stylesheet Stylesheet for the ManiaLink
* @return \FML\ManiaLink * @return \FML\ManiaLink|static
*/ */
public function setStylesheet(Stylesheet $stylesheet) { public function setStylesheet(Stylesheet $stylesheet) {
$this->stylesheet = $stylesheet; $this->stylesheet = $stylesheet;
@ -190,7 +190,7 @@ class ManiaLink {
/** /**
* Get the Stylesheet of the ManiaLink * Get the Stylesheet of the ManiaLink
* *
* @param bool $createIfEmpty (optional) Whether the Script Object should be created if it's not set yet * @param bool $createIfEmpty (optional) Whether the Stylesheet object should be created if it's not set
* @return \FML\Stylesheet\Stylesheet * @return \FML\Stylesheet\Stylesheet
*/ */
public function getStylesheet($createIfEmpty = true) { public function getStylesheet($createIfEmpty = true) {
@ -203,8 +203,8 @@ class ManiaLink {
/** /**
* Set the Script of the ManiaLink * Set the Script of the ManiaLink
* *
* @param Script $script The Script for the ManiaLink * @param Script $script Script for the ManiaLink
* @return \FML\ManiaLink * @return \FML\ManiaLink|static
*/ */
public function setScript(Script $script) { public function setScript(Script $script) {
$this->script = $script; $this->script = $script;
@ -214,7 +214,7 @@ class ManiaLink {
/** /**
* Get the current Script of the ManiaLink * Get the current Script of the ManiaLink
* *
* @param bool $createIfEmpty (optional) Whether the Script Object should be created if it's not set yet * @param bool $createIfEmpty (optional) Whether the Script object should be created if it's not set
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function getScript($createIfEmpty = true) { public function getScript($createIfEmpty = true) {
@ -225,10 +225,10 @@ class ManiaLink {
} }
/** /**
* Render the XML Document * Render the XML document
* *
* @param bool (optional) $echo If the XML Text should be echoed and the Content-Type Header should be set * @param bool $echo (optional) If the XML text should be echoed and the Content-Type header should be set
* @param \DOMDocument $domDocument (optional) DOMDocument for which the XML Element should be created * @param \DOMDocument $domDocument (optional) DOMDocument for which the XML element should be created
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($echo = false, $domDocument = null) { public function render($echo = false, $domDocument = null) {
@ -241,8 +241,8 @@ class ManiaLink {
if (!$isChild) { if (!$isChild) {
$domDocument->appendChild($maniaLink); $domDocument->appendChild($maniaLink);
} }
if (strlen($this->id) > 0) { if (strlen($this->maniaLinkId) > 0) {
$maniaLink->setAttribute('id', $this->id); $maniaLink->setAttribute('id', $this->maniaLinkId);
} }
if ($this->version) { if ($this->version) {
$maniaLink->setAttribute('version', $this->version); $maniaLink->setAttribute('version', $this->version);
@ -263,7 +263,6 @@ class ManiaLink {
} }
$scriptFeatures = array(); $scriptFeatures = array();
foreach ($this->children as $child) { foreach ($this->children as $child) {
/** @var Renderable $child */
$childXml = $child->render($domDocument, $this->getScript()); $childXml = $child->render($domDocument, $this->getScript());
$maniaLink->appendChild($childXml); $maniaLink->appendChild($childXml);
if ($child instanceof ScriptFeatureable) { if ($child instanceof ScriptFeatureable) {
@ -295,13 +294,11 @@ class ManiaLink {
} }
/** /**
* Get String Representation * Get string representation
* *
* @return string * @return string
*/ */
public function __toString() { public function __toString() {
$domDocument = $this->render(); return $this->render()->saveXML();
$xmlText = $domDocument->saveXML();
return $xmlText;
} }
} }

View File

@ -15,31 +15,25 @@ class ManiaLinks {
*/ */
protected $encoding = 'utf-8'; protected $encoding = 'utf-8';
protected $tagName = 'manialinks'; protected $tagName = 'manialinks';
/** @var ManiaLink[] $children */
protected $children = array(); protected $children = array();
/** @var CustomUI $customUI */ /** @var CustomUI $customUI */
protected $customUI = null; protected $customUI = null;
/** /**
* Create a new ManiaLinks Object * Create a new ManiaLinks object
* *
* @return \FML\ManiaLinks * @return \FML\ManiaLinks|static
*/ */
public static function create() { public static function create() {
$maniaLinks = new ManiaLinks(); return new static();
return $maniaLinks;
} }
/** /**
* Construct a new ManiaLinks Object * Set XML encoding
*/
public function __construct() {
}
/**
* Set XML Encoding
* *
* @param string $encoding XML Encoding * @param string $encoding XML encoding
* @return \FML\ManiaLinks * @return \FML\ManiaLinks|static
*/ */
public function setXmlEncoding($encoding) { public function setXmlEncoding($encoding) {
$this->encoding = (string)$encoding; $this->encoding = (string)$encoding;
@ -47,7 +41,7 @@ class ManiaLinks {
} }
/** /**
* Add a Child ManiaLink * Add a child ManiaLink
* *
* @param ManiaLink $child Child ManiaLink * @param ManiaLink $child Child ManiaLink
* @return \FML\ManiaLinks * @return \FML\ManiaLinks
@ -60,9 +54,9 @@ class ManiaLinks {
} }
/** /**
* Remove all Child ManiaLinks * Remove all child ManiaLinks
* *
* @return \FML\ManiaLinks * @return \FML\ManiaLinks|static
*/ */
public function removeChildren() { public function removeChildren() {
$this->children = array(); $this->children = array();
@ -72,8 +66,8 @@ class ManiaLinks {
/** /**
* Set the CustomUI * Set the CustomUI
* *
* @param CustomUI $customUI The CustomUI Object * @param CustomUI $customUI CustomUI object
* @return \FML\ManiaLinks * @return \FML\ManiaLinks|static
*/ */
public function setCustomUI(CustomUI $customUI) { public function setCustomUI(CustomUI $customUI) {
$this->customUI = $customUI; $this->customUI = $customUI;
@ -81,9 +75,9 @@ class ManiaLinks {
} }
/** /**
* Get the current CustomUI * Get the CustomUI
* *
* @param bool $createIfEmpty (optional) Whether the CustomUI Object should be created if it's not set yet * @param bool $createIfEmpty (optional) Whether the CustomUI object should be created if it's not set
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function getCustomUI($createIfEmpty = true) { public function getCustomUI($createIfEmpty = true) {
@ -94,9 +88,9 @@ class ManiaLinks {
} }
/** /**
* Render the XML Document * Render the XML document
* *
* @param bool (optional) $echo Whether the XML Text should be echoed and the Content-Type Header should be set * @param bool (optional) $echo Whether the XML text should be echoed and the Content-Type header should be set
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($echo = false) { public function render($echo = false) {
@ -105,7 +99,6 @@ class ManiaLinks {
$maniaLinks = $domDocument->createElement($this->tagName); $maniaLinks = $domDocument->createElement($this->tagName);
$domDocument->appendChild($maniaLinks); $domDocument->appendChild($maniaLinks);
foreach ($this->children as $child) { foreach ($this->children as $child) {
/** @var ManiaLink $child */
$childXml = $child->render(false, $domDocument); $childXml = $child->render(false, $domDocument);
$maniaLinks->appendChild($childXml); $maniaLinks->appendChild($childXml);
} }
@ -121,13 +114,11 @@ class ManiaLinks {
} }
/** /**
* Get String Representation * Get string representation
* *
* @return string * @return string
*/ */
public function __toString() { public function __toString() {
$domDocument = $this->render(); return $this->render()->saveXML();
$xmlText = $domDocument->saveXML();
return $xmlText;
} }
} }

View File

@ -17,40 +17,38 @@ use FML\Types\SubStyleable;
*/ */
class CheckBoxDesign implements Styleable, SubStyleable { class CheckBoxDesign implements Styleable, SubStyleable {
/* /*
* Protected Properties * Protected properties
*/ */
protected $url = null; protected $url = null;
protected $style = null; protected $style = null;
protected $subStyle = null; protected $subStyle = null;
/** /**
* Create the Default Enabled Design * Create the default enabled Design
* *
* @return \FML\Models\CheckBoxDesign * @return \FML\Models\CheckBoxDesign|static
*/ */
public static function defaultEnabledDesign() { public static function defaultEnabledDesign() {
$checkBoxDesign = new CheckBoxDesign(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_LvlGreen); return new static(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_Check);
return $checkBoxDesign;
} }
/** /**
* Create the Default Disabled Design * Create the default disabled Design
* *
* @return \FML\Models\CheckBoxDesign * @return \FML\Models\CheckBoxDesign|static
*/ */
public static function defaultDisabledDesign() { public static function defaultDisabledDesign() {
$checkBoxDesign = new CheckBoxDesign(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_LvlRed); return new static(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_Check);
return $checkBoxDesign;
} }
/** /**
* Create a new CheckBox Design * Construct a new CheckBox Design object
* *
* @param string $style Style Name or Image Url * @param string $style Style name or image url
* @param string $subStyle SubStyle Name * @param string $subStyle (optional) SubStyle name
*/ */
public function __construct($style, $subStyle = null) { public function __construct($style, $subStyle = null) {
if ($subStyle === null) { if (is_null($subStyle)) {
$this->setImageUrl($style); $this->setImageUrl($style);
} else { } else {
$this->setStyle($style); $this->setStyle($style);
@ -59,10 +57,10 @@ class CheckBoxDesign implements Styleable, SubStyleable {
} }
/** /**
* Set the Image Url * Set the image url
* *
* @param string $url Image Url * @param string $url Image url
* @return \FML\Models\CheckBoxDesign * @return \FML\Models\CheckBoxDesign|static
*/ */
public function setImageUrl($url) { public function setImageUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;
@ -102,7 +100,7 @@ class CheckBoxDesign implements Styleable, SubStyleable {
* Apply the Design to the given Quad * Apply the Design to the given Quad
* *
* @param Quad $quad CheckBox Quad * @param Quad $quad CheckBox Quad
* @return \FML\Models\CheckBoxDesign * @return \FML\Models\CheckBoxDesign|static
*/ */
public function applyToQuad(Quad $quad) { public function applyToQuad(Quad $quad) {
$quad->setImage($this->url); $quad->setImage($this->url);
@ -111,19 +109,20 @@ class CheckBoxDesign implements Styleable, SubStyleable {
} }
/** /**
* Get the CheckBox Design String * Get the CheckBox Design string
* *
* @param bool $escaped (optional) Whether the String should be escaped for the Script * @param bool $escaped (optional) Whether the string should be escaped for the Script
* @param bool $addApostrophes (optional) Whether to add apostrophes before and after the text
* @return string * @return string
*/ */
public function getDesignString($escaped = true) { public function getDesignString($escaped = true, $addApostrophes = true) {
if ($this->url !== null) { if (!is_null($this->url)) {
$string = $this->url; $string = $this->url;
} else { } else {
$string = $this->style . '|' . $this->subStyle;; $string = $this->style . '|' . $this->subStyle;;
} }
if ($escaped) { if ($escaped) {
return Builder::escapeText($string); return Builder::escapeText($string, $addApostrophes);
} }
return $string; return $string;
} }

View File

@ -3,20 +3,24 @@
namespace FML\Script; namespace FML\Script;
/** /**
* Builder Class offering Methods to build ManiaScript * ManiaScript Builder class
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
abstract class Builder { abstract class Builder {
/*
* Constants
*/
const EMPTY_STRING = '""';
/** /**
* Build a Label Implementation Block * Build a label implementation block
* *
* @param string $labelName Name of the Label * @param string $labelName Name of the label
* @param string $implementationCode Label Implementation Coding (without declaration) * @param string $implementationCode Label implementation coding (without declaration)
* @param bool $isolate Whether the Code should be isolated in an own Block * @param bool $isolate Whether the code should be isolated in an own block
* @return string * @return string
*/ */
public static function getLabelImplementationBlock($labelName, $implementationCode, $isolate = true) { 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 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 * @return string
*/ */
public static function escapeText($text, $addApostrophes = false) { 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 * @return string
*/ */
public static function getReal($value) { 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 * @return string
*/ */
public static function getBoolean($value) { public static function getBoolean($value) {
$bool = (bool)$value; $bool = (bool)$value;
if ($bool) { 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 array $array Array to convert to a ManiaScript array
* @param bool $associative (optional) Whether the Array should be associative * @param bool $associative (optional) Whether the array should be associative
* @return string * @return string
*/ */
public static function getArray(array $array, $associative = false) { public static function getArray(array $array, $associative = false) {
@ -87,14 +91,14 @@ abstract class Builder {
foreach ($array as $key => $value) { foreach ($array as $key => $value) {
if ($associative) { if ($associative) {
if (is_string($key)) { if (is_string($key)) {
$arrayText .= '"' . self::escapeText($key) . '"'; $arrayText .= '"' . static::escapeText($key) . '"';
} else { } else {
$arrayText .= $key; $arrayText .= $key;
} }
$arrayText .= ' => '; $arrayText .= ' => ';
} }
if (is_string($value)) { if (is_string($value)) {
$arrayText .= '"' . self::escapeText($value) . '"'; $arrayText .= '"' . static::escapeText($value) . '"';
} else { } else {
$arrayText .= $value; $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 $file Include file
* @param string $namespace (optional) Include Namespace * @param string $namespace (optional) Include namespace
* @return string * @return string
*/ */
public static function getInclude($file, $namespace = null) { public static function getInclude($file, $namespace = null) {
if (!$namespace && stripos($file, '.') === false) { if (!$namespace && stripos($file, '.') === false) {
$namespace = $file; $namespace = $file;
} }
$includeText = "#Include \"{$file}\""; $file = static::escapeText($file, true);
$includeText = "#Include {$file}";
if ($namespace) { if ($namespace) {
$includeText .= " as {$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 $name Constant name
* @param string $value Constant Value * @param string $value Constant value
* @return string * @return string
*/ */
public static function getConstant($name, $value) { public static function getConstant($name, $value) {
if (is_string($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; $constantText = "#Const {$name} {$value}" . PHP_EOL;
return $constantText; return $constantText;

View File

@ -9,7 +9,7 @@ use FML\Script\ScriptLabel;
use FML\Types\Scriptable; use FML\Types\Scriptable;
/** /**
* Script Feature for triggering a Page Action * Script Feature for triggering a manialink page action
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -17,7 +17,7 @@ use FML\Types\Scriptable;
*/ */
class ActionTrigger extends ScriptFeature { class ActionTrigger extends ScriptFeature {
/* /*
* Protected Properties * Protected properties
*/ */
protected $actionName = null; protected $actionName = null;
/** @var Control $control */ /** @var Control $control */
@ -27,24 +27,30 @@ class ActionTrigger extends ScriptFeature {
/** /**
* Construct a new Action Trigger Feature * 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 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) { public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
if (!is_null($actionName)) {
$this->setActionName($actionName); $this->setActionName($actionName);
}
if (!is_null($control)) {
$this->setControl($control); $this->setControl($control);
}
if (!is_null($labelName)) {
$this->setLabelName($labelName); $this->setLabelName($labelName);
} }
}
/** /**
* Set the Action to trigger * Set the action to trigger
* *
* @param string $actionName * @param string $actionName
* @return \FML\Script\Features\ActionTrigger * @return \FML\Script\Features\ActionTrigger|static
*/ */
public function setActionName($actionName) { public function setActionName($actionName) {
$this->actionName = $actionName; $this->actionName = (string)$actionName;
return $this; return $this;
} }
@ -52,7 +58,7 @@ class ActionTrigger extends ScriptFeature {
* Set the Control * Set the Control
* *
* @param Control $control Action Control * @param Control $control Action Control
* @return \FML\Script\Features\ActionTrigger * @return \FML\Script\Features\ActionTrigger|static
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
@ -64,13 +70,13 @@ class ActionTrigger extends ScriptFeature {
} }
/** /**
* Set the Label Name * Set the label name
* *
* @param string $labelName Script Label Name * @param string $labelName Script Label name
* @return \FML\Script\Features\ActionTrigger * @return \FML\Script\Features\ActionTrigger|static
*/ */
public function setLabelName($labelName) { public function setLabelName($labelName) {
$this->labelName = $labelName; $this->labelName = (string)$labelName;
return $this; return $this;
} }
@ -83,23 +89,23 @@ class ActionTrigger extends ScriptFeature {
} }
/** /**
* Get the Script Text * Get the script text
* *
* @return string * @return string
*/ */
protected function getScriptText() { protected function getScriptText() {
$actionName = Builder::escapeText($this->actionName); $actionName = Builder::escapeText($this->actionName, true);
if ($this->control) { if ($this->control) {
// Control event // Control event
$controlId = Builder::escapeText($this->control->getId()); $controlId = Builder::escapeText($this->control->getId(), true);
$scriptText = " $scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") { if (Event.Control.ControlId == {$controlId}) {
TriggerPageAction(\"{$actionName}\"); TriggerPageAction({$actionName});
}"; }";
} else { } else {
// Other // Other
$scriptText = " $scriptText = "
TriggerPageAction(\"{$actionName}\");"; TriggerPageAction({$actionName});";
} }
return $scriptText; return $scriptText;
} }

View File

@ -11,7 +11,7 @@ use FML\Script\ScriptInclude;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
/** /**
* Script Feature for creating a CheckBox Behavior * Script Feature for creating a CheckBox behavior
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -27,7 +27,7 @@ class CheckBoxFeature extends ScriptFeature {
const VAR_CHECKBOX_ENTRY_ID = 'FML_CheckBox_EntryId'; const VAR_CHECKBOX_ENTRY_ID = 'FML_CheckBox_EntryId';
/* /*
* Protected Properties * Protected properties
*/ */
/** @var Quad $quad */ /** @var Quad $quad */
protected $quad = null; protected $quad = null;
@ -44,12 +44,18 @@ class CheckBoxFeature extends ScriptFeature {
* *
* @param Quad $quad (optional) CheckBox Quad * @param Quad $quad (optional) CheckBox Quad
* @param Entry $entry (optional) Hidden Entry * @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) { public function __construct(Quad $quad = null, Entry $entry = null, $default = null) {
if (!is_null($quad)) {
$this->setQuad($quad); $this->setQuad($quad);
}
if (!is_null($entry)) {
$this->setEntry($entry); $this->setEntry($entry);
}
if (!is_null($default)) {
$this->setDefault($default); $this->setDefault($default);
}
$this->setEnabledDesign(CheckBoxDesign::defaultEnabledDesign()); $this->setEnabledDesign(CheckBoxDesign::defaultEnabledDesign());
$this->setDisabledDesign(CheckBoxDesign::defaultDisabledDesign()); $this->setDisabledDesign(CheckBoxDesign::defaultDisabledDesign());
} }
@ -58,14 +64,10 @@ class CheckBoxFeature extends ScriptFeature {
* Set the CheckBox Quad * Set the CheckBox Quad
* *
* @param Quad $quad CheckBox Quad * @param Quad $quad CheckBox Quad
* @return \FML\Script\Features\CheckBoxFeature * @return \FML\Script\Features\CheckBoxFeature|static
*/ */
public function setQuad(Quad $quad = null) { public function setQuad(Quad $quad) {
if ($quad) { $this->quad = $quad->checkId()->setScriptEvents(true);
$quad->checkId();
$quad->setScriptEvents(true);
}
$this->quad = $quad;
return $this; return $this;
} }
@ -82,13 +84,10 @@ class CheckBoxFeature extends ScriptFeature {
* Set the CheckBox Entry * Set the CheckBox Entry
* *
* @param Entry $entry CheckBox Entry * @param Entry $entry CheckBox Entry
* @return \FML\Script\Features\CheckBoxFeature * @return \FML\Script\Features\CheckBoxFeature|static
*/ */
public function setEntry(Entry $entry = null) { public function setEntry(Entry $entry) {
if ($entry) { $this->entry = $entry->checkId();
$entry->checkId();
}
$this->entry = $entry;
return $this; return $this;
} }
@ -102,10 +101,10 @@ class CheckBoxFeature extends ScriptFeature {
} }
/** /**
* Set the default Value * Set the default value
* *
* @param bool $default Default Value * @param bool $default Default value
* @return \FML\Script\Features\CheckBoxFeature * @return \FML\Script\Features\CheckBoxFeature|static
*/ */
public function setDefault($default) { public function setDefault($default) {
$this->default = (bool)$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 * @param CheckBoxDesign $checkBoxDesign Enabled CheckBox Design
* @return \FML\Script\Features\CheckBoxFeature * @return \FML\Script\Features\CheckBoxFeature|static
*/ */
public function setEnabledDesign(CheckBoxDesign $checkBoxDesign) { public function setEnabledDesign(CheckBoxDesign $checkBoxDesign) {
$this->enabledDesign = $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 * @param CheckBoxDesign $checkBoxDesign Disabled CheckBox Design
* @return \FML\Script\Features\CheckBoxFeature * @return \FML\Script\Features\CheckBoxFeature|static
*/ */
public function setDisabledDesign(CheckBoxDesign $checkBoxDesign) { public function setDisabledDesign(CheckBoxDesign $checkBoxDesign) {
$this->disabledDesign = $checkBoxDesign; $this->disabledDesign = $checkBoxDesign;
@ -148,12 +147,12 @@ class CheckBoxFeature extends ScriptFeature {
} }
/** /**
* Build the Function Text * Build the function text
* *
* @return string * @return string
*/ */
protected function buildUpdateQuadDesignFunction() { protected function buildUpdateQuadDesignFunction() {
$functionText = " return "
Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) { Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) {
declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True; declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True;
Enabled = !Enabled; Enabled = !Enabled;
@ -167,8 +166,8 @@ Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) {
} else { } else {
_Quad.ImageUrl = Design; _Quad.ImageUrl = Design;
} }
declare " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for _Quad = \"\"; declare " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for _Quad = " . Builder::EMPTY_STRING . ";
if (EntryId != \"\") { if (EntryId != " . Builder::EMPTY_STRING . ") {
declare Value = \"0\"; declare Value = \"0\";
if (Enabled) { if (Enabled) {
Value = \"1\"; Value = \"1\";
@ -177,49 +176,46 @@ Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) {
Entry.Value = Value; Entry.Value = Value;
} }
}"; }";
return $functionText;
} }
/** /**
* Build the Init Script Text * Build the init script text
* *
* @return string * @return string
*/ */
protected function buildInitScriptText() { protected function buildInitScriptText() {
$quadId = $this->getQuad()->getId(true); $quadId = $this->getQuad()->getId(true, true);
$entryId = ''; $entryId = '""';
if ($this->entry) { if ($this->entry) {
$entryId = $this->entry->getId(true); $entryId = $this->entry->getId(true, true);
} }
$default = Builder::getBoolean($this->default); $default = Builder::getBoolean($this->default);
$enabledDesignString = $this->enabledDesign->getDesignString(); $enabledDesignString = $this->enabledDesign->getDesignString();
$disabledDesignString = $this->disabledDesign->getDesignString(); $disabledDesignString = $this->disabledDesign->getDesignString();
$scriptText = " return "
declare Quad_CheckBox <=> (Page.GetFirstChild(\"{$quadId}\") as CMlQuad); declare Quad_CheckBox <=> (Page.GetFirstChild({$quadId}) as CMlQuad);
declare Text[Boolean] " . self::VAR_CHECKBOX_DESIGNS . " as Designs for Quad_CheckBox; declare Text[Boolean] " . self::VAR_CHECKBOX_DESIGNS . " as Designs for Quad_CheckBox;
Designs[True] = \"{$enabledDesignString}\"; Designs[True] = {$enabledDesignString};
Designs[False] = \"{$disabledDesignString}\"; Designs[False] = {$disabledDesignString};
declare Boolean " . self::VAR_CHECKBOX_ENABLED . " as Enabled for Quad_CheckBox; declare Boolean " . self::VAR_CHECKBOX_ENABLED . " as Enabled for Quad_CheckBox;
Enabled = !{$default}; Enabled = !{$default};
declare Text " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for Quad_CheckBox; declare Text " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for Quad_CheckBox;
EntryId = \"{$entryId}\"; EntryId = {$entryId};
" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox); " . 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 * @return string
*/ */
protected function buildClickScriptText() { protected function buildClickScriptText() {
$quadId = $this->getQuad()->getId(true); $quadId = $this->getQuad()->getId(true, true);
$scriptText = " return "
if (Event.ControlId == \"{$quadId}\") { if (Event.ControlId == {$quadId}) {
declare Quad_CheckBox <=> (Event.Control as CMlQuad); declare Quad_CheckBox <=> (Event.Control as CMlQuad);
" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox); " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox);
}"; }";
return $scriptText;
} }
} }

View File

@ -8,7 +8,7 @@ use FML\Script\ScriptInclude;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
/** /**
* Script Feature showing the current Time on a Label * Script Feature showing the current time on a Label
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -16,7 +16,7 @@ use FML\Script\ScriptLabel;
*/ */
class Clock extends ScriptFeature { class Clock extends ScriptFeature {
/* /*
* Protected Properties * Protected properties
*/ */
/** @var Label $label */ /** @var Label $label */
protected $label = null; protected $label = null;
@ -27,11 +27,13 @@ class Clock extends ScriptFeature {
* Construct a new Clock Feature * Construct a new Clock Feature
* *
* @param Label $label (optional) Clock Label * @param Label $label (optional) Clock Label
* @param bool $showSeconds (optional) Whether the Seconds should be shown * @param bool $showSeconds (optional) Whether the seconds should be shown
* @param bool $showFullDate (optional) Whether the Date should be shown * @param bool $showFullDate (optional) Whether the date should be shown
*/ */
public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) { public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) {
if (!is_null($label)) {
$this->setLabel($label); $this->setLabel($label);
}
$this->setShowSeconds($showSeconds); $this->setShowSeconds($showSeconds);
$this->setShowFullDate($showFullDate); $this->setShowFullDate($showFullDate);
} }
@ -40,19 +42,18 @@ class Clock extends ScriptFeature {
* Set the Label * Set the Label
* *
* @param Label $label Clock Label * @param Label $label Clock Label
* @return \FML\Script\Features\Clock * @return \FML\Script\Features\Clock|static
*/ */
public function setLabel(Label $label) { public function setLabel(Label $label) {
$label->checkId(); $this->label = $label->checkId();
$this->label = $label;
return $this; return $this;
} }
/** /**
* Set whether the Seconds should be shown * Set whether seconds should be shown
* *
* @param bool $showSeconds Whether the Seconds should be shown * @param bool $showSeconds Whether seconds should be shown
* @return \FML\Script\Features\Clock * @return \FML\Script\Features\Clock|static
*/ */
public function setShowSeconds($showSeconds) { public function setShowSeconds($showSeconds) {
$this->showSeconds = (bool)$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 * @param bool $showFullDate Whether the full date should be shown
* @return \FML\Script\Features\Clock * @return \FML\Script\Features\Clock|static
*/ */
public function setShowFullDate($showFullDate) { public function setShowFullDate($showFullDate) {
$this->showFullDate = (bool)$showFullDate; $this->showFullDate = (bool)$showFullDate;
@ -80,14 +81,14 @@ class Clock extends ScriptFeature {
} }
/** /**
* Get the Script Text * Get the script text
* *
* @return string * @return string
*/ */
protected function getScriptText() { protected function getScriptText() {
$controlId = $this->label->getId(true); $controlId = $this->label->getId(true, true);
$scriptText = " $scriptText = "
declare ClockLabel <=> (Page.GetFirstChild(\"{$controlId}\") as CMlLabel); declare ClockLabel <=> (Page.GetFirstChild({$controlId}) as CMlLabel);
declare TimeText = CurrentLocalDateText;"; declare TimeText = CurrentLocalDateText;";
if (!$this->showSeconds) { if (!$this->showSeconds) {
$scriptText .= " $scriptText .= "

View File

@ -8,7 +8,7 @@ use FML\Script\ScriptLabel;
use FML\Types\Scriptable; use FML\Types\Scriptable;
/** /**
* Script Feature for a Control-related Script * Script Feature for a Control related script
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -16,7 +16,7 @@ use FML\Types\Scriptable;
*/ */
class ControlScript extends ScriptFeature { class ControlScript extends ScriptFeature {
/* /*
* Protected Properties * Protected properties
*/ */
/** @var Control $control */ /** @var Control $control */
protected $control = null; protected $control = null;
@ -24,11 +24,11 @@ class ControlScript extends ScriptFeature {
protected $text = null; protected $text = null;
/** /**
* Construct a new Custom Script Text * Construct a new Control Script
* *
* @param Control $control Event Control * @param Control $control Event Control
* @param string $text Script Text * @param string $text Script text
* @param string $labelName (optional) Script Label Name * @param string $labelName (optional) Script Label name
*/ */
public function __construct(Control $control, $text, $labelName = ScriptLabel::MOUSECLICK) { public function __construct(Control $control, $text, $labelName = ScriptLabel::MOUSECLICK) {
$this->setControl($control); $this->setControl($control);
@ -39,21 +39,20 @@ class ControlScript extends ScriptFeature {
/** /**
* Set the Control * Set the Control
* *
* @param Control $control Custom Control * @param Control $control Event Control
* @return \FML\Script\Features\ControlScript * @return \FML\Script\Features\ControlScript|static
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $this->control = $control->checkId();
$this->control = $control;
$this->updateScriptEvents(); $this->updateScriptEvents();
return $this; return $this;
} }
/** /**
* Set the Script Text * Set the script text
* *
* @param string $text Script Text * @param string $text Script text
* @return \FML\Script\Features\ControlScript * @return \FML\Script\Features\ControlScript|static
*/ */
public function setText($text) { public function setText($text) {
$this->text = (string)$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 * @param string $labelName Script Label name
* @return \FML\Script\Features\ControlScript * @return \FML\Script\Features\ControlScript|static
*/ */
public function setLabelName($labelName) { public function setLabelName($labelName) {
$this->labelName = $labelName; $this->labelName = (string)$labelName;
$this->updateScriptEvents(); $this->updateScriptEvents();
return $this; return $this;
} }
@ -76,10 +75,7 @@ class ControlScript extends ScriptFeature {
* Enable Script Events on the Control if needed * Enable Script Events on the Control if needed
*/ */
protected function updateScriptEvents() { protected function updateScriptEvents() {
if (!$this->control) { if (!$this->control || !ScriptLabel::isEventLabel($this->labelName)) {
return;
}
if (!ScriptLabel::isEventLabel($this->labelName)) {
return; return;
} }
if ($this->control instanceof Scriptable) { 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 * @return string
*/ */
@ -105,7 +101,6 @@ class ControlScript extends ScriptFeature {
$controlId = $this->control->getId(true); $controlId = $this->control->getId(true);
$scriptText = ''; $scriptText = '';
$closeBlock = false; $closeBlock = false;
if (ScriptLabel::isEventLabel($this->labelName)) { if (ScriptLabel::isEventLabel($this->labelName)) {
$scriptText .= ' $scriptText .= '
if (Event.ControlId == "' . $controlId . '") { if (Event.ControlId == "' . $controlId . '") {
@ -115,20 +110,16 @@ declare Control <=> Event.Control;';
$scriptText .= ' $scriptText .= '
declare Control <=> Page.GetFirstChild("' . $controlId . '");'; declare Control <=> Page.GetFirstChild("' . $controlId . '");';
} }
$class = $this->control->getManiaScriptClass(); $class = $this->control->getManiaScriptClass();
$name = preg_replace('/^CMl/', '', $class, 1); $name = preg_replace('/^CMl/', '', $class, 1);
$scriptText .= ' $scriptText .= '
declare ' . $name . ' <=> (Control as ' . $class . '); declare ' . $name . ' <=> (Control as ' . $class . ');
'; ';
$scriptText .= $this->text . ' $scriptText .= $this->text . '
'; ';
if ($closeBlock) { if ($closeBlock) {
$scriptText .= '}'; $scriptText .= '}';
} }
return $scriptText; return $scriptText;
} }
} }

View File

@ -17,7 +17,7 @@ use FML\Script\ScriptLabel;
*/ */
class EntrySubmit extends ScriptFeature { class EntrySubmit extends ScriptFeature {
/* /*
* Protected Properties * Protected properties
*/ */
/** @var Entry $entry */ /** @var Entry $entry */
protected $entry = null; protected $entry = null;
@ -27,10 +27,12 @@ class EntrySubmit extends ScriptFeature {
* Construct a new Entry Submit Feature * Construct a new Entry Submit Feature
* *
* @param Entry $entry (optional) Entry Control * @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) { public function __construct(Entry $entry = null, $url = null) {
if (!is_null($entry)) {
$this->setEntry($entry); $this->setEntry($entry);
}
$this->setUrl($url); $this->setUrl($url);
} }
@ -38,20 +40,18 @@ class EntrySubmit extends ScriptFeature {
* Set the Entry * Set the Entry
* *
* @param Entry $entry Entry Control * @param Entry $entry Entry Control
* @return \FML\Script\Features\EntrySubmit * @return \FML\Script\Features\EntrySubmit|static
*/ */
public function setEntry(Entry $entry) { public function setEntry(Entry $entry) {
$entry->checkId(); $this->entry = $entry->checkId()->setScriptEvents(true);
$entry->setScriptEvents(true);
$this->entry = $entry;
return $this; return $this;
} }
/** /**
* Set the Submit Url * Set the submit url
* *
* @param string $url Submit Url * @param string $url Submit url
* @return \FML\Script\Features\EntrySubmit * @return \FML\Script\Features\EntrySubmit|static
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string)$url; $this->url = (string)$url;
@ -69,22 +69,22 @@ class EntrySubmit extends ScriptFeature {
} }
/** /**
* Get the Script Text * Get the script text
* *
* @return string * @return string
*/ */
protected function getScriptText() { protected function getScriptText() {
$url = $this->buildCompatibleUrl(); $url = $this->buildCompatibleUrl();
$entryName = Builder::escapeText($this->entry->getName()); $entryName = $this->entry->getName();
$scriptText = " $link = Builder::escapeText($entryName . $url . '=', true);
return "
declare Value = TextLib::URLEncode(Entry.Value); 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 * @return string
*/ */

View File

@ -7,7 +7,7 @@ use FML\Script\Script;
use FML\Script\ScriptLabel; 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 * @author steeffeen
* @link http://destroflyer.mania-community.de/maniascript/keycharid_table.php * @link http://destroflyer.mania-community.de/maniascript/keycharid_table.php
@ -16,7 +16,7 @@ use FML\Script\ScriptLabel;
*/ */
class KeyAction extends ScriptFeature { class KeyAction extends ScriptFeature {
/* /*
* Protected Properties * Protected properties
*/ */
protected $actionName = null; protected $actionName = null;
protected $keyName = null; protected $keyName = null;
@ -26,23 +26,23 @@ class KeyAction extends ScriptFeature {
/** /**
* Construct a new Key Action Feature * Construct a new Key Action Feature
* *
* @param string $actionName (optional) Triggered Action * @param string $actionName (optional) Triggered action
* @param string $keyName (optional) Key Name * @param string $keyName (optional) Key name
* @param int $keyCode (optional) Key Code
* @param string $charPressed (optional) Pressed Char
*/ */
public function __construct($actionName = null, $keyName = null, $keyCode = null, $charPressed = null) { public function __construct($actionName = null, $keyName = null) {
if (!is_null($actionName)) {
$this->setActionName($actionName); $this->setActionName($actionName);
}
if (!is_null($keyName)) {
$this->setKeyName($keyName); $this->setKeyName($keyName);
$this->setKeyCode($keyCode); }
$this->setCharPressed($charPressed);
} }
/** /**
* Set the Action to trigger * Set the action to trigger
* *
* @param string $actionName Triggered Action * @param string $actionName Triggered action
* @return \FML\Script\Features\KeyAction * @return \FML\Script\Features\KeyAction|static
*/ */
public function setActionName($actionName) { public function setActionName($actionName) {
$this->actionName = (string)$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 * @param string $keyName Key Name
* @return \FML\Script\Features\KeyAction * @return \FML\Script\Features\KeyAction|static
*/ */
public function setKeyName($keyName) { public function setKeyName($keyName) {
$this->keyName = (string)$keyName; $this->keyName = (string)$keyName;
$this->keyCode = null;
$this->charPressed = null;
return $this; return $this;
} }
/** /**
* Set the Key Code for triggering the Action * Set the key code for triggering the action
* *
* @param int $keyCode Key Code * @param int $keyCode Key Code
* @return \FML\Script\Features\KeyAction * @return \FML\Script\Features\KeyAction|static
*/ */
public function setKeyCode($keyCode) { public function setKeyCode($keyCode) {
$this->keyCode = $keyCode; $this->keyCode = (int)$keyCode;
$this->keyName = null;
$this->charPressed = null;
return $this; 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 * @param string $charPressed Pressed char
* @return \FML\Script\Features\KeyAction * @return \FML\Script\Features\KeyAction|static
*/ */
public function setCharPressed($charPressed) { public function setCharPressed($charPressed) {
$this->charPressed = $charPressed; $this->charPressed = (string)$charPressed;
$this->keyName = null;
$this->keyCode = null;
return $this; return $this;
} }
@ -91,25 +97,28 @@ class KeyAction extends ScriptFeature {
} }
/** /**
* Get the Script Text * Get the script text
* *
* @return string * @return string
*/ */
protected function getScriptText() { protected function getScriptText() {
$actionName = Builder::escapeText($this->actionName); $actionName = Builder::escapeText($this->actionName, true);
$key = null;
$value = null;
if (!is_null($this->keyName)) {
$key = 'KeyName'; $key = 'KeyName';
$value = $this->keyName; $value = $this->keyName;
if ($this->keyCode !== null) { } else if (!is_null($this->keyCode)) {
$key = 'KeyCode'; $key = 'KeyCode';
$value = (int)$this->keyCode; $value = $this->keyCode;
} else if ($this->charPressed !== null) { } else if (!is_null($this->charPressed)) {
$key = 'CharPressed'; $key = 'CharPressed';
$value = (string)$this->charPressed; $value = $this->charPressed;
} }
$scriptText = " $value = Builder::escapeText($value, true);
if (Event.{$key} == \"{$value}\") { return "
TriggerPageAction(\"{$actionName}\"); if (Event.{$key} == {$value}) {
TriggerPageAction({$actionName});
}"; }";
return $scriptText;
} }
} }

View File

@ -9,7 +9,7 @@ use FML\Script\ScriptLabel;
use FML\Types\Scriptable; use FML\Types\Scriptable;
/** /**
* Script Feature for opening the Map Info * Script Feature for opening the map info
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -17,7 +17,7 @@ use FML\Types\Scriptable;
*/ */
class MapInfo extends ScriptFeature { class MapInfo extends ScriptFeature {
/* /*
* Protected Properties * Protected properties
*/ */
/** @var Control $control */ /** @var Control $control */
protected $control = null; protected $control = null;
@ -27,7 +27,7 @@ class MapInfo extends ScriptFeature {
* Construct a new Map Info Feature * Construct a new Map Info Feature
* *
* @param Control $control (optional) Map Info Control * @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) { public function __construct(Control $control, $labelName = ScriptLabel::MOUSECLICK) {
$this->setControl($control); $this->setControl($control);
@ -38,7 +38,7 @@ class MapInfo extends ScriptFeature {
* Set the Control * Set the Control
* *
* @param Control $control Map Info Control * @param Control $control Map Info Control
* @return \FML\Script\Features\MapInfo * @return \FML\Script\Features\MapInfo|static
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
@ -50,13 +50,13 @@ class MapInfo extends ScriptFeature {
} }
/** /**
* Set the Label Name * Set the label name
* *
* @param string $labelName Script Label Name * @param string $labelName Script Label name
* @return \FML\Script\Features\MapInfo * @return \FML\Script\Features\MapInfo|static
*/ */
public function setLabelName($labelName) { public function setLabelName($labelName) {
$this->labelName = $labelName; $this->labelName = (string)$labelName;
return $this; return $this;
} }
@ -69,16 +69,16 @@ class MapInfo extends ScriptFeature {
} }
/** /**
* Get the Script Text * Get the script text
* *
* @return string * @return string
*/ */
protected function getScriptText() { protected function getScriptText() {
if ($this->control) { if ($this->control) {
// Control event // Control event
$controlId = Builder::escapeText($this->control->getId()); $controlId = Builder::escapeText($this->control->getId(), true);
$scriptText = " $scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") { if (Event.Control.ControlId == {$controlId}) {
ShowCurChallengeCard(); ShowCurChallengeCard();
}"; }";
} else { } else {

View File

@ -8,7 +8,7 @@ use FML\Script\Script;
use FML\Script\ScriptLabel; 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 * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -21,8 +21,9 @@ class Menu extends ScriptFeature {
const FUNCTION_UPDATE_MENU = 'FML_UpdateMenu'; const FUNCTION_UPDATE_MENU = 'FML_UpdateMenu';
/* /*
* Protected Properties * Protected properties
*/ */
/** @var MenuElement[] $elements */
protected $elements = array(); protected $elements = array();
/** @var MenuElement $startElement */ /** @var MenuElement $startElement */
protected $startElement = null; protected $startElement = null;
@ -30,7 +31,7 @@ class Menu extends ScriptFeature {
/** /**
* Construct a new Menu Feature * 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 * @param Control $control (optional) Toggled Menu Control
*/ */
public function __construct(Control $item = null, Control $control = null) { public function __construct(Control $item = null, Control $control = null) {
@ -42,10 +43,10 @@ class Menu extends ScriptFeature {
/** /**
* Add a new Element to the Menu * 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 Control $control Toggled Menu Control
* @param bool $isStartElement (optional) Whether the Menu should start with this 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 addElement(Control $item, Control $control, $isStartElement = false) { public function addElement(Control $item, Control $control, $isStartElement = false) {
$menuElement = new MenuElement($item, $control); $menuElement = new MenuElement($item, $control);
@ -58,15 +59,17 @@ class Menu extends ScriptFeature {
* *
* @param MenuElement $menuElement Menu Element * @param MenuElement $menuElement Menu Element
* @param bool $isStartElement (optional) Whether the Menu should start with this 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) { public function appendElement(MenuElement $menuElement, $isStartElement = false) {
if (!in_array($menuElement, $this->elements, true)) {
array_push($this->elements, $menuElement); array_push($this->elements, $menuElement);
if ($isStartElement) { if ($isStartElement) {
$this->setStartElement($menuElement); $this->setStartElement($menuElement);
} else if (count($this->elements) > 1) { } else if (count($this->elements) > 1) {
$menuElement->getControl()->setVisible(false); $menuElement->getControl()->setVisible(false);
} }
}
return $this; return $this;
} }
@ -74,7 +77,7 @@ class Menu extends ScriptFeature {
* Set the Element to start with * Set the Element to start with
* *
* @param MenuElement $startElement Starting Element * @param MenuElement $startElement Starting Element
* @return \FML\Script\Features\Menu * @return \FML\Script\Features\Menu|static
*/ */
public function setStartElement(MenuElement $startElement) { public function setStartElement(MenuElement $startElement) {
$this->startElement = $startElement; $this->startElement = $startElement;
@ -93,9 +96,9 @@ class Menu extends ScriptFeature {
// OnInit // OnInit
if ($this->startElement) { if ($this->startElement) {
$startControlId = $this->startElement->getControl()->getId(true); $startControlId = $this->startElement->getControl()->getId(true, true);
$initScriptText = " $initScriptText = "
{$updateFunctionName}({$elementsArrayText}, \"{$startControlId}\");"; {$updateFunctionName}({$elementsArrayText}, {$startControlId});";
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); $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 * @return string
*/ */
protected function getElementsArrayText() { protected function getElementsArrayText() {
$elements = array(); $elements = array();
foreach ($this->elements as $element) { foreach ($this->elements as $element) {
/** @var MenuElement $element */
$elementId = $element->getItem()->getId(); $elementId = $element->getItem()->getId();
$elements[$elementId] = $element->getControl()->getId(); $elements[$elementId] = $element->getControl()->getId();
} }

View File

@ -6,7 +6,7 @@ use FML\Controls\Control;
use FML\Types\Scriptable; use FML\Types\Scriptable;
/** /**
* An Element for the Menu Feature * Menu Element for the Menu Feature
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -14,7 +14,7 @@ use FML\Types\Scriptable;
*/ */
class MenuElement { class MenuElement {
/* /*
* Protected Properties * Protected properties
*/ */
protected $item = null; protected $item = null;
protected $control = null; protected $control = null;
@ -22,19 +22,23 @@ class MenuElement {
/** /**
* Create a new Menu Element * 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 * @param Control $control (optional) Toggled Menu Control
*/ */
public function __construct(Control $item = null, Control $control = null) { public function __construct(Control $item = null, Control $control = null) {
if (!is_null($item)) {
$this->setItem($item); $this->setItem($item);
}
if (!is_null($control)) {
$this->setControl($control); $this->setControl($control);
} }
}
/** /**
* Set the Item Control * Set the Item Control
* *
* @param Control $item Item Control in the Menu Bar * @param Control $item Item Control in the Menu bar
* @return \FML\Script\Features\MenuElement * @return \FML\Script\Features\MenuElement|static
*/ */
public function setItem(Control $item) { public function setItem(Control $item) {
$item->checkId(); $item->checkId();
@ -58,11 +62,10 @@ class MenuElement {
* Set the Menu Control * Set the Menu Control
* *
* @param Control $control Toggled Menu Control * @param Control $control Toggled Menu Control
* @return \FML\Script\Features\MenuElement * @return \FML\Script\Features\MenuElement|static
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $this->control = $control->checkId();
$this->control = $control;
return $this; return $this;
} }

View File

@ -10,7 +10,7 @@ use FML\Script\ScriptInclude;
use FML\Script\ScriptLabel; 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> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -24,9 +24,11 @@ class Paging extends ScriptFeature {
const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage'; const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage';
/* /*
* Protected Properties * Protected properties
*/ */
/** @var PagingPage[] $pages */
protected $pages = array(); protected $pages = array();
/** @var PagingButton[] $buttons */
protected $buttons = array(); protected $buttons = array();
/** @var Label $label */ /** @var Label $label */
protected $label = null; protected $label = null;
@ -39,10 +41,10 @@ class Paging extends ScriptFeature {
/** /**
* Construct a new Paging Script Feature * 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) { public function __construct(Label $label = null) {
if ($label) { if (!is_null($label)) {
$this->setLabel($label); $this->setLabel($label);
} }
} }
@ -51,11 +53,11 @@ class Paging extends ScriptFeature {
* Add a new Page Control * Add a new Page Control
* *
* @param Control $pageControl Page Control * @param Control $pageControl Page Control
* @param string $pageNumber (optional) Page Number * @param string $pageNumber (optional) Page number
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function addPage(Control $pageControl, $pageNumber = null) { public function addPage(Control $pageControl, $pageNumber = null) {
if ($pageNumber === null) { if (is_null($pageNumber)) {
$pageNumber = count($this->pages) + 1; $pageNumber = count($this->pages) + 1;
} }
$page = new PagingPage($pageControl, $pageNumber); $page = new PagingPage($pageControl, $pageNumber);
@ -67,22 +69,24 @@ class Paging extends ScriptFeature {
* Append a Page * Append a Page
* *
* @param PagingPage $page Paging Page * @param PagingPage $page Paging Page
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function appendPage(PagingPage $page) { public function appendPage(PagingPage $page) {
if (!in_array($page, $this->pages, true)) {
array_push($this->pages, $page); array_push($this->pages, $page);
}
return $this; return $this;
} }
/** /**
* Add a new Button to browse through the Pages * Add a new Button to browse through the Pages
* *
* @param Control $buttonControl Button used for Browsing * @param Control $buttonControl Button used for browsing
* @param int $browseAction (optional) Number of browsed Pages per Click * @param int $browseAction (optional) Number of browsed Pages per click
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function addButton(Control $buttonControl, $browseAction = null) { public function addButton(Control $buttonControl, $browseAction = null) {
if ($browseAction === null) { if (is_null($browseAction)) {
$buttonCount = count($this->buttons); $buttonCount = count($this->buttons);
if ($buttonCount % 2 === 0) { if ($buttonCount % 2 === 0) {
$browseAction = $buttonCount / 2 + 1; $browseAction = $buttonCount / 2 + 1;
@ -99,40 +103,41 @@ class Paging extends ScriptFeature {
* Append a Button to browse through Pages * Append a Button to browse through Pages
* *
* @param PagingButton $button Paging Button * @param PagingButton $button Paging Button
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function appendButton(PagingButton $button) { public function appendButton(PagingButton $button) {
if (!in_array($button, $this->buttons, true)) {
array_push($this->buttons, $button); array_push($this->buttons, $button);
}
return $this; return $this;
} }
/** /**
* Set the Label showing the Page Number * Set the Label showing the Page number
* *
* @param Label $label Page Number Label * @param Label $label Page number Label
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function setLabel(Label $label) { public function setLabel(Label $label) {
$label->checkId(); $this->label = $label->checkId();
$this->label = $label;
return $this; return $this;
} }
/** /**
* Set the Start Page Number * Set the Start Page number
* *
* @param int $startPageNumber Page Number to start with * @param int $startPageNumber Page number to start with
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function setStartPageNumber($startPageNumber) { public function setStartPageNumber($startPageNumber) {
$this->startPageNumber = (int)$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 * @param int $maxPageNumber Custom maximum Page number
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function setCustomMaxPageNumber($maxPageNumber) { public function setCustomMaxPageNumber($maxPageNumber) {
$this->customMaxPageNumber = (int)$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 * @param string $previousChunkAction Triggered action
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function setPreviousChunkAction($previousChunkAction) { public function setPreviousChunkAction($previousChunkAction) {
$this->previousChunkAction = (string)$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 * @param string $nextChunkAction Triggered action
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function setNextChunkAction($nextChunkAction) { public function setNextChunkAction($nextChunkAction) {
$this->nextChunkAction = (string)$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 * @param string $chunkAction Triggered action
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function setChunkActions($chunkAction) { public function setChunkActions($chunkAction) {
$this->setNextChunkAction($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 * @param bool $appendPageNumber Whether to append the needed Page number
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging|static
*/ */
public function setChunkActionAppendsPageNumber($appendPageNumber) { public function setChunkActionAppendsPageNumber($appendPageNumber) {
$this->chunkActionAppendsPageNumber = (bool)$appendPageNumber; $this->chunkActionAppendsPageNumber = (bool)$appendPageNumber;
@ -188,7 +193,7 @@ class Paging extends ScriptFeature {
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
if (!$this->pages) { if (empty($this->pages)) {
return $this; return $this;
} }
$script->setScriptInclude(ScriptInclude::TEXTLIB); $script->setScriptInclude(ScriptInclude::TEXTLIB);
@ -204,23 +209,23 @@ class Paging extends ScriptFeature {
$maxPageNumber = $maxPage->getPageNumber(); $maxPageNumber = $maxPage->getPageNumber();
} }
$pagingId = $maxPage->getControl()->getId(true); $pagingId = $maxPage->getControl()->getId(true, true);
$pageLabelId = ''; $pageLabelId = '""';
if ($this->label) { if ($this->label) {
$pageLabelId = $this->label->getId(true); $pageLabelId = $this->label->getId(true, true);
} }
$pagesArrayText = $this->getPagesArrayText(); $pagesArrayText = $this->getPagesArrayText();
$pageButtonsArrayText = $this->getPageButtonsArrayText(); $pageButtonsArrayText = $this->getPageButtonsArrayText();
$previousChunkAction = Builder::escapeText($this->previousChunkAction); $previousChunkAction = Builder::escapeText($this->previousChunkAction, true);
$nextChunkAction = Builder::escapeText($this->nextChunkAction); $nextChunkAction = Builder::escapeText($this->nextChunkAction, true);
$chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber); $chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber);
// Init // Init
$initScriptText = " $initScriptText = "
declare {$currentPageVariable} for This = Integer[Text]; declare {$currentPageVariable} for This = Integer[Text];
{$currentPageVariable}[\"{$pagingId}\"] = {$startPageNumber}; {$currentPageVariable}[{$pagingId}] = {$startPageNumber};
{$updatePageFunction}(\"{$pagingId}\", \"{$pageLabelId}\", 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, \"{$previousChunkAction}\", \"{$nextChunkAction}\", {$chunkActionAppendsPageNumber});"; {$updatePageFunction}({$pagingId}, {$pageLabelId}, 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber});";
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
// MouseClick // MouseClick
@ -228,7 +233,7 @@ declare {$currentPageVariable} for This = Integer[Text];
declare PageButtons = {$pageButtonsArrayText}; declare PageButtons = {$pageButtonsArrayText};
if (PageButtons.existskey(Event.Control.ControlId)) { if (PageButtons.existskey(Event.Control.ControlId)) {
declare BrowseAction = PageButtons[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); $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true);
@ -264,7 +269,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
} }
TriggerPageAction(ChunkAction); TriggerPageAction(ChunkAction);
} }
if (_PageLabelId == \"\") return; if (_PageLabelId == " . Builder::EMPTY_STRING . ") return;
declare PageLabel <=> (Page.GetFirstChild(_PageLabelId) as CMlLabel); declare PageLabel <=> (Page.GetFirstChild(_PageLabelId) as CMlLabel);
if (PageLabel == Null) return; if (PageLabel == Null) return;
PageLabel.Value = CurrentPage^\"/\"^_MaxPageNumber; PageLabel.Value = CurrentPage^\"/\"^_MaxPageNumber;
@ -282,9 +287,8 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
$minPageNumber = null; $minPageNumber = null;
$minPage = null; $minPage = null;
foreach ($this->pages as $page) { foreach ($this->pages as $page) {
/** @var PagingPage $page */
$pageNumber = $page->getPageNumber(); $pageNumber = $page->getPageNumber();
if ($minPageNumber === null || $pageNumber < $minPageNumber) { if (is_null($minPageNumber) || $pageNumber < $minPageNumber) {
$minPageNumber = $pageNumber; $minPageNumber = $pageNumber;
$minPage = $page; $minPage = $page;
} }
@ -301,9 +305,8 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
$maxPageNumber = null; $maxPageNumber = null;
$maxPage = null; $maxPage = null;
foreach ($this->pages as $page) { foreach ($this->pages as $page) {
/** @var PagingPage $page */
$pageNumber = $page->getPageNumber(); $pageNumber = $page->getPageNumber();
if ($maxPageNumber === null || $pageNumber > $maxPageNumber) { if (is_null($maxPageNumber) || $pageNumber > $maxPageNumber) {
$maxPageNumber = $pageNumber; $maxPageNumber = $pageNumber;
$maxPage = $page; $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 * @return string
*/ */
protected function getPagesArrayText() { protected function getPagesArrayText() {
if (empty($this->pages)) {
return Builder::getArray(array(0 => ''), true);
}
$pages = array(); $pages = array();
foreach ($this->pages as $page) { foreach ($this->pages as $page) {
/** @var PagingPage $page */ $pages[$page->getPageNumber()] = $page->getControl()->getId();
$pageNumber = $page->getPageNumber();
$pages[$pageNumber] = $page->getControl()->getId();
} }
return Builder::getArray($pages, true); return Builder::getArray($pages, true);
} }
/** /**
* Build the Array Text for the Page Buttons * Build the array text for the Page Buttons
* *
* @return string * @return string
*/ */
protected function getPageButtonsArrayText() { protected function getPageButtonsArrayText() {
if (!$this->buttons) { if (empty($this->buttons)) {
return Builder::getArray(array("" => 0), true); return Builder::getArray(array('' => 0), true);
} }
$pageButtons = array(); $pageButtons = array();
foreach ($this->buttons as $pageButton) { foreach ($this->buttons as $pageButton) {
/** @var PagingButton $pageButton */ $pageButtons[$pageButton->getControl()->getId()] = $pageButton->getBrowseAction();
$pageButtonId = $pageButton->getControl()->getId();
$pageButtons[$pageButtonId] = $pageButton->getBrowseAction();
} }
return Builder::getArray($pageButtons, true); return Builder::getArray($pageButtons, true);
} }

View File

@ -6,7 +6,7 @@ use FML\Controls\Control;
use FML\Types\Scriptable; use FML\Types\Scriptable;
/** /**
* A Button for browsing through Pages * Paging Button for browsing through Pages
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -14,8 +14,9 @@ use FML\Types\Scriptable;
*/ */
class PagingButton { class PagingButton {
/* /*
* Protected Properties * Protected properties
*/ */
/** @var Control $control */
protected $control = null; protected $control = null;
protected $browseAction = null; protected $browseAction = null;
@ -26,15 +27,19 @@ class PagingButton {
* @param int $browseAction (optional) Number of browsed Pages per Click * @param int $browseAction (optional) Number of browsed Pages per Click
*/ */
public function __construct(Control $control = null, $browseAction = null) { public function __construct(Control $control = null, $browseAction = null) {
if (!is_null($control)) {
$this->setControl($control); $this->setControl($control);
}
if (!is_null($browseAction)) {
$this->setBrowseAction($browseAction); $this->setBrowseAction($browseAction);
} }
}
/** /**
* Set the Button Control * Set the Button Control
* *
* @param Control $control Browse Control * @param Control $control Browse Control
* @return \FML\Script\Features\PagingButton * @return \FML\Script\Features\PagingButton|static
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $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 * @param int $browseAction Number of browsed Pages per click
* @return \FML\Script\Features\PagingButton * @return \FML\Script\Features\PagingButton|static
*/ */
public function setBrowseAction($browseAction) { public function setBrowseAction($browseAction) {
$this->browseAction = (int)$browseAction; $this->browseAction = (int)$browseAction;
@ -66,7 +71,7 @@ class PagingButton {
} }
/** /**
* Get the Browse Action * Get the browse action
* *
* @return int * @return int
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
/** /**
* A Page Control * Paging Page
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -13,8 +13,9 @@ use FML\Controls\Control;
*/ */
class PagingPage { class PagingPage {
/* /*
* Protected Properties * Protected properties
*/ */
/** @var Control $control */
protected $control = null; protected $control = null;
protected $number = null; protected $number = null;
@ -25,7 +26,9 @@ class PagingPage {
* @param int $pageNumber (optional) Number of the Page * @param int $pageNumber (optional) Number of the Page
*/ */
public function __construct(Control $control = null, $pageNumber = 1) { public function __construct(Control $control = null, $pageNumber = 1) {
if (!is_null($control)) {
$this->setControl($control); $this->setControl($control);
}
$this->setPageNumber($pageNumber); $this->setPageNumber($pageNumber);
} }
@ -33,11 +36,10 @@ class PagingPage {
* Set the Page Control * Set the Page Control
* *
* @param Control $control Page Control * @param Control $control Page Control
* @return \FML\Script\Features\PagingPage * @return \FML\Script\Features\PagingPage|static
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $this->control = $control->checkId();
$this->control = $control;
return $this; return $this;
} }
@ -51,10 +53,10 @@ class PagingPage {
} }
/** /**
* Set the Page Number * Set the Page number
* *
* @param int $pageNumber Number of the Page * @param int $pageNumber Number of the Page
* @return \FML\Script\Features\PagingPage * @return \FML\Script\Features\PagingPage|static
*/ */
public function setPageNumber($pageNumber) { public function setPageNumber($pageNumber) {
$this->number = (int)$pageNumber; $this->number = (int)$pageNumber;
@ -62,7 +64,7 @@ class PagingPage {
} }
/** /**
* Get the Page Number * Get the Page number
* *
* @return int * @return int
*/ */

View File

@ -9,7 +9,7 @@ use FML\Script\ScriptLabel;
use FML\Types\Scriptable; use FML\Types\Scriptable;
/** /**
* Script Feature for opening a Player Profile * Script Feature for opening a player profile
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -17,7 +17,7 @@ use FML\Types\Scriptable;
*/ */
class PlayerProfile extends ScriptFeature { class PlayerProfile extends ScriptFeature {
/* /*
* Protected Properties * Protected properties
*/ */
protected $login = null; protected $login = null;
/** @var Control $control */ /** @var Control $control */
@ -27,21 +27,23 @@ class PlayerProfile extends ScriptFeature {
/** /**
* Construct a new Player Profile Feature * 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 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) { public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
$this->setLogin($login); $this->setLogin($login);
if (!is_null($control)) {
$this->setControl($control); $this->setControl($control);
}
$this->setLabelName($labelName); $this->setLabelName($labelName);
} }
/** /**
* Set the Login of the Player * Set the login of the opened player
* *
* @param string $login Player Login * @param string $login Player login
* @return \FML\Script\Features\PlayerProfile * @return \FML\Script\Features\PlayerProfile|static
*/ */
public function setLogin($login) { public function setLogin($login) {
$this->login = $login; $this->login = $login;
@ -52,7 +54,7 @@ class PlayerProfile extends ScriptFeature {
* Set the Control * Set the Control
* *
* @param Control $control Profile Control * @param Control $control Profile Control
* @return \FML\Script\Features\PlayerProfile * @return \FML\Script\Features\PlayerProfile|static
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
@ -64,13 +66,13 @@ class PlayerProfile extends ScriptFeature {
} }
/** /**
* Set the Label Name * Set the label name
* *
* @param string $labelName Script Label Name * @param string $labelName Script Label name
* @return \FML\Script\Features\PlayerProfile * @return \FML\Script\Features\PlayerProfile|static
*/ */
public function setLabelName($labelName) { public function setLabelName($labelName) {
$this->labelName = $labelName; $this->labelName = (string)$labelName;
return $this; return $this;
} }
@ -83,23 +85,23 @@ class PlayerProfile extends ScriptFeature {
} }
/** /**
* Get the Script Text * Get the script text
* *
* @return string * @return string
*/ */
protected function getScriptText() { protected function getScriptText() {
$login = Builder::escapeText($this->login); $login = Builder::escapeText($this->login, true);
if ($this->control) { if ($this->control) {
// Control event // Control event
$controlId = Builder::escapeText($this->control->getId()); $controlId = Builder::escapeText($this->control->getId(), true);
$scriptText = " $scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") { if (Event.Control.ControlId == {$controlId}) {
ShowProfile(\"{$login}\"); ShowProfile({$login});
}"; }";
} else { } else {
// Other // Other
$scriptText = " $scriptText = "
ShowProfile(\"{$login}\");"; ShowProfile({$login});";
} }
return $scriptText; return $scriptText;
} }

View File

@ -13,15 +13,13 @@ use FML\Types\ScriptFeatureable;
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
abstract class ScriptFeature { abstract class ScriptFeature {
/** /**
* Collect the Script Features of the given Objects * Collect the Script Features of the given objects
* *
* @param object $scriptFeatureable ScriptFeatureable Object * @param ScriptFeatureable $objects (optional) Various amount of ScriptFeatureable objects
* @param object $_ (optional) Various Amount of additional Objects * @return ScriptFeature[]
* @return array
*/ */
public static function collect($scriptFeatureable, $_ = null) { public static function collect() {
$params = func_get_args(); $params = func_get_args();
$scriptFeatures = array(); $scriptFeatures = array();
foreach ($params as $object) { 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 * @param Script $script Script to prepare
* @return \FML\Script\Features\ScriptFeature * @return \FML\Script\Features\ScriptFeature|static
*/ */
public abstract function prepare(Script $script); public abstract function prepare(Script $script);
} }

View File

@ -16,7 +16,7 @@ use FML\Types\Scriptable;
*/ */
class Toggle extends ScriptFeature { class Toggle extends ScriptFeature {
/* /*
* Protected Properties * Protected properties
*/ */
/** @var Control $togglingControl */ /** @var Control $togglingControl */
protected $togglingControl = null; protected $togglingControl = null;
@ -31,23 +31,28 @@ class Toggle extends ScriptFeature {
* *
* @param Control $togglingControl (optional) Toggling Control * @param Control $togglingControl (optional) Toggling Control
* @param Control $toggledControl (optional) Toggled Control * @param Control $toggledControl (optional) Toggled Control
* @param string $labelName (optional) Script Label Name * @param string $labelName (optional) Script Label name
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle * @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 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) { public function __construct(Control $togglingControl = null, Control $toggledControl = null, $labelName = ScriptLabel::MOUSECLICK,
$onlyShow = false, $onlyHide = false) {
if (!is_null($togglingControl)) {
$this->setTogglingControl($togglingControl); $this->setTogglingControl($togglingControl);
}
if (!is_null($toggledControl)) {
$this->setToggledControl($toggledControl); $this->setToggledControl($toggledControl);
}
$this->setLabelName($labelName); $this->setLabelName($labelName);
$this->setOnlyShow($onlyShow); $this->setOnlyShow($onlyShow);
$this->setOnlyHide($onlyHide); $this->setOnlyHide($onlyHide);
} }
/** /**
* Set the Toggling Control * Set the toggling Control
* *
* @param Control $control Toggling Control * @param Control $control Toggling Control
* @return \FML\Script\Features\Toggle * @return \FML\Script\Features\Toggle|static
*/ */
public function setTogglingControl(Control $control) { public function setTogglingControl(Control $control) {
$control->checkId(); $control->checkId();
@ -59,22 +64,21 @@ class Toggle extends ScriptFeature {
} }
/** /**
* Set the Toggled Control * Set the toggled Control
* *
* @param Control $control Toggling Control * @param Control $control Toggling Control
* @return \FML\Script\Features\Toggle * @return \FML\Script\Features\Toggle|static
*/ */
public function setToggledControl(Control $control) { public function setToggledControl(Control $control) {
$control->checkId(); $this->toggledControl = $control->checkId();
$this->toggledControl = $control;
return $this; return $this;
} }
/** /**
* Set the Label Name * Set the label name
* *
* @param string $labelName Script Label Name * @param string $labelName Script Label Name
* @return \FML\Script\Features\Toggle * @return \FML\Script\Features\Toggle|static
*/ */
public function setLabelName($labelName) { public function setLabelName($labelName) {
$this->labelName = (string)$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 * @param bool $onlyShow Whether it should only show the Control but not toggle
* @return \FML\Script\Features\Toggle * @return \FML\Script\Features\Toggle|static
*/ */
public function setOnlyShow($onlyShow) { public function setOnlyShow($onlyShow) {
$this->onlyShow = (bool)$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 * @param bool $onlyHide Whether it should only hide the Control but not toggle
* @return \FML\Script\Features\Toggle * @return \FML\Script\Features\Toggle|static
*/ */
public function setOnlyHide($onlyHide) { public function setOnlyHide($onlyHide) {
$this->onlyHide = (bool)$onlyHide; $this->onlyHide = (bool)$onlyHide;
@ -112,24 +116,23 @@ class Toggle extends ScriptFeature {
} }
/** /**
* Get the Script Text * Get the script text
* *
* @return string * @return string
*/ */
protected function getScriptText() { protected function getScriptText() {
$togglingControlId = $this->togglingControl->getId(true); $togglingControlId = $this->togglingControl->getId(true, true);
$toggledControlId = $this->toggledControl->getId(true); $toggledControlId = $this->toggledControl->getId(true, true);
$visibility = '!ToggleControl.Visible'; $visibility = '!ToggleControl.Visible';
if ($this->onlyShow) { if ($this->onlyShow) {
$visibility = 'True'; $visibility = 'True';
} else if ($this->onlyHide) { } else if ($this->onlyHide) {
$visibility = 'False'; $visibility = 'False';
} }
$scriptText = " return "
if (Event.Control.ControlId == \"{$togglingControlId}\") { if (Event.Control.ControlId == {$togglingControlId}) {
declare ToggleControl = Page.GetFirstChild(\"{$toggledControlId}\"); declare ToggleControl = Page.GetFirstChild({$toggledControlId});
ToggleControl.Visible = {$visibility}; ToggleControl.Visible = {$visibility};
}"; }";
return $scriptText;
} }
} }

View File

@ -10,7 +10,7 @@ use FML\Script\ScriptLabel;
use FML\Types\Scriptable; use FML\Types\Scriptable;
/** /**
* Script Feature for Showing Tooltips * Script Feature for showing Tooltips
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -18,7 +18,7 @@ use FML\Types\Scriptable;
*/ */
class Tooltip extends ScriptFeature { class Tooltip extends ScriptFeature {
/* /*
* Protected Properties * Protected properties
*/ */
/** @var Control $hoverControl */ /** @var Control $hoverControl */
protected $hoverControl = null; protected $hoverControl = null;
@ -33,23 +33,29 @@ class Tooltip extends ScriptFeature {
* *
* @param Control $hoverControl (optional) Hover Control * @param Control $hoverControl (optional) Hover Control
* @param Control $tooltipControl (optional) Tooltip Control * @param Control $tooltipControl (optional) Tooltip Control
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted * @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 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) { public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = false, $invert = false, $text = null) {
if (!is_null($hoverControl)) {
$this->setHoverControl($hoverControl); $this->setHoverControl($hoverControl);
}
if (!is_null($tooltipControl)) {
$this->setTooltipControl($tooltipControl); $this->setTooltipControl($tooltipControl);
}
$this->setStayOnClick($stayOnClick); $this->setStayOnClick($stayOnClick);
$this->setInvert($invert); $this->setInvert($invert);
if (!is_null($text)) {
$this->setText($text); $this->setText($text);
} }
}
/** /**
* Set the Hover Control * Set the Hover Control
* *
* @param Control $hoverControl Hover Control * @param Control $hoverControl Hover Control
* @return \FML\Script\Features\Tooltip * @return \FML\Script\Features\Tooltip|static
*/ */
public function setHoverControl(Control $hoverControl) { public function setHoverControl(Control $hoverControl) {
$hoverControl->checkId(); $hoverControl->checkId();
@ -64,20 +70,18 @@ class Tooltip extends ScriptFeature {
* Set the Tooltip Control * Set the Tooltip Control
* *
* @param Control $tooltipControl Tooltip Control * @param Control $tooltipControl Tooltip Control
* @return \FML\Script\Features\Tooltip * @return \FML\Script\Features\Tooltip|static
*/ */
public function setTooltipControl(Control $tooltipControl) { public function setTooltipControl(Control $tooltipControl) {
$tooltipControl->checkId(); $this->tooltipControl = $tooltipControl->checkId()->setVisible(false);
$tooltipControl->setVisible(false);
$this->tooltipControl = $tooltipControl;
return $this; return $this;
} }
/** /**
* Set only Show * Set to only show
* *
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click
* @return \FML\Script\Features\Tooltip * @return \FML\Script\Features\Tooltip|static
*/ */
public function setStayOnClick($stayOnClick) { public function setStayOnClick($stayOnClick) {
$this->stayOnClick = (bool)$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 * @param bool $invert (optional) Whether the visibility toggling should be inverted
* @return \FML\Script\Features\Tooltip * @return \FML\Script\Features\Tooltip|static
*/ */
public function setInvert($invert) { public function setInvert($invert) {
$this->invert = (bool)$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 * @param string $text (optional) Text to display if the TooltipControl is a Label
* @return \FML\Script\Features\Tooltip * @return \FML\Script\Features\Tooltip|static
*/ */
public function setText($text) { public function setText($text) {
$this->text = $text; $this->text = (string)$text;
return $this; return $this;
} }
@ -110,20 +114,20 @@ class Tooltip extends ScriptFeature {
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
$hoverControlId = $this->hoverControl->getId(true); $hoverControlId = $this->hoverControl->getId(true, true);
$tooltipControlId = $this->tooltipControl->getId(true); $tooltipControlId = $this->tooltipControl->getId(true, true);
// MouseOver // MouseOver
$visibility = ($this->invert ? 'False' : 'True'); $visibility = ($this->invert ? 'False' : 'True');
$scriptText = " $scriptText = "
if (Event.Control.ControlId == \"{$hoverControlId}\") { if (Event.Control.ControlId == {$hoverControlId}) {
declare TooltipControl = Page.GetFirstChild(\"{$tooltipControlId}\"); declare TooltipControl = Page.GetFirstChild({$tooltipControlId});
TooltipControl.Visible = {$visibility};"; TooltipControl.Visible = {$visibility};";
if (is_string($this->text) && ($this->tooltipControl instanceof Label)) { if (is_string($this->text) && ($this->tooltipControl instanceof Label)) {
$tooltipText = Builder::escapeText($this->text); $tooltipText = Builder::escapeText($this->text, true);
$scriptText .= " $scriptText .= "
declare TooltipLabel = (TooltipControl as CMlLabel); declare TooltipLabel = (TooltipControl as CMlLabel);
TooltipLabel.Value = \"{$tooltipText}\";"; TooltipLabel.Value = {$tooltipText};";
} }
$scriptText .= " $scriptText .= "
}"; }";
@ -132,8 +136,8 @@ if (Event.Control.ControlId == \"{$hoverControlId}\") {
// MouseOut // MouseOut
$visibility = ($this->invert ? 'True' : 'False'); $visibility = ($this->invert ? 'True' : 'False');
$scriptText = " $scriptText = "
if (Event.Control.ControlId == \"{$hoverControlId}\") { if (Event.Control.ControlId == {$hoverControlId}) {
declare TooltipControl = Page.GetFirstChild(\"{$tooltipControlId}\");"; declare TooltipControl = Page.GetFirstChild({$tooltipControlId});";
if ($this->stayOnClick) { if ($this->stayOnClick) {
$scriptText .= " $scriptText .= "
declare FML_Clicked for Event.Control = False; declare FML_Clicked for Event.Control = False;
@ -147,7 +151,7 @@ if (Event.Control.ControlId == \"{$hoverControlId}\") {
// MouseClick // MouseClick
if ($this->stayOnClick) { if ($this->stayOnClick) {
$scriptText = " $scriptText = "
if (Event.Control.ControlId == \"{$hoverControlId}\") { if (Event.Control.ControlId == {$hoverControlId}) {
declare FML_Clicked for Event.Control = False; declare FML_Clicked for Event.Control = False;
FML_Clicked = !FML_Clicked; FML_Clicked = !FML_Clicked;
}"; }";

View File

@ -9,7 +9,7 @@ use FML\Script\ScriptLabel;
use FML\Types\Scriptable; use FML\Types\Scriptable;
/** /**
* Script Feature for playing an UI Sound * Script Feature for playing a UISound
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -50,7 +50,7 @@ class UISound extends ScriptFeature {
const Warning = 'Warning'; const Warning = 'Warning';
/* /*
* Protected Properties * Protected properties
*/ */
protected $soundName = null; protected $soundName = null;
/** @var Control $control */ /** @var Control $control */
@ -62,23 +62,27 @@ class UISound extends ScriptFeature {
/** /**
* Construct a new UISound Feature * Construct a new UISound Feature
* *
* @param string $soundName (optional) Played Sound * @param string $soundName (optional) Played sound
* @param Control $control (optional) Action Control * @param Control $control (optional) Action Control
* @param int $variant (optional) Sound Variant * @param int $variant (optional) Sound variant
* @param string $labelName (optional) Script Label Name * @param string $labelName (optional) Script Label name
*/ */
public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) { public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) {
if (!is_null($soundName)) {
$this->setSoundName($soundName); $this->setSoundName($soundName);
}
if (!is_null($control)) {
$this->setControl($control); $this->setControl($control);
}
$this->setVariant($variant); $this->setVariant($variant);
$this->setLabelName($labelName); $this->setLabelName($labelName);
} }
/** /**
* Set the Sound to play * Set the sound to play
* *
* @param string $soundName Sound Name * @param string $soundName Sound name
* @return \FML\Script\Features\UISound * @return \FML\Script\Features\UISound|static
*/ */
public function setSoundName($soundName) { public function setSoundName($soundName) {
$this->soundName = (string)$soundName; $this->soundName = (string)$soundName;
@ -89,7 +93,7 @@ class UISound extends ScriptFeature {
* Set the Control * Set the Control
* *
* @param Control $control Action Control * @param Control $control Action Control
* @return \FML\Script\Features\UISound * @return \FML\Script\Features\UISound|static
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
@ -101,10 +105,10 @@ class UISound extends ScriptFeature {
} }
/** /**
* Set the Sound Variant * Set the sound variant
* *
* @param int $variant Sound Variant * @param int $variant Sound variant
* @return \FML\Script\Features\UISound * @return \FML\Script\Features\UISound|static
*/ */
public function setVariant($variant) { public function setVariant($variant) {
$this->variant = (int)$variant; $this->variant = (int)$variant;
@ -112,10 +116,10 @@ class UISound extends ScriptFeature {
} }
/** /**
* Set the Volume * Set the volume
* *
* @param float $volume Sound Volume * @param float $volume Sound volume
* @return \FML\Script\Features\UISound * @return \FML\Script\Features\UISound|static
*/ */
public function setVolume($volume) { public function setVolume($volume) {
$this->volume = (float)$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 * @param string $labelName Script Label name
* @return \FML\Script\Features\UISound * @return \FML\Script\Features\UISound|static
*/ */
public function setLabelName($labelName) { public function setLabelName($labelName) {
$this->labelName = (string)$labelName; $this->labelName = (string)$labelName;
@ -142,16 +146,16 @@ class UISound extends ScriptFeature {
} }
/** /**
* Get the Script Text * Get the script text
* *
* @return string * @return string
*/ */
protected function getScriptText() { protected function getScriptText() {
if ($this->control) { if ($this->control) {
// Control event // Control event
$controlId = Builder::escapeText($this->control->getId()); $controlId = Builder::escapeText($this->control->getId(), true);
$scriptText = " $scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") { if (Event.Control.ControlId == {$controlId}) {
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume}); PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});
}"; }";
} else { } else {

View File

@ -10,7 +10,7 @@ use FML\Script\ScriptInclude;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
/** /**
* Script Feature for creating a ValuePicker Behavior * Script Feature for creating a ValuePicker behavior
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -26,13 +26,13 @@ class ValuePickerFeature extends ScriptFeature {
const VAR_PICKER_ENTRY_ID = 'FML_Picker_EntryId'; const VAR_PICKER_ENTRY_ID = 'FML_Picker_EntryId';
/* /*
* Protected Properties * Protected properties
*/ */
/** @var Label $label */ /** @var Label $label */
protected $label = null; protected $label = null;
/** @var Entry $entry */ /** @var Entry $entry */
protected $entry = null; protected $entry = null;
protected $values = null; protected $values = array();
protected $default = null; protected $default = null;
/** /**
@ -40,28 +40,32 @@ class ValuePickerFeature extends ScriptFeature {
* *
* @param Label $label (optional) ValuePicker Label * @param Label $label (optional) ValuePicker Label
* @param Entry $entry (optional) Hidden Entry * @param Entry $entry (optional) Hidden Entry
* @param array $values (optional) Possible Values * @param array $values (optional) Possible values
* @param string $default (optional) Default Value * @param string $default (optional) Default value
*/ */
public function __construct(Label $label = null, Entry $entry = null, array $values = array(), $default = null) { public function __construct(Label $label = null, Entry $entry = null, array $values = array(), $default = null) {
if (!is_null($label)) {
$this->setLabel($label); $this->setLabel($label);
}
if (!is_null($entry)) {
$this->setEntry($entry); $this->setEntry($entry);
}
if (!empty($values)) {
$this->setValues($values); $this->setValues($values);
}
if (!is_null($default)) {
$this->setDefault($default); $this->setDefault($default);
} }
}
/** /**
* Set the ValuePicker Label * Set the ValuePicker Label
* *
* @param Label $label ValuePicker Label * @param Label $label ValuePicker Label
* @return \FML\Script\Features\ValuePickerFeature * @return \FML\Script\Features\ValuePickerFeature|static
*/ */
public function setLabel(Label $label = null) { public function setLabel(Label $label) {
if ($label) { $this->label = $label->checkId()->setScriptEvents(true);
$label->checkId();
$label->setScriptEvents(true);
}
$this->label = $label;
return $this; return $this;
} }
@ -78,13 +82,10 @@ class ValuePickerFeature extends ScriptFeature {
* Set the hidden Entry * Set the hidden Entry
* *
* @param Entry $entry Hidden Entry * @param Entry $entry Hidden Entry
* @return \FML\Script\Features\ValuePickerFeature * @return \FML\Script\Features\ValuePickerFeature|static
*/ */
public function setEntry(Entry $entry = null) { public function setEntry(Entry $entry) {
if ($entry) { $this->entry = $entry->checkId();
$entry->checkId();
}
$this->entry = $entry;
return $this; return $this;
} }
@ -98,10 +99,10 @@ class ValuePickerFeature extends ScriptFeature {
} }
/** /**
* Set the possible Values * Set the possible values
* *
* @param array $values Possible Values * @param array $values Possible values
* @return \FML\Script\Features\ValuePickerFeature * @return \FML\Script\Features\ValuePickerFeature|static
*/ */
public function setValues(array $values) { public function setValues(array $values) {
$this->values = array(); $this->values = array();
@ -112,17 +113,17 @@ class ValuePickerFeature extends ScriptFeature {
} }
/** /**
* Set the default Value * Set the default value
* *
* @param string $default Default Value * @param string $default Default value
* @return \FML\Script\Features\ValuePickerFeature * @return \FML\Script\Features\ValuePickerFeature|static
*/ */
public function setDefault($default) { public function setDefault($default) {
$this->default = (string)$default; $this->default = (string)$default;
} }
/** /**
* Get the default Value * Get the default value
* *
* @return string * @return string
*/ */
@ -130,7 +131,7 @@ class ValuePickerFeature extends ScriptFeature {
if ($this->default) { if ($this->default) {
return $this->default; return $this->default;
} }
if ($this->values) { if (!empty($this->values)) {
return reset($this->values); return reset($this->values);
} }
return null; return null;
@ -150,12 +151,12 @@ class ValuePickerFeature extends ScriptFeature {
} }
/** /**
* Build the Function Text * Build the function text
* *
* @return string * @return string
*/ */
protected function buildUpdatePickerValueFunction() { protected function buildUpdatePickerValueFunction() {
$functionText = " return "
Void " . self::FUNCTION_UPDATE_PICKER_VALUE . "(CMlLabel _Label) { Void " . self::FUNCTION_UPDATE_PICKER_VALUE . "(CMlLabel _Label) {
declare " . self::VAR_PICKER_VALUES . " as Values for _Label = Text[]; declare " . self::VAR_PICKER_VALUES . " as Values for _Label = Text[];
declare NewValueIndex = -1; declare NewValueIndex = -1;
@ -168,61 +169,58 @@ Void " . self::FUNCTION_UPDATE_PICKER_VALUE . "(CMlLabel _Label) {
NewValueIndex = 0; NewValueIndex = 0;
} }
} }
declare NewValue = \"\"; declare NewValue = " . Builder::EMPTY_STRING . ";
if (Values.existskey(NewValueIndex)) { if (Values.existskey(NewValueIndex)) {
NewValue = Values[NewValueIndex]; NewValue = Values[NewValueIndex];
} else { } 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; NewValue = Default;
} }
_Label.Value = NewValue; _Label.Value = NewValue;
declare " . self::VAR_PICKER_ENTRY_ID . " as EntryId for _Label = \"\"; declare " . self::VAR_PICKER_ENTRY_ID . " as EntryId for _Label = " . Builder::EMPTY_STRING . ";
if (EntryId != \"\") { if (EntryId != " . Builder::EMPTY_STRING . ") {
declare Entry <=> (Page.GetFirstChild(EntryId) as CMlEntry); declare Entry <=> (Page.GetFirstChild(EntryId) as CMlEntry);
Entry.Value = NewValue; Entry.Value = NewValue;
} }
}"; }";
return $functionText;
} }
/** /**
* Build the Init Script Text * Build the init script text
* *
* @return string * @return string
*/ */
protected function buildInitScriptText() { protected function buildInitScriptText() {
$labelId = $this->label->getId(true); $labelId = $this->label->getId(true, true);
$entryId = ''; $entryId = '""';
if ($this->entry) { if ($this->entry) {
$entryId = $this->entry->getId(true); $entryId = $this->entry->getId(true, true);
} }
$values = Builder::getArray($this->values); $values = Builder::getArray($this->values);
$default = $this->getDefault(); $default = Builder::escapeText($this->getDefault(), true);
$scriptText = " return "
declare Label_Picker <=> (Page.GetFirstChild(\"{$labelId}\") as CMlLabel); declare Label_Picker <=> (Page.GetFirstChild({$labelId}) as CMlLabel);
declare Text[] " . self::VAR_PICKER_VALUES . " as Values for Label_Picker; declare Text[] " . self::VAR_PICKER_VALUES . " as Values for Label_Picker;
Values = {$values}; Values = {$values};
declare Text " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for Label_Picker; 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; declare Text " . self::VAR_PICKER_ENTRY_ID . " as EntryId for Label_Picker;
EntryId = \"{$entryId}\"; EntryId = {$entryId};
" . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker); " . 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 * @return string
*/ */
protected function buildClickScriptText() { protected function buildClickScriptText() {
$labelId = $this->label->getId(true); $labelId = $this->label->getId(true, true);
$scriptText = " return "
if (Event.ControlId == \"{$labelId}\") { if (Event.ControlId == {$labelId}) {
declare Label_Picker <=> (Event.Control as CMlLabel); declare Label_Picker <=> (Event.Control as CMlLabel);
" . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker); " . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker);
}"; }";
return $scriptText;
} }
} }

View File

@ -21,7 +21,7 @@ class Script {
const VAR_LastTick = 'FML_LastTick'; const VAR_LastTick = 'FML_LastTick';
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'script'; protected $tagName = 'script';
protected $features = array(); protected $features = array();
@ -34,9 +34,9 @@ class Script {
/** /**
* Set a Script Include * Set a Script Include
* *
* @param string $file Include File * @param string $file Include file
* @param string $namespace Include Namespace * @param string $namespace Include namespace
* @return \FML\Script\Script * @return \FML\Script\Script|static
*/ */
public function setScriptInclude($file, $namespace = null) { public function setScriptInclude($file, $namespace = null) {
if (is_object($file) && ($file instanceof ScriptInclude)) { if (is_object($file) && ($file instanceof ScriptInclude)) {
@ -44,17 +44,16 @@ class Script {
} else { } else {
$scriptInclude = new ScriptInclude($file, $namespace); $scriptInclude = new ScriptInclude($file, $namespace);
} }
$namespace = $scriptInclude->getNamespace(); $this->includes[$scriptInclude->getNamespace()] = $scriptInclude;
$this->includes[$namespace] = $scriptInclude;
return $this; return $this;
} }
/** /**
* Add a Script Constant * Add a Script Constant
* *
* @param string $name Constant Name * @param string $name Constant name
* @param string $value Constant Value * @param string $value Constant value
* @return \FML\Script\Script * @return \FML\Script\Script|static
*/ */
public function addScriptConstant($name, $value = null) { public function addScriptConstant($name, $value = null) {
if (is_object($name) && ($name instanceof ScriptConstant)) { if (is_object($name) && ($name instanceof ScriptConstant)) {
@ -62,16 +61,18 @@ class Script {
} else { } else {
$scriptConstant = new ScriptConstant($name, $value); $scriptConstant = new ScriptConstant($name, $value);
} }
if (!in_array($scriptConstant, $this->constants)) {
array_push($this->constants, $scriptConstant); array_push($this->constants, $scriptConstant);
}
return $this; return $this;
} }
/** /**
* Add a Script Function * Add a Script Function
* *
* @param string $name Function Name * @param string $name Function name
* @param string $text Function Text * @param string $text Function text
* @return \FML\Script\Script * @return \FML\Script\Script|static
*/ */
public function addScriptFunction($name, $text = null) { public function addScriptFunction($name, $text = null) {
if (is_object($name) && ($name instanceof ScriptFunction)) { 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 $name Label name
* @param string $text Script Text * @param string $text Script text
* @return \FML\Script\Script * @return \FML\Script\Script|static
*/ */
public function addCustomScriptLabel($name, $text = null) { public function addCustomScriptLabel($name, $text = null) {
if (is_object($name) && ($name instanceof ScriptLabel)) { 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 $name Label name
* @param string $text Script Text * @param string $text Script text
* @param bool $isolated (optional) Whether to isolate the Label Script * @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) { public function appendGenericScriptLabel($name, $text = null, $isolated = false) {
if (is_object($name) && ($name instanceof ScriptLabel)) { 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() { public function resetGenericScriptLabels() {
$this->genericLabels = array(); $this->genericLabels = array();
@ -131,13 +132,15 @@ class Script {
} }
/** /**
* Add an own Script Feature * Add a Script Feature
* *
* @param ScriptFeature $feature Script Feature * @param ScriptFeature $feature Script Feature
* @return \FML\Script\Script * @return \FML\Script\Script|static
*/ */
public function addFeature(ScriptFeature $feature) { public function addFeature(ScriptFeature $feature) {
if (!in_array($feature, $this->features, true)) {
array_push($this->features, $feature); array_push($this->features, $feature);
}
return $this; return $this;
} }
@ -145,7 +148,7 @@ class Script {
* Load the given Script Feature * Load the given Script Feature
* *
* @param ScriptFeature $scriptFeature Script Feature to load * @param ScriptFeature $scriptFeature Script Feature to load
* @return \FML\Script\Script * @return \FML\Script\Script|static
*/ */
public function loadFeature(ScriptFeature $scriptFeature) { public function loadFeature(ScriptFeature $scriptFeature) {
$scriptFeature->prepare($this); $scriptFeature->prepare($this);
@ -155,8 +158,8 @@ class Script {
/** /**
* Load the given Script Features * Load the given Script Features
* *
* @param array $scriptFeatures Script Features to load * @param ScriptFeature[] $scriptFeatures Script Features to load
* @return \FML\Script\Script * @return \FML\Script\Script|static
*/ */
public function loadFeatures(array $scriptFeatures) { public function loadFeatures(array $scriptFeatures) {
foreach ($scriptFeatures as $scriptFeature) { 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 * @return bool
*/ */
@ -178,7 +181,7 @@ class Script {
} }
/** /**
* Build the complete Script Text * Build the complete Script text
* *
* @return string * @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 * @return \DOMElement
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
@ -209,7 +212,7 @@ class Script {
} }
/** /**
* Get the Header Comment * Get the header comment
* *
* @return string * @return string
*/ */
@ -224,7 +227,7 @@ class Script {
} }
/** /**
* Get the Includes * Get the Includes text
* *
* @return string * @return string
*/ */
@ -234,7 +237,7 @@ class Script {
} }
/** /**
* Get the Constants * Get the Constants text
* *
* @return string * @return string
*/ */
@ -244,7 +247,7 @@ class Script {
} }
/** /**
* Get the Functions * Get the Functions text
* *
* @return string * @return string
*/ */
@ -254,7 +257,7 @@ class Script {
} }
/** /**
* Get the Labels * Get the Labels text
* *
* @return string * @return string
*/ */
@ -265,7 +268,7 @@ class Script {
} }
/** /**
* Get the Main Function * Get the main function text
* *
* @return string * @return string
*/ */

View File

@ -11,7 +11,7 @@ namespace FML\Script;
*/ */
class ScriptConstant { class ScriptConstant {
/* /*
* Protected Properties * Protected properties
*/ */
protected $name = null; protected $name = null;
protected $value = null; protected $value = null;
@ -19,8 +19,8 @@ class ScriptConstant {
/** /**
* Construct a new Script Constant * Construct a new Script Constant
* *
* @param string $name (optional) Constant Name * @param string $name (optional) Constant name
* @param string $value (optional) Constant Value * @param string $value (optional) Constant value
*/ */
public function __construct($name = null, $value = null) { public function __construct($name = null, $value = null) {
$this->setName($name); $this->setName($name);
@ -28,21 +28,21 @@ class ScriptConstant {
} }
/** /**
* Set the Name * Set the name
* *
* @param string $name Constant Name * @param string $name Constant name
* @return \FML\Script\ScriptConstant * @return \FML\Script\ScriptConstant|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = $name; $this->name = (string)$name;
return $this; return $this;
} }
/** /**
* Set the Value * Set the value
* *
* @param string $value Constant Value * @param string $value Constant value
* @return \FML\Script\ScriptConstant * @return \FML\Script\ScriptConstant|static
*/ */
public function setValue($value) { public function setValue($value) {
$this->value = $value; $this->value = $value;
@ -50,12 +50,11 @@ class ScriptConstant {
} }
/** /**
* Build the Script Constant Text * Build the Script Constant text
* *
* @return string * @return string
*/ */
public function __toString() { public function __toString() {
$scriptText = Builder::getConstant($this->name, $this->value); return Builder::getConstant($this->name, $this->value);
return $scriptText;
} }
} }

View File

@ -11,7 +11,7 @@ namespace FML\Script;
*/ */
class ScriptFunction { class ScriptFunction {
/* /*
* Protected Properties * Protected properties
*/ */
protected $name = null; protected $name = null;
protected $text = null; protected $text = null;
@ -19,8 +19,8 @@ class ScriptFunction {
/** /**
* Construct a new Script Function * Construct a new Script Function
* *
* @param string $name (optional) Function Name * @param string $name (optional) Function name
* @param string $text (optional) Function Text * @param string $text (optional) Function text
*/ */
public function __construct($name = null, $text = null) { public function __construct($name = null, $text = null) {
$this->setName($name); $this->setName($name);
@ -28,10 +28,10 @@ class ScriptFunction {
} }
/** /**
* Set the Name * Set the name
* *
* @param string $name Function Name * @param string $name Function name
* @return \FML\Script\ScriptFunction * @return \FML\Script\ScriptFunction|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -39,10 +39,10 @@ class ScriptFunction {
} }
/** /**
* Set the Text * Set the text
* *
* @param string $text Function Text * @param string $text Function text
* @return \FML\Script\ScriptFunction * @return \FML\Script\ScriptFunction|static
*/ */
public function setText($text) { public function setText($text) {
$this->text = (string)$text; $this->text = (string)$text;
@ -50,7 +50,7 @@ class ScriptFunction {
} }
/** /**
* Get the Script Function Text * Get the Script Function text
* *
* @return string * @return string
*/ */

View File

@ -17,7 +17,7 @@ class ScriptInclude {
const TEXTLIB = 'TextLib'; const TEXTLIB = 'TextLib';
/* /*
* Protected Properties * Protected properties
*/ */
protected $file = null; protected $file = null;
protected $namespace = null; protected $namespace = null;
@ -25,8 +25,8 @@ class ScriptInclude {
/** /**
* Construct a new Script Include * Construct a new Script Include
* *
* @param string $file (optional) Include File * @param string $file (optional) Include file
* @param string $namespace (optional) Include Namespace * @param string $namespace (optional) Include namespace
*/ */
public function __construct($file = null, $namespace = null) { public function __construct($file = null, $namespace = null) {
$this->setFile($file); $this->setFile($file);
@ -34,10 +34,10 @@ class ScriptInclude {
} }
/** /**
* Set the File * Set the file
* *
* @param string $file Include File * @param string $file Include file
* @return \FML\Script\ScriptInclude * @return \FML\Script\ScriptInclude|static
*/ */
public function setFile($file) { public function setFile($file) {
$this->file = (string)$file; $this->file = (string)$file;
@ -45,10 +45,10 @@ class ScriptInclude {
} }
/** /**
* Set the Namespace * Set the namespace
* *
* @param string $namespace Include Namespace * @param string $namespace Include namespace
* @return \FML\Script\ScriptInclude * @return \FML\Script\ScriptInclude|static
*/ */
public function setNamespace($namespace) { public function setNamespace($namespace) {
$this->namespace = (string)$namespace; $this->namespace = (string)$namespace;
@ -56,7 +56,7 @@ class ScriptInclude {
} }
/** /**
* Get the Namespace * Get the namespace
* *
* @return string * @return string
*/ */
@ -65,12 +65,11 @@ class ScriptInclude {
} }
/** /**
* Build the Script Include Text * Build the Script Include text
* *
* @return string * @return string
*/ */
public function __toString() { public function __toString() {
$scriptText = Builder::getInclude($this->file, $this->namespace); return Builder::getInclude($this->file, $this->namespace);
return $scriptText;
} }
} }

View File

@ -3,7 +3,7 @@
namespace FML\Script; namespace FML\Script;
/** /**
* Class representing a Part of the ManiaLink Script * Class representing a part of the ManiaLink Script
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -23,7 +23,7 @@ class ScriptLabel {
const MOUSEOVER = 'FML_MouseOver'; const MOUSEOVER = 'FML_MouseOver';
/* /*
* Protected Properties * Protected properties
*/ */
protected $name = null; protected $name = null;
protected $text = null; protected $text = null;
@ -32,21 +32,21 @@ class ScriptLabel {
/** /**
* Construct a new ScriptLabel * Construct a new ScriptLabel
* *
* @param string $name (optional) Label Name * @param string $name (optional) Label name
* @param string $text (optional) Script Text * @param string $text (optional) Script text
* @param bool $isolated (optional) Isolate the Label Script * @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->setName($name);
$this->setText($text); $this->setText($text);
$this->setIsolated($isolated); $this->setIsolated($isolated);
} }
/** /**
* Set the Name * Set the name
* *
* @param string $name Label Name * @param string $name Label name
* @return \FML\Script\ScriptLabel * @return \FML\Script\ScriptLabel|static
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string)$name; $this->name = (string)$name;
@ -54,10 +54,10 @@ class ScriptLabel {
} }
/** /**
* Set the Text * Set the text
* *
* @param string $text Script Text * @param string $text Script text
* @return \FML\Script\ScriptLabel * @return \FML\Script\ScriptLabel|static
*/ */
public function setText($text) { public function setText($text) {
$this->text = (string)$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 * @param bool $isolated Whether the code should be isolated in an own block
* @return \FML\Script\ScriptLabel * @return \FML\Script\ScriptLabel|static
*/ */
public function setIsolated($isolated) { public function setIsolated($isolated) {
$this->isolated = (bool)$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 * @return bool
*/ */
public static function isEventLabel($label) { public static function isEventLabel($label) {
$eventLabels = self::getEventLabels(); if (in_array($label, static::getEventLabels())) {
if (in_array($label, $eventLabels)) {
return true; return true;
} }
return false; return false;
} }
/** /**
* Get the possible Event Label Names * Get the possible event label names
* *
* @return array * @return string[]
*/ */
public static function getEventLabels() { public static function getEventLabels() {
return array(self::ENTRYSUBMIT, self::KEYPRESS, self::MOUSECLICK, self::MOUSEOUT, self::MOUSEOVER); 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 * @return string
*/ */
public function __toString() { public function __toString() {
$scriptText = Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated); return Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated);
return $scriptText;
} }
} }

View File

@ -6,7 +6,7 @@ namespace FML\Stylesheet;
// Missing attributes: LDir1.. // Missing attributes: LDir1..
/** /**
* Class representing a Stylesheets Mood * Class representing a Stylesheet Mood
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -14,109 +14,90 @@ namespace FML\Stylesheet;
*/ */
class Mood { class Mood {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'mood'; protected $tagName = 'mood';
protected $lAmbient_LinearRgb = ''; protected $lAmbient_LinearRgb = null;
protected $cloudsRgbMinLinear = ''; protected $cloudsRgbMinLinear = null;
protected $cloudsRgbMaxLinear = ''; protected $cloudsRgbMaxLinear = null;
protected $lDir0_LinearRgb = ''; protected $lDir0_LinearRgb = null;
protected $lDir0_Intens = 1.; protected $lDir0_Intens = 1.;
protected $lDir0_DirPhi = 0.; protected $lDir0_DirPhi = 0.;
protected $lDir0_DirTheta = 0.; protected $lDir0_DirTheta = 0.;
protected $lBall_LinearRgb = ''; protected $lBall_LinearRgb = null;
protected $lBall_Intensity = 1.; protected $lBall_Intensity = 1.;
protected $lBall_Radius = 0.; protected $lBall_Radius = 0.;
protected $fogColorSrgb = ''; protected $fogColorSrgb = null;
protected $selfIllumColor = ''; protected $selfIllumColor = null;
protected $skyGradientV_Scale = 1.; protected $skyGradientV_Scale = 1.;
protected $skyGradientKeys = array(); protected $skyGradientKeys = array();
/** /**
* Create a new Mood Object * Create a new Mood object
* *
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public static function create() { public static function create() {
$mood = new Mood(); return new static();
return $mood;
} }
/** /**
* Construct a new Mood Object * Set ambient color in which the Elements reflect the light
*/
public function __construct() {
}
/**
* Set Ambient Color in which the Elements reflect the Light
* *
* @param float $red Red Color Value * @param float $red Red color value
* @param float $green Green Color Value * @param float $green Green color value
* @param float $blue Blue Color Value * @param float $blue Blue color value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setLightAmbientColor($red, $green, $blue) { public function setLightAmbientColor($red, $green, $blue) {
$red = (float)$red; $this->lAmbient_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
$green = (float)$green;
$blue = (float)$blue;
$this->lAmbient_LinearRgb = "{$red} {$green} {$blue}";
return $this; return $this;
} }
/** /**
* Set Minimum Value for the Background Color Range * Set minimum value for the background color range
* *
* @param float $red Red Color Value * @param float $red Red color value
* @param float $green Green Color Value * @param float $green Green color value
* @param float $blue Blue Color Value * @param float $blue Blue color value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setCloudsColorMin($red, $green, $blue) { public function setCloudsColorMin($red, $green, $blue) {
$red = (float)$red; $this->cloudsRgbMinLinear = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
$green = (float)$green;
$blue = (float)$blue;
$this->cloudsRgbMinLinear = "{$red} {$green} {$blue}";
return $this; return $this;
} }
/** /**
* Set Maximum Value for the Background Color Range * Set maximum value for the background color range
* *
* @param float $red Red Color Value * @param float $red Red color value
* @param float $green Green Color Value * @param float $green Green color value
* @param float $blue Blue Color Value * @param float $blue Blue color value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setCloudsColorMax($red, $green, $blue) { public function setCloudsColorMax($red, $green, $blue) {
$red = (float)$red; $this->cloudsRgbMaxLinear = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
$green = (float)$green;
$blue = (float)$blue;
$this->cloudsRgbMaxLinear = "{$red} {$green} {$blue}";
return $this; return $this;
} }
/** /**
* Set RGB Color of Light Source 0 * Set RGB color of light source 0
* *
* @param float $red Red Color Value * @param float $red Red color value
* @param float $green Green Color Value * @param float $green Green color value
* @param float $blue Blue Color Value * @param float $blue Blue color value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setLight0Color($red, $green, $blue) { public function setLight0Color($red, $green, $blue) {
$red = (float)$red; $this->lDir0_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
$green = (float)$green;
$blue = (float)$blue;
$this->lDir0_LinearRgb = "{$red} {$green} {$blue}";
return $this; return $this;
} }
/** /**
* Set Intensity of Light Source 0 * Set intensity of light source 0
* *
* @param float $intensity Light Intensity * @param float $intensity Light intensity
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setLight0Intensity($intensity) { public function setLight0Intensity($intensity) {
$this->lDir0_Intens = (float)$intensity; $this->lDir0_Intens = (float)$intensity;
@ -124,10 +105,10 @@ class Mood {
} }
/** /**
* Set Phi-Angle of Light Source 0 * Set phi angle of light source 0
* *
* @param float $phiAngle Phi-Angle * @param float $phiAngle Phi angle
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setLight0PhiAngle($phiAngle) { public function setLight0PhiAngle($phiAngle) {
$this->lDir0_DirPhi = (float)$phiAngle; $this->lDir0_DirPhi = (float)$phiAngle;
@ -135,10 +116,10 @@ class Mood {
} }
/** /**
* Set Theta-Angle of Light Source 0 * Set theta angle of light source 0
* *
* @param float $thetaAngle Theta-Angle * @param float $thetaAngle Theta angle
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setLight0ThetaAngle($thetaAngle) { public function setLight0ThetaAngle($thetaAngle) {
$this->lDir0_DirTheta = (float)$thetaAngle; $this->lDir0_DirTheta = (float)$thetaAngle;
@ -146,26 +127,23 @@ class Mood {
} }
/** /**
* Set Light Ball Color * Set light ball color
* *
* @param float $red Red Color Value * @param float $red Red color value
* @param float $green Green Color Value * @param float $green Green color value
* @param float $blue Blue Color Value * @param float $blue Blue color value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setLightBallColor($red, $green, $blue) { public function setLightBallColor($red, $green, $blue) {
$red = (float)$red; $this->lBall_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
$green = (float)$green;
$blue = (float)$blue;
$this->lBall_LinearRgb = "{$red} {$green} {$blue}";
return $this; return $this;
} }
/** /**
* Set Light Ball Intensity * Set light ball intensity
* *
* @param float $intensity Light Ball Intensity * @param float $intensity Light ball intensity
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setLightBallIntensity($intensity) { public function setLightBallIntensity($intensity) {
$this->lBall_Intensity = (float)$intensity; $this->lBall_Intensity = (float)$intensity;
@ -173,10 +151,10 @@ class Mood {
} }
/** /**
* Set Light Ball Radius * Set light ball radius
* *
* @param float $radius Light Ball Radius * @param float $radius Light ball radius
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setLightBallRadius($radius) { public function setLightBallRadius($radius) {
$this->lBall_Radius = (float)$radius; $this->lBall_Radius = (float)$radius;
@ -184,42 +162,36 @@ class Mood {
} }
/** /**
* Set Fog Color * Set fog color
* *
* @param float $red Red Color Value * @param float $red Red color value
* @param float $green Green Color Value * @param float $green Green color value
* @param float $blue Blue Color Value * @param float $blue Blue color value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setFogColor($red, $green, $blue) { public function setFogColor($red, $green, $blue) {
$red = (float)$red; $this->fogColorSrgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
$green = (float)$green;
$blue = (float)$blue;
$this->fogColorSrgb = "{$red} {$green} {$blue}";
return $this; return $this;
} }
/** /**
* Set Self Illumination Color * Set self illumination color
* *
* @param float $red Red Color Value * @param float $red Red color value
* @param float $green Green Color Value * @param float $green Green color value
* @param float $blue Blue Color Value * @param float $blue Blue color value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setSelfIllumColor($red, $green, $blue) { public function setSelfIllumColor($red, $green, $blue) {
$red = (float)$red; $this->selfIllumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
$green = (float)$green;
$blue = (float)$blue;
$this->selfIllumColor = "{$red} {$green} {$blue}";
return $this; return $this;
} }
/** /**
* Set Sky Gradient Scale * Set sky gradient scale
* *
* @param float $scale Gradient Scale * @param float $scale Gradient scale
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function setSkyGradientScale($scale) { public function setSkyGradientScale($scale) {
$this->skyGradientV_Scale = (float)$scale; $this->skyGradientV_Scale = (float)$scale;
@ -227,24 +199,24 @@ class Mood {
} }
/** /**
* Add a Key for the SkyGradient * Add a sky gradient key
* *
* @param float $x Scale Value * @param float $gradientX Scale value
* @param string $color Gradient Color * @param string $color Gradient color
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function addSkyGradientKey($x, $color) { public function addSkyGradientKey($gradientX, $color) {
$x = (float)$x; $gradientX = (float)$gradientX;
$color = (string)$color; $color = (string)$color;
$gradientKey = array('x' => $x, 'color' => $color); $gradientKey = array('x' => $gradientX, 'color' => $color);
array_push($this->skyGradientKeys, $gradientKey); array_push($this->skyGradientKeys, $gradientKey);
return $this; return $this;
} }
/** /**
* Remove all SkyGradient Keys * Remove all sky gradient keys
* *
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood|static
*/ */
public function removeSkyGradientKeys() { public function removeSkyGradientKeys() {
$this->skyGradientKeys = array(); $this->skyGradientKeys = array();
@ -252,9 +224,9 @@ class Mood {
} }
/** /**
* Render the Mood XML Element * Render the Mood XML element
* *
* @param \DOMDocument $domDocument DomDocument for which the Mood XML Element should be rendered * @param \DOMDocument $domDocument DOMDocument for which the Mood XML element should be rendered
* @return \DOMElement * @return \DOMElement
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -2,8 +2,10 @@
namespace FML\Stylesheet; namespace FML\Stylesheet;
use FML\UniqueID;
/** /**
* Class representing a specific Style3d * Class representing a Style3d
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -20,10 +22,10 @@ class Style3d {
const MODEL_Window = 'Window'; const MODEL_Window = 'Window';
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'style3d'; protected $tagName = 'style3d';
protected $id = null; protected $styleId = null;
protected $model = self::MODEL_Box; protected $model = self::MODEL_Box;
protected $thickness = null; protected $thickness = null;
protected $color = null; protected $color = null;
@ -36,64 +38,63 @@ class Style3d {
protected $focusZOffset = null; protected $focusZOffset = null;
/** /**
* Create a new Style3d Object * Create a new Style3d object
* *
* @param string $id (optional) Style Id * @param string $styleId (optional) Style id
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public static function create($id = null) { public static function create($styleId = null) {
$style3d = new Style3d($id); return new static($styleId);
return $style3d;
} }
/** /**
* Construct a new Style3d Object * Construct a new Style3d object
* *
* @param string $id (optional) Style Id * @param string $styleId (optional) Style id
*/ */
public function __construct($id = null) { public function __construct($styleId = null) {
if ($id !== null) { if (!is_null($styleId)) {
$this->setId($id); $this->setId($styleId);
} }
} }
/** /**
* Set Style Id * Set style id
* *
* @param string $id Style Id * @param string $styleId Style id
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setId($id) { public function setId($styleId) {
$this->id = (string)$id; $this->styleId = (string)$styleId;
return $this; return $this;
} }
/** /**
* Check for Id and assign one if necessary * Check for id and assign one if necessary
* *
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function checkId() { public function checkId() {
if (!$this->id) { if (!$this->styleId) {
$this->id = uniqid(); $this->setId(new UniqueID());
} }
return $this; return $this;
} }
/** /**
* Get Style Id * Get style id
* *
* @return string * @return string
*/ */
public function getId() { public function getId() {
return $this->id; return $this->styleId;
} }
/** /**
* Set Model * Set model
* *
* @param string $model Style Model * @param string $model Style model
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setModel($model) { public function setModel($model) {
$this->model = (string)$model; $this->model = (string)$model;
@ -101,10 +102,10 @@ class Style3d {
} }
/** /**
* Set Thickness * Set thickness
* *
* @param float $thickness Style Thickness * @param float $thickness Style thickness
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setThickness($thickness) { public function setThickness($thickness) {
$this->thickness = (float)$thickness; $this->thickness = (float)$thickness;
@ -112,10 +113,10 @@ class Style3d {
} }
/** /**
* Set Color * Set color
* *
* @param string $color Style Color * @param string $color Style color
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setColor($color) { public function setColor($color) {
$this->color = (string)$color; $this->color = (string)$color;
@ -123,10 +124,10 @@ class Style3d {
} }
/** /**
* Set Focus Color * Set focus color
* *
* @param string $focusColor Style Focus Color * @param string $focusColor Style focus color
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setFocusColor($focusColor) { public function setFocusColor($focusColor) {
$this->focusColor = (string)$focusColor; $this->focusColor = (string)$focusColor;
@ -134,10 +135,10 @@ class Style3d {
} }
/** /**
* Set Light Color * Set light color
* *
* @param string $lightColor Light Color * @param string $lightColor Light color
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setLightColor($lightColor) { public function setLightColor($lightColor) {
$this->lightColor = (string)$lightColor; $this->lightColor = (string)$lightColor;
@ -145,10 +146,10 @@ class Style3d {
} }
/** /**
* Set Focus Light Color * Set focus light color
* *
* @param string $focusLightColor Focus Light Color * @param string $focusLightColor Focus light color
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setFocusLightColor($focusLightColor) { public function setFocusLightColor($focusLightColor) {
$this->focusLightColor = (string)$focusLightColor; $this->focusLightColor = (string)$focusLightColor;
@ -156,10 +157,10 @@ class Style3d {
} }
/** /**
* Set Y-Offset * Set Y-offset
* *
* @param float $yOffset Y-Offset * @param float $yOffset Y-offset
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setYOffset($yOffset) { public function setYOffset($yOffset) {
$this->yOffset = (float)$yOffset; $this->yOffset = (float)$yOffset;
@ -167,10 +168,10 @@ class Style3d {
} }
/** /**
* Set Focus Y-Offset * Set focus Y-offset
* *
* @param float $focusYOffset Focus Y-Offset * @param float $focusYOffset Focus Y-offset
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setFocusYOffset($focusYOffset) { public function setFocusYOffset($focusYOffset) {
$this->focusYOffset = (float)$focusYOffset; $this->focusYOffset = (float)$focusYOffset;
@ -178,10 +179,10 @@ class Style3d {
} }
/** /**
* Set Z-Offset * Set Z-offset
* *
* @param float $zOffset Z-Offset * @param float $zOffset Z-offset
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setZOffset($zOffset) { public function setZOffset($zOffset) {
$this->zOffset = (float)$zOffset; $this->zOffset = (float)$zOffset;
@ -189,10 +190,10 @@ class Style3d {
} }
/** /**
* Set Focus Z-Offset * Set focus Z-offset
* *
* @param float $focusZOffset Focus Z-Offset * @param float $focusZOffset Focus Z-offset
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d|static
*/ */
public function setFocusZOffset($focusZOffset) { public function setFocusZOffset($focusZOffset) {
$this->focusZOffset = (float)$focusZOffset; $this->focusZOffset = (float)$focusZOffset;
@ -200,16 +201,16 @@ class Style3d {
} }
/** /**
* Render the Style3d XML Element * Render the Style3d XML element
* *
* @param \DOMDocument $domDocument DomDocument for which the Style3d XML Element should be rendered * @param \DOMDocument $domDocument DOMDocument for which the Style3d XML element should be rendered
* @return \DOMElement * @return \DOMElement
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$style3dXml = $domDocument->createElement($this->tagName); $style3dXml = $domDocument->createElement($this->tagName);
$this->checkId(); $this->checkId();
if ($this->id) { if ($this->styleId) {
$style3dXml->setAttribute('id', $this->id); $style3dXml->setAttribute('id', $this->styleId);
} }
if ($this->model) { if ($this->model) {
$style3dXml->setAttribute('model', $this->model); $style3dXml->setAttribute('model', $this->model);

View File

@ -3,7 +3,7 @@
namespace FML\Stylesheet; namespace FML\Stylesheet;
/** /**
* Class representing the ManiaLinks Stylesheet * Class representing a ManiaLink Stylesheet
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -11,34 +11,28 @@ namespace FML\Stylesheet;
*/ */
class Stylesheet { class Stylesheet {
/* /*
* Protected Properties * Protected properties
*/ */
protected $tagName = 'stylesheet'; protected $tagName = 'stylesheet';
/** @var Style3d[] $styles3d */
protected $styles3d = array(); protected $styles3d = array();
/** @var Mood $mood */ /** @var Mood $mood */
protected $mood = null; protected $mood = null;
/** /**
* Create a new Stylesheet Object * Create a new Stylesheet object
* *
* @return \FML\Stylesheet\Stylesheet * @return \FML\Stylesheet\Stylesheet|static
*/ */
public static function create() { public static function create() {
$stylesheet = new Stylesheet(); return new static();
return $stylesheet;
}
/**
* Construct a new Stylesheet Object
*/
public function __construct() {
} }
/** /**
* Add a new Style3d * Add a new Style3d
* *
* @param Style3d $style3d The Style3d to add * @param Style3d $style3d Style3d object
* @return \FML\Stylesheet\Stylesheet * @return \FML\Stylesheet\Stylesheet|static
*/ */
public function addStyle3d(Style3d $style3d) { public function addStyle3d(Style3d $style3d) {
if (!in_array($style3d, $this->styles3d, true)) { if (!in_array($style3d, $this->styles3d, true)) {
@ -48,9 +42,9 @@ class Stylesheet {
} }
/** /**
* Remove all Styles * Remove all Style3ds
* *
* @return \FML\Stylesheet\Stylesheet * @return \FML\Stylesheet\Stylesheet|static
*/ */
public function removeStyles() { public function removeStyles() {
$this->styles3d = array(); $this->styles3d = array();
@ -58,10 +52,10 @@ class Stylesheet {
} }
/** /**
* Set the Mood Object of the Stylesheet * Set the Mood object of the Stylesheet
* *
* @param Mood $mood Mood Object * @param Mood $mood Mood object
* @return \FML\Stylesheet\Stylesheet * @return \FML\Stylesheet\Stylesheet|static
*/ */
public function setMood(Mood $mood) { public function setMood(Mood $mood) {
$this->mood = $mood; $this->mood = $mood;
@ -69,9 +63,9 @@ class Stylesheet {
} }
/** /**
* Get the Mood Object * Get the Mood object
* *
* @param bool $createIfEmpty (optional) Whether the Mood Object should be created if it's not set yet * @param bool $createIfEmpty (optional) Whether the Mood object should be created if it's not set
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function getMood($createIfEmpty = true) { public function getMood($createIfEmpty = true) {
@ -82,9 +76,9 @@ class Stylesheet {
} }
/** /**
* Render the Stylesheet XML Element * Render the Stylesheet XML element
* *
* @param \DOMDocument $domDocument DomDocument for which the Stylesheet XML Element should be rendered * @param \DOMDocument $domDocument DOMDocument for which the Stylesheet XML element should be rendered
* @return \DOMElement * @return \DOMElement
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
@ -93,7 +87,6 @@ class Stylesheet {
$stylesXml = $domDocument->createElement('frame3dstyles'); $stylesXml = $domDocument->createElement('frame3dstyles');
$stylesheetXml->appendChild($stylesXml); $stylesheetXml->appendChild($stylesXml);
foreach ($this->styles3d as $style3d) { foreach ($this->styles3d as $style3d) {
/** @var Style3d $style3d */
$style3dXml = $style3d->render($domDocument); $style3dXml = $style3d->render($domDocument);
$stylesXml->appendChild($style3dXml); $stylesXml->appendChild($style3dXml);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for Elements that support the Action Attribute * Interface for Elements that support the action attribute
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -33,25 +33,25 @@ interface Actionable {
const ACTIONKEY_F8 = 4; const ACTIONKEY_F8 = 4;
/** /**
* Set Action * Set action
* *
* @param string $action Action Name * @param string $action Action name
* @return \FML\Types\Actionable * @return \FML\Types\Actionable|static
*/ */
public function setAction($action); public function setAction($action);
/** /**
* Get the assigned Action * Get the assigned action
* *
* @return string * @return string
*/ */
public function getAction(); public function getAction();
/** /**
* Set Action Key * Set action key
* *
* @param int $actionKey Action Key Number * @param int $actionKey Action key
* @return \FML\Types\Actionable * @return \FML\Types\Actionable|static
*/ */
public function setActionKey($actionKey); public function setActionKey($actionKey);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for Elements with Background Color Attribute * Interface for Elements with background color attribute
* *
* @author steeffeen * @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -12,10 +12,10 @@ namespace FML\Types;
interface BgColorable { interface BgColorable {
/** /**
* Set Background Color * Set background color
* *
* @param string $bgColor Background Color * @param string $bgColor Background color
* @return \FML\Types\BgColorable * @return \FML\Types\BgColorable|static
*/ */
public function setBgColor($bgColor); public function setBgColor($bgColor);
} }

View File

@ -14,33 +14,33 @@ use FML\Elements\Format;
interface Container { interface Container {
/** /**
* Add a new Child Element * Add a new child Element
* *
* @param Renderable $child The Child Control to add * @param Renderable $child Child Control to add
* @return \FML\Types\Container * @return \FML\Types\Container|static
*/ */
public function add(Renderable $child); public function add(Renderable $child);
/** /**
* Remove all Children * Remove all children
* *
* @return \FML\Types\Container * @return \FML\Types\Container|static
*/ */
public function removeChildren(); public function removeChildren();
/** /**
* Set the Format Object of the Container * Set the Format object of the Container
* *
* @param Format $format New Format Object * @param Format $format New Format object
* @return \FML\Types\Container * @return \FML\Types\Container|static
*/ */
public function setFormat(Format $format); public function setFormat(Format $format);
/** /**
* Get the Format Object of the Container * Get the Format object of the Container
* *
* @param bool $createIfEmpty (optional) Whether the Format Object should be created if it's not set yet * @param bool $createIfEmpty (optional) Whether the Format object should be created if it's not set
* @return \FML\Elements\Format * @return \FML\Elements\Format|static
*/ */
public function getFormat($createIfEmpty = true); public function getFormat($createIfEmpty = true);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for Elements with Url Attributes * Interface for Elements with url attributes
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -12,34 +12,34 @@ namespace FML\Types;
interface Linkable { interface Linkable {
/** /**
* Set Url * Set url
* *
* @param string $url Link Url * @param string $url Link url
* @return \FML\Types\Linkable * @return \FML\Types\Linkable|static
*/ */
public function setUrl($url); public function setUrl($url);
/** /**
* Set Url Id to use from the Dico * Set url id to use from Dico
* *
* @param string $urlId * @param string $urlId Url id
* @return \FML\Types\Linkable * @return \FML\Types\Linkable|static
*/ */
public function setUrlId($urlId); public function setUrlId($urlId);
/** /**
* Set Manialink * Set manialink
* *
* @param string $manialink Manialink Name * @param string $manialink Manialink name
* @return \FML\Types\Linkable * @return \FML\Types\Linkable|static
*/ */
public function setManialink($manialink); public function setManialink($manialink);
/** /**
* Set Manialink Id to use from the Dico * Set manialink id to use from Dico
* *
* @param string $manialinkId Manialink Id * @param string $manialinkId Manialink id
* @return \FML\Types\Linkable * @return \FML\Types\Linkable|static
*/ */
public function setManialinkId($manialinkId); public function setManialinkId($manialinkId);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for Elements with AutoNewLine Attribute * Interface for Elements with autonewline attribute
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -12,10 +12,10 @@ namespace FML\Types;
interface NewLineable { interface NewLineable {
/** /**
* Set Auto New Line * Set auto new line
* *
* @param bool $autoNewLine Whether the Control should insert New Lines automatically * @param bool $autoNewLine Whether the Control should insert new lines automatically
* @return \FML\Types\NewLineable * @return \FML\Types\NewLineable|static
*/ */
public function setAutoNewLine($autoNewLine); public function setAutoNewLine($autoNewLine);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for Elements with Media Attributes * Interface for Elements with media attributes
* *
* @author steeffeen <mail@steeffeen.com> * @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
@ -12,50 +12,50 @@ namespace FML\Types;
interface Playable { interface Playable {
/** /**
* Set Data * Set data
* *
* @param string $data Media Url * @param string $data Media url
* @return \FML\Types\Playable * @return \FML\Types\Playable|static
*/ */
public function setData($data); public function setData($data);
/** /**
* Set Data Id to use from the Dico * Set data id to use from Dico
* *
* @param string $dataId * @param string $dataId Data id
* @return \FML\Types\Playable * @return \FML\Types\Playable|static
*/ */
public function setDataId($dataId); public function setDataId($dataId);
/** /**
* Set Play * Set play
* *
* @param bool $play Whether the Control should start playing automatically * @param bool $play Whether the Control should start playing automatically
* @return \FML\Types\Playable * @return \FML\Types\Playable|static
*/ */
public function setPlay($play); public function setPlay($play);
/** /**
* Set Looping * Set looping
* *
* @param bool $looping Whether the Control should play looping * @param bool $looping Whether the Control should play looping
* @return \FML\Types\Playable * @return \FML\Types\Playable|static
*/ */
public function setLooping($looping); public function setLooping($looping);
/** /**
* Set Music * Set music
* *
* @param bool $music Whether the Control represents Background Music * @param bool $music Whether the Control represents background music
* @return \FML\Types\Playable * @return \FML\Types\Playable|static
*/ */
public function setMusic($music); public function setMusic($music);
/** /**
* Set Volume * Set volume
* *
* @param float $volume Media Volume * @param float $volume Media volume
* @return \FML\Types\Playable * @return \FML\Types\Playable|static
*/ */
public function setVolume($volume); public function setVolume($volume);
} }

View File

@ -12,9 +12,9 @@ namespace FML\Types;
interface Renderable { interface Renderable {
/** /**
* Render the XML Element * Render the XML element
* *
* @param \DOMDocument $domDocument DomDocument for which the XML Element should be rendered * @param \DOMDocument $domDocument DOMDocument for which the XML element should be rendered
* @return \DOMElement * @return \DOMElement
*/ */
public function render(\DOMDocument $domDocument); public function render(\DOMDocument $domDocument);

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