add pubdate and latest change date to rss feed

git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@589 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
cweiske 2010-01-16 10:12:25 +00:00
parent bacc8ecb70
commit 7d3de4e01e
2 changed files with 23 additions and 20 deletions

View file

@ -1,12 +1,13 @@
<?php <?php
echo '<?xml version="1.0" encoding="UTF-8" ?'.">\n"; echo '<' . '?xml version="1.0" encoding="UTF-8" ?' . ">\n";
?> ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel> <channel>
<title><?php echo $feedtitle; ?></title> <title><?php echo $feedtitle; ?></title>
<link><?php echo $feedlink; ?></link> <link><?php echo $feedlink; ?></link>
<description><?php echo $feeddescription; ?></description> <description><?php echo $feeddescription; ?></description>
<pubDate><?php echo date('r'); ?></pubDate>
<lastBuildDate><?php echo $feedlastupdate ?></lastBuildDate>
<ttl>60</ttl> <ttl>60</ttl>
<?php foreach($bookmarks as $bookmark): ?> <?php foreach($bookmarks as $bookmark): ?>
@ -16,13 +17,10 @@ echo '<?xml version="1.0" encoding="UTF-8" ?'.">\n";
<description><?php echo $bookmark['description']; ?></description> <description><?php echo $bookmark['description']; ?></description>
<dc:creator><?php echo $bookmark['creator']; ?></dc:creator> <dc:creator><?php echo $bookmark['creator']; ?></dc:creator>
<pubDate><?php echo $bookmark['pubdate']; ?></pubDate> <pubDate><?php echo $bookmark['pubdate']; ?></pubDate>
<?php foreach($bookmark['tags'] as $tag): ?>
<?php foreach($bookmark['tags'] as $tag): ?>
<category><?php echo $tag; ?></category> <category><?php echo $tag; ?></category>
<?php endforeach; ?> <?php endforeach; ?>
</item> </item>
<?php endforeach; ?> <?php endforeach; ?>
</channel> </channel>
</rss> </rss>

View file

@ -79,34 +79,39 @@ $tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $page
$tplVars['feedlink'] = ROOT; $tplVars['feedlink'] = ROOT;
$tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']); $tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
$bookmarks =& $bookmarkservice->getBookmarks(0, 15, $userid, $cat, null, getSortOrder(), $watchlist); $bookmarks = $bookmarkservice->getBookmarks(
0, 15, $userid, $cat,
null, getSortOrder(), $watchlist
);
$bookmarks_tmp =& filter($bookmarks['bookmarks']); $bookmarks_tmp = filter($bookmarks['bookmarks']);
$bookmarks_tpl = array(); $bookmarks_tpl = array();
foreach (array_keys($bookmarks_tmp) as $key) { $latestdate = null;
$row =& $bookmarks_tmp[$key]; foreach ($bookmarks_tmp as $key => $row) {
$_link = $row['bAddress']; $_link = $row['bAddress'];
// Redirection option // Redirection option
if ($GLOBALS['useredir']) { if ($GLOBALS['useredir']) {
$_link = $GLOBALS['url_redir'] . $_link; $_link = $GLOBALS['url_redir'] . $_link;
} }
$_pubdate = gmdate("r", strtotime($row['bDatetime'])); if ($row['bDatetime'] > $latestdate) {
// array_walk($row['tags'], 'filter'); $latestdate = $row['bDatetime'];
}
$_pubdate = gmdate('r', strtotime($row['bDatetime']));
$bookmarks_tpl[] = array( $bookmarks_tpl[] = array(
'title' => $row['bTitle'], 'title' => $row['bTitle'],
'link' => $_link, 'link' => $_link,
'description' => $row['bDescription'], 'description' => $row['bDescription'],
'creator' => $row['username'], 'creator' => $row['username'],
'pubdate' => $_pubdate, 'pubdate' => $_pubdate,
'tags' => $row['tags'] 'tags' => $row['tags']
); );
} }
unset($bookmarks_tmp); unset($bookmarks_tmp);
unset($bookmarks); unset($bookmarks);
$tplVars['bookmarks'] =& $bookmarks_tpl; $tplVars['bookmarks'] = $bookmarks_tpl;
$tplVars['feedlastupdate'] = date('r', strtotime($latestdate));
$templateservice->loadTemplate('rss.tpl', $tplVars); $templateservice->loadTemplate('rss.tpl', $tplVars);