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 ***************************************************************************/
21 require_once('header.inc.php');
23 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
24 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
25 $userservice =& ServiceFactory::getServiceInstance('UserService');
26 $cacheservice =& ServiceFactory::getServiceInstance('CacheService');
30 @list($url, $user, $page) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
33 if ($userservice->isLoggedOn()) {
35 $currentUser = $userservice->getCurrentUser();
36 $currentUsername = $currentUser[$userservice->getFieldName('username')];
40 // Generate hash for caching on
42 if ($currentUsername != $user) {
43 $cachehash = md5($_SERVER['REQUEST_URI'] . $currentUsername);
45 // Cache for 5 minutes
46 $cacheservice->Start($cachehash);
49 // Cache for 30 minutes
50 $cachehash = md5($_SERVER['REQUEST_URI']);
51 $cacheservice->Start($cachehash, 1800);
57 $userid = intval($user);
59 if (!($userinfo = $userservice->getUserByUsername($user) ) ) {
61 $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
62 $templateservice->loadTemplate('error.404.tpl', $tplVars);
65 $userid =& $userinfo['uId'];
71 $tplVars['loadjs'] = true;
74 $tplVars['user'] = $user;
75 $tplVars['userid'] = $userid;
76 $tplVars['userinfo'] =& $userinfo;
79 $perpage = getPerPageCount();
80 if (isset($_GET['page']) && intval($_GET['page']) > 1) {
81 $page = $_GET['page'];
82 $start = ($page - 1) * $perpage;
89 $tplVars['page'] = $page;
90 $tplVars['start'] = $start;
91 $tplVars['bookmarkCount'] = $start + 1;
93 $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, NULL, NULL, getSortOrder(), true);
95 $tplVars['sidebar_blocks'] = array('watchlist');
96 $tplVars['watched'] = true;
97 $tplVars['total'] = $bookmarks['total'];
98 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
99 $tplVars['cat_url'] = createURL('tags', '%2$s');
100 $tplVars['nav_url'] = createURL('watchlist', '%s/%s%s');
102 if ($user == $currentUsername) {
103 $title = T_('My Watchlist');
105 $title = T_('Watchlist') .': '. $user;
107 $tplVars['pagetitle'] = $title;
108 $tplVars['subtitle'] = $title;
110 $tplVars['rsschannels'] = array(
111 array(filter($sitename .': '. $title), createURL('rss', 'watchlist/'. filter($user, 'url')))
114 $templateservice->loadTemplate('bookmarks.tpl', $tplVars);
116 $tplVars['error'] = T_('Username was not specified');
117 $templateservice->loadTemplate('error.404.tpl', $tplVars);
122 // Cache output if existing copy has expired
123 $cacheservice->End($hash);