$numPhotos? nested albums counted as photos - not anymore!

Len

Joined: 2003-04-10
Posts: 18
Posted: Fri, 2003-05-09 21:30

Hello all,

In albums.php (the top level Gallery page), in the admin section, Gallery displays "X albums, X photos" ($numAlbums, $numPhotos (= $albumDB->getCachedNumPhotos)). But Gallery counts each nested album (even if it's empty) as if it were a photo. This is misleading: e.g. I have an album with several nested albums which are empty (waiting to be populated), but album.php would have you believe that it contains several photos. Is there any way to get $numPhotos to be more specific/accurate, and represent only the number of actual photos?

I've tracked it down to the function getCachedNumPhotos in AlbumDB.php, but here is where my php skills (i.e. lack thereof) stops. Any idea how I might do this? (maybe by subtracting the number of nested albums? Is this value determinable?)

Thanks a million to anyone who can help, LEN

For the record, I am using Gallery to organize images into categories (albums) and subcategories (nested albums), so I don't mind when view_album.php indicates "X items (i.e. subcategories) in this album (i.e. cagtegory)", since this is independent of the number of photos in the nested albums. (note: this methodology means there are no 'loose' photos that are not in a nested album).

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Fri, 2003-05-09 21:44

No use re-inventing the wheel:
http://gallery.sf.net/forums.php?topic=2317

-Beckett (

)

 
Len

Joined: 2003-04-10
Posts: 18
Posted: Mon, 2003-05-12 19:03
beckett wrote:
No use re-inventing the wheel:
http://gallery.sf.net/forums.php?topic=2317

I searched a LOT before posting... thanks for the lead... I wish people's posts would be more search-friendly (use likely kewords to help future searchers)

Thanks again. LEN

 
Len

Joined: 2003-04-10
Posts: 18
Posted: Tue, 2003-05-13 00:45

This was the relevent part of the albums.php code after the patch:

<!-- admin section begin -->
<?php 
$adminText = "<span class=\"admin\">";
$adminText .= pluralize($numAlbums, ($numAccessibleAlbums != $numAlbums) ? "top-level album" : "album", "no");
if ($numAccessibleAlbums != $numAlbums) {
	$adminText .= " ($numAccessibleAlbums total)";
}
$adminText .= ",&" . pluralize($numPhotos, "photo", "no");
if ($maxPages > 1) {
	$adminText .= " on " . pluralize($maxPages, "page", "no") . "&";
}
$adminText .= "</span>";
$adminCommands = "<span class=\"admin\">";

This helped, but still did not display the number of actual photos independently of the number of sub-(nested) albums. What it now displayed was: 5 top-level albums (46 total), & 44 photos. In my test example, I had 5 top-level albums (categories), 38 nested albums (subcategories, most of them empty), and 3 actual photos (the site had not yet been populated). To get what I needed I had to do a little math:

$lenNumTemp = $numAccessibleAlbums - $numAlbums;
$lenNum = $numPhotos - $lenNumTemp;

Here I subtracted the number of top level albums ($numAlbums (i.e. 5)) from the total number of all albums plus photos ($numAccessibleAlbums (i.e. 46 (5+38+3))). (i.e. 46-5=41). Then I subtracted this from the total number of sub- (nested) albums plus photos ($numPhotos (i.e. 44 (41+3)). (i.e. 44-41=3). This gave me the number of actual photos, independent of albums.

I then juggled the following lines:

$adminText .= pluralize($lenNum, "photo", "no");
$adminText .= " in " . pluralize($numAlbums, ($numAccessibleAlbums != $numAlbums) ? "categorie" : "album", "no");

and commented out:

/*if ($numAccessibleAlbums != $numAlbums) {
	$adminText .= " ($numAccessibleAlbums total)";
}
*/

so that it now displays: 3 photos in 5 categories
and doesn't mention the number nested albums (which I don't really need).

All this without knowing squat about php! --pats self on back--

Hope this helps someone else... LEN

LEN

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Tue, 2003-05-13 06:13

Yep... the search engine is pretty powerful, but sometimes it's hard to find what you want, since we all call the same things by very different names! :) Next time... just post a quick question here before embarking on anything major--just in case it's already been done.

 
bobob

Joined: 2003-07-12
Posts: 110
Posted: Thu, 2003-08-07 16:10

what is the difference between the patch of len and that one in the previous thread which is quoted here above? The previous one counts subalbums as photo's too?

I would like to install the same as Len in that case. How do I go about this? Do I first have to install the patch and then do some manual hacking as Len?

I have never used a patch before..... :-(
And will it work with files that already have been manually altered?