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');
29 @list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
31 header('Location: '. createURL('populartags'));
36 // Generate hash for caching on
37 $hashtext = $_SERVER['REQUEST_URI'];
38 if ($userservice->isLoggedOn()) {
39 $hashtext .= $userservice->getCurrentUserID();
41 $hash = md5($hashtext);
44 $cacheservice->Start($hash, 3600);
49 $pagetitle = T_('All Tags');
51 if (isset($user) && $user != '') {
53 $userid = intval($user);
55 if ($userinfo = $userservice->getUserByUsername($user)) {
56 $userid =& $userinfo[$userservice->getFieldName('primary')];
58 $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
59 $templateservice->loadTemplate('error.404.tpl', $tplVars);
64 $pagetitle .= ': '. ucfirst($user);
69 $tags =& $tagservice->getTags($userid);
70 $tplVars['tags'] =& $tagservice->tagCloud($tags, 5, 90, 225, getSortOrder());
71 $tplVars['user'] = $user;
74 $tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
76 $tplVars['cat_url'] = createURL('tags', '%2$s');
79 $tplVars['subtitle'] = $pagetitle;
80 $templateservice->loadTemplate('tags.tpl', $tplVars);
83 // Cache output if existing copy has expired
84 $cacheservice->End($hash);