1
+ <?php
2
+ declare (strict_types = 1 );
3
+
4
+ namespace Forensic \FeedParser \Feeds ;
5
+
6
+ use Forensic \FeedParser \Enums \FeedTypes ;
7
+ use Forensic \FeedParser \XPath ;
8
+ use Forensic \FeedParser \FeedItems \RDFFeedItem ;
9
+
10
+
11
+ class RSSFeed extends BaseFeed
12
+ {
13
+ public function __construct (XPath $ xpath , string $ default_lang ,
14
+ bool $ remove_styles , bool $ remove_scripts )
15
+ {
16
+ $ namespaces = [
17
+ 'def ' => 'http://purl.org/rss/1.0/ ' ,
18
+ 'rdf ' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns# ' ,
19
+ 'dc ' => 'http://purl.org/dc/elements/1.1/ ' ,
20
+ 'sy ' => 'http://purl.org/rss/1.0/modules/syndication ' ,
21
+ 'enc ' => 'http://purl.oclc.org/net/rss_2.0/enc# ' ,
22
+ 'content ' => 'http://purl.org/rss/1.0/modules/content/ ' ,
23
+ 'taxo ' => 'http://purl.org/rss/1.0/modules/taxonomy/ '
24
+ ];
25
+
26
+ $ property_selectors = [
27
+ 'id ' => 'def:channel/@rdf:about || def:channel/dc:identifier ' ,
28
+ 'title ' => 'def:channel/def:title || def:channel/dc:title ' ,
29
+ 'link ' => 'def:channel/def:link ' ,
30
+ 'description ' => 'def:channel/def:description || def:channel/dc:description ' ,
31
+ 'image ' => [
32
+ 'src ' => 'def:image/def:url || def:image/@rdf:about ' ,
33
+ 'link ' => 'def:image/def:link || def:channel/def:link ' ,
34
+ 'title ' => 'def:image/def:title || def:image/dc:title || def:channel/def:title ' .
35
+ '|| def:channel/dc:title '
36
+ ],
37
+ 'copyright ' => 'def:channel/dc:rights ' ,
38
+ 'lastUpdated ' => 'def:channel/dc:date ' ,
39
+ 'generator ' => 'def:channel/dc:publisher || def:channel/dc:creator ' ,
40
+ 'language ' => 'def:channel/dc:language ' ,
41
+ 'category ' => 'def:channel/dc:coverage || ' .
42
+ 'def:channel/dc:subject/taxo:topic/@rdf:value || dc:subject ' ,
43
+ ];
44
+
45
+ $ items_selector = 'def:item ' ;
46
+
47
+ parent ::__construct (
48
+ new FeedTypes (FeedTypes::RDF_FEED ),
49
+ $ default_lang ,
50
+ $ xpath ,
51
+ $ namespaces ,
52
+ $ property_selectors ,
53
+ $ items_selector ,
54
+ $ remove_styles ,
55
+ $ remove_scripts
56
+ );
57
+ }
58
+ }
0 commit comments