home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / skeptic / bibliography / display2.cgi < prev    next >
Text File  |  2009-08-26  |  2KB  |  91 lines

  1. #!/usr/bin/perl
  2.  
  3. # Given an ID, displays a single entry from the bibliography.
  4. # The ID must be part of the URL, for example:
  5. # /cgi-bin/display.cgi/ID
  6.  
  7. unshift(@INC, "lib");
  8.  
  9. require 'config.pl';
  10. require 'db.pl';
  11. require 'web.pl';
  12. require 'cgi-lib.pl';
  13.  
  14. print "Content-type: text/html\n\n";
  15. &ReadParse();
  16.  
  17. if ($in{id})
  18. {
  19.     $id = $in{id};
  20. }
  21. elsif ($in{next_submit} && $in{next})
  22. {
  23.     $id = $in{next};
  24. }
  25. elsif ($in{previous_submit} && $in{previous})
  26. {
  27.     $id = $in{previous};
  28. }
  29. else
  30. {
  31.     ($id = $ENV{PATH_INFO}) =~ s!.*/!!;
  32.     &error("Bibliography ID must be specified as part of the URL.") unless $id;
  33. }
  34.  
  35. (%entry) = &db::read_entry($id);
  36. &error("Error reading bibliography entry for ID '$id': $db::error")
  37.   unless defined %entry;
  38.  
  39. foreach $keyword (sort {uc($a) cmp uc($b)} split(/\s+/, $entry{KEYWORDS}))
  40. {
  41.     push(@keywords, $keyword);
  42. }
  43. $entry{KEYWORDS} = join(', ', @keywords);
  44.  
  45. ($entry{TITLE2} = $entry{TITLE}) =~ s/\W+/ /g;
  46.  
  47. if ($entry{URL})
  48. {
  49.     $entry{TITLE} = &hotlink($entry{URL}, $entry{TITLE});
  50. }
  51.  
  52. foreach (split(/,/, $in{series}))
  53. {
  54.     if ($need_next)
  55.     {
  56.         $next = "<INPUT TYPE=hidden NAME=next VALUE=$_>\n";
  57.         $next .= "<INPUT TYPE=submit NAME=next_submit VALUE=Next>";
  58.         last;
  59.     }
  60.  
  61.     if ($id eq $_)
  62.     {
  63.         $need_next = 1;
  64.         next;
  65.     }
  66.  
  67.     $previous = "<INPUT TYPE=hidden NAME=previous VALUE=$_>\n";
  68.     $previous .= "<INPUT TYPE=submit NAME=previous_submit VALUE=Previous>";
  69. }
  70.  
  71.  
  72. $entry .= &bib::template("entry3.html",
  73.                          "NEXT", $next,
  74.                          "PREVIOUS", $previous,
  75.                          "SERIES", $in{series},
  76.                          %entry)
  77.   if ($next || $previous);
  78.  
  79. $entry .= &bib::template("entry.html",
  80.                         "ID", $id,
  81.                         %entry);
  82. $entry .= &bib::template("entry2.html",
  83.                          "ID", $id,
  84.                          %entry);
  85.  
  86. print &bib::template("basic.html",
  87.                      "TITLE", $entry{TITLE2},
  88.                      "DATA", $entry);
  89.  
  90. exit 0;
  91.