Re: Ansel::listGalleries()

"Heath S. Hendrickson" <[email protected]>
Newsgroups gmane.comp.horde.ansel
Message-ID <[email protected]>
Heath S. Hendrickson wrote:

> Does Ansel::listGalleries() return the galleries in some deterministic 
> fashion?  Meaning, are the galleries always returned a defined order 
> (parent1, parent1->child1, parent1->child2, parent1->child2->child3, 
> parent2, parent3, parent3->child1).  I'm asking because I'm still 
> having a problem with listing of galleries in the XPPublish function.  
> It lists all the galleries, but the order is all messed up (a child of 
> one parent coming after another parent, etc.).  It doesn't seem to be 
> in any sorted fashion for the parents, either.
>
> I'm going to take a look at the code, but wanted to see if anyone else 
> was seeing the same thing or not.
>
> h


I'm not sure why listGalleries() isn't returnin the galleries in sorted 
order (my pref is to sort by name), but the attached patch will add the 
necessary sorting to the templates/xppublish/list.inc file to create a 
sorted pulldown of galleries.  I also commented out some unecessary code 
(it wasn't being used and just used up some extra CPU cycles and memory).

h

-- 
ansel mailing list - Join the hunt: http://horde.org/bounties/#ansel
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]
list.inc.patch2 (text/plain, 1.3 KB)
Index: templates/xppublish/list.inc
===================================================================
RCS file: /usr/local/horde/cvs/ansel/templates/xppublish/list.inc,v
retrieving revision 1.10
diff -u -r1.10 list.inc
--- templates/xppublish/list.inc	20 Mar 2004 16:00:46 -0000	1.10
+++ templates/xppublish/list.inc	10 Apr 2004 21:31:07 -0000
@@ -13,9 +13,15 @@
 // Display all galleries that the user can edit.
 $galleries = Ansel::listGalleries(PERMS_EDIT);
 foreach ($galleries as $groupId => $group) {
-    foreach ($group['galleries'] as $id => $gallery) {
+    $tmp = array_keys($group['galleries']);
+    sort($tmp);
+    reset($tmp);
+    //foreach ($group['galleries'] as $id => $gallery) {
+    foreach ($tmp as $junk => $id) {
+        $gallery = $group['galleries'][$id];
         $sel = ($galleryId == $id) ? ' selected="selected"' : '';
         $indent = substr_count($id, ':');
+/*
         $p = $gallery; $gs = array();
         while (is_a($p = $p->getParent(), 'DataTreeObject_Gallery')) {
             $gs[] = $p->get('name');
@@ -23,6 +29,7 @@
         if (count($gs)) {
             $gs = array_reverse($gs);
         }
+*/
         echo '<option value="' . htmlspecialchars($id) . '"' . $sel . '>' . str_repeat('&nbsp;', 2 * $indent) . htmlspecialchars($gallery->get('name')) . '</option>';
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.