From ab4679de45c9608f9a87f90a1093ae3a2ae6559d Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 11 Jun 2010 20:29:38 +0000 Subject: Small code cleanup on bookmarks. Added better logic for determining the username to use when adding a bookmark via the bookmarklet. git-svn-id: http://code.elgg.org/elgg/trunk@6461 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/bookmarks/languages/en.php | 121 ++++++++++----------- mod/bookmarks/start.php | 13 ++- .../views/default/bookmarks/bookmarklet.php | 25 +++-- 3 files changed, 85 insertions(+), 74 deletions(-) (limited to 'mod/bookmarks') diff --git a/mod/bookmarks/languages/en.php b/mod/bookmarks/languages/en.php index 6bdf565ad..6f64e7e16 100644 --- a/mod/bookmarks/languages/en.php +++ b/mod/bookmarks/languages/en.php @@ -6,85 +6,84 @@ $english = array( * Menu items and titles */ - 'bookmarks' => "Bookmarks", - 'bookmarks:add' => "Bookmark something", - 'bookmarks:read' => "Bookmark list", - 'bookmarks:friends' => "Friends' bookmarks", - 'bookmarks:all' => "All site bookmarks", - 'bookmarks:user' => "%s's bookmarks", - 'bookmarks:group' => "Bookmarks", - 'bookmarks:this' => "Bookmark this", - 'bookmarks:ingroup' => "in the group", - 'bookmarks:this:group' => "Bookmark in %s", - 'bookmarks:bookmarklet' => "Get bookmarklet", - 'bookmarks:bookmarklet:group' => "Get community bookmarklet", - 'bookmarks:inbox' => "Bookmarks inbox", - 'bookmarks:more' => "View note", - 'bookmarks:yours' => "My bookmarks", - 'bookmarks:shareditem' => "Bookmarked item", - 'bookmarks:with' => "Share with", - 'bookmarks:new' => "Add a Bookmark", - 'bookmarks:via' => "via bookmarks", - 'bookmarks:address' => "Address of the resource to bookmark", - 'bookmarks:addnote' => "Add a note", - 'bookmarks:delete:confirm' => "Are you sure you want to delete this resource?", - 'bookmarks:url' => 'URL', - 'bookmarks:numbertodisplay' => 'Number of bookmarked items to display', - 'bookmarks:edit:success' => "Bookmark successfully edited", - 'bookmarks:edit:fail' => "There was a problem editing that bookmark, please try again.", - 'bookmarks:shared' => "Bookmarked", - 'bookmarks:visit' => "Visit resource", - 'bookmarks:recent' => "Recent bookmarks", - 'bookmarks:stats' => "Bookmark stats", - 'bookmarks:resources' => "resources bookmarked", - 'bookmarks:river:created' => '%s bookmarked', - 'bookmarks:river:annotate' => 'posted a comment on this bookmarked item', - 'bookmarks:river:item' => 'an item', - - 'item:object:bookmarks' => 'Bookmarked items', - - 'bookmarks:enablebookmarks' => 'Enable group bookmarks', - 'bookmarks:referenceadded' => 'You have added that bookmark as a reference', - 'bookmarks:referenceerror' => 'There was a problem adding that bookmark as a reference', - 'bookmarks:none' => 'You don\'t have any bookmarks', - 'bookmarks:addref' => 'Add a reference', - 'bookmarks:removed' => 'You have now removed that reference', - 'bookmarks:removederror' => ' There was a problem removing that reference', - 'bookmarks:remove:confirm' => 'Are you sure you want to remove this reference?', + 'bookmarks' => "Bookmarks", + 'bookmarks:add' => "Bookmark something", + 'bookmarks:read' => "Bookmark list", + 'bookmarks:friends' => "Friends' bookmarks", + 'bookmarks:all' => "All site bookmarks", + 'bookmarks:user' => "%s's bookmarks", + 'bookmarks:group' => "Bookmarks", + 'bookmarks:this' => "Bookmark this", + 'bookmarks:ingroup' => "in the group", + 'bookmarks:this:group' => "Bookmark in %s", + 'bookmarks:bookmarklet' => "Get bookmarklet", + 'bookmarks:bookmarklet:group' => "Get community bookmarklet", + 'bookmarks:browser_bookmarklet' => 'Browser Bookmarklet', + 'bookmarks:inbox' => "Bookmarks inbox", + 'bookmarks:more' => "View note", + 'bookmarks:yours' => "My bookmarks", + 'bookmarks:shareditem' => "Bookmarked item", + 'bookmarks:with' => "Share with", + 'bookmarks:new' => "Add a Bookmark", + 'bookmarks:via' => "via bookmarks", + 'bookmarks:address' => "Address of the resource to bookmark", + 'bookmarks:addnote' => "Add a note", + 'bookmarks:delete:confirm' => "Are you sure you want to delete this resource?", + 'bookmarks:url' => 'URL', + 'bookmarks:numbertodisplay' => 'Number of bookmarked items to display', + 'bookmarks:edit:success' => "Bookmark successfully edited", + 'bookmarks:edit:fail' => "There was a problem editing that bookmark, please try again.", + 'bookmarks:shared' => "Bookmarked", + 'bookmarks:visit' => "Visit resource", + 'bookmarks:recent' => "Recent bookmarks", + 'bookmarks:stats' => "Bookmark stats", + 'bookmarks:resources' => "resources bookmarked", + 'bookmarks:river:created' => '%s bookmarked', + 'bookmarks:river:annotate' => 'posted a comment on this bookmarked item', + 'bookmarks:river:item' => 'an item', + + 'item:object:bookmarks' => 'Bookmarked items', + + 'bookmarks:enablebookmarks' => 'Enable group bookmarks', + 'bookmarks:referenceadded' => 'You have added that bookmark as a reference', + 'bookmarks:referenceerror' => 'There was a problem adding that bookmark as a reference', + 'bookmarks:none' => 'You don\'t have any bookmarks', + 'bookmarks:addref' => 'Add a reference', + 'bookmarks:removed' => 'You have now removed that reference', + 'bookmarks:removederror' => ' There was a problem removing that reference', + 'bookmarks:remove:confirm' => 'Are you sure you want to remove this reference?', /** * More text */ - - 'bookmarks:widget:description' => - "This widget displays your latest bookmarks.", - 'bookmarks:bookmarklet:description' => - "The bookmarklet allows you to share a url with your friends, or just bookmark it for yourself. To use it, simply drag the button above to your browser's links bar.", + 'bookmarks:widget:description' => + "This widget displays your latest bookmarks.", - 'bookmarks:bookmarklet:descriptionie' => - "If you are using Internet Explorer, you will need to right click on the bookmarklet icon, and select 'add to favorites', and then the Links bar.", + 'bookmarks:bookmarklet:description' => + "The bookmarklet allows you to share a url with your friends, or just bookmark it for yourself. To use it, simply drag the button above to your browser's links bar.", - 'bookmarks:bookmarklet:description:conclusion' => - "You can then bookmark any webpage you visit by clicking the button in your browsers toolbar.", + 'bookmarks:bookmarklet:descriptionie' => + "If you are using Internet Explorer, you will need to right click on the bookmarklet icon, and select 'add to favorites', and then the Links bar.", + + 'bookmarks:bookmarklet:description:conclusion' => + "You can then bookmark any webpage you visit by clicking the button in your browsers toolbar.", /** * Status messages */ - 'bookmarks:save:success' => "Your item was successfully bookmarked.", - 'bookmarks:delete:success' => "Your bookmarked item was successfully deleted.", + 'bookmarks:save:success' => "Your item was successfully bookmarked.", + 'bookmarks:delete:success' => "Your bookmarked item was successfully deleted.", /** * Error messages */ - 'bookmarks:save:failed' => "Your bookmarked item could not be saved. Please try again.", - 'bookmarks:delete:failed' => "Your bookmarked item could not be deleted. Please try again.", + 'bookmarks:save:failed' => "Your bookmarked item could not be saved. Please try again.", + 'bookmarks:delete:failed' => "Your bookmarked item could not be deleted. Please try again.", ); - -add_translation("en",$english); -?> \ No newline at end of file +add_translation("en", $english); \ No newline at end of file diff --git a/mod/bookmarks/start.php b/mod/bookmarks/start.php index cab118063..7d05ae0d1 100644 --- a/mod/bookmarks/start.php +++ b/mod/bookmarks/start.php @@ -45,7 +45,7 @@ function bookmarks_init() { // Extend Groups profile page elgg_extend_view('groups/tool_latest','bookmarks/group_bookmarks'); - + // Register profile menu hook register_plugin_hook('profile_menu', 'profile', 'bookmarks_profile_menu'); } @@ -90,6 +90,8 @@ function bookmarks_page_handler($page) { // grab the page owner here so the group magic works. $owner = page_owner_entity(); + } else { + set_page_owner(get_loggedin_userid()); } // owner name passed but invalid. @@ -110,7 +112,7 @@ function bookmarks_page_handler($page) { if(page_owner() != 0){ elgg_push_breadcrumb(elgg_echo('bookmarks:all'), $CONFIG->wwwroot . 'pg/bookmarks/'); } - + if ($owner) { switch($section) { case 'friends': @@ -185,7 +187,7 @@ function bookmarks_page_handler($page) { gatekeeper(); $content = elgg_view_title(elgg_echo('bookmarks:bookmarklet')); - $content .= elgg_view('bookmarks/bookmarklet', array('pg_owner' => $owner)); + $content .= elgg_view('bookmarks/bookmarklet'); break; } @@ -246,6 +248,7 @@ function bookmarks_page_handler($page) { return TRUE; } + /** * Populates the ->getUrl() method for bookmarked objects * @@ -318,12 +321,12 @@ function create_wire_url_code(){ function bookmarks_profile_menu($hook, $entity_type, $return_value, $params) { global $CONFIG; - + $return_value[] = array( 'text' => elgg_echo('bookmarks'), 'href' => "{$CONFIG->url}pg/bookmarks/{$params['owner']->username}", ); - + return $return_value; } diff --git a/mod/bookmarks/views/default/bookmarks/bookmarklet.php b/mod/bookmarks/views/default/bookmarks/bookmarklet.php index 4ff05c68a..c12b461e3 100644 --- a/mod/bookmarks/views/default/bookmarks/bookmarklet.php +++ b/mod/bookmarks/views/default/bookmarks/bookmarklet.php @@ -1,7 +1,7 @@ @@ -9,19 +9,28 @@ * @link http://elgg.org/ */ -$page_owner = $vars['pg_owner']; - +$page_owner = page_owner_entity(); $bookmarktext = elgg_echo("bookmarks:this"); -if ($page_owner instanceof ElggGroup) - $bookmarktext = sprintf(elgg_echo("bookmarks:this:group"), $page_owner->name) + +if ($page_owner instanceof ElggGroup) { + $bookmarktext = sprintf(elgg_echo("bookmarks:this:group"), $page_owner->name); + $name = "group:$page_owner->guid"; +} else { + $name = $page_owner->username; +} + +if (!$name && ($user = get_loggedin_user())) { + $name = $user->username; +} + ?> -

Browser Bookmarklet

- +

+
Instructions \ No newline at end of file -- cgit v1.2.3