]> git.wh0rd.org - tt-rss.git/blob - classes/feeditem/common.php
Merge branch 'master' of github.com:gothfox/Tiny-Tiny-RSS
[tt-rss.git] / classes / feeditem / common.php
1 <?php
2 abstract 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 try {
13
14 $source = $elem->getElementsByTagName("source")->item(0);
15
16 // we don't need <source> element
17 if ($source)
18 $elem->removeChild($source);
19 } catch (DOMException $e) {
20 //
21 }
22 }
23
24 function get_author() {
25 $author = $this->elem->getElementsByTagName("author")->item(0);
26
27 if ($author) {
28 $name = $author->getElementsByTagName("name")->item(0);
29
30 if ($name) return $name->nodeValue;
31
32 $email = $author->getElementsByTagName("email")->item(0);
33
34 if ($email) return $email->nodeValue;
35
36 if ($author->nodeValue)
37 return $author->nodeValue;
38 }
39
40 $author = $this->xpath->query("dc:creator", $this->elem)->item(0);
41
42 if ($author) {
43 return $author->nodeValue;
44 }
45 }
46
47 // todo
48 function get_comments_url() {
49
50 }
51
52 function get_comments_count() {
53 $comments = $this->xpath->query("slash:comments", $this->elem)->item(0);
54
55 if ($comments) {
56 return $comments->nodeValue;
57 }
58 }
59
60
61 }
62 ?>