/** * Generate html representation for this value. * * The html output is 100% trusted, and no effort is being made to sanitize * it. It's up to the implementor to sanitize user provided values. * * The output must be in UTF-8. * * The baseUri parameter is a url to the root of the application, and can * be used to construct local links. * * @param HtmlOutputHelper $html * @return string */ function toHtml(HtmlOutputHelper $html) { $traverse = function ($privName, $priv) use(&$traverse, $html) { echo "<li>"; echo $html->xmlName($privName); if (isset($priv['abstract']) && $priv['abstract']) { echo " <i>(abstract)</i>"; } if (isset($priv['description'])) { echo " " . $html->h($priv['description']); } if (isset($priv['aggregates'])) { echo "\n<ul>\n"; foreach ($priv['aggregates'] as $subPrivName => $subPriv) { $traverse($subPrivName, $subPriv); } echo "</ul>"; } echo "</li>\n"; }; ob_start(); echo "<ul class=\"tree\">"; $traverse('{DAV:}all', ['aggregates' => $this->getValue()]); echo "</ul>\n"; return ob_get_clean(); }
/** * Draws a table row for a property * * @param HtmlOutputHelper $html * @param mixed $value * @return string */ private function drawPropertyValue($html, $value) { if (is_scalar($value)) { return $html->h($value); } elseif ($value instanceof HtmlOutput) { return $value->toHtml($html); } elseif ($value instanceof \Sabre\Xml\XmlSerializable) { // There's no default html output for this property, we're going // to output the actual xml serialization instead. $xml = $this->server->xml->write('{DAV:}root', $value, $this->server->getBaseUri()); // removing first and last line, as they contain our root // element. $xml = explode("\n", $xml); $xml = array_slice($xml, 2, -2); return "<pre>" . $html->h(implode("\n", $xml)) . "</pre>"; } else { return "<em>unknown</em>"; } }