Album Hiearchy

scorpius

Joined: 2002-10-22
Posts: 3
Posted: Tue, 2002-10-22 05:38

Can any explain to me how the album hiearchy works? I mean given a particular album (say album23), how do I determine which album(s) is is nested under?

I'd like to write a script that show's the last 10 albums that were created or updated. Our gallery is laid out by game, then army then army album;fFor example Warhammer 40k -> Space Marines -> Norm's Space Marines. I only want to look at those albums on the third level or lower. I need to understand the hiearchy to do this but the .dat files aren't all that friendly lookin :grin: Any info at all would be appreciated.

Thanks

 
josephp

Joined: 2002-10-03
Posts: 172
Posted: Tue, 2002-10-22 05:45

You want last 10 updates script for your gallery?

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Tue, 2002-10-22 07:25

Album hierarchy is messy. An album knows about its parent... FYI it's stored in $album->fields['parentAlbumName'], which is zero for top-level albums). It knows about child albums because the $album->photos[i] is an album object for each nested album rather than an image object...
But who cares... :smile: why waste time and re-invent the wheel.

<!-- BBCode Start --><A HREF="http://gallery.menalto.com/user.php?op=userinfo&amp;uname=.pixelchimp" TARGET="_blank">.pixelchimp</A><!-- BBCode End --> has a top 10 updated albums code running on his site:
http://www.chaoslibrary.com (look at the bottom left)

Hey says just drop him a line for the code (e-mail presumably on the website ?)

(Found in an unrelated thread: <!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpBB_14&amp;file=index&amp;topic=701&amp;action=viewtopic&amp;topic=83" TARGET="_blank">Last Picture / Top 10 on my index.php</A><!-- BBCode End -->)

-Beckett (beck@beckettmw.com)

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Tue, 2002-10-22 07:47

Oh sorry scorpius, I didn't really answer your question there...
You need a script that only looks at albums with a hierarchy of 3 deep or more. Hmm.

Well, as I mentioned, the parent of an album object (stored in $album, say) can be found in $album->fields['parentAlbumName']. This returns '0' for top level albums. (or $album->isRoot() does this, I'm guessing).

So you could use this to scan through each album and determine whether you have to go back three times to get to a '0' album. I think this might be a good approach.

You could also work "forwards" by scanning each element in $album->photos to see if it is an album object rather than a photo object, and recursing through the structure. This seems like it'd be a lot harder and significantly slower.

Anyhow, to get at this data, you need to run the Gallery init.php stuff... then you can run something to the effect of:
$album = new Album();
$album->loadFromFile("/path/to/album.dat");
to get a handle on the album data.

In fact, better than this, follow albums.php as a model, and create
$albumDB = new AlbumDB();
And then you only get a list of albums visible to the user... if you extract each album in a for() loop with:
$album = $albumDB->getAlbum($gallery->user, $i);
Then look for the parent album...
Well, I haven't thought this through much, so I apologise for the rambling, but this is where you want to be focusing your attention, I think.

Essential:
To understand what's in an album.dat file, download Bharat's <!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpWiki&amp;file=index&amp;pagename=PHP%20Deserializer" TARGET="_blank">PHP Deserializer</A><!-- BBCode End --> Perl script and run something like:
% php-deserialize.pl < album.dat | less
This greatly demystifies what's in there.

Let me know if you have more questions, and I'll be glad to at least offer my opinion. :wink:
(and sorry for the disorganized stream-of-consciousness ramble above)
-Beckett (beck@beckettmw.com)

 
josephp

Joined: 2002-10-03
Posts: 172
Posted: Tue, 2002-10-22 07:56
Quote:
Album hierarchy is messy. An album knows about its parent... FYI it's stored in $album->fields['parentAlbumName'], which is zero for top-level albums). It knows about child albums because the $album->photos[i] is an album object for each nested album rather than an image object...
But who cares... :smile: why waste time and re-invent the wheel.

<!-- BBCode Start --><A HREF="http://gallery.menalto.com/user.php?op=userinfo&amp;uname=.pixelchimp" TARGET="_blank">.pixelchimp</A><!-- BBCode End --> has a top 10 updated albums code running on his site:
http://www.chaoslibrary.com (look at the bottom left)

Hey says just drop him a line for the code (e-mail presumably on the website ?)

(Found in an unrelated thread: <!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpBB_14&amp;file=index&amp;topic=701&amp;action=viewtopic&amp;topic=83" TARGET="_blank">Last Picture / Top 10 on my index.php</A><!-- BBCode End -->)

-Beckett (beck@beckettmw.com)

Believe me, I got his scripts and it work great, loved it so much! :grin:

 
scorpius

Joined: 2002-10-22
Posts: 3
Posted: Wed, 2002-10-23 01:36
Quote:
]
To understand what's in an album.dat file, download Bharat's <!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpWiki&amp;file=index&amp;pagename=PHP%20Deserializer" TARGET="_blank">PHP Deserializer</A><!-- BBCode End --> Perl script and run something like:
% php-deserialize.pl < album.dat | less
This greatly demystifies what's in there.

Thanks Beckett, I'll be writing this in Perl anyhow so the code to "Deserialzie" the dat file is _just_ what I needed :grin:

I'm not a good PHP coder at all, know just enough to:

<?php

system("/home/www/myperlscript.pl");

?>

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Wed, 2002-10-23 01:59

<? php system("/home/www/myperlscript.pl"); ?>
LOL :lol:

 
josephp

Joined: 2002-10-03
Posts: 172
Posted: Wed, 2002-10-23 02:51

That's Saturday Night Comedy :grin: