2007-12-12 17:29:16 +01:00
|
|
|
<?php
|
2010-01-16 11:09:32 +01:00
|
|
|
/**
|
|
|
|
* RSS output of the latest posts.
|
|
|
|
*
|
|
|
|
* 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 17:29:16 +01:00
|
|
|
|
2009-10-03 23:52:30 +02:00
|
|
|
require_once '../src/SemanticScuttle/header.php';
|
2008-11-25 16:57:29 +01:00
|
|
|
|
|
|
|
/* Service creation: only useful services are created */
|
2010-01-16 11:09:32 +01:00
|
|
|
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
|
|
|
|
$cacheservice = SemanticScuttle_Service_Factory::get('Cache');
|
2008-11-25 16:57:29 +01:00
|
|
|
|
2007-12-12 17:29:16 +01:00
|
|
|
header('Content-Type: application/xml');
|
2010-01-16 11:09:32 +01:00
|
|
|
if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) >1) {
|
|
|
|
list($url, $user, $cat) = explode('/', $_SERVER['PATH_INFO']);
|
2008-11-25 16:57:29 +01:00
|
|
|
} else {
|
2010-01-16 11:09:32 +01:00
|
|
|
$url = '';
|
|
|
|
$user = '';
|
|
|
|
$cat = null;
|
2008-11-25 16:57:29 +01:00
|
|
|
}
|
2007-12-12 17:29:16 +01:00
|
|
|
|
|
|
|
if ($usecache) {
|
2010-01-16 11:09:32 +01: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 17:29:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$watchlist = null;
|
2008-11-25 16:57:29 +01:00
|
|
|
$pagetitle = '';
|
2007-12-12 17:29:16 +01:00
|
|
|
if ($user && $user != 'all') {
|
2010-01-16 11:09:32 +01: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 17:29:16 +01:00
|
|
|
} else {
|
2010-01-16 11:09:32 +01:00
|
|
|
$userid = null;
|
2007-12-12 17:29:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($cat) {
|
2010-01-16 11:09:32 +01:00
|
|
|
$pagetitle .= ": ". str_replace('+', ' + ', $cat);
|
2007-12-12 17:29:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : ''));
|
2008-11-21 11:44:28 +01:00
|
|
|
$tplVars['feedlink'] = ROOT;
|
2007-12-12 17:29:16 +01:00
|
|
|
$tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
|
|
|
|
|
2010-01-16 11:09:32 +01:00
|
|
|
$bookmarks =& $bookmarkservice->getBookmarks(0, 15, $userid, $cat, null, getSortOrder(), $watchlist);
|
2008-11-25 16:57:29 +01:00
|
|
|
|
2007-12-12 17:29:16 +01:00
|
|
|
$bookmarks_tmp =& filter($bookmarks['bookmarks']);
|
|
|
|
|
|
|
|
$bookmarks_tpl = array();
|
2010-01-16 11:09:32 +01:00
|
|
|
foreach (array_keys($bookmarks_tmp) as $key) {
|
|
|
|
$row =& $bookmarks_tmp[$key];
|
|
|
|
|
|
|
|
$_link = $row['bAddress'];
|
|
|
|
// Redirection option
|
|
|
|
if ($GLOBALS['useredir']) {
|
|
|
|
$_link = $GLOBALS['url_redir'] . $_link;
|
|
|
|
}
|
|
|
|
$_pubdate = gmdate("r", strtotime($row['bDatetime']));
|
|
|
|
// array_walk($row['tags'], 'filter');
|
|
|
|
|
|
|
|
$bookmarks_tpl[] = array(
|
2007-12-12 17:29:16 +01:00
|
|
|
'title' => $row['bTitle'],
|
|
|
|
'link' => $_link,
|
|
|
|
'description' => $row['bDescription'],
|
|
|
|
'creator' => $row['username'],
|
|
|
|
'pubdate' => $_pubdate,
|
|
|
|
'tags' => $row['tags']
|
2010-01-16 11:09:32 +01:00
|
|
|
);
|
2007-12-12 17:29:16 +01:00
|
|
|
}
|
|
|
|
unset($bookmarks_tmp);
|
|
|
|
unset($bookmarks);
|
|
|
|
$tplVars['bookmarks'] =& $bookmarks_tpl;
|
|
|
|
|
|
|
|
$templateservice->loadTemplate('rss.tpl', $tplVars);
|
|
|
|
|
|
|
|
if ($usecache) {
|
2010-01-16 11:09:32 +01:00
|
|
|
// Cache output if existing copy has expired
|
|
|
|
$cacheservice->End($hash);
|
2007-12-12 17:29:16 +01:00
|
|
|
}
|
|
|
|
?>
|