Show
Ignore:
Timestamp:
07/15/08 14:08:55 (4 months ago)
Author:
sidtheduck
Message:

+ Partial fix for ticket #184 - truncating the collections and albums if only 1 album or 1 collection is present

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/plog-includes/plog-functions.php

    r557 r559  
    66} 
    77 
    8 function generate_breadcrumb($collections = 'Collections', $sep = ' » ', $translate = true) { 
     8function generate_breadcrumb($collections = 'Collections', $sep = ' » '){ 
    99        global $config; 
    1010 
    1111        $id = $GLOBALS['plogger_id']; 
    1212 
    13         if ($translate === true){ 
    14                 $collections = plog_tr(SmartStripSlashes($collections)); 
    15         } 
    1613        $collections_link = '<a href="'.generate_url("collections").'">' . $collections . '</a>'; 
    1714        $collections_name = '<strong>' . $collections . '</strong>'; 
     
    2219                        $collection_name = '<strong>' . SmartStripSlashes($row['name']) . '</strong>'; 
    2320 
    24                         $breadcrumbs = $collections_link . $sep . $collection_name; 
     21                        if ($config['truncate_breadcrumb'] == "collection"){ 
     22                                $breadcrumbs = $collection_name; 
     23                        } else { 
     24                                $breadcrumbs = $collections_link . $sep . $collection_name; 
     25                        } 
    2526 
    2627                        // Does this ever happen?  Collection level + slideshow mode ends in SQL error 
    27                         if ($GLOBALS['plogger_mode'] == "slideshow") $breadcrumbs .= $sep . '<strong>' . plog_tr('Slideshow'); 
     28                        //if ($GLOBALS['plogger_mode'] == "slideshow") $breadcrumbs .= $sep . '<strong>' . plog_tr('Slideshow'); 
    2829 
    2930                break; 
     
    3738                        $collection_link = '<a accesskey="/" href="' . generate_url("collection", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 
    3839 
    39                         if ($GLOBALS['plogger_mode'] == "slideshow") { 
    40                                 $breadcrumbs = $collections_link . $sep . $collection_link . $sep . $album_link . $sep . '<strong>' . plog_tr('Slideshow') . '</strong>'; 
     40                        if ($config['truncate_breadcrumb'] == "album"){ 
     41                                $breadcrumbs = $album_name; 
     42                        } else if ($config['truncate_breadcrumb'] == "collection"){ 
     43                                $breadcrumbs = $collection_link . $sep . $album_name; 
    4144                        } else { 
    4245                                $breadcrumbs = $collections_link . $sep . $collection_link . $sep . $album_name; 
     46                        } 
     47 
     48                        if ($GLOBALS['plogger_mode'] == "slideshow") { 
     49                                $breadcrumbs = str_replace($album_name, $album_link . $sep . '<strong>' . plog_tr('Slideshow') . '</strong>', $breadcrumbs); 
    4350                        } 
    4451 
     
    4855                        $picture_name = '<span id="image_name"><strong>' . SmartStripSlashes(get_caption_filename($row)) . '</strong></span>'; 
    4956 
    50                         $row = get_album_by_id($row["parent_album"]); 
     57                        $row = get_album_by_id($row['parent_album']); 
    5158                        $album_link = '<a accesskey="/" href="' . generate_url("album", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 
    5259 
    53                         $row = get_collection_by_id($row["parent_id"]); 
     60                        $row = get_collection_by_id($row['parent_id']); 
    5461                        $collection_link = '<a accesskey="/" href="' . generate_url("collection", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 
    5562 
    56                         $breadcrumbs = $collections_link . $sep . $collection_link . $sep . $album_link . $sep . $picture_name; 
     63                        if ($config['truncate_breadcrumb'] == "album"){ 
     64                                $breadcrumbs = $album_link . $sep . $picture_name; 
     65                        } else if ($config['truncate_breadcrumb'] == "collection") { 
     66                                $breadcrumbs = $collection_link . $sep . $album_link . $sep . $picture_name; 
     67                        } else { 
     68                                $breadcrumbs = $collections_link . $sep . $collection_link . $sep . $album_link . $sep . $picture_name; 
     69                        } 
    5770 
    5871                        // Does this ever happen?  Picture level + slideshow adds 'Slideshow' to breadcrumbs only 
    59                         if ($GLOBALS['plogger_mode'] == "slideshow") $breadcrumbs .= $sep . '<strong>' . plog_tr('Slideshow'); 
     72                        //if ($GLOBALS['plogger_mode'] == "slideshow") $breadcrumbs .= $sep . '<strong>' . plog_tr('Slideshow'); 
    6073 
    6174                break; 
    6275                case 'search': 
    63                         $breadcrumbs = $collections_link . $sep . '<strong>'.plog_tr('Search').'</strong>' . $sep . plog_tr('You searched for') . ' <strong>'.htmlspecialchars(SmartStripSlashes($_GET['searchterms'])).'</strong>.'; 
     76                        if ($config['truncate_breadcrumb'] == "album"){ 
     77                                $row = get_album_by_id($id); 
     78                                $album_link = '<a accesskey="/" href="' . generate_url("album", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 
     79                                $breadcrumbs = $album_link . $sep . '<strong>'.plog_tr('Search').'</strong>' . $sep . plog_tr('You searched for') . ' <strong>'.htmlspecialchars(SmartStripSlashes($_GET['searchterms'])).'</strong>.'; 
     80                        } else if ($config['truncate_breadcrumb'] == "collection") { 
     81                                $row = get_collection_by_id($id); 
     82                                $collection_link = '<a accesskey="/" href="' . generate_url("collection", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 
     83                                $breadcrumbs = $collection_link . $sep . '<strong>'.plog_tr('Search').'</strong>' . $sep . plog_tr('You searched for') . ' <strong>'.htmlspecialchars(SmartStripSlashes($_GET['searchterms'])).'</strong>.'; 
     84                        } else { 
     85                                $breadcrumbs = $collections_link . $sep . '<strong>'.plog_tr('Search').'</strong>' . $sep . plog_tr('You searched for') . ' <strong>'.htmlspecialchars(SmartStripSlashes($_GET['searchterms'])).'</strong>.'; 
     86                        } 
    6487                break; 
    6588                default: 
     
    503526                } 
    504527        } 
     528 
     529function get_active_collections_albums() { 
     530        $return = array( 
     531                "collections" => '', 
     532                "albums" => ''); 
     533 
     534        $sql = "SELECT parent_collection,parent_album,COUNT(*) AS imagecount 
     535        FROM `".TABLE_PREFIX."pictures` GROUP BY parent_collection,parent_album"; 
     536        $result = run_query($sql); 
     537        while($row = mysql_fetch_assoc($result)) { 
     538                $image_collection_count[$row["parent_collection"]] = $row["imagecount"]; 
     539                $image_album_count[$row["parent_album"]] = $row["imagecount"]; 
     540        } 
     541        $return['collections'] = array_keys($image_collection_count); 
     542        $return['albums'] = array_keys($image_album_count); 
     543        return $return; 
     544} 
    505545 
    506546        function generate_thumb($path, $prefix, $type = THUMB_SMALL) {