blob: 1af65e289996500d74267b79fd451cf4b5968012 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<?php
namespace Providers;
require_once('Provider.php');
abstract class XmlFeed extends \Providers\Provider {
protected $_feedUrl;
protected $_feedXml;
abstract protected function _getFeedUrl($feed);
public function __construct($feed, $options=[]) {
parent::__construct($feed, $options);
$this->_feedUrl = $this->_getFeedUrl($feed);
if (!$this->_feedUrl) {
throw new \Exception('XML feed "' . $feed . '" undefined');
}
}
abstract protected function _parseFeedContent($feed);
protected function _fetchFeedContent($url) {
$userAgent = file_get_contents('../config/user-agent');
$context = stream_context_create([
'http' => [
'method' => "GET",
'header' => "Accept: text/html,application/xml,application/xhtml+xml,text/xml\r\nAccept-Language: en;1=0.7\r\nUser-Agent: " . $userAgent,
]
]);
return trim(file_get_contents($url, FALSE, $context));
}
protected function _fetchItems() {
$feedContent = $this->_fetchFeedContent($this->_feedUrl);
$this->_feedXml = new \SimpleXMLElement($feedContent);
return $this->_parseFeedContent($this->_feedXml);
}
protected function _spamFilter($content) {
return $content;
}
protected function _sortContent($content) {
return $content;
}
}
?>
|