2013-11-25 00:02:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\Elements;
|
|
|
|
|
2014-01-12 00:51:46 +01:00
|
|
|
use FML\Types\Renderable;
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
2014-01-12 00:51:46 +01:00
|
|
|
* Include Element
|
2013-11-25 00:02:07 +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-18 19:45:50 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
class Including implements Renderable {
|
2014-01-21 20:30:40 +01:00
|
|
|
/*
|
2014-06-21 03:18:21 +02:00
|
|
|
* Protected properties
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
protected $tagName = 'include';
|
2014-06-21 03:18:21 +02:00
|
|
|
protected $url = null;
|
2013-11-25 00:02:07 +01:00
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Create a new Include object
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $url (optional) Include url
|
|
|
|
* @return \FML\Elements\Including|static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public static function create($url = null) {
|
2014-06-21 03:18:21 +02:00
|
|
|
return new static($url);
|
2014-01-19 19:30:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Construct a new Include object
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $url (optional) Include url
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public function __construct($url = null) {
|
2014-06-21 03:18:21 +02:00
|
|
|
if (!is_null($url)) {
|
2014-01-19 19:30:21 +01:00
|
|
|
$this->setUrl($url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set url
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $url Include url
|
|
|
|
* @return \FML\Elements\Including|static
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function setUrl($url) {
|
2014-05-18 19:45:50 +02:00
|
|
|
$this->url = (string)$url;
|
2014-06-21 03:18:21 +02:00
|
|
|
return $this;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \FML\Renderable::render()
|
|
|
|
*/
|
|
|
|
public function render(\DOMDocument $domDocument) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement = $domDocument->createElement($this->tagName);
|
2013-12-31 02:55:19 +01:00
|
|
|
if ($this->url) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$xmlElement->setAttribute('url', $this->url);
|
2013-12-31 02:55:19 +01:00
|
|
|
}
|
2014-01-12 00:51:46 +01:00
|
|
|
return $xmlElement;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
}
|