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