2014-01-19 19:30:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\Stylesheet;
|
|
|
|
|
2014-06-21 03:18:21 +02:00
|
|
|
use FML\UniqueID;
|
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Class representing a Style3d
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-05-20 15:44:45 +02:00
|
|
|
* @author steeffeen <mail@steeffeen.com>
|
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
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
class Style3d {
|
2014-01-21 20:30:40 +01:00
|
|
|
/*
|
2014-01-19 19:30:21 +01:00
|
|
|
* Constants
|
|
|
|
*/
|
2014-05-14 23:24:00 +02:00
|
|
|
const MODEL_Box = 'Box';
|
|
|
|
const MODEL_Button = 'Button';
|
2014-01-19 19:30:21 +01:00
|
|
|
const MODEL_ButtonH = 'ButtonH';
|
2014-05-14 23:24:00 +02:00
|
|
|
const MODEL_Title = 'Title';
|
|
|
|
const MODEL_Window = 'Window';
|
|
|
|
|
2014-01-21 20:30:40 +01:00
|
|
|
/*
|
2014-06-21 03:18:21 +02:00
|
|
|
* Protected properties
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
protected $tagName = 'style3d';
|
2014-06-21 03:18:21 +02:00
|
|
|
protected $styleId = null;
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $model = self::MODEL_Box;
|
|
|
|
protected $thickness = null;
|
2014-04-27 14:44:40 +02:00
|
|
|
protected $color = null;
|
|
|
|
protected $focusColor = null;
|
|
|
|
protected $lightColor = null;
|
|
|
|
protected $focusLightColor = null;
|
|
|
|
protected $yOffset = null;
|
|
|
|
protected $focusYOffset = null;
|
|
|
|
protected $zOffset = null;
|
|
|
|
protected $focusZOffset = null;
|
2014-01-19 19:30:21 +01:00
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Create a new Style3d object
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $styleId (optional) Style id
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
2014-06-21 03:18:21 +02:00
|
|
|
public static function create($styleId = null) {
|
|
|
|
return new static($styleId);
|
2014-01-19 19:30:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Construct a new Style3d object
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $styleId (optional) Style id
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
2014-06-21 03:18:21 +02:00
|
|
|
public function __construct($styleId = null) {
|
|
|
|
if (!is_null($styleId)) {
|
|
|
|
$this->setId($styleId);
|
2014-01-19 19:30:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set style id
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $styleId Style id
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
2014-06-21 03:18:21 +02:00
|
|
|
public function setId($styleId) {
|
|
|
|
$this->styleId = (string)$styleId;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Check for id and assign one if necessary
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function checkId() {
|
2014-06-21 03:18:21 +02:00
|
|
|
if (!$this->styleId) {
|
|
|
|
$this->setId(new UniqueID());
|
2014-01-19 19:30:21 +01:00
|
|
|
}
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Get style id
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getId() {
|
2014-06-21 03:18:21 +02:00
|
|
|
return $this->styleId;
|
2014-01-19 19:30:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set model
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $model Style model
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function setModel($model) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->model = (string)$model;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set thickness
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param float $thickness Style thickness
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function setThickness($thickness) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->thickness = (float)$thickness;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set color
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $color Style color
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function setColor($color) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->color = (string)$color;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set focus color
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $focusColor Style focus color
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function setFocusColor($focusColor) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->focusColor = (string)$focusColor;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set light color
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $lightColor Light color
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function setLightColor($lightColor) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->lightColor = (string)$lightColor;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set focus light color
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $focusLightColor Focus light color
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function setFocusLightColor($focusLightColor) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->focusLightColor = (string)$focusLightColor;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set Y-offset
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param float $yOffset Y-offset
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function setYOffset($yOffset) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->yOffset = (float)$yOffset;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set focus Y-offset
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param float $focusYOffset Focus Y-offset
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function setFocusYOffset($focusYOffset) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->focusYOffset = (float)$focusYOffset;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set Z-offset
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param float $zOffset Z-offset
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function setZOffset($zOffset) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->zOffset = (float)$zOffset;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set focus Z-offset
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param float $focusZOffset Focus Z-offset
|
|
|
|
* @return \FML\Stylesheet\Style3d|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function setFocusZOffset($focusZOffset) {
|
2014-05-14 23:24:00 +02:00
|
|
|
$this->focusZOffset = (float)$focusZOffset;
|
2014-01-19 19:30:21 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Render the Style3d XML element
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param \DOMDocument $domDocument DOMDocument for which the Style3d XML element should be rendered
|
2014-01-19 19:30:21 +01:00
|
|
|
* @return \DOMElement
|
|
|
|
*/
|
|
|
|
public function render(\DOMDocument $domDocument) {
|
|
|
|
$style3dXml = $domDocument->createElement($this->tagName);
|
|
|
|
$this->checkId();
|
2014-06-21 03:18:21 +02:00
|
|
|
if ($this->styleId) {
|
|
|
|
$style3dXml->setAttribute('id', $this->styleId);
|
2014-01-19 19:30:21 +01:00
|
|
|
}
|
|
|
|
if ($this->model) {
|
|
|
|
$style3dXml->setAttribute('model', $this->model);
|
|
|
|
}
|
|
|
|
if ($this->thickness) {
|
|
|
|
$style3dXml->setAttribute('thickness', $this->thickness);
|
|
|
|
}
|
|
|
|
if ($this->color) {
|
|
|
|
$style3dXml->setAttribute('color', $this->color);
|
|
|
|
}
|
|
|
|
if ($this->focusColor) {
|
|
|
|
$style3dXml->setAttribute('fcolor', $this->focusColor);
|
|
|
|
}
|
|
|
|
if ($this->lightColor) {
|
|
|
|
$style3dXml->setAttribute('lightcolor', $this->lightColor);
|
|
|
|
}
|
|
|
|
if ($this->focusLightColor) {
|
|
|
|
$style3dXml->setAttribute('flightcolor', $this->focusLightColor);
|
|
|
|
}
|
|
|
|
if ($this->yOffset) {
|
|
|
|
$style3dXml->setAttribute('yoffset', $this->yOffset);
|
|
|
|
}
|
|
|
|
if ($this->focusYOffset) {
|
|
|
|
$style3dXml->setAttribute('fyoffset', $this->focusYOffset);
|
|
|
|
}
|
|
|
|
if ($this->zOffset) {
|
|
|
|
$style3dXml->setAttribute('zoffset', $this->zOffset);
|
|
|
|
}
|
|
|
|
if ($this->focusZOffset) {
|
|
|
|
$style3dXml->setAttribute('fzoffset', $this->focusZOffset);
|
|
|
|
}
|
|
|
|
return $style3dXml;
|
|
|
|
}
|
|
|
|
}
|