2 /***************************************************************************
3 Copyright (C) 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');
24 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
25 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
26 $userservice =& ServiceFactory::getServiceInstance('UserService');
27 $cacheservice =& ServiceFactory::getServiceInstance('CacheService');
31 @list($url, $hash) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
34 if ($userservice->isLoggedOn()) {
36 $currentUser = $userservice->getCurrentUser();
37 $currentUsername = $currentUser[$userservice->getFieldName('username')];
41 // Generate hash for caching on
42 $hashtext = $_SERVER['REQUEST_URI'];
43 if ($userservice->isLoggedOn()) {
44 $hashtext .= $currentUsername;
46 $cachehash = md5($hashtext);
48 // Cache for 30 minutes
49 $cacheservice->Start($cachehash, 1800);
53 $perpage = getPerPageCount();
54 if (isset($_GET['page']) && intval($_GET['page']) > 1) {
55 $page = $_GET['page'];
56 $start = ($page - 1) * $perpage;
62 if ($bookmark =& $bookmarkservice->getBookmarkByHash($hash)) {
64 $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, NULL, NULL, getSortOrder(), NULL, NULL, NULL, $hash);
65 $tplVars['pagetitle'] = T_('History') .': '. $bookmark['bAddress'];
66 $tplVars['subtitle'] = sprintf(T_('History for %s'), $bookmark['bAddress']);
67 $tplVars['loadjs'] = true;
68 $tplVars['page'] = $page;
69 $tplVars['start'] = $start;
70 $tplVars['bookmarkCount'] = $start + 1;
71 $tplVars['total'] = $bookmarks['total'];
72 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
73 $tplVars['hash'] = $hash;
74 $tplVars['popCount'] = 50;
75 $tplVars['sidebar_blocks'] = array('common');
76 $tplVars['cat_url'] = createURL('tags', '%2$s');
77 $tplVars['nav_url'] = createURL('history', $hash .'/%3$s');
78 $templateservice->loadTemplate('bookmarks.tpl', $tplVars);
81 $tplVars['error'] = T_('Address was not found');
82 $templateservice->loadTemplate('error.404.tpl', $tplVars);
87 // Cache output if existing copy has expired
88 $cacheservice->End($cachehash);