aboutsummaryrefslogtreecommitdiff
path: root/mod/bookmarks/start.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/bookmarks/start.php')
-rw-r--r--mod/bookmarks/start.php86
1 files changed, 52 insertions, 34 deletions
diff --git a/mod/bookmarks/start.php b/mod/bookmarks/start.php
index 98449d0d1..a4cba4805 100644
--- a/mod/bookmarks/start.php
+++ b/mod/bookmarks/start.php
@@ -5,9 +5,24 @@
* @package ElggBookmarks
*/
+elgg_register_event_handler('init', 'system', 'bookmarks_init');
+elgg_register_event_handler('pagesetup', 'system', 'bookmarks_pagesetup');
+
+/**
+ * Bookmark init
+ */
function bookmarks_init() {
global $CONFIG;
+ $root = dirname(__FILE__);
+
+ elgg_register_library('elgg:bookmarks', "$root/lib/bookmarks.php");
+ $action_path = "$root/actions/bookmarks";
+
+ elgg_register_action('bookmarks/save', "$action_path/save.php", 'logged_in');
+ elgg_register_action('bookmarks/delete', "$action_path/delete.php", 'logged_in');
+ elgg_register_action('bookmarks/share', "$action_path/share.php", 'logged_in');
+
//add a tools menu option
$item = new ElggMenuItem('bookmarks', elgg_echo('bookmarks'), 'pg/bookmarks/all');
elgg_register_menu_item('site', $item);
@@ -102,18 +117,28 @@ function bookmarks_pagesetup() {
}
/**
- * Bookmarks page handler
- * Expects URLs like:
- * pg/bookmarks/username/[friends||items||add||edit||bookmarklet]
+ * Dispatcher for bookmarks.
+ *
+ * URLs take the form of
+ * All bookmarks: pg/bookmarks/all
+ * User's bookmarks: pg/bookmarks/owner/<username>
+ * Friends' bookmarks: pg/bookmarks/friends/<username>
+ * View bookmark: pg/bookmarks/view/<guid>/<title>
+ * New bookmark: pg/bookmarks/add/<guid> (container: user, group, parent)
+ * Edit bookmark: pg/bookmarks/edit/<guid>
+ * Group bookmarks: pg/bookmarks/group/<guid>/owner
+ * Bookmarklet: pg/bookmarks/bookmarklet/<guid> (user)
*
+ * Title is ignored
*
- * @param array $page From the page_handler function
- * @return true|false Depending on success
+ * @param array $page
*/
function bookmarks_page_handler($page) {
- global $CONFIG;
+ elgg_load_library('elgg:bookmarks');
- // group usernames
+ elgg_push_breadcrumb(elgg_echo('bookmarks'), 'pg/bookmarks/all');
+
+ // old group usernames
if (substr_count($page[0], 'group:')) {
preg_match('/group\:([0-9]+)/i', $page[0], $matches);
$guid = $matches[1];
@@ -128,42 +153,44 @@ function bookmarks_page_handler($page) {
bookmarks_url_forwarder($page);
}
-
$pages = dirname(__FILE__) . '/pages';
switch ($page[0]) {
- case "read":
- case "view":
- set_input('guid', $page[1]);
- include "$pages/view.php";
- break;
- case "friends":
- set_input('username', $page[1]);
- include "$pages/friends.php";
- break;
case "all":
include "$pages/all.php";
break;
- case "inbox":
- set_input('username', $page[1]);
- include "$pages/inbox.php";
- break;
+
case "owner":
set_input('username', $page[1]);
include "$pages/owner.php";
break;
- case "add":
+
+ case "friends":
set_input('username', $page[1]);
+ include "$pages/friends.php";
+ break;
+
+ case "read":
+ case "view":
+ set_input('guid', $page[1]);
+ include "$pages/view.php";
+ break;
+
+ case "add":
+ set_input('container_guid', $page[1]);
include "$pages/add.php";
break;
+
case "edit":
- set_input('bookmark', $page[1]);
- include "$pages/add.php";
+ set_input('guid', $page[1]);
+ include "$pages/edit.php";
break;
+
case "bookmarklet":
set_input('username', $page[1]);
include "$pages/bookmarklet.php";
break;
+
default:
return false;
}
@@ -273,13 +300,4 @@ function bookmarks_notify_message($hook, $entity_type, $returnvalue, $params) {
}
return null;
-}
-
-elgg_register_event_handler('init', 'system', 'bookmarks_init');
-elgg_register_event_handler('pagesetup', 'system', 'bookmarks_pagesetup');
-
-// Register actions
-$action_path = dirname(__FILE__) . '/actions/bookmarks';
-
-elgg_register_action('bookmarks/add', "$action_path/add.php", 'logged_in');
-elgg_register_action('bookmarks/delete', "$action_path/delete.php", 'logged_in'); \ No newline at end of file
+} \ No newline at end of file