]>
git.wh0rd.org - tt-rss.git/blob - classes/feeditem/common.php
2 abstract class FeedItem_Common
extends FeedItem
{
7 function __construct($elem, $doc, $xpath) {
14 $source = $elem->getElementsByTagName("source")->item(0);
16 // we don't need <source> element
18 $elem->removeChild($source);
19 } catch (DOMException
$e) {
24 function get_author() {
25 $author = $this->elem
->getElementsByTagName("author")->item(0);
28 $name = $author->getElementsByTagName("name")->item(0);
30 if ($name) return $name->nodeValue
;
32 $email = $author->getElementsByTagName("email")->item(0);
34 if ($email) return $email->nodeValue
;
36 if ($author->nodeValue
)
37 return $author->nodeValue
;
40 $author = $this->xpath
->query("dc:creator", $this->elem
)->item(0);
43 return $author->nodeValue
;
47 function get_comments_url() {
48 //RSS only. Use a query here to avoid namespace clashes (e.g. with slash).
49 //might give a wrong result if a default namespace was declared (possible with XPath 2.0)
50 $com_url = $this->xpath
->query("comments", $this->elem
)->item(0);
53 return $com_url->nodeValue
;
55 //Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common.
56 //'text/html' for type is too restrictive?
57 $com_url = $this->xpath
->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem
)->item(0);
60 return $com_url->nodeValue
;
63 function get_comments_count() {
64 //also query for ATE stuff here
65 $query = "slash:comments|thread:total|atom:link[@rel='replies']/@thread:count";
66 $comments = $this->xpath
->query($query, $this->elem
)->item(0);
69 return $comments->nodeValue
;