2007-12-12 16:29:16 +00:00
|
|
|
<?php
|
2010-01-16 10:09:32 +00:00
|
|
|
/**
|
|
|
|
* RSS output of the latest posts.
|
|
|
|
*
|
2010-01-16 10:15:19 +00:00
|
|
|
* Parameter:
|
|
|
|
* - count=15
|
|
|
|
* Sets the number of RSS entries to export
|
|
|
|
*
|
2010-01-16 10:09:32 +00:00
|
|
|
* SemanticScuttle - your social bookmark manager.
|
|
|
|
*
|
|
|
|
* PHP version 5.
|
|
|
|
*
|
|
|
|
* @category Bookmarking
|
|
|
|
* @package SemanticScuttle
|
|
|
|
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
|
|
|
|
* @author Christian Weiske <cweiske@cweiske.de>
|
|
|
|
* @author Eric Dane <ericdane@users.sourceforge.net>
|
|
|
|
* @license GPL http://www.gnu.org/licenses/gpl.html
|
|
|
|
* @link http://sourceforge.net/projects/semanticscuttle
|
|
|
|
*/
|
2007-12-12 16:29:16 +00:00
|
|
|
|
2010-02-08 07:32:34 +00:00
|
|
|
require_once 'www-header.php';
|
2008-11-25 15:57:29 +00:00
|
|
|
|
|
|
|
/* Service creation: only useful services are created */
|
2010-01-16 10:09:32 +00:00
|
|
|
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
|
|
|
|
$cacheservice = SemanticScuttle_Service_Factory::get('Cache');
|
2008-11-25 15:57:29 +00:00
|
|
|
|
2010-01-16 10:10:48 +00:00
|
|
|
header('Content-Type: application/rss+xml; charset=utf-8');
|
|
|
|
|
2010-01-16 10:09:32 +00:00
|
|
|
if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) >1) {
|
|
|
|
list($url, $user, $cat) = explode('/', $_SERVER['PATH_INFO']);
|
2008-11-25 15:57:29 +00:00
|
|
|
} else {
|
2010-01-16 10:09:32 +00:00
|
|
|
$url = '';
|
|
|
|
$user = '';
|
|
|
|
$cat = null;
|
2008-11-25 15:57:29 +00:00
|
|
|
}
|
2007-12-12 16:29:16 +00:00
|
|
|
|
|
|
|
if ($usecache) {
|
2010-01-16 10:09:32 +00:00
|
|
|
// Generate hash for caching on
|
|
|
|
$hashtext = $_SERVER['REQUEST_URI'];
|
|
|
|
if ($userservice->isLoggedOn()) {
|
|
|
|
$hashtext .= $userservice->getCurrentUserID();
|
|
|
|
if ($currentUser->getUsername() == $user) {
|
|
|
|
$hashtext .= $user;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$hash = md5($hashtext);
|
|
|
|
|
|
|
|
// Cache for an hour
|
|
|
|
$cacheservice->Start($hash, 3600);
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
|
2010-01-16 10:15:19 +00:00
|
|
|
if (isset($_GET['count'])) {
|
|
|
|
$rssEntries = (int)$_GET['count'];
|
|
|
|
}
|
2010-01-19 20:30:44 +00:00
|
|
|
if (!isset($rssEntries) || $rssEntries <= 0) {
|
2010-01-16 10:15:19 +00:00
|
|
|
$rssEntries = $defaultRssEntries;
|
|
|
|
} else if ($rssEntries > $maxRssEntries) {
|
|
|
|
$rssEntries = $maxRssEntries;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 16:29:16 +00:00
|
|
|
$watchlist = null;
|
2008-11-25 15:57:29 +00:00
|
|
|
$pagetitle = '';
|
2007-12-12 16:29:16 +00:00
|
|
|
if ($user && $user != 'all') {
|
2010-01-16 10:09:32 +00:00
|
|
|
if ($user == 'watchlist') {
|
|
|
|
$user = $cat;
|
|
|
|
$cat = null;
|
|
|
|
$watchlist = true;
|
|
|
|
}
|
|
|
|
if (is_int($user)) {
|
|
|
|
$userid = intval($user);
|
|
|
|
} else {
|
|
|
|
if ($userinfo = $userservice->getUserByUsername($user)) {
|
|
|
|
$userid =& $userinfo[$userservice->getFieldName('primary')];
|
|
|
|
} else {
|
|
|
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
|
|
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
|
|
|
//throw a 404 error
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$pagetitle .= ": ". $user;
|
2007-12-12 16:29:16 +00:00
|
|
|
} else {
|
2010-01-16 10:09:32 +00:00
|
|
|
$userid = null;
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($cat) {
|
2010-01-16 10:09:32 +00:00
|
|
|
$pagetitle .= ": ". str_replace('+', ' + ', $cat);
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : ''));
|
2008-11-21 10:44:28 +00:00
|
|
|
$tplVars['feedlink'] = ROOT;
|
2007-12-12 16:29:16 +00:00
|
|
|
$tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
|
|
|
|
|
2010-01-16 10:12:25 +00:00
|
|
|
$bookmarks = $bookmarkservice->getBookmarks(
|
2010-01-16 10:15:19 +00:00
|
|
|
0, $rssEntries, $userid, $cat,
|
2010-01-16 10:12:25 +00:00
|
|
|
null, getSortOrder(), $watchlist
|
|
|
|
);
|
2008-11-25 15:57:29 +00:00
|
|
|
|
2010-01-16 10:12:25 +00:00
|
|
|
$bookmarks_tmp = filter($bookmarks['bookmarks']);
|
2007-12-12 16:29:16 +00:00
|
|
|
|
|
|
|
$bookmarks_tpl = array();
|
2010-01-16 10:12:25 +00:00
|
|
|
$latestdate = null;
|
|
|
|
foreach ($bookmarks_tmp as $key => $row) {
|
2010-01-16 10:09:32 +00:00
|
|
|
$_link = $row['bAddress'];
|
|
|
|
// Redirection option
|
|
|
|
if ($GLOBALS['useredir']) {
|
|
|
|
$_link = $GLOBALS['url_redir'] . $_link;
|
|
|
|
}
|
2010-01-16 10:12:25 +00:00
|
|
|
if ($row['bDatetime'] > $latestdate) {
|
|
|
|
$latestdate = $row['bDatetime'];
|
|
|
|
}
|
|
|
|
$_pubdate = gmdate('r', strtotime($row['bDatetime']));
|
2010-01-16 10:09:32 +00:00
|
|
|
|
|
|
|
$bookmarks_tpl[] = array(
|
2010-01-16 10:12:25 +00:00
|
|
|
'title' => $row['bTitle'],
|
|
|
|
'link' => $_link,
|
2007-12-12 16:29:16 +00:00
|
|
|
'description' => $row['bDescription'],
|
2010-01-16 10:12:25 +00:00
|
|
|
'creator' => $row['username'],
|
|
|
|
'pubdate' => $_pubdate,
|
|
|
|
'tags' => $row['tags']
|
2010-01-16 10:09:32 +00:00
|
|
|
);
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
unset($bookmarks_tmp);
|
|
|
|
unset($bookmarks);
|
2010-01-16 10:12:25 +00:00
|
|
|
$tplVars['bookmarks'] = $bookmarks_tpl;
|
|
|
|
$tplVars['feedlastupdate'] = date('r', strtotime($latestdate));
|
2007-12-12 16:29:16 +00:00
|
|
|
|
|
|
|
$templateservice->loadTemplate('rss.tpl', $tplVars);
|
|
|
|
|
|
|
|
if ($usecache) {
|
2010-01-16 10:09:32 +00:00
|
|
|
// Cache output if existing copy has expired
|
|
|
|
$cacheservice->End($hash);
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
?>
|