Modules Name Sorting patch

View: New views
2 Messages — Rating Filter:   Alert me  

Modules Name Sorting patch

by James Nash-2 :: Rate this Message:

| View Threaded | Show Only this Message

Can I propose this patch for the sorting of modules by their name vs. their
filename.  Makes looking through the list a lot more appealing.

Thanks,

James (jnash)

--- /data/archives/g3-git/gallery3/modules/gallery/helpers/module.php
2012-02-28 13:28:18.000000000 -0500
+++ /data/apache/htdocs/gallery/modules/gallery/helpers/module.php
2012-05-08 10:45:39.000000000 -0400
@@ -109,7 +109,12 @@
        $modules->gallery->locked = true;
        $identity_module = module::get_var("gallery", "identity_provider",
"user");
        $modules->$identity_module->locked = true;
-      $modules->ksort();
+
+      function cmp($a, $b) {
+ return strcmp(strtolower($a->name), strtolower($b->name));
+      }
+
+      $modules->uasort('cmp');
        self::$available = $modules;
      }


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]

Re: Modules Name Sorting patch

by Bharat Mediratta :: Rate this Message:

| View Threaded | Show Only this Message


strcasecmp would be better than strcmp on multiple strlower's.  Actually I think we want strnatcasecmp here.  I'll tune this up and submit it - thanks.

On Tue, May 8, 2012 at 7:55 AM, James Nash <gallery@...> wrote:
Can I propose this patch for the sorting of modules by their name vs. their
filename.  Makes looking through the list a lot more appealing.

Thanks,

James (jnash)

--- /data/archives/g3-git/gallery3/modules/gallery/helpers/module.php
2012-02-28 13:28:18.000000000 -0500
+++ /data/apache/htdocs/gallery/modules/gallery/helpers/module.php
2012-05-08 10:45:39.000000000 -0400
@@ -109,7 +109,12 @@
       $modules->gallery->locked = true;
       $identity_module = module::get_var("gallery", "identity_provider",
"user");
       $modules->$identity_module->locked = true;
-      $modules->ksort();
+
+      function cmp($a, $b) {
+       return strcmp(strtolower($a->name), strtolower($b->name));
+      }
+
+      $modules->uasort('cmp');
       self::$available = $modules;
     }


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]