ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
UIInfo.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2\XML\mdui;
4
7
14class UIInfo
15{
23 public $children = array();
24
30 public $DisplayName = array();
31
37 public $Description = array();
38
44 public $InformationURL = array();
45
51 public $PrivacyStatementURL = array();
52
58 public $Keywords = array();
59
65 public $Logo = array();
66
72 public function __construct(\DOMElement $xml = null)
73 {
74 if ($xml === null) {
75 return;
76 }
77
78 $this->DisplayName = Utils::extractLocalizedStrings($xml, Common::NS, 'DisplayName');
79 $this->Description = Utils::extractLocalizedStrings($xml, Common::NS, 'Description');
80 $this->InformationURL = Utils::extractLocalizedStrings($xml, Common::NS, 'InformationURL');
81 $this->PrivacyStatementURL = Utils::extractLocalizedStrings($xml, Common::NS, 'PrivacyStatementURL');
82
83 foreach (Utils::xpQuery($xml, './*') as $node) {
84 if ($node->namespaceURI === Common::NS) {
85 switch ($node->localName) {
86 case 'Keywords':
87 $this->Keywords[] = new Keywords($node);
88 break;
89 case 'Logo':
90 $this->Logo[] = new Logo($node);
91 break;
92 }
93 } else {
94 $this->children[] = new Chunk($node);
95 }
96 }
97 }
98
105 public function toXML(\DOMElement $parent)
106 {
107 assert(is_array($this->DisplayName));
108 assert(is_array($this->InformationURL));
109 assert(is_array($this->PrivacyStatementURL));
110 assert(is_array($this->Keywords));
111 assert(is_array($this->Logo));
112 assert(is_array($this->children));
113
114 $e = null;
115 if (!empty($this->DisplayName)
116 || !empty($this->Description)
117 || !empty($this->InformationURL)
118 || !empty($this->PrivacyStatementURL)
119 || !empty($this->Keywords)
120 || !empty($this->Logo)
121 || !empty($this->children)) {
122 $doc = $parent->ownerDocument;
123
124 $e = $doc->createElementNS(Common::NS, 'mdui:UIInfo');
125 $parent->appendChild($e);
126
127 Utils::addStrings($e, Common::NS, 'mdui:DisplayName', true, $this->DisplayName);
128 Utils::addStrings($e, Common::NS, 'mdui:Description', true, $this->Description);
129 Utils::addStrings($e, Common::NS, 'mdui:InformationURL', true, $this->InformationURL);
130 Utils::addStrings($e, Common::NS, 'mdui:PrivacyStatementURL', true, $this->PrivacyStatementURL);
131
132 if (!empty($this->Keywords)) {
133 foreach ($this->Keywords as $child) {
134 $child->toXML($e);
135 }
136 }
137
138 if (!empty($this->Logo)) {
139 foreach ($this->Logo as $child) {
140 $child->toXML($e);
141 }
142 }
143
144 if (!empty($this->children)) {
145 foreach ($this->children as $child) {
146 $child->toXML($e);
147 }
148 }
149 }
150
151 return $e;
152 }
153}
An exception for terminatinating execution or to throw for unit testing.
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
Definition: Utils.php:191
static addStrings(\DOMElement $parent, $namespace, $name, $localized, array $values)
Append string elements.
Definition: Utils.php:659
static extractLocalizedStrings(\DOMElement $parent, $namespaceURI, $localName)
Extract localized strings from a set of nodes.
Definition: Utils.php:580
toXML(\DOMElement $parent)
Convert this UIInfo to XML.
Definition: UIInfo.php:105
__construct(\DOMElement $xml=null)
Create a UIInfo element.
Definition: UIInfo.php:72
$xml
Definition: metadata.php:240