2 /***************************************************************************
3 Copyright (C) 2004 - 2010 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';
23 $sf = new ServiceFactory();
24 $bookmarkservice =& $sf->getServiceInstance('BookmarkService');
25 $templateservice =& $sf->getServiceInstance('TemplateService');
26 $userservice =& $sf->getServiceInstance('UserService');
27 $cacheservice =& $sf->getServiceInstance('CacheService');
30 header('Content-Type: application/xml');
31 list($url, $user, $cat) = explode('/', $_SERVER['PATH_INFO']);
34 // Generate hash for caching on
35 $hashtext = $_SERVER['REQUEST_URI'];
36 if ($userservice->isLoggedOn()) {
37 $hashtext .= $userservice->getCurrentUserID();
38 $currentUser = $userservice->getCurrentUser();
39 $currentUsername = $currentUser[$userservice->getFieldName('username')];
40 if ($currentUsername == $user) {
44 $hash = md5($hashtext);
47 $cacheservice->Start($hash, 3600);
51 if ($user && $user != 'all') {
52 if ($user == 'watchlist') {
58 $userid = intval($user);
60 if ($userinfo = $userservice->getUserByUsername($user)) {
61 $userid =& $userinfo[$userservice->getFieldName('primary')];
63 $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
64 $templateservice->loadTemplate('error.404.tpl', $tplVars);
69 $pagetitle .= ": ". $user;
75 $pagetitle .= ": ". str_replace('+', ' + ', $cat);
78 $tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : ''));
79 $tplVars['feedlink'] = $GLOBALS['root'];
80 $tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
82 $bookmarks =& $bookmarkservice->getBookmarks(0, 15, $userid, $cat, NULL, getSortOrder(), $watchlist);
83 $bookmarks_tmp =& filter($bookmarks['bookmarks']);
85 $bookmarks_tpl = array();
86 foreach(array_keys($bookmarks_tmp) as $key) {
87 $row =& $bookmarks_tmp[$key];
89 $_link = $row['bAddress'];
91 if ($GLOBALS['useredir']) {
92 $_link = $GLOBALS['url_redir'] . $_link;
94 $_pubdate = date("r", strtotime($row['bDatetime']));
96 $uriparts = explode('.', $_link);
97 $extension = end($uriparts);
100 $enclosure = array();
101 if ($keys = multi_array_search($extension, $GLOBALS['filetypes'])) {
102 $enclosure['mime'] = file_get_mimetype($_link);
103 $enclosure['length'] = file_get_filesize($_link);
106 $bookmarks_tpl[] = array(
107 'title' => $row['bTitle'],
109 'description' => $row['bDescription'],
110 'creator' => $row['username'],
111 'pubdate' => $_pubdate,
112 'tags' => $row['tags'],
113 'enclosure_mime' => $enclosure['mime'],
114 'enclosure_length' => $enclosure['length']
117 unset($bookmarks_tmp);
119 $tplVars['bookmarks'] =& $bookmarks_tpl;
121 $templateservice->loadTemplate('rss.tpl', $tplVars);
124 // Cache output if existing copy has expired
125 $cacheservice->End($hash);