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 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
25 $userservice =& ServiceFactory::getServiceInstance('UserService');
26 $cacheservice =& ServiceFactory::getServiceInstance('CacheService');
29 if (isset($_GET['action'])){
30 if ($_GET['action'] == "logout") {
31 $userservice->logout($path);
32 $tplvars['msg'] = T_('You have now logged out');
37 $tplVars['loadjs'] = true;
38 $tplVars['rsschannels'] = array(
39 array(sprintf(T_('%s: Recent bookmarks'), $sitename), createURL('rss'))
43 // Generate hash for caching on
44 $hashtext = $_SERVER['REQUEST_URI'];
45 if ($userservice->isLoggedOn()) {
46 $hashtext .= $userservice->getCurrentUserID();
48 $hash = md5($hashtext);
50 // Cache for 15 minutes
51 $cacheservice->Start($hash, 900);
55 $perpage = getPerPageCount();
56 if (isset($_GET['page']) && intval($_GET['page']) > 1) {
57 $page = $_GET['page'];
58 $start = ($page - 1) * $perpage;
64 $dtend = date('Y-m-d H:i:s', strtotime('tomorrow'));
65 $dtstart = date('Y-m-d H:i:s', strtotime($dtend .' -'. $defaultRecentDays .' days'));
67 $tplVars['page'] = $page;
68 $tplVars['start'] = $start;
69 $tplVars['popCount'] = 30;
70 $tplVars['sidebar_blocks'] = array('recent');
71 $tplVars['range'] = 'all';
72 $tplVars['pagetitle'] = T_('Store, share and tag your favourite links');
73 $tplVars['subtitle'] = T_('Recent Bookmarks');
74 $tplVars['bookmarkCount'] = $start + 1;
75 $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, NULL, NULL, getSortOrder(), NULL, $dtstart, $dtend);
76 $tplVars['total'] = $bookmarks['total'];
77 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
78 $tplVars['cat_url'] = createURL('tags', '%2$s');
79 $tplVars['nav_url'] = createURL('index', '%3$s');
81 $templateservice->loadTemplate('bookmarks.tpl', $tplVars);
84 // Cache output if existing copy has expired
85 $cacheservice->End($hash);