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 }
Objects implementing XmlSerializable can control how they are represented in Xml. ...
xmlSerialize(Writer $writer)
The xmlSerialize method is called during xml writing.
serializePriv(Writer $writer, $privName, $privilege)
Serializes a property.
startElement($name)
Opens a new element.
Definition: Writer.php:121
WebDAV properties that implement this interface are able to generate their own html output for the br...
Definition: HtmlOutput.php:16
xmlName($element)
This method takes an xml element in clark-notation, and turns it into a shortened version with a pref...
toHtml(HtmlOutputHelper $html)
Generate html representation for this value.
h($input)
Escape string for HTML output.
$html
Definition: example_001.php:87
writeElement($name, $content=null)
Write a full element tag and it&#39;s contents.
Definition: Writer.php:189
The XML Writer class.
Definition: Writer.php:31
This class provides a few utility functions for easily generating HTML for the browser plugin...