-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatomlink.class
More file actions
93 lines (67 loc) · 2.51 KB
/
Copy pathatomlink.class
File metadata and controls
93 lines (67 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
class AtomLink extends XMLement {
private $URI;
private $Rel;
private $Type; // Valid MIME type per RFC 4288
private $Lang;
private $Title;
private $Length;
const REL_ALTERNATE = 1; // Alternate representation, permlink to html version++
const REL_ENCLOSURE = 2; // Related resource that is potentially large (audio/video/++)
const REL_RELATED = 3; // Document that is somehow related
const REL_SELF = 4; // The feed itself
const REL_VIA = 5; // Source of the information provided in entry
public function __construct($uri, $rel=NULL, $type=NULL, $lang=NULL, $title=NULL, $length=NULL) {
parent::__construct('link', NULL, 'atom');
$this->URI = $uri;
if ($rel !== NULL)
$this->SetRel($rel);
if ($type !== NULL)
$this->SetType($type);
if ($lang !== NULL)
$this->SetLang($lang);
if ($title !== NULL)
$this->SetTitle($title);
if ($length !== NULL)
$this->SetLength($length);
}
public function SetRel($rel) {
if ($rel != AtomLink::REL_ALTERNATE && $rel != AtomLink::REL_ENCLOSURE &&
$rel != AtomLink::REL_RELATED && $rel != AtomLink::REL_SELF && $rel != AtomLink::REL_VIA)
throw new Exception('Rel must be of a type defined by the Atom specification (alternate, enclosure, related, self or via)');
$this->Rel = $rel;
}
public function SetType($type) {
$this->Type = $type;
}
public function SetLang($lang) {
$this->Lang = $lang;
}
public function SetTitle($title) {
$this->Title = $title;
}
public function SetLength($length) {
if (!is_numeric($length))
throw new Exception('Length must be a numeric value');
$this->Length = (int)$length;
}
public static function Consume($data) {
// parse atom linkage via dom
$atomlink = new AtomLink();
}
public function Build() {
$this->SetAttribute('href', $this->URI);
if ($this->Rel !== NULL)
$this->SetAttribute('rel', $this->Rel);
if ($this->Type !== NULL)
$this->SetAttribute('type', $this->Type);
if ($this->Lang !== NULL)
$this->SetAttribute('hreflang', $this->Lang);
if ($this->Title !== NULL)
$this->SetAttribute('title', $this->Title);
if ($this->Length !== NULL)
$this->SetAttribute('length', $this->Length);
return $this;
}
}
?>