| 1 | <?php |
|---|
| 2 | /*
|
|---|
| 3 |
|
|---|
| 4 | This file is part of omCollab.
|
|---|
| 5 |
|
|---|
| 6 | Copyright (c) 2008 omCollab (Openmethodology Project)
|
|---|
| 7 | http://www.openmethodology.org
|
|---|
| 8 | http://mike2.openmethodology.org/wiki/OmCollab
|
|---|
| 9 |
|
|---|
| 10 | And parts copyright of Scuttle project
|
|---|
| 11 | (http://sourceforge.net/projects/scuttle/, http://scuttle.org/)
|
|---|
| 12 |
|
|---|
| 13 | omCollab is free software: you can redistribute it and/or modify
|
|---|
| 14 | it under the terms of the GNU General Public License as published by
|
|---|
| 15 | the Free Software Foundation, either version 3 of the License, or
|
|---|
| 16 | (at your option) any later version.
|
|---|
| 17 |
|
|---|
| 18 | omCollab is distributed in the hope that it will be useful,
|
|---|
| 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 21 | GNU General Public License for more details.
|
|---|
| 22 |
|
|---|
| 23 | */
|
|---|
| 24 |
|
|---|
| 25 | require_once('header.inc.php'); |
|---|
| 26 | $templateservice =& ServiceFactory::getServiceInstance('TemplateService'); |
|---|
| 27 | $tagservice =& ServiceFactory::getServiceInstance('TagService'); |
|---|
| 28 | $userservice =& ServiceFactory::getServiceInstance('UserService'); |
|---|
| 29 | $cacheservice =& ServiceFactory::getServiceInstance('CacheService'); |
|---|
| 30 | |
|---|
| 31 | list($url, $user) = explode('/', $_SERVER['PATH_INFO']); |
|---|
| 32 | |
|---|
| 33 | if ($userservice->isLoggedOn()) $logged_on_userid = $userservice->getCurrentUserID();
|
|---|
| 34 |
|
|---|
| 35 | if ($usecache) { |
|---|
| 36 | // Generate hash for caching on |
|---|
| 37 | $hashtext = $_SERVER['REQUEST_URI']; |
|---|
| 38 | if ($userservice->isLoggedOn()) {
|
|---|
| 39 | $hashtext .= $logged_on_userid; |
|---|
| 40 | $currentUser = $userservice->getCurrentUser(); |
|---|
| 41 | $currentUsername = $currentUser[$userservice->getFieldName('username')]; |
|---|
| 42 | if ($currentUsername == $user) { |
|---|
| 43 | $hashtext .= $user; |
|---|
| 44 | } |
|---|
| 45 | } |
|---|
| 46 | $hash = md5($hashtext); |
|---|
| 47 | |
|---|
| 48 | // Cache for an hour |
|---|
| 49 | $cacheservice->Start($hash, 3600); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | // Header variables |
|---|
| 53 | $tplvars = array(); |
|---|
| 54 | $tplVars['sidebar_blocks'] = array('profile', 'partners'); |
|---|
| 55 |
|
|---|
| 56 | $pagetitle = T_('Popular Tags'); |
|---|
| 57 |
|
|---|
| 58 | if (isset($user) && $user != '') { |
|---|
| 59 | if (is_int($user)) { |
|---|
| 60 | $userid = intval($user); |
|---|
| 61 | } else { |
|---|
| 62 | if ($userinfo = $userservice->getUserByUsername($user)) { |
|---|
| 63 | $userid =& $userinfo[$userservice->getFieldName('primary')]; |
|---|
| 64 | } else { |
|---|
| 65 | $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user); |
|---|
| 66 | $templateservice->loadTemplate('error.404.tpl', $tplVars); |
|---|
| 67 | //throw a 404 error |
|---|
| 68 | exit(); |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | $pagetitle .= ': '. ucfirst($user); |
|---|
| 72 | } else { |
|---|
| 73 | $userid = NULL; |
|---|
| 74 | } |
|---|
| 75 |
|
|---|
| 76 | $bIsAdmin = $userservice->isAdmin($logged_on_userid);
|
|---|
| 77 | if( $bIsAdmin ){
|
|---|
| 78 | $tags = $tagservice->getTags();
|
|---|
| 79 | $tplVars['bLoadJqueryPhp'] = true;
|
|---|
| 80 | }else{
|
|---|
| 81 | $tags = $tagservice->getPopularTags( $userid, 30, $logged_on_userid );
|
|---|
| 82 | } |
|---|
| 83 | $tplVars['tags'] =& $tagservice->tagCloud($tags, 5, 90, 225, getSortOrder('alphabet_asc')); |
|---|
| 84 | $tplVars['user'] = $user;
|
|---|
| 85 | $tplVars['bIsAdmin'] = $bIsAdmin;
|
|---|
| 86 | |
|---|
| 87 | if (isset($userid)) { |
|---|
| 88 | $tplVars['cat_url'] = createURL('bookmarks', '%s/%s'); |
|---|
| 89 | } else { |
|---|
| 90 | $tplVars['cat_url'] = createURL('tags', '%2$s'); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | $tplVars['subtitle'] = $pagetitle; |
|---|
| 94 | $templateservice->loadTemplate('tags.tpl', $tplVars); |
|---|
| 95 | |
|---|
| 96 | if ($usecache) { |
|---|
| 97 | // Cache output if existing copy has expired |
|---|
| 98 | $cacheservice->End($hash); |
|---|
| 99 | } |
|---|
| 100 | ?> |
|---|