1: <?php
2: /**
3: * ManiaLive - TrackMania dedicated server manager in PHP
4: *
5: * @copyright Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
6: * @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
7: * @version $Revision: 454 $:
8: * @author $Author: martin.gwendal $:
9: * @date $Date: 2012-09-28 16:56:12 +0200 (ven., 28 sept. 2012) $:
10: */
11:
12: namespace ManiaLive\Gui\Elements;
13:
14: use ManiaLib\Gui\Manialink;
15:
16: /**
17: * Can be used to add already parsed xml to
18: * a manialink window.
19: *
20: * @author Florian Schnell
21: */
22: class Xml extends \ManiaLive\Gui\Element
23: {
24: protected $xml;
25:
26: function __construct($xml = '')
27: {
28: $this->xml = $xml;
29: }
30:
31: function setContent($xml)
32: {
33: $this->xml = $xml;
34: }
35:
36: function save()
37: {
38: try
39: {
40: $doc = new \DOMDocument();
41: $doc->loadXML($this->xml);
42: $node = Manialink::$domDocument->importNode($doc->firstChild, true);
43: end(Manialink::$parentNodes)->appendChild($node);
44: }
45: catch (\Exception $e)
46: {
47: $doc = new \DOMDocument();
48: $doc->loadXML('<content>' . $this->xml . '</content>');
49: foreach ($doc->firstChild->childNodes as $child)
50: {
51: $node = Manialink::$domDocument->importNode($child, true);
52: end(Manialink::$parentNodes)->appendChild($node);
53: }
54: }
55: }
56: }
57:
58: ?>