ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SupportedPrivilegeSet.php
Go to the documentation of this file.
1<?php
2
4
9
25
31 protected $privileges;
32
38 function __construct(array $privileges) {
39
40 $this->privileges = $privileges;
41
42 }
43
49 function getValue() {
50
51 return $this->privileges;
52
53 }
54
74 function xmlSerialize(Writer $writer) {
75
76 $this->serializePriv($writer, '{DAV:}all', ['aggregates' => $this->privileges]);
77
78 }
79
95
96 $traverse = function($privName, $priv) use (&$traverse, $html) {
97 echo "<li>";
98 echo $html->xmlName($privName);
99 if (isset($priv['abstract']) && $priv['abstract']) {
100 echo " <i>(abstract)</i>";
101 }
102 if (isset($priv['description'])) {
103 echo " " . $html->h($priv['description']);
104 }
105 if (isset($priv['aggregates'])) {
106 echo "\n<ul>\n";
107 foreach ($priv['aggregates'] as $subPrivName => $subPriv) {
108 $traverse($subPrivName, $subPriv);
109 }
110 echo "</ul>";
111 }
112 echo "</li>\n";
113 };
114
115 ob_start();
116 echo "<ul class=\"tree\">";
117 $traverse('{DAV:}all', ['aggregates' => $this->getValue()]);
118 echo "</ul>\n";
119
120 return ob_get_clean();
121
122 }
123
124
125
136 private function serializePriv(Writer $writer, $privName, $privilege) {
137
138 $writer->startElement('{DAV:}supported-privilege');
139
140 $writer->startElement('{DAV:}privilege');
141 $writer->writeElement($privName);
142 $writer->endElement(); // privilege
143
144 if (!empty($privilege['abstract'])) {
145 $writer->writeElement('{DAV:}abstract');
146 }
147 if (!empty($privilege['description'])) {
148 $writer->writeElement('{DAV:}description', $privilege['description']);
149 }
150 if (isset($privilege['aggregates'])) {
151 foreach ($privilege['aggregates'] as $subPrivName => $subPrivilege) {
152 $this->serializePriv($writer, $subPrivName, $subPrivilege);
153 }
154 }
155
156 $writer->endElement(); // supported-privilege
157
158 }
159
160}
An exception for terminatinating execution or to throw for unit testing.
serializePriv(Writer $writer, $privName, $privilege)
Serializes a property.
xmlSerialize(Writer $writer)
The xmlSerialize method is called during xml writing.
toHtml(HtmlOutputHelper $html)
Generate html representation for this value.
This class provides a few utility functions for easily generating HTML for the browser plugin.
The XML Writer class.
Definition: Writer.php:31
writeElement($name, $content=null)
Write a full element tag and it's contents.
Definition: Writer.php:189
startElement($name)
Opens a new element.
Definition: Writer.php:121
$html
Definition: example_001.php:87
WebDAV properties that implement this interface are able to generate their own html output for the br...
Definition: HtmlOutput.php:16
Objects implementing XmlSerializable can control how they are represented in Xml.