1+ <?php
2+ declare (strict_types = 1 );
3+
4+ namespace Forensic \FeedParser \FeedItems ;
5+
6+ use Forensic \FeedParser \Enums \FeedItemTypes ;
7+ use Forensic \FeedParser \XPath ;
8+ use DOMElement ;
9+
10+ class RDFFeedItem extends BaseFeedItem
11+ {
12+ public function __construct (DOMElement $ item , XPath $ xpath ,
13+ bool $ remove_styles , bool $ remove_scripts )
14+ {
15+ $ property_selectors = [
16+ 'id ' => '@rdf:about ' ,
17+ 'title ' => 'def:title || dc:title ' ,
18+ 'link ' => 'def:link ' ,
19+ 'content ' => 'content:encoded || dc:description || def:description ' ,
20+ 'enclosure ' => [
21+ 'type ' => 'enc:enclosure/@enc:type ' ,
22+ 'url ' => 'enc:enclosure/@rdf:resource ' ,
23+ 'length ' => 'enc:enclosure/enc:length '
24+ ],
25+ 'source ' => 'dc:source ' ,
26+ //'image' => { 'src' => '', 'link' => '', 'title' => '' }, // to be parsed specially
27+ 'lastUpdated ' => 'dc:date ' , // a date construct
28+ 'author ' => 'dc:creator || dc:contributor ' ,
29+ 'category ' => 'dc:coverage || dc:subject/taxo:topic/@rdf:value || dc:subject || ' .
30+ 'parent::rdf:RDF/def:channel/dc:coverage || ' +
31+ 'parent::rdf:RDF/def:channel/dc:subject/taxo:topic/@rdf:value || ' .
32+ 'parent::rdf:RDF/def:channel/dc:subject ' // defaults to the parent category
33+ ];
34+
35+ parent ::__construct (
36+ new FeedItemTypes (FeedItemTypes::RDF_FEED_ITEM ),
37+ $ item ,
38+ $ xpath ,
39+ $ property_selectors ,
40+ $ remove_styles ,
41+ $ remove_scripts
42+ );
43+ }
44+ }
0 commit comments