2 /***************************************************************************
3 Copyright (c) 2005 - 2006 Scuttle project
4 http://sourceforge.net/projects/scuttle/
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ***************************************************************************/
22 require_once('header.inc.php');
25 if (isset($_POST['terms'])) {
27 header('Location: '. createURL('search', $_POST['range'] .'/'. filter($_POST['terms'], 'url')));
31 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
32 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
33 $userservice =& ServiceFactory::getServiceInstance('UserService');
35 $logged_on_userid = $userservice->getCurrentUserId();
36 list($url, $range, $terms, $page) = explode('/', $_SERVER['PATH_INFO']);
39 $tplVars['loadjs'] = true;
42 $perpage = getPerPageCount();
43 if (isset($_GET['page']) && intval($_GET['page']) > 1) {
44 $page = $_GET['page'];
45 $start = ($page - 1) * $perpage;
57 if (is_null($terms)) {
58 $tplVars['subtitle'] = T_('Search Bookmarks');
59 $s_start = date('Y-m-d H:i:s', strtotime($dtend .' -'. $defaultRecentDays .' days'));
60 $s_end = date('Y-m-d H:i:s', strtotime('tomorrow'));
64 $tplVars['subtitle'] = T_('Search Results');
65 $selected = ' selected="selected"';
69 $tplVars['select_all'] = $selected;
73 $tplVars['select_watchlist'] = $selected;
74 $s_user = $logged_on_userid;
83 if (is_numeric($s_user)) {
84 $s_user = intval($s_user);
86 if (!($userinfo = $userservice->getUserByUsername($s_user) ) ) {
87 $tplVars['error'] = sprintf(T_('User with username %s was not found'), $s_user);
88 $templateservice->loadTemplate('error.404.tpl', $tplVars);
91 $s_user =& $userinfo[$userservice->getFieldName('primary')];
96 $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $s_user, NULL, $terms, getSortOrder(), $s_watchlist, $s_start, $s_end);
98 $tplVars['page'] = $page;
99 $tplVars['start'] = $start;
100 $tplVars['popCount'] = 25;
101 $tplVars['sidebar_blocks'] = array('recent');
102 $tplVars['range'] = $range;
103 $tplVars['terms'] = $terms;
104 $tplVars['pagetitle'] = T_('Search Bookmarks');
105 $tplVars['bookmarkCount'] = $start + 1;
106 $tplVars['total'] = $bookmarks['total'];
107 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
108 $tplVars['cat_url'] = createURL('tags', '%2$s');
109 $tplVars['nav_url'] = createURL('search', $range .'/'. $terms .'/%3$s');
111 $templateservice->loadTemplate('bookmarks.tpl', $tplVars);