aboutsummaryrefslogtreecommitdiff
path: root/mod/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'mod/bookmarks')
-rw-r--r--mod/bookmarks/actions/add.php43
-rw-r--r--mod/bookmarks/actions/bookmarks/delete.php24
-rw-r--r--mod/bookmarks/actions/bookmarks/save.php90
-rw-r--r--mod/bookmarks/actions/delete.php20
-rwxr-xr-xmod/bookmarks/actions/edit.php35
-rwxr-xr-xmod/bookmarks/actions/reference.php34
-rwxr-xr-xmod/bookmarks/actions/remove.php34
-rw-r--r--mod/bookmarks/bookmarklet.php35
-rw-r--r--mod/bookmarks/graphics/bookmark.gifbin0 -> 576 bytes
-rw-r--r--mod/bookmarks/graphics/bookmarklet.gifbin0 -> 790 bytes
-rw-r--r--mod/bookmarks/languages/en.php98
-rw-r--r--mod/bookmarks/lib/bookmarks.php46
-rw-r--r--mod/bookmarks/manifest.xml27
-rw-r--r--mod/bookmarks/pages/bookmarks/add.php22
-rw-r--r--mod/bookmarks/pages/bookmarks/all.php33
-rw-r--r--mod/bookmarks/pages/bookmarks/bookmarklet.php36
-rw-r--r--mod/bookmarks/pages/bookmarks/edit.php30
-rw-r--r--mod/bookmarks/pages/bookmarks/friends.php33
-rw-r--r--mod/bookmarks/pages/bookmarks/owner.php50
-rw-r--r--mod/bookmarks/pages/bookmarks/view.php38
-rw-r--r--mod/bookmarks/start.php495
-rw-r--r--mod/bookmarks/views/default/bookmarks/bookmarklet.php39
-rw-r--r--mod/bookmarks/views/default/bookmarks/css.php49
-rw-r--r--mod/bookmarks/views/default/bookmarks/form.php109
-rwxr-xr-xmod/bookmarks/views/default/bookmarks/group_bookmarks.php35
-rw-r--r--mod/bookmarks/views/default/bookmarks/group_module.php47
-rw-r--r--mod/bookmarks/views/default/bookmarks/js.php12
-rw-r--r--mod/bookmarks/views/default/bookmarks/sidebar.php14
-rwxr-xr-xmod/bookmarks/views/default/bookmarks/stats.php7
-rw-r--r--mod/bookmarks/views/default/forms/bookmarks/save.php59
-rw-r--r--mod/bookmarks/views/default/object/bookmarks.php174
-rw-r--r--mod/bookmarks/views/default/river/object/bookmarks/create.php29
-rw-r--r--mod/bookmarks/views/default/widgets/bookmarks/content.php32
-rw-r--r--mod/bookmarks/views/default/widgets/bookmarks/edit.php32
-rw-r--r--mod/bookmarks/views/default/widgets/bookmarks/view.php52
-rw-r--r--mod/bookmarks/views/rss/object/bookmarks.php47
36 files changed, 1055 insertions, 905 deletions
diff --git a/mod/bookmarks/actions/add.php b/mod/bookmarks/actions/add.php
deleted file mode 100644
index e633244c1..000000000
--- a/mod/bookmarks/actions/add.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-/**
- * Elgg bookmarks add/save action
- *
- * @package ElggBookmarks
- */
-
-gatekeeper();
-action_gatekeeper();
-//set some required variables
-$title = strip_tags(get_input('title'));
-$address = get_input('address');
-$notes = get_input('notes');
-$access = get_input('access');
-$tags = get_input('tags');
-$tagarray = string_to_tag_array($tags);
-
-if (!$title || !$address) {
- 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/delete.php b/mod/bookmarks/actions/bookmarks/delete.php
new file mode 100644
index 000000000..2e9f41438
--- /dev/null
+++ b/mod/bookmarks/actions/bookmarks/delete.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Delete a bookmark
+ *
+ * @package Bookmarks
+ */
+
+$guid = get_input('guid');
+$bookmark = get_entity($guid);
+
+if (elgg_instanceof($bookmark, 'object', 'bookmarks') && $bookmark->canEdit()) {
+ $container = $bookmark->getContainerEntity();
+ if ($bookmark->delete()) {
+ system_message(elgg_echo("bookmarks:delete:success"));
+ if (elgg_instanceof($container, 'group')) {
+ forward("bookmarks/group/$container->guid/all");
+ } else {
+ forward("bookmarks/owner/$container->username");
+ }
+ }
+}
+
+register_error(elgg_echo("bookmarks:delete:failed"));
+forward(REFERER);
diff --git a/mod/bookmarks/actions/bookmarks/save.php b/mod/bookmarks/actions/bookmarks/save.php
new file mode 100644
index 000000000..46090b115
--- /dev/null
+++ b/mod/bookmarks/actions/bookmarks/save.php
@@ -0,0 +1,90 @@
+<?php
+/**
+* Elgg bookmarks save action
+*
+* @package Bookmarks
+*/
+
+$title = htmlspecialchars(get_input('title', '', false), ENT_QUOTES, 'UTF-8');
+$description = get_input('description');
+$address = get_input('address');
+$access_id = get_input('access_id');
+$tags = get_input('tags');
+$guid = get_input('guid');
+$share = get_input('share');
+$container_guid = get_input('container_guid', elgg_get_logged_in_user_guid());
+
+elgg_make_sticky_form('bookmarks');
+
+// don't use elgg_normalize_url() because we don't want
+// relative links resolved to this site.
+if ($address && !preg_match("#^((ht|f)tps?:)?//#i", $address)) {
+ $address = "http://$address";
+}
+
+if (!$title || !$address) {
+ register_error(elgg_echo('bookmarks:save:failed'));
+ forward(REFERER);
+}
+
+// see https://bugs.php.net/bug.php?id=51192
+$php_5_2_13_and_below = version_compare(PHP_VERSION, '5.2.14', '<');
+$php_5_3_0_to_5_3_2 = version_compare(PHP_VERSION, '5.3.0', '>=') &&
+ version_compare(PHP_VERSION, '5.3.3', '<');
+
+$validated = false;
+if ($php_5_2_13_and_below || $php_5_3_0_to_5_3_2) {
+ $tmp_address = str_replace("-", "", $address);
+ $validated = filter_var($tmp_address, FILTER_VALIDATE_URL);
+} else {
+ $validated = filter_var($address, FILTER_VALIDATE_URL);
+}
+if (!$validated) {
+ register_error(elgg_echo('bookmarks:save:failed'));
+ forward(REFERER);
+}
+
+if ($guid == 0) {
+ $bookmark = new ElggObject;
+ $bookmark->subtype = "bookmarks";
+ $bookmark->container_guid = (int)get_input('container_guid', $_SESSION['user']->getGUID());
+ $new = true;
+} else {
+ $bookmark = get_entity($guid);
+ if (!$bookmark->canEdit()) {
+ system_message(elgg_echo('bookmarks:save:failed'));
+ forward(REFERRER);
+ }
+}
+
+$tagarray = string_to_tag_array($tags);
+
+$bookmark->title = $title;
+$bookmark->address = $address;
+$bookmark->description = $description;
+$bookmark->access_id = $access_id;
+$bookmark->tags = $tagarray;
+
+if ($bookmark->save()) {
+
+ elgg_clear_sticky_form('bookmarks');
+
+ // @todo
+ if (is_array($shares) && sizeof($shares) > 0) {
+ foreach($shares as $share) {
+ $share = (int) $share;
+ add_entity_relationship($bookmark->getGUID(), 'share', $share);
+ }
+ }
+ system_message(elgg_echo('bookmarks:save:success'));
+
+ //add to river only if new
+ if ($new) {
+ add_to_river('river/object/bookmarks/create','create', elgg_get_logged_in_user_guid(), $bookmark->getGUID());
+ }
+
+ forward($bookmark->getURL());
+} else {
+ register_error(elgg_echo('bookmarks:save:failed'));
+ forward("bookmarks");
+}
diff --git a/mod/bookmarks/actions/delete.php b/mod/bookmarks/actions/delete.php
deleted file mode 100644
index d6e19cdae..000000000
--- a/mod/bookmarks/actions/delete.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-/**
- * Elgg bookmarks delete action
- *
- * @package ElggBookmarks
- */
-
-$guid = get_input('bookmark_guid',0);
-if ($entity = get_entity($guid)) {
- if ($entity->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($_SERVER['HTTP_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 dd0330b2d..000000000
--- a/mod/bookmarks/actions/edit.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Elgg bookmarks edit action
- *
- */
-
-gatekeeper();
-action_gatekeeper();
-//set some required variables
-$guid = get_input('guid');
-$title = get_input('title');
-$address = get_input('address');
-$notes = get_input('notes');
-$access = get_input('access');
-$tags = get_input('tags');
-$tagarray = string_to_tag_array($tags);
-
-// Make sure we actually have permission to edit
-$bookmark = get_entity($guid);
-if ($bookmark->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 @@
-<?php
-
-/**
- * Elgg bookmarks add as reference
- * Guid one is the object, guid two is the bookmark, 'reference' is the relationship name
- */
-
-//set some variables
-$object_guid = get_input('object_guid');
-$bookmark_guid = get_input('reference');
-$object = get_entity($object_guid);
-$bookmark = get_entity($bookmark_guid);
-//check both the object and bookmark exist
-if($bookmark && $object){
- //check the user can add a reference
- if($object->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 @@
-<?php
-
-/**
- * Elgg bookmarks remove a reference
- * Guid one is the object, guid two is the bookmark, 'reference' is the relationship name
- */
-
-//set some variables
-$object_guid = get_input('object_guid');
-$bookmark_guid = get_input('bookmark');
-$object = get_entity($object_guid);
-$bookmark = get_entity($bookmark_guid);
-//check both the object and bookmark exist
-if($bookmark && $object){
- //check the user can add a reference
- if($object->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
deleted file mode 100644
index ecfe61ae5..000000000
--- a/mod/bookmarks/bookmarklet.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-/**
- * Elgg bookmarks plugin bookmarklet page
- *
- * @package ElggBookmarks
- */
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-gatekeeper();
-
-// Get the current page's owner
-$page_owner = elgg_get_page_owner();
-if ($page_owner === false || is_null($page_owner) && (get_loggedin_user())) {
- $page_owner = get_loggedin_user();
- set_page_owner($page_owner->getGUID());
-}
-
-// get the content area header
-$area1 = elgg_view('page_elements/content_header', array('context' => "mine", 'type' => 'bookmarks'));
-
-// List bookmarks
-$area2 = elgg_view_title(elgg_echo('bookmarks:bookmarklet'));
-$area2 .= elgg_view('bookmarks/bookmarklet', array('pg_owner' => $page_owner));
-
-// if logged in, get the bookmarklet
-$area3 = elgg_view("bookmarks/bookmarklet");
-
-// Format page
-$body = elgg_view_layout('one_column_with_sidebar', $area1.$area2, $area3);
-
-// Draw it
-echo page_draw(elgg_echo('bookmarks:bookmarklet'),$body); \ No newline at end of file
diff --git a/mod/bookmarks/graphics/bookmark.gif b/mod/bookmarks/graphics/bookmark.gif
new file mode 100644
index 000000000..55c5e3e15
--- /dev/null
+++ b/mod/bookmarks/graphics/bookmark.gif
Binary files differ
diff --git a/mod/bookmarks/graphics/bookmarklet.gif b/mod/bookmarks/graphics/bookmarklet.gif
new file mode 100644
index 000000000..45b24709b
--- /dev/null
+++ b/mod/bookmarks/graphics/bookmarklet.gif
Binary files differ
diff --git a/mod/bookmarks/languages/en.php b/mod/bookmarks/languages/en.php
index e0c4a9e08..970b39415 100644
--- a/mod/bookmarks/languages/en.php
+++ b/mod/bookmarks/languages/en.php
@@ -1,91 +1,91 @@
<?php
+/**
+ * Bookmarks English language file
+ */
$english = array(
/**
* Menu items and titles
*/
-
'bookmarks' => "Bookmarks",
- 'bookmarks:add' => "Bookmark something",
- 'bookmarks:read' => "Bookmark list",
+ 'bookmarks:add' => "Add a bookmark",
+ 'bookmarks:edit' => "Edit bookmark",
+ 'bookmarks:owner' => "%s's bookmarks",
'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:everyone' => "All site bookmarks",
+ 'bookmarks:this' => "Bookmark this page",
'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:shareditem' => "Bookmarked item",
+ 'bookmarks:morebookmarks' => "More bookmarks",
+ 'bookmarks:more' => "More",
'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:new' => "A new bookmark",
+ 'bookmarks:address' => "Address of the bookmark",
+ 'bookmarks:none' => 'No bookmarks',
+
+ 'bookmarks:notification' =>
+'%s added a new bookmark:
+
+%s - %s
+%s
+
+View and comment on the new bookmark:
+%s
+',
+
'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:numbertodisplay' => 'Number of bookmarks to display',
+
'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',
+
+ 'river:create:object:bookmarks' => '%s bookmarked %s',
+ 'river:comment:object:bookmarks' => '%s commented on a bookmark %s',
+ 'bookmarks:river:annotate' => 'a comment on this bookmark',
'bookmarks:river:item' => 'an item',
- 'item:object:bookmarks' => 'Bookmarked items',
+ 'item:object:bookmarks' => 'Bookmarks',
+ 'bookmarks:group' => 'Group bookmarks',
'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: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.",
+ 'bookmarks:widget:description' => "Display 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
*/
'bookmarks:save:success' => "Your item was successfully bookmarked.",
- 'bookmarks:delete:success' => "Your bookmarked item was successfully deleted.",
+ 'bookmarks:delete:success' => "Your bookmark was deleted.",
/**
* Error messages
*/
- '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:save:failed' => "Your bookmark could not be saved. Make sure you've entered a title and address and then try again.",
+ 'bookmarks:save:invalid' => "The address of the bookmark is invalid and could not be saved.",
+ 'bookmarks:delete:failed' => "Your bookmark 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/lib/bookmarks.php b/mod/bookmarks/lib/bookmarks.php
new file mode 100644
index 000000000..9a9dff18c
--- /dev/null
+++ b/mod/bookmarks/lib/bookmarks.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Bookmarks helper functions
+ *
+ * @package Bookmarks
+ */
+
+/**
+ * Prepare the add/edit form variables
+ *
+ * @param ElggObject $bookmark A bookmark object.
+ * @return array
+ */
+function bookmarks_prepare_form_vars($bookmark = null) {
+ // input names => defaults
+ $values = array(
+ 'title' => get_input('title', ''), // bookmarklet support
+ 'address' => get_input('address', ''),
+ 'description' => '',
+ 'access_id' => ACCESS_DEFAULT,
+ 'tags' => '',
+ 'shares' => array(),
+ 'container_guid' => elgg_get_page_owner_guid(),
+ 'guid' => null,
+ 'entity' => $bookmark,
+ );
+
+ if ($bookmark) {
+ foreach (array_keys($values) as $field) {
+ if (isset($bookmark->$field)) {
+ $values[$field] = $bookmark->$field;
+ }
+ }
+ }
+
+ if (elgg_is_sticky_form('bookmarks')) {
+ $sticky_values = elgg_get_sticky_values('bookmarks');
+ foreach ($sticky_values as $key => $value) {
+ $values[$key] = $value;
+ }
+ }
+
+ elgg_clear_sticky_form('bookmarks');
+
+ return $values;
+}
diff --git a/mod/bookmarks/manifest.xml b/mod/bookmarks/manifest.xml
index f9cf0b4c0..b95af87f8 100644
--- a/mod/bookmarks/manifest.xml
+++ b/mod/bookmarks/manifest.xml
@@ -1,12 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
-<plugin_manifest>
- <field key="author" value="Curverider" />
- <field key="version" value="1.7" />
- <field key="description" value="Elgg bookmarks plugin." />
- <field key="website" value="http://www.elgg.org/" />
- <field key="copyright" value="(C) Curverider 2008-2010" />
- <field key="licence" value="GNU Public License version 2" />
- <field key="elgg_version" value="2010030101" />
- <field key="elgg_install_state" value="enabled" />
- <field key="admin_interface" value="simple" />
+<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
+ <name>Bookmarks</name>
+ <author>Core developers</author>
+ <version>1.8</version>
+ <category>bundled</category>
+ <category>content</category>
+ <category>widget</category>
+ <blurb>Add and comment on bookmarks.</blurb>
+ <description>Adds the ability for users to bookmark internal and external sites. Other users can then comment on the bookmarks.</description>
+ <website>http://www.elgg.org/</website>
+ <copyright>See COPYRIGHT.txt</copyright>
+ <license>GNU General Public License version 2</license>
+ <requires>
+ <type>elgg_release</type>
+ <version>1.8</version>
+ </requires>
+ <activate_on_install>true</activate_on_install>
</plugin_manifest>
diff --git a/mod/bookmarks/pages/bookmarks/add.php b/mod/bookmarks/pages/bookmarks/add.php
new file mode 100644
index 000000000..d80d4a4bc
--- /dev/null
+++ b/mod/bookmarks/pages/bookmarks/add.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Add bookmark page
+ *
+ * @package Bookmarks
+ */
+
+$page_owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo('bookmarks:add');
+elgg_push_breadcrumb($title);
+
+$vars = bookmarks_prepare_form_vars();
+$content = elgg_view_form('bookmarks/save', array(), $vars);
+
+$body = elgg_view_layout('content', array(
+ 'filter' => '',
+ 'content' => $content,
+ 'title' => $title,
+));
+
+echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/bookmarks/pages/bookmarks/all.php b/mod/bookmarks/pages/bookmarks/all.php
new file mode 100644
index 000000000..5c6011ad9
--- /dev/null
+++ b/mod/bookmarks/pages/bookmarks/all.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Elgg bookmarks plugin everyone page
+ *
+ * @package ElggBookmarks
+ */
+
+elgg_pop_breadcrumb();
+elgg_push_breadcrumb(elgg_echo('bookmarks'));
+
+elgg_register_title_button();
+
+$content = elgg_list_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'bookmarks',
+ 'full_view' => false,
+ 'view_toggle_type' => false,
+));
+
+if (!$content) {
+ $content = elgg_echo('bookmarks:none');
+}
+
+$title = elgg_echo('bookmarks:everyone');
+
+$body = elgg_view_layout('content', array(
+ 'filter_context' => 'all',
+ 'content' => $content,
+ 'title' => $title,
+ 'sidebar' => elgg_view('bookmarks/sidebar'),
+));
+
+echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/bookmarks/pages/bookmarks/bookmarklet.php b/mod/bookmarks/pages/bookmarks/bookmarklet.php
new file mode 100644
index 000000000..99866e385
--- /dev/null
+++ b/mod/bookmarks/pages/bookmarks/bookmarklet.php
@@ -0,0 +1,36 @@
+<?php
+/**
+* Elgg bookmarks plugin bookmarklet page
+*
+* @package Bookmarks
+*/
+
+gatekeeper();
+
+$container_guid = get_input('container_guid');
+$container = get_entity($container_guid);
+$page_owner = $container;
+
+if (elgg_instanceof($container, 'object')) {
+ $page_owner = $container->getContainerEntity();
+}
+
+elgg_set_page_owner_guid($page_owner->getGUID());
+
+$title = elgg_echo('bookmarks:bookmarklet');
+
+if ($page_owner instanceof ElggGroup) {
+ elgg_push_breadcrumb($page_owner->name, $page_owner->getURL());
+}
+
+elgg_push_breadcrumb($title);
+
+$content = elgg_view("bookmarks/bookmarklet");
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => false
+));
+
+echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/bookmarks/pages/bookmarks/edit.php b/mod/bookmarks/pages/bookmarks/edit.php
new file mode 100644
index 000000000..93b143c36
--- /dev/null
+++ b/mod/bookmarks/pages/bookmarks/edit.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Add bookmark page
+ *
+ * @package ElggBookmarks
+ */
+
+$bookmark_guid = get_input('guid');
+$bookmark = get_entity($bookmark_guid);
+
+if (!elgg_instanceof($bookmark, 'object', 'bookmarks') || !$bookmark->canEdit()) {
+ register_error(elgg_echo('bookmarks:unknown_bookmark'));
+ forward(REFERRER);
+}
+
+$page_owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo('bookmarks:edit');
+elgg_push_breadcrumb($title);
+
+$vars = bookmarks_prepare_form_vars($bookmark);
+$content = elgg_view_form('bookmarks/save', array(), $vars);
+
+$body = elgg_view_layout('content', array(
+ 'filter' => '',
+ 'content' => $content,
+ 'title' => $title,
+));
+
+echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/bookmarks/pages/bookmarks/friends.php b/mod/bookmarks/pages/bookmarks/friends.php
new file mode 100644
index 000000000..173996346
--- /dev/null
+++ b/mod/bookmarks/pages/bookmarks/friends.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Elgg bookmarks plugin friends page
+ *
+ * @package ElggBookmarks
+ */
+
+$page_owner = elgg_get_page_owner_entity();
+if (!$page_owner) {
+ forward('', '404');
+}
+
+elgg_push_breadcrumb($page_owner->name, "bookmarks/owner/$page_owner->username");
+elgg_push_breadcrumb(elgg_echo('friends'));
+
+elgg_register_title_button();
+
+$title = elgg_echo('bookmarks:friends');
+
+$content = list_user_friends_objects($page_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);
diff --git a/mod/bookmarks/pages/bookmarks/owner.php b/mod/bookmarks/pages/bookmarks/owner.php
new file mode 100644
index 000000000..b7b907916
--- /dev/null
+++ b/mod/bookmarks/pages/bookmarks/owner.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Elgg bookmarks plugin everyone page
+ *
+ * @package Bookmarks
+ */
+
+$page_owner = elgg_get_page_owner_entity();
+if (!$page_owner) {
+ forward('', '404');
+}
+
+elgg_push_breadcrumb($page_owner->name);
+
+elgg_register_title_button();
+
+$content .= elgg_list_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'bookmarks',
+ 'container_guid' => $page_owner->guid,
+ 'full_view' => false,
+ 'view_toggle_type' => false
+));
+
+if (!$content) {
+ $content = elgg_echo('bookmarks:none');
+}
+
+$title = elgg_echo('bookmarks:owner', array($page_owner->name));
+
+$filter_context = '';
+if ($page_owner->getGUID() == elgg_get_logged_in_user_guid()) {
+ $filter_context = 'mine';
+}
+
+$vars = array(
+ 'filter_context' => $filter_context,
+ 'content' => $content,
+ 'title' => $title,
+ 'sidebar' => elgg_view('bookmarks/sidebar'),
+);
+
+// don't show filter if out of filter context
+if ($page_owner instanceof ElggGroup) {
+ $vars['filter'] = false;
+}
+
+$body = elgg_view_layout('content', $vars);
+
+echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/bookmarks/pages/bookmarks/view.php b/mod/bookmarks/pages/bookmarks/view.php
new file mode 100644
index 000000000..70a6a5bfe
--- /dev/null
+++ b/mod/bookmarks/pages/bookmarks/view.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * View a bookmark
+ *
+ * @package ElggBookmarks
+ */
+
+$bookmark = get_entity(get_input('guid'));
+if (!$bookmark) {
+ register_error(elgg_echo('noaccess'));
+ $_SESSION['last_forward_from'] = current_page_url();
+ forward('');
+}
+
+$page_owner = elgg_get_page_owner_entity();
+
+$crumbs_title = $page_owner->name;
+
+if (elgg_instanceof($page_owner, 'group')) {
+ elgg_push_breadcrumb($crumbs_title, "bookmarks/group/$page_owner->guid/all");
+} else {
+ elgg_push_breadcrumb($crumbs_title, "bookmarks/owner/$page_owner->username");
+}
+
+$title = $bookmark->title;
+
+elgg_push_breadcrumb($title);
+
+$content = elgg_view_entity($bookmark, array('full_view' => true));
+$content .= elgg_view_comments($bookmark);
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/bookmarks/start.php b/mod/bookmarks/start.php
index 2c82ca674..caea43587 100644
--- a/mod/bookmarks/start.php
+++ b/mod/bookmarks/start.php
@@ -5,247 +5,204 @@
* @package ElggBookmarks
*/
-// Bookmarks initialisation function
+elgg_register_event_handler('init', 'system', 'bookmarks_init');
+
+/**
+ * Bookmark init
+ */
function bookmarks_init() {
- // Grab the config global
- global $CONFIG;
- //add a tools menu option
- add_menu(elgg_echo('bookmarks'), elgg_get_site_url() . 'pg/bookmarks');
+ $root = dirname(__FILE__);
+ elgg_register_library('elgg:bookmarks', "$root/lib/bookmarks.php");
- // Register a page handler, so we can have nice URLs
- register_page_handler('bookmarks', 'bookmarks_page_handler');
+ // actions
+ $action_path = "$root/actions/bookmarks";
+ elgg_register_action('bookmarks/save', "$action_path/save.php");
+ elgg_register_action('bookmarks/delete', "$action_path/delete.php");
+ elgg_register_action('bookmarks/share', "$action_path/share.php");
- // Add our CSS
- elgg_extend_view('css', 'bookmarks/css');
+ // menus
+ elgg_register_menu_item('site', array(
+ 'name' => 'bookmarks',
+ 'text' => elgg_echo('bookmarks'),
+ 'href' => 'bookmarks/all'
+ ));
- // Register granular notification for this type
- if (is_callable('register_notification_object')) {
- register_notification_object('object', 'bookmarks', elgg_echo('bookmarks:new'));
- }
+ elgg_register_plugin_hook_handler('register', 'menu:page', 'bookmarks_page_menu');
+ elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'bookmarks_owner_block_menu');
- // Listen to notification events and supply a more useful message
- register_plugin_hook('notify:entity:message', 'object', 'bookmarks_notify_message');
+ elgg_register_page_handler('bookmarks', 'bookmarks_page_handler');
- // Register a URL handler for shared items
- register_entity_url_handler('bookmark_url','object','bookmarks');
+ elgg_extend_view('css/elgg', 'bookmarks/css');
+ elgg_extend_view('js/elgg', 'bookmarks/js');
- // Shares widget
- add_widget_type('bookmarks',elgg_echo("bookmarks"),elgg_echo("bookmarks:widget:description"));
+ elgg_register_widget_type('bookmarks', elgg_echo('bookmarks'), elgg_echo('bookmarks:widget:description'));
- // Register entity type
- register_entity_type('object','bookmarks');
+ if (elgg_is_logged_in()) {
+ $user_guid = elgg_get_logged_in_user_guid();
+ $address = urlencode(current_page_url());
- // Add group menu option
- add_group_tool_option('bookmarks',elgg_echo('bookmarks:enablebookmarks'),true);
+ elgg_register_menu_item('extras', array(
+ 'name' => 'bookmark',
+ 'text' => elgg_view_icon('push-pin-alt'),
+ 'href' => "bookmarks/add/$user_guid?address=$address",
+ 'title' => elgg_echo('bookmarks:this'),
+ 'rel' => 'nofollow',
+ ));
+ }
+ // Register granular notification for this type
+ register_notification_object('object', 'bookmarks', elgg_echo('bookmarks:new'));
- // Extend Groups profile page
- elgg_extend_view('groups/tool_latest','bookmarks/group_bookmarks');
+ // Listen to notification events and supply a more useful message
+ elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'bookmarks_notify_message');
- // Register profile menu hook
- register_plugin_hook('profile_menu', 'profile', 'bookmarks_profile_menu');
-}
+ // Register bookmarks view for ecml parsing
+ elgg_register_plugin_hook_handler('get_views', 'ecml', 'bookmarks_ecml_views_hook');
-/**
- * Sidebar menu for bookmarks
- *
- */
-function bookmarks_pagesetup() {
- global $CONFIG;
+ // Register a URL handler for bookmarks
+ elgg_register_entity_url_handler('object', 'bookmarks', 'bookmark_url');
- $page_owner = elgg_get_page_owner();
+ // Register entity type for search
+ elgg_register_entity_type('object', 'bookmarks');
- // Add group bookmark menu item
- if (isloggedin()) {
- 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), elgg_get_site_url() . "pg/bookmarks/" . $page_owner->username . '/items');
- }
- }
- }
+ // Groups
+ add_group_tool_option('bookmarks', elgg_echo('bookmarks:enablebookmarks'), true);
+ elgg_extend_view('groups/tool_latest', 'bookmarks/group_module');
}
/**
- * Bookmarks page handler
- * Expects URLs like:
- * pg/bookmarks/username/[friends||items||add||edit||bookmarklet]
+ * Dispatcher for bookmarks.
+ *
+ * URLs take the form of
+ * All bookmarks: bookmarks/all
+ * User's bookmarks: bookmarks/owner/<username>
+ * Friends' bookmarks: bookmarks/friends/<username>
+ * View bookmark: bookmarks/view/<guid>/<title>
+ * New bookmark: bookmarks/add/<guid> (container: user, group, parent)
+ * Edit bookmark: bookmarks/edit/<guid>
+ * Group bookmarks: bookmarks/group/<guid>/all
+ * Bookmarklet: bookmarks/bookmarklet/<guid> (user)
*
+ * Title is ignored
*
- * @param array $page From the page_handler function
- * @return true|false Depending on success
+ * @param array $page
+ * @return bool
*/
function bookmarks_page_handler($page) {
- global $CONFIG;
-
- // The first component of a bookmarks URL is the username
- // If the username is set_input()'d and has group:NN in it, magic happens
- // and the elgg_get_page_owner() is the group.
- if (isset($page[0])) {
- $owner_name = $page[0];
- set_input('username', $owner_name);
- // grab the page owner here so the group magic works.
- $owner = elgg_get_page_owner();
- } else {
- set_page_owner(get_loggedin_userid());
- }
-
- // owner name passed but invalid.
- if ($owner_name && !$owner) {
- $sidebar = elgg_view('bookmarks/sidebar', array('object_type' => 'bookmarks'));
- $content = elgg_echo("bookmarks:unknown_user");
+ elgg_load_library('elgg:bookmarks');
- $body = elgg_view_layout('one_column_with_sidebar', $content, $sidebar);
- echo page_draw(sprintf(elgg_echo("bookmarks:user"), elgg_get_page_owner()->name), $body);
-
- return FALSE;
+ if (!isset($page[0])) {
+ $page[0] = 'all';
}
- $logged_in_user = get_loggedin_user();
- $section = (isset($page[1])) ? $page[1] : $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(sprintf(elgg_echo('bookmarks:friends'), $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(sprintf(elgg_echo('bookmarks:user'), $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();
+ elgg_push_breadcrumb(elgg_echo('bookmarks'), 'bookmarks/all');
- $content = elgg_view_title(elgg_echo('bookmarks:bookmarklet'));
- $content .= elgg_view('bookmarks/bookmarklet');
-
- break;
+ // old group usernames
+ if (substr_count($page[0], 'group:')) {
+ preg_match('/group\:([0-9]+)/i', $page[0], $matches);
+ $guid = $matches[1];
+ if ($entity = get_entity($guid)) {
+ bookmarks_url_forwarder($page);
}
+ }
- } else {
- // no owner name passed, show everything.
- $content = elgg_list_entities(array('type' => 'object', 'subtype' => 'bookmarks'));
- $context = 'everyone';
+ // user usernames
+ $user = get_user_by_username($page[0]);
+ if ($user) {
+ bookmarks_url_forwarder($page);
}
- // sidebar
- if ($logged_in_user != $owner) {
- $area3 = elgg_view('bookmarks/ownerblock');
+ $pages = dirname(__FILE__) . '/pages/bookmarks';
+
+ switch ($page[0]) {
+ case "all":
+ include "$pages/all.php";
+ break;
+
+ case "owner":
+ include "$pages/owner.php";
+ break;
+
+ case "friends":
+ include "$pages/friends.php";
+ break;
+
+ case "view":
+ set_input('guid', $page[1]);
+ include "$pages/view.php";
+ break;
+ case 'read': // Elgg 1.7 compatibility
+ register_error(elgg_echo("changebookmark"));
+ forward("bookmarks/view/{$page[1]}");
+ break;
+
+ case "add":
+ gatekeeper();
+ include "$pages/add.php";
+ break;
+
+ case "edit":
+ gatekeeper();
+ set_input('guid', $page[1]);
+ include "$pages/edit.php";
+ break;
+
+ case 'group':
+ group_gatekeeper();
+ include "$pages/owner.php";
+ break;
+
+ case "bookmarklet":
+ set_input('container_guid', $page[1]);
+ include "$pages/bookmarklet.php";
+ break;
+
+ default:
+ return false;
}
- $sidebar = elgg_view('bookmarks/sidebar', array('object_type' => 'bookmarks'));
+ elgg_pop_context();
+ return true;
+}
- if (isloggedin()){
- $sidebar .= elgg_view('bookmarks/bookmarklet');
- }
+/**
+ * Forward to the new style of URLs
+ *
+ * @param string $page
+ */
+function bookmarks_url_forwarder($page) {
+ global $CONFIG;
- // 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;
+ if (!isset($page[1])) {
+ $page[1] = 'items';
}
- //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' => "{$CONFIG->url}pg/bookmarks/",
- 'new_link' => "{$CONFIG->url}pg/bookmarks/{$owner_name}/add"
- ));
- }
- }else{
- $header .= elgg_view("page_elements/content_header", array(
- 'context' => $context,
- 'type' => 'bookmarks',
- 'all_link' => "{$CONFIG->url}pg/bookmarks/",
- 'new_link' => "{$CONFIG->url}pg/bookmarks/{$owner_name}/add"
- ));
+ switch ($page[1]) {
+ case "read":
+ $url = "{$CONFIG->wwwroot}bookmarks/view/{$page[2]}/{$page[3]}";
+ break;
+ case "inbox":
+ $url = "{$CONFIG->wwwroot}bookmarks/inbox/{$page[0]}";
+ break;
+ case "friends":
+ $url = "{$CONFIG->wwwroot}bookmarks/friends/{$page[0]}";
+ break;
+ case "add":
+ $url = "{$CONFIG->wwwroot}bookmarks/add/{$page[0]}";
+ break;
+ case "items":
+ $url = "{$CONFIG->wwwroot}bookmarks/owner/{$page[0]}";
+ break;
+ case "bookmarklet":
+ $url = "{$CONFIG->wwwroot}bookmarks/bookmarklet/{$page[0]}";
+ break;
}
- $content = $header . $content;
- $body = elgg_view_layout('one_column_with_sidebar', $content, $sidebar);
- echo page_draw(sprintf(elgg_echo("bookmarks:user"), elgg_get_page_owner()->name), $body);
-
- return TRUE;
+ register_error(elgg_echo("changebookmark"));
+ forward($url);
}
-
/**
* Populates the ->getUrl() method for bookmarked objects
*
@@ -253,20 +210,44 @@ function bookmarks_page_handler($page) {
* @return string bookmarked item URL
*/
function bookmark_url($entity) {
-
global $CONFIG;
+
$title = $entity->title;
$title = elgg_get_friendly_title($title);
- return $CONFIG->url . "pg/bookmarks/" . $entity->getOwnerEntity()->username . "/read/" . $entity->getGUID() . "/" . $title;
+ return $CONFIG->url . "bookmarks/view/" . $entity->getGUID() . "/" . $title;
+}
+
+/**
+ * Add a menu item to an ownerblock
+ *
+ * @param string $hook
+ * @param string $type
+ * @param array $return
+ * @param array $params
+ */
+function bookmarks_owner_block_menu($hook, $type, $return, $params) {
+ if (elgg_instanceof($params['entity'], 'user')) {
+ $url = "bookmarks/owner/{$params['entity']->username}";
+ $item = new ElggMenuItem('bookmarks', elgg_echo('bookmarks'), $url);
+ $return[] = $item;
+ } else {
+ if ($params['entity']->bookmarks_enable != 'no') {
+ $url = "bookmarks/group/{$params['entity']->guid}/all";
+ $item = new ElggMenuItem('bookmarks', elgg_echo('bookmarks:group'), $url);
+ $return[] = $item;
+ }
+ }
+
+ return $return;
}
/**
- * Returns a more meaningful message
+ * Returns the body of a notification message
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
+ * @param string $hook
+ * @param string $entity_type
+ * @param string $returnvalue
+ * @param array $params
*/
function bookmarks_notify_message($hook, $entity_type, $returnvalue, $params) {
$entity = $params['entity'];
@@ -275,65 +256,61 @@ function bookmarks_notify_message($hook, $entity_type, $returnvalue, $params) {
if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'bookmarks')) {
$descr = $entity->description;
$title = $entity->title;
- global $CONFIG;
- $url = elgg_get_site_url() . "pg/view/" . $entity->guid;
- if ($method == 'sms') {
- $owner = $entity->getOwnerEntity();
- return $owner->name . ' ' . elgg_echo("bookmarks:via") . ': ' . $url . ' (' . $title . ')';
- }
- if ($method == 'email') {
- $owner = $entity->getOwnerEntity();
- return $owner->name . ' ' . elgg_echo("bookmarks:via") . ': ' . $title . "\n\n" . $descr . "\n\n" . $entity->getURL();
- }
- if ($method == 'web') {
- $owner = $entity->getOwnerEntity();
- return $owner->name . ' ' . elgg_echo("bookmarks:via") . ': ' . $title . "\n\n" . $descr . "\n\n" . $entity->getURL();
- }
-
+ $owner = $entity->getOwnerEntity();
+
+ return elgg_echo('bookmarks:notification', array(
+ $owner->name,
+ $title,
+ $entity->address,
+ $descr,
+ $entity->getURL()
+ ));
}
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;
-}
+ * Add a page menu menu.
+ *
+ * @param string $hook
+ * @param string $type
+ * @param array $return
+ * @param array $params
+ */
+function bookmarks_page_menu($hook, $type, $return, $params) {
+ if (elgg_is_logged_in()) {
+ // only show bookmarklet in bookmark pages
+ if (elgg_in_context('bookmarks')) {
+ $page_owner = elgg_get_page_owner_entity();
+ if (!$page_owner) {
+ $page_owner = elgg_get_logged_in_user_entity();
+ }
-function bookmarks_profile_menu($hook, $entity_type, $return_value, $params) {
- global $CONFIG;
+ if ($page_owner instanceof ElggGroup) {
+ if (!$page_owner->isMember()) {
+ return $return;
+ }
+ $title = elgg_echo('bookmarks:bookmarklet:group');
+ } else {
+ $title = elgg_echo('bookmarks:bookmarklet');
+ }
- $return_value[] = array(
- 'text' => elgg_echo('bookmarks'),
- 'href' => "{$CONFIG->url}pg/bookmarks/{$params['owner']->username}",
- );
+ $return[] = new ElggMenuItem('bookmarklet', $title, 'bookmarks/bookmarklet/' . $page_owner->getGUID());
+ }
+ }
- return $return_value;
+ return $return;
}
-// Make sure the initialisation function is called on initialisation
-register_elgg_event_handler('init','system','bookmarks_init');
-register_elgg_event_handler('pagesetup','system','bookmarks_pagesetup');
-
-// Register actions
-global $CONFIG;
-register_action('bookmarks/add',false,$CONFIG->pluginspath . "bookmarks/actions/add.php");
-register_action('bookmarks/edit',false,$CONFIG->pluginspath . "bookmarks/actions/edit.php");
-register_action('bookmarks/delete',false,$CONFIG->pluginspath . "bookmarks/actions/delete.php");
-register_action('bookmarks/reference',false,$CONFIG->pluginspath . "bookmarks/actions/reference.php");
-register_action('bookmarks/remove',false,$CONFIG->pluginspath . "bookmarks/actions/remove.php");
+/**
+ * Return bookmarks views to parse for ecml
+ *
+ * @param string $hook
+ * @param string $type
+ * @param array $return
+ * @param array $params
+ */
+function bookmarks_ecml_views_hook($hook, $type, $return, $params) {
+ $return['object/bookmarks'] = elgg_echo('item:object:bookmarks');
+ return $return;
+}
diff --git a/mod/bookmarks/views/default/bookmarks/bookmarklet.php b/mod/bookmarks/views/default/bookmarks/bookmarklet.php
index 5cb8ca6d8..b3e9737fe 100644
--- a/mod/bookmarks/views/default/bookmarks/bookmarklet.php
+++ b/mod/bookmarks/views/default/bookmarks/bookmarklet.php
@@ -1,32 +1,35 @@
<?php
/**
- * Elgg get bookmarks bookmarklet view
+ * Bookmarklet
*
- * @package ElggBookmarks
+ * @package Bookmarks
*/
-$page_owner = elgg_get_page_owner();
-$bookmarktext = elgg_echo("bookmarks:this");
+$page_owner = elgg_get_page_owner_entity();
if ($page_owner instanceof ElggGroup) {
- $bookmarktext = sprintf(elgg_echo("bookmarks:this:group"), $page_owner->name);
- $name = "group:$page_owner->guid";
+ $title = elgg_echo("bookmarks:this:group", array($page_owner->name));
} else {
- $name = $page_owner->username;
+ $title = elgg_echo("bookmarks:this");
}
-if (!$name && ($user = get_loggedin_user())) {
+$guid = $page_owner->getGUID();
+
+if (!$name && ($user = elgg_get_logged_in_user_entity())) {
$name = $user->username;
}
-?>
-<h3><?php echo elgg_echo('bookmarks:browser_bookmarklet')?></h3>
-<a href="javascript:location.href='<?php echo elgg_get_site_url(); ?>pg/bookmarks/<?php echo $name; ?>/add?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)"> <img src="<?php echo elgg_get_site_url(); ?>_graphics/elgg_bookmarklet.gif" border="0" title="<?php echo elgg_echo('bookmarks:this');?>" /> </a>
-<br />
-<a class="link" onclick="elgg_slide_toggle(this,'#elgg_sidebar','.bookmarklet');">Instructions</a>
+$url = elgg_get_site_url();
+$img = elgg_view('output/img', array(
+ 'src' => 'mod/bookmarks/graphics/bookmarklet.gif',
+ 'alt' => $title,
+));
+$bookmarklet = "<a href=\"javascript:location.href='{$url}bookmarks/add/$guid?address='"
+ . "+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)\">"
+ . $img . "</a>";
-<div class="bookmarklet hidden">
- <p><?php echo elgg_echo("bookmarks:bookmarklet:description"); ?></p>
- <p><?php echo elgg_echo("bookmarks:bookmarklet:descriptionie"); ?></p>
- <p><?php echo elgg_echo("bookmarks:bookmarklet:description:conclusion"); ?></p>
-</div> \ No newline at end of file
+?>
+<p><?php echo elgg_echo("bookmarks:bookmarklet:description"); ?></p>
+<p><?php echo $bookmarklet; ?></p>
+<p><?php echo elgg_echo("bookmarks:bookmarklet:descriptionie"); ?></p>
+<p><?php echo elgg_echo("bookmarks:bookmarklet:description:conclusion"); ?></p>
diff --git a/mod/bookmarks/views/default/bookmarks/css.php b/mod/bookmarks/views/default/bookmarks/css.php
index 30df44744..0d734c847 100644
--- a/mod/bookmarks/views/default/bookmarks/css.php
+++ b/mod/bookmarks/views/default/bookmarks/css.php
@@ -1,46 +1,3 @@
-<?php
-/**
- * Elgg bookmarks CSS
- *
- * @package ElggBookmarks
- */
-?>
-
-.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;
-}
-*/
+.elgg-icon-bookmark {
+ background: transparent url(<?php echo elgg_get_site_url();?>mod/bookmarks/graphics/bookmark.gif);
+} \ No newline at end of file
diff --git a/mod/bookmarks/views/default/bookmarks/form.php b/mod/bookmarks/views/default/bookmarks/form.php
deleted file mode 100644
index 927ed445d..000000000
--- a/mod/bookmarks/views/default/bookmarks/form.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-
-/**
- * Elgg bookmarks plugin form
- *
- * @package ElggBookmarks
- */
-
-if(isset($vars['entity'])){
- $guid = $vars['entity']->guid;
- $title = $vars['entity']->title;
- $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 = '';
- $title = get_input('title',"");
- $title = stripslashes($title); // strip slashes from URL encoded apostrophes
- $address = get_input('address',"");
- $notes = '';
- if ($address == "previous")
- $address = $_SERVER['HTTP_REFERER'];
- $tags = array();
- if(elgg_get_page_owner() instanceof ElggGroup){
- //if in a group, set the access level to default to the group
- $access_id = elgg_get_page_owner()->group_acl;
- }else{
- $access_id = get_default_access(get_loggedin_user());
- }
- $owner = get_loggedin_user();
- $url = "action/bookmarks/add";
-}
-?>
-<form id="bookmark_edit_form" class="margin_top" action="<?php echo elgg_get_site_url() . $url; ?>" method="post">
- <?php echo elgg_view('input/securitytoken'); ?>
- <p>
- <label>
- <?php echo elgg_echo('title'); ?>
- <?php
- echo elgg_view('input/text',array(
- 'internalname' => 'title',
- 'value' => $title,
- ));
- ?>
- </label>
- </p>
- <p>
- <label>
- <?php echo elgg_echo('bookmarks:address'); ?>
- <?php
- echo elgg_view('input/url',array(
- 'internalname' => 'address',
- 'value' => $address,
- ));
- ?>
- </label>
- </p>
- <p>
- <label>
- <?php echo elgg_echo('bookmarks:addnote'); ?>
- <br />
- <?php
-
- echo elgg_view('input/text',array(
- 'internalname' => 'notes',
- 'value' => $notes,
- ));
-
- ?>
- </label>
- </p>
- <p>
- <label>
- <?php echo elgg_echo('tags'); ?>
- <?php
- echo elgg_view('input/tags',array(
- 'internalname' => 'tags',
- 'value' => $tags,
- ));
- ?>
- </label>
- </p>
- <p>
- <label>
- <?php echo elgg_echo('access'); ?>
- <?php
- //if it is a group, pull out the group access view
- if(elgg_get_page_owner() instanceof ElggGroup){
- $access_options = group_access_options($owner);
- echo elgg_view('input/access', array('internalname' => 'access',
- 'value' => $access_id,
- 'options' => $access_options));
- }else{
- echo elgg_view('input/access', array('internalname' => 'access',
- 'value' => $access_id));
- }
- ?>
- </label>
- </p>
- <p>
- <?php echo $vars['container_guid'] ? elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $vars['container_guid'])) : ""; ?>
- <input type="hidden" value="<?php echo $guid; ?>" name="guid" />
- <input type="submit" onfocus="blur()" value="<?php echo elgg_echo('save'); ?>" />
- </p>
-</form>
diff --git a/mod/bookmarks/views/default/bookmarks/group_bookmarks.php b/mod/bookmarks/views/default/bookmarks/group_bookmarks.php
deleted file mode 100755
index 59619d587..000000000
--- a/mod/bookmarks/views/default/bookmarks/group_bookmarks.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-//grab the groups bookmarks
-$bookmarks = elgg_get_entities(array('type' => 'object', 'subtype' => 'bookmarks',
- 'container_guids' => elgg_get_page_owner_guid(), 'limit' => 6));
-?>
-<div class="group_tool_widget bookmarks">
-<span class="group_widget_link"><a href="<?php echo elgg_get_site_url() . "pg/bookmarks/" . elgg_get_page_owner()->username; ?>"><?php echo elgg_echo('link:view:all')?></a></span>
-<h3><?php echo elgg_echo('bookmarks:group') ?></h3>
-<?php
-if($bookmarks){
- foreach($bookmarks as $b){
-
- //get the owner
- $owner = $b->getOwnerEntity();
-
- //get the time
- $friendlytime = elgg_view_friendly_time($b->time_created);
-
- $info = "<div class='entity_listing_icon'>" . elgg_view('profile/icon',array('entity' => $b->getOwnerEntity(), 'size' => 'tiny')) . "</div>";
-
- //get the bookmark entries body
- $info .= "<div class='entity_listing_info'><p class='entity_title'><a href=\"{$b->address}\">{$b->title}</a></p>";
-
- //get the user details
- $info .= "<p class='entity_subtext'>{$friendlytime}</p>";
- $info .= "</div>";
- //display
- echo "<div class='entity_listing clearfloat'>" . $info . "</div>";
- }
-} else {
- $create_bookmark = elgg_get_site_url() . "pg/bookmarks/" . elgg_get_page_owner()->username . "/add";
- echo "<p class='margin_top'><a href=\"{$create_bookmark}\">" . elgg_echo("bookmarks:new") . "</a></p>";
-}
-echo "</div>"; \ No newline at end of file
diff --git a/mod/bookmarks/views/default/bookmarks/group_module.php b/mod/bookmarks/views/default/bookmarks/group_module.php
new file mode 100644
index 000000000..60a727819
--- /dev/null
+++ b/mod/bookmarks/views/default/bookmarks/group_module.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * List most recent bookmarks on group profile page
+ *
+ * @package Bookmarks
+ */
+
+$group = elgg_get_page_owner_entity();
+
+if ($group->bookmarks_enable == "no") {
+ return true;
+}
+
+$all_link = elgg_view('output/url', array(
+ 'href' => "bookmarks/group/$group->guid/all",
+ 'text' => elgg_echo('link:view:all'),
+ 'is_trusted' => true,
+));
+
+elgg_push_context('widgets');
+$options = array(
+ 'type' => 'object',
+ 'subtype' => 'bookmarks',
+ 'container_guid' => elgg_get_page_owner_guid(),
+ 'limit' => 6,
+ 'full_view' => false,
+ 'pagination' => false,
+);
+$content = elgg_list_entities($options);
+elgg_pop_context();
+
+if (!$content) {
+ $content = '<p>' . elgg_echo('bookmarks:none') . '</p>';
+}
+
+$new_link = elgg_view('output/url', array(
+ 'href' => "bookmarks/add/$group->guid",
+ 'text' => elgg_echo('bookmarks:add'),
+ 'is_trusted' => true,
+));
+
+echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('bookmarks:group'),
+ 'content' => $content,
+ 'all_link' => $all_link,
+ 'add_link' => $new_link,
+));
diff --git a/mod/bookmarks/views/default/bookmarks/js.php b/mod/bookmarks/views/default/bookmarks/js.php
new file mode 100644
index 000000000..c36823c09
--- /dev/null
+++ b/mod/bookmarks/views/default/bookmarks/js.php
@@ -0,0 +1,12 @@
+
+elgg.provide('elgg.bookmarks');
+
+elgg.bookmarks.init = function() {
+ // append the title to the url
+ var title = document.title;
+ var e = $('a.elgg-bookmark-page');
+ var link = e.attr('href') + '&title=' + encodeURIComponent(title);
+ e.attr('href', link);
+};
+
+elgg.register_hook_handler('init', 'system', elgg.bookmarks.init);
diff --git a/mod/bookmarks/views/default/bookmarks/sidebar.php b/mod/bookmarks/views/default/bookmarks/sidebar.php
new file mode 100644
index 000000000..811284ef3
--- /dev/null
+++ b/mod/bookmarks/views/default/bookmarks/sidebar.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Bookmarks sidebar
+ */
+
+echo elgg_view('page/elements/comments_block', array(
+ 'subtypes' => 'bookmarks',
+ 'owner_guid' => elgg_get_page_owner_guid(),
+));
+
+echo elgg_view('page/elements/tagcloud_block', array(
+ 'subtypes' => 'bookmarks',
+ 'owner_guid' => elgg_get_page_owner_guid(),
+));
diff --git a/mod/bookmarks/views/default/bookmarks/stats.php b/mod/bookmarks/views/default/bookmarks/stats.php
deleted file mode 100755
index 77c3d703f..000000000
--- a/mod/bookmarks/views/default/bookmarks/stats.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-/**
- * All site bookmark stats
- **/
-
-echo "<h3>".elgg_echo('bookmarks:stats')."</h3>";
-echo "<p>". $vars['count'] . " " . elgg_echo('bookmarks:resources') .".</p>"; \ No newline at end of file
diff --git a/mod/bookmarks/views/default/forms/bookmarks/save.php b/mod/bookmarks/views/default/forms/bookmarks/save.php
new file mode 100644
index 000000000..7d064a55b
--- /dev/null
+++ b/mod/bookmarks/views/default/forms/bookmarks/save.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Edit / add a bookmark
+ *
+ * @package Bookmarks
+ */
+
+// once elgg_view stops throwing all sorts of junk into $vars, we can use extract()
+$title = elgg_extract('title', $vars, '');
+$desc = elgg_extract('description', $vars, '');
+$address = elgg_extract('address', $vars, '');
+$tags = elgg_extract('tags', $vars, '');
+$access_id = elgg_extract('access_id', $vars, ACCESS_DEFAULT);
+$container_guid = elgg_extract('container_guid', $vars);
+$guid = elgg_extract('guid', $vars, null);
+$shares = elgg_extract('shares', $vars, array());
+
+?>
+<div>
+ <label><?php echo elgg_echo('title'); ?></label><br />
+ <?php echo elgg_view('input/text', array('name' => 'title', 'value' => $title)); ?>
+</div>
+<div>
+ <label><?php echo elgg_echo('bookmarks:address'); ?></label><br />
+ <?php echo elgg_view('input/text', array('name' => 'address', 'value' => $address)); ?>
+</div>
+<div>
+ <label><?php echo elgg_echo('description'); ?></label>
+ <?php echo elgg_view('input/longtext', array('name' => 'description', 'value' => $desc)); ?>
+</div>
+<div>
+ <label><?php echo elgg_echo('tags'); ?></label>
+ <?php echo elgg_view('input/tags', array('name' => 'tags', 'value' => $tags)); ?>
+</div>
+<?php
+
+$categories = elgg_view('input/categories', $vars);
+if ($categories) {
+ echo $categories;
+}
+
+?>
+<div>
+ <label><?php echo elgg_echo('access'); ?></label><br />
+ <?php echo elgg_view('input/access', array('name' => 'access_id', 'value' => $access_id)); ?>
+</div>
+<div class="elgg-foot">
+<?php
+
+echo elgg_view('input/hidden', array('name' => 'container_guid', 'value' => $container_guid));
+
+if ($guid) {
+ echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $guid));
+}
+
+echo elgg_view('input/submit', array('value' => elgg_echo("save")));
+
+?>
+</div> \ No newline at end of file
diff --git a/mod/bookmarks/views/default/object/bookmarks.php b/mod/bookmarks/views/default/object/bookmarks.php
index db41eee40..83bae2b13 100644
--- a/mod/bookmarks/views/default/object/bookmarks.php
+++ b/mod/bookmarks/views/default/object/bookmarks.php
@@ -5,87 +5,123 @@
* @package ElggBookmarks
*/
-$owner = $vars['entity']->getOwnerEntity();
-$friendlytime = elgg_view_friendly_time($vars['entity']->time_created);
-$address = $vars['entity']->address;
-
-// you used to be able to add without titles, which created unclickable bookmarks
-// putting a fake title in so you can click on it.
-if (!$title = $vars['entity']->title) {
- $title = elgg_echo('bookmarks:no_title');
-}
+$full = elgg_extract('full_view', $vars, FALSE);
+$bookmark = elgg_extract('entity', $vars, FALSE);
-$parsed_url = parse_url($address);
-$faviconurl = $parsed_url['scheme'] . "://" . $parsed_url['host'] . "/favicon.ico";
-
-//sort out the access level for display
-$object_acl = get_readable_access_level($vars['entity']->access_id);
-//files with these access level don't need an icon
-$general_access = array('Public', 'Logged in users', 'Friends');
-//set the right class for access level display - need it to set on groups and shared access only
-$is_group = get_entity($vars['entity']->container_guid);
-if($is_group instanceof ElggGroup){
- //get the membership type open/closed
- $membership = $is_group->membership;
- //we decided to show that the item is in a group, rather than its actual access level
- $object_acl = "Group: " . $is_group->name;
- if($membership == 2)
- $access_level = "class='access_level group_open'";
- else
- $access_level = "class='access_level group_closed'";
-}elseif($object_acl == 'Private'){
- $access_level = "class='access_level private'";
-}else{
- if(!in_array($object_acl, $general_access))
- $access_level = "class='access_level shared_collection'";
- else
- $access_level = "class='access_level entity_access'";
+if (!$bookmark) {
+ return;
}
-if($vars['entity']->description != '')
- $view_notes = "<a class='link' onclick=\"elgg_slide_toggle(this,'.entity_listing','.note');\">note</a>";
-else
- $view_notes = '';
-if (@file_exists($faviconurl)) {
- $icon = "<img src=\"{$faviconurl}\" />";
+$owner = $bookmark->getOwnerEntity();
+$owner_icon = elgg_view_entity_icon($owner, 'tiny');
+$container = $bookmark->getContainerEntity();
+$categories = elgg_view('output/categories', $vars);
+
+$link = elgg_view('output/url', array('href' => $bookmark->address));
+$description = elgg_view('output/longtext', array('value' => $bookmark->description, 'class' => 'pbl'));
+
+$owner_link = elgg_view('output/url', array(
+ 'href' => "bookmarks/owner/$owner->username",
+ 'text' => $owner->name,
+ 'is_trusted' => true,
+));
+$author_text = elgg_echo('byline', array($owner_link));
+
+$date = elgg_view_friendly_time($bookmark->time_created);
+
+$comments_count = $bookmark->countComments();
+//only display if there are commments
+if ($comments_count != 0) {
+ $text = elgg_echo("comments") . " ($comments_count)";
+ $comments_link = elgg_view('output/url', array(
+ 'href' => $bookmark->getURL() . '#comments',
+ 'text' => $text,
+ 'is_trusted' => true,
+ ));
} else {
- $icon = elgg_view("profile/icon", array('entity' => $owner,'size' => 'tiny',));
+ $comments_link = '';
}
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $vars['entity'],
+ 'handler' => 'bookmarks',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+));
+
+$subtitle = "$author_text $date $comments_link $categories";
-//delete
-if($vars['entity']->canEdit()){
- $delete .= "<span class='delete_button'>" . elgg_view('output/confirmlink',array(
- 'href' => elgg_get_site_url() . "action/bookmarks/delete?bookmark_guid=" . $vars['entity']->guid,
- 'text' => elgg_echo("delete"),
- 'confirm' => elgg_echo("bookmarks:delete:confirm"),
- )) . "</span>";
+// do not show the metadata and controls in widget view
+if (elgg_in_context('widgets')) {
+ $metadata = '';
}
-$info = "<div class='entity_metadata'><span {$access_level}>{$object_acl}</span>";
+if ($full && !elgg_in_context('gallery')) {
-// include a view for plugins to extend
-$info .= elgg_view("bookmarks/options",array('entity' => $vars['entity']));
-$info .= elgg_view_likes($vars['entity']); // include likes
+ $params = array(
+ 'entity' => $bookmark,
+ 'title' => false,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ );
+ $params = $params + $vars;
+ $summary = elgg_view('object/elements/summary', $params);
-//include edit and delete options
-if($vars['entity']->canEdit()){
- $info .= "<span class='entity_edit'><a href=\"".elgg_get_site_url()."pg/bookmarks/{$owner->username}/edit/{$vars['entity']->getGUID()}\">" . elgg_echo('edit') . "</a></span>";
- $info .= $delete;
-}
+ $bookmark_icon = elgg_view_icon('push-pin-alt');
+ $body = <<<HTML
+<div class="bookmark elgg-content mts">
+ $bookmark_icon<span class="elgg-heading-basic mbs">$link</span>
+ $description
+</div>
+HTML;
- $info .= "</div>";
+ echo elgg_view('object/elements/full', array(
+ 'entity' => $bookmark,
+ 'icon' => $owner_icon,
+ 'summary' => $summary,
+ 'body' => $body,
+ ));
-$info .= "<p class='entity_title'><a href=\"{$address}\" target=\"_blank\">{$title}</a></p>";
-$info .= "<p class='entity_subtext'>Bookmarked by <a href=\"".elgg_get_site_url()."pg/bookmarks/{$owner->username}\">{$owner->name}</a> {$friendlytime} {$view_notes}</p>";
+} elseif (elgg_in_context('gallery')) {
+ echo <<<HTML
+<div class="bookmarks-gallery-item">
+ <h3>$bookmark->title</h3>
+ <p class='subtitle'>$owner_link $date</p>
+</div>
+HTML;
+} else {
+ // brief view
+ $url = $bookmark->address;
+ $display_text = $url;
+ $excerpt = elgg_get_excerpt($bookmark->description);
+ if ($excerpt) {
+ $excerpt = " - $excerpt";
+ }
-$tags = elgg_view('output/tags', array('tags' => $vars['entity']->tags));
-if (!empty($tags)) {
- $info .= '<p class="tags">' . $tags . '</p>';
-}
-if($view_notes != ''){
- $info .= "<div class='note hidden'>". $vars['entity']->description . "</div>";
-}
+ if (strlen($url) > 25) {
+ $bits = parse_url($url);
+ if (isset($bits['host'])) {
+ $display_text = $bits['host'];
+ } else {
+ $display_text = elgg_get_excerpt($url, 100);
+ }
+ }
-//display
-echo elgg_view_listing($icon, $info); \ No newline at end of file
+ $link = elgg_view('output/url', array(
+ 'href' => $bookmark->address,
+ 'text' => $display_text,
+ ));
+
+ $content = elgg_view_icon('push-pin-alt') . "$link{$excerpt}";
+
+ $params = array(
+ 'entity' => $bookmark,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ 'content' => $content,
+ );
+ $params = $params + $vars;
+ $body = elgg_view('object/elements/summary', $params);
+
+ echo elgg_view_image_block($owner_icon, $body);
+}
diff --git a/mod/bookmarks/views/default/river/object/bookmarks/create.php b/mod/bookmarks/views/default/river/object/bookmarks/create.php
index dec4ab4d1..388f54ac9 100644
--- a/mod/bookmarks/views/default/river/object/bookmarks/create.php
+++ b/mod/bookmarks/views/default/river/object/bookmarks/create.php
@@ -1,22 +1,15 @@
<?php
/**
- * Elgg bookmark river entry view
+ * New bookmarks river entry
+ *
+ * @package Bookmarks
*/
-$performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject();
-$object = get_entity($vars['item']->object_guid);
-$is_group = get_entity($object->container_guid);
-$url = $object->getURL();
-$url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
-$string = sprintf(elgg_echo("bookmarks:river:created"),$url) . " ";
-$string .= "<a href=\"" . $object->address . "\">" . $object->title . "</a>";
-if(($is_group instanceof ElggGroup) && (get_context() != 'groups')){
- $string .= " " . elgg_echo('bookmarks:ingroup') . " <a href=\"{$is_group->getURL()}\">" . $is_group->name . "</a>";
-}
-$string .= " <span class='entity_subtext'>" . elgg_view_friendly_time($object->time_created);
-if (isloggedin()){
- $string .= "<a class='river_comment_form_button link'>Comment</a>";
- $string .= elgg_view('likes/forms/link', array('entity' => $object));
-}
-$string .= "</span>";
-echo $string; \ No newline at end of file
+$object = $vars['item']->getObjectEntity();
+$excerpt = elgg_get_excerpt($object->description);
+
+echo elgg_view('river/elements/layout', array(
+ 'item' => $vars['item'],
+ 'message' => $excerpt,
+ 'attachments' => elgg_view('output/url', array('href' => $object->address)),
+));
diff --git a/mod/bookmarks/views/default/widgets/bookmarks/content.php b/mod/bookmarks/views/default/widgets/bookmarks/content.php
new file mode 100644
index 000000000..0b85017fc
--- /dev/null
+++ b/mod/bookmarks/views/default/widgets/bookmarks/content.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Elgg bookmarks widget
+ *
+ * @package Bookmarks
+ */
+
+$max = (int) $vars['entity']->num_display;
+
+$options = array(
+ 'type' => 'object',
+ 'subtype' => 'bookmarks',
+ 'container_guid' => $vars['entity']->owner_guid,
+ 'limit' => $max,
+ 'full_view' => FALSE,
+ 'pagination' => FALSE,
+);
+$content = elgg_list_entities($options);
+
+echo $content;
+
+if ($content) {
+ $url = "bookmarks/owner/" . elgg_get_page_owner_entity()->username;
+ $more_link = elgg_view('output/url', array(
+ 'href' => $url,
+ 'text' => elgg_echo('bookmarks:more'),
+ 'is_trusted' => true,
+ ));
+ echo "<span class=\"elgg-widget-more\">$more_link</span>";
+} else {
+ echo elgg_echo('bookmarks:none');
+}
diff --git a/mod/bookmarks/views/default/widgets/bookmarks/edit.php b/mod/bookmarks/views/default/widgets/bookmarks/edit.php
index deba1c012..ed9c7fd88 100644
--- a/mod/bookmarks/views/default/widgets/bookmarks/edit.php
+++ b/mod/bookmarks/views/default/widgets/bookmarks/edit.php
@@ -1,24 +1,24 @@
<?php
/**
* Elgg bookmark widget edit view
- *
- * @package ElggBookmarks
+ *
+ * @package Bookmarks
*/
-?>
-<p>
- <?php echo elgg_echo('bookmarks:numbertodisplay'); ?>:
- <select name="params[num_display]">
-<?php
+// set default value
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 4;
+}
-for ($i=1; $i<=10; $i++) {
- $selected = '';
- if ($vars['entity']->num_display == $i) {
- $selected = "selected='selected'";
- }
+$params = array(
+ 'name' => 'params[num_display]',
+ 'value' => $vars['entity']->num_display,
+ 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
+);
+$dropdown = elgg_view('input/dropdown', $params);
- echo " <option value='{$i}' $selected >{$i}</option>\n";
-}
?>
- </select>
-</p> \ No newline at end of file
+<div>
+ <?php echo elgg_echo('bookmarks:numbertodisplay'); ?>:
+ <?php echo $dropdown; ?>
+</div>
diff --git a/mod/bookmarks/views/default/widgets/bookmarks/view.php b/mod/bookmarks/views/default/widgets/bookmarks/view.php
deleted file mode 100644
index b401f86ad..000000000
--- a/mod/bookmarks/views/default/widgets/bookmarks/view.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-/**
- * Elgg bookmark widget view
- *
- * @package ElggBookmarks
- */
-
-//get the num of shares the user want to display
-$num = $vars['entity']->num_display;
-
-//if no number has been set, default to 4
-if(!$num)
- $num = 4;
-
-//grab the users bookmarked items
-$bookmarks = elgg_get_entities('object', 'bookmarks',$vars['entity']->owner_guid, "", $num, 0, false);
-
-if($bookmarks){
-
- foreach($bookmarks as $b){
-
- //get the owner
- $owner = $b->getOwnerEntity();
-
- //get the time
- $friendlytime = elgg_view_friendly_time($s->time_created);
-
- //get the bookmark title
- $info = "<div class='river_object_bookmarks_create'><p class=\"shares_title\"><a href=\"{$b->address}\">{$b->title}</a></p></div>";
-
- //get the user details
- $info .= "<p class=\"shares_timestamp\"><small>{$friendlytime} ";
-
- //get the bookmark description
- if($s->description)
- $info .= "<a href=\"javascript:void(0);\" class=\"share_more_info\">".elgg_echo('bookmarks:more')."</a></small></p><div class=\"share_desc\"><p>{$s->description}</p></div>";
- else
- $info .= "</small></p>";
-
- //display
- echo "<div class='ContentWrapper bookmarks'>";
- echo "<div class='shares_widget_content'>" . $info . "</div></div>";
-
- }
-
- $user_inbox = elgg_get_site_url() . "pg/bookmarks/" . elgg_get_page_owner()->username;
- if (get_entities('object', 'bookmarks', $vars['entity']->container_guid, '', '', '', true) > $num)
- echo "<div class='ContentWrapper bookmarks more'><a href=\"{$user_inbox}\">".elgg_echo('bookmarks:read')."</a></div>";
-
-} else {
- echo "<div class='ContentWrapper'>" . elgg_echo("bookmarks:widget:description") . "</div>";
-} \ 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..1abda4710 100644
--- a/mod/bookmarks/views/rss/object/bookmarks.php
+++ b/mod/bookmarks/views/rss/object/bookmarks.php
@@ -1,22 +1,37 @@
<?php
/**
- * Elgg bookmark rss view
- *
+ * Bookmark RSS object view
+ *
* @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 = strip_tags($vars['entity']->description);
+ $title = elgg_get_excerpt($title, 32);
+}
- <item>
- <guid isPermaLink='true'><?php echo $vars['entity']->getURL(); ?></guid>
- <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>
- <link><?php echo $vars['entity']->address; ?></link>
- <title><![CDATA[<?php echo $title; ?>]]></title>
- <description><![CDATA[<?php echo (autop($vars['entity']->description)); ?>]]></description>
- </item>
+$permalink = htmlspecialchars($vars['entity']->getURL(), ENT_NOQUOTES, 'UTF-8');
+$pubdate = date('r', $vars['entity']->getTimeCreated());
+
+$url_text = elgg_echo('bookmarks:address');
+$link = elgg_view('output/url', array('href' => $vars['entity']->address));
+$description = $vars['entity']->description . "<p>$url_text: $link</p>";
+
+$creator = elgg_view('page/components/creator', $vars);
+$georss = elgg_view('page/components/georss', $vars);
+$extension = elgg_view('extensions/item');
+
+$item = <<<__HTML
+<item>
+ <guid isPermaLink="true">$permalink</guid>
+ <pubDate>$pubdate</pubDate>
+ <link>$permalink</link>
+ <title><![CDATA[$title]]></title>
+ <description><![CDATA[$description]]></description>
+ $creator$georss$extension
+</item>
+
+__HTML;
+
+echo $item;