/**
  * 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();
 }
Example #2
0
 /**
  * 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)
 {
     $links = [];
     foreach ($this->getHrefs() as $href) {
         $links[] = $html->link($href);
     }
     return implode('<br />', $links);
 }
Example #3
0
 /**
  * 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>";
     }
 }
Example #4
0
    /**
     * 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) {

        ob_start();
        echo "<table>";
        echo "<tr><th>Principal</th><th>Privilege</th><th></th></tr>";
        foreach ($this->privileges as $privilege) {

            echo '<tr>';
            // if it starts with a {, it's a special principal
            if ($privilege['principal'][0] === '{') {
                echo '<td>', $html->xmlName($privilege['principal']), '</td>';
            } else {
                echo '<td>', $html->link($privilege['principal']), '</td>';
            }
            echo '<td>', $html->xmlName($privilege['privilege']), '</td>';
            echo '<td>';
            if (!empty($privilege['protected'])) echo '(protected)';
            echo '</td>';
            echo '</tr>';

        }
        echo "</table>";
        return ob_get_clean();

    }