From d4e4268d11612408e4989a5c57f69fcb2febe8aa Mon Sep 17 00:00:00 2001
From: brettp
Date: Thu, 3 Feb 2011 03:25:25 +0000
Subject: Refs #2680: First pass at porting the 1.7 bookmarks to 1.8.
Functional, but code is still messy.
git-svn-id: http://code.elgg.org/elgg/trunk@7998 36083f99-b078-4883-b0ff-0f9b5a30f544
---
mod/bookmarks/actions/add.php | 49 ----
mod/bookmarks/actions/bookmarks/add.php | 82 ++++++
mod/bookmarks/actions/bookmarks/delete.php | 29 ++
mod/bookmarks/actions/bookmarks/edit.php | 33 +++
mod/bookmarks/actions/delete.php | 20 --
mod/bookmarks/actions/edit.php | 33 ---
mod/bookmarks/actions/reference.php | 34 ---
mod/bookmarks/actions/remove.php | 34 ---
mod/bookmarks/bookmarklet.php | 10 +-
mod/bookmarks/languages/en.php | 69 ++---
mod/bookmarks/pages/add.php | 36 +++
mod/bookmarks/pages/all.php | 36 +++
mod/bookmarks/pages/friends.php | 33 +++
mod/bookmarks/pages/inbox.php | 28 ++
mod/bookmarks/pages/owner.php | 39 +++
mod/bookmarks/pages/view.php | 36 +++
mod/bookmarks/start.php | 303 ++++++---------------
.../views/default/bookmarks/bookmarklet.php | 2 +-
mod/bookmarks/views/default/bookmarks/css.php | 46 ----
mod/bookmarks/views/default/bookmarks/form.php | 204 ++++++++------
.../views/default/bookmarks/group_bookmarks.php | 35 ---
.../default/bookmarks/groupprofile_bookmarks.php | 34 +++
.../views/default/bookmarks/owner_block.php | 10 +
mod/bookmarks/views/default/bookmarks/sharing.php | 80 ++++++
mod/bookmarks/views/default/bookmarks/stats.php | 7 -
mod/bookmarks/views/default/object/bookmarks.php | 173 ++++++------
.../default/river/object/bookmarks/annotate.php | 10 +
.../default/river/object/bookmarks/create.php | 39 +--
.../views/default/widgets/bookmarks/view.php | 86 +++---
mod/bookmarks/views/rss/object/bookmarks.php | 27 +-
30 files changed, 886 insertions(+), 771 deletions(-)
delete mode 100644 mod/bookmarks/actions/add.php
create mode 100644 mod/bookmarks/actions/bookmarks/add.php
create mode 100644 mod/bookmarks/actions/bookmarks/delete.php
create mode 100644 mod/bookmarks/actions/bookmarks/edit.php
delete mode 100644 mod/bookmarks/actions/delete.php
delete mode 100755 mod/bookmarks/actions/edit.php
delete mode 100755 mod/bookmarks/actions/reference.php
delete mode 100755 mod/bookmarks/actions/remove.php
create mode 100644 mod/bookmarks/pages/add.php
create mode 100644 mod/bookmarks/pages/all.php
create mode 100644 mod/bookmarks/pages/friends.php
create mode 100644 mod/bookmarks/pages/inbox.php
create mode 100644 mod/bookmarks/pages/owner.php
create mode 100644 mod/bookmarks/pages/view.php
delete mode 100644 mod/bookmarks/views/default/bookmarks/css.php
delete mode 100755 mod/bookmarks/views/default/bookmarks/group_bookmarks.php
create mode 100644 mod/bookmarks/views/default/bookmarks/groupprofile_bookmarks.php
create mode 100644 mod/bookmarks/views/default/bookmarks/owner_block.php
create mode 100644 mod/bookmarks/views/default/bookmarks/sharing.php
delete mode 100755 mod/bookmarks/views/default/bookmarks/stats.php
create mode 100644 mod/bookmarks/views/default/river/object/bookmarks/annotate.php
diff --git a/mod/bookmarks/actions/add.php b/mod/bookmarks/actions/add.php
deleted file mode 100644
index b17ce76a4..000000000
--- a/mod/bookmarks/actions/add.php
+++ /dev/null
@@ -1,49 +0,0 @@
-";
-if ($xss_test != filter_tags($xss_test)) {
- register_error(elgg_echo('bookmarks:save:failed'));
- forward(REFERER);
-}
-
-//create a new bookmark object
-$entity = new ElggObject;
-$entity->subtype = "bookmarks";
-$entity->owner_guid = get_loggedin_userid();
-$entity->container_guid = (int)get_input('container_guid', get_loggedin_userid());
-$entity->title = $title;
-$entity->description = $notes;
-$entity->address = $address;
-$entity->access_id = $access;
-$entity->link_version = create_wire_url_code();//returns a random code in the form {{L:1hp56}}
-$entity->tags = $tagarray;
-
-if ($entity->save()) {
- system_message(elgg_echo('bookmarks:save:success'));
- //add to river
- add_to_river('river/object/bookmarks/create','create',get_loggedin_userid(),$entity->guid);
-} else {
- register_error(elgg_echo('bookmarks:save:failed'));
-}
-$account = get_entity((int)get_input('container_guid', get_loggedin_userid()));
-forward("pg/bookmarks/" . $account->username);
\ No newline at end of file
diff --git a/mod/bookmarks/actions/bookmarks/add.php b/mod/bookmarks/actions/bookmarks/add.php
new file mode 100644
index 000000000..7d8204ca5
--- /dev/null
+++ b/mod/bookmarks/actions/bookmarks/add.php
@@ -0,0 +1,82 @@
+";
+if ($xss_test != filter_tags($xss_test)) {
+ register_error(elgg_echo('bookmarks:save:failed'));
+ forward(REFERER);
+}
+
+$tags = get_input('tags');
+$tagarray = string_to_tag_array($tags);
+
+$new_bookmark = FALSE;
+if ($guid == 0) {
+ $entity = new ElggObject;
+ $entity->subtype = "bookmarks";
+ $entity->owner_guid = $_SESSION['user']->getGUID();
+ $entity->container_guid = (int)get_input('container_guid', $_SESSION['user']->getGUID());
+
+ $new_bookmark = TRUE;
+
+} else {
+
+ $canedit = false;
+ if ($entity = get_entity($guid)) {
+ if ($entity->canEdit()) {
+ $canedit = true;
+ }
+ }
+ if (!$canedit) {
+ system_message(elgg_echo('notfound'));
+ forward("pg/bookmarks");
+ }
+
+}
+
+$entity->title = $title;
+$entity->address = $address;
+$entity->description = $description;
+$entity->access_id = $access;
+$entity->tags = $tagarray;
+
+if ($entity->save()) {
+ $entity->clearRelationships();
+ $entity->shares = $shares;
+
+ if (is_array($shares) && sizeof($shares) > 0) {
+ foreach($shares as $share) {
+ $share = (int) $share;
+ add_entity_relationship($entity->getGUID(), 'share', $share);
+ }
+ }
+ system_message(elgg_echo('bookmarks:save:success'));
+ //add to river
+ if ($new_bookmark) {
+ add_to_river('river/object/bookmarks/create','create',$_SESSION['user']->guid,$entity->guid);
+ }
+ forward($entity->getURL());
+} else {
+ register_error(elgg_echo('bookmarks:save:failed'));
+ forward("pg/bookmarks");
+}
diff --git a/mod/bookmarks/actions/bookmarks/delete.php b/mod/bookmarks/actions/bookmarks/delete.php
new file mode 100644
index 000000000..48b4a2dd8
--- /dev/null
+++ b/mod/bookmarks/actions/bookmarks/delete.php
@@ -0,0 +1,29 @@
+container_guid);
+ if ($entity->canEdit()) {
+
+ if ($entity->delete()) {
+
+ system_message(elgg_echo("bookmarks:delete:success"));
+ forward("pg/bookmarks/owner/$container->username/");
+
+ }
+
+ }
+
+ }
+
+ register_error(elgg_echo("bookmarks:delete:failed"));
+ forward(REFERER);
+
+?>
\ No newline at end of file
diff --git a/mod/bookmarks/actions/bookmarks/edit.php b/mod/bookmarks/actions/bookmarks/edit.php
new file mode 100644
index 000000000..87de1c5e2
--- /dev/null
+++ b/mod/bookmarks/actions/bookmarks/edit.php
@@ -0,0 +1,33 @@
+getSubtype() == "bookmarks" && $bookmark->canEdit()) {
+ $bookmark->title = $title;
+ $bookmark->description = $notes;
+ $bookmark->address = $address;
+ $bookmark->access_id = $access;
+ $bookmark->tags = $tagarray;
+ if ($bookmark->save()) {
+ system_message(elgg_echo('bookmarks:edit:success'));
+ } else {
+ system_message(elgg_echo('bookmarks:edit:fail'));
+ }
+}else{
+ system_message(elgg_echo('bookmarks:edit:fail'));
+}
+$account = get_entity($bookmark->container_guid);
+forward("pg/bookmarks/" . $account->username);
\ No newline at end of file
diff --git a/mod/bookmarks/actions/delete.php b/mod/bookmarks/actions/delete.php
deleted file mode 100644
index 23de80146..000000000
--- a/mod/bookmarks/actions/delete.php
+++ /dev/null
@@ -1,20 +0,0 @@
-canEdit()) {
- $container = get_entity($entity->container_guid);
- if ($entity->delete()) {
- system_message(elgg_echo("bookmarks:delete:success"));
- forward("pg/bookmarks/$container->username/");
- }
- }
-}
-
-register_error(elgg_echo("bookmarks:delete:failed"));
-forward(REFERER);
\ No newline at end of file
diff --git a/mod/bookmarks/actions/edit.php b/mod/bookmarks/actions/edit.php
deleted file mode 100755
index 87de1c5e2..000000000
--- a/mod/bookmarks/actions/edit.php
+++ /dev/null
@@ -1,33 +0,0 @@
-getSubtype() == "bookmarks" && $bookmark->canEdit()) {
- $bookmark->title = $title;
- $bookmark->description = $notes;
- $bookmark->address = $address;
- $bookmark->access_id = $access;
- $bookmark->tags = $tagarray;
- if ($bookmark->save()) {
- system_message(elgg_echo('bookmarks:edit:success'));
- } else {
- system_message(elgg_echo('bookmarks:edit:fail'));
- }
-}else{
- system_message(elgg_echo('bookmarks:edit:fail'));
-}
-$account = get_entity($bookmark->container_guid);
-forward("pg/bookmarks/" . $account->username);
\ No newline at end of file
diff --git a/mod/bookmarks/actions/reference.php b/mod/bookmarks/actions/reference.php
deleted file mode 100755
index 515ac1ed1..000000000
--- a/mod/bookmarks/actions/reference.php
+++ /dev/null
@@ -1,34 +0,0 @@
-canEdit()){
- //create a relationship between the object and bookmark
- if(add_entity_relationship($object_guid, "reference", $bookmark_guid)){
- // Success message
- system_message(elgg_echo("bookmarks:referenceadded"));
- }else{
- // Failure message
- system_message(elgg_echo("bookmarks:referenceerror"));
- }
- }else{
- // Failure message
- system_message(elgg_echo("bookmarks:referenceerror"));
- }
-}else{
- // Failure message
- system_message(elgg_echo("bookmarks:referenceerror"));
-}
-
-forward($object->getURL());
\ No newline at end of file
diff --git a/mod/bookmarks/actions/remove.php b/mod/bookmarks/actions/remove.php
deleted file mode 100755
index f704a5cc3..000000000
--- a/mod/bookmarks/actions/remove.php
+++ /dev/null
@@ -1,34 +0,0 @@
-canEdit()){
- //remove the relationship between the object and bookmark
- if(remove_entity_relationship($object_guid, "reference", $bookmark_guid)){
- // Success message
- system_message(elgg_echo("bookmarks:removed"));
- }else{
- // Failure message
- system_message(elgg_echo("bookmarks:removederror"));
- }
- }else{
- // Failure message
- system_message(elgg_echo("bookmarks:removederror"));
- }
-}else{
- // Failure message
- system_message(elgg_echo("bookmarks:removederror"));
-}
-
-forward($object->getURL());
\ No newline at end of file
diff --git a/mod/bookmarks/bookmarklet.php b/mod/bookmarks/bookmarklet.php
index 8f97905f9..cfd03ac67 100644
--- a/mod/bookmarks/bookmarklet.php
+++ b/mod/bookmarks/bookmarklet.php
@@ -1,16 +1,16 @@
"Bookmarks",
- 'bookmarks:add' => "Bookmark something",
- 'bookmarks:read' => "Bookmark list",
+ 'bookmarks:add' => "Add bookmark",
+ 'bookmarks:owner' => "%s's bookmarks",
'bookmarks:friends' => "Friends' bookmarks",
- 'bookmarks:all' => "All site bookmarks",
- 'bookmarks:user' => "%s's bookmarks",
- 'bookmarks:group' => "Group bookmarks",
+ 'bookmarks:everyone' => "All site 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:bookmarklet:group' => "Get group bookmarklet",
'bookmarks:inbox' => "Bookmarks inbox",
- 'bookmarks:more' => "View note",
- 'bookmarks:yours' => "My bookmarks",
+ 'bookmarks:morebookmarks' => "More bookmarks",
+ 'bookmarks:more' => "More",
'bookmarks:shareditem' => "Bookmarked item",
'bookmarks:with' => "Share with",
- 'bookmarks:new' => "Add a Bookmark",
+ 'bookmarks:new' => "A new bookmarked item",
'bookmarks:via' => "via bookmarks",
'bookmarks:address' => "Address of the resource to bookmark",
- 'bookmarks:addnote' => "Add a note",
+ 'bookmarks:none' => 'No bookmarks',
+
'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:create' => 'bookmarked',
+
+ 'bookmarks:river:created' => '%s bookmarked',
+ 'bookmarks:river:annotate' => '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:group' => 'Group bookmarks',
+ 'groups:enablebookmarks' => 'Enable group bookmarks',
+ 'bookmarks:nogroup' => 'This group does not have any bookmarks yet',
+ 'bookmarks:more' => 'More bookmarks',
+
+ 'bookmarks:no_title' => 'No title',
/**
- * More text
+ * Widget and bookmarklet
*/
-
'bookmarks:widget:description' =>
- "This widget displays your latest bookmarks.",
+ "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.",
+ "The bookmarks bookmarklet allows you to share any resource you find on the web with your friends, or just bookmark it for yourself. To use it, simply drag the following button to your browser's links bar:",
- '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:descriptionie' =>
+ "If you are using Internet Explorer, you will need to right click on the bookmarklet icon, 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.",
-
- 'bookmarks:no_title' => 'No title',
+ "You can then save any page you visit by clicking it at any time.",
/**
* Status messages
@@ -81,9 +72,7 @@ $english = array(
*/
'bookmarks:save:failed' => "Your bookmarked item could not be saved. Make sure you've entered a title and address and then try again.",
- 'bookmarks:delete:failed' => "Your bookmarked item could not be deleted.",
-
-
+ '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/pages/add.php b/mod/bookmarks/pages/add.php
new file mode 100644
index 000000000..17e1e6fa4
--- /dev/null
+++ b/mod/bookmarks/pages/add.php
@@ -0,0 +1,36 @@
+getGUID());
+}
+if ($page_owner instanceof ElggGroup)
+ $container = $page_owner->guid;
+
+$area2 .= elgg_view_title(elgg_echo('bookmarks:this'), false);
+
+// If we've been given a bookmark to edit, grab it
+if ($this_guid = get_input('bookmark',0)) {
+ $entity = get_entity($this_guid);
+ if ($entity->canEdit()) {
+ $area2 .= elgg_view('bookmarks/form',array('entity' => $entity, 'container_guid' => $container));
+ }
+} else {
+ $area2 .= elgg_view('bookmarks/form', array('container_guid' => $container));
+}
+
+// Format page
+$body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
+
+// Draw it
+page_draw(elgg_echo('bookmarks:add'),$body);
diff --git a/mod/bookmarks/pages/all.php b/mod/bookmarks/pages/all.php
new file mode 100644
index 000000000..2bde462ba
--- /dev/null
+++ b/mod/bookmarks/pages/all.php
@@ -0,0 +1,36 @@
+ 'object',
+ 'subtype' => 'bookmarks',
+ 'limit' => 10,
+ 'offset' => $offset,
+ 'full_view' => false,
+ 'view_toggle_type' => false
+));
+
+$title = elgg_echo('bookmarks:everyone');
+
+$body = elgg_view_layout('content', array(
+ 'filter_context' => 'all',
+ 'content' => $content,
+ 'title' => $title
+));
+
+echo elgg_view_page($title, $body);
+elgg_pop_context();
\ No newline at end of file
diff --git a/mod/bookmarks/pages/friends.php b/mod/bookmarks/pages/friends.php
new file mode 100644
index 000000000..5c930434b
--- /dev/null
+++ b/mod/bookmarks/pages/friends.php
@@ -0,0 +1,33 @@
+name, "pg/bookmarks/owner/$owner->username");
+elgg_push_breadcrumb(elgg_echo('friends'));
+
+$title = elgg_echo('bookmarks:friends');
+
+$content = list_user_friends_objects($owner->guid, 'bookmarks', 10, false);
+if (!$content) {
+ $content = elgg_echo('bookmarks:none');
+}
+
+$params = array(
+ 'filter_context' => 'friends',
+ 'content' => $content,
+ 'title' => $title,
+);
+
+$body = elgg_view_layout('content', $params);
+
+echo elgg_view_page($title, $body);
+elgg_pop_context();
\ No newline at end of file
diff --git a/mod/bookmarks/pages/inbox.php b/mod/bookmarks/pages/inbox.php
new file mode 100644
index 000000000..061a51e18
--- /dev/null
+++ b/mod/bookmarks/pages/inbox.php
@@ -0,0 +1,28 @@
+
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.org/
+ */
+
+ // Start engine
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ // List bookmarks
+ $area2 = elgg_view_title(elgg_echo('bookmarks:inbox'));
+ set_context('search');
+ $area2 .= list_entities_from_relationship('share',page_owner(),true,'object','bookmarks');
+ set_context('bookmarks');
+
+ // Format page
+ $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
+
+ // Draw it
+ page_draw(elgg_echo('bookmarks:inbox'),$body);
+
+?>
\ No newline at end of file
diff --git a/mod/bookmarks/pages/owner.php b/mod/bookmarks/pages/owner.php
new file mode 100644
index 000000000..1e45bc518
--- /dev/null
+++ b/mod/bookmarks/pages/owner.php
@@ -0,0 +1,39 @@
+name, "pg/bookmarks/owner/$page_owner->username");
+
+$offset = (int)get_input('offset', 0);
+$content .= elgg_list_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'bookmarks',
+ 'owner_guid' => $page_owner->guid,
+ 'limit' => 10,
+ 'offset' => $offset,
+ 'full_view' => false,
+ 'view_toggle_type' => false
+));
+
+$title = elgg_echo('bookmarks:owner', array($page_owner->name));
+
+$body = elgg_view_layout('content', array(
+ 'filter_context' => 'mine',
+ 'content' => $content,
+ 'title' => $title
+));
+
+echo elgg_view_page($title, $body);
+elgg_pop_context();
\ No newline at end of file
diff --git a/mod/bookmarks/pages/view.php b/mod/bookmarks/pages/view.php
new file mode 100644
index 000000000..6b4b839b1
--- /dev/null
+++ b/mod/bookmarks/pages/view.php
@@ -0,0 +1,36 @@
+getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+elgg_push_breadcrumb(elgg_echo('bookmarks'), 'pg/bookmarks/all');
+
+$crumbs_title = elgg_echo('blog:owned_blogs', array($owner->name));
+if (elgg_instanceof($owner, 'group')) {
+ elgg_push_breadcrumb($crumbs_title, "pg/bookmarks/group/$owner->guid/owner");
+} else {
+ elgg_push_breadcrumb($crumbs_title, "pg/bookmarks/owner/$owner->username");
+}
+
+$title = $bookmark->title;
+
+elgg_push_breadcrumb($title);
+
+$content = elgg_view_entity($bookmark, true);
+$content .= elgg_view_comments($bookmark);
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+ 'header' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/bookmarks/start.php b/mod/bookmarks/start.php
index bed077864..b7e2e5df9 100644
--- a/mod/bookmarks/start.php
+++ b/mod/bookmarks/start.php
@@ -5,13 +5,11 @@
* @package ElggBookmarks
*/
-// Bookmarks initialisation function
function bookmarks_init() {
- // Grab the config global
global $CONFIG;
//add a tools menu option
- $item = new ElggMenuItem('bookmarks', elgg_echo('bookmarks'), 'pg/bookmarks');
+ $item = new ElggMenuItem('bookmarks', elgg_echo('bookmarks'), 'pg/bookmarks/all');
elgg_register_menu_item('site', $item);
// Register a page handler, so we can have nice URLs
@@ -56,16 +54,51 @@ function bookmarks_init() {
function bookmarks_pagesetup() {
global $CONFIG;
- $page_owner = elgg_get_page_owner_entity();
+ $page_owner = page_owner_entity();
- // Add group bookmark menu item
- if (isloggedin()) {
- if ($page_owner instanceof ElggGroup && elgg_get_context() == 'groups') {
- if ($page_owner->bookmarks_enable != "no") {
- //add_submenu_item(elgg_echo("bookmarks:group",array($page_owner->name), "pg/bookmarks/" . $page_owner->username . '/items'));
+ //add submenu options
+ if (get_context() == "bookmarks") {
+
+ if (isloggedin()) {
+ // link to add bookmark form
+ if ($page_owner instanceof ElggGroup) {
+ if ($page_owner->isMember(get_loggedin_user())) {
+ add_submenu_item(elgg_echo('bookmarks:add'), $CONFIG->wwwroot."pg/bookmarks/add/" . $page_owner->username);
+ }
+ } else {
+ add_submenu_item(elgg_echo('bookmarks:add'), $CONFIG->wwwroot."pg/bookmarks/add/" . $_SESSION['user']->username);
+ add_submenu_item(elgg_echo('bookmarks:inbox'),$CONFIG->wwwroot."pg/bookmarks/inbox/" . $_SESSION['user']->username);
+ }
+ if (page_owner()) {
+ add_submenu_item(sprintf(elgg_echo('bookmarks:read'), $page_owner->name),$CONFIG->wwwroot."pg/bookmarks/owner/" . $page_owner->username);
+ }
+ if (!$page_owner instanceof ElggGroup) {
+ add_submenu_item(elgg_echo('bookmarks:friends'),$CONFIG->wwwroot."pg/bookmarks/friends/" . $_SESSION['user']->username);
+ }
+ }
+
+ if (!$page_owner instanceof ElggGroup) {
+ add_submenu_item(elgg_echo('bookmarks:everyone'),$CONFIG->wwwroot."pg/bookmarks/all/");
+ }
+
+ // Bookmarklet
+ if ((isloggedin()) && (page_owner()) && (can_write_to_container(0, page_owner()))) {
+
+ $bmtext = elgg_echo('bookmarks:bookmarklet');
+ if ($page_owner instanceof ElggGroup) {
+ $bmtext = elgg_echo('bookmarks:bookmarklet:group');
}
+ add_submenu_item($bmtext, $CONFIG->wwwroot . "pg/bookmarks/bookmarklet/{$page_owner->username}/");
}
+
}
+
+ if ($page_owner instanceof ElggGroup && get_context() == 'groups') {
+ if ($page_owner->bookmarks_enable != "no") {
+ add_submenu_item(sprintf(elgg_echo("bookmarks:group"),$page_owner->name), $CONFIG->wwwroot . "pg/bookmarks/owner/" . $page_owner->username);
+ }
+ }
+
}
/**
@@ -95,172 +128,47 @@ function bookmarks_page_handler($page) {
bookmarks_url_forwarder($page);
}
- set_input('username', $page[1]);
- $owner = get_user_by_username($page[1]);
- //$owner = elgg_get_page_owner();
- $owner_name = $owner->username;
-
- // owner name passed but invalid.
- if ($owner_name && !$owner) {
- $sidebar = elgg_view('bookmarks/sidebar', array('object_type' => 'bookmarks'));
- $content = elgg_echo("bookmarks:unknown_user");
-
- $params = array(
- 'content' => $content,
- 'sidebar' => $sidebar,
- );
- $body = elgg_view_layout('one_column_with_sidebar', $params);
- echo elgg_view_page(elgg_echo("bookmarks:user", array(elgg_get_page_owner_entity()->name)), $body);
-
- return FALSE;
- }
-
- $logged_in_user = get_loggedin_user();
- $section = (isset($page[0])) ? $page[0] : $section = 'items';
-
- //don't show the all site bookmarks breadcrumb when on the all site bookmarks page
- if(elgg_get_page_owner_guid() != 0){
- elgg_push_breadcrumb(elgg_echo('bookmarks:all'), $CONFIG->wwwroot . 'pg/bookmarks/');
- }
-
- if ($owner) {
- switch($section) {
- case 'friends':
- elgg_push_breadcrumb(elgg_echo('bookmarks:friends', array($owner->name)));
-
- $content = list_user_friends_objects($owner->getGUID(), 'bookmarks', 10, false, false);
- $context = ($owner == $logged_in_user) ? 'friends' : '';
- break;
-
- default:
- case 'items':
- elgg_push_breadcrumb(elgg_echo('bookmarks:user', array($owner->name)));
-
- group_gatekeeper();
- $options = array(
- 'type' => 'object',
- 'subtype' => 'bookmarks'
- );
-
- if ($owner instanceof ElggGroup) {
- $options['container_guid'] = $owner->getGUID();
- } else {
- $options['owner_guid'] = $owner->getGUID();
- }
-
- $content = elgg_list_entities($options);
-
- if (!$content && ($owner == $logged_in_user)) {
- $content = elgg_view('help/bookmarks');
- }
-
- $context = ($owner == $logged_in_user) ? 'mine' : '';
- break;
-
- case 'add':
- gatekeeper();
- elgg_push_breadcrumb(elgg_echo('bookmarks:add'));
-
- $vars = array();
- if ($owner instanceof ElggGroup) {
- $vars['container_guid'] = $owner->getGUID();
- }
-
- $context = 'action';
- $content = elgg_view('bookmarks/form', $vars);
- break;
-
- case 'edit':
- gatekeeper();
-
- elgg_push_breadcrumb(elgg_echo('bookmarks:edit'));
-
- $vars = array();
- // this will never be the case.
- if ($owner instanceof ElggGroup) {
- $vars['container_guid'] = $owner->getGUID();
- }
-
- $bookmark = (isset($page[2])) ? get_entity($page[2]) : FALSE;
-
- if ($bookmark && elgg_instanceof($bookmark, 'object', 'bookmarks') && $bookmark->canEdit()) {
- $vars['entity'] = $bookmark;
- $context = 'action';
- $content = elgg_view('bookmarks/form', $vars);
- } else {
- $content = elgg_echo('bookmarks:cannot_find_bookmark');
- }
-
- break;
-
- // I don't think this is used.
- case 'bookmarklet':
- gatekeeper();
-
- $content = elgg_view_title(elgg_echo('bookmarks:bookmarklet'));
- $content .= elgg_view('bookmarks/bookmarklet');
-
- break;
- }
-
- } else {
- // no owner name passed, show everything.
- $content = elgg_list_entities(array('type' => 'object', 'subtype' => 'bookmarks'));
- $context = 'everyone';
- }
-
- // sidebar
- if ($logged_in_user != $owner) {
- $area3 = elgg_view('bookmarks/ownerblock');
- }
-
- $sidebar = elgg_view('bookmarks/sidebar', array('object_type' => 'bookmarks'));
- if (isloggedin()){
- $sidebar .= elgg_view('bookmarks/bookmarklet');
- }
-
- // main content
- //if ($owner != $logged_in_user || $context == 'action') {
- $header = elgg_view('navigation/breadcrumbs');
- //}
- //if no user is set
- if(!$owner_name){
- $owner_name = get_loggedin_user()->username;
- }
+ $pages = dirname(__FILE__) . '/pages';
- //select the header depending on whether a user is looking at their bookmarks or someone elses
- if($owner){
- if ($owner != $logged_in_user && !($owner instanceof ElggGroup)) {
- $header .= elgg_view("page/elements/content_header_member", array(
- 'type' => 'bookmarks'
- ));
- }else{
- $header .= elgg_view("page/elements/content_header", array(
- 'context' => $context,
- 'type' => 'bookmarks',
- 'all_link' => "pg/bookmarks/",
- 'new_link' => "pg/bookmarks/add/{$owner_name}"
- ));
- }
- }else{
- $header .= elgg_view("page/elements/content_header", array(
- 'context' => $context,
- 'type' => 'bookmarks',
- 'all_link' => "pg/bookmarks/",
- 'new_link' => "pg/bookmarks/add/{$owner_name}"
- ));
+ switch ($page[0]) {
+ case "read":
+ case "view":
+ set_input('guid', $page[1]);
+ include "$pages/view.php";
+ break;
+ case "friends":
+ set_input('username', $page[1]);
+ include "$pages/friends.php";
+ break;
+ case "all":
+ include "$pages/all.php";
+ break;
+ case "inbox":
+ set_input('username', $page[1]);
+ include "$pages/inbox.php";
+ break;
+ case "owner":
+ set_input('username', $page[1]);
+ include "$pages/owner.php";
+ break;
+ case "add":
+ set_input('username', $page[1]);
+ include "$pages/add.php";
+ break;
+ case "edit":
+ set_input('bookmark', $page[1]);
+ include "$pages/add.php";
+ break;
+ case "bookmarklet":
+ set_input('username', $page[1]);
+ include "$pages/bookmarklet.php";
+ break;
+ default:
+ return false;
}
- $content = $header . $content;
- $params = array(
- 'content' => $content,
- 'sidebar' => $sidebar,
- );
- $body = elgg_view_layout('two_sidebar', $params);
- echo elgg_view_page(elgg_echo("bookmarks:user", array(elgg_get_page_owner_entity()->name)), $body);
-
- return TRUE;
+ return true;
}
/**
@@ -277,7 +185,7 @@ function bookmarks_url_forwarder($page) {
switch ($page[1]) {
case "read":
- $url = "{$CONFIG->wwwroot}pg/bookmarks/read/{$page[2]}/{$page[3]}";
+ $url = "{$CONFIG->wwwroot}pg/bookmarks/view/{$page[2]}/{$page[3]}";
break;
case "inbox":
$url = "{$CONFIG->wwwroot}pg/bookmarks/inbox/{$page[0]}/";
@@ -307,11 +215,11 @@ function bookmarks_url_forwarder($page) {
* @return string bookmarked item URL
*/
function bookmark_url($entity) {
-
global $CONFIG;
+
$title = $entity->title;
$title = elgg_get_friendly_title($title);
- return "pg/bookmarks/" . $entity->getOwnerEntity()->username . "/read/" . $entity->getGUID() . "/" . $title;
+ return $CONFIG->url . "pg/bookmarks/view/" . $entity->getGUID() . "/" . $title;
}
/**
@@ -367,46 +275,11 @@ function bookmarks_notify_message($hook, $entity_type, $returnvalue, $params) {
return null;
}
-/**
- * A function to generate an internal code to put on the wire in place of the full url
- * to save space.
- **/
-
-function create_wire_url_code(){
- $chars = "abcdefghijkmnopqrstuvwxyz023456789";
- srand((double)microtime()*1000000);
- $i = 0;
- $code = '';
-
- while ($i <= 4) {
- $num = rand() % 33;
- $tmp = substr($chars, $num, 1);
- $code = $code . $tmp;
- $i++;
- }
- $code = "{{L:" . $code . "}}";
- return $code;
-}
-
-function bookmarks_profile_menu($hook, $entity_type, $return_value, $params) {
- global $CONFIG;
-
- $return_value[] = array(
- 'text' => elgg_echo('bookmarks'),
- 'href' => "pg/bookmarks/{$params['owner']->username}",
- );
-
- return $return_value;
-}
-
-// Make sure the initialisation function is called on initialisation
-elgg_register_event_handler('init','system','bookmarks_init');
-elgg_register_event_handler('pagesetup','system','bookmarks_pagesetup');
+elgg_register_event_handler('init', 'system', 'bookmarks_init');
+elgg_register_event_handler('pagesetup', 'system', 'bookmarks_pagesetup');
// Register actions
-global $CONFIG;
-elgg_register_action('bookmarks/add', $CONFIG->pluginspath . "bookmarks/actions/add.php");
-elgg_register_action('bookmarks/edit', $CONFIG->pluginspath . "bookmarks/actions/edit.php");
-elgg_register_action('bookmarks/delete', $CONFIG->pluginspath . "bookmarks/actions/delete.php");
-elgg_register_action('bookmarks/reference', $CONFIG->pluginspath . "bookmarks/actions/reference.php");
-elgg_register_action('bookmarks/remove', $CONFIG->pluginspath . "bookmarks/actions/remove.php");
+$action_path = dirname(__FILE__) . '/actions/bookmarks';
+
+elgg_register_action('bookmarks/add', "$action_path/add.php", 'logged_in');
+elgg_register_action('bookmarks/delete', "$action_path/delete.php", 'logged_in');
\ No newline at end of file
diff --git a/mod/bookmarks/views/default/bookmarks/bookmarklet.php b/mod/bookmarks/views/default/bookmarks/bookmarklet.php
index 75d3686b9..bb2cf885e 100644
--- a/mod/bookmarks/views/default/bookmarks/bookmarklet.php
+++ b/mod/bookmarks/views/default/bookmarks/bookmarklet.php
@@ -1,7 +1,7 @@
-
-.bookmark_note {
- margin:0 0 0 5px;
-}
-.note {
- margin-top:5px;
-}
-
-
-/* BOOKMARKS WIDGET
-.collapsable_box_content .ContentWrapper.bookmarks {
- margin-bottom:5px;
- line-height:1.2em;
-}
-.collapsable_box_content .ContentWrapper.bookmarks .share_desc {
- display:none;
- line-height: 1.2em;
-}
-.collapsable_box_content .ContentWrapper.bookmarks .share_desc p {
- margin:0 0 5px 0;
-}
-.collapsable_box_content .ContentWrapper.bookmarks .river_object_bookmarks_create p {
- min-height:17px;
- padding:0 0 0 17px;
-}
-.collapsable_box_content .ContentWrapper.bookmarks .shares_timestamp {
- color:#666666;
- margin:0;
- padding:0 0 0 17px;
-}
-.collapsable_box_content .ContentWrapper.bookmarks .shares_title {
- margin:0;
- line-height: 1.1em;
-}
-.collapsable_box_content .ContentWrapper.bookmarks.more {
- margin:0 10px;
- padding:5px 10px;
-}
-*/
diff --git a/mod/bookmarks/views/default/bookmarks/form.php b/mod/bookmarks/views/default/bookmarks/form.php
index 12cd76ba7..2131f7cd8 100644
--- a/mod/bookmarks/views/default/bookmarks/form.php
+++ b/mod/bookmarks/views/default/bookmarks/form.php
@@ -1,109 +1,133 @@
guid;
$title = $vars['entity']->title;
+ $description = $vars['entity']->description;
$address = $vars['entity']->address;
- $access_id = $vars['entity']->access_id;
$tags = $vars['entity']->tags;
- $notes = $vars['entity']->description;
- $owner = get_entity($vars['entity']->container_guid);
- $url = "action/bookmarks/edit";
-}else{
- //set some variables
- $guid = '';
+ $access_id = $vars['entity']->access_id;
+ $shares = $vars['entity']->shares;
+ $owner = $vars['entity']->getOwnerEntity();
+ $highlight = 'default';
+
+} else {
+ $guid = 0;
$title = get_input('title',"");
$title = stripslashes($title); // strip slashes from URL encoded apostrophes
+ $description = "";
$address = get_input('address',"");
- $notes = '';
+ $highlight = 'all';
+
if ($address == "previous")
$address = $_SERVER['HTTP_REFERER'];
$tags = array();
- if(elgg_get_page_owner_entity() instanceof ElggGroup){
- //if in a group, set the access level to default to the group
- $access_id = elgg_get_page_owner_entity()->group_acl;
- }else{
- $access_id = get_default_access(get_loggedin_user());
+
+ if (defined('ACCESS_DEFAULT')) {
+ $access_id = ACCESS_DEFAULT;
+ } else {
+ $access_id = 0;
}
- $owner = get_loggedin_user();
- $url = "action/bookmarks/add";
+ $shares = array();
+ $owner = page_owner_entity();
}
+
?>
-
";
- } else {
- $info .= "";
- }
-
- //display
- echo "";
- }
+ if($s->description)
+ $info .= "".elgg_echo('bookmarks:more')."
";
+
+ //display
+ echo "";
- if ($num_bookmarks > $num) {
- $user_inbox = elgg_get_site_url() . "pg/bookmarks/" . elgg_get_page_owner_entity()->username;
- echo "";
}
-} else {
- echo "" . elgg_echo("bookmarks:widget:description") . "
";
+
+ $user_inbox = $vars['url'] . "pg/bookmarks/owner/" . page_owner_entity()->username;
+ echo "";
+
}
+
+
+?>
\ No newline at end of file
diff --git a/mod/bookmarks/views/rss/object/bookmarks.php b/mod/bookmarks/views/rss/object/bookmarks.php
index f17ae87d7..8e88485f1 100644
--- a/mod/bookmarks/views/rss/object/bookmarks.php
+++ b/mod/bookmarks/views/rss/object/bookmarks.php
@@ -4,19 +4,20 @@
*
* @package ElggBookmarks
*/
- $title = $vars['entity']->title;
- if (empty($title)) {
- $title = substr($vars['entity']->description,0,32);
- if (strlen($vars['entity']->description) > 32)
- $title .= " ...";
- }
+
+$title = $vars['entity']->title;
+if (empty($title)) {
+ $title = substr($vars['entity']->description,0,32);
+ if (strlen($vars['entity']->description) > 32)
+ $title .= " ...";
+}
?>
- -
- getURL(); ?>
- time_created) ?>
- address; ?>
- ]]>
- description)); ?>]]>
-
+-
+ getURL(); ?>
+ time_created) ?>
+ address; ?>
+ ]]>
+ description)); ?>]]>
+
--
cgit v1.2.3