[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ -> FeedParserFile.php (source)

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