2 class FeedItem_Atom extends FeedItem_Common {
4 $id = $this->elem->getElementsByTagName("id")->item(0);
9 return $this->get_link();
14 $updated = $this->elem->getElementsByTagName("updated")->item(0);
17 return strtotime($updated->nodeValue);
20 $published = $this->elem->getElementsByTagName("published")->item(0);
23 return strtotime($published->nodeValue);
26 $date = $this->xpath->query("dc:date", $this->elem)->item(0);
29 return strtotime($date->nodeValue);
34 $links = $this->elem->getElementsByTagName("link");
36 foreach ($links as $link) {
37 if ($link && $link->hasAttribute("href") &&
38 (!$link->hasAttribute("rel")
39 || $link->getAttribute("rel") == "alternate"
40 || $link->getAttribute("rel") == "standout")) {
42 return $link->getAttribute("href");
47 function get_title() {
48 $title = $this->elem->getElementsByTagName("title")->item(0);
51 return $title->nodeValue;
55 function get_content() {
56 $content = $this->elem->getElementsByTagName("content")->item(0);
59 if ($content->hasAttribute('type')) {
60 if ($content->getAttribute('type') == 'xhtml') {
61 for ($i = 0; $i < $content->childNodes->length; $i++) {
62 $child = $content->childNodes->item($i);
64 if ($child->hasChildNodes()) {
65 return $this->doc->saveXML($child);
71 return $content->nodeValue;
75 function get_description() {
76 $content = $this->elem->getElementsByTagName("summary")->item(0);
79 if ($content->hasAttribute('type')) {
80 if ($content->getAttribute('type') == 'xhtml') {
81 for ($i = 0; $i < $content->childNodes->length; $i++) {
82 $child = $content->childNodes->item($i);
84 if ($child->hasChildNodes()) {
85 return $this->doc->saveXML($child);
91 return $content->nodeValue;
96 function get_categories() {
97 $categories = $this->elem->getElementsByTagName("category");
100 foreach ($categories as $cat) {
101 if ($cat->hasAttribute("term"))
102 array_push($cats, $cat->getAttribute("term"));
105 $categories = $this->xpath->query("dc:subject", $this->elem);
107 foreach ($categories as $cat) {
108 array_push($cats, $cat->nodeValue);
114 function get_enclosures() {
115 $links = $this->elem->getElementsByTagName("link");
119 foreach ($links as $link) {
120 if ($link && $link->hasAttribute("href") && $link->hasAttribute("rel")) {
121 if ($link->getAttribute("rel") == "enclosure") {
122 $enc = new FeedEnclosure();
124 $enc->type = $link->getAttribute("type");
125 $enc->link = $link->getAttribute("href");
126 $enc->length = $link->getAttribute("length");
128 array_push($encs, $enc);
133 $enclosures = $this->xpath->query("media:content", $this->elem);
135 foreach ($enclosures as $enclosure) {
136 $enc = new FeedEnclosure();
138 $enc->type = $enclosure->getAttribute("type");
139 $enc->link = $enclosure->getAttribute("url");
140 $enc->length = $enclosure->getAttribute("length");
142 array_push($encs, $enc);