Example #1
0
 /**
  * Generates a RSS feed from an external RSS feed
  *
  * @param $url string The URL of the external feed
  * @return void
  */
 public function rssProxy($url)
 {
     $this->_remoteRSS = array();
     $this->_feed = new FeedWriter();
     $this->loadRSSFeed($url);
     $version = $this->_remoteRSS["version"];
     $version = floatval($version);
     if ($version <= 1.0) {
         $version = RSS1;
     } else {
         $version = RSS2;
     }
     $this->_feed->setVersion($version);
     $this->_feed->setTitle($this->_remoteRSS["title"]);
     $this->_feed->setDescription($this->_remoteRSS["description"]);
     $this->_feed->setLink($this->_remoteRSS["link"]);
     $this->_feed->setImage($this->_remoteRSS["image"]["title"], $this->_remoteRSS["image"]["url"], $this->_remoteRSS["image"]["link"]);
     $this->_feed->setChannelElement("language", $this->_remoteRSS["language"]);
     $this->_feed->setChannelElement('pubDate', $this->_remoteRSS["pubDate"]);
     if (isset($this->_remoteRSS["items"]) && count($this->_remoteRSS["items"]) > 0) {
         foreach ($this->_remoteRSS["items"] as $item) {
             $title = $this->_filter->encodeHTML($item["title"]);
             $link = $item["link"];
             $pubDate = $item["pubDate"];
             $description = $item["description"];
             if (isset($item["enclosure"])) {
                 $enclosure = array("url" => $item["enclosure"]["url"], "length" => $item["enclosure"]["length"], "type" => $item["enclosure"]["type"]);
                 $this->addEnclosureContent($title, $link, $pubDate, $description, $enclosure);
             } else {
                 $this->addContent($title, $link, $pubDate, $description);
             }
         }
     }
     header('Content-type: text/xml');
     $this->_feed->genarateFeed();
 }