public function displayMain() { $postFeed = new FeedWriter(RSS2); $postFeed->setTitle(Configuration::get('TM_SHOP_NAME')); $postFeed->setLink(Configuration::get('TM_SHOP_URL')); $postFeed->setDescription('This is test of creating a RSS 2.0 feed Universal Feed Writer'); $postFeed->setImage('Testing the RSS writer class', 'http://www.ajaxray.com/projects/rss', 'http://www.rightbrainsolution.com/images/logo.gif'); $posts = CMSHelper::getNewCMS(50); foreach ($posts as $row) { $newItem = $postFeed->createNewItem(); $newItem->setTitle($row['title']); $newItem->setLink($row['link']); $newItem->setDate($row['add_date']); $newItem->setDescription($row['content']); $postFeed->addItem($newItem); } $postFeed->genarateFeed(); }
/** * 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(); }
//////////////////////////////////////////// $output = new FeedWriter(); $output->setTitle(strip_tags($feed->get_title())); $output->setDescription(strip_tags($feed->get_description())); $output->setXsl('css/feed.xsl'); // Chrome uses this, most browsers ignore it if ($valid_key && isset($_GET['pubsub'])) { // used only on fivefilters.org at the moment $output->addHub('http://fivefilters.superfeedr.com/'); $output->addHub('http://pubsubhubbub.appspot.com/'); $output->setSelf('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } $output->setLink($feed->get_link()); // Google Reader uses this for pulling in favicons if ($img_url = $feed->get_image_url()) { $output->setImage($feed->get_title(), $feed->get_link(), $img_url); } //////////////////////////////////////////// // Loop through feed items //////////////////////////////////////////// $items = $feed->get_items(0, $max); // Request all feed items in parallel (if supported) $urls_sanitized = array(); $urls = array(); foreach ($items as $key => $item) { $permalink = htmlspecialchars_decode($item->get_permalink()); // Colons in URL path segments get encoded by SimplePie, yet some sites expect them unencoded $permalink = str_replace('%3A', ':', $permalink); // simplepie already sanitizes URLs so let's not do it again here. if ($permalink && !is_cached($permalink)) { $urls_sanitized[] = $permalink;
<?php // This is a minimum example of using the class include "FeedWriter.php"; //Creating an instance of FeedWriter class. $TestFeed = new FeedWriter(RSS2); //Setting the channel elements //Use wrapper functions for common channel elements $TestFeed->setTitle('Testing & Checking the RSS writer class'); $TestFeed->setLink('http://www.ajaxray.com/projects/rss'); $TestFeed->setDescription('This is test of creating a RSS 2.0 feed Universal Feed Writer'); //Image title and link must match with the 'title' and 'link' channel elements for valid RSS 2.0 $TestFeed->setImage('Testing the RSS writer class', 'http://www.ajaxray.com/projects/rss', 'http://www.rightbrainsolution.com/images/logo.gif'); //Detriving informations from database addin feeds $db->query($query); $result = $db->result; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { //Create an empty FeedItem $newItem = $TestFeed->createNewItem(); //Add elements to the feed item $newItem->setTitle($row['title']); $newItem->setLink($row['link']); $newItem->setDate($row['create_date']); $newItem->setDescription($row['description']); //Now add the feed item $TestFeed->addItem($newItem); } //OK. Everything is done. Now genarate the feed. $TestFeed->genarateFeed();
} $current_time = time(); $timelimit = $maxdays * 60 * 60 * 24; $statslink = httplink() . "?config=" . $currentconfignumber; $feeddescription = "These are the top players of " . $statstitle . " (ordered by " . $sortby . "). Connect (with your " . $game . " gameclient) to: " . $public_ip . " and compete with them!"; $feeddescriptionshort = "XLRstats Top Players Feed"; $feedlogo = "http://www.bigbrotherbot.com/images/b3_power_88_2.gif"; //Creating an instance of FeedWriter class. $XLRfeed = new FeedWriter(RSS2); //Setting the channel elements //Use wrapper functions for common channel elements $XLRfeed->setTitle($statstitle); $XLRfeed->setLink($statslink); $XLRfeed->setDescription($feeddescription); //Image title and link must match with the 'title' and 'link' channel elements for valid RSS 2.0 $XLRfeed->setImage($feeddescriptionshort, $statslink, $feedlogo); // DATABASE $coddb = new sql_db($db_host, $db_user, $db_pass, $db_db, false); if (!$coddb->db_connect_id) { die("Could not connect to the database"); } //Detriving informations from database addin feeds $query = "SELECT {$t['b3_clients']}.name, {$t['b3_clients']}.time_edit, {$t['players']}.id, kills, deaths, ratio, skill, winstreak, losestreak, rounds, fixed_name, ip\n FROM {$t['b3_clients']}, {$t['players']}\n WHERE ({$t['b3_clients']}.id = {$t['players']}.client_id)\n AND (({$t['players']}.kills > {$minkills})\n OR ({$t['players']}.rounds > {$minrounds}))\n AND ({$t['players']}.hide = 0)\n AND ({$current_time} - {$t['b3_clients']}.time_edit < {$timelimit})"; if ($clan_name != "") { $query .= " AND ({$t['b3_clients']}.name like '%%{$clan_name}%%')"; } $query .= " ORDER BY {$sortby} {$direction} \n LIMIT 0, {$limit}"; $result = $coddb->sql_query($query); $timestamp = time(); $count = 1; while ($row = $coddb->sql_fetchrow($result)) {
$thread_name = ''; } } else { $feed = $rssC->get_section($section, $uinfo); $title = $rssC->get_title($section, $subsection, $tid); $section_name = ' - ' . $title['section_name']; $subsection_name = ''; $thread_name = ''; } } else { $feed = $rssC->get_all($uinfo); $section_name = ''; $subsection_name = ''; $thread_name = ''; } $TestFeed = new FeedWriter(RSS2); $site_name = $_SERVER["HTTP_HOST"]; $title = $site_name . $section_name . $subsection_name . $thread_name; $TestFeed->setTitle($title); $TestFeed->setImage($title, 'http://' . $site_name . '/', 'http://' . $site_name . '/rss_icon.png'); if (!empty($feed)) { for ($i = 0; $i < count($feed); $i++) { $newItem = $TestFeed->createNewItem(); $newItem->setTitle($feed[$i]['title']); $newItem->setLink($feed[$i]['link']); $newItem->setDate($feed[$i]['time']); $newItem->setDescription($feed[$i]['description']); $TestFeed->addItem($newItem); } } $TestFeed->genarateFeed();
<?php $arrAllArticles = $ogArticleManager->pullTokens(0, "", "id", "DESC"); $oFeedWriter = new FeedWriter(RSS2); $oFeedWriter->setTitle($ogContentManager->getContent("RSSTitle", "Site RSS Feed")); $oFeedWriter->setLink($ogContentManager->getContent("RSSLink", $fusebox['urlBase'])); $oFeedWriter->setDescription("RSSDescription", "Site RSS Feed Description"); $oFeedWriter->setImage($ogContentManager->getContent("RSSTitle", "Site RSS Feed"), $ogContentManager->getContent("RSSLink", "Site RSS Link"), $fusebox['urlAssets'] . 'images/rss.png'); foreach ($arrAllArticles as $a) { $oItem = $oFeedWriter->createNewItem(); $oItem->setTitle($ogArticleManager->getTitle($a['token'])); $oItem->setLink($fusebox['urlBase'] . $a['token'] . ".page"); $oItem->setDate($ogArticleManager->getCreatedDate($a['token'])); $oItem->setDescription($ogArticleManager->getContent($a['token'])); $oFeedWriter->addItem($oItem); } $oFeedWriter->genarateFeed();
protected function rss() { global $onpub_disp_rss, $onpub_disp_updates_num, $onpub_disp_friendly_urls; if ($this->website && $onpub_disp_rss) { // See the following OnpubAPI tutorial for more info: // http://onpub.com/index.php?s=20&a=78 // This example is based on an example by Anis uddin Ahmad, the author of // Universal Feed Writer. //Creating an instance of FeedWriter class. //The constant RSS2 is passed to mention the version $feed = new FeedWriter(RSS2); //Setting the channel elements //Use wrapper functions for common channel elements $feed->setTitle($this->website->name); $feed->setLink(addTrailingSlash($this->website->url)); $feed->setDescription(''); //Image title and link must match with the 'title' and 'link' channel elements for RSS 2.0 if ($this->website->image) { $feed->setImage($this->website->name, addTrailingSlash($this->website->url), addTrailingSlash($this->website->imagesURL) . $this->website->image->fileName); } else { $feed->setImage($this->website->name, addTrailingSlash($this->website->url), null); } //Use core setChannelElement() function for other optional channels $feed->setChannelElement('language', 'en-us'); $feed->setChannelElement('pubDate', date(DATE_RSS, time())); $qo = new OnpubQueryOptions(); $qo->includeContent = true; $qo->includeAuthors = true; $qo->orderBy = 'created'; $qo->order = 'DESC'; $qo->rowLimit = $onpub_disp_updates_num; $articles = $this->articles->select($qo, null, $this->website->ID); //Adding a feed. Genarally this portion will be in a loop and add all feeds. foreach ($articles as $article) { // Get the article's authors. $authors = $article->authors; //Create an empty FeedItem $newItem = $feed->createNewItem(); //Add elements to the feed item //Use wrapper functions to add common feed elements // Use the OnpubArticle object to set the various properties of the FeedItem. $newItem->setTitle($article->title); $samaps = $this->samaps->select(null, null, $article->ID); if ($onpub_disp_friendly_urls) { $newItem->setLink(addTrailingSlash($this->website->url) . $this->generateFriendlyURL(NULL, $article, $samaps[0]->sectionID)); } else { $newItem->setLink(addTrailingSlash($this->website->url) . 'index.php?s=' . $samaps[0]->sectionID . '&a=' . $article->ID); } //The parameter is a timestamp for setDate() function $newItem->setDate($article->getCreated()->format('c')); $newItem->setDescription($this->friendlyURLs($article->content)); if (sizeof($authors)) { //Use core addElement() function for other supported optional elements $newItem->addElement('author', $authors[0]->displayAs); } //Now add the feed item $feed->addItem($newItem); } //OK. Everything is done. Now genarate the feed. $feed->genarateFeed(); } }