Changeset 548

Show
Ignore:
Timestamp:
06/09/08 13:19:25 (5 months ago)
Author:
sidtheduck
Message:

+ Fix for pagination on "Collections" level
+ Fix for collection and album count on gallery front-end when album or collection has no pictures.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/plog-functions.php

    r547 r548  
    10281028        // if adding arguments to mod_rewritten urls, then I need ? (question mark) before the arguments 
    10291029        // otherwise I want & 
    1030         $last = substr($url,-1); 
    1031          
    1032         if ($last == "/") { 
     1030        //$last = substr($url,-1); 
     1031         
     1032        if (!strpos($url,"?")) { 
    10331033                //$url = substr($url,0,-1); 
    10341034                $separator = "?"; 
     
    16001600         
    16011601        // -1 is just for the case there are no collections at all 
    1602         $image_count = array(-1 => -1); 
     1602        $image_collection_count = array(-1 => -1); 
     1603        $image_album_count = array(); 
    16031604        $album_count = array(); 
    16041605         
    16051606        // 1. create a list of all albums with at least one photo 
    1606         $sql = "SELECT parent_collection,COUNT(*) AS imagecount 
    1607                                 FROM `".TABLE_PREFIX."pictures` GROUP BY parent_collection"; 
     1607        $sql = "SELECT parent_collection,parent_album,COUNT(*) AS imagecount 
     1608                                FROM `".TABLE_PREFIX."pictures` GROUP BY parent_collection,parent_album"; 
    16081609        $result = run_query($sql); 
    16091610        while($row = mysql_fetch_assoc($result)) { 
    1610                 $image_count[$row["parent_collection"]] = $row["imagecount"]; 
    1611         } 
    1612          
    1613         $imlist = join(",",array_keys($image_count)); 
     1611                $image_collection_count[$row["parent_collection"]] = $row["imagecount"]; 
     1612                $image_album_count[$row["parent_album"]] = $row["imagecount"]; 
     1613        } 
     1614        $imlist = join(",",array_keys($image_collection_count)); 
     1615        $albumlist = join(",",array_keys($image_album_count)); 
    16141616         
    16151617        $cond = ''; 
    16161618         
    16171619        if (empty($arr['all_collections'])) { 
    1618                 $cond = " WHERE parent_id IN ($imlist) "; 
     1620                $cond = " WHERE `parent_id` IN ($imlist) AND `id` IN ($albumlist) "; 
    16191621        } 
    16201622         
     
    16401642        // override that with passing all_collections as an argument to  
    16411643        // this function 
    1642         if (empty($arr['all_collections'])) { 
    1643                 $cond = " WHERE id IN ($imlist) "; 
     1644  if (empty($arr['all_collections'])) { 
     1645                $cond = " WHERE `id` IN ($imlist) "; 
    16441646        } 
    16451647         
     
    22422244function plogger_count_collections() { 
    22432245         
    2244         $numquery = "SELECT COUNT(*) AS `num_collections` FROM `".TABLE_PREFIX."collections`"; 
     2246        $numquery = "SELECT COUNT(DISTINCT `parent_collection`) AS `num_collections` FROM `".TABLE_PREFIX."pictures`"; 
    22452247                 
    22462248        $numresult = run_query($numquery);