ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Href.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAV\Xml\Property;
4 
7 use Sabre\Uri;
11 
26 class Href implements Element, HtmlOutput {
27 
33  protected $hrefs;
34 
45  function __construct($hrefs) {
46 
47  if (is_string($hrefs)) {
48  $hrefs = [$hrefs];
49  }
50  $this->hrefs = $hrefs;
51 
52  }
53 
59  function getHref() {
60 
61  return $this->hrefs[0];
62 
63  }
64 
70  function getHrefs() {
71 
72  return $this->hrefs;
73 
74  }
75 
95  function xmlSerialize(Writer $writer) {
96 
97  foreach ($this->getHrefs() as $href) {
98  $href = Uri\resolve($writer->contextUri, $href);
99  $writer->writeElement('{DAV:}href', $href);
100  }
101 
102  }
103 
119 
120  $links = [];
121  foreach ($this->getHrefs() as $href) {
122  $links[] = $html->link($href);
123  }
124  return implode('<br />', $links);
125 
126  }
127 
149  static function xmlDeserialize(Reader $reader) {
150 
151  $hrefs = [];
152  foreach ((array)$reader->parseInnerTree() as $elem) {
153  if ($elem['name'] !== '{DAV:}href')
154  continue;
155 
156  $hrefs[] = $elem['value'];
157 
158  }
159  if ($hrefs) {
160  return new self($hrefs, false);
161  }
162 
163  }
164 
165 }
parseInnerTree(array $elementMap=null)
Parses all elements below the current element.
Definition: Reader.php:129
resolve($basePath, $newPath)
This file contains all the uri handling functions.
Definition: functions.php:23
__construct($hrefs)
Constructor.
Definition: Href.php:45
Href property.
Definition: Href.php:26
xmlSerialize(Writer $writer)
The xmlSerialize method is called during xml writing.
Definition: Href.php:95
The Reader class expands upon PHP&#39;s built-in XMLReader.
Definition: Reader.php:20
getHref()
Returns the first Href.
Definition: Href.php:59
link($url, $label=null)
Generates a full -tag.
WebDAV properties that implement this interface are able to generate their own html output for the br...
Definition: HtmlOutput.php:16
getHrefs()
Returns the hrefs as an array.
Definition: Href.php:70
This is the XML element interface.
Definition: Element.php:18
$links
$html
Definition: example_001.php:87
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
Definition: Href.php:149
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...
toHtml(HtmlOutputHelper $html)
Generate html representation for this value.
Definition: Href.php:118