FML 1.2
This commit is contained in:
parent
e61c6f4c11
commit
d3e4fd309f
169
application/core/Libs/FML/Components/CheckBox.php
Normal file
169
application/core/Libs/FML/Components/CheckBox.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Components;
|
||||
|
||||
use FML\Controls\Entry;
|
||||
use FML\Controls\Frame;
|
||||
use FML\Controls\Quad;
|
||||
use FML\Models\CheckBoxDesign;
|
||||
use FML\Script\Features\CheckBoxFeature;
|
||||
use FML\Types\Renderable;
|
||||
use FML\Types\ScriptFeatureable;
|
||||
|
||||
/**
|
||||
* CheckBox Component
|
||||
*
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CheckBox implements Renderable, ScriptFeatureable {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $name = null;
|
||||
protected $default = null;
|
||||
protected $hiddenEntryDisabled = null;
|
||||
protected $feature = null;
|
||||
|
||||
/**
|
||||
* Create a new CheckBox Component
|
||||
*
|
||||
* @param string $name (optional) CheckBox Name
|
||||
* @param bool $default (optional) Default Value
|
||||
* @param Quad $quad (optional) CheckBox Quad
|
||||
*/
|
||||
public function __construct($name = null, $default = null, Quad $quad = null) {
|
||||
$this->setName($name);
|
||||
$this->setDefault($default);
|
||||
$this->feature = new CheckBoxFeature();
|
||||
$this->feature->setQuad($quad);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Name
|
||||
*
|
||||
* @param string $name CheckBox Name
|
||||
* @return \FML\Components\CheckBox
|
||||
*/
|
||||
public function setName($name) {
|
||||
$this->name = (string)$name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Default Value
|
||||
*
|
||||
* @param bool $default Default Value
|
||||
* @return \FML\Components\CheckBox
|
||||
*/
|
||||
public function setDefault($default) {
|
||||
$this->default = ($default ? 1 : 0);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the hidden Entry that's sending the Value on Page Actions
|
||||
*
|
||||
* @param bool $disable (optional) Whether to disable or not
|
||||
* @return \FML\Components\CheckBox
|
||||
*/
|
||||
public function disableHiddenEntry($disable = true) {
|
||||
$this->hiddenEntryDisabled = (bool)$disable;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Enabled Design
|
||||
*
|
||||
* @param string $style Style Name or Image Url
|
||||
* @param string $subStyle SubStyle Name
|
||||
* @return \FML\Components\CheckBox
|
||||
*/
|
||||
public function setEnabledDesign($style, $subStyle = null) {
|
||||
$checkBoxDesign = new CheckBoxDesign($style, $subStyle);
|
||||
$this->feature->setEnabledDesign($checkBoxDesign);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Disabled Design
|
||||
*
|
||||
* @param string $style Style Name or Image Url
|
||||
* @param string $subStyle SubStyle Name
|
||||
* @return \FML\Components\CheckBox
|
||||
*/
|
||||
public function setDisabledDesign($style, $subStyle = null) {
|
||||
$checkBoxDesign = new CheckBoxDesign($style, $subStyle);
|
||||
$this->feature->setDisabledDesign($checkBoxDesign);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CheckBox Quad
|
||||
*
|
||||
* @param bool $createIfEmpty (optional) Create the Quad if it's not set
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function getQuad($createIfEmpty = true) {
|
||||
if (!$this->feature->getQuad() && $createIfEmpty) {
|
||||
$quad = new Quad();
|
||||
$quad->setSize(10, 10);
|
||||
$quad->setScriptEvents(true);
|
||||
$this->feature->setQuad($quad);
|
||||
}
|
||||
return $this->feature->getQuad();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CheckBox Quad
|
||||
*
|
||||
* @param Quad $quad CheckBox Quad
|
||||
* @return \FML\Components\CheckBox
|
||||
*/
|
||||
public function setQuad(Quad $quad) {
|
||||
$this->feature->setQuad($quad);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\ScriptFeatureable::getScriptFeatures()
|
||||
*/
|
||||
public function getScriptFeatures() {
|
||||
return array($this->feature);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$frame = new Frame();
|
||||
$frame->addScriptFeature($this->feature);
|
||||
|
||||
$quad = $this->getQuad();
|
||||
$frame->add($quad);
|
||||
|
||||
if (!$this->hiddenEntryDisabled) {
|
||||
$entry = $this->buildEntry();
|
||||
$frame->add($entry);
|
||||
$this->feature->setEntry($entry);
|
||||
} else {
|
||||
$this->feature->setEntry(null);
|
||||
}
|
||||
|
||||
return $frame->render($domDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the hidden Entry
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
protected function buildEntry() {
|
||||
$entry = new Entry();
|
||||
$entry->setVisible(false);
|
||||
$entry->setName($this->name);
|
||||
$entry->setDefault($this->default);
|
||||
return $entry;
|
||||
}
|
||||
}
|
@ -2,41 +2,43 @@
|
||||
|
||||
namespace FML\Controls;
|
||||
|
||||
use FML\Types\Renderable;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Features\ActionTrigger;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Types\ScriptFeatureable;
|
||||
use FML\Script\Features\ControlScript;
|
||||
use FML\Script\Features\MapInfo;
|
||||
use FML\Script\Features\PlayerProfile;
|
||||
use FML\Script\Features\UISound;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Features\ScriptFeature;
|
||||
use FML\Script\Features\Toggle;
|
||||
use FML\Script\Features\Tooltip;
|
||||
use FML\Script\Features\UISound;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Types\Renderable;
|
||||
use FML\Types\ScriptFeatureable;
|
||||
|
||||
/**
|
||||
* Base Control
|
||||
* (CMlControl)
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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 Control implements Renderable, ScriptFeatureable {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const CENTER = 'center';
|
||||
const CENTER = 'center';
|
||||
const CENTER2 = 'center2';
|
||||
const TOP = 'top';
|
||||
const RIGHT = 'right';
|
||||
const BOTTOM = 'bottom';
|
||||
const LEFT = 'left';
|
||||
|
||||
const TOP = 'top';
|
||||
const RIGHT = 'right';
|
||||
const BOTTOM = 'bottom';
|
||||
const LEFT = 'left';
|
||||
|
||||
/*
|
||||
* Static Properties
|
||||
*/
|
||||
protected static $currentIndex = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
@ -85,26 +87,29 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = (string) $id;
|
||||
$this->id = (string)$id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Id for dangerous Characters and assign a unique Id if necessary
|
||||
*
|
||||
* @param bool $forceNewId Whether to force setting a newly generated Id
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function checkId() {
|
||||
if (!$this->getId()) {
|
||||
public function checkId($forceNewId = false) {
|
||||
if ($forceNewId || !$this->getId()) {
|
||||
$this->setId('FML_ID_' . self::$currentIndex);
|
||||
self::$currentIndex++;
|
||||
return $this;
|
||||
}
|
||||
$dangerousCharacters = array(' ', ' ', '.', '|', '-', PHP_EOL);
|
||||
$idCharacters = str_split($this->getId());
|
||||
$danger = false;
|
||||
$idCharacters = str_split($this->getId());
|
||||
$danger = false;
|
||||
foreach ($idCharacters as $character) {
|
||||
if (!in_array($character, $dangerousCharacters)) continue;
|
||||
if (!in_array($character, $dangerousCharacters)) {
|
||||
continue;
|
||||
}
|
||||
$danger = true;
|
||||
break;
|
||||
}
|
||||
@ -123,7 +128,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setX($x) {
|
||||
$this->x = (float) $x;
|
||||
$this->x = (float)$x;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -134,7 +139,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setY($y) {
|
||||
$this->y = (float) $y;
|
||||
$this->y = (float)$y;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -145,7 +150,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setZ($z) {
|
||||
$this->z = (float) $z;
|
||||
$this->z = (float)$z;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -173,7 +178,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setWidth($width) {
|
||||
$this->width = (float) $width;
|
||||
$this->width = (float)$width;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -184,14 +189,14 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setHeight($height) {
|
||||
$this->height = (float) $height;
|
||||
$this->height = (float)$height;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Control Size
|
||||
*
|
||||
* @param float $width Control Width
|
||||
* @param float $width Control Width
|
||||
* @param float $height Control Height
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
@ -208,7 +213,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setHAlign($hAlign) {
|
||||
$this->hAlign = (string) $hAlign;
|
||||
$this->hAlign = (string)$hAlign;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -219,7 +224,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setVAlign($vAlign) {
|
||||
$this->vAlign = (string) $vAlign;
|
||||
$this->vAlign = (string)$vAlign;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -236,6 +241,26 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Center Alignment
|
||||
*
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function centerAlign() {
|
||||
$this->setAlign(self::CENTER, self::CENTER2);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset Alignment
|
||||
*
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function resetAlign() {
|
||||
$this->setAlign(null, null);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Control Scale
|
||||
*
|
||||
@ -243,7 +268,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setScale($scale) {
|
||||
$this->scale = (float) $scale;
|
||||
$this->scale = (float)$scale;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -253,7 +278,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @param bool $visible Whether Control should be visible
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setVisible($visible) {
|
||||
public function setVisible($visible = true) {
|
||||
$this->hidden = ($visible ? 0 : 1);
|
||||
return $this;
|
||||
}
|
||||
@ -265,7 +290,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function addClass($class) {
|
||||
$class = (string) $class;
|
||||
$class = (string)$class;
|
||||
if (!in_array($class, $this->classes)) {
|
||||
array_push($this->classes, $class);
|
||||
}
|
||||
@ -281,7 +306,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
*/
|
||||
public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) {
|
||||
$actionTrigger = new ActionTrigger($actionName, $this, $eventLabel);
|
||||
array_push($this->scriptFeatures, $actionTrigger);
|
||||
$this->addScriptFeature($actionTrigger);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -293,34 +318,34 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
*/
|
||||
public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) {
|
||||
$mapInfo = new MapInfo($this, $eventLabel);
|
||||
array_push($this->scriptFeatures, $mapInfo);
|
||||
$this->addScriptFeature($mapInfo);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a dynamic Feature to open a specific Player Profile
|
||||
*
|
||||
* @param string $login The Login of the Player
|
||||
* @param string $login The Login of the Player
|
||||
* @param string $eventLabel (optional) Event on which the Player Profile will be opened
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) {
|
||||
$playerProfile = new PlayerProfile($login, $this, $eventLabel);
|
||||
array_push($this->scriptFeatures, $playerProfile);
|
||||
$this->addScriptFeature($playerProfile);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a dynamic Feature playing an UISound
|
||||
*
|
||||
* @param string $soundName UISound Name
|
||||
* @param int $variant (optional) Sound Variant
|
||||
* @param string $soundName UISound Name
|
||||
* @param int $variant (optional) Sound Variant
|
||||
* @param string $eventLabel (optional) Event on which the Sound will be played
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) {
|
||||
$uiSound = new UISound($soundName, $this, $variant, $eventLabel);
|
||||
array_push($this->scriptFeatures, $uiSound);
|
||||
$this->addScriptFeature($uiSound);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -328,14 +353,14 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* Add a dynamic Feature toggling another Control
|
||||
*
|
||||
* @param Control $toggledControl Toggled Control
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle
|
||||
* @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle
|
||||
* @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function addToggleFeature(Control $toggledControl, $labelName = Scriptlabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) {
|
||||
$toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide);
|
||||
array_push($this->scriptFeatures, $toggle);
|
||||
$this->addScriptFeature($toggle);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -343,43 +368,67 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
* Add a dynamic Feature showing a Tooltip on hovering
|
||||
*
|
||||
* @param Control $tooltipControl Tooltip Control
|
||||
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
|
||||
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
|
||||
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
|
||||
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) {
|
||||
$tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert);
|
||||
array_push($this->scriptFeatures, $tooltip);
|
||||
$this->addScriptFeature($tooltip);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a dynamic Feature showing a Tooltip on hovering
|
||||
*
|
||||
* @param Label $tooltipControl Tooltip Control
|
||||
* @param string $text The Text to display on the Tooltip Label
|
||||
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
|
||||
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
|
||||
* @param Label $tooltipControl Tooltip Control
|
||||
* @param string $text The Text to display on the Tooltip Label
|
||||
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
|
||||
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function addTooltipLabelFeature(Label $tooltipControl, $text, $stayOnClick = false, $invert = false) {
|
||||
$tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert, $text);
|
||||
array_push($this->scriptFeatures, $tooltip);
|
||||
$this->addScriptFeature($tooltip);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Custom Control Script Text Part
|
||||
*
|
||||
* @param string $scriptText Script Text
|
||||
* @param string $label (optional) Script Label Name
|
||||
* @param bool $isolated (optional) Whether to isolate the Script Text
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK, $isolated = true) {
|
||||
$customText = new ControlScript($this, $scriptText, $label, $isolated);
|
||||
$this->addScriptFeature($customText);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Script Feature
|
||||
*
|
||||
* @param ScriptFeature $scriptFeature Script Feature
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function addScriptFeature(ScriptFeature $scriptFeature) {
|
||||
array_push($this->scriptFeatures, $scriptFeature);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all Script Features
|
||||
*
|
||||
*
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function removeScriptFeatures() {
|
||||
$this->scriptFeatures = array();
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\ScriptFeatureable::getScriptFeatures()
|
||||
*/
|
||||
public function getScriptFeatures() {
|
||||
@ -387,7 +436,6 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
|
@ -1,20 +1,21 @@
|
||||
<?php
|
||||
// TODO: add entry styles
|
||||
|
||||
namespace FML\Controls;
|
||||
|
||||
use FML\Script\Features\EntrySubmit;
|
||||
use FML\Types\NewLineable;
|
||||
use FML\Types\Scriptable;
|
||||
use FML\Types\Styleable;
|
||||
use FML\Types\TextFormatable;
|
||||
use FML\Script\Features\EntrySubmit;
|
||||
|
||||
/**
|
||||
* Entry Control
|
||||
* (CMlEntry)
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable {
|
||||
/*
|
||||
@ -59,7 +60,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
* @return \FML\Controls\Entry
|
||||
*/
|
||||
public function setName($name) {
|
||||
$this->name = (string) $name;
|
||||
$this->name = (string)$name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -84,7 +85,15 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Default Value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefault() {
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\NewLineable::setAutoNewLine()
|
||||
*/
|
||||
public function setAutoNewLine($autoNewLine) {
|
||||
@ -93,7 +102,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Scriptable::setScriptEvents()
|
||||
*/
|
||||
public function setScriptEvents($scriptEvents) {
|
||||
@ -102,47 +110,42 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Styleable::setStyle()
|
||||
*/
|
||||
public function setStyle($style) {
|
||||
$this->style = (string) $style;
|
||||
$this->style = (string)$style;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\TextFormatable::setTextColor()
|
||||
*/
|
||||
public function setTextColor($textColor) {
|
||||
$this->textColor = (string) $textColor;
|
||||
$this->textColor = (string)$textColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\TextFormatable::setTextSize()
|
||||
*/
|
||||
public function setTextSize($textSize) {
|
||||
$this->textSize = (int) $textSize;
|
||||
$this->textSize = (int)$textSize;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\TextFormatable::setAreaColor()
|
||||
*/
|
||||
public function setAreaColor($areaColor) {
|
||||
$this->focusAreaColor1 = (string) $areaColor;
|
||||
$this->focusAreaColor1 = (string)$areaColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\TextFormatable::setAreaFocusColor()
|
||||
*/
|
||||
public function setAreaFocusColor($areaFocusColor) {
|
||||
$this->focusAreaColor2 = (string) $areaFocusColor;
|
||||
$this->focusAreaColor2 = (string)$areaFocusColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -153,7 +156,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
* @return \FML\Controls\Entry
|
||||
*/
|
||||
public function setAutoComplete($autoComplete) {
|
||||
$this->autoComplete = (bool) $autoComplete;
|
||||
$this->autoComplete = (bool)$autoComplete;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -165,12 +168,11 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
*/
|
||||
public function addSubmitFeature($url) {
|
||||
$entrySubmit = new EntrySubmit($this, $url);
|
||||
array_push($this->scriptFeatures, $entrySubmit);
|
||||
$this->addScriptFeature($entrySubmit);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Control::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
@ -180,13 +182,11 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
}
|
||||
if ($this->default !== null) {
|
||||
$xmlElement->setAttribute('default', $this->default);
|
||||
}
|
||||
else if ($this->autoComplete) {
|
||||
} else if ($this->autoComplete) {
|
||||
$value = null;
|
||||
if (array_key_exists($this->name, $_GET)) {
|
||||
$value = $_GET[$this->name];
|
||||
}
|
||||
else if (array_key_exists($this->name, $_POST)) {
|
||||
} else if (array_key_exists($this->name, $_POST)) {
|
||||
$value = $_POST[$this->name];
|
||||
}
|
||||
if ($value) {
|
||||
|
@ -2,25 +2,25 @@
|
||||
|
||||
namespace FML\Controls;
|
||||
|
||||
use FML\Types\Container;
|
||||
|
||||
use FML\Elements\Format;
|
||||
|
||||
use FML\Types\Container;
|
||||
use FML\Types\Renderable;
|
||||
use FML\Types\ScriptFeatureable;
|
||||
|
||||
/**
|
||||
* Frame Control
|
||||
* (CMlFrame)
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Frame extends Control implements Container {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $children = array();
|
||||
/** @var Format $format */
|
||||
protected $format = null;
|
||||
|
||||
/**
|
||||
@ -45,10 +45,9 @@ class Frame extends Control implements Container {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::add()
|
||||
*/
|
||||
public function add(Control $child) {
|
||||
public function add(Renderable $child) {
|
||||
if (!in_array($child, $this->children, true)) {
|
||||
array_push($this->children, $child);
|
||||
}
|
||||
@ -56,7 +55,6 @@ class Frame extends Control implements Container {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::removeChildren()
|
||||
*/
|
||||
public function removeChildren() {
|
||||
@ -65,7 +63,6 @@ class Frame extends Control implements Container {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::setFormat()
|
||||
*/
|
||||
public function setFormat(Format $format) {
|
||||
@ -74,7 +71,6 @@ class Frame extends Control implements Container {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::getFormat()
|
||||
*/
|
||||
public function getFormat($createIfEmpty = true) {
|
||||
@ -85,7 +81,6 @@ class Frame extends Control implements Container {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Controls\Control::getScriptFeatures()
|
||||
*/
|
||||
public function getScriptFeatures() {
|
||||
@ -99,7 +94,6 @@ class Frame extends Control implements Container {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
@ -109,6 +103,7 @@ class Frame extends Control implements Container {
|
||||
$xmlElement->appendChild($formatXml);
|
||||
}
|
||||
foreach ($this->children as $child) {
|
||||
/** @var Renderable $child */
|
||||
$childXmlElement = $child->render($domDocument);
|
||||
$xmlElement->appendChild($childXmlElement);
|
||||
}
|
||||
|
@ -2,22 +2,37 @@
|
||||
|
||||
namespace FML\Controls;
|
||||
|
||||
use FML\Types\Scriptable;
|
||||
use FML\Stylesheet\Style3d;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Frame3d Control
|
||||
* (CMlFrame)
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Frame3d extends Frame implements Scriptable {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const STYLE_BaseStation = 'BaseStation';
|
||||
const STYLE_BaseBoxCase = 'BaseBoxCase';
|
||||
const STYLE_Titlelogo = 'Titlelogo';
|
||||
const STYLE_ButtonBack = 'ButtonBack';
|
||||
const STYLE_ButtonNav = 'ButtonNav';
|
||||
const STYLE_ButtonH = 'ButtonH';
|
||||
const STYLE_Station3x3 = 'Station3x3';
|
||||
const STYLE_Title = 'Title';
|
||||
const STYLE_TitleEditor = 'TitleEditor';
|
||||
const STYLE_Window = 'Window';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $style3dId = '';
|
||||
/** @var Style3d $style3d */
|
||||
protected $style3d = null;
|
||||
protected $scriptEvents = 0;
|
||||
|
||||
@ -49,8 +64,8 @@ class Frame3d extends Frame implements Scriptable {
|
||||
* @return \FML\Controls\Frame3d
|
||||
*/
|
||||
public function setStyle3dId($style3dId) {
|
||||
$this->style3dId = (string) $style3dId;
|
||||
$this->style3d = null;
|
||||
$this->style3dId = (string)$style3dId;
|
||||
$this->style3d = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -66,7 +81,6 @@ class Frame3d extends Frame implements Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Scriptable::setScriptEvents()
|
||||
*/
|
||||
public function setScriptEvents($scriptEvents) {
|
||||
@ -75,7 +89,6 @@ class Frame3d extends Frame implements Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Controls\Frame::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
@ -83,8 +96,7 @@ class Frame3d extends Frame implements Scriptable {
|
||||
if ($this->style3d) {
|
||||
$this->style3d->checkId();
|
||||
$xmlElement->setAttribute('style3d', $this->style3d->getId());
|
||||
}
|
||||
else if ($this->style3dId) {
|
||||
} else if ($this->style3dId) {
|
||||
$xmlElement->setAttribute('style3d', $this->style3dId);
|
||||
}
|
||||
if ($this->scriptEvents) {
|
||||
|
@ -4,26 +4,26 @@ namespace FML\Controls;
|
||||
|
||||
use FML\Elements\FrameModel;
|
||||
|
||||
|
||||
/**
|
||||
* Class representing an Instance of a Frame Model
|
||||
* (CMlFrame)
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class FrameInstance extends Control {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $modelId = '';
|
||||
/** @var FrameModel $model */
|
||||
protected $model = null;
|
||||
|
||||
/**
|
||||
* Create a new Frame Instance
|
||||
*
|
||||
* @param string $modelId (optional) Frame Model Id
|
||||
* @param string $modelId (optional) Frame Model Id
|
||||
* @param string $controlId (optional) Control Id
|
||||
* @return \FML\Controls\Frame
|
||||
*/
|
||||
@ -35,7 +35,7 @@ class FrameInstance extends Control {
|
||||
/**
|
||||
* Construct a new Frame Instance
|
||||
*
|
||||
* @param string $modelId (optional) Frame Model Id
|
||||
* @param string $modelId (optional) Frame Model Id
|
||||
* @param string $controlId (optional) Control Id
|
||||
*/
|
||||
public function __construct($modelId = null, $controlId = null) {
|
||||
@ -53,8 +53,8 @@ class FrameInstance extends Control {
|
||||
* @return \FML\Controls\FrameInstance
|
||||
*/
|
||||
public function setModelId($modelId) {
|
||||
$this->modelId = (string) $modelId;
|
||||
$this->model = null;
|
||||
$this->modelId = (string)$modelId;
|
||||
$this->model = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -65,13 +65,12 @@ class FrameInstance extends Control {
|
||||
* @return \FML\Controls\FrameInstance
|
||||
*/
|
||||
public function setModel(FrameModel $frameModel) {
|
||||
$this->model = $frameModel;
|
||||
$this->model = $frameModel;
|
||||
$this->modelId = '';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
@ -79,8 +78,7 @@ class FrameInstance extends Control {
|
||||
if ($this->model) {
|
||||
$this->model->checkId();
|
||||
$xmlElement->setAttribute('modelid', $this->model->getId());
|
||||
}
|
||||
else if ($this->modelId) {
|
||||
} else if ($this->modelId) {
|
||||
$xmlElement->setAttribute('modelid', $this->modelId);
|
||||
}
|
||||
return $xmlElement;
|
||||
|
@ -264,7 +264,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
*/
|
||||
public function addClockFeature($showSeconds = true, $showFullDate = false) {
|
||||
$clock = new Clock($this, $showSeconds, $showFullDate);
|
||||
array_push($this->scriptFeatures, $clock);
|
||||
$this->addScriptFeature($clock);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace FML\Controls;
|
||||
|
||||
use FML\Models\CheckBoxDesign;
|
||||
use FML\Types\Actionable;
|
||||
use FML\Types\BgColorable;
|
||||
use FML\Types\Linkable;
|
||||
@ -13,9 +14,9 @@ use FML\Types\SubStyleable;
|
||||
* Quad Control
|
||||
* (CMlQuad)
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Quad extends Control implements Actionable, BgColorable, Linkable, Scriptable, Styleable, SubStyleable {
|
||||
/*
|
||||
@ -68,7 +69,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function setImage($image) {
|
||||
$this->image = (string) $image;
|
||||
$this->image = (string)$image;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -79,7 +80,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function setImageId($imageId) {
|
||||
$this->imageId = (string) $imageId;
|
||||
$this->imageId = (string)$imageId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -90,7 +91,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function setImageFocus($imageFocus) {
|
||||
$this->imageFocus = (string) $imageFocus;
|
||||
$this->imageFocus = (string)$imageFocus;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -101,7 +102,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function setImageFocusId($imageFocusId) {
|
||||
$this->imageFocusId = (string) $imageFocusId;
|
||||
$this->imageFocusId = (string)$imageFocusId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -112,7 +113,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function setColorize($colorize) {
|
||||
$this->colorize = (string) $colorize;
|
||||
$this->colorize = (string)$colorize;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -123,7 +124,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function setModulizeColor($modulizeColor) {
|
||||
$this->modulizeColor = (string) $modulizeColor;
|
||||
$this->modulizeColor = (string)$modulizeColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -139,16 +140,14 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Actionable::setAction()
|
||||
*/
|
||||
public function setAction($action) {
|
||||
$this->action = (string) $action;
|
||||
$this->action = (string)$action;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Actionable::getAction()
|
||||
*/
|
||||
public function getAction() {
|
||||
@ -156,61 +155,54 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Actionable::setActionKey()
|
||||
*/
|
||||
public function setActionKey($actionKey) {
|
||||
$this->actionKey = (int) $actionKey;
|
||||
$this->actionKey = (int)$actionKey;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\BgColorable::setBgColor()
|
||||
*/
|
||||
public function setBgColor($bgColor) {
|
||||
$this->bgColor = (string) $bgColor;
|
||||
$this->bgColor = (string)$bgColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Linkable::setUrl()
|
||||
*/
|
||||
public function setUrl($url) {
|
||||
$this->url = (string) $url;
|
||||
$this->url = (string)$url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Linkable::setUrlId()
|
||||
*/
|
||||
public function setUrlId($urlId) {
|
||||
$this->urlId = (string) $urlId;
|
||||
$this->urlId = (string)$urlId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Linkable::setManialink()
|
||||
*/
|
||||
public function setManialink($manialink) {
|
||||
$this->manialink = (string) $manialink;
|
||||
$this->manialink = (string)$manialink;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Linkable::setManialinkId()
|
||||
*/
|
||||
public function setManialinkId($manialinkId) {
|
||||
$this->manialinkId = (string) $manialinkId;
|
||||
$this->manialinkId = (string)$manialinkId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Scriptable::setScriptEvents()
|
||||
*/
|
||||
public function setScriptEvents($scriptEvents) {
|
||||
@ -219,25 +211,22 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Styleable::setStyle()
|
||||
*/
|
||||
public function setStyle($style) {
|
||||
$this->style = (string) $style;
|
||||
$this->style = (string)$style;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\SubStyleable::setSubStyle()
|
||||
*/
|
||||
public function setSubStyle($subStyle) {
|
||||
$this->subStyle = (string) $subStyle;
|
||||
$this->subStyle = (string)$subStyle;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\SubStyleable::setStyles()
|
||||
*/
|
||||
public function setStyles($style, $subStyle) {
|
||||
@ -247,7 +236,17 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the given CheckBox Design
|
||||
*
|
||||
* @param CheckBoxDesign $checkBoxDesign CheckBox Design
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function applyCheckBoxDesign(CheckBoxDesign $checkBoxDesign) {
|
||||
$checkBoxDesign->applyToQuad($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Control::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
|
@ -5,9 +5,9 @@ namespace FML;
|
||||
/**
|
||||
* Class representing a Custom_UI
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class CustomUI {
|
||||
/*
|
||||
@ -47,7 +47,7 @@ class CustomUI {
|
||||
* @return \FML\CustomUI
|
||||
*/
|
||||
public function setXMLEncoding($encoding) {
|
||||
$this->encoding = (string) $encoding;
|
||||
$this->encoding = (string)$encoding;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ class CustomUI {
|
||||
/**
|
||||
* Set Global Showing
|
||||
*
|
||||
* @param bool $visible Wether the UI should be disabled completely
|
||||
* @param bool $visible Whether the UI should be disabled completely
|
||||
* @return \FML\CustomUI
|
||||
*/
|
||||
public function setGlobalVisible($visible) {
|
||||
@ -146,9 +146,9 @@ class CustomUI {
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function render($domDocument = null) {
|
||||
$isChild = (bool) $domDocument;
|
||||
$isChild = (bool)$domDocument;
|
||||
if (!$isChild) {
|
||||
$domDocument = new \DOMDocument('1.0', $this->encoding);
|
||||
$domDocument = new \DOMDocument('1.0', $this->encoding);
|
||||
$domDocument->xmlStandalone = true;
|
||||
}
|
||||
$xmlElement = $domDocument->createElement($this->tagName);
|
||||
@ -157,7 +157,9 @@ class CustomUI {
|
||||
}
|
||||
$settings = $this->getSettings();
|
||||
foreach ($settings as $setting => $value) {
|
||||
if ($value === null) continue;
|
||||
if ($value === null) {
|
||||
continue;
|
||||
}
|
||||
$xmlSubElement = $domDocument->createElement($setting);
|
||||
$xmlSubElement->setAttribute('visible', ($value ? 1 : 0));
|
||||
$xmlElement->appendChild($xmlSubElement);
|
||||
@ -175,7 +177,7 @@ class CustomUI {
|
||||
*/
|
||||
public function __toString() {
|
||||
$domDocument = $this->render();
|
||||
$xmlText = $domDocument->saveXML();
|
||||
$xmlText = $domDocument->saveXML();
|
||||
return $xmlText;
|
||||
}
|
||||
|
||||
@ -185,15 +187,15 @@ class CustomUI {
|
||||
* @return array
|
||||
*/
|
||||
protected function getSettings() {
|
||||
$settings = array();
|
||||
$settings['challenge_info'] = $this->challengeInfoVisible;
|
||||
$settings['chat'] = $this->chatVisible;
|
||||
$settings = array();
|
||||
$settings['challenge_info'] = $this->challengeInfoVisible;
|
||||
$settings['chat'] = $this->chatVisible;
|
||||
$settings['checkpoint_list'] = $this->checkpointListVisible;
|
||||
$settings['global'] = $this->globalVisible;
|
||||
$settings['net_infos'] = $this->netInfosVisible;
|
||||
$settings['notice'] = $this->noticeVisible;
|
||||
$settings['round_scores'] = $this->roundScoresVisible;
|
||||
$settings['scoretable'] = $this->scoretableVisible;
|
||||
$settings['global'] = $this->globalVisible;
|
||||
$settings['net_infos'] = $this->netInfosVisible;
|
||||
$settings['notice'] = $this->noticeVisible;
|
||||
$settings['round_scores'] = $this->roundScoresVisible;
|
||||
$settings['scoretable'] = $this->scoretableVisible;
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,15 @@
|
||||
|
||||
namespace FML\Elements;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Types\Container;
|
||||
use FML\Types\Renderable;
|
||||
|
||||
/**
|
||||
* Class representing a Frame Model
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class FrameModel implements Container, Renderable {
|
||||
/*
|
||||
@ -20,6 +19,7 @@ class FrameModel implements Container, Renderable {
|
||||
protected $tagName = 'framemodel';
|
||||
protected $id = '';
|
||||
protected $children = array();
|
||||
/** @var Format $format */
|
||||
protected $format = null;
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ class FrameModel implements Container, Renderable {
|
||||
* @return \FML\Elements\FrameModel
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = (string) $id;
|
||||
$this->id = (string)$id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -55,18 +55,16 @@ class FrameModel implements Container, Renderable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::add()
|
||||
*/
|
||||
public function add(Control $childControl) {
|
||||
if (!in_array($childControl, $this->children, true)) {
|
||||
array_push($this->children, $childControl);
|
||||
public function add(Renderable $childElement) {
|
||||
if (!in_array($childElement, $this->children, true)) {
|
||||
array_push($this->children, $childElement);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::removeChildren()
|
||||
*/
|
||||
public function removeChildren() {
|
||||
@ -75,7 +73,6 @@ class FrameModel implements Container, Renderable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::setFormat()
|
||||
*/
|
||||
public function setFormat(Format $format) {
|
||||
@ -84,7 +81,6 @@ class FrameModel implements Container, Renderable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Container::getFormat()
|
||||
*/
|
||||
public function getFormat($createIfEmpty = true) {
|
||||
@ -95,7 +91,6 @@ class FrameModel implements Container, Renderable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Renderable::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
@ -107,6 +102,7 @@ class FrameModel implements Container, Renderable {
|
||||
$xmlElement->appendChild($formatXml);
|
||||
}
|
||||
foreach ($this->children as $child) {
|
||||
/** @var Renderable $child */
|
||||
$childElement = $child->render($domDocument);
|
||||
$xmlElement->appendChild($childElement);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use FML\ManiaCode\AddFavorite;
|
||||
use FML\ManiaCode\Element;
|
||||
use FML\ManiaCode\GetSkin;
|
||||
use FML\ManiaCode\Go_To;
|
||||
use FML\ManiaCode\InstallMacroblock;
|
||||
use FML\ManiaCode\InstallMap;
|
||||
use FML\ManiaCode\InstallPack;
|
||||
use FML\ManiaCode\InstallReplay;
|
||||
@ -17,14 +18,13 @@ use FML\ManiaCode\PlayMap;
|
||||
use FML\ManiaCode\PlayReplay;
|
||||
use FML\ManiaCode\ShowMessage;
|
||||
use FML\ManiaCode\ViewReplay;
|
||||
use FML\ManiaCode\InstallMacroblock;
|
||||
|
||||
/**
|
||||
* Class representing a ManiaCode
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class ManiaCode {
|
||||
/*
|
||||
@ -58,7 +58,7 @@ class ManiaCode {
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function setXmlEncoding($encoding) {
|
||||
$this->encoding = (string) $encoding;
|
||||
$this->encoding = (string)$encoding;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ class ManiaCode {
|
||||
*
|
||||
* @param string $name Macroblock Name
|
||||
* @param string $file Macroblock File
|
||||
* @param string $url Macroblock Url
|
||||
* @param string $url Macroblock Url
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function addInstallMacroblock($name, $file, $url) {
|
||||
@ -103,7 +103,7 @@ class ManiaCode {
|
||||
* Install a Map
|
||||
*
|
||||
* @param string $name Map Name
|
||||
* @param string $url Map Url
|
||||
* @param string $url Map Url
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function addInstallMap($name, $url) {
|
||||
@ -116,7 +116,7 @@ class ManiaCode {
|
||||
* Play a Map
|
||||
*
|
||||
* @param string $name Map Name
|
||||
* @param string $url Map Url
|
||||
* @param string $url Map Url
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function addPlayMap($name, $url) {
|
||||
@ -129,7 +129,7 @@ class ManiaCode {
|
||||
* Install a Replay
|
||||
*
|
||||
* @param string $name Replay Name
|
||||
* @param string $url Replay Url
|
||||
* @param string $url Replay Url
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function addInstallReplay($name, $url) {
|
||||
@ -142,7 +142,7 @@ class ManiaCode {
|
||||
* View a Replay
|
||||
*
|
||||
* @param string $name Replay Name
|
||||
* @param string $url Replay Url
|
||||
* @param string $url Replay Url
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function addViewReplay($name, $url) {
|
||||
@ -155,7 +155,7 @@ class ManiaCode {
|
||||
* Play a Replay
|
||||
*
|
||||
* @param string $name Replay Name
|
||||
* @param string $url Replay Url
|
||||
* @param string $url Replay Url
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function addPlayReplay($name, $url) {
|
||||
@ -169,7 +169,7 @@ class ManiaCode {
|
||||
*
|
||||
* @param string $name Skin Name
|
||||
* @param string $file Skin File
|
||||
* @param string $url Skin Url
|
||||
* @param string $url Skin Url
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function addInstallSkin($name, $file, $url) {
|
||||
@ -183,7 +183,7 @@ class ManiaCode {
|
||||
*
|
||||
* @param string $name Skin Name
|
||||
* @param string $file Skin File
|
||||
* @param string $url Skin Url
|
||||
* @param string $url Skin Url
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function addGetSkin($name, $file, $url) {
|
||||
@ -245,7 +245,7 @@ class ManiaCode {
|
||||
*
|
||||
* @param string $name Script Name
|
||||
* @param string $file Script File
|
||||
* @param string $url Script Url
|
||||
* @param string $url Script Url
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function addInstallScript($name, $file, $url) {
|
||||
@ -259,7 +259,7 @@ class ManiaCode {
|
||||
*
|
||||
* @param string $name Pack Name
|
||||
* @param string $file Pack File
|
||||
* @param string $url Pack Url
|
||||
* @param string $url Pack Url
|
||||
* @return \FML\ManiaCode
|
||||
*/
|
||||
public function addInstallPack($name, $file, $url) {
|
||||
@ -296,14 +296,15 @@ class ManiaCode {
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function render($echo = false) {
|
||||
$domDocument = new \DOMDocument('1.0', $this->encoding);
|
||||
$domDocument = new \DOMDocument('1.0', $this->encoding);
|
||||
$domDocument->xmlStandalone = true;
|
||||
$maniaCode = $domDocument->createElement($this->tagName);
|
||||
$maniaCode = $domDocument->createElement($this->tagName);
|
||||
$domDocument->appendChild($maniaCode);
|
||||
if ($this->noConfirmation) {
|
||||
$maniaCode->setAttribute('noconfirmation', $this->noConfirmation);
|
||||
}
|
||||
foreach ($this->elements as $element) {
|
||||
/** @var Element $element */
|
||||
$xmlElement = $element->render($domDocument);
|
||||
$maniaCode->appendChild($xmlElement);
|
||||
}
|
||||
@ -321,7 +322,7 @@ class ManiaCode {
|
||||
*/
|
||||
public function __toString() {
|
||||
$domDocument = $this->render();
|
||||
$xmlText = $domDocument->saveXML();
|
||||
$xmlText = $domDocument->saveXML();
|
||||
return $xmlText;
|
||||
}
|
||||
}
|
||||
|
@ -11,20 +11,20 @@ use FML\Types\ScriptFeatureable;
|
||||
/**
|
||||
* Class representing a ManiaLink
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class ManiaLink {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const BACKGROUND_0 = '0';
|
||||
const BACKGROUND_1 = '1';
|
||||
const BACKGROUND_STARS = 'stars';
|
||||
const BACKGROUND_0 = '0';
|
||||
const BACKGROUND_1 = '1';
|
||||
const BACKGROUND_STARS = 'stars';
|
||||
const BACKGROUND_STATIONS = 'stations';
|
||||
const BACKGROUND_TITLE = 'title';
|
||||
|
||||
const BACKGROUND_TITLE = 'title';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
@ -36,8 +36,11 @@ class ManiaLink {
|
||||
protected $navigable3d = 1;
|
||||
protected $timeout = 0;
|
||||
protected $children = array();
|
||||
/** @var Dico $dico */
|
||||
protected $dico = null;
|
||||
/** @var Stylesheet $stylesheet */
|
||||
protected $stylesheet = null;
|
||||
/** @var Script $script */
|
||||
protected $script = null;
|
||||
|
||||
/**
|
||||
@ -69,7 +72,7 @@ class ManiaLink {
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
public function setXmlEncoding($encoding) {
|
||||
$this->encoding = (string) $encoding;
|
||||
$this->encoding = (string)$encoding;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -80,7 +83,7 @@ class ManiaLink {
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = (string) $id;
|
||||
$this->id = (string)$id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -100,7 +103,7 @@ class ManiaLink {
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
public function setBackground($background) {
|
||||
$this->background = (string) $background;
|
||||
$this->background = (string)$background;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -122,7 +125,7 @@ class ManiaLink {
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
public function setTimeout($timeout) {
|
||||
$this->timeout = (int) $timeout;
|
||||
$this->timeout = (int)$timeout;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -224,14 +227,14 @@ class ManiaLink {
|
||||
/**
|
||||
* Render the XML Document
|
||||
*
|
||||
* @param bool (optional) $echo 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 bool (optional) $echo If the XML Text should be echoed and the Content-Type Header should be set
|
||||
* @param \DOMDocument $domDocument (optional) DOMDocument for which the XML Element should be created
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function render($echo = false, $domDocument = null) {
|
||||
$isChild = (bool) $domDocument;
|
||||
$isChild = (bool)$domDocument;
|
||||
if (!$isChild) {
|
||||
$domDocument = new \DOMDocument('1.0', $this->encoding);
|
||||
$domDocument = new \DOMDocument('1.0', $this->encoding);
|
||||
$domDocument->xmlStandalone = true;
|
||||
}
|
||||
$maniaLink = $domDocument->createElement($this->tagName);
|
||||
@ -260,6 +263,7 @@ class ManiaLink {
|
||||
}
|
||||
$scriptFeatures = array();
|
||||
foreach ($this->children as $child) {
|
||||
/** @var Renderable $child */
|
||||
$childXml = $child->render($domDocument, $this->getScript());
|
||||
$maniaLink->appendChild($childXml);
|
||||
if ($child instanceof ScriptFeatureable) {
|
||||
@ -297,7 +301,7 @@ class ManiaLink {
|
||||
*/
|
||||
public function __toString() {
|
||||
$domDocument = $this->render();
|
||||
$xmlText = $domDocument->saveXML();
|
||||
$xmlText = $domDocument->saveXML();
|
||||
return $xmlText;
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ namespace FML;
|
||||
/**
|
||||
* Class holding several ManiaLinks at once
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class ManiaLinks {
|
||||
/*
|
||||
@ -16,6 +16,7 @@ class ManiaLinks {
|
||||
protected $encoding = 'utf-8';
|
||||
protected $tagName = 'manialinks';
|
||||
protected $children = array();
|
||||
/** @var CustomUI $customUI */
|
||||
protected $customUI = null;
|
||||
|
||||
/**
|
||||
@ -41,7 +42,7 @@ class ManiaLinks {
|
||||
* @return \FML\ManiaLinks
|
||||
*/
|
||||
public function setXmlEncoding($encoding) {
|
||||
$this->encoding = (string) $encoding;
|
||||
$this->encoding = (string)$encoding;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -99,11 +100,12 @@ class ManiaLinks {
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function render($echo = false) {
|
||||
$domDocument = new \DOMDocument('1.0', $this->encoding);
|
||||
$domDocument = new \DOMDocument('1.0', $this->encoding);
|
||||
$domDocument->xmlStandalone = true;
|
||||
$maniaLinks = $domDocument->createElement($this->tagName);
|
||||
$maniaLinks = $domDocument->createElement($this->tagName);
|
||||
$domDocument->appendChild($maniaLinks);
|
||||
foreach ($this->children as $child) {
|
||||
/** @var ManiaLink $child */
|
||||
$childXml = $child->render(false, $domDocument);
|
||||
$maniaLinks->appendChild($childXml);
|
||||
}
|
||||
@ -125,7 +127,7 @@ class ManiaLinks {
|
||||
*/
|
||||
public function __toString() {
|
||||
$domDocument = $this->render();
|
||||
$xmlText = $domDocument->saveXML();
|
||||
$xmlText = $domDocument->saveXML();
|
||||
return $xmlText;
|
||||
}
|
||||
}
|
||||
|
127
application/core/Libs/FML/Models/CheckBoxDesign.php
Normal file
127
application/core/Libs/FML/Models/CheckBoxDesign.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Models;
|
||||
|
||||
use FML\Controls\Quad;
|
||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||
use FML\Script\Builder;
|
||||
use FML\Types\Styleable;
|
||||
use FML\Types\SubStyleable;
|
||||
|
||||
/**
|
||||
* Class representing CheckBox Design
|
||||
*
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CheckBoxDesign implements Styleable, SubStyleable {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $url = null;
|
||||
protected $style = null;
|
||||
protected $subStyle = null;
|
||||
|
||||
/**
|
||||
* Create the Default Enabled Design
|
||||
*
|
||||
* @return \FML\Models\CheckBoxDesign
|
||||
*/
|
||||
public static function defaultEnabledDesign() {
|
||||
$checkBoxDesign = new CheckBoxDesign(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_LvlGreen);
|
||||
return $checkBoxDesign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Default Disabled Design
|
||||
*
|
||||
* @return \FML\Models\CheckBoxDesign
|
||||
*/
|
||||
public static function defaultDisabledDesign() {
|
||||
$checkBoxDesign = new CheckBoxDesign(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_LvlRed);
|
||||
return $checkBoxDesign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new CheckBox Design
|
||||
*
|
||||
* @param string $style Style Name or Image Url
|
||||
* @param string $subStyle SubStyle Name
|
||||
*/
|
||||
public function __construct($style, $subStyle = null) {
|
||||
if ($subStyle === null) {
|
||||
$this->setImageUrl($style);
|
||||
} else {
|
||||
$this->setStyle($style);
|
||||
$this->setSubStyle($subStyle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Image Url
|
||||
*
|
||||
* @param string $url Image Url
|
||||
* @return \FML\Models\CheckBoxDesign
|
||||
*/
|
||||
public function setImageUrl($url) {
|
||||
$this->url = (string)$url;
|
||||
$this->style = null;
|
||||
$this->subStyle = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Styleable::setStyle()
|
||||
*/
|
||||
public function setStyle($style) {
|
||||
$this->style = (string)$style;
|
||||
$this->url = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\SubStyleable::setSubStyle()
|
||||
*/
|
||||
public function setSubStyle($subStyle) {
|
||||
$this->subStyle = (string)$subStyle;
|
||||
$this->url = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\SubStyleable::setStyles()
|
||||
*/
|
||||
public function setStyles($style, $subStyle) {
|
||||
$this->setStyle($style);
|
||||
$this->setSubStyle($subStyle);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Design to the given Quad
|
||||
*
|
||||
* @param Quad $quad CheckBox Quad
|
||||
* @return \FML\Models\CheckBoxDesign
|
||||
*/
|
||||
public function applyToQuad(Quad $quad) {
|
||||
$quad->setImage($this->url);
|
||||
$quad->setStyles($this->style, $this->subStyle);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CheckBox Design String
|
||||
*
|
||||
* @param bool $escaped (optional) Whether the String should be escaped for the Script
|
||||
* @return string
|
||||
*/
|
||||
public function getDesignString($escaped = true) {
|
||||
if ($this->url !== null) {
|
||||
$string = $this->url;
|
||||
} else {
|
||||
$string = $this->style . '|' . $this->subStyle;;
|
||||
}
|
||||
return Builder::escapeText($string);
|
||||
}
|
||||
}
|
@ -3,32 +3,33 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for triggering a Page Action
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class ActionTrigger extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $actionName = null;
|
||||
/** @var Control $control */
|
||||
protected $control = null;
|
||||
protected $labelName = null;
|
||||
|
||||
/**
|
||||
* Construct a new Action Trigger Feature
|
||||
*
|
||||
* @param string $actionName (optional) Triggered Action
|
||||
* @param Control $control (optional) Action Control
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
* @param string $actionName (optional) Triggered Action
|
||||
* @param Control $control (optional) Action Control
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
*/
|
||||
public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
|
||||
$this->setActionName($actionName);
|
||||
@ -49,13 +50,15 @@ class ActionTrigger extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set the Control
|
||||
*
|
||||
*
|
||||
* @param Control $control Action Control
|
||||
* @return \FML\Script\Features\ActionTrigger
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -72,7 +75,6 @@ class ActionTrigger extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -89,13 +91,12 @@ class ActionTrigger extends ScriptFeature {
|
||||
$actionName = Builder::escapeText($this->actionName);
|
||||
if ($this->control) {
|
||||
// Control event
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$scriptText = "
|
||||
if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
TriggerPageAction(\"{$actionName}\");
|
||||
}";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Other
|
||||
$scriptText = "
|
||||
TriggerPageAction(\"{$actionName}\");";
|
||||
|
203
application/core/Libs/FML/Script/Features/CheckBoxFeature.php
Normal file
203
application/core/Libs/FML/Script/Features/CheckBoxFeature.php
Normal file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Entry;
|
||||
use FML\Controls\Quad;
|
||||
use FML\Models\CheckBoxDesign;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptInclude;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
/**
|
||||
* Script Feature for creating a CheckBox Behavior
|
||||
*
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CheckBoxFeature extends ScriptFeature {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const FUNCTION_UPDATE_QUAD_DESIGN = 'FML_UpdateQuadDesign';
|
||||
const VAR_CHECKBOX_ENABLED = 'FML_CheckBox_Enabled';
|
||||
const VAR_CHECKBOX_DESIGNS = 'FML_CheckBox_Designs';
|
||||
const VAR_CHECKBOX_ENTRY_ID = 'FML_CheckBox_EntryId';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Quad $quad */
|
||||
protected $quad = null;
|
||||
/** @var Entry $entry */
|
||||
protected $entry = null;
|
||||
/** @var CheckBoxDesign $enabledDesign */
|
||||
protected $enabledDesign = null;
|
||||
/** @var CheckBoxDesign $disabledDesign */
|
||||
protected $disabledDesign = null;
|
||||
|
||||
/**
|
||||
* Construct a new CheckBox Feature
|
||||
*
|
||||
* @param Quad $quad (optional) CheckBox Quad
|
||||
* @param Entry $entry (optional) Hidden Entry
|
||||
*/
|
||||
public function __construct(Quad $quad = null, Entry $entry = null) {
|
||||
$this->setQuad($quad);
|
||||
$this->setEntry($entry);
|
||||
$this->setEnabledDesign(CheckBoxDesign::defaultEnabledDesign());
|
||||
$this->setDisabledDesign(CheckBoxDesign::defaultDisabledDesign());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CheckBox Quad
|
||||
*
|
||||
* @param Quad $quad CheckBox Quad
|
||||
* @return \FML\Script\Features\CheckBoxFeature
|
||||
*/
|
||||
public function setQuad(Quad $quad = null) {
|
||||
if ($quad) {
|
||||
$quad->checkId();
|
||||
$quad->setScriptEvents(true);
|
||||
}
|
||||
$this->quad = $quad;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CheckBox Quad
|
||||
*
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function getQuad() {
|
||||
return $this->quad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CheckBox Entry
|
||||
*
|
||||
* @param Entry $entry CheckBox Entry
|
||||
* @return \FML\Script\Features\CheckBoxFeature
|
||||
*/
|
||||
public function setEntry(Entry $entry = null) {
|
||||
if ($entry) {
|
||||
$entry->checkId();
|
||||
}
|
||||
$this->entry = $entry;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Enabled Design
|
||||
*
|
||||
* @param CheckBoxDesign $checkBoxDesign CheckBox Design
|
||||
* @return \FML\Script\Features\CheckBoxFeature
|
||||
*/
|
||||
public function setEnabledDesign(CheckBoxDesign $checkBoxDesign) {
|
||||
$this->enabledDesign = $checkBoxDesign;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Disabled Design
|
||||
*
|
||||
* @param CheckBoxDesign $checkBoxDesign CheckBox Design
|
||||
* @return \FML\Script\Features\CheckBoxFeature
|
||||
*/
|
||||
public function setDisabledDesign(CheckBoxDesign $checkBoxDesign) {
|
||||
$this->disabledDesign = $checkBoxDesign;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
if ($this->getQuad()) {
|
||||
$script->setScriptInclude(ScriptInclude::TEXTLIB);
|
||||
$script->addScriptFunction(self::FUNCTION_UPDATE_QUAD_DESIGN, $this->buildSetQuadDesignFunction());
|
||||
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true);
|
||||
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText());
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Function Text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildSetQuadDesignFunction() {
|
||||
$functionText = "
|
||||
Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) {
|
||||
declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True;
|
||||
Enabled = !Enabled;
|
||||
declare " . self::VAR_CHECKBOX_DESIGNS . " as Designs for _Quad = Text[Boolean];
|
||||
declare Design = Designs[Enabled];
|
||||
declare DesignParts = TextLib::Split(\"|\", Design);
|
||||
if (DesignParts.count > 1) {
|
||||
_Quad.Style = DesignParts[0];
|
||||
_Quad.Substyle = DesignParts[1];
|
||||
} else {
|
||||
_Quad.ImageUrl = Design;
|
||||
}
|
||||
declare " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for _Quad = \"\";
|
||||
if (EntryId != \"\") {
|
||||
declare Value = \"0\";
|
||||
if (Enabled) {
|
||||
Value = \"1\";
|
||||
}
|
||||
declare Entry <=> (Page.GetFirstChild(EntryId) as CMlEntry);
|
||||
Entry.Value = Value;
|
||||
}
|
||||
}";
|
||||
return $functionText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Init Script Text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildInitScriptText() {
|
||||
$quadId = $this->getQuad()->getId(true);
|
||||
$default = true;
|
||||
$entryId = '';
|
||||
if ($this->entry) {
|
||||
$default = $this->entry->getDefault();
|
||||
$entryId = $this->entry->getId(true);
|
||||
}
|
||||
$default = Builder::getBoolean($default);
|
||||
$enabledDesignString = $this->enabledDesign->getDesignString();
|
||||
$disabledDesignString = $this->disabledDesign->getDesignString();
|
||||
$scriptText = "
|
||||
declare Quad_CheckBox <=> (Page.GetFirstChild(\"{$quadId}\") as CMlQuad);
|
||||
declare Text[Boolean] " . self::VAR_CHECKBOX_DESIGNS . " as Designs for Quad_CheckBox;
|
||||
Designs[True] = \"{$enabledDesignString}\";
|
||||
Designs[False] = \"{$disabledDesignString}\";
|
||||
declare Boolean " . self::VAR_CHECKBOX_ENABLED . " as Enabled for Quad_CheckBox;
|
||||
Enabled = {$default};
|
||||
declare Text " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for Quad_CheckBox;
|
||||
EntryId = \"{$entryId}\";
|
||||
" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox);
|
||||
";
|
||||
return $scriptText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Script Text for Quad Clicks
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildClickScriptText() {
|
||||
$quadId = $this->getQuad()->getId(true);
|
||||
$scriptText = "
|
||||
if (Event.ControlId == \"{$quadId}\") {
|
||||
declare Quad_CheckBox <=> (Event.Control as CMlQuad);
|
||||
" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox);
|
||||
}";
|
||||
return $scriptText;
|
||||
}
|
||||
}
|
@ -2,25 +2,23 @@
|
||||
|
||||
namespace FML\Script\Features;
|
||||
|
||||
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
|
||||
use FML\Controls\Label;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptInclude;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
/**
|
||||
* Script Feature showing the current Time on a Label
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Clock extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Label $label */
|
||||
protected $label = null;
|
||||
protected $showSeconds = null;
|
||||
protected $showFullDate = null;
|
||||
@ -28,9 +26,9 @@ class Clock extends ScriptFeature {
|
||||
/**
|
||||
* Construct a new Clock Feature
|
||||
*
|
||||
* @param Label $label (optional) Clock Label
|
||||
* @param bool $showSeconds (optional) Whether the Seconds should be shown
|
||||
* @param bool $showFullDate (optional) Whether the Date should be shown
|
||||
* @param Label $label (optional) Clock Label
|
||||
* @param bool $showSeconds (optional) Whether the Seconds should be shown
|
||||
* @param bool $showFullDate (optional) Whether the Date should be shown
|
||||
*/
|
||||
public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) {
|
||||
$this->setLabel($label);
|
||||
@ -57,7 +55,7 @@ class Clock extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Clock
|
||||
*/
|
||||
public function setShowSeconds($showSeconds) {
|
||||
$this->showSeconds = (bool) $showSeconds;
|
||||
$this->showSeconds = (bool)$showSeconds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -68,12 +66,11 @@ class Clock extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Clock
|
||||
*/
|
||||
public function setShowFullDate($showFullDate) {
|
||||
$this->showFullDate = (bool) $showFullDate;
|
||||
$this->showFullDate = (bool)$showFullDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -88,7 +85,7 @@ class Clock extends ScriptFeature {
|
||||
* @return string
|
||||
*/
|
||||
protected function getScriptText() {
|
||||
$controlId = $this->label->getId(true);
|
||||
$controlId = $this->label->getId(true);
|
||||
$scriptText = "
|
||||
declare ClockLabel <=> (Page.GetFirstChild(\"{$controlId}\") as CMlLabel);
|
||||
declare TimeText = CurrentLocalDateText;";
|
||||
|
111
application/core/Libs/FML/Script/Features/ControlScript.php
Normal file
111
application/core/Libs/FML/Script/Features/ControlScript.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for a Control-related Script
|
||||
*
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ControlScript extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Control $control */
|
||||
protected $control = null;
|
||||
protected $labelName = null;
|
||||
protected $text = null;
|
||||
protected $isolated = null;
|
||||
|
||||
/**
|
||||
* Construct a new Custom Script Text
|
||||
*
|
||||
* @param Control $control Event Control
|
||||
* @param string $text Script Text
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
* @param bool $isolated (optional) Whether to isolate the Script Text
|
||||
*/
|
||||
public function __construct(Control $control, $text, $labelName = ScriptLabel::MOUSECLICK, $isolated = true) {
|
||||
$this->setControl($control);
|
||||
$this->setText($text);
|
||||
$this->setLabelName($labelName);
|
||||
$this->setIsolated($isolated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Control
|
||||
*
|
||||
* @param Control $control Custom Control
|
||||
* @return \FML\Script\Features\ControlScript
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Script Text
|
||||
*
|
||||
* @param string $text Script Text
|
||||
* @return \FML\Script\Features\ControlScript
|
||||
*/
|
||||
public function setText($text) {
|
||||
$this->text = (string)$text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Label Name
|
||||
*
|
||||
* @param string $labelName Script Label Name
|
||||
* @return \FML\Script\Features\ControlScript
|
||||
*/
|
||||
public function setLabelName($labelName) {
|
||||
$this->labelName = $labelName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the Script should be isolated
|
||||
*
|
||||
* @param bool $isolated Whether to isolate the Script Text
|
||||
* @return \FML\Script\Features\ControlScript
|
||||
*/
|
||||
public function setIsolated($isolated = true) {
|
||||
$this->isolated = (bool)$isolated;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
$script->appendGenericScriptLabel($this->labelName, $this->getEncapsulatedText(), $this->isolated);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Script Text encapsulated for the Control Event
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getEncapsulatedText() {
|
||||
$controlId = $this->control->getId(true);
|
||||
$scriptText = "
|
||||
if (Event.ControlId == \"{$controlId}\") {
|
||||
{$this->text}
|
||||
}";
|
||||
return $scriptText;
|
||||
}
|
||||
}
|
@ -2,34 +2,32 @@
|
||||
|
||||
namespace FML\Script\Features;
|
||||
|
||||
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
|
||||
use FML\Controls\Entry;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptInclude;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
/**
|
||||
* Script Feature for submitting an Entry
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class EntrySubmit extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Entry $entry */
|
||||
protected $entry = null;
|
||||
protected $url = null;
|
||||
|
||||
/**
|
||||
* Construct a new Entry Submit Feature
|
||||
*
|
||||
* @param Entry $entry (optional) Entry Control
|
||||
* @param string $url (optional) Submit Url
|
||||
* @param Entry $entry (optional) Entry Control
|
||||
* @param string $url (optional) Submit Url
|
||||
*/
|
||||
public function __construct(Entry $entry = null, $url = null) {
|
||||
$this->setEntry($entry);
|
||||
@ -56,12 +54,11 @@ class EntrySubmit extends ScriptFeature {
|
||||
* @return \FML\Script\Features\EntrySubmit
|
||||
*/
|
||||
public function setUrl($url) {
|
||||
$this->url = (string) $url;
|
||||
$this->url = (string)$url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -76,9 +73,9 @@ class EntrySubmit extends ScriptFeature {
|
||||
* @return string
|
||||
*/
|
||||
protected function getScriptText() {
|
||||
$controlId = $this->entry->getId(true);
|
||||
$url = $this->buildCompatibleUrl();
|
||||
$entryName = Builder::escapeText($this->entry->getName());
|
||||
$controlId = $this->entry->getId(true);
|
||||
$url = $this->buildCompatibleUrl();
|
||||
$entryName = Builder::escapeText($this->entry->getName());
|
||||
$scriptText = "
|
||||
if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
declare Entry <=> (Event.Control as CMlEntry);
|
||||
@ -94,12 +91,11 @@ if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
* @return string
|
||||
*/
|
||||
protected function buildCompatibleUrl() {
|
||||
$url = $this->url;
|
||||
$url = $this->url;
|
||||
$paramsBegin = stripos($url, '?');
|
||||
if (!is_int($paramsBegin) || $paramsBegin < 0) {
|
||||
$url .= '?';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$url .= '&';
|
||||
}
|
||||
return $url;
|
||||
|
@ -2,18 +2,17 @@
|
||||
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
/**
|
||||
* Script Feature for triggering a Page Action on Key Press
|
||||
*
|
||||
* @author steeffeen
|
||||
* @link http://destroflyer.mania-community.de/maniascript/keycharid_table.php
|
||||
*
|
||||
* @author steeffeen
|
||||
* @link http://destroflyer.mania-community.de/maniascript/keycharid_table.php
|
||||
* @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
|
||||
*/
|
||||
class KeyAction extends ScriptFeature {
|
||||
/*
|
||||
@ -26,10 +25,10 @@ class KeyAction extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Construct a new Key Action Feature
|
||||
*
|
||||
* @param string $actionName (optional) Triggered Action
|
||||
* @param string $keyName (optional) Key Name
|
||||
* @param int $keyCode (optional) Key Code
|
||||
*
|
||||
* @param string $actionName (optional) Triggered Action
|
||||
* @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) {
|
||||
@ -41,29 +40,29 @@ class KeyAction extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set the Action to trigger
|
||||
*
|
||||
*
|
||||
* @param string $actionName Triggered Action
|
||||
* @return \FML\Script\Features\KeyAction
|
||||
*/
|
||||
public function setActionName($actionName) {
|
||||
$this->actionName = (string) $actionName;
|
||||
$this->actionName = (string)$actionName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Key Name for triggering the Action
|
||||
*
|
||||
*
|
||||
* @param string $keyName Key Name
|
||||
* @return \FML\Script\Features\KeyAction
|
||||
*/
|
||||
public function setKeyName($keyName) {
|
||||
$this->keyName = (string) $keyName;
|
||||
$this->keyName = (string)$keyName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Key Code for triggering the Action
|
||||
*
|
||||
*
|
||||
* @param int $keyCode Key Code
|
||||
* @return \FML\Script\Features\KeyAction
|
||||
*/
|
||||
@ -74,7 +73,7 @@ class KeyAction extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set the Char to press for triggering the Action
|
||||
*
|
||||
*
|
||||
* @param string $charPressed Pressed Char
|
||||
* @return \FML\Script\Features\KeyAction
|
||||
*/
|
||||
@ -84,7 +83,6 @@ class KeyAction extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -94,20 +92,19 @@ class KeyAction extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Get the Script Text
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getScriptText() {
|
||||
$actionName = Builder::escapeText($this->actionName);
|
||||
$key = 'KeyName';
|
||||
$value = $this->keyName;
|
||||
$key = 'KeyName';
|
||||
$value = $this->keyName;
|
||||
if ($this->keyCode !== null) {
|
||||
$key = 'KeyCode';
|
||||
$value = (int) $this->keyCode;
|
||||
}
|
||||
else if ($this->charPressed !== null) {
|
||||
$key = 'CharPressed';
|
||||
$value = (string) $this->charPressed;
|
||||
$key = 'KeyCode';
|
||||
$value = (int)$this->keyCode;
|
||||
} else if ($this->charPressed !== null) {
|
||||
$key = 'CharPressed';
|
||||
$value = (string)$this->charPressed;
|
||||
}
|
||||
$scriptText = "
|
||||
if (Event.{$key} == \"{$value}\") {
|
||||
|
@ -3,30 +3,31 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for opening the Map Info
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class MapInfo extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Control $control */
|
||||
protected $control = null;
|
||||
protected $labelName = null;
|
||||
|
||||
/**
|
||||
* Construct a new Map Info Feature
|
||||
*
|
||||
* @param Control $control (optional) Map Info Control
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
* @param Control $control (optional) Map Info Control
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
*/
|
||||
public function __construct(Control $control, $labelName = ScriptLabel::MOUSECLICK) {
|
||||
$this->setControl($control);
|
||||
@ -36,12 +37,14 @@ class MapInfo extends ScriptFeature {
|
||||
/**
|
||||
* Set the Control
|
||||
*
|
||||
* @param Control $control Action Control
|
||||
* @return \FML\Script\Features\ActionTrigger
|
||||
* @param Control $control Map Info Control
|
||||
* @return \FML\Script\Features\MapInfo
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -50,7 +53,7 @@ class MapInfo extends ScriptFeature {
|
||||
* Set the Label Name
|
||||
*
|
||||
* @param string $labelName Script Label Name
|
||||
* @return \FML\Script\Features\ActionTrigger
|
||||
* @return \FML\Script\Features\MapInfo
|
||||
*/
|
||||
public function setLabelName($labelName) {
|
||||
$this->labelName = $labelName;
|
||||
@ -58,7 +61,6 @@ class MapInfo extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -74,13 +76,12 @@ class MapInfo extends ScriptFeature {
|
||||
protected function getScriptText() {
|
||||
if ($this->control) {
|
||||
// Control event
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$scriptText = "
|
||||
if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
ShowCurChallengeCard();
|
||||
}";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Other
|
||||
$scriptText = "
|
||||
ShowCurChallengeCard();";
|
||||
|
@ -3,48 +3,48 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
|
||||
/**
|
||||
* Script Feature realising a Menu showing specific Controls for the different Item Controls
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Menu extends ScriptFeature {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const FUNCTION_UPDATE_MENU = 'FML_UpdateMenu';
|
||||
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $elements = array();
|
||||
/** @var MenuElement $startElement */
|
||||
protected $startElement = null;
|
||||
|
||||
/**
|
||||
* Construct a new Menu Feature
|
||||
*
|
||||
* @param Control $item (optional) Item Control in the Menu Bar
|
||||
* @param Control $item (optional) Item Control in the Menu Bar
|
||||
* @param Control $control (optional) Toggled Menu Control
|
||||
*/
|
||||
public function __construct(Control $item = null, Control $control = null) {
|
||||
if ($item && $control) {
|
||||
$this->addNewElement($item, $control);
|
||||
$this->addElement($item, $control);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new Element to the Menu
|
||||
*
|
||||
* @param Control $item Item Control in the Menu Bar
|
||||
* @param Control $control Toggled Menu Control
|
||||
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
|
||||
* @param Control $item Item Control in the Menu Bar
|
||||
* @param Control $control Toggled Menu Control
|
||||
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
|
||||
* @return \FML\Script\Features\Menu
|
||||
*/
|
||||
public function addElement(Control $item, Control $control, $isStartElement = false) {
|
||||
@ -56,16 +56,15 @@ class Menu extends ScriptFeature {
|
||||
/**
|
||||
* Append an Element to the Menu
|
||||
*
|
||||
* @param MenuElement $menuElement Menu Element
|
||||
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
|
||||
* @param MenuElement $menuElement Menu Element
|
||||
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
|
||||
* @return \FML\Script\Features\Menu
|
||||
*/
|
||||
public function appendElement(MenuElement $menuElement, $isStartElement = false) {
|
||||
array_push($this->elements, $menuElement);
|
||||
if ($isStartElement) {
|
||||
$this->setStartElement($menuElement);
|
||||
}
|
||||
else if (count($this->elements) > 1) {
|
||||
} else if (count($this->elements) > 1) {
|
||||
$menuElement->getControl()->setVisible(false);
|
||||
}
|
||||
return $this;
|
||||
@ -86,13 +85,12 @@ class Menu extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
$updateFunctionName = self::FUNCTION_UPDATE_MENU;
|
||||
$elementsArrayText = $this->getElementsArrayText();
|
||||
|
||||
$elementsArrayText = $this->getElementsArrayText();
|
||||
|
||||
// OnInit
|
||||
if ($this->startElement) {
|
||||
$startControlId = $this->startElement->getControl()->getId(true);
|
||||
@ -100,7 +98,7 @@ class Menu extends ScriptFeature {
|
||||
{$updateFunctionName}({$elementsArrayText}, \"{$startControlId}\");";
|
||||
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
|
||||
}
|
||||
|
||||
|
||||
// MouseClick
|
||||
$scriptText = "
|
||||
declare MenuElements = {$elementsArrayText};
|
||||
@ -109,7 +107,7 @@ if (MenuElements.existskey(Event.Control.ControlId)) {
|
||||
{$updateFunctionName}(MenuElements, ShownControlId);
|
||||
}";
|
||||
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true);
|
||||
|
||||
|
||||
// Update menu function
|
||||
$updateFunctionText = "
|
||||
Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {
|
||||
@ -119,7 +117,7 @@ Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {
|
||||
}
|
||||
}";
|
||||
$script->addScriptFunction($updateFunctionName, $updateFunctionText);
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -131,7 +129,9 @@ Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {
|
||||
protected function getElementsArrayText() {
|
||||
$elements = array();
|
||||
foreach ($this->elements as $element) {
|
||||
$elements[$element->getItem()->getId()] = $element->getControl()->getId();
|
||||
/** @var MenuElement $element */
|
||||
$elementId = $element->getItem()->getId();
|
||||
$elements[$elementId] = $element->getControl()->getId();
|
||||
}
|
||||
return Builder::getArray($elements, true);
|
||||
}
|
||||
|
@ -3,13 +3,14 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* An Element for the Menu Feature
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class MenuElement {
|
||||
/*
|
||||
@ -21,7 +22,7 @@ class MenuElement {
|
||||
/**
|
||||
* Create a new Menu Element
|
||||
*
|
||||
* @param Control $item (optional) Item Control in the Menu Bar
|
||||
* @param Control $item (optional) Item Control in the Menu Bar
|
||||
* @param Control $control (optional) Toggled Menu Control
|
||||
*/
|
||||
public function __construct(Control $item = null, Control $control = null) {
|
||||
@ -37,7 +38,9 @@ class MenuElement {
|
||||
*/
|
||||
public function setItem(Control $item) {
|
||||
$item->checkId();
|
||||
$item->setScriptEvents(true);
|
||||
if ($item instanceof Scriptable) {
|
||||
$item->setScriptEvents(true);
|
||||
}
|
||||
$this->item = $item;
|
||||
return $this;
|
||||
}
|
||||
|
@ -3,31 +3,32 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
use FML\Controls\Label;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptInclude;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
/**
|
||||
* Script Feature realising a Mechanism for browsing through Pages
|
||||
*
|
||||
* @author steeffeen
|
||||
*
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Paging extends ScriptFeature {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const VAR_CURRENT_PAGE = 'FML_Paging_CurrentPage';
|
||||
const VAR_CURRENT_PAGE = 'FML_Paging_CurrentPage';
|
||||
const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage';
|
||||
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $pages = array();
|
||||
protected $buttons = array();
|
||||
/** @var Label $label */
|
||||
protected $label = null;
|
||||
protected $startPageNumber = null;
|
||||
protected $customMaxPageNumber = null;
|
||||
@ -37,7 +38,7 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Construct a new Paging Script Feature
|
||||
*
|
||||
*
|
||||
* @param Label $label (optional) Page Number Label
|
||||
*/
|
||||
public function __construct(Label $label = null) {
|
||||
@ -48,9 +49,9 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Add a new Page Control
|
||||
*
|
||||
*
|
||||
* @param Control $pageControl Page Control
|
||||
* @param string $pageNumber (optional) Page Number
|
||||
* @param string $pageNumber (optional) Page Number
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
public function addPage(Control $pageControl, $pageNumber = null) {
|
||||
@ -64,7 +65,7 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Append a Page
|
||||
*
|
||||
*
|
||||
* @param PagingPage $page Paging Page
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
@ -75,9 +76,9 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Add a new Button to browse through the Pages
|
||||
*
|
||||
*
|
||||
* @param Control $buttonControl Button used for Browsing
|
||||
* @param int $browseAction (optional) Number of browsed Pages per Click
|
||||
* @param int $browseAction (optional) Number of browsed Pages per Click
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
public function addButton(Control $buttonControl, $browseAction = null) {
|
||||
@ -85,8 +86,7 @@ class Paging extends ScriptFeature {
|
||||
$buttonCount = count($this->buttons);
|
||||
if ($buttonCount % 2 === 0) {
|
||||
$browseAction = $buttonCount / 2 + 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$browseAction = $buttonCount / -2 - 1;
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Append a Button to browse through Pages
|
||||
*
|
||||
*
|
||||
* @param PagingButton $button Paging Button
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
@ -108,7 +108,7 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set the Label showing the Page Number
|
||||
*
|
||||
*
|
||||
* @param Label $label Page Number Label
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
@ -120,50 +120,50 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set the Start Page Number
|
||||
*
|
||||
*
|
||||
* @param int $startPageNumber Page Number to start with
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
public function setStartPageNumber($startPageNumber) {
|
||||
$this->startPageNumber = (int) $startPageNumber;
|
||||
$this->startPageNumber = (int)$startPageNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom Maximum Page Number for using Chunks
|
||||
*
|
||||
*
|
||||
* @param int $maxPageNumber Custom Maximum Page Number
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
public function setCustomMaxPageNumber($maxPageNumber) {
|
||||
$this->customMaxPageNumber = (int) $maxPageNumber;
|
||||
$this->customMaxPageNumber = (int)$maxPageNumber;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Action triggered when the previous Chunk is needed
|
||||
*
|
||||
*
|
||||
* @param string $previousChunkAction Triggered Action
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
public function setPreviousChunkAction($previousChunkAction) {
|
||||
$this->previousChunkAction = (string) $previousChunkAction;
|
||||
$this->previousChunkAction = (string)$previousChunkAction;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Action triggered when the next Chunk is needed
|
||||
*
|
||||
*
|
||||
* @param string $nextChunkAction Triggered Action
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
public function setNextChunkAction($nextChunkAction) {
|
||||
$this->nextChunkAction = (string) $nextChunkAction;
|
||||
$this->nextChunkAction = (string)$nextChunkAction;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Actions triggered when another Chunk is needed
|
||||
*
|
||||
*
|
||||
* @param string $chunkAction Triggered Action
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
@ -175,18 +175,16 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set if the Chunk Action should get the needed Page Number appended
|
||||
*
|
||||
*
|
||||
* @param bool $appendPageNumber Whether to append the needed Page Number
|
||||
* @return \FML\Script\Features\Paging
|
||||
*
|
||||
*/
|
||||
public function setChunkActionAppendsPageNumber($appendPageNumber) {
|
||||
$this->chunkActionAppendsPageNumber = (bool) $appendPageNumber;
|
||||
$this->chunkActionAppendsPageNumber = (bool)$appendPageNumber;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -194,37 +192,37 @@ class Paging extends ScriptFeature {
|
||||
return $this;
|
||||
}
|
||||
$script->setScriptInclude(ScriptInclude::TEXTLIB);
|
||||
|
||||
|
||||
$currentPageVariable = self::VAR_CURRENT_PAGE;
|
||||
$updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE;
|
||||
|
||||
$minPageNumber = 1;
|
||||
$updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE;
|
||||
|
||||
$minPageNumber = 1;
|
||||
$startPageNumber = (is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber);
|
||||
$maxPage = $this->getMaxPage();
|
||||
$maxPageNumber = $this->customMaxPageNumber;
|
||||
$maxPage = $this->getMaxPage();
|
||||
$maxPageNumber = $this->customMaxPageNumber;
|
||||
if (!is_int($maxPageNumber)) {
|
||||
$maxPageNumber = $maxPage->getPageNumber();
|
||||
}
|
||||
|
||||
$pagingId = $maxPage->getControl()->getId(true);
|
||||
|
||||
$pagingId = $maxPage->getControl()->getId(true);
|
||||
$pageLabelId = '';
|
||||
if ($this->label) {
|
||||
$pageLabelId = $this->label->getId(true);
|
||||
}
|
||||
$pagesArrayText = $this->getPagesArrayText();
|
||||
$pagesArrayText = $this->getPagesArrayText();
|
||||
$pageButtonsArrayText = $this->getPageButtonsArrayText();
|
||||
|
||||
$previousChunkAction = Builder::escapeText($this->previousChunkAction);
|
||||
$nextChunkAction = Builder::escapeText($this->nextChunkAction);
|
||||
|
||||
$previousChunkAction = Builder::escapeText($this->previousChunkAction);
|
||||
$nextChunkAction = Builder::escapeText($this->nextChunkAction);
|
||||
$chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber);
|
||||
|
||||
|
||||
// Init
|
||||
$initScriptText = "
|
||||
declare {$currentPageVariable} for This = Integer[Text];
|
||||
{$currentPageVariable}[\"{$pagingId}\"] = {$startPageNumber};
|
||||
{$updatePageFunction}(\"{$pagingId}\", \"{$pageLabelId}\", 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, \"{$previousChunkAction}\", \"{$nextChunkAction}\", {$chunkActionAppendsPageNumber});";
|
||||
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
|
||||
|
||||
|
||||
// MouseClick
|
||||
$clickScriptText = "
|
||||
declare PageButtons = {$pageButtonsArrayText};
|
||||
@ -233,7 +231,7 @@ if (PageButtons.existskey(Event.Control.ControlId)) {
|
||||
{$updatePageFunction}(\"{$pagingId}\", \"{$pageLabelId}\", BrowseAction, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, \"{$previousChunkAction}\", \"{$nextChunkAction}\", {$chunkActionAppendsPageNumber});
|
||||
}";
|
||||
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true);
|
||||
|
||||
|
||||
// Update function
|
||||
$functionText = "
|
||||
Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAction, Integer _MinPageNumber, Integer _MaxPageNumber, Text[Integer] _Pages, Text _PreviousChunkAction, Text _NextChunkAction, Boolean _ChunkActionAppendPageNumber) {
|
||||
@ -277,17 +275,18 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
|
||||
|
||||
/**
|
||||
* Get the minimum Page
|
||||
*
|
||||
*
|
||||
* @return \FML\Script\Features\PagingPage
|
||||
*/
|
||||
protected function getMinPage() {
|
||||
$minPageNumber = null;
|
||||
$minPage = null;
|
||||
$minPage = null;
|
||||
foreach ($this->pages as $page) {
|
||||
/** @var PagingPage $page */
|
||||
$pageNumber = $page->getPageNumber();
|
||||
if ($minPageNumber === null || $pageNumber < $minPageNumber) {
|
||||
$minPageNumber = $pageNumber;
|
||||
$minPage = $page;
|
||||
$minPage = $page;
|
||||
}
|
||||
}
|
||||
return $minPage;
|
||||
@ -295,17 +294,18 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
|
||||
|
||||
/**
|
||||
* Get the maximum Page
|
||||
*
|
||||
*
|
||||
* @return \FML\Script\Features\PagingPage
|
||||
*/
|
||||
protected function getMaxPage() {
|
||||
$maxPageNumber = null;
|
||||
$maxPage = null;
|
||||
$maxPage = null;
|
||||
foreach ($this->pages as $page) {
|
||||
/** @var PagingPage $page */
|
||||
$pageNumber = $page->getPageNumber();
|
||||
if ($maxPageNumber === null || $pageNumber > $maxPageNumber) {
|
||||
$maxPageNumber = $pageNumber;
|
||||
$maxPage = $page;
|
||||
$maxPage = $page;
|
||||
}
|
||||
}
|
||||
return $maxPage;
|
||||
@ -313,20 +313,22 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
|
||||
|
||||
/**
|
||||
* Build the Array Text for the Pages
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getPagesArrayText() {
|
||||
$pages = array();
|
||||
foreach ($this->pages as $page) {
|
||||
$pages[$page->getPageNumber()] = $page->getControl()->getId();
|
||||
/** @var PagingPage $page */
|
||||
$pageNumber = $page->getPageNumber();
|
||||
$pages[$pageNumber] = $page->getControl()->getId();
|
||||
}
|
||||
return Builder::getArray($pages, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Array Text for the Page Buttons
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getPageButtonsArrayText() {
|
||||
@ -335,7 +337,9 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
|
||||
}
|
||||
$pageButtons = array();
|
||||
foreach ($this->buttons as $pageButton) {
|
||||
$pageButtons[$pageButton->getControl()->getId()] = $pageButton->getBrowseAction();
|
||||
/** @var PagingButton $pageButton */
|
||||
$pageButtonId = $pageButton->getControl()->getId();
|
||||
$pageButtons[$pageButtonId] = $pageButton->getBrowseAction();
|
||||
}
|
||||
return Builder::getArray($pageButtons, true);
|
||||
}
|
||||
|
@ -3,13 +3,14 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* A Button for browsing through Pages
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class PagingButton {
|
||||
/*
|
||||
@ -21,8 +22,8 @@ class PagingButton {
|
||||
/**
|
||||
* Construct a new Paging Button
|
||||
*
|
||||
* @param Control $control (optional) Browse Control
|
||||
* @param int $browseAction (optional) Number of browsed Pages per Click
|
||||
* @param Control $control (optional) Browse Control
|
||||
* @param int $browseAction (optional) Number of browsed Pages per Click
|
||||
*/
|
||||
public function __construct(Control $control = null, $browseAction = null) {
|
||||
$this->setControl($control);
|
||||
@ -37,7 +38,9 @@ class PagingButton {
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -58,7 +61,7 @@ class PagingButton {
|
||||
* @return \FML\Script\Features\PagingButton
|
||||
*/
|
||||
public function setBrowseAction($browseAction) {
|
||||
$this->browseAction = (int) $browseAction;
|
||||
$this->browseAction = (int)$browseAction;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -3,31 +3,33 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for opening a Player Profile
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class PlayerProfile extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $login = null;
|
||||
/** @var Control $control */
|
||||
protected $control = null;
|
||||
protected $labelName = null;
|
||||
|
||||
/**
|
||||
* Construct a new Player Profile Feature
|
||||
*
|
||||
* @param string $login (optional) Player Login
|
||||
* @param Control $control (optional) Action Control
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
* @param string $login (optional) Player Login
|
||||
* @param Control $control (optional) Action Control
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
*/
|
||||
public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
|
||||
$this->setLogin($login);
|
||||
@ -54,7 +56,9 @@ class PlayerProfile extends ScriptFeature {
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -71,7 +75,6 @@ class PlayerProfile extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -88,13 +91,12 @@ class PlayerProfile extends ScriptFeature {
|
||||
$login = Builder::escapeText($this->login);
|
||||
if ($this->control) {
|
||||
// Control event
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$scriptText = "
|
||||
if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
ShowProfile(\"{$login}\");
|
||||
}";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Other
|
||||
$scriptText = "
|
||||
ShowProfile(\"{$login}\");";
|
||||
|
@ -5,20 +5,22 @@ namespace FML\Script\Features;
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for toggling Controls
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Toggle extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Control $togglingControl */
|
||||
protected $togglingControl = null;
|
||||
/** @var Control $toggledControl */
|
||||
protected $toggledControl = null;
|
||||
protected $labelName = null;
|
||||
protected $onlyShow = null;
|
||||
@ -28,10 +30,10 @@ class Toggle extends ScriptFeature {
|
||||
* Construct a new Toggle Feature
|
||||
*
|
||||
* @param Control $togglingControl (optional) Toggling Control
|
||||
* @param Control $toggledControl (optional) Toggled Control
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle
|
||||
* @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle
|
||||
* @param Control $toggledControl (optional) Toggled Control
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle
|
||||
* @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle
|
||||
*/
|
||||
public function __construct(Control $togglingControl = null, Control $toggledControl = null, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) {
|
||||
$this->setTogglingControl($togglingControl);
|
||||
@ -49,7 +51,9 @@ class Toggle extends ScriptFeature {
|
||||
*/
|
||||
public function setTogglingControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->togglingControl = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -73,7 +77,7 @@ class Toggle extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Toggle
|
||||
*/
|
||||
public function setLabelName($labelName) {
|
||||
$this->labelName = (string) $labelName;
|
||||
$this->labelName = (string)$labelName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -84,7 +88,7 @@ class Toggle extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Toggle
|
||||
*/
|
||||
public function setOnlyShow($onlyShow) {
|
||||
$this->onlyShow = (bool) $onlyShow;
|
||||
$this->onlyShow = (bool)$onlyShow;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -95,12 +99,11 @@ class Toggle extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Toggle
|
||||
*/
|
||||
public function setOnlyHide($onlyHide) {
|
||||
$this->onlyHide = (bool) $onlyHide;
|
||||
$this->onlyHide = (bool)$onlyHide;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -115,12 +118,11 @@ class Toggle extends ScriptFeature {
|
||||
*/
|
||||
protected function getScriptText() {
|
||||
$togglingControlId = $this->togglingControl->getId(true);
|
||||
$toggledControlId = $this->toggledControl->getId(true);
|
||||
$visibility = '!ToggleControl.Visible';
|
||||
$toggledControlId = $this->toggledControl->getId(true);
|
||||
$visibility = '!ToggleControl.Visible';
|
||||
if ($this->onlyShow) {
|
||||
$visibility = 'True';
|
||||
}
|
||||
else if ($this->onlyHide) {
|
||||
} else if ($this->onlyHide) {
|
||||
$visibility = 'False';
|
||||
}
|
||||
$scriptText = "
|
||||
|
@ -3,25 +3,26 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Controls\Label;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
|
||||
use FML\Controls\Label;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for Showing Tooltips
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Tooltip extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Control $hoverControl */
|
||||
protected $hoverControl = null;
|
||||
/** @var Control $tooltipControl */
|
||||
protected $tooltipControl = null;
|
||||
protected $stayOnClick = null;
|
||||
protected $invert = null;
|
||||
@ -30,11 +31,11 @@ class Tooltip extends ScriptFeature {
|
||||
/**
|
||||
* Construct a new Tooltip Feature
|
||||
*
|
||||
* @param Control $hoverControl (optional) Hover Control
|
||||
* @param Control $hoverControl (optional) Hover Control
|
||||
* @param Control $tooltipControl (optional) Tooltip Control
|
||||
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
|
||||
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
|
||||
* @param string $text (optional) The Text to display if the TooltipControl is a Label
|
||||
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
|
||||
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
|
||||
* @param string $text (optional) The Text to display if the TooltipControl is a Label
|
||||
*/
|
||||
public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = false, $invert = false, $text = null) {
|
||||
$this->setHoverControl($hoverControl);
|
||||
@ -52,7 +53,9 @@ class Tooltip extends ScriptFeature {
|
||||
*/
|
||||
public function setHoverControl(Control $hoverControl) {
|
||||
$hoverControl->checkId();
|
||||
$hoverControl->setScriptEvents(true);
|
||||
if ($hoverControl instanceof Scriptable) {
|
||||
$hoverControl->setScriptEvents(true);
|
||||
}
|
||||
$this->hoverControl = $hoverControl;
|
||||
return $this;
|
||||
}
|
||||
@ -77,7 +80,7 @@ class Tooltip extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Tooltip
|
||||
*/
|
||||
public function setStayOnClick($stayOnClick) {
|
||||
$this->stayOnClick = (bool) $stayOnClick;
|
||||
$this->stayOnClick = (bool)$stayOnClick;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -88,7 +91,7 @@ class Tooltip extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Tooltip
|
||||
*/
|
||||
public function setInvert($invert) {
|
||||
$this->invert = (bool) $invert;
|
||||
$this->invert = (bool)$invert;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -104,13 +107,12 @@ class Tooltip extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
$hoverControlId = $this->hoverControl->getId(true);
|
||||
$hoverControlId = $this->hoverControl->getId(true);
|
||||
$tooltipControlId = $this->tooltipControl->getId(true);
|
||||
|
||||
|
||||
// MouseOver
|
||||
$visibility = ($this->invert ? 'False' : 'True');
|
||||
$scriptText = "
|
||||
@ -126,7 +128,7 @@ if (Event.Control.ControlId == \"{$hoverControlId}\") {
|
||||
$scriptText .= "
|
||||
}";
|
||||
$script->appendGenericScriptLabel(ScriptLabel::MOUSEOVER, $scriptText);
|
||||
|
||||
|
||||
// MouseOut
|
||||
$visibility = ($this->invert ? 'True' : 'False');
|
||||
$scriptText = "
|
||||
@ -141,7 +143,7 @@ if (Event.Control.ControlId == \"{$hoverControlId}\") {
|
||||
TooltipControl.Visible = {$visibility};
|
||||
}";
|
||||
$script->appendGenericScriptLabel(ScriptLabel::MOUSEOUT, $scriptText);
|
||||
|
||||
|
||||
// MouseClick
|
||||
if ($this->stayOnClick) {
|
||||
$scriptText = "
|
||||
|
@ -3,55 +3,57 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for playing an UI Sound
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class UISound extends ScriptFeature {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const Bonus = 'Bonus';
|
||||
const Capture = 'Capture';
|
||||
const Checkpoint = 'Checkpoint';
|
||||
const Combo = 'Combo';
|
||||
const Custom1 = 'Custom1';
|
||||
const Custom2 = 'Custom2';
|
||||
const Custom3 = 'Custom3';
|
||||
const Custom4 = 'Custom4';
|
||||
const Default_ = 'Default';
|
||||
const EndMatch = 'EndMatch';
|
||||
const EndRound = 'EndRound';
|
||||
const Finish = 'Finish';
|
||||
const FirstHit = 'FirstHit';
|
||||
const Notice = 'Notice';
|
||||
const PhaseChange = 'PhaseChange';
|
||||
const Bonus = 'Bonus';
|
||||
const Capture = 'Capture';
|
||||
const Checkpoint = 'Checkpoint';
|
||||
const Combo = 'Combo';
|
||||
const Custom1 = 'Custom1';
|
||||
const Custom2 = 'Custom2';
|
||||
const Custom3 = 'Custom3';
|
||||
const Custom4 = 'Custom4';
|
||||
const Default_ = 'Default';
|
||||
const EndMatch = 'EndMatch';
|
||||
const EndRound = 'EndRound';
|
||||
const Finish = 'Finish';
|
||||
const FirstHit = 'FirstHit';
|
||||
const Notice = 'Notice';
|
||||
const PhaseChange = 'PhaseChange';
|
||||
const PlayerEliminated = 'PlayerEliminated';
|
||||
const PlayerHit = 'PlayerHit';
|
||||
const PlayerHit = 'PlayerHit';
|
||||
const PlayersRemaining = 'PlayersRemaining';
|
||||
const RankChange = 'RankChange';
|
||||
const Record = 'Record';
|
||||
const ScoreProgress = 'ScoreProgress';
|
||||
const Silence = 'Silence';
|
||||
const StartMatch = 'StartMatch';
|
||||
const StartRound = 'StartRound';
|
||||
const TieBreakPoint = 'TieBreakPoint';
|
||||
const TiePoint = 'TiePoint';
|
||||
const TimeOut = 'TimeOut';
|
||||
const VictoryPoint = 'VictoryPoint';
|
||||
const Warning = 'Warning';
|
||||
|
||||
const RankChange = 'RankChange';
|
||||
const Record = 'Record';
|
||||
const ScoreProgress = 'ScoreProgress';
|
||||
const Silence = 'Silence';
|
||||
const StartMatch = 'StartMatch';
|
||||
const StartRound = 'StartRound';
|
||||
const TieBreakPoint = 'TieBreakPoint';
|
||||
const TiePoint = 'TiePoint';
|
||||
const TimeOut = 'TimeOut';
|
||||
const VictoryPoint = 'VictoryPoint';
|
||||
const Warning = 'Warning';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $soundName = null;
|
||||
/** @var Control $control */
|
||||
protected $control = null;
|
||||
protected $variant = 0;
|
||||
protected $volume = 1.;
|
||||
@ -60,10 +62,10 @@ class UISound extends ScriptFeature {
|
||||
/**
|
||||
* Construct a new UISound Feature
|
||||
*
|
||||
* @param string $soundName (optional) Played Sound
|
||||
* @param Control $control (optional) Action Control
|
||||
* @param int $variant (optional) Sound Variant
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
* @param string $soundName (optional) Played Sound
|
||||
* @param Control $control (optional) Action Control
|
||||
* @param int $variant (optional) Sound Variant
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
*/
|
||||
public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) {
|
||||
$this->setSoundName($soundName);
|
||||
@ -79,7 +81,7 @@ class UISound extends ScriptFeature {
|
||||
* @return \FML\Script\Features\UISound
|
||||
*/
|
||||
public function setSoundName($soundName) {
|
||||
$this->soundName = (string) $soundName;
|
||||
$this->soundName = (string)$soundName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -91,7 +93,9 @@ class UISound extends ScriptFeature {
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -103,7 +107,7 @@ class UISound extends ScriptFeature {
|
||||
* @return \FML\Script\Features\UISound
|
||||
*/
|
||||
public function setVariant($variant) {
|
||||
$this->variant = (int) $variant;
|
||||
$this->variant = (int)$variant;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -114,7 +118,7 @@ class UISound extends ScriptFeature {
|
||||
* @return \FML\Script\Features\UISound
|
||||
*/
|
||||
public function setVolume($volume) {
|
||||
$this->volume = (float) $volume;
|
||||
$this->volume = (float)$volume;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -125,12 +129,11 @@ class UISound extends ScriptFeature {
|
||||
* @return \FML\Script\Features\UISound
|
||||
*/
|
||||
public function setLabelName($labelName) {
|
||||
$this->labelName = (string) $labelName;
|
||||
$this->labelName = (string)$labelName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -146,13 +149,12 @@ class UISound extends ScriptFeature {
|
||||
protected function getScriptText() {
|
||||
if ($this->control) {
|
||||
// Control event
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$scriptText = "
|
||||
if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});
|
||||
}";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Other
|
||||
$scriptText = "
|
||||
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});";
|
||||
|
@ -7,19 +7,19 @@ use FML\Script\Features\ScriptFeature;
|
||||
/**
|
||||
* Class representing the ManiaLink Script
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Script {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const TICKINTERVAL = 250;
|
||||
const TICKINTERVAL = 250;
|
||||
const VAR_ScriptStart = 'FML_ScriptStart';
|
||||
const VAR_LoopCounter = 'FML_LoopCounter';
|
||||
const VAR_LastTick = 'FML_LastTick';
|
||||
|
||||
const VAR_LastTick = 'FML_LastTick';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
@ -34,33 +34,32 @@ class Script {
|
||||
/**
|
||||
* Set a Script Include
|
||||
*
|
||||
* @param string $file Include File
|
||||
* @param string $file Include File
|
||||
* @param string $namespace Include Namespace
|
||||
* @return \FML\Script\Script
|
||||
*/
|
||||
public function setScriptInclude($file, $namespace = null) {
|
||||
if (is_object($file) && ($file instanceof ScriptInclude)) {
|
||||
$scriptInclude = $file;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scriptInclude = new ScriptInclude($file, $namespace);
|
||||
}
|
||||
$this->includes[$scriptInclude->getNamespace()] = $scriptInclude;
|
||||
$namespace = $scriptInclude->getNamespace();
|
||||
$this->includes[$namespace] = $scriptInclude;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Script Constant
|
||||
*
|
||||
* @param string $name Constant Name
|
||||
* @param string $name Constant Name
|
||||
* @param string $value Constant Value
|
||||
* @return \FML\Script\Script
|
||||
*/
|
||||
public function addScriptConstant($name, $value = null) {
|
||||
if (is_object($name) && ($name instanceof ScriptConstant)) {
|
||||
$scriptConstant = $name;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scriptConstant = new ScriptConstant($name, $value);
|
||||
}
|
||||
array_push($this->constants, $scriptConstant);
|
||||
@ -77,8 +76,7 @@ class Script {
|
||||
public function addScriptFunction($name, $text = null) {
|
||||
if (is_object($name) && ($name instanceof ScriptFunction)) {
|
||||
$scriptFunction = $name;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scriptFunction = new ScriptFunction($name, $text);
|
||||
}
|
||||
if (!in_array($scriptFunction, $this->functions)) {
|
||||
@ -97,8 +95,7 @@ class Script {
|
||||
public function addCustomScriptLabel($name, $text = null) {
|
||||
if (is_object($name) && ($name instanceof ScriptLabel)) {
|
||||
$scriptLabel = $name;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scriptLabel = new ScriptLabel($name, $text);
|
||||
}
|
||||
array_push($this->customLabels, $scriptLabel);
|
||||
@ -108,16 +105,15 @@ class Script {
|
||||
/**
|
||||
* Append a generic Script Text for the next Rendering
|
||||
*
|
||||
* @param string $name Label Name
|
||||
* @param string $text Script Text
|
||||
* @param bool $isolated (optional) Whether to isolate the Label Script
|
||||
* @param string $name Label Name
|
||||
* @param string $text Script Text
|
||||
* @param bool $isolated (optional) Whether to isolate the Label Script
|
||||
* @return \FML\Script\Script
|
||||
*/
|
||||
public function appendGenericScriptLabel($name, $text = null, $isolated = false) {
|
||||
if (is_object($name) && ($name instanceof ScriptLabel)) {
|
||||
$scriptLabel = $name;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scriptLabel = new ScriptLabel($name, $text, $isolated);
|
||||
}
|
||||
array_push($this->genericLabels, $scriptLabel);
|
||||
@ -205,8 +201,8 @@ class Script {
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$this->loadFeatures($this->features);
|
||||
$scriptXml = $domDocument->createElement($this->tagName);
|
||||
$scriptText = $this->buildScriptText();
|
||||
$scriptXml = $domDocument->createElement($this->tagName);
|
||||
$scriptText = $this->buildScriptText();
|
||||
$scriptComment = $domDocument->createComment($scriptText);
|
||||
$scriptXml->appendChild($scriptComment);
|
||||
return $scriptXml;
|
||||
@ -222,6 +218,7 @@ class Script {
|
||||
* FancyManiaLinks v' . FML_VERSION . ' by steeffeen *
|
||||
* http://github.com/steeffeen/FancyManiaLinks *
|
||||
****************************************************/
|
||||
|
||||
';
|
||||
return $headerComment;
|
||||
}
|
||||
@ -262,7 +259,7 @@ class Script {
|
||||
* @return string
|
||||
*/
|
||||
protected function getLabels() {
|
||||
$customLabelsText = implode(PHP_EOL, $this->customLabels);
|
||||
$customLabelsText = implode(PHP_EOL, $this->customLabels);
|
||||
$genericLabelsText = implode(PHP_EOL, $this->genericLabels);
|
||||
return $customLabelsText . $genericLabelsText;
|
||||
}
|
||||
|
@ -5,23 +5,23 @@ namespace FML\Script;
|
||||
/**
|
||||
* Class representing a Part of the ManiaLink Script
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class ScriptLabel {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const ONINIT = 'FML_OnInit';
|
||||
const LOOP = 'FML_Loop';
|
||||
const TICK = 'FML_Tick';
|
||||
const ONINIT = 'FML_OnInit';
|
||||
const LOOP = 'FML_Loop';
|
||||
const TICK = 'FML_Tick';
|
||||
const ENTRYSUBMIT = 'FML_EntrySubmit';
|
||||
const KEYPRESS = 'FML_KeyPress';
|
||||
const MOUSECLICK = 'FML_MouseClick';
|
||||
const MOUSEOUT = 'FML_MouseOut';
|
||||
const MOUSEOVER = 'FML_MouseOver';
|
||||
|
||||
const KEYPRESS = 'FML_KeyPress';
|
||||
const MOUSECLICK = 'FML_MouseClick';
|
||||
const MOUSEOUT = 'FML_MouseOut';
|
||||
const MOUSEOVER = 'FML_MouseOver';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
@ -32,9 +32,9 @@ class ScriptLabel {
|
||||
/**
|
||||
* Construct a new ScriptLabel
|
||||
*
|
||||
* @param string $name (optional) Label Name
|
||||
* @param string $text (optional) Script Text
|
||||
* @param bool $isolated (optional) Isolate the Label Script
|
||||
* @param string $name (optional) Label Name
|
||||
* @param string $text (optional) Script Text
|
||||
* @param bool $isolated (optional) Isolate the Label Script
|
||||
*/
|
||||
public function __construct($name = self::LOOP, $text = '', $isolated = false) {
|
||||
$this->setName($name);
|
||||
@ -49,7 +49,7 @@ class ScriptLabel {
|
||||
* @return \FML\Script\ScriptLabel
|
||||
*/
|
||||
public function setName($name) {
|
||||
$this->name = (string) $name;
|
||||
$this->name = (string)$name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class ScriptLabel {
|
||||
* @return \FML\Script\ScriptLabel
|
||||
*/
|
||||
public function setText($text) {
|
||||
$this->text = (string) $text;
|
||||
$this->text = (string)$text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ class ScriptLabel {
|
||||
* @return \FML\Script\ScriptLabel
|
||||
*/
|
||||
public function setIsolated($isolated) {
|
||||
$this->isolated = (bool) $isolated;
|
||||
$this->isolated = (bool)$isolated;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
namespace FML\Stylesheet;
|
||||
|
||||
// Warning: The mood class isn't fully supported yet!
|
||||
// Missing attributes: LDir1..
|
||||
// Warning: The mood class isn't fully supported yet!
|
||||
// Missing attributes: LDir1..
|
||||
|
||||
/**
|
||||
* Class representing a Stylesheets Mood
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Mood {
|
||||
/*
|
||||
@ -51,15 +51,15 @@ class Mood {
|
||||
/**
|
||||
* 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 $blue Blue Color Value
|
||||
* @param float $blue Blue Color Value
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setLightAmbientColor($red, $green, $blue) {
|
||||
$red = (float) $red;
|
||||
$green = (float) $green;
|
||||
$blue = (float) $blue;
|
||||
$red = (float)$red;
|
||||
$green = (float)$green;
|
||||
$blue = (float)$blue;
|
||||
$this->lAmbient_LinearRgb = "{$red} {$green} {$blue}";
|
||||
return $this;
|
||||
}
|
||||
@ -67,15 +67,15 @@ class Mood {
|
||||
/**
|
||||
* 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 $blue Blue Color Value
|
||||
* @param float $blue Blue Color Value
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setCloudsColorMin($red, $green, $blue) {
|
||||
$red = (float) $red;
|
||||
$green = (float) $green;
|
||||
$blue = (float) $blue;
|
||||
$red = (float)$red;
|
||||
$green = (float)$green;
|
||||
$blue = (float)$blue;
|
||||
$this->cloudsRgbMinLinear = "{$red} {$green} {$blue}";
|
||||
return $this;
|
||||
}
|
||||
@ -83,15 +83,15 @@ class Mood {
|
||||
/**
|
||||
* 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 $blue Blue Color Value
|
||||
* @param float $blue Blue Color Value
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setCloudsColorMax($red, $green, $blue) {
|
||||
$red = (float) $red;
|
||||
$green = (float) $green;
|
||||
$blue = (float) $blue;
|
||||
$red = (float)$red;
|
||||
$green = (float)$green;
|
||||
$blue = (float)$blue;
|
||||
$this->cloudsRgbMaxLinear = "{$red} {$green} {$blue}";
|
||||
return $this;
|
||||
}
|
||||
@ -99,15 +99,15 @@ class Mood {
|
||||
/**
|
||||
* 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 $blue Blue Color Value
|
||||
* @param float $blue Blue Color Value
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setLight0Color($red, $green, $blue) {
|
||||
$red = (float) $red;
|
||||
$green = (float) $green;
|
||||
$blue = (float) $blue;
|
||||
$red = (float)$red;
|
||||
$green = (float)$green;
|
||||
$blue = (float)$blue;
|
||||
$this->lDir0_LinearRgb = "{$red} {$green} {$blue}";
|
||||
return $this;
|
||||
}
|
||||
@ -119,7 +119,7 @@ class Mood {
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setLight0Intensity($intensity) {
|
||||
$this->lDir0_Intens = (float) $intensity;
|
||||
$this->lDir0_Intens = (float)$intensity;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -130,33 +130,33 @@ class Mood {
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setLight0PhiAngle($phiAngle) {
|
||||
$this->lDir0_DirPhi = (float) $phiAngle;
|
||||
$this->lDir0_DirPhi = (float)$phiAngle;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Theta-Angle of Light Source 0
|
||||
*
|
||||
*
|
||||
* @param float $thetaAngle Theta-Angle
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setLight0ThetaAngle($thetaAngle) {
|
||||
$this->lDir0_DirTheta = (float) $thetaAngle;
|
||||
$this->lDir0_DirTheta = (float)$thetaAngle;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Light Ball Color
|
||||
*
|
||||
* @param float $red Red Color Value
|
||||
* @param float $red Red Color Value
|
||||
* @param float $green Green Color Value
|
||||
* @param float $blue Blue Color Value
|
||||
* @param float $blue Blue Color Value
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setLightBallColor($red, $green, $blue) {
|
||||
$red = (float) $red;
|
||||
$green = (float) $green;
|
||||
$blue = (float) $blue;
|
||||
$red = (float)$red;
|
||||
$green = (float)$green;
|
||||
$blue = (float)$blue;
|
||||
$this->lBall_LinearRgb = "{$red} {$green} {$blue}";
|
||||
return $this;
|
||||
}
|
||||
@ -168,7 +168,7 @@ class Mood {
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setLightBallIntensity($intensity) {
|
||||
$this->lBall_Intensity = (float) $intensity;
|
||||
$this->lBall_Intensity = (float)$intensity;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -179,22 +179,22 @@ class Mood {
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setLightBallRadius($radius) {
|
||||
$this->lBall_Radius = (float) $radius;
|
||||
$this->lBall_Radius = (float)$radius;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fog Color
|
||||
*
|
||||
* @param float $red Red Color Value
|
||||
* @param float $red Red Color Value
|
||||
* @param float $green Green Color Value
|
||||
* @param float $blue Blue Color Value
|
||||
* @param float $blue Blue Color Value
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setFogColor($red, $green, $blue) {
|
||||
$red = (float) $red;
|
||||
$green = (float) $green;
|
||||
$blue = (float) $blue;
|
||||
$red = (float)$red;
|
||||
$green = (float)$green;
|
||||
$blue = (float)$blue;
|
||||
$this->fogColorSrgb = "{$red} {$green} {$blue}";
|
||||
return $this;
|
||||
}
|
||||
@ -202,15 +202,15 @@ class Mood {
|
||||
/**
|
||||
* Set Self Illumination Color
|
||||
*
|
||||
* @param float $red Red Color Value
|
||||
* @param float $red Red Color Value
|
||||
* @param float $green Green Color Value
|
||||
* @param float $blue Blue Color Value
|
||||
* @param float $blue Blue Color Value
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setSelfIllumColor($red, $green, $blue) {
|
||||
$red = (float) $red;
|
||||
$green = (float) $green;
|
||||
$blue = (float) $blue;
|
||||
$red = (float)$red;
|
||||
$green = (float)$green;
|
||||
$blue = (float)$blue;
|
||||
$this->selfIllumColor = "{$red} {$green} {$blue}";
|
||||
return $this;
|
||||
}
|
||||
@ -222,20 +222,20 @@ class Mood {
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function setSkyGradientScale($scale) {
|
||||
$this->skyGradientV_Scale = (float) $scale;
|
||||
$this->skyGradientV_Scale = (float)$scale;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Key for the SkyGradient
|
||||
*
|
||||
* @param float $x Scale Value
|
||||
* @param float $x Scale Value
|
||||
* @param string $color Gradient Color
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function addSkyGradientKey($x, $color) {
|
||||
$x = (float) $x;
|
||||
$color = (string) $color;
|
||||
$x = (float)$x;
|
||||
$color = (string)$color;
|
||||
$gradientKey = array('x' => $x, 'color' => $color);
|
||||
array_push($this->skyGradientKeys, $gradientKey);
|
||||
return $this;
|
||||
|
@ -5,20 +5,20 @@ namespace FML\Stylesheet;
|
||||
/**
|
||||
* Class representing a specific Style3d
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Style3d {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const MODEL_Box = 'Box';
|
||||
const MODEL_Button = 'Button';
|
||||
const MODEL_Box = 'Box';
|
||||
const MODEL_Button = 'Button';
|
||||
const MODEL_ButtonH = 'ButtonH';
|
||||
const MODEL_Title = 'Title';
|
||||
const MODEL_Window = 'Window';
|
||||
|
||||
const MODEL_Title = 'Title';
|
||||
const MODEL_Window = 'Window';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
@ -64,7 +64,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = (string) $id;
|
||||
$this->id = (string)$id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setModel($model) {
|
||||
$this->model = (string) $model;
|
||||
$this->model = (string)$model;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setThickness($thickness) {
|
||||
$this->thickness = (float) $thickness;
|
||||
$this->thickness = (float)$thickness;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setColor($color) {
|
||||
$this->color = (string) $color;
|
||||
$this->color = (string)$color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setFocusColor($focusColor) {
|
||||
$this->focusColor = (string) $focusColor;
|
||||
$this->focusColor = (string)$focusColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setLightColor($lightColor) {
|
||||
$this->lightColor = (string) $lightColor;
|
||||
$this->lightColor = (string)$lightColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setFocusLightColor($focusLightColor) {
|
||||
$this->focusLightColor = (string) $focusLightColor;
|
||||
$this->focusLightColor = (string)$focusLightColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setYOffset($yOffset) {
|
||||
$this->yOffset = (float) $yOffset;
|
||||
$this->yOffset = (float)$yOffset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setFocusYOffset($focusYOffset) {
|
||||
$this->focusYOffset = (float) $focusYOffset;
|
||||
$this->focusYOffset = (float)$focusYOffset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setZOffset($zOffset) {
|
||||
$this->zOffset = (float) $zOffset;
|
||||
$this->zOffset = (float)$zOffset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ class Style3d {
|
||||
* @return \FML\Stylesheet\Style3d
|
||||
*/
|
||||
public function setFocusZOffset($focusZOffset) {
|
||||
$this->focusZOffset = (float) $focusZOffset;
|
||||
$this->focusZOffset = (float)$focusZOffset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@ namespace FML\Stylesheet;
|
||||
/**
|
||||
* Class representing the ManiaLinks Stylesheet
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
class Stylesheet {
|
||||
/*
|
||||
@ -15,6 +15,7 @@ class Stylesheet {
|
||||
*/
|
||||
protected $tagName = 'stylesheet';
|
||||
protected $styles3d = array();
|
||||
/** @var Mood $mood */
|
||||
protected $mood = null;
|
||||
|
||||
/**
|
||||
@ -92,6 +93,7 @@ class Stylesheet {
|
||||
$stylesXml = $domDocument->createElement('frame3dstyles');
|
||||
$stylesheetXml->appendChild($stylesXml);
|
||||
foreach ($this->styles3d as $style3d) {
|
||||
/** @var Style3d $style3d */
|
||||
$style3dXml = $style3d->render($domDocument);
|
||||
$stylesXml->appendChild($style3dXml);
|
||||
}
|
||||
|
@ -2,25 +2,24 @@
|
||||
|
||||
namespace FML\Types;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Elements\Format;
|
||||
|
||||
/**
|
||||
* Interface for Element being able to contain other Controls
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @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
|
||||
*/
|
||||
interface Container {
|
||||
|
||||
/**
|
||||
* Add a new Child Control
|
||||
* Add a new Child Element
|
||||
*
|
||||
* @param Control $child The Child Control to add
|
||||
* @param Renderable $child The Child Control to add
|
||||
* @return \FML\Types\Container
|
||||
*/
|
||||
public function add(Control $child);
|
||||
public function add(Renderable $child);
|
||||
|
||||
/**
|
||||
* Remove all Children
|
||||
@ -39,7 +38,7 @@ interface 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
|
||||
* @return \FML\Elements\Format
|
||||
*/
|
||||
|
@ -3,17 +3,17 @@
|
||||
/**
|
||||
* FancyManiaLinks - Automatic ManiaLink Generator Framework
|
||||
*
|
||||
* @author steeffeen
|
||||
* @version 1.1
|
||||
* @link http://github.com/steeffeen/FancyManiaLinks
|
||||
* @author steeffeen
|
||||
* @version 1.2
|
||||
* @link http://github.com/steeffeen/FancyManiaLinks
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
if (!defined('FML_PATH')) {
|
||||
define('FML_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
if (!defined('FML_VERSION')) {
|
||||
define('FML_VERSION', 1.1);
|
||||
define('FML_VERSION', '1.2');
|
||||
}
|
||||
if (!defined('FML_SIMPLE_CLASSES')) {
|
||||
define('FML_SIMPLE_CLASSES', false);
|
||||
@ -26,29 +26,28 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
|
||||
define('FML_AUTOLOAD_DEFINED', true);
|
||||
spl_autoload_register(function ($className) {
|
||||
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, $className);
|
||||
$filePath = FML_PATH . $classPath . '.php';
|
||||
$filePath = FML_PATH . $classPath . '.php';
|
||||
if (file_exists($filePath)) {
|
||||
// Load with FML namespace
|
||||
require_once $filePath;
|
||||
}
|
||||
else if (FML_SIMPLE_CLASSES) {
|
||||
} else if (FML_SIMPLE_CLASSES) {
|
||||
// Load as simple class name
|
||||
if (!function_exists('loadSimpleClass')) {
|
||||
|
||||
/**
|
||||
* Load FML Class Files from the given Directory
|
||||
*
|
||||
* @param string $className Class to load
|
||||
* @param string $directory Directory to open
|
||||
* @param array $excludes File Names to ignore
|
||||
* @param string $className Class to load
|
||||
* @param string $directory Directory to open
|
||||
* @param array $excludes File Names to ignore
|
||||
* @param string $baseNamespace Base Namespace
|
||||
* @return bool
|
||||
*/
|
||||
function loadSimpleClass($className, $directory, $excludes, $baseNamespace) {
|
||||
if ($dirHandle = opendir($directory)) {
|
||||
$classParts = explode('\\', $className);
|
||||
$classParts = explode('\\', $className);
|
||||
$simpleClassName = end($classParts);
|
||||
$classFileName = $simpleClassName . '.php';
|
||||
$classFileName = $simpleClassName . '.php';
|
||||
while ($fileName = readdir($dirHandle)) {
|
||||
if (in_array($fileName, $excludes)) {
|
||||
continue;
|
||||
@ -56,9 +55,11 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
|
||||
$filePath = $directory . $fileName;
|
||||
if (is_dir($filePath)) {
|
||||
$subDirectory = $filePath . DIRECTORY_SEPARATOR;
|
||||
$namespace = $baseNamespace . $fileName . '\\';
|
||||
$success = loadSimpleClass($className, $subDirectory, $excludes, $namespace);
|
||||
if ($success) return true;
|
||||
$namespace = $baseNamespace . $fileName . '\\';
|
||||
$success = loadSimpleClass($className, $subDirectory, $excludes, $namespace);
|
||||
if ($success) {
|
||||
return true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (is_file($filePath)) {
|
||||
@ -75,7 +76,7 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$excludes = array('.', '..');
|
||||
$excludes = array('.', '..');
|
||||
$baseNamespace = 'FML\\';
|
||||
loadSimpleClass($className, FML_PATH . 'FML' . DIRECTORY_SEPARATOR, $excludes, $baseNamespace);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user