3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 * This file is a part of Codendi.
7 * Codendi 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 * Codendi 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 Codendi. If not, see <http://www.gnu.org/licenses/>.
21 require_once 'Widget.class.php';
22 require_once $gfcommon.'include/plugins_utils.php';
30 class Widget_MyBookmarks extends Widget {
31 function __construct() {
32 $this->Widget('mybookmarks');
36 return _("My Bookmarks");
39 function getContent() {
40 $html_my_bookmarks = '';
41 $result = db_query_params("SELECT bookmark_url, bookmark_title, bookmark_id from user_bookmarks where ".
42 "user_id=$1 ORDER BY bookmark_title",array( user_getid() ));
43 $rows = db_numrows($result);
44 if (!$result || $rows < 1) {
45 $html_my_bookmarks .= '<div class="warning">'. _("You currently do not have any bookmarks saved") .'</div>';
46 $html_my_bookmarks .= db_error();
48 $html_my_bookmarks .= '<table style="width:100%">';
49 for ($i=0; $i<$rows; $i++) {
50 $html_my_bookmarks .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td>';
51 $html_my_bookmarks .= '<a href="'. db_result($result,$i,'bookmark_url') .'">'. db_result($result,$i,'bookmark_title') .'</a> ';
52 $html_my_bookmarks .= '<small><a href="/my/bookmark_edit.php?bookmark_id='. db_result($result,$i,'bookmark_id') .'">['._("Edit").']</a></small></td>';
53 $html_my_bookmarks .= '<td style="text-align:right"><a href="/my/bookmark_delete.php?bookmark_id='. db_result($result,$i,'bookmark_id');
54 $html_my_bookmarks .= '" onClick="return confirm(\''._("Delete this bookmark?").'\')">';
55 $html_my_bookmarks .= '<img src="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" height="16" width="16" border="0" alt="DELETE" /></a></td></tr>';
57 $html_my_bookmarks .= '</table>';
59 $html_my_bookmarks .= '<div style="text-align:center; font-size:0.8em;"><a href="/my/bookmark_add.php">['. _("Add a bookmark") .']</a></div>';
60 return $html_my_bookmarks;
63 function getDescription() {
64 return sprintf(_('List your favorite bookmarks (your favorite pages in %1$s or external).<br />Note that in many cases %1$s uses URL with enough embedded information to bookmark sophisticated items like Software Map browsing, typical search in your project Bug or Task database, etc. <br />Bookmarked items can be edited which means that both the title of the bookmark and its destination URL can be modified.'), forge_get_config('forge_name'));