[ansel] Ansel::listGalleries()

Heath S. Hendrickson heath at outerspaceconsultants.com
Sat Apr 10 14:34:33 PDT 2004


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


-------------- next part --------------
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>';
     }
 }


More information about the ansel mailing list