2 /***************************************************************************
3 Copyright (c) 2005 - 2006 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';
24 if (isset($_POST['terms'])) {
26 header('Location: '. createURL('search', $_POST['range'] .'/'. filter($_POST['terms'], 'url')));
30 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
31 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
32 $userservice =& ServiceFactory::getServiceInstance('UserService');
34 $logged_on_userid = $userservice->getCurrentUserId();
35 list($url, $range, $terms, $page) = explode('/', $_SERVER['PATH_INFO']);
38 $tplVars['loadjs'] = true;
41 $perpage = getPerPageCount();
42 if (isset($_GET['page']) && intval($_GET['page']) > 1) {
43 $page = $_GET['page'];
44 $start = ($page - 1) * $perpage;
56 if (is_null($terms)) {
57 $tplVars['subtitle'] = T_('Search Bookmarks');
58 $s_start = date('Y-m-d H:i:s', strtotime($dtend .' -'. $defaultRecentDays .' days'));
59 $s_end = date('Y-m-d H:i:s', strtotime('tomorrow'));
63 $tplVars['subtitle'] = T_('Search Results');
64 $selected = ' selected="selected"';
68 $tplVars['select_all'] = $selected;
72 $tplVars['select_watchlist'] = $selected;
73 $s_user = $logged_on_userid;
82 if (is_numeric($s_user)) {
83 $s_user = intval($s_user);
85 if (!($userinfo = $userservice->getUserByUsername($s_user) ) ) {
86 $tplVars['error'] = sprintf(T_('User with username %s was not found'), $s_user);
87 $templateservice->loadTemplate('error.404.tpl', $tplVars);
90 $s_user =& $userinfo[$userservice->getFieldName('primary')];
95 $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $s_user, NULL, $terms, getSortOrder(), $s_watchlist, $s_start, $s_end);
97 $tplVars['page'] = $page;
98 $tplVars['start'] = $start;
99 $tplVars['popCount'] = 25;
100 $tplVars['sidebar_blocks'] = array('recent');
101 $tplVars['range'] = $range;
102 $tplVars['terms'] = $terms;
103 $tplVars['pagetitle'] = T_('Search Bookmarks');
104 $tplVars['bookmarkCount'] = $start + 1;
105 $tplVars['total'] = $bookmarks['total'];
106 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
107 $tplVars['cat_url'] = createURL('tags', '%2$s');
108 $tplVars['nav_url'] = createURL('search', $range .'/'. $terms .'/%3$s');
110 $templateservice->loadTemplate('bookmarks.tpl', $tplVars);