2013-11-25 00:02:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\Controls;
|
|
|
|
|
2014-05-14 23:24:00 +02:00
|
|
|
use FML\Models\CheckBoxDesign;
|
2013-11-28 02:04:06 +01:00
|
|
|
use FML\Types\Actionable;
|
2013-11-25 00:02:07 +01:00
|
|
|
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)
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-05-14 23:24:00 +02:00
|
|
|
* @author steeffeen
|
2014-04-13 18:21:40 +02:00
|
|
|
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
2014-05-14 23:24:00 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
2013-11-28 02:04:06 +01:00
|
|
|
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
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
protected $image = '';
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $imageId = '';
|
2013-11-25 00:02:07 +01:00
|
|
|
protected $imageFocus = '';
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $imageFocusId = '';
|
2013-11-25 00:02:07 +01:00
|
|
|
protected $colorize = '';
|
|
|
|
protected $modulizeColor = '';
|
2014-01-12 00:51:46 +01:00
|
|
|
protected $autoScale = 1;
|
2013-11-28 02:04:06 +01:00
|
|
|
protected $action = '';
|
2014-01-12 00:51:46 +01:00
|
|
|
protected $actionKey = -1;
|
2013-11-25 00:02:07 +01:00
|
|
|
protected $bgColor = '';
|
|
|
|
protected $url = '';
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $urlId = '';
|
2013-11-25 00:02:07 +01:00
|
|
|
protected $manialink = '';
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $manialinkId = '';
|
2013-11-25 00:02:07 +01:00
|
|
|
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-11-25 00:02:07 +01:00
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Construct a new Quad Control
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $id (optional) Control Id
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
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
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $image Image Url
|
2013-11-25 00:02:07 +01:00
|
|
|
* @return \FML\Controls\Quad
|
|
|
|
*/
|
|
|
|
public function setImage($image) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->image = (string)$image;
|
2013-11-25 00:02:07 +01:00
|
|
|
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) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->imageId = (string)$imageId;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Focus Image Url
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $imageFocus Focus Image Url
|
2013-11-25 00:02:07 +01:00
|
|
|
* @return \FML\Controls\Quad
|
|
|
|
*/
|
|
|
|
public function setImageFocus($imageFocus) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->imageFocus = (string)$imageFocus;
|
2013-11-25 00:02:07 +01:00
|
|
|
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) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->imageFocusId = (string)$imageFocusId;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Colorization
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $colorize Colorize Value
|
2013-11-25 00:02:07 +01:00
|
|
|
* @return \FML\Controls\Quad
|
|
|
|
*/
|
|
|
|
public function setColorize($colorize) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->colorize = (string)$colorize;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Modulization
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $modulizeColor Modulize Value
|
2013-11-25 00:02:07 +01:00
|
|
|
* @return \FML\Controls\Quad
|
|
|
|
*/
|
|
|
|
public function setModulizeColor($modulizeColor) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->modulizeColor = (string)$modulizeColor;
|
2014-01-12 00:51:46 +01:00
|
|
|
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);
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-28 02:04:06 +01:00
|
|
|
/**
|
|
|
|
* @see \FML\Types\Actionable::setAction()
|
|
|
|
*/
|
|
|
|
public function setAction($action) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->action = (string)$action;
|
2014-01-12 00:51:46 +01:00
|
|
|
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) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->actionKey = (int)$actionKey;
|
2013-11-28 02:04:06 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
|
|
|
* @see \FML\Types\BgColorable::setBgColor()
|
|
|
|
*/
|
|
|
|
public function setBgColor($bgColor) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->bgColor = (string)$bgColor;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \FML\Types\Linkable::setUrl()
|
|
|
|
*/
|
|
|
|
public function setUrl($url) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->url = (string)$url;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
|
|
|
* @see \FML\Types\Linkable::setUrlId()
|
|
|
|
*/
|
|
|
|
public function setUrlId($urlId) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->urlId = (string)$urlId;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
|
|
|
* @see \FML\Types\Linkable::setManialink()
|
|
|
|
*/
|
|
|
|
public function setManialink($manialink) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->manialink = (string)$manialink;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
|
|
|
* @see \FML\Types\Linkable::setManialinkId()
|
|
|
|
*/
|
|
|
|
public function setManialinkId($manialinkId) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->manialinkId = (string)$manialinkId;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
|
|
|
* @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-05-14 23:24:00 +02:00
|
|
|
$this->style = (string)$style;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \FML\Types\SubStyleable::setSubStyle()
|
|
|
|
*/
|
|
|
|
public function setSubStyle($subStyle) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->subStyle = (string)$subStyle;
|
2013-11-25 00:02:07 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \FML\Types\SubStyleable::setStyles()
|
|
|
|
*/
|
|
|
|
public function setStyles($style, $subStyle) {
|
|
|
|
$this->setStyle($style);
|
|
|
|
$this->setSubStyle($subStyle);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-14 23:24:00 +02:00
|
|
|
* Apply the given CheckBox Design
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-05-14 23:24:00 +02:00
|
|
|
* @param CheckBoxDesign $checkBoxDesign CheckBox Design
|
|
|
|
* @return \FML\Controls\Quad
|
|
|
|
*/
|
|
|
|
public function applyCheckBoxDesign(CheckBoxDesign $checkBoxDesign) {
|
|
|
|
$checkBoxDesign->applyToQuad($this);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-11-25 00:02:07 +01:00
|
|
|
* @see \FML\Control::render()
|
|
|
|
*/
|
|
|
|
public function render(\DOMDocument $domDocument) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement = parent::render($domDocument);
|
2013-11-25 00:02:07 +01:00
|
|
|
if ($this->image) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('image', $this->image);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
2014-01-19 19:30:21 +01:00
|
|
|
if ($this->imageId) {
|
|
|
|
$xmlElement->setAttribute('imageid', $this->imageId);
|
|
|
|
}
|
2013-11-25 00:02:07 +01:00
|
|
|
if ($this->imageFocus) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('imagefocus', $this->imageFocus);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
2014-01-19 19:30:21 +01:00
|
|
|
if ($this->imageFocusId) {
|
|
|
|
$xmlElement->setAttribute('imagefocusid', $this->imageFocusId);
|
|
|
|
}
|
2013-11-25 00:02:07 +01:00
|
|
|
if ($this->colorize) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('colorize', $this->colorize);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->modulizeColor) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('modulizecolor', $this->modulizeColor);
|
|
|
|
}
|
|
|
|
if (!$this->autoScale) {
|
|
|
|
$xmlElement->setAttribute('autoscale', $this->autoScale);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
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);
|
2013-11-28 02:04:06 +01:00
|
|
|
}
|
2013-11-25 00:02:07 +01:00
|
|
|
if ($this->bgColor) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('bgcolor', $this->bgColor);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->url) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('url', $this->url);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->manialink) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('manialink', $this->manialink);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->scriptEvents) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->style) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('style', $this->style);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
if ($this->subStyle) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('substyle', $this->subStyle);
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
2014-01-12 00:51:46 +01:00
|
|
|
return $xmlElement;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
}
|