[dev] Ansel_Gallery

Michael Rubinsky mike at theupstairsroom.com
Thu May 17 23:05:03 UTC 2007


Quoting Chuck Hagenbuch <chuck at horde.org>:

> Quoting Michael Rubinsky <mike at theupstairsroom.com>:
>
>> Now that subgalleries are displayed along with images, I've been
>> toying with the idea of changing some things about Ansel_Gallery
>> class.  For one, I think it makes sense, if it's possible, to add
>> something like Ansel_Gallery::getChildren countChildren,
>> listChildren  etc... instead of getImages etc...so we can
>> encapsulate more of the  functionality into the gallery object.
>
> Sounds okay to me.
>
>> I've really just started playing with moving some stuff around, and
>> don't know for sure if it will work.  I can't figure out the best
>> way  to deal with the fact that we will basically be returning a
>> mixed  array or both Ansel_Image and Ansel_Gallery objects.  I don't
>> like the  thought of a bunch of if (is_a($child, 'Ansel_Gallery'))
>> etc... but no  matter what design I try, I've not been able to get
>> past the fact that  at some point we *will* need to know if an image
>> or gallery...at least  not without putting some sort of HTML
>> generating methods into the  objects.
>
> If the HTML generation is what you need it for, just add something
> like a getView() method to the objects that returns the appropriate
> Horde_View object; the html will be encapsulated in the templates for
> the view.

I actually did start to go a similar route, but the issue I'm having  
is that the HTML I'm referring to is for the gallery and image info  
that are displayed on the gallery view...the thumbnails/gallery  
name/date created/owner etc...

What I started to do is add a method ->getThumbView() that returned  
the HTML (or  an Ansel_View_Image_Thumb / Ansel_View_Gallery_Thumb  
object) for  each image/gallery. My idea was that  
Ansel_Gallery::getThumbView() could also be used from list.php as  
well.  Anyway, the issue is that it "works", but I'm wondering if the  
permormance hit in doing it this way is worth it....The  method would  
need to be called for each image/gallery, if we delegate the actual  
html generation to a view object - an additional object would be  
instantiated for each image/gallery, and if we are allowing comments,  
all the the forums/numMessages api call would be called for each image  
instead of doing it as a batch for all images at once, like we do now.

The alternative would be to do a is_a() or maybe have getChildren  
return something like:

Array( Array('type' => 'gallery',
              'object' => Horde_Gallery object),
        Array('type' => 'image',
              'object' => Horde_Image object))

This way, we could still encapsulate the logic for returning and  
preoperly paging the subgalleries and images, yet still avoid some of  
the performance issues from retrieving comment counts one at a time,  
instantiating new view objects for each images/gallery etc...

I know my designs can sometimes get away from me and start to get too  
complicated, so thoughts, input appreciated! :)

Thanks,
mike

--
The Horde Project (www.horde.org)
mrubinsk at horde.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-keys
Size: 2013 bytes
Desc: PGP Public Key
Url : http://lists.horde.org/archives/dev/attachments/20070517/904d81ee/attachment.bin 


More information about the dev mailing list