fixed plugin updating FS#1804
[dokuwiki/radio.git] / inc / FeedParser.php
blobf37888f01264a05fbd13b3f950389e9f8aad1b9e
1 <?php
2 /**
3 * Class used to parse RSS and ATOM feeds
5 * @author Andreas Gohr <andi@splitbrain.org>
6 */
8 if(!defined('DOKU_INC')) die('meh.');
9 require_once(DOKU_INC.'inc/HTTPClient.php');
10 require_once(DOKU_INC.'inc/SimplePie.php');
13 /**
14 * We override some methods of the original SimplePie class here
16 class FeedParser extends SimplePie {
18 /**
19 * Constructor. Set some defaults
21 function FeedParser(){
22 $this->SimplePie();
23 $this->enable_cache(false);
24 $this->set_file_class('FeedParser_File');
27 /**
28 * Backward compatibility for older plugins
30 function feed_url($url){
31 $this->set_feed_url($url);
35 /**
36 * Fetch an URL using our own HTTPClient
38 * Replaces SimplePie's own class
40 class FeedParser_File extends SimplePie_File {
41 var $http;
42 var $useragent;
43 var $success = true;
44 var $headers = array();
45 var $body;
46 var $error;
48 /**
49 * Inititializes the HTTPClient
51 * We ignore all given parameters - they are set in DokuHTTPClient
53 function FeedParser_File($url, $timeout=10, $redirects=5,
54 $headers=null, $useragent=null, $force_fsockopen=false) {
55 $this->http = new DokuHTTPClient();
56 $this->success = $this->http->sendRequest($url);
58 $this->headers = $this->http->resp_headers;
59 $this->body = $this->http->resp_body;
60 $this->error = $this->http->error;
61 return $this->success;
64 function headers(){
65 return $this->headers;
68 function body(){
69 return $this->body;
72 function close(){
73 return true;