ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Href.php
Go to the documentation of this file.
1<?php
2
4
7use Sabre\Uri;
11
26class 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}
An exception for terminatinating execution or to throw for unit testing.
This class provides a few utility functions for easily generating HTML for the browser plugin.
Href property.
Definition: Href.php:26
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
Definition: Href.php:149
__construct($hrefs)
Constructor.
Definition: Href.php:45
getHref()
Returns the first Href.
Definition: Href.php:59
toHtml(HtmlOutputHelper $html)
Generate html representation for this value.
Definition: Href.php:118
xmlSerialize(Writer $writer)
The xmlSerialize method is called during xml writing.
Definition: Href.php:95
getHrefs()
Returns the hrefs as an array.
Definition: Href.php:70
The Reader class expands upon PHP's built-in XMLReader.
Definition: Reader.php:20
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
$html
Definition: example_001.php:87
$links
WebDAV properties that implement this interface are able to generate their own html output for the br...
Definition: HtmlOutput.php:16
This is the XML element interface.
Definition: Element.php:18
resolve($basePath, $newPath)
This file contains all the uri handling functions.
Definition: functions.php:23