2 /***************************************************************************
3 Copyright (C) 2004 - 2006 Marcus Campbell
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ***************************************************************************/
21 require_once 'header.inc.php';
22 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
23 $cacheservice =& ServiceFactory::getServiceInstance('CacheService');
24 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
25 $userservice =& ServiceFactory::getServiceInstance('UserService');
28 header('Content-Type: application/xml');
29 list($url, $user, $cat) = explode('/', $_SERVER['PATH_INFO']);
32 // Generate hash for caching on
33 $hashtext = $_SERVER['REQUEST_URI'];
34 if ($userservice->isLoggedOn()) {
35 $hashtext .= $userservice->getCurrentUserID();
36 $currentUser = $userservice->getCurrentUser();
37 $currentUsername = $currentUser[$userservice->getFieldName('username')];
38 if ($currentUsername == $user) {
42 $hash = md5($hashtext);
45 $cacheservice->Start($hash, 3600);
49 if ($user && $user != 'all') {
50 if ($user == 'watchlist') {
56 $userid = intval($user);
58 if ($userinfo = $userservice->getUserByUsername($user)) {
59 $userid =& $userinfo[$userservice->getFieldName('primary')];
61 $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
62 $templateservice->loadTemplate('error.404.tpl', $tplVars);
67 $pagetitle .= ": ". $user;
73 $pagetitle .= ": ". str_replace('+', ' + ', $cat);
76 $tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : ''));
77 $tplVars['feedlink'] = $GLOBALS['root'];
78 $tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
80 $bookmarks =& $bookmarkservice->getBookmarks(0, 15, $userid, $cat, NULL, getSortOrder(), $watchlist);
81 $bookmarks_tmp =& filter($bookmarks['bookmarks']);
83 $bookmarks_tpl = array();
84 foreach(array_keys($bookmarks_tmp) as $key) {
85 $row =& $bookmarks_tmp[$key];
87 $_link = $row['bAddress'];
89 if ($GLOBALS['useredir']) {
90 $_link = $GLOBALS['url_redir'] . $_link;
92 $_pubdate = date("r", strtotime($row['bDatetime']));
93 // array_walk($row['tags'], 'filter');
95 $bookmarks_tpl[] = array(
96 'title' => $row['bTitle'],
98 'description' => $row['bDescription'],
99 'creator' => $row['username'],
100 'pubdate' => $_pubdate,
101 'tags' => $row['tags']
104 unset($bookmarks_tmp);
106 $tplVars['bookmarks'] =& $bookmarks_tpl;
108 $templateservice->loadTemplate('rss.tpl', $tplVars);
111 // Cache output if existing copy has expired
112 $cacheservice->End($hash);