Ticket #184: truncate_album_collection_fix.patch
| File truncate_album_collection_fix.patch, 7.7 KB (added by sidtheduck, 5 months ago) |
|---|
-
plog-includes/plog-functions.php
5 5 exit(); 6 6 } 7 7 8 function generate_breadcrumb($collections = 'Collections', $sep = ' » ' , $translate = true){8 function generate_breadcrumb($collections = 'Collections', $sep = ' » '){ 9 9 global $config; 10 10 11 11 $id = $GLOBALS['plogger_id']; 12 12 13 if ($translate === true){14 $collections = plog_tr(SmartStripSlashes($collections));15 }16 13 $collections_link = ' <a href="'.generate_url("collections").'">' . $collections . '</a>'; 17 14 $collections_name = ' <strong>' . $collections . '</strong>'; 18 15 … … 21 18 $row = get_collection_by_id($id); 22 19 $collection_name = '<strong>' . SmartStripSlashes($row['name']) . '</strong>'; 23 20 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 } 25 26 26 27 // 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'); 28 29 29 30 break; 30 31 case 'slideshow': … … 36 37 $row = get_collection_by_id($row['parent_id']); 37 38 $collection_link = '<a accesskey="/" href="' . generate_url("collection", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 38 39 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; 41 44 } else { 42 45 $breadcrumbs = $collections_link . $sep . $collection_link . $sep . $album_name; 43 46 } 44 47 48 if ($GLOBALS['plogger_mode'] == "slideshow") { 49 $breadcrumbs = str_replace($album_name, $album_link . $sep . '<strong>' . plog_tr('Slideshow') . '</strong>', $breadcrumbs); 50 } 51 45 52 break; 46 53 case 'picture': 47 54 $row = get_picture_by_id($id); 48 55 $picture_name = '<span id="image_name"><strong>' . SmartStripSlashes(get_caption_filename($row)) . '</strong></span>'; 49 56 50 $row = get_album_by_id($row[ "parent_album"]);57 $row = get_album_by_id($row['parent_album']); 51 58 $album_link = '<a accesskey="/" href="' . generate_url("album", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 52 59 53 $row = get_collection_by_id($row[ "parent_id"]);60 $row = get_collection_by_id($row['parent_id']); 54 61 $collection_link = '<a accesskey="/" href="' . generate_url("collection", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 55 62 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 } 57 70 58 71 // 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'); 60 73 61 74 break; 62 75 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 } 64 87 break; 65 88 default: 66 89 $breadcrumbs = $collections_name; … … 482 505 } 483 506 } 484 507 508 function get_active_collections_albums() { 509 $return = array( 510 "collections" => '', 511 "albums" => ''); 512 513 $sql = "SELECT parent_collection,parent_album,COUNT(*) AS imagecount 514 FROM `".TABLE_PREFIX."pictures` GROUP BY parent_collection,parent_album"; 515 $result = run_query($sql); 516 while($row = mysql_fetch_assoc($result)) { 517 $image_collection_count[$row["parent_collection"]] = $row["imagecount"]; 518 $image_album_count[$row["parent_album"]] = $row["imagecount"]; 519 } 520 $return['collections'] = array_keys($image_collection_count); 521 $return['albums'] = array_keys($image_album_count); 522 return $return; 523 } 524 485 525 function generate_thumb($path, $prefix, $type = THUMB_SMALL) { 486 526 global $config; 487 527 global $thumbnail_config; -
plogger.php
70 70 71 71 // use plogger specific variables to avoid name clashes if Plogger is embedded 72 72 73 $GLOBALS['plogger_level'] = isset($_GET[ "level"]) ? $_GET["level"] : '';74 $GLOBALS['plogger_id'] = isset($_GET[ "id"]) ? intval($_GET["id"]) : 0;75 $GLOBALS['plogger_mode'] = isset($_GET[ "mode"]) ? $_GET["mode"] : '';73 $GLOBALS['plogger_level'] = isset($_GET['level']) ? $_GET['level'] : ''; 74 $GLOBALS['plogger_id'] = isset($_GET['id']) ? intval($_GET['id']) : 0; 75 $GLOBALS['plogger_mode'] = isset($_GET['mode']) ? $_GET['mode'] : ''; 76 76 77 // count collections and albums with pictures in them 78 $active = get_active_collections_albums(); 79 80 // if only 1 active album, truncate the "collection" & "collections" portion of Plogger 81 if (count($active['albums']) == 1) { 82 $config['truncate_breadcrumb'] = 'album'; 83 if ($GLOBALS['plogger_level']!="picture") { 84 if ($GLOBALS['plogger_level']!="search") { 85 $GLOBALS['plogger_level'] = "album"; 86 } 87 $GLOBALS['plogger_id'] = $active['albums'][0]; 88 } 89 // if only 1 active collection, truncate the "collections" portion of Plogger 90 } else if (count($active['collections']) == 1) { 91 $config['truncate_breadcrumb'] = 'collection'; 92 if ($GLOBALS['plogger_level']!="album" && $GLOBALS['plogger_level']!='picture') { 93 if ($GLOBALS['plogger_level']!="search") { 94 $GLOBALS['plogger_level'] = "collection"; 95 } 96 $GLOBALS['plogger_id'] = $active['collections'][0]; 97 } 98 } else { 99 $config['truncate_breadcrumb'] = false; 100 } 101 77 102 $allowed_levels = array('collections','collection','album','picture','search'); 78 103 if (!in_array($GLOBALS['plogger_level'],$allowed_levels)) { 79 104 $GLOBALS['plogger_level'] = 'collections';
