Ajax software
Free javascripts
↑
Main Page
6.
Now take a look at how to add the same functionality to feeds. The
SocialBookmarking
class
has a method named
getFeedHTML()
, which can be used for that purpose. Essentially,
getHTML
and
getFeedHTML
are very similar, but your output will be a bit different for feeds. In this case,
getHTML()
uses an unordered list to display the links, whereas
getFeedHTML()
simply sepa-
rates the links using spaces. Modify the code in
rss_factory.inc.php
to add social book-
marking links at the end of each feed, like this:
<?php
// load social bookmarking helper class
require_once ‘social_bookmarking.inc.php’;
class RSSFactory
{
...
...
...
// generates feed
function get()
{
...
...
...
// add feed items
foreach ($this->_items as $feed_item)
{
// add a feed item and its contents
echo ‘<item>’;
foreach ($feed_item as $item_name => $item_value)
{
// add social bookmarking icons to feed description
if ($item_name == ‘description’)
{
// instantiate class by providing link, title, and site name
$social = new SocialBookmarking($feed_item[‘link’],
$feed_item[‘title’],
$this->_title);
// add social bookmarking icons to the feed
$item_value = $item_value . $social->getFeedHTML();
}
// output feed item
echo “<$item_name>” .
RSSFactory::_escapeXML($item_value) .
“</$item_name>”;
}
...
...
...
}
}
?>
170
Chapter 7: Web Feeds and Social Bookmarking
c07.qxd:c07 10:42 170
Ajax software
Free javascripts
→