You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.5 KiB
71 lines
2.5 KiB
6 years ago
|
<?php
|
||
|
/** @license MIT
|
||
|
* Copyright 2018 J. King et al.
|
||
|
* See LICENSE and AUTHORS files for details */
|
||
|
|
||
|
declare(strict_types=1);
|
||
4 years ago
|
namespace JKingWeb\Lax\Parser\XML\Primitives;
|
||
6 years ago
|
|
||
6 years ago
|
use JKingWeb\Lax\Person\Collection as PersonCollection;
|
||
4 years ago
|
use JKingWeb\Lax\Parser\XML\XPath;
|
||
6 years ago
|
|
||
|
trait Feed {
|
||
6 years ago
|
/** Primitive to fetch an Atom feed summary
|
||
|
*
|
||
|
* Atom does not have a 'description' element like the RSSes, but it does have 'subtitle', which fills roughly the same function
|
||
|
*/
|
||
|
protected function getSummaryAtom() {
|
||
6 years ago
|
return $this->fetchTextAtom("atom:subtitle");
|
||
6 years ago
|
}
|
||
|
|
||
|
/** Primitive to fetch an RSS feed summary */
|
||
|
protected function getSummaryRss2() {
|
||
6 years ago
|
return $this->fetchText("description");
|
||
6 years ago
|
}
|
||
|
|
||
|
/** Primitive to fetch an RDF feed summary */
|
||
|
protected function getSummaryRss1() {
|
||
6 years ago
|
return $this->fetchText("rss1:description|rss0:description");
|
||
6 years ago
|
}
|
||
|
|
||
|
/** Primitive to fetch a Dublin Core feed summary */
|
||
|
protected function getSummaryDC() {
|
||
6 years ago
|
return $this->fetchText("dc:description");
|
||
6 years ago
|
}
|
||
|
|
||
6 years ago
|
/** Primitive to fetch a podcast summary */
|
||
|
protected function getSummaryPod() {
|
||
6 years ago
|
return $this->fetchText("apple:summary|gplay:description") ?? $this->fetchText("apple:subtitle");
|
||
6 years ago
|
}
|
||
6 years ago
|
|
||
6 years ago
|
/** Primitive to fetch a collection of authors associated with an Atom feed */
|
||
|
protected function getAuthorsAtom() {
|
||
|
return $this->fetchPeopleAtom("atom:author", "author");
|
||
6 years ago
|
}
|
||
6 years ago
|
|
||
|
/** Primitive to fetch an RDF feed's canonical URL */
|
||
|
protected function getUrlRss1() {
|
||
|
// XPath doesn't seem to like the query we'd need for this, so it must be done the hard way.
|
||
|
$node = $this->subject;
|
||
|
if ($node->hasAttributeNS(XPath::NS['rdf'], "about")) {
|
||
|
if (
|
||
|
($node->localName=="channel" && ($node->namespaceURI==XPath::NS['rss1'] || $node->namespaceURI==XPath::NS['rss0'])) ||
|
||
|
($node==$node->ownerDocument->documentElement && $node->localName=="RDF" && $node->namespaceURI==XPath::NS['rdf'])
|
||
|
) {
|
||
|
return $this->resolveNodeUrl($node, "about", XPath::NS['rdf']);
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
6 years ago
|
/** Primitive to fetch a podcast's canonical URL */
|
||
6 years ago
|
protected function getUrlPod() {
|
||
6 years ago
|
return $this->fetchUrl("apple:new-feed-url");
|
||
6 years ago
|
}
|
||
6 years ago
|
|
||
|
/** Primitive to fetch the modification date of an RSS feed */
|
||
|
protected function getDateModifiedRss2() {
|
||
6 years ago
|
return $this->fetchDate("lastBuildDate") ?? $this->fetchDate("pubDate");
|
||
6 years ago
|
}
|
||
6 years ago
|
}
|