Index: /trunk/protemix/etc/collect.cfg
===================================================================
--- /trunk/protemix/etc/collect.cfg	(revision 3206)
+++ /trunk/protemix/etc/collect.cfg	(revision 3207)
@@ -20,5 +20,5 @@
 plugin        WordPlug
 plugin        ArcPlug
-plugin        RecPlug
+plugin        RecPlug -use_metadata_files
 
 classify      AZList -metadata Title
@@ -28,8 +28,8 @@
 
 format CL1VList \
-  '<p>[Title]<br><small>\[ [link]text</a> \]{If}{[pdf],\\[ <a href="_httpcollection_/index/assoc/[archivedir]/[pdf]">pdf</a> \\]}</small></p>'
+  '<p>[Title]<br><small>\[ [link]text</a> \]{If}{[pdf],\\[ <a href="_httpcollection_/index/assoc/[archivedir]/[pdf]">pdf</a> \\]}{If}{[srclink],\\[ [srclink][srcicon][/srclink] \\]}</small></p>'
 
 format SearchVList \
-  '<p>{If}{[parent:Title],[parent:Title] <small><i>(page [Title])</i></small>,[Title]}<br><small>\[ [link]text</a> \]{If}{[pdf],\\[ <a href="_httpcollection_/index/assoc/[parent:archivedir]/[pdf]">page</a> \\]}{If}{[parent:pdf]{\\[ <a href="_httpcollection_/index/assoc/[parent:archivedir]/[parent:pdf]">article</a> \\]}</small></p>'
+  '<p>{If}{[parent:Title],[parent:Title] <small><i>(page [Title])</i></small>,[Title]}<br><small>\[ [link]text</a> \]{If}{[pdf],\\[ <a href="_httpcollection_/index/assoc/[parent:archivedir]/[pdf]">page</a> \\]}{If}{[parent:pdf],\\[ <a href="_httpcollection_/index/assoc/[parent:archivedir]/[parent:pdf]">article</a> \\]}{If}{[srclink],\\[ [srclink][srcicon][/srclink] \\]}</small></p>'
 
 collectionmeta collectionname      "Protemix FDA Submission"
@@ -37,3 +37,3 @@
 
 cgiarg          shortname=a argdefault=q
-cgiarg          shortname=t argdefault=0
+#cgiarg          shortname=t argdefault=0
Index: /trunk/protemix/macros/base.dm
===================================================================
--- /trunk/protemix/macros/base.dm	(revision 3206)
+++ /trunk/protemix/macros/base.dm	(revision 3207)
@@ -271,7 +271,7 @@
 _iconclosedbook_ {<img src="_httpiconbook_" width=_widthbook_ height=_heightbook_ border=0 alt="_texticonclosedbook_">}
 
-_icondoc_ {<img border=0 align=absmiddle src="_httpiconimsword_" width=_widthimsword_ height=_heightimsword_ alt="_texticonmsword_">}
-
-_iconpdf_ {<img border=0 align=absmiddle src="_httpiconipdf_" width=_widthipdf_ height=_heightipdf_ alt="_texticonpdf_">}
+_icondoc_ {doc}
+
+_iconpdf_ {pdf}
 
 #######################################################################
Index: /trunk/protemix/macros/query.dm
===================================================================
--- /trunk/protemix/macros/query.dm	(revision 3206)
+++ /trunk/protemix/macros/query.dm	(revision 3207)
@@ -118,5 +118,5 @@
 <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="SafetySideEffectsToxicity" _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
Index: /trunk/protemix/macros/subdocs.dm
===================================================================
--- /trunk/protemix/macros/subdocs.dm	(revision 3206)
+++ /trunk/protemix/macros/subdocs.dm	(revision 3207)
@@ -9,6 +9,6 @@
 </p>
 
-<p><a href="_httpcollection_/docs/IB/HTML/IB%20HTML.htm">Investigators Brocure</a>
-<br><a href="_httpcollection_/docs/IB/DOC/IB_vs3.9_31May02.doc">Investigators Brocure (Word document)</a></p>
+<p><a href="_httpcollection_/docs/IB/HTML/IB%20HTML.htm">Investigators Brochure</a>
+<br><a href="_httpcollection_/docs/IB/DOC/IB_vs3.9_31May02.doc">Investigators Brochure (Word document)</a></p>
 
 <p><a href="_httpcollection_/docs/Protocol/HTML/Protocol%20HTML.htm">Protocol</a>
Index: /trunk/protemix/perllib/plugins/ProtemixPlug.pm
===================================================================
--- /trunk/protemix/perllib/plugins/ProtemixPlug.pm	(revision 3206)
+++ /trunk/protemix/perllib/plugins/ProtemixPlug.pm	(revision 3207)
@@ -32,4 +32,5 @@
 sub BEGIN {
     @ISA = ('HTMLPlug');
+    unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
 }
 
@@ -68,5 +69,7 @@
 
     # process the meta.xml file and set top level metadata
-    my $parser = new XML::Parser('Style' => 'Stream');
+    my $parser = new XML::Parser('Style' => 'Stream',
+				 'Handlers' => {'Char' => \&Char}
+				 );
     $self->{'section_metadata'} = {};
     $self->{'Page'} = "TopLevel";
@@ -131,11 +134,9 @@
 
 	    # add any section level metadata we have for this page (set from within the meta.xml file)
-
-# currently commented out as we're not using Class1, Class2, and Class3 metadata yet
-#	    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 ++;
@@ -199,4 +200,12 @@
 }
 
+# This Char function overrides the one in XML::Parser::Stream to overcome a
+# problem where $expat->{Text} is treated as the return value, slowing
+# things down significantly in some cases.
+sub Char {
+  $_[0]->{'Text'} .= $_[1];
+  return undef;
+}
+
 
 1;
Index: /trunk/protemix/rename.pl
===================================================================
--- /trunk/protemix/rename.pl	(revision 3206)
+++ /trunk/protemix/rename.pl	(revision 3207)
@@ -11,24 +11,11 @@
 use unicode;
 
-my %classifications = (
-		       'Pharmacokinetics' => ['Absorption', 'Distribution', 'Metabolism', 'Elimination',
-					       'Effect of Food', 'Drug Interactions', 'Special Populations'],
-		       'Pharmacodynamics' => ['Trace Metal', 'Excretion', 'Selectivity', 'Copper', 'Zinc',
-					      'Manganese', 'Iron', 'Distribution', 'Tissue', 'Brain',
-					      'Heart', 'Plasma', 'Fetal', 'Liver', 'Kidney'],
-		       'Safety/Side Effects/Toxicity' => ['Acute Toxicity', 'Repeated Dose Toxicity',
-							 'Studies in Rodents', 'Studies in Dogs',
-							 'Overdosage', 'Reproductive Toxicity',
-							 'Teratogenicity', 'Mutagenecity', 'Carcinogenicity'],
-		       'Other' => ['Superoxide Dismutase', 'Ferroxidase I', 'Ferroxidase II', 
-				   'Metallothienein', 'Ceruloplasmin'],
-		       'Efficacy' => ['Heart', 'Complications', 'Microvascular', 'Renal', 'Diabetes'],
-		       'Contraindications' => [],
-		       'Precautions' => []
-		       );
-
 my @meta_files = ();
 
 &recursive_rename("import");
+
+# read in log.Type.txt and log.Category.txt
+my $classifications = &read_cat_files();
+
 # process meta files
 foreach my $mfile (@meta_files) {
@@ -149,31 +136,27 @@
     $metafile .= "  <Metadata name=\"Title\">$title</Metadata>\n";
 
-    # currently just write some random values for classification metadata
-    my @c1 = ('Animal', 'Human', 'Other');
-    my $rand = int(rand 3);
-    my $classtext = "    <Metadata name=\"Class1\">" . $c1[$rand] . "</Metadata>\n";
-    my @c2 = ('Pharmacokinetics', 'Pharmacodynamics', 'Safety/Side Effects/Toxicity',
-	      'Other', 'Efficacy', 'Contraindications', 'Precautions');
-    $rand = int(rand 7);
-    my $c2val = $c2[$rand];
-    $classtext .= "    <Metadata name=\"Class2\">$c2val</Metadata>\n";
-    if (defined $classifications{$c2val}) {
-	if (scalar(@{$classifications{$c2val}})) {
-	    my $numvals = scalar(@{$classifications{$c2val}});
-	    $rand = int(rand $numvals);
-	    my $c3val = $classifications{$c2val}->[$rand];
-	    $classtext .= "    <Metadata name=\"Class3\">$c3val</Metadata>\n";
-	}
-    } else {
-	print STDERR "ERROR: '$c2val' not in clasifications list\n";
-    }
-
     my $dir = File::Basename::dirname($filename);
+    my ($subdirs) = $dir =~ /import\/(.*)$/;
 
     opendir(DIR, $dir) || die;
     my @files = readdir DIR;
     foreach my $file (@files) {
-	if ($file =~ s/\.html?$//i) {
-	    $metafile .= "  <Page filename=\"$file\">\n$classtext  </Page>\n";
+	if ($file =~ /\.html?$/i) {
+	    my $fstub = $file;
+	    $fstub =~ s/\.html?$//i;
+	    $metafile .= "  <Page filename=\"$fstub\">\n";
+	    if (defined ($classifications->{'type'}->{"$subdirs/$file"})) {
+		$metafile .= "    <Metadata name=\"Class1\">" .
+		    $classifications->{'type'}->{"$subdirs/$file"} . "</Metadata>\n";
+	    } else {
+		print STDERR "$subdirs/$file has no type metadata\n";
+	    }
+	    if (defined ($classifications->{'category'}->{"$subdirs/$file"})) {
+		$metafile .= "    <Metadata name=\"Class2\">" .
+		    $classifications->{'category'}->{"$subdirs/$file"} . "</Metadata>\n";
+	    } else {
+		print STDERR "$subdirs/$file has no category metadata\n";
+	    }
+	    $metafile .= "  </Page>\n";
 	}
     }
@@ -186,3 +169,30 @@
 }
 
+sub read_cat_files {
 
+    my $class = {'type' => {}, 'category' => {}};
+    
+    open (TYPE, "import/log.Type.txt") || die;
+    my $line = "";
+    while (defined ($line = <TYPE>)) {
+	my ($filename, $cat) = split(/ /, $line);
+	chomp $cat;
+	$filename =~ s/^.*?Protemix\(ii\)/OCR2/;
+	$filename =~ s/^.*?Protemix\(i\)/OCR1/;
+	$class->{'type'}->{$filename} = $cat;
+    }
+    close TYPE;
+    
+    open (CAT, "import/log.Category.txt") || die;
+    $line = "";
+    while (defined ($line = <CAT>)) {
+	my ($filename, $cat) = split(/ /, $line);
+	chomp $cat;
+	$filename =~ s/^.*?Protemix\(ii\)/OCR2/;
+	$filename =~ s/^.*?Protemix\(i\)/OCR1/;
+	$class->{'category'}->{$filename} = $cat;
+    }
+    close CAT;
+
+    return $class;
+}
Index: /trunk/protemix/src/recpt/browsetools.cpp
===================================================================
--- /trunk/protemix/src/recpt/browsetools.cpp	(revision 3206)
+++ /trunk/protemix/src/recpt/browsetools.cpp	(revision 3207)
@@ -44,8 +44,14 @@
 
   if (!response.docInfo[0].metadata["pdf"].values[0].empty()) {
-    textout << outconvert << disp
-	    << "_document:imagepagepdf_"
-	    << "_document:imagearticlepdf_";
-  }
+    textout << outconvert << disp << "_document:imagepagepdf_";
+  }
+
+  text_t top;
+  get_top (args["d"], top);
+  if (!get_info (top, args["c"], metadata, false, collectproto, response, logout)) return;
+  if (!response.docInfo[0].metadata["pdf"].values[0].empty()) {
+    textout << outconvert << disp << "_document:imagearticlepdf_";
+  }
+  
   textout << outconvert << disp
 	  << "_document:imagedetach_";
Index: /trunk/protemix/src/recpt/ptmxdocaction.cpp
===================================================================
--- /trunk/protemix/src/recpt/ptmxdocaction.cpp	(revision 3206)
+++ /trunk/protemix/src/recpt/ptmxdocaction.cpp	(revision 3207)
@@ -87,23 +87,4 @@
 
     // ------ for ptmx collection
-
-    if (!args["c1"].empty() && args["c1"] != "Any") {
-      //    formattedstring = "[" + args["c1"] + "]:CL";
-      formattedstring = args["c1"];
-    }
-    if (!args["c2"].empty() && args["c2"] != "Any") {
-      if (!formattedstring.empty()) formattedstring += " & ";
-      //    formattedstring += "[" + args["c2"] + "]:CA";
-      formattedstring += args["c2"];
-    }
-    if (!args["c3"].empty() && args["c3"] != "Any") {
-      if (!formattedstring.empty()) formattedstring += " & ";
-      //    formattedstring += "[" + args["c3"] + "]:CS";
-      formattedstring += args["c3"];
-    }
-    if (!args["q"].empty()) {
-      if (!formattedstring.empty()) formattedstring += " & ";
-      formattedstring += args["q"];
-    }
 
     void insert_equiv_terms(text_t&); // declaration
Index: /trunk/protemix/src/recpt/ptmxqueryaction.cpp
===================================================================
--- /trunk/protemix/src/recpt/ptmxqueryaction.cpp	(revision 3206)
+++ /trunk/protemix/src/recpt/ptmxqueryaction.cpp	(revision 3207)
@@ -110,11 +110,9 @@
 
   if (!args["c1"].empty() && args["c1"] != "Any") {
-    //    formattedstring = "[" + args["c1"] + "]:CL";
-    formattedstring = args["c1"];
+    formattedstring += "[" + args["c1"] + "]:CL";
   }
   if (!args["c2"].empty() && args["c2"] != "Any") {
     if (!formattedstring.empty()) formattedstring += " & ";
-    //    formattedstring += "[" + args["c2"] + "]:CA";
-    formattedstring += args["c2"];
+    formattedstring += "[" + args["c2"] + "]:CA";
   }
   if (!args["c3"].empty() && args["c3"] != "Any") {
@@ -125,10 +123,13 @@
   if (!args["q"].empty()) {
     if (!formattedstring.empty()) formattedstring += " & ";
-    formattedstring += args["q"];
+    // do synonym searching stuff
+    text_t qstring = args["q"];
+    int insert_equiv_terms(text_t&); // forward declaration
+    insert_equiv_terms(qstring);
+    formattedstring += qstring;
   }
 
-  // do synonym searching stuff
-  int insert_equiv_terms(text_t&); // forward declaration
-  insert_equiv_terms(formattedstring);
+  outconvertclass text_t2ascii;
+  logout << text_t2ascii << "formattedstring: " << formattedstring << "\n";
 
   if (!formattedstring.empty()) {
