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 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
24 $tagservice =& ServiceFactory::getServiceInstance('TagService');
25 $userservice =& ServiceFactory::getServiceInstance('UserService');
26 $cacheservice =& ServiceFactory::getServiceInstance('CacheService');
28 list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
30 header('Location: '. createURL('populartags'));
35 // Generate hash for caching on
36 $hashtext = $_SERVER['REQUEST_URI'];
37 if ($userservice->isLoggedOn()) {
38 $hashtext .= $userservice->getCurrentUserID();
40 $hash = md5($hashtext);
43 $cacheservice->Start($hash, 3600);
48 $pagetitle = T_('All Tags');
50 if (isset($user) && $user != '') {
52 $userid = intval($user);
54 if ($userinfo = $userservice->getUserByUsername($user)) {
55 $userid =& $userinfo[$userservice->getFieldName('primary')];
57 $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
58 $templateservice->loadTemplate('error.404.tpl', $tplVars);
63 $pagetitle .= ': '. ucfirst($user);
68 $tags =& $tagservice->getTags($userid);
69 $tplVars['tags'] =& $tagservice->tagCloud($tags, 5, 90, 225, getSortOrder());
70 $tplVars['user'] = $user;
73 $tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
75 $tplVars['cat_url'] = createURL('tags', '%2$s');
78 $tplVars['subtitle'] = $pagetitle;
79 $templateservice->loadTemplate('tags.tpl', $tplVars);
82 // Cache output if existing copy has expired
83 $cacheservice->End($hash);