]> git.wh0rd.org - tt-rss.git/blame - classes/feeditem/common.php
move common methods to feeditem_common
[tt-rss.git] / classes / feeditem / common.php
CommitLineData
b4d16900
AD
1<?php
2abstract class FeedItem_Common extends FeedItem {
3 protected $elem;
4 protected $xpath;
5 protected $doc;
6
7 function __construct($elem, $doc, $xpath) {
8 $this->elem = $elem;
9 $this->xpath = $xpath;
10 $this->doc = $doc;
11 }
12
13 function get_author() {
14 $author = $this->elem->getElementsByTagName("author")->item(0);
15
16 if ($author) {
17 $name = $author->getElementsByTagName("name")->item(0);
18
19 if ($name) return $name->nodeValue;
20
21 $email = $author->getElementsByTagName("email")->item(0);
22
23 if ($email) return $email->nodeValue;
24 }
25
26 $author = $this->xpath->query("dc:creator", $this->elem)->item(0);
27
28 if ($author) {
29 return $author->nodeValue;
30 }
31 }
32
33 // todo
34 function get_comments_url() {
35
36 }
37
38 function get_comments_count() {
39 $comments = $this->xpath->query("slash:comments", $this->elem)->item(0);
40
41 if ($comments) {
42 return $comments->nodeValue;
43 }
44 }
45
46
47}
48?>