aboutsummaryrefslogtreecommitdiff
path: root/mod/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'mod/bookmarks')
-rw-r--r--mod/bookmarks/actions/add.php41
-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.php23
-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/add.php58
-rw-r--r--mod/bookmarks/all.php36
-rw-r--r--mod/bookmarks/bookmarklet.php39
-rw-r--r--mod/bookmarks/friends.php34
-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/index.php57
-rw-r--r--mod/bookmarks/languages/en.php130
-rw-r--r--mod/bookmarks/lib/bookmarks.php46
-rw-r--r--mod/bookmarks/manifest.xml25
-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.php391
-rw-r--r--mod/bookmarks/views/default/bookmarks/bookmarklet.php50
-rw-r--r--mod/bookmarks/views/default/bookmarks/css.php53
-rw-r--r--mod/bookmarks/views/default/bookmarks/form.php112
-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.php10
-rw-r--r--mod/bookmarks/views/default/forms/bookmarks/save.php59
-rw-r--r--mod/bookmarks/views/default/object/bookmarks.php175
-rw-r--r--mod/bookmarks/views/default/river/object/bookmarks/create.php25
-rw-r--r--mod/bookmarks/views/default/widgets/bookmarks/content.php32
-rw-r--r--mod/bookmarks/views/default/widgets/bookmarks/edit.php37
-rw-r--r--mod/bookmarks/views/default/widgets/bookmarks/view.php56
-rw-r--r--mod/bookmarks/views/rss/object/bookmarks.php51
39 files changed, 1093 insertions, 979 deletions
diff --git a/mod/bookmarks/actions/add.php b/mod/bookmarks/actions/add.php
deleted file mode 100644
index be2f79f82..000000000
--- a/mod/bookmarks/actions/add.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-/**
- * Elgg bookmarks add/save action
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-gatekeeper();
-action_gatekeeper();
-//set some required variables
-$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);
-//create a new bookmark object
-$entity = new ElggObject;
-$entity->subtype = "bookmarks";
-$entity->owner_guid = get_loggedin_user()->getGUID();
-$entity->container_guid = (int)get_input('container_guid', get_loggedin_user()->getGUID());
-$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',$_SESSION['user']->guid,$entity->guid);
-} else {
- register_error(elgg_echo('bookmarks:save:failed'));
-}
-$account = get_entity((int)get_input('container_guid', get_loggedin_user()->getGUID()));
-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 5a35d44f5..000000000
--- a/mod/bookmarks/actions/delete.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Elgg bookmarks delete action
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-$guid = get_input('bookmark_guid',0);
-if ($entity = get_entity($guid)) {
- if ($entity->canEdit()) {
- if ($entity->delete()) {
- system_message(elgg_echo("bookmarks:delete:success"));
- forward($_SERVER['HTTP_REFERER']);
- }
- }
-}
-
-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 16e324154..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 ae79b78cd..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 b8b1ad6a3..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/add.php b/mod/bookmarks/add.php
deleted file mode 100644
index 7fe6e8956..000000000
--- a/mod/bookmarks/add.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/**
- * Elgg bookmarks plugin add bookmark page
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-global $CONFIG;
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// You need to be logged in for this one
-gatekeeper();
-
-// Get the current page's owner
-$page_owner = page_owner_entity();
-if ($page_owner === false || is_null($page_owner)) {
- $page_owner = $_SESSION['user'];
- set_page_owner($page_owner->getGUID());
-}
-if ($page_owner instanceof ElggGroup)
- $container = $page_owner->guid;
-
-//set up breadcrumbs
-elgg_push_breadcrumb(elgg_echo('bookmarks:all'), $CONFIG->wwwroot."mod/bookmarks/all.php");
-elgg_push_breadcrumb(elgg_echo("bookmarks:add"));
-
-$area1 .= elgg_view('navigation/breadcrumbs');
-
-// get the filter menu
-$area1 .= elgg_view('page_elements/content_header', array('context' => "action", 'type' => 'bookmarks'));
-
-// 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));
-}
-
-$area3 = elgg_view('bookmarks/ownerblock');
-// include a view for plugins to extend
-$area3 .= elgg_view("bookmarks/sidebar", array("object_type" => 'bookmarks'));
-// 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:add'),$body); \ No newline at end of file
diff --git a/mod/bookmarks/all.php b/mod/bookmarks/all.php
deleted file mode 100644
index 88258c855..000000000
--- a/mod/bookmarks/all.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * Elgg bookmarks plugin everyone page
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// get the filter menu
-$area1 = elgg_view('page_elements/content_header', array('context' => "everyone", 'type' => 'bookmarks'));
-
-// List bookmarks
-set_context('search');
-$area2 .= list_entities('object','bookmarks');
-set_context('bookmarks');
-
-// include a view for plugins to extend
-$area3 = elgg_view("bookmarks/sidebar", array("object_type" => 'bookmarks'));
-
-// if logged in, get the bookmarklet
-if(isloggedin()){
- $area3 .= elgg_view("bookmarks/bookmarklet");
-}
-// include statistics
-$area3 .= elgg_view("bookmarks/stats");
-// Format page
-$body = elgg_view_layout('one_column_with_sidebar', $area1.$area2, $area3);
-
-// Draw it
-echo page_draw(elgg_echo('bookmarks:all'),$body); \ No newline at end of file
diff --git a/mod/bookmarks/bookmarklet.php b/mod/bookmarks/bookmarklet.php
deleted file mode 100644
index f068e7c50..000000000
--- a/mod/bookmarks/bookmarklet.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-/**
- * Elgg bookmarks plugin bookmarklet page
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-gatekeeper();
-
-// Get the current page's owner
-$page_owner = page_owner_entity();
-if ($page_owner === false || is_null($page_owner) && ($_SESSION['user'])) {
- $page_owner = $_SESSION['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/friends.php b/mod/bookmarks/friends.php
deleted file mode 100644
index 158108553..000000000
--- a/mod/bookmarks/friends.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * Elgg bookmarks plugin friends' page
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// get the filter menu
-$area1 = elgg_view("page_elements/content_header", array('context' => "friends", 'type' => 'bookmarks'));
-
-// List bookmarks
-set_context('search');
-$area2 .= list_user_friends_objects(page_owner(),'bookmarks',10,false,false);
-set_context('bookmarks');
-
-// include a view for plugins to extend
-$area3 = elgg_view("bookmarks/sidebar", array("object_type" => 'bookmarks'));
-
-// if logged in, get the bookmarklet
-if(isloggedin()){
- $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:friends'),$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/index.php b/mod/bookmarks/index.php
deleted file mode 100644
index 0b8508cc9..000000000
--- a/mod/bookmarks/index.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/**
- * Elgg bookmarks plugin index page
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-global $CONFIG;
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-$page_owner = page_owner_entity();
-if ($page_owner === false || is_null($page_owner)) {
- $page_owner = $_SESSION['user'];
- set_page_owner($page_owner->getGUID());
-}
-
-elgg_push_breadcrumb(elgg_echo('bookmarks:all'), $CONFIG->wwwroot."mod/bookmarks/all.php");
-elgg_push_breadcrumb(sprintf(elgg_echo("bookmarks:user"),$page_owner->name));
-
-//set bookmarks header
-if(page_owner() == get_loggedin_userid()) {
- $area1 .= elgg_view('page_elements/content_header', array('context' => "own", 'type' => 'bookmarks'));
-} else {
- $area1 .= elgg_view('navigation/breadcrumbs');
- $area1 .= elgg_view('page_elements/content_header_member', array('type' => 'bookmarks'));
-}
-
-// List bookmarks
-set_context('search');
-$bookmarks = list_entities('object','bookmarks',page_owner());
-if(!$bookmarks && ($page_owner->guid == get_loggedin_user()->guid))
- $bookmarks = elgg_view('help/bookmarks');
-$area2 .= $bookmarks;
-set_context('bookmarks');
-
-//if the logged in user is not looking at their stuff, display the ownerblock
-if(page_owner() != get_loggedin_user()->guid){
- $area3 = elgg_view('bookmarks/ownerblock');
-}
-// include a view for plugins to extend
-$area3 .= elgg_view("bookmarks/sidebar", array("object_type" => 'bookmarks'));
-
-if(isloggedin()){
- // 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(sprintf(elgg_echo("bookmarks:user"),page_owner_entity()->name), $body); \ No newline at end of file
diff --git a/mod/bookmarks/languages/en.php b/mod/bookmarks/languages/en.php
index 87d7772ca..970b39415 100644
--- a/mod/bookmarks/languages/en.php
+++ b/mod/bookmarks/languages/en.php
@@ -1,89 +1,91 @@
<?php
+/**
+ * Bookmarks English language file
+ */
$english = array(
/**
* Menu items and titles
*/
-
- 'bookmarks' => "Bookmarks",
- 'bookmarks:add' => "Bookmark something",
- 'bookmarks:read' => "Bookmark list",
- 'bookmarks:friends' => "Friends' bookmarks",
- 'bookmarks:all' => "All site bookmarks",
- 'bookmarks:user' => "%s's bookmarks",
- 'bookmarks:workgroup' => "Work Group bookmarks",
- 'bookmarks:this' => "Bookmark this",
- 'bookmarks:this:group' => "Bookmark in %s",
- 'bookmarks:bookmarklet' => "Get bookmarklet",
- 'bookmarks:bookmarklet:group' => "Get community bookmarklet",
- 'bookmarks:inbox' => "Bookmarks inbox",
- 'bookmarks:more' => "View note",
- 'bookmarks:yours' => "My bookmarks",
- 'bookmarks:shareditem' => "Bookmarked item",
- 'bookmarks:with' => "Share with",
- 'bookmarks:new' => "Add a Bookmark",
- 'bookmarks:via' => "via bookmarks",
- 'bookmarks:address' => "Address of the resource to bookmark",
- 'bookmarks:addnote' => "Add a note",
- 'bookmarks:delete:confirm' => "Are you sure you want to delete this resource?",
- 'bookmarks:url' => 'URL',
- 'bookmarks:numbertodisplay' => 'Number of bookmarked items to display',
- 'bookmarks:edit:success' => "Bookmark successfully edited",
- 'bookmarks:edit:fail' => "There was a problem editing that bookmark, please try again.",
- 'bookmarks:shared' => "Bookmarked",
- 'bookmarks:visit' => "Visit resource",
- 'bookmarks:recent' => "Recent bookmarks",
-
- 'bookmarks:river:created' => '%s bookmarked',
- 'bookmarks:river:annotate' => 'posted a comment on this bookmarked item',
- 'bookmarks:river:item' => 'an item',
-
- 'item:object:bookmarks' => 'Bookmarked items',
-
- 'bookmarks:group' => 'Group bookmarks',
- 'bookmarks:enablebookmarks' => 'Enable community bookmarks',
- 'bookmarks:referenceadded' => 'You have added that bookmark as a reference',
- 'bookmarks:referenceerror' => 'There was a problem adding that bookmark as a reference',
- 'bookmarks:none' => 'You don\'t have any bookmarks',
- 'bookmarks:addref' => 'Add a reference',
- 'bookmarks:removed' => 'You have now removed that reference',
- 'bookmarks:removederror' => ' There was a problem removing that reference',
- 'bookmarks:remove:confirm' => 'Are you sure you want to remove this reference?',
+ 'bookmarks' => "Bookmarks",
+ 'bookmarks:add' => "Add a bookmark",
+ 'bookmarks:edit' => "Edit bookmark",
+ 'bookmarks:owner' => "%s's bookmarks",
+ 'bookmarks:friends' => "Friends' bookmarks",
+ 'bookmarks:everyone' => "All site bookmarks",
+ 'bookmarks:this' => "Bookmark this page",
+ 'bookmarks:this:group' => "Bookmark in %s",
+ 'bookmarks:bookmarklet' => "Get bookmarklet",
+ 'bookmarks:bookmarklet:group' => "Get group bookmarklet",
+ 'bookmarks:inbox' => "Bookmarks inbox",
+ 'bookmarks:morebookmarks' => "More bookmarks",
+ 'bookmarks:more' => "More",
+ 'bookmarks:with' => "Share with",
+ '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:numbertodisplay' => 'Number of bookmarks to display',
+
+ 'bookmarks:shared' => "Bookmarked",
+ 'bookmarks:visit' => "Visit resource",
+ 'bookmarks:recent' => "Recent bookmarks",
+
+ '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' => 'Bookmarks',
+
+ 'bookmarks:group' => 'Group bookmarks',
+ 'bookmarks: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.",
+ '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.",
+ 'bookmarks:bookmarklet:description' =>
+ "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:bookmarklet:description:conclusion' =>
+ "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:save:success' => "Your item was successfully bookmarked.",
+ 'bookmarks:delete:success' => "Your bookmark was deleted.",
/**
* Error messages
*/
- 'bookmarks:save:failed' => "Your bookmarked item could not be saved. Please try again.",
- 'bookmarks:delete:failed' => "Your bookmarked item could not be deleted. Please try again.",
-
-
+ 'bookmarks:save:failed' => "Your 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 687b62a7e..b95af87f8 100644
--- a/mod/bookmarks/manifest.xml
+++ b/mod/bookmarks/manifest.xml
@@ -1,10 +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" />
+<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 3df44f724..caea43587 100644
--- a/mod/bookmarks/start.php
+++ b/mod/bookmarks/start.php
@@ -3,137 +3,204 @@
* Elgg Bookmarks plugin
*
* @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
*/
-// 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'), $CONFIG->wwwroot . 'mod/bookmarks/all.php');
+ $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');
+
+ elgg_register_page_handler('bookmarks', 'bookmarks_page_handler');
+
+ elgg_extend_view('css/elgg', 'bookmarks/css');
+ elgg_extend_view('js/elgg', 'bookmarks/js');
+
+ elgg_register_widget_type('bookmarks', elgg_echo('bookmarks'), elgg_echo('bookmarks:widget:description'));
+
+ if (elgg_is_logged_in()) {
+ $user_guid = elgg_get_logged_in_user_guid();
+ $address = urlencode(current_page_url());
+
+ 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'));
// Listen to notification events and supply a more useful message
- register_plugin_hook('notify:entity:message', 'object', 'bookmarks_notify_message');
+ elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'bookmarks_notify_message');
- // Register a URL handler for shared items
- register_entity_url_handler('bookmark_url','object','bookmarks');
+ // Register bookmarks view for ecml parsing
+ elgg_register_plugin_hook_handler('get_views', 'ecml', 'bookmarks_ecml_views_hook');
- // Shares widget
- add_widget_type('bookmarks',elgg_echo("bookmarks:recent"),elgg_echo("bookmarks:widget:description"));
+ // Register a URL handler for bookmarks
+ elgg_register_entity_url_handler('object', 'bookmarks', 'bookmark_url');
- // Register entity type
- register_entity_type('object','bookmarks');
-
- // Add group menu option
- add_group_tool_option('bookmarks',elgg_echo('bookmarks:enablebookmarks'),true);
+ // Register entity type for search
+ elgg_register_entity_type('object', 'bookmarks');
+ // Groups
+ add_group_tool_option('bookmarks', elgg_echo('bookmarks:enablebookmarks'), true);
+ elgg_extend_view('groups/tool_latest', 'bookmarks/group_module');
}
/**
- * Sidebar menu for bookmarks
+ * 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
+ * @return bool
*/
-function bookmarks_pagesetup() {
- global $CONFIG;
+function bookmarks_page_handler($page) {
- // Set up menu for logged in users
- // add submenu options - @todo partially removed - now provided by drop-down menu filter in content area
- if (get_context() == "bookmarks") {
-/*
- if (isloggedin()) {
- if (page_owner()) {
- $page_owner = page_owner_entity();
- add_submenu_item(elgg_echo('bookmarks:read'),$CONFIG->wwwroot."pg/bookmarks/" . $page_owner->username . "/items");
- }
- if(!$page_owner instanceof ElggGroup)
- add_submenu_item(elgg_echo('bookmarks:friends'),$CONFIG->wwwroot."pg/bookmarks/" . $_SESSION['user']->username . "/friends");
- }
+ elgg_load_library('elgg:bookmarks');
- if(!$page_owner instanceof ElggGroup)
- add_submenu_item(elgg_echo('bookmarks:everyone'),$CONFIG->wwwroot."mod/bookmarks/everyone.php");
-*/
-
- // Bookmarklet
- if ((isloggedin()) && (page_owner()) && (can_write_to_container(0, page_owner()))) {
- $page_owner = page_owner_entity();
- $bmtext = elgg_echo('bookmarks:bookmarklet');
- if ($page_owner instanceof ElggGroup)
- $bmtext = elgg_echo('bookmarks:bookmarklet:group');
- // add_submenu_item($bmtext, $CONFIG->wwwroot . "pg/bookmarks/{$page_owner->username}/bookmarklet");
- }
- }
+ if (!isset($page[0])) {
+ $page[0] = 'all';
+ }
- $page_owner = page_owner_entity();
+ elgg_push_breadcrumb(elgg_echo('bookmarks'), 'bookmarks/all');
- 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/" . $page_owner->username . '/items');
+ // 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);
}
}
+
+ // user usernames
+ $user = get_user_by_username($page[0]);
+ if ($user) {
+ bookmarks_url_forwarder($page);
+ }
+
+ $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;
+ }
+
+ elgg_pop_context();
+ return true;
}
/**
- * Bookmarks page handler; allows the use of fancy URLs
+ * Forward to the new style of URLs
*
- * @param array $page From the page_handler function
- * @return true|false Depending on success
+ * @param string $page
*/
-function bookmarks_page_handler($page) {
+function bookmarks_url_forwarder($page) {
+ global $CONFIG;
- // The first component of a bookmarks URL is the username
- if (isset($page[0])) {
- set_input('username',$page[0]);
+ if (!isset($page[1])) {
+ $page[1] = 'items';
}
- // The second part dictates what we're doing
- if (isset($page[1])) {
- switch($page[1]) {
- case "friends":
- include(dirname(__FILE__) . "/friends.php");
- return true;
- break;
- case "items":
- include(dirname(__FILE__) . "/index.php");
- return true;
- break;
- case "add":
- include(dirname(__FILE__) . "/add.php");
- return true;
- break;
- case "edit":
- set_input('bookmark',$page[2]);
- include(dirname(__FILE__) . "/add.php");
- return true;
- break;
- case "bookmarklet":
- include(dirname(__FILE__) . "/bookmarklet.php");
- return true;
- break;
- }
- // If the URL is just 'bookmarks/username', or just 'bookmarks/', load the standard bookmarks index
- } else {
- include(dirname(__FILE__) . "/index.php");
- return true;
+ 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;
}
- return false;
-
+ register_error(elgg_echo("changebookmark"));
+ forward($url);
}
/**
@@ -143,21 +210,44 @@ function bookmarks_page_handler($page) {
* @return string bookmarked item URL
*/
function bookmark_url($entity) {
-
global $CONFIG;
+
$title = $entity->title;
- $title = friendly_title($title);
- return $CONFIG->url . "pg/bookmarks/" . $entity->getOwnerEntity()->username . "/read/" . $entity->getGUID() . "/" . $title;
+ $title = elgg_get_friendly_title($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'];
@@ -166,54 +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 = $CONFIG->wwwroot . "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++;
+ * 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();
+ }
+
+ if ($page_owner instanceof ElggGroup) {
+ if (!$page_owner->isMember()) {
+ return $return;
+ }
+ $title = elgg_echo('bookmarks:bookmarklet:group');
+ } else {
+ $title = elgg_echo('bookmarks:bookmarklet');
+ }
+
+ $return[] = new ElggMenuItem('bookmarklet', $title, 'bookmarks/bookmarklet/' . $page_owner->getGUID());
+ }
}
- $code = "{{L:" . $code . "}}";
- return $code;
+
+ 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 4ff05c68a..b3e9737fe 100644
--- a/mod/bookmarks/views/default/bookmarks/bookmarklet.php
+++ b/mod/bookmarks/views/default/bookmarks/bookmarklet.php
@@ -1,27 +1,35 @@
<?php
/**
- * Elgg get bookmarks bookmarklet view
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
+ * Bookmarklet
+ *
+ * @package Bookmarks
*/
-$page_owner = $vars['pg_owner'];
+$page_owner = elgg_get_page_owner_entity();
-$bookmarktext = elgg_echo("bookmarks:this");
-if ($page_owner instanceof ElggGroup)
- $bookmarktext = sprintf(elgg_echo("bookmarks:this:group"), $page_owner->name)
-?>
-<h3>Browser Bookmarklet</h3>
-<a href="javascript:location.href='<?php echo $vars['url']; ?>pg/bookmarks/<?php echo page_owner_entity()->username; ?>/add?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)"> <img src="<?php echo $vars['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>
+if ($page_owner instanceof ElggGroup) {
+ $title = elgg_echo("bookmarks:this:group", array($page_owner->name));
+} else {
+ $title = elgg_echo("bookmarks:this");
+}
+
+$guid = $page_owner->getGUID();
+
+if (!$name && ($user = elgg_get_logged_in_user_entity())) {
+ $name = $user->username;
+}
-<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
+$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>";
+
+?>
+<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 1e8f8c145..0d734c847 100644
--- a/mod/bookmarks/views/default/bookmarks/css.php
+++ b/mod/bookmarks/views/default/bookmarks/css.php
@@ -1,50 +1,3 @@
-<?php
-/**
- * Elgg bookmarks CSS
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-?>
-
-.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 b72863841..000000000
--- a/mod/bookmarks/views/default/bookmarks/form.php
+++ /dev/null
@@ -1,112 +0,0 @@
-<?php
-
-/**
- * Elgg bookmarks plugin form
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-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;
- $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(page_owner_entity() instanceof ElggGroup){
- //if in a group, set the access level to default to the group
- $access_id = page_owner_entity()->group_acl;
- }else{
- $access_id = get_default_access(get_loggedin_user());
- }
- $owner = $vars['user'];
- $url = "action/bookmarks/add";
-}
-?>
-<form class="margin_top" action="<?php echo $vars['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(page_owner_entity() instanceof ElggGroup){
- $access_options = group_access_options(page_owner_entity());
- 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_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 07450fd2e..000000000
--- a/mod/bookmarks/views/default/bookmarks/stats.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-/**
- * All site bookmark stats
- **/
-
-$count_bookmarks = elgg_get_entities("object", "bookmarks",0,"",10,0,true,0,null,0,0);
-$count_bookmark_comments = count_annotations(0, "object", "bookmarks","generic_comment");
-
-echo "<h3>Bookmark stats</h3>";
-echo "<p>".$count_bookmarks . " resources bookmarked.</p>";
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 fbb00e545..83bae2b13 100644
--- a/mod/bookmarks/views/default/object/bookmarks.php
+++ b/mod/bookmarks/views/default/object/bookmarks.php
@@ -1,84 +1,127 @@
<?php
/**
* Elgg bookmark view
- *
+ *
* @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
*/
-$owner = $vars['entity']->getOwnerEntity();
-$friendlytime = friendly_time($vars['entity']->time_created);
-$parsed_url = parse_url($vars['entity']->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'";
+$full = elgg_extract('full_view', $vars, FALSE);
+$bookmark = elgg_extract('entity', $vars, FALSE);
+
+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' => $vars['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 edit and delete options
-if($vars['entity']->canEdit()){
- $info .= "<span class='entity_edit'><a href=\"{$vars['url']}pg/bookmarks/{$owner->username}/edit/{$vars['entity']->getGUID()}\">" . elgg_echo('edit') . "</a></span>";
- // include a view for plugins to extend
- $info .= elgg_view("bookmarks/options",array('entity' => $vars['entity']));
- $info .= $delete;
-}
- $info .= "</div>";
+ $params = array(
+ 'entity' => $bookmark,
+ 'title' => false,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ );
+ $params = $params + $vars;
+ $summary = elgg_view('object/elements/summary', $params);
-$info .= "<p class='entity_title'><a href=\"{$vars['entity']->address}\" target=\"_blank\">{$vars['entity']->title}</a></p>";
-$info .= "<p class='entity_subtext'>Bookmarked by <a href=\"{$vars['url']}pg/bookmarks/{$owner->username}\">{$owner->name}</a> {$friendlytime} {$view_notes}</p>";
+ $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;
-$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>";
-}
+ echo elgg_view('object/elements/full', array(
+ 'entity' => $bookmark,
+ 'icon' => $owner_icon,
+ 'summary' => $summary,
+ 'body' => $body,
+ ));
+
+} 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";
+ }
+
+ if (strlen($url) > 25) {
+ $bits = parse_url($url);
+ if (isset($bits['host'])) {
+ $display_text = $bits['host'];
+ } else {
+ $display_text = elgg_get_excerpt($url, 100);
+ }
+ }
+
+ $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);
-//display
-echo elgg_view_listing($icon, $info); \ No newline at end of file
+ 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 8de1c27b0..388f54ac9 100644
--- a/mod/bookmarks/views/default/river/object/bookmarks/create.php
+++ b/mod/bookmarks/views/default/river/object/bookmarks/create.php
@@ -1,18 +1,15 @@
<?php
/**
- * Elgg bookmark river entry view
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
+ * New bookmarks river entry
+ *
+ * @package Bookmarks
*/
-$performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject();
-$object = get_entity($vars['item']->object_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> <span class='entity_subtext'>" . friendly_time($object->time_updated) . "</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 2ae8af6e4..ed9c7fd88 100644
--- a/mod/bookmarks/views/default/widgets/bookmarks/edit.php
+++ b/mod/bookmarks/views/default/widgets/bookmarks/edit.php
@@ -1,27 +1,24 @@
<?php
/**
* Elgg bookmark widget edit view
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
+ *
+ * @package Bookmarks
*/
+// set default value
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 4;
+}
+
+$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);
+
?>
-<p>
+<div>
<?php echo elgg_echo('bookmarks:numbertodisplay'); ?>:
- <select name="params[num_display]">
- <option value="1" <?php if($vars['entity']->num_display == 1) echo "SELECTED"; ?>>1</option>
- <option value="2" <?php if($vars['entity']->num_display == 2) echo "SELECTED"; ?>>2</option>
- <option value="3" <?php if($vars['entity']->num_display == 3) echo "SELECTED"; ?>>3</option>
- <option value="4" <?php if($vars['entity']->num_display == 4) echo "SELECTED"; ?>>4</option>
- <option value="5" <?php if($vars['entity']->num_display == 5) echo "SELECTED"; ?>>5</option>
- <option value="6" <?php if($vars['entity']->num_display == 6) echo "SELECTED"; ?>>6</option>
- <option value="7" <?php if($vars['entity']->num_display == 7) echo "SELECTED"; ?>>7</option>
- <option value="8" <?php if($vars['entity']->num_display == 8) echo "SELECTED"; ?>>8</option>
- <option value="9" <?php if($vars['entity']->num_display == 9) echo "SELECTED"; ?>>9</option>
- <option value="10" <?php if($vars['entity']->num_display == 10) echo "SELECTED"; ?>>10</option>
- </select>
-</p> \ No newline at end of file
+ <?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 4240b95f0..000000000
--- a/mod/bookmarks/views/default/widgets/bookmarks/view.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * Elgg bookmark widget view
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-//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 = friendly_time($b->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 = $vars['url'] . "pg/bookmarks/" . page_owner_entity()->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 0a9a46333..1abda4710 100644
--- a/mod/bookmarks/views/rss/object/bookmarks.php
+++ b/mod/bookmarks/views/rss/object/bookmarks.php
@@ -1,26 +1,37 @@
<?php
/**
- * Elgg bookmark rss view
- *
+ * Bookmark RSS object view
+ *
* @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
*/
- $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;