]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Make Bugzilla support <link> tag for buglists. Bug 87818. r=jake, caillon.
authorgerv%gerv.net <>
Tue, 11 Sep 2001 04:26:05 +0000 (04:26 +0000)
committergerv%gerv.net <>
Tue, 11 Sep 2001 04:26:05 +0000 (04:26 +0000)
CGI.pl
buglist.cgi
show_bug.cgi

diff --git a/CGI.pl b/CGI.pl
index 3c0795d44d335df9cb14ef613e6560c1e4ab5d82..7fb0298d8de567db8e373c0a686878e74bc4879d 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -22,6 +22,7 @@
 #                 Joe Robins <jmrobins@tgix.com>
 #                 Dave Miller <justdave@syndicomm.com>
 #                 Christopher Aillon <christopher@aillon.com>
+#                 Gervase Markham <gerv@gerv.net>
 
 # Contains some global routines used throughout the CGI scripts of Bugzilla.
 
@@ -408,6 +409,48 @@ sub navigation_header {
     print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=enter_bug.cgi>Enter new bug</A>\n"
 }
 
+# Adds <link> elements for bug lists. These can be inserted into the header by
+# (ab)using the "jscript" parameter to PutHeader, which inserts an arbitrary
+# string into the header. This function is modelled on the one above.
+sub navigation_links($) {
+    my ($buglist) = @_;
+    
+    my $retval = "";
+    
+    # We need to be able to pass in a buglist because when you sort on a column
+    # the bugs in the cookie you are given will still be in the old order.
+    # If a buglist isn't passed, we just use the cookie.
+    $buglist ||= $::COOKIE{"BUGLIST"};
+    
+    if (defined $buglist && $buglist ne "") {
+    my @bugs = split(/:/, $buglist);
+        
+        if (defined $::FORM{'id'}) {
+            # We are on an individual bug
+            my $cur = lsearch(\@bugs, $::FORM{"id"});
+
+            if ($cur > 0) {
+                $retval .= "<link rel=\"First\" href=\"show_bug.cgi?id=$bugs[0]\" />\n";
+                $retval .= "<link rel=\"Prev\" href=\"show_bug.cgi?id=$bugs[$cur - 1]\" />\n";
+            } 
+            if ($cur < $#bugs) {
+                $retval .= "<link rel=\"Next\" href=\"show_bug.cgi?id=$bugs[$cur + 1]\" />\n";
+                $retval .= "<link rel=\"Last\" href=\"show_bug.cgi?id=$bugs[$#bugs]\" />\n";
+            }
+
+            $retval .= "<link rel=\"Up\" href=\"buglist.cgi?regetlastlist=1\" />\n";
+            $retval .= "<link rel=\"Contents\" href=\"buglist.cgi?regetlastlist=1\" />\n";
+        } else {
+            # We are on a bug list
+            $retval .= "<link rel=\"First\" href=\"show_bug.cgi?id=$bugs[0]\" />\n";
+            $retval .= "<link rel=\"Next\" href=\"show_bug.cgi?id=$bugs[0]\" />\n";
+            $retval .= "<link rel=\"Last\" href=\"show_bug.cgi?id=$bugs[$#bugs]\" />\n";
+        }
+    }
+    
+    return $retval;
+} 
+
 sub make_checkboxes {
     my ($src,$default,$isregexp,$name) = (@_);
     my $last = "";
index e08df3952d0ebca97e4f3e98bfc55970e41e0e11..f6143abaa3241515b20547ca933e5af3e1e51139 100755 (executable)
@@ -1313,7 +1313,7 @@ if (length($buglist) < 4000) {
     print "Set-Cookie: BUGLIST=\n\n";
     $toolong = 1;
 }
-PutHeader($::querytitle);
+PutHeader($::querytitle, undef, "", "", navigation_links($buglist));
 
 
 print "
index eced9cfbef72f1d006d842a123f155ca20c5d9b9..c5b569a459c5ed5062bf43f81165b269a3ad121f 100755 (executable)
@@ -68,7 +68,7 @@ GetVersionTable();
 SendSQL("SELECT short_desc FROM bugs WHERE bug_id = $::FORM{'id'}");
 my ($summary) = FetchSQLData();
 $summary = html_quote($summary);
-PutHeader("Bug $::FORM{'id'} - $summary", "Bugzilla Bug $::FORM{'id'}", $summary );
+PutHeader("Bug $::FORM{'id'} - $summary", "Bugzilla Bug $::FORM{'id'}", $summary, "", navigation_links() );
 
 navigation_header();