2 /********************************************************************
5 Nothing too exciting here. Just a sample page that demos integrated
6 Multifeeds support as well as cached favicons and perhaps a few other
9 Lots of this code is commented to help explain some of the new stuff.
10 Code was tested in PHP 5.2.2, but *should* also work with earlier
11 versions of PHP, as supported by SimplePie (PHP 4.1).
13 ********************************************************************/
15 // Include the SimplePie library, and the one that handles internationalized domain names.
16 require_once('../simplepie.inc');
17 require_once('../idn/idna_convert.class.php');
19 // Initialize some feeds for use.
20 $feed = new SimplePie();
21 $feed->set_feed_url(array(
22 'http://rss.news.yahoo.com/rss/topstories',
23 'http://news.google.com/?output=atom',
24 'http://rss.cnn.com/rss/cnn_topstories.rss'
27 // When we set these, we need to make sure that the handler_image.php file is also trying to read from the same cache directory that we are.
28 $feed->set_favicon_handler('./handler_image.php');
29 $feed->set_image_handler('./handler_image.php');
31 // Initialize the feed.
34 // Make sure the page is being served with the UTF-8 headers.
35 $feed->handle_content_type();
37 // Begin the (X)HTML page.
38 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
39 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
40 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
42 <title>Multifeeds Test page</title>
43 <link rel="stylesheet" href="../demo/for_the_demo/simplepie.css" type="text/css" media="screen" title="SimplePie Styles" charset="utf-8" />
44 <style type="text/css">
56 background-color:transparent;
57 background-repeat:no-repeat;
58 background-position:0 1px;
68 <?php if ($feed->error): ?>
69 <p><?=$feed->error()?></p>
73 <h1>Quick-n-Dirty Multifeeds Demo</a></h1>
77 // Let's loop through each item in the feed.
78 foreach($feed->get_items() as $item):
80 // Let's give ourselves a reference to the parent $feed object for this particular item.
81 $feed = $item->get_feed();
85 <h4 style="background-image:url(<?php echo $feed->get_favicon(); ?>);"><a href="<?php echo $item->get_permalink(); ?>"><?php echo html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8'); ?></a></h4>
87 <!-- get_content() prefers full content over summaries -->
88 <?php echo $item->get_content(); ?>
90 <?php if ($enclosure = $item->get_enclosure()): ?>
92 <?php echo $enclosure->native_embed(array(
93 // New 'mediaplayer' attribute shows off Flash-based MP3 and FLV playback.
94 'mediaplayer' => '../demo/for_the_demo/mediaplayer.swf'
99 <p class="footnote">Source: <a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a> | <?php echo $item->get_date('j M Y | g:i a'); ?></p>
104 <p class="footnote">This is a test of the emergency broadcast system. This is only a test… beeeeeeeeeeeeeeeeeeeeeeeeeep!</p>