]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #1253 added toggle for list types to file plugin. It's not pretty so we may...
authorcash <cash.costello@gmail.com>
Sat, 5 Nov 2011 21:33:04 +0000 (17:33 -0400)
committercash <cash.costello@gmail.com>
Sat, 5 Nov 2011 21:33:04 +0000 (17:33 -0400)
mod/file/languages/en.php
mod/file/start.php
views/default/navigation/listtype.php [deleted file]
views/default/navigation/viewtype.php
views/default/page/elements/sidebar.php

index c4d5a4f88e33cb83d7cedf310d5b343282635d85..2780769275a085942d1222de7212252e4b1c1fbd 100644 (file)
@@ -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',
index 7a0a058444bfec4a4fadaf2a5901a0b79cac90c5..d6e17cc4b95ca1dc19282fce8dc0a306c2931649 100644 (file)
@@ -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
  *
diff --git a/views/default/navigation/listtype.php b/views/default/navigation/listtype.php
deleted file mode 100644 (file)
index e90667e..0000000
+++ /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
index 69d29dc323ea354b004a0cb5b5dcf5492c68d330..6dfa4ebc7b49895b69332f1c92d1cd5f995443fa 100644 (file)
@@ -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);
index e1d25eed5d12dabdfa4b8bcd07b56fd51f63a149..fe6bb450e87711d58dbe79cf23463a47cc871d28 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 echo elgg_view_menu('extras', array(
-       'sort_by' => 'name',
+       'sort_by' => 'priority',
        'class' => 'elgg-menu-hz',
 ));