2014-01-12 00:51:46 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\ManiaCode;
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* ManiaCode Element installing a title pack
|
2014-01-12 00:51:46 +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
|
2014-01-12 00:51:46 +01:00
|
|
|
*/
|
2014-07-03 22:34:47 +02:00
|
|
|
class InstallPack extends Element {
|
2014-01-21 20:30:40 +01:00
|
|
|
/*
|
2014-06-21 03:18:21 +02:00
|
|
|
* Protected properties
|
2014-01-12 00:51:46 +01:00
|
|
|
*/
|
|
|
|
protected $tagName = 'install_pack';
|
2014-06-21 03:18:21 +02:00
|
|
|
protected $name = null;
|
|
|
|
protected $file = null;
|
|
|
|
protected $url = null;
|
2014-01-12 00:51:46 +01:00
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Create a new InstallPack object
|
2014-01-19 19:30:21 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $name (optional) Pack name
|
|
|
|
* @param string $file (optional) Pack file
|
|
|
|
* @param string $url (optional) Pack url
|
2014-07-03 22:34:47 +02:00
|
|
|
* @return static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
|
|
|
public static function create($name = null, $file = null, $url = null) {
|
2014-06-21 03:18:21 +02:00
|
|
|
return new static($name, $file, $url);
|
2014-01-19 19:30:21 +01:00
|
|
|
}
|
|
|
|
|
2014-01-12 00:51:46 +01:00
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Construct a new InstallPack object
|
2014-01-12 00:51:46 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $name (optional) Pack name
|
|
|
|
* @param string $file (optional) Pack file
|
|
|
|
* @param string $url (optional) Pack url
|
2014-01-12 00:51:46 +01:00
|
|
|
*/
|
|
|
|
public function __construct($name = null, $file = null, $url = null) {
|
2014-06-21 03:18:21 +02:00
|
|
|
if (!is_null($name)) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->setName($name);
|
|
|
|
}
|
2014-06-21 03:18:21 +02:00
|
|
|
if (!is_null($file)) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->setFile($file);
|
|
|
|
}
|
2014-06-21 03:18:21 +02:00
|
|
|
if (!is_null($url)) {
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->setUrl($url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set the name of the pack
|
2014-01-12 00:51:46 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $name Pack name
|
2014-07-03 22:34:47 +02:00
|
|
|
* @return static
|
2014-01-19 19:30:21 +01:00
|
|
|
*/
|
2014-01-12 00:51:46 +01:00
|
|
|
public function setName($name) {
|
2014-05-18 19:45:50 +02:00
|
|
|
$this->name = (string)$name;
|
2014-01-12 00:51:46 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set the file of the pack
|
2014-01-12 00:51:46 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $file Pack file
|
2014-07-03 22:34:47 +02:00
|
|
|
* @return static
|
2014-01-12 00:51:46 +01:00
|
|
|
*/
|
|
|
|
public function setFile($file) {
|
2014-05-18 19:45:50 +02:00
|
|
|
$this->file = (string)$file;
|
2014-01-12 00:51:46 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Set the url of the pack
|
2014-01-12 00:51:46 +01:00
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param string $url Pack url
|
2014-07-03 22:34:47 +02:00
|
|
|
* @return static
|
2014-01-12 00:51:46 +01:00
|
|
|
*/
|
|
|
|
public function setUrl($url) {
|
2014-05-18 19:45:50 +02:00
|
|
|
$this->url = (string)$url;
|
2014-01-12 00:51:46 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \FML\ManiaCode\Element::render()
|
|
|
|
*/
|
|
|
|
public function render(\DOMDocument $domDocument) {
|
2014-07-03 22:34:47 +02:00
|
|
|
$xmlElement = parent::render($domDocument);
|
2014-01-12 00:51:46 +01:00
|
|
|
$nameElement = $domDocument->createElement('name', $this->name);
|
|
|
|
$xmlElement->appendChild($nameElement);
|
|
|
|
$fileElement = $domDocument->createElement('file', $this->file);
|
|
|
|
$xmlElement->appendChild($fileElement);
|
|
|
|
$urlElement = $domDocument->createElement('url', $this->url);
|
|
|
|
$xmlElement->appendChild($urlElement);
|
|
|
|
return $xmlElement;
|
|
|
|
}
|
|
|
|
}
|