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
Posts: 172
You want last 10 updates script for your gallery?
Posts: 3474
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&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&name=phpBB_14&file=index&topic=701&action=viewtopic&topic=83" TARGET="_blank">Last Picture / Top 10 on my index.php</A><!-- BBCode End -->)
-Beckett (beck@beckettmw.com)
Posts: 3474
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&name=phpWiki&file=index&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)
Posts: 172
Believe me, I got his scripts and it work great, loved it so much! :grin:
Posts: 3
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");
?>
Posts: 3474
<? php system("/home/www/myperlscript.pl"); ?>
LOL :lol:
Posts: 172
That's Saturday Night Comedy :grin: