[Solved] Where is information about the album highlight stored?

brunson

Joined: 2005-12-27
Posts: 8
Posted: Thu, 2010-09-09 17:21

I've been poring over the schema and can't seem to find where the the reference to highlight is tracked for each album. Can someone point me to the table where it's stored?

Thanks,
e.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-09-09 20:35
 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2010-09-09 20:54

I'm not sure where in the DB that's stored either, but you might want to start digging around in modules/core/ItemMakeHighlight.inc and follow that trail.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-09-09 20:59
 
brunson

Joined: 2005-12-27
Posts: 8
Posted: Thu, 2010-09-09 21:02

All of my g_onLoadHandlers in g2_Entity are set to Null. I'm reading through the code right now.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2010-09-09 21:03

Oops, sorry man, I should really refresh the page before posting. I opened the topic, and left to get lunch and got pulled aside for other things...

Ignore my comment, suprsidr knows what he's talkin' about here. :)
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
brunson

Joined: 2005-12-27
Posts: 8
Posted: Thu, 2010-09-09 22:13

It looks like for every g2_Entity with g_entityType = 'GalleryAlbumItem' there may be, at most, one g_Entity of type 'GalleryDerivativeImage' related to the GalleryAlbumItem through the cross-reference table g2_ChildEntity. If that child entity exists, then it is the highlight for the album.

Most of the schema was pretty easy to understand, that convention had me searching for the better part of two days. I ended up doing text searches through a mysqldump of my gallery2 database. :-P

I'm completing my project with the above assumption. If it turns out to not be the case, then I'll post back.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-09-09 22:22

Not sure what your "project" is, but G2 API is pretty simple(for me anyways), so if you need help or examples...

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
brunson

Joined: 2005-12-27
Posts: 8
Posted: Thu, 2010-09-09 22:25

I'm pulling this data out of the database in python, so the API isn't useful to me. Also, my conclusion above is wrong, I still don't know where the thumbnail id is stored.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-09-09 22:38

the thumbnail is simply a derivativeImage g2_ThumbnailImage

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
brunson

Joined: 2005-12-27
Posts: 8
Posted: Thu, 2010-09-09 23:07

Sorry, I meant the highlight reference.

Here's what I need: Given an album id, derive enough information from the database to construct the link to the thumbnail for the highlight of that album.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-09-09 23:18

Load the album's children and derivatives, and look for the derivative w/ the highlight onLoadHandlers

I may be able to write the SQL if you need.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
brunson

Joined: 2005-12-27
Posts: 8
Posted: Thu, 2010-09-09 23:37

I eventually plowed through it, here's the SQL I came up with:

    select prjitm.g_Title as prjtitle,
        prjitm.g_id as prjid,
        prjitm.g_summary as prjsum,
        thmimg.g_derivativeSourceId as thmid,
        thment.g_serialNumber as thmser,
        thmfsent.g_pathComponent as fname
    from g2_Item as prjitm
    join g2_ChildEntity as prjent on prjent.g_id = prjitm.g_id
    join g2_AlbumItem as prjalb on prjalb.g_id = prjitm.g_id
    join g2_ItemAttributesMap as prjattr on prjattr.g_itemId = prjitm.g_id
    join g2_ChildEntity as topent on topent.g_id = prjent.g_parentid
    join g2_Item as topitm on topitm.g_id = topent.g_id
    join g2_AlbumItem as topalb on topalb.g_id = topitm.g_id
    join g2_ChildEntity as mikent on mikent.g_id = topent.g_parentid
    join g2_Item as mikitm on mikitm.g_id = mikent.g_id
    join g2_ChildEntity as prjchld
         on prjchld.g_parentId = prjitm.g_id
    join g2_Entity as thment
         on thment.g_id = prjchld.g_id
         and thment.g_entityType = 'GalleryDerivativeImage'
    join g2_Derivative as thmimg on thmimg.g_id = thment.g_id
    join g2_ChildEntity as fsent on fsent.g_id = thmimg.g_derivativeSourceId
    join g2_FileSystemEntity as thmfsent on thmfsent.g_id = fsent.g_parentId
    where topitm.g_title = 'Website Projects'
    order by prjattr.g_orderWeight

most of it is getting to the album I want to find sub albums in, the meat of getting to the thumbnail is here:

    join g2_ChildEntity as prjchld
         on prjchld.g_parentId = prjitm.g_id
    join g2_Entity as thment
         on thment.g_id = prjchld.g_id
         and thment.g_entityType = 'GalleryDerivativeImage'
    join g2_Derivative as thmimg on thmimg.g_id = thment.g_id
    join g2_ChildEntity as fsent on fsent.g_id = thmimg.g_derivativeSourceId
    join g2_FileSystemEntity as thmfsent on thmfsent.g_id = fsent.g_parentId

You have to find a child entity of the album of type 'GalleryDerivativeImage', then find that derivative and the derivative's child entity so you can get to filesystem entity for the pathcomponent. Given all that you have the derivative id, serial number and filename, so I can create the URL for the highlight.

Thanks for your time, I appreciate your help. In the end it was just a bit convoluted, but mainly it was knowing the convention of finding the derivative image entity in child entity.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2010-09-10 00:11

So can't python query an online data manager(galleryData.php) for this info in a qualified format like json or mediaRssXML?
I have the scripts already written... no need to re-invent the wheel.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
brunson

Joined: 2005-12-27
Posts: 8
Posted: Fri, 2010-09-10 01:15

Actually, that was a solution I hadn't considered. When you said "API" I thought of the PHP libraries that I was wading through, I'd forgotten that gallery exposes an interface over http.

I'd love to see the scripts.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2010-09-10 01:31