source: trunk/bookmarks/alltags.php @ 103

Revision 103, 2.6 KB checked in by admin, 4 years ago (diff)

Merged 1.003 into Trunk

Line 
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
25require_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
31list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
32if (!$user) {
33    header('Location: '. createURL('populartags'));
34    exit;
35}
36
37if ($usecache) {
38    // Generate hash for caching on
39    $hashtext = $_SERVER['REQUEST_URI'];
40    if ($userservice->isLoggedOn()) {
41        $hashtext .= $userservice->getCurrentUserID();
42    }
43    $hash = md5($hashtext);
44
45    // Cache for an hour
46    $cacheservice->Start($hash, 3600);
47}
48
49// Header variables
50$tplvars = array();
51$pagetitle = T_('All Tags');
52
53if (isset($user) && $user != '') {
54    if (is_int($user)) {
55      $userid = intval($user);
56    } else {
57        if ($userinfo = $userservice->getUserByUsername($user)) {
58            $userid =& $userinfo[$userservice->getFieldName('primary')];
59        } else {
60            $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
61            $templateservice->loadTemplate('error.404.tpl', $tplVars);
62            //throw a 404 error
63            exit();
64        }
65    }
66    $pagetitle .= ': '. ucfirst($user);
67} else {
68    $userid = NULL;
69}
70
71$tags =& $tagservice->getTags($userid);
72$tplVars['tags'] =& $tagservice->tagCloud($tags, 5, 90, 225, getSortOrder());
73$tplVars['user'] = $user;
74
75if (isset($userid)) {
76    $tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
77} else {
78    $tplVars['cat_url'] = createURL('tags', '%2$s');
79}
80
81$tplVars['subtitle'] = $pagetitle;
82$templateservice->loadTemplate('tags.tpl', $tplVars);
83
84if ($usecache) {
85    // Cache output if existing copy has expired
86    $cacheservice->End($hash);
87}
88?>
Note: See TracBrowser for help on using the repository browser.