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 ***************************************************************************/
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, $cat) = explode('/', $_SERVER['PATH_INFO']);
32 header('Location: '. createURL('populartags'));
35 $cattitle = str_replace('+', ' + ', $cat);
37 $pagetitle = T_('Tags') .': '. $cattitle;
40 // Generate hash for caching on
41 if ($userservice->isLoggedOn()) {
42 $hash = md5($_SERVER['REQUEST_URI'] . $userservice->getCurrentUserID());
44 $hash = md5($_SERVER['REQUEST_URI']);
47 // Cache for 30 minutes
48 $cacheservice->Start($hash, 1800);
52 $tplVars['pagetitle'] = $pagetitle;
53 $tplVars['loadjs'] = true;
54 $tplVars['rsschannels'] = array(
55 array(filter($sitename .': '. $pagetitle), createURL('rss', 'all/'. filter($cat, 'url')))
59 $perpage = getPerPageCount();
60 if (isset($_GET['page']) && intval($_GET['page']) > 1) {
61 $page = $_GET['page'];
62 $start = ($page - 1) * $perpage;
68 $tplVars['page'] = $page;
69 $tplVars['start'] = $start;
70 $tplVars['popCount'] = 25;
71 $tplVars['currenttag'] = $cat;
72 $tplVars['sidebar_blocks'] = array('related', 'popular');
73 $tplVars['subtitle'] = filter($pagetitle);
74 $tplVars['bookmarkCount'] = $start + 1;
75 $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, $cat, NULL, getSortOrder());
76 $tplVars['total'] = $bookmarks['total'];
77 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
78 $tplVars['cat_url'] = createURL('tags', '%2$s');
79 $tplVars['nav_url'] = createURL('tags', '%2$s%3$s');
81 $templateservice->loadTemplate('bookmarks.tpl', $tplVars);
84 // Cache output if existing copy has expired
85 $cacheservice->End($hash);