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 ***************************************************************************/
20 require_once 'header.inc.php';
22 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
23 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
24 $userservice =& ServiceFactory::getServiceInstance('UserService');
25 $cacheservice =& ServiceFactory::getServiceInstance('CacheService');
29 @list($url, $user, $page) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
32 if ($userservice->isLoggedOn()) {
34 $currentUser = $userservice->getCurrentUser();
35 $currentUsername = $currentUser[$userservice->getFieldName('username')];
39 // Generate hash for caching on
41 if ($currentUsername != $user) {
42 $cachehash = md5($_SERVER['REQUEST_URI'] . $currentUsername);
44 // Cache for 5 minutes
45 $cacheservice->Start($cachehash);
48 // Cache for 30 minutes
49 $cachehash = md5($_SERVER['REQUEST_URI']);
50 $cacheservice->Start($cachehash, 1800);
56 $userid = intval($user);
58 if (!($userinfo = $userservice->getUserByUsername($user) ) ) {
60 $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
61 $templateservice->loadTemplate('error.404.tpl', $tplVars);
64 $userid =& $userinfo['uId'];
70 $tplVars['loadjs'] = true;
73 $tplVars['user'] = $user;
74 $tplVars['userid'] = $userid;
75 $tplVars['userinfo'] =& $userinfo;
78 $perpage = getPerPageCount();
79 if (isset($_GET['page']) && intval($_GET['page']) > 1) {
80 $page = $_GET['page'];
81 $start = ($page - 1) * $perpage;
88 $tplVars['page'] = $page;
89 $tplVars['start'] = $start;
90 $tplVars['bookmarkCount'] = $start + 1;
92 $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, NULL, NULL, getSortOrder(), true);
94 $tplVars['sidebar_blocks'] = array('watchlist');
95 $tplVars['watched'] = true;
96 $tplVars['total'] = $bookmarks['total'];
97 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
98 $tplVars['cat_url'] = createURL('tags', '%2$s');
99 $tplVars['nav_url'] = createURL('watchlist', '%s/%s%s');
101 if ($user == $currentUsername) {
102 $title = T_('My Watchlist');
104 $title = T_('Watchlist') .': '. $user;
106 $tplVars['pagetitle'] = $title;
107 $tplVars['subtitle'] = $title;
109 $tplVars['rsschannels'] = array(
110 array(filter($sitename .': '. $title), createURL('rss', 'watchlist/'. filter($user, 'url')))
113 $templateservice->loadTemplate('bookmarks.tpl', $tplVars);
115 $tplVars['error'] = T_('Username was not specified');
116 $templateservice->loadTemplate('error.404.tpl', $tplVars);
121 // Cache output if existing copy has expired
122 $cacheservice->End($hash);