]>
Commit | Line | Data |
---|---|---|
b4d16900 AD |
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; | |
b5844603 AD |
11 | |
12 | $source = $elem->getElementsByTagName("source")->item(0); | |
13 | ||
14 | // we don't need <source> element | |
15 | if ($source) | |
16 | $elem->removeChild($source); | |
b4d16900 AD |
17 | } |
18 | ||
19 | function get_author() { | |
20 | $author = $this->elem->getElementsByTagName("author")->item(0); | |
21 | ||
22 | if ($author) { | |
23 | $name = $author->getElementsByTagName("name")->item(0); | |
24 | ||
25 | if ($name) return $name->nodeValue; | |
26 | ||
27 | $email = $author->getElementsByTagName("email")->item(0); | |
28 | ||
29 | if ($email) return $email->nodeValue; | |
602fe534 AD |
30 | |
31 | if ($author->nodeValue) | |
32 | return $author->nodeValue; | |
b4d16900 AD |
33 | } |
34 | ||
35 | $author = $this->xpath->query("dc:creator", $this->elem)->item(0); | |
36 | ||
37 | if ($author) { | |
38 | return $author->nodeValue; | |
39 | } | |
40 | } | |
41 | ||
42 | // todo | |
43 | function get_comments_url() { | |
44 | ||
45 | } | |
46 | ||
47 | function get_comments_count() { | |
48 | $comments = $this->xpath->query("slash:comments", $this->elem)->item(0); | |
49 | ||
50 | if ($comments) { | |
51 | return $comments->nodeValue; | |
52 | } | |
53 | } | |
54 | ||
55 | ||
56 | } | |
57 | ?> |