[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ -> FeedParserFile.php (source)

   1  <?php
   2  
   3  namespace dokuwiki;
   4  
   5  use dokuwiki\HTTP\DokuHTTPClient;
   6  
   7  /**
   8   * Fetch an URL using our own HTTPClient
   9   *
  10   * Replaces SimplePie's own class
  11   */
  12  class FeedParserFile extends \SimplePie\File
  13  {
  14      protected $http;
  15      /** @noinspection PhpMissingParentConstructorInspection */
  16  
  17      /**
  18       * Inititializes the HTTPClient
  19       *
  20       * We ignore all given parameters - they are set in DokuHTTPClient
  21       *
  22       * @inheritdoc
  23       */
  24      public function __construct(
  25          $url,
  26          $timeout = 10,
  27          $redirects = 5,
  28          $headers = null,
  29          $useragent = null,
  30          $force_fsockopen = false,
  31          $curl_options = array()
  32      ) {
  33          $this->http = new DokuHTTPClient();
  34          $this->success = $this->http->sendRequest($url);
  35  
  36          $this->headers = $this->http->resp_headers;
  37          $this->body = $this->http->resp_body;
  38          $this->error = $this->http->error;
  39  
  40          $this->method = \SimplePie\SimplePie::FILE_SOURCE_REMOTE | \SimplePie\SimplePie::FILE_SOURCE_FSOCKOPEN;
  41  
  42          return $this->success;
  43      }
  44  
  45      /** @inheritdoc */
  46      public function headers()
  47      {
  48          return $this->headers;
  49      }
  50  
  51      /** @inheritdoc */
  52      public function body()
  53      {
  54          return $this->body;
  55      }
  56  
  57      /** @inheritdoc */
  58      public function close()
  59      {
  60          return true;
  61      }
  62  }