blob: c9ecd59e4212d1cdacb75e289947d5dc60da36c7 (
plain)
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
|
<?php
class FeedItem_Json extends FeedItem_Common {
/* for JSON feed only $elem is passed which is the actual entry as an object */
function __construct($elem, $doc, $xpath) {
$this->elem = $elem;
$this->doc = $doc;
}
function get_id() {
return $this->elem->id;
}
function get_date() {
return isset($this->elem->date_published) ? strtotime($this->elem->date_published) : false;
}
function get_author() {
$author = false;
if (isset($this->author)) {
$author = $this->author;
} else if (isset($this->doc->author)) {
$author = $this->doc->author;
}
if ($author && $author->name) {
return $author->name;
}
}
function get_comments_url() {
return false;
}
function get_comments_count() {
return false;
}
function get_link() {
return isset($this->elem->url) ? $this->elem->url : false;
}
function get_title() {
return $this->elem->title;
}
function get_content() {
return isset($this->elem->content_html) ? $this->elem->content_html : $this->elem->content_text;
}
function get_description() {
return isset($this->elem->summary) ? $this->elem->summary : false;
}
function get_categories() {
$cats = array();
if (is_array($this->elem->tags)) {
foreach ($this->elem->tags as $cat) {
array_push($cats, trim($cat));
}
}
return $cats;
}
function get_enclosures() {
$encs = array();
if (is_array($this->elem->attachments)) {
foreach ($this->elem->attachments as $enclosure) {
$enc = new FeedEnclosure();
$enc->type = $enclosure["mime_type"];
$enc->link = $enclosure["url"];
@$enc->length = $enclosure["size_in_bytes"];
array_push($encs, $enc);
}
}
return $encs;
}
}
|