aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2011-11-05 17:33:04 -0400
committercash <cash.costello@gmail.com>2011-11-05 17:33:04 -0400
commitabaf5567e7b2bbeee033faa04618270660d80ab4 (patch)
tree7418c7988457509ec4ee0a72da05023a875218ae
parentfa0dbc7f8a34597345f7939ca9914438624c3cee (diff)
downloadelgg-abaf5567e7b2bbeee033faa04618270660d80ab4.tar.gz
elgg-abaf5567e7b2bbeee033faa04618270660d80ab4.tar.bz2
Fixes #1253 added toggle for list types to file plugin. It's not pretty so we may want to style/rethink in future version
-rw-r--r--mod/file/languages/en.php3
-rw-r--r--mod/file/start.php35
-rw-r--r--views/default/navigation/listtype.php28
-rw-r--r--views/default/navigation/viewtype.php6
-rw-r--r--views/default/page/elements/sidebar.php2
5 files changed, 41 insertions, 33 deletions
diff --git a/mod/file/languages/en.php b/mod/file/languages/en.php
index c4d5a4f88..278076927 100644
--- a/mod/file/languages/en.php
+++ b/mod/file/languages/en.php
@@ -35,6 +35,9 @@ $english = array(
'file:desc' => "Description",
'file:tags' => "Tags",
+ 'file:list:list' => 'Switch to the list view',
+ 'file:list:gallery' => 'Switch to the gallery view',
+
'file:types' => "Uploaded file types",
'file:type:' => 'Files',
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':
@@ -150,6 +155,36 @@ function file_page_handler($page) {
}
/**
+ * 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
*
* @param string $hook
diff --git a/views/default/navigation/listtype.php b/views/default/navigation/listtype.php
deleted file mode 100644
index e90667e8d..000000000
--- a/views/default/navigation/listtype.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/**
- * Elgg list view switcher
- *
- * @package Elgg
- * @subpackage Core
- */
-
-$baseurl = elgg_http_remove_url_query_element($vars['baseurl'], 'search_listtype');
-
-if ($vars['listtype'] == "list") {
- $listtype = "gallery";
-} else {
- $listtype = "list";
-}
-
-if (substr_count($baseurl,'?')) {
- $baseurl .= "&search_listtype=" . $listtype;
-} else {
- $baseurl .= "?search_listtype=" . $listtype;
-}
-
-?>
-
-<p class="mtm">
- <?php echo elgg_echo("listtype:change") ?>:
- <a href="<?php echo $baseurl; ?>"><?php echo elgg_echo("listtype:{$listtype}"); ?></a>
-</p> \ No newline at end of file
diff --git a/views/default/navigation/viewtype.php b/views/default/navigation/viewtype.php
index 69d29dc32..6dfa4ebc7 100644
--- a/views/default/navigation/viewtype.php
+++ b/views/default/navigation/viewtype.php
@@ -5,9 +5,7 @@
* @package Elgg
* @subpackage Core
*
- * @deprecated 1.8 Use navigation/listtype
+ * @deprecated 1.8 See how file plugin adds a toggle in function file_register_toggle()
*/
-elgg_deprecated_notice('navigation/viewtype was deprecated by navigation/listtype', 1.8);
-
-echo elgg_view('navigation/listtype', $vars); \ No newline at end of file
+elgg_deprecated_notice('navigation/viewtype was deprecated', 1.8);
diff --git a/views/default/page/elements/sidebar.php b/views/default/page/elements/sidebar.php
index e1d25eed5..fe6bb450e 100644
--- a/views/default/page/elements/sidebar.php
+++ b/views/default/page/elements/sidebar.php
@@ -6,7 +6,7 @@
*/
echo elgg_view_menu('extras', array(
- 'sort_by' => 'name',
+ 'sort_by' => 'priority',
'class' => 'elgg-menu-hz',
));