Index: /trunk/protemix/etc/collect.cfg
===================================================================
--- /trunk/protemix/etc/collect.cfg	(revision 3167)
+++ /trunk/protemix/etc/collect.cfg	(revision 3168)
@@ -4,10 +4,9 @@
 
 buildtype     mgpp
-#indexes       text,Title,Class1,Class2,Class3
 indexes       text,metadata
-#levels        Section
-#defaultindex  text,Title,Class1,Class2,Class3
+levels        Section
 defaultindex  text,metadata
 
+collectionmeta .text,metadata    "all"
 
 plugin        GAPlug
@@ -18,13 +17,12 @@
 classify      AZList -metadata Title
 
+format CL1VList \
+  '<p>[Title]<br><small>\[ [link]HTML</a> \]\[ <a href="_httpcollection_/index/assoc/[archivedir]/[pdf]">PDF</a> \]</small></p>'
+
 format SearchVList \
-  "<td>[link][icon][/link]</td>{If}{[srclink],<td>[srclink]_iconpdf_</a></td>}<td>{If}{[parent(All': '):Title],[parent(All': '):Title]:}[link][Title][/link]</td>"
-
-format DocumentText \
-  "<center><table border=0 cellspacing=0 cellpadding=0 width=_pagewidth_><tr><td>[srclink]_iconpdf_ View PDF version</a></td></tr></table></center>[Text]"
+  '<p>[parent:Title] <small><i>(page [Title])</i><br>\[ [link]HTML</a> \]\[ <a href="_httpcollection_/index/assoc/[parent:archivedir]/[pdf]">Single Page PDF</a> \]\[ <a href="_httpcollection_/index/assoc/[parent:archivedir]/[parent:pdf]">Article PDF</a> \]</small></p>'
 
 collectionmeta collectionname      "Protemix FDA Submission"
 collectionmeta collectionextra     ""
 
-
-
+cgiarg          shortname=a argdefault=q
Index: /trunk/protemix/macros/base.dm
===================================================================
--- /trunk/protemix/macros/base.dm	(revision 3167)
+++ /trunk/protemix/macros/base.dm	(revision 3168)
@@ -32,8 +32,5 @@
 _collectionname_ {}
 
-_imagecollection_ {_If_("_iconcollection_" ne "",
-<a href="_httppageabout_"><img src="_iconcollection_" border=0></a>,
-_imagecollectionv_}
-_imagecollectionv_ {_If_(_collectionname_,<br><br><h2><a href="_httppageabout_">_collectionname_</a></h2>)}
+_imagecollection_ {<img src="_httpcollection_/images/protemixlogo.gif">}
 
 #######################################################################
@@ -140,5 +137,5 @@
 # the page. 
 
-_javalinks_ {_imagehome_}
+_javalinks_ {}
 
 
Index: /trunk/protemix/macros/english.dm
===================================================================
--- /trunk/protemix/macros/english.dm	(revision 3167)
+++ /trunk/protemix/macros/english.dm	(revision 3168)
@@ -131,4 +131,7 @@
 _texticonexpandtext_ {Display all text}
 _texticoncontracttext_ {Display text only for currently selected section}
+_texticonpagepdf_ {Display PDF file of this page}
+_texticonartpdf_ {Display PDF file of entire article}
+
 
 _textgoto_ {go to page}
@@ -170,4 +173,12 @@
 _httpiconenhlof_ {_httpimg_/enhlof.gif}
 _httpiconenhlon_ {_httpimg_/enhlon.gif}
+
+## "SINGLE PAGE PDF" ## document_button ## sppdf ##
+_httpiconsppdfof_ {_httpcollection_/images/sppdfof.gif}
+_httpiconsppdfon_ {_httpcollection_/images/sppdfon.gif}
+
+## "ARTICLE PDF" ## document_button ## apdf ##
+_httpiconapdfof_ {_httpcollection_/images/apdfof.gif}
+_httpiconapdfon_ {_httpcollection_/images/apdfon.gif}
 
 ######################################################################
Index: /trunk/protemix/macros/query.dm
===================================================================
--- /trunk/protemix/macros/query.dm	(revision 3167)
+++ /trunk/protemix/macros/query.dm	(revision 3168)
@@ -28,15 +28,11 @@
 
 _iconthispage_ {<img src="_httpiconhsearch_" alt="_texticonthispage_" width="_widthhsearch_" height="_heighthsearch_">}
-_iconthispage_ [v=1] {<h2>_texticonthispage_</h2>}
 
 _iconqueryresultsbar_ {<img src="_httpiconqryresb_" width="_widthqryresb_" height="_heightqryresb_" alt="_texticonqueryresultsbar_">}
-_iconqueryresultsbar_[v=1] {_texticonqueryresultsbar_}
 
 # _iconnext_ and _iconprev_ are overridden in this package as we
 # don't want alt text here
 _iconnext_{<img src="_httpiconmore_" width=_widthmore_ height=_heightmore_ border=0 align=top>}
-_iconnext_ [v=1] {}
 _iconprev_{<img src="_httpiconless_" width=_widthless_ height=_heightless_ border=0 align=top>}
-_iconprev_ [v=1] {}
 
 #######################################################################
@@ -75,10 +71,13 @@
   form.c3.options.length = 0;
 
+  var isselected = 0;
   for (i = 0; i < options[c2].length; i++) \{
     form.c3.options[i] = new Option(options[c2][i], options[c2][i]);
+    if (options[c2][i] == "_cgiargc3_") \{
+      form.c3.selectedIndex = i;
+      isselected = 1;
+    \}
   \}
-
-  form.c3.selectedIndex = 0;
-
+  if (!isselected) form.c3.selectedIndex = 0;
 \}
 }
@@ -88,5 +87,5 @@
 }
 
-_pagetitle_ {_If_(_cgiargq_,_textquerytitle_,_textnoquerytitle_)}
+_pagetitle_ {}
 
 _content_ {
@@ -97,10 +96,6 @@
 _queryform_
 </center>
-_If_(_cgiargq_,<center>_iconqueryresultsbar_</center><br>
-<small>
-_freqmsg_
-_textpostprocess_</small><br>
+<center>_iconblankbar_</center><br>
 _resultline_
-,<center>_iconblankbar_</center>)<br>
 }
 
@@ -109,4 +104,5 @@
 <input type=hidden name="a" value="q">
 <input type=hidden name="r" value="1">
+<input type=hidden name="g" value="Section">
 <input type=hidden name="e" value="_decodedcompressedoptions_">
 <p>
@@ -116,8 +112,8 @@
 <td align="center">
 <select name="c1">
-<option value="">Any
-<option value="Animal">Animal
-<option value="Human">Human
-<option value="Other">Other
+<option value=""_If_(_cgiargc1_,, selected)>Any
+<option value="Animal"_If_("_cgiargc1_" eq "Animal", selected)>Animal
+<option value="Human"_If_("_cgiargc1_" eq "Human", selected)>Human
+<option value="Other"_If_("_cgiargc1_" eq "Other", selected)>Other
 </select>
 </td>
@@ -129,12 +125,12 @@
 <td align="center">
 <select name="c2" onChange='initialize()'>
-<option value="">Any
-<option value="Pharmacokinetics">Pharmacokinetics
-<option value="Pharmacodynamics">Pharmacodynamics
-<option value="Safety/Side Effects/Toxicity">Safety/Side Effects/Toxicity
-<option value="Other">Other
-<option value="Efficacy">Efficacy
-<option value="Contraindications">Contraindications
-<option value="Precautions">Precautions
+<option value=""_If_(_cgiargc2_,, selected)>Any
+<option value="Pharmacokinetics"_If_("_cgiargc2_" eq "Pharmacokinetics", selected)>Pharmacokinetics
+<option value="Pharmacodynamics"_If_("_cgiargc2_" eq "Pharmacodynamics", selected)>Pharmacodynamics
+<option value="Safety/Side Effects/Toxicity"_If_("_cgiargc2_" eq "Safety/Side Effects/Toxicity", selected)>Safety/Side Effects/Toxicity
+<option value="Other"_If_("_cgiargc2_" eq "Other", selected)>Other
+<option value="Efficacy"_If_("_cgiargc2_" eq "Efficacy", selected)>Efficacy
+<option value="Contraindications"_If_("_cgiargc2_" eq "Contraindications", selected)>Contraindications
+<option value="Precautions"_If_("_cgiargc2_" eq "Precautions", selected)>Precautions
 </select>
 </td>
@@ -153,4 +149,5 @@
 
 <tr valign="top"><td colspan="5">
+<b>AND</b><br>
 <nobr>
 <input type="text" name="q" value="_cgiargq_" size="40">
@@ -162,2 +159,14 @@
 </form>
 }
+
+# we want to put the links to previous/next pages of results
+# in the footer
+_pagefooterextra_ {
+<center>
+<table cellspacing=0 cellpadding=0 width=_pagewidth_>
+<tr>
+<td align=left>_If_(_prevfirst_,<a href="_httpquery_&r=_prevfirst_">_iconprev__textmatches__prevfirst_ - _prevlast_</a>)</td>
+<td align=right>_If_(_nextfirst_,<a href="_httpquery_&r=_nextfirst_">_textmatches__nextfirst_ - _nextlast__iconnext_</a>)</td>
+</tr></table>
+</center>
+}
Index: /trunk/protemix/perllib/plugins/ProtemixPlug.pm
===================================================================
--- /trunk/protemix/perllib/plugins/ProtemixPlug.pm	(revision 3167)
+++ /trunk/protemix/perllib/plugins/ProtemixPlug.pm	(revision 3168)
@@ -75,7 +75,15 @@
     }
 
-    # read in directory and process individual files
     my $dir = File::Basename::dirname($filename);
 
+    # associate article level pdf file
+    my ($pdffile) = $dir =~ /([^\/\\]+)$/;
+    $pdffile = &util::filename_cat($dir, $pdffile);
+    $pdffile .= "-all.pdf";
+    die "$pdffile does not exist" unless -e $pdffile;
+    $doc_obj->associate_file($pdffile, "article.pdf", undef, $topsection);
+    $doc_obj->add_utf8_metadata ($cursection, "pdf",  "article.pdf"); 
+
+    # read in directory and process individual files
     opendir(DIR, $dir) || die;
     my @files = readdir DIR;
@@ -103,19 +111,18 @@
 	    $self->process_section (\$text, '', $thisfile, $doc_obj, $cursection);
 
-	    # associate PDF file with doc object
+	    # associate PDF page level pdf file
 	    my $pdffile = $thisfile;
 	    $pdffile =~ s/\.html?$/\.pdf/;
 	    die "no PDF file for $thisfile" unless -e $pdffile;
-	    $doc_obj->associate_file($pdffile, "doc$count.pdf", undef, $cursection);
-	    my $doclink = "<a href=\"_httpcollection_/index/assoc/[parent(Top):archivedir]/doc$count.pdf\">";
-#	    $doc_obj->add_utf8_metadata ($cursection, "srclink",  $doclink); 
+	    $doc_obj->associate_file($pdffile, "page$count.pdf", undef, $cursection);
+	    $doc_obj->add_utf8_metadata ($cursection, "pdf",  "page$count.pdf"); 
 	    $doc_obj->add_utf8_metadata ($cursection, "Title", $count); 
 
 	    # add any section level metadata we have for this page (set from within the meta.xml file)
-#	    if (defined ($self->{'section_metadata'}->{$filesuf})) {
-#		foreach my $key (keys %{$self->{'section_metadata'}->{$filesuf}}) {
-#		    $doc_obj->add_utf8_metadata ($cursection, $key, $self->{'section_metadata'}->{$filesuf}->{$key});
-#		}
-#	    }
+	    if (defined ($self->{'section_metadata'}->{$filesuf})) {
+		foreach my $key (keys %{$self->{'section_metadata'}->{$filesuf}}) {
+		    $doc_obj->add_utf8_metadata ($cursection, $key, $self->{'section_metadata'}->{$filesuf}->{$key});
+		}
+	    }
 
 	    $count ++;
Index: /trunk/protemix/rename.pl
===================================================================
--- /trunk/protemix/rename.pl	(revision 3167)
+++ /trunk/protemix/rename.pl	(revision 3168)
@@ -97,4 +97,11 @@
     $noncss =~ s/(<table.*?)rules=\"all\"\s+/$1/sig;
 
+    # remove empty <div> tags 
+    while ($noncss =~ s/(<div[^>]*>\s*<\/div>)//sig) {}
+
+    # remove empty table rows
+    $noncss =~ s/(<tr[^>]*>(\s*<td[^>]*>\s*<\/td>)*\s*<\/tr>)//sig;
+    $noncss =~ s/<table[^>]*>\s*<\/table>//sig;
+
     open (FILE, ">$filename") || die;
     print FILE $header . $noncss . $footer;
@@ -108,4 +115,5 @@
     $filename =~ s/\s+//g;
     $filename =~ s/^protemix\(\d+\)-?//;
+    $filename =~ s/^OCR\d+-0//;
 
     return $filename;
Index: /trunk/protemix/src/recpt/Makefile.in
===================================================================
--- /trunk/protemix/src/recpt/Makefile.in	(revision 3167)
+++ /trunk/protemix/src/recpt/Makefile.in	(revision 3168)
@@ -65,9 +65,9 @@
 	$(COMPILE) $< 
 
-HEADERS = ptmxqueryaction.h
+HEADERS = ptmxqueryaction.h ptmxdocaction.h
 
-SOURCES = ptmxmain.cpp ptmxqueryaction.cpp browsetools.cpp
+SOURCES = ptmxmain.cpp ptmxqueryaction.cpp ptmxdocaction.cpp browsetools.cpp
 
-OBJECTS = ptmxmain.o ptmxqueryaction.o browsetools.o
+OBJECTS = ptmxmain.o ptmxqueryaction.o ptmxdocaction.o browsetools.o
 
 EXEC    = ptmx
Index: /trunk/protemix/src/recpt/browsetools.cpp
===================================================================
--- /trunk/protemix/src/recpt/browsetools.cpp	(revision 3167)
+++ /trunk/protemix/src/recpt/browsetools.cpp	(revision 3168)
@@ -23,5 +23,4 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id$
  *
  *********************************************************************/
@@ -38,48 +37,14 @@
 		      ostream &/*logout*/) {
 
-  if (args["u"] != "1") {
-    
-    FilterResponse_t response;
-    text_tarray metadata;
-    text_tarray buttons;
-    
-    text_tarray::const_iterator here = ibuttons.begin();
-    text_tarray::const_iterator end = ibuttons.end();
-    
-    while (here != end) {
-      
-      if (*here == "Detach")
-	buttons.push_back ("_document:imagedetach_");
-      else if (*here == "Highlight") {
-	if (args["hl"] == "1") 
-	  buttons.push_back ("_document:imagenohighlight_");
-	else 
-	  buttons.push_back ("_document:imagehighlight_");
-      } else if (*here == "Expand Contents") {
-	if (args["gc"] == "1")
-	  buttons.push_back ("_document:imagecontracttoc_");
-	else 
-	  buttons.push_back ("_document:imageexpandtoc_");
-      } else if (*here == "Expand Text") {
-	if (args.getintarg("gt"))
-	  buttons.push_back ("_document:imagecontracttext_");
-	else 
-	  buttons.push_back ("_document:imageexpandtext_");
-      }
-      here ++;
-    }
-    
-    here = buttons.begin();
-    end = buttons.end();
-    int count = 0;
-    while (here != end) {
-      if ((count != 0) && ((count % 2) == 0)) textout << "<br>\n";
-      textout << outconvert << disp << *here;
-      count ++;
-      here ++;
-    }
-  }
-}
-
+  textout << outconvert << disp
+	  << "_document:imagepagepdf_"
+	  << "_document:imagearticlepdf_"
+	  << "_document:imagedetach_";
+  if (args["hl"] == "1") {
+    textout << outconvert << disp << "_document:imagenohighlight_";
+  } else {
+    textout << outconvert << disp << "_document:imagehighlight_";
+  }
+}
 
 // at the moment this just writes out the html to display 
@@ -765,17 +730,11 @@
   if ((!fulltoc) && (!args["d"].empty())) {
     textout << "<center>\n";
-    textout << outconvert << disp << "<p><table width=_pagewidth_ cellpadding=0 cellspacing=0><tr>\n";
-    textout << "<td valign=top align=left";
-    if (formatinfo.DocumentContents) textout << " width=200>\n";
-    else textout << " width=100%>\n";
-    if (formatinfo.DocumentImages) 
-      output_cover_image (args, collectproto, disp, outconvert, textout, logout);
-    else if (formatinfo.DocumentTitles)
-      output_titles (args, collectproto, formatinfo, disp, outconvert, textout, logout);
-    if (args["u"] != "1") {
-      output_controls (args, formatinfo.DocumentButtons, collectproto, disp, 
-		       outconvert, textout, logout);
-    }
-    textout << "</td><td valign=top>\n";  
+    textout << outconvert << disp 
+	    << "<p><table width=\"_pagewidth_\" cellpadding=\"0\" cellspacing=\"0\">\n"
+	    << "<tr valign=\"top\">\n"
+	    << "<td>\n";
+    output_titles (args, collectproto, formatinfo, disp, outconvert, textout, logout);
+    textout << "</td></tr>\n"
+	    << "<tr><td>\n";
     havecontrols = true;
   }
@@ -800,13 +759,11 @@
   }
 
-  if (havecontrols) textout << "</td></tr></table></center>\n"; 
-
-  //if there is a format specified in the config file then
-  //try to display the related documents (may not be displayed
-  //if preference file does not indicate a wish to display
-  //related documents.
-  if (!formatinfo.RelatedDocuments.empty())
-    output_related_docs(args, collectproto, formatinfo, disp, outconvert, textout, logout);
- 
-}
-
+  if (havecontrols) {
+    textout << "</td></tr>\n"
+	    << "<tr><td>\n";
+    output_controls (args, formatinfo.DocumentButtons, collectproto, disp, 
+		     outconvert, textout, logout);
+    textout << "</td></tr></table></center>\n"; 
+  }
+}
+
Index: /trunk/protemix/src/recpt/ptmxdocaction.cpp
===================================================================
--- /trunk/protemix/src/recpt/ptmxdocaction.cpp	(revision 3168)
+++ /trunk/protemix/src/recpt/ptmxdocaction.cpp	(revision 3168)
@@ -0,0 +1,60 @@
+/**********************************************************************
+ *
+ * ptmxdocaction.cpp -- 
+ * A component of the Greenstone digital library software
+ * from the New Zealand Digital Library Project at the
+ * University of Waikato, New Zealand.
+ *
+ * Copyright (C) 2002  Stefan Boddie
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ *********************************************************************/
+
+#include "ptmxdocaction.h"
+#include "OIDtools.h"
+
+ptmxdocaction::ptmxdocaction () {
+}
+
+ptmxdocaction::~ptmxdocaction () {
+}
+
+void ptmxdocaction::define_internal_macros (displayclass &disp, cgiargsclass &args, 
+					    recptprotolistclass *protos, ostream &logout) {
+
+  documentaction::define_internal_macros(disp, args, protos, logout);
+
+  // set _pagepdf_ metadata
+
+  if (!args["d"].empty()) {
+    text_t &collection = args["c"];
+    if (collection.empty()) return;
+    recptproto *collectproto = protos->getrecptproto (collection, logout);
+    if (collectproto == NULL) return;
+    
+    FilterResponse_t response;
+    text_tset metadata;
+    metadata.insert("pdf");
+    if (get_info (args["d"], collection, metadata, false, collectproto, response, logout)) {
+      text_t &pdf = response.docInfo[0].metadata["pdf"].values[0];
+      if (!pdf.empty()) {
+	disp.setmacro ("pagepdf", "Global", pdf);
+      }
+    }
+  }
+}
+
Index: /trunk/protemix/src/recpt/ptmxdocaction.h
===================================================================
--- /trunk/protemix/src/recpt/ptmxdocaction.h	(revision 3168)
+++ /trunk/protemix/src/recpt/ptmxdocaction.h	(revision 3168)
@@ -0,0 +1,47 @@
+/**********************************************************************
+ *
+ * ptmxdocaction.h -- 
+ * A component of the Greenstone digital library software
+ * from the New Zealand Digital Library Project at the
+ * University of Waikato, New Zealand.
+ *
+ * Copyright (C) 2002  Stefan Boddie
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ *********************************************************************/
+
+
+#ifndef PTMXDOCACTION_H
+#define PTMXDOCACTION_H
+
+#include "documentaction.h"
+
+class ptmxdocaction : public documentaction {
+
+protected:
+
+public:
+  ptmxdocaction ();
+  virtual ~ptmxdocaction ();
+
+  virtual void define_internal_macros (displayclass &disp, cgiargsclass &args, 
+				       recptprotolistclass *protos, ostream &logout);
+};
+
+#endif
+
+
Index: /trunk/protemix/src/recpt/ptmxmain.cpp
===================================================================
--- /trunk/protemix/src/recpt/ptmxmain.cpp	(revision 3167)
+++ /trunk/protemix/src/recpt/ptmxmain.cpp	(revision 3168)
@@ -43,5 +43,5 @@
 #include "pageaction.h"
 #include "ptmxqueryaction.h"
-#include "documentaction.h"
+#include "ptmxdocaction.h"
 #include "extlinkaction.h"
 #include "phindaction.h"
@@ -84,5 +84,5 @@
   recpt.add_action (&aqueryaction);
 
-  documentaction adocumentaction;
+  ptmxdocaction adocumentaction;
   adocumentaction.set_receptionist (&recpt);
   recpt.add_action (&adocumentaction);
Index: /trunk/protemix/src/recpt/ptmxqueryaction.h
===================================================================
--- /trunk/protemix/src/recpt/ptmxqueryaction.h	(revision 3167)
+++ /trunk/protemix/src/recpt/ptmxqueryaction.h	(revision 3168)
@@ -26,5 +26,5 @@
 
 
-#ifndef PTMXQUERYDOCACTION_H
+#ifndef PTMXQUERYACTION_H
 #define PTMXQUERYACTION_H
 
