From abaf5567e7b2bbeee033faa04618270660d80ab4 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 5 Nov 2011 17:33:04 -0400 Subject: Fixes #1253 added toggle for list types to file plugin. It's not pretty so we may want to style/rethink in future version --- mod/file/start.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'mod/file/start.php') diff --git a/mod/file/start.php b/mod/file/start.php index 7a0a05844..d6e17cc4b 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -114,9 +114,11 @@ function file_page_handler($page) { $page_type = $page[0]; switch ($page_type) { case 'owner': + file_register_toggle(); include "$file_dir/owner.php"; break; case 'friends': + file_register_toggle(); include "$file_dir/friends.php"; break; case 'view': @@ -131,12 +133,15 @@ function file_page_handler($page) { include "$file_dir/edit.php"; break; case 'search': + file_register_toggle(); include "$file_dir/search.php"; break; case 'group': + file_register_toggle(); include "$file_dir/owner.php"; break; case 'all': + file_register_toggle(); include "$file_dir/world.php"; break; case 'download': @@ -149,6 +154,36 @@ function file_page_handler($page) { return true; } +/** + * Adds a toggle to extra menu for switching between list and gallery views + */ +function file_register_toggle() { + $url = elgg_http_remove_url_query_element(current_page_url(), 'list_type'); + + if (get_input('list_type', 'list') == 'list') { + $list_type = "gallery"; + $icon = elgg_view_icon('grid'); + } else { + $list_type = "list"; + $icon = elgg_view_icon('list'); + } + + if (substr_count($url, '?')) { + $url .= "&list_type=" . $list_type; + } else { + $url .= "?list_type=" . $list_type; + } + + + elgg_register_menu_item('extras', array( + 'name' => 'file_list', + 'text' => $icon, + 'href' => $url, + 'title' => elgg_echo("file:list:$list_type"), + 'priority' => 1000, + )); +} + /** * Creates the notification message body * -- cgit v1.2.3