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 if (isset($_GET['action']) && 'logout' == $_GET['action']) {
31 $userservice->logout($path);
32 $tplvars['msg'] = T_('You have now logged out');
36 $tplVars['loadjs'] = true;
37 $tplVars['rsschannels'] = array(
38 array(sprintf(T_('%s: Recent bookmarks'), $sitename), createURL('rss'))
42 // Generate hash for caching on
43 $hashtext = $_SERVER['REQUEST_URI'];
44 if ($userservice->isLoggedOn()) {
45 $hashtext .= $userservice->getCurrentUserID();
47 $hash = md5($hashtext);
49 // Cache for 15 minutes
50 $cacheservice->Start($hash, 900);
54 $perpage = getPerPageCount();
57 $tplVars['start'] = 0;
58 $tplVars['popCount'] = 30;
59 $tplVars['sidebar_blocks'] = array('recent');
60 $tplVars['range'] = 'all';
61 $tplVars['pagetitle'] = T_('Store, share and tag your favourite links');
62 $tplVars['subtitle'] = T_('Recent Bookmarks');
63 $tplVars['bookmarkCount'] = 1;
64 $bookmarks =& $bookmarkservice->getBookmarks(0, $perpage, NULL, NULL, NULL, getSortOrder(), NULL);
65 $tplVars['total'] = $bookmarks['total'];
66 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
67 $tplVars['cat_url'] = createURL('tags', '%2$s');
68 $tplVars['nav_url'] = createURL('index', '%3$s');
70 $templateservice->loadTemplate('bookmarks.tpl', $tplVars);
73 // Cache output if existing copy has expired
74 $cacheservice->End($hash);