source: trunk/bookmarks/history.php @ 103

Revision 103, 3.0 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
27$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
28$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
29$userservice =& ServiceFactory::getServiceInstance('UserService');
30$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
31
32$tplVars = array();
33
34@list($url, $hash) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
35
36$loggedon = false;
37if ($userservice->isLoggedOn()) {
38    $loggedon = true;
39    $currentUser = $userservice->getCurrentUser();
40    $currentUsername = $currentUser[$userservice->getFieldName('username')];
41}
42
43if ($usecache) {
44    // Generate hash for caching on
45    $hashtext = $_SERVER['REQUEST_URI'];
46    if ($userservice->isLoggedOn()) {
47        $hashtext .= $currentUsername;
48    }
49    $cachehash = md5($hashtext);
50
51    // Cache for 30 minutes
52    $cacheservice->Start($cachehash, 1800);
53}
54
55// Pagination
56$perpage = getPerPageCount();
57if (isset($_GET['page']) && intval($_GET['page']) > 1) {
58    $page = $_GET['page'];
59    $start = ($page - 1) * $perpage;
60} else {
61    $page = 0;
62    $start = 0;
63}
64
65if ($bookmark =& $bookmarkservice->getBookmarkByHash($hash)) {
66    // Template variables
67    $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, NULL, NULL, getSortOrder(), NULL, NULL, NULL, $hash);
68    $tplVars['pagetitle'] = T_('History') .': '. $bookmark['bAddress'];
69    $tplVars['subtitle'] = sprintf(T_('History for %s'), $bookmark['bAddress']);
70    $tplVars['loadjs'] = true;
71    $tplVars['page'] = $page;
72    $tplVars['start'] = $start;
73    $tplVars['bookmarkCount'] = $start + 1;
74    $tplVars['total'] = $bookmarks['total'];
75    $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
76    $tplVars['hash'] = $hash;
77    $tplVars['popCount'] = 50;
78    $tplVars['sidebar_blocks'] = array('profile', 'common', 'partners');
79    $tplVars['cat_url'] = createURL('tags', '%2$s');
80    $tplVars['nav_url'] = createURL('history', $hash .'/%3$s');
81    $templateservice->loadTemplate('bookmarks.tpl', $tplVars);
82} else {
83    // Throw a 404 error
84    $tplVars['error'] = T_('Address was not found');
85    $templateservice->loadTemplate('error.404.tpl', $tplVars);
86    exit();
87}
88
89if ($usecache) {
90    // Cache output if existing copy has expired
91    $cacheservice->End($cachehash);
92}
93?>
Note: See TracBrowser for help on using the repository browser.