TrackManiaControl/application/core/Libs/FML/Controls/Quad.php

303 lines
6.3 KiB
PHP
Raw Normal View History

<?php
namespace FML\Controls;
use FML\Types\Actionable;
use FML\Types\BgColorable;
use FML\Types\Linkable;
use FML\Types\Scriptable;
use FML\Types\Styleable;
use FML\Types\SubStyleable;
/**
2014-01-19 19:30:21 +01:00
* Quad Control
2014-01-12 00:51:46 +01:00
* (CMlQuad)
*
* @author steeffeen
2014-04-13 18:21:40 +02:00
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Quad extends Control implements Actionable, BgColorable, Linkable, Scriptable, Styleable, SubStyleable {
2014-01-21 20:30:40 +01:00
/*
2013-12-31 02:55:19 +01:00
* Protected Properties
*/
protected $image = '';
2014-01-19 19:30:21 +01:00
protected $imageId = '';
protected $imageFocus = '';
2014-01-19 19:30:21 +01:00
protected $imageFocusId = '';
protected $colorize = '';
protected $modulizeColor = '';
2014-01-12 00:51:46 +01:00
protected $autoScale = 1;
protected $action = '';
2014-01-12 00:51:46 +01:00
protected $actionKey = -1;
protected $bgColor = '';
protected $url = '';
2014-01-19 19:30:21 +01:00
protected $urlId = '';
protected $manialink = '';
2014-01-19 19:30:21 +01:00
protected $manialinkId = '';
protected $scriptEvents = 0;
protected $style = '';
protected $subStyle = '';
2014-01-19 19:30:21 +01:00
/**
* Create a new Quad Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Quad
*/
public static function create($id = null) {
$quad = new Quad($id);
return $quad;
}
/**
2013-12-31 02:55:19 +01:00
* Construct a new Quad Control
*
2014-01-12 00:51:46 +01:00
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'quad';
$this->setZ(-1);
}
/**
2013-12-31 02:55:19 +01:00
* Set Image Url
*
2014-01-12 00:51:46 +01:00
* @param string $image Image Url
* @return \FML\Controls\Quad
*/
public function setImage($image) {
2014-01-12 00:51:46 +01:00
$this->image = (string) $image;
return $this;
}
2014-01-19 19:30:21 +01:00
/**
* Set Image Id to use from the Dico
*
* @param string $imageId Image Id
* @return \FML\Controls\Quad
*/
public function setImageId($imageId) {
$this->imageId = (string) $imageId;
return $this;
}
/**
2013-12-31 02:55:19 +01:00
* Set Focus Image Url
*
2014-01-12 00:51:46 +01:00
* @param string $imageFocus Focus Image Url
* @return \FML\Controls\Quad
*/
public function setImageFocus($imageFocus) {
2014-01-12 00:51:46 +01:00
$this->imageFocus = (string) $imageFocus;
return $this;
}
2014-01-19 19:30:21 +01:00
/**
* Set Focus Image Id to use from the Dico
*
* @param string $imageFocusId Focus Image Id
* @return \FML\Controls\Quad
*/
public function setImageFocusId($imageFocusId) {
$this->imageFocusId = (string) $imageFocusId;
return $this;
}
/**
2013-12-31 02:55:19 +01:00
* Set Colorization
*
2014-01-12 00:51:46 +01:00
* @param string $colorize Colorize Value
* @return \FML\Controls\Quad
*/
public function setColorize($colorize) {
2014-01-12 00:51:46 +01:00
$this->colorize = (string) $colorize;
return $this;
}
/**
2013-12-31 02:55:19 +01:00
* Set Modulization
*
2014-01-12 00:51:46 +01:00
* @param string $modulizeColor Modulize Value
* @return \FML\Controls\Quad
*/
public function setModulizeColor($modulizeColor) {
2014-01-12 00:51:46 +01:00
$this->modulizeColor = (string) $modulizeColor;
return $this;
}
/**
* Disable the automatic Image Scaling
*
* @param bool $autoScale Whether the Image should scale automatically
* @return \FML\Controls\Quad
*/
public function setAutoScale($autoScale) {
$this->autoScale = ($autoScale ? 1 : 0);
return $this;
}
/**
*
* @see \FML\Types\Actionable::setAction()
*/
public function setAction($action) {
2014-01-12 00:51:46 +01:00
$this->action = (string) $action;
return $this;
}
2014-01-21 20:30:40 +01:00
/**
*
* @see \FML\Types\Actionable::getAction()
*/
public function getAction() {
return $this->action;
}
2014-01-12 00:51:46 +01:00
/**
*
* @see \FML\Types\Actionable::setActionKey()
*/
public function setActionKey($actionKey) {
$this->actionKey = (int) $actionKey;
return $this;
}
/**
*
* @see \FML\Types\BgColorable::setBgColor()
*/
public function setBgColor($bgColor) {
2014-01-12 00:51:46 +01:00
$this->bgColor = (string) $bgColor;
return $this;
}
/**
*
* @see \FML\Types\Linkable::setUrl()
*/
public function setUrl($url) {
2014-01-12 00:51:46 +01:00
$this->url = (string) $url;
return $this;
}
2014-01-19 19:30:21 +01:00
/**
*
* @see \FML\Types\Linkable::setUrlId()
*/
public function setUrlId($urlId) {
$this->urlId = (string) $urlId;
return $this;
}
/**
*
* @see \FML\Types\Linkable::setManialink()
*/
public function setManialink($manialink) {
2014-01-12 00:51:46 +01:00
$this->manialink = (string) $manialink;
return $this;
}
2014-01-19 19:30:21 +01:00
/**
*
* @see \FML\Types\Linkable::setManialinkId()
*/
public function setManialinkId($manialinkId) {
$this->manialinkId = (string) $manialinkId;
return $this;
}
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
return $this;
}
/**
*
* @see \FML\Types\Styleable::setStyle()
*/
public function setStyle($style) {
2014-01-12 00:51:46 +01:00
$this->style = (string) $style;
return $this;
}
/**
*
* @see \FML\Types\SubStyleable::setSubStyle()
*/
public function setSubStyle($subStyle) {
2014-01-12 00:51:46 +01:00
$this->subStyle = (string) $subStyle;
return $this;
}
/**
*
* @see \FML\Types\SubStyleable::setStyles()
*/
public function setStyles($style, $subStyle) {
$this->setStyle($style);
$this->setSubStyle($subStyle);
return $this;
}
/**
*
* @see \FML\Control::render()
*/
public function render(\DOMDocument $domDocument) {
2014-01-12 00:51:46 +01:00
$xmlElement = parent::render($domDocument);
if ($this->image) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('image', $this->image);
}
2014-01-19 19:30:21 +01:00
if ($this->imageId) {
$xmlElement->setAttribute('imageid', $this->imageId);
}
if ($this->imageFocus) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('imagefocus', $this->imageFocus);
}
2014-01-19 19:30:21 +01:00
if ($this->imageFocusId) {
$xmlElement->setAttribute('imagefocusid', $this->imageFocusId);
}
if ($this->colorize) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('colorize', $this->colorize);
}
if ($this->modulizeColor) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('modulizecolor', $this->modulizeColor);
}
if (!$this->autoScale) {
$xmlElement->setAttribute('autoscale', $this->autoScale);
}
2014-01-21 20:30:40 +01:00
if (strlen($this->action) > 0) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('action', $this->action);
}
if ($this->actionKey >= 0) {
$xmlElement->setAttribute('actionkey', $this->actionKey);
}
if ($this->bgColor) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('bgcolor', $this->bgColor);
}
if ($this->url) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('url', $this->url);
}
if ($this->manialink) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('manialink', $this->manialink);
}
if ($this->scriptEvents) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
}
if ($this->style) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('style', $this->style);
}
if ($this->subStyle) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('substyle', $this->subStyle);
}
2014-01-12 00:51:46 +01:00
return $xmlElement;
}
}