* Updated isValidEmail regex to match plussed addresses
[scuttle] / tags.php
1 <?php
2 /***************************************************************************
3 Copyright (C) 2004 - 2006 Scuttle project
4 http://sourceforge.net/projects/scuttle/
5 http://scuttle.org/
6
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.
11
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.
16
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 ***************************************************************************/
21
22 require_once('header.inc.php');
23
24 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
25 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
26 $userservice =& ServiceFactory::getServiceInstance('UserService');
27 $cacheservice =& ServiceFactory::getServiceInstance('CacheService');
28
29 $tplVars = array();
30
31 list($url, $cat) = explode('/', $_SERVER['PATH_INFO']);
32 if (!$cat) {
33     header('Location: '. createURL('populartags'));
34     exit;
35 } else {
36     $cattitle = str_replace('+', ' + ', $cat);
37 }
38 $pagetitle = T_('Tags') .': '. $cattitle;
39
40 if ($usecache) {
41     // Generate hash for caching on
42     if ($userservice->isLoggedOn()) {
43         $hash = md5($_SERVER['REQUEST_URI'] . $userservice->getCurrentUserID());
44     } else {
45         $hash = md5($_SERVER['REQUEST_URI']);
46     }
47
48     // Cache for 30 minutes
49     $cacheservice->Start($hash, 1800);
50 }
51
52 // Header variables
53 $tplVars['pagetitle'] = $pagetitle;
54 $tplVars['loadjs'] = true;
55 $tplVars['rsschannels'] = array(
56     array(filter($sitename .': '. $pagetitle), createURL('rss', 'all/'. filter($cat, 'url')))
57 );
58
59 // Pagination
60 $perpage = getPerPageCount();
61 if (isset($_GET['page']) && intval($_GET['page']) > 1) {
62     $page = $_GET['page'];
63     $start = ($page - 1) * $perpage;
64 } else {
65     $page = 0;
66     $start = 0;
67 }
68
69 $tplVars['page'] = $page;
70 $tplVars['start'] = $start;
71 $tplVars['popCount'] = 25;
72 $tplVars['currenttag'] = $cat;
73 $tplVars['sidebar_blocks'] = array('related', 'popular');
74 $tplVars['subtitle'] = filter($pagetitle);
75 $tplVars['bookmarkCount'] = $start + 1;
76 $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, $cat, NULL, getSortOrder());
77 $tplVars['total'] = $bookmarks['total'];
78 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
79 $tplVars['cat_url'] = createURL('tags', '%2$s');
80 $tplVars['nav_url'] = createURL('tags', '%2$s%3$s');
81
82 $templateservice->loadTemplate('bookmarks.tpl', $tplVars);
83
84 if ($usecache) {
85     // Cache output if existing copy has expired
86     $cacheservice->End($hash);
87 }
88 ?>

Benjamin Mako Hill || Want to submit a patch?