Changeset 534

Show
Ignore:
Timestamp:
04/25/08 13:24:47 (7 months ago)
Author:
sidtheduck
Message:

+ Fix for ticket #83 - Updated generate_breadcrumbs() function

  • Adds 3 variables to the function: $collections, $sep, and $translate . $collections allows you to quickly change the "Collections" text - defaults to "Collections" if nothing submitted. . $sep allows you to quickly change the separator - defaults to ' » ' . $translate allows the user to toggle translation of the $collections variable (whether the submitted text is typed in english or in the user's language) - defaults to true

example usage: generate_breadcrumbs("My Pics", " | ", true);

+ Fix for ticket #95 - Added "Collections" link and "Search" to breadcrumbs if level = search

+ general cleanup of the generate_breadcrumbs() function

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/plog-functions.php

    r533 r534  
    11<?php 
    22 
    3 function generate_breadcrumb(){ 
    4         global $config; 
    5          
    6         $id = $GLOBALS["plogger_id"]; 
     3function generate_breadcrumb($collections = 'Collections', $sep = ' &raquo; ', $translate = true){ 
     4        global $config; 
     5         
     6        $id = $GLOBALS['plogger_id']; 
     7         
     8        if ($translate === true){ 
     9                $collections = plog_tr(SmartStripSlashes($collections)); 
     10        } 
     11        $collections_link = ' <a href="'.$config['baseurl'].'">' . $collections . '</a>'; 
     12        $collections_name = ' <strong>' . $collections . '</strong>'; 
    713         
    814        switch ($GLOBALS['plogger_level']) { 
    915                case 'collection': 
    1016                        $row = get_collection_by_id($id); 
    11                          
    12                         $breadcrumbs = ' <a accesskey="/" href="'.$config["baseurl"].'">' . plog_tr('Collections') . '</a> &raquo; <b>' . SmartStripSlashes($row["name"]) . '</b>'; 
    13                         if ($GLOBALS['plogger_mode'] == "slideshow") $breadcrumbs .= ' &raquo; ' . plog_tr('Slideshow'); 
     17                        $collection_name = '<strong>' . SmartStripSlashes($row['name']) . '</strong>'; 
     18                         
     19                        $breadcrumbs = $collections_link . $sep . $collection_name; 
     20                         
     21                        // Does this ever happen?  Collection level + slideshow mode ends in SQL error 
     22                        if ($GLOBALS['plogger_mode'] == "slideshow") $breadcrumbs .= $sep . '<strong>' . plog_tr('Slideshow'); 
    1423                         
    1524                        break; 
     
    1726                case 'album': 
    1827                        $row = get_album_by_id($id); 
    19                          
    20                         $album_name = SmartStripSlashes($row["name"]); 
    21                         $album_link = generate_url("album",$row["id"]); 
    22                          
    23                         $row = get_collection_by_id($row["parent_id"]); 
    24                          
    25                         $collection_link = '<a accesskey="/" href="' . generate_url("collection",$row["id"]) . '">' . $row["name"] . '</a>'; 
     28                        $album_name = '<strong>' . SmartStripSlashes($row['name']) . '</strong>'; 
     29                        $album_link = '<a accesskey="/" href="' . generate_url("album", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 
     30                         
     31                        $row = get_collection_by_id($row['parent_id']); 
     32                        $collection_link = '<a accesskey="/" href="' . generate_url("collection", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 
    2633                         
    2734                        if ($GLOBALS['plogger_mode'] == "slideshow") { 
    28                                  
    29                                 $breadcrumbs = ' <a href="'.$config["baseurl"].'">' . plog_tr('Collections') . '</a> &raquo; ' . $collection_link . ' &raquo; ' . '<a href="'.$album_link.'">'.$album_name.'</a> &raquo; ' . ' <b>' . plog_tr('Slideshow') . '</b>'; 
     35                                $breadcrumbs = $collections_link . $sep . $collection_link . $sep . $album_link . $sep . '<strong>' . plog_tr('Slideshow') . '</strong>'; 
    3036                        } else { 
    31                                  
    32                                 $breadcrumbs = ' <a href="'.$config["baseurl"].'">' . plog_tr('Collections') . '</a> &raquo; ' . $collection_link . ' &raquo; ' . '<b>'.$album_name.'</b>'; 
     37                                $breadcrumbs = $collections_link . $sep . $collection_link . $sep . $album_name; 
    3338                        } 
    3439                         
     
    3641                case 'picture': 
    3742                        $row = get_picture_by_id($id); 
    38                         $picture_name = get_caption_filename($row); 
     43                        $picture_name = '<span id="image_name"><strong>' . SmartStripSlashes(get_caption_filename($row)) . '</strong></span>'; 
    3944                         
    4045                        $row = get_album_by_id($row["parent_album"]); 
    41                          
    42                         $album_link = '<a accesskey="/" href="' . generate_url("album",$row["id"]) . '">' . SmartStripSlashes($row["name"]) . '</a>'; 
     46                        $album_link = '<a accesskey="/" href="' . generate_url("album", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 
    4347                         
    4448                        $row = get_collection_by_id($row["parent_id"]); 
    45                          
    46                         $collection_link = ' <a href="'.$config["baseurl"].'">' . plog_tr('Collections') . '</a> ' . ' &raquo; ' . '<a href="' . generate_url("collection",$row["id"]) . '">' . SmartStripSlashes($row["name"]) . '</a>'; 
    47                          
    48                         $breadcrumbs = $collection_link . ' &raquo; ' . $album_link . ' &raquo; ' . '<span id="image_name"><b>' . $picture_name.'</b></span>'; 
    49                          
    50                         if ($GLOBALS['plogger_mode'] == "slideshow") $breadcrumbs .= ' &raquo; ' . plog_tr('Slideshow'); 
     49                        $collection_link = '<a accesskey="/" href="' . generate_url("collection", $row['id']) . '">' . SmartStripSlashes($row['name']) . '</a>'; 
     50                         
     51                        $breadcrumbs = $collections_link . $sep . $collection_link . $sep . $album_link . $sep . $picture_name; 
     52                         
     53                        // Does this ever happen?  Picture level + slideshow adds 'Slideshow' to breadcrumbs only 
     54                        if ($GLOBALS['plogger_mode'] == "slideshow") $breadcrumbs .= $sep . '<strong>' . plog_tr('Slideshow'); 
    5155                         
    5256                        break; 
    5357                case 'search': 
    54                         $breadcrumbs = plog_tr('You searched for') . ' <b>'.htmlspecialchars($_GET["searchterms"]).'</b>.'; 
     58                        $breadcrumbs = $collections_link . $sep . '<strong>'.plog_tr('Search').'</strong>' . $sep . plog_tr('You searched for') . ' <strong>'.htmlspecialchars(SmartStripSlashes($_GET['searchterms'])).'</strong>.'; 
    5559                        break; 
    5660                default: 
    57                         $breadcrumbs = ' <b>' . plog_tr('Collections') . '</b>'; 
     61                        $breadcrumbs = $collections_name; 
    5862                        break; 
    5963        }