Index: /trunk/gsdl/perllib/basebuilder.pm
===================================================================
--- /trunk/gsdl/perllib/basebuilder.pm	(revision 14111)
+++ /trunk/gsdl/perllib/basebuilder.pm	(revision 14112)
@@ -26,4 +26,7 @@
 package basebuilder;
 
+use strict;
+no strict 'refs'; # allow filehandles to be variables and viceversa
+
 use classify;
 use cfgread;
@@ -56,7 +59,7 @@
 	$outhandle, $no_text, $failhandle, $gli) = @_;
 
-    $outhandle = STDERR unless defined $outhandle;
+    $outhandle = *STDERR unless defined $outhandle;
     $no_text = 0 unless defined $no_text;
-    $failhandle = STDERR unless defined $failhandle;
+    $failhandle = *STDERR unless defined $failhandle;
 
     # create a builder object
@@ -80,19 +83,11 @@
     $self->{'gli'} = 0 unless defined $self->{'gli'};
 
-    # read in the collection configuration file
-    my $colcfgname = "$ENV{'GSDLCOLLECTDIR'}/etc/collect.cfg";
-    if (-e $colcfgname) {
-      $self->{'collect_cfg'} = &colcfg::read_collect_cfg ($colcfgname);
-      $gs_mode = "gs2";
-    }
-    else {
-      my $colcfgname = "$ENV{'GSDLCOLLECTDIR'}/etc/collectionConfig.xml";
-      if (!-e $colcfgname) {
-	die "mgbuilder::new - couldn't find collect.cfg for collection $collection\n";
-      }
-      else {
+    # Read in the collection configuration file.
+    my ($colcfgname);
+    ($colcfgname, $gs_mode) = &colcfg::get_collect_cfg_name($outhandle);
+    if ($gs_mode eq "gs2") {
+        $self->{'collect_cfg'} = &colcfg::read_collect_cfg ($colcfgname);
+    } elsif ($gs_mode eq "gs3") {
 	$self->{'collect_cfg'} = &colcfg::read_collection_cfg_xml ($colcfgname);
-	$gs_mode = "gs3";
-      }
     }
     
@@ -192,5 +187,11 @@
     my ($buildprocdir, $buildproctype);
     my $collection = $self->{'collection'};
-    if (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}buildproc.pm") {
+    if (-e "$ENV{'GSDLCOLLECTDIR'}/custom/${collection}/perllib/custombuildproc.pm") {
+	$buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/custom/${collection}/perllib";
+	$buildproctype = "custombuildproc";
+    } elsif (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/custombuildproc.pm") {
+	$buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
+	$buildproctype = "custombuildproc";
+    } elsif (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}buildproc.pm") {
 	$buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
 	$buildproctype = "${collection}buildproc";
@@ -338,5 +339,5 @@
     my ($handle);
     if ($self->{'debug'}) {
-	$handle = STDOUT;
+	$handle = *STDOUT;
     } else {
 	if (!-e "$txt2db_exe" || !open (PIPEOUT, "| txt2db$exe \"$fulldbname\"")) {
@@ -344,5 +345,5 @@
 	    die "builder::make_infodatabase - couldn't run $txt2db_exe\n";
 	}
-	$handle = basebuilder::PIPEOUT;
+	$handle = *PIPEOUT;
     }
     
Index: /trunk/gsdl/perllib/classify.pm
===================================================================
--- /trunk/gsdl/perllib/classify.pm	(revision 14111)
+++ /trunk/gsdl/perllib/classify.pm	(revision 14112)
@@ -49,12 +49,11 @@
 
     # find the classifier
-    my $colclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},
-					   "perllib/classify", 
-					   "${classifier}.pm");
-    my $mainclassname = &util::filename_cat($ENV{'GSDLHOME'},
-					    "perllib/classify", 
-					    "${classifier}.pm");
-
-    if (-e $colclassname) { require $colclassname; }
+    my $customclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'},
+                                              "perllib", "classify", "${classifier}.pm");
+    my $colclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "perllib", "classify", "${classifier}.pm");
+    my $mainclassname = &util::filename_cat($ENV{'GSDLHOME'}, "perllib", "classify", "${classifier}.pm");
+
+    if (-e $customclassname) { require $customclassname; }
+    elsif (-e $colclassname) { require $colclassname; }
     elsif (-e $mainclassname) { require $mainclassname; }
     else { 
@@ -84,14 +83,15 @@
 
 	# find the classifier
-	my $colclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/classify", 
-					       "${classname}.pm");
-	my $mainclassname = &util::filename_cat($ENV{'GSDLHOME'},"perllib/classify", 
-						"${classname}.pm");
-
-	if (-e $colclassname) { require $colclassname; }
+        my $customclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'},
+                                                  "perllib", "classify", "${classname}.pm");
+        my $colclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "perllib", "classify", "${classname}.pm");
+        my $mainclassname = &util::filename_cat($ENV{'GSDLHOME'}, "perllib", "classify", "${classname}.pm");
+
+	if (-e $customclassname) { require $customclassname; }
+	elsif (-e $colclassname) { require $colclassname; }
 	elsif (-e $mainclassname) { require $mainclassname; }
 	else { &gsprintf(STDERR, "{classify.could_not_find_classifier}\n", $classname) && die "\n";
 	       # die "ERROR - couldn't find classifier \"$classname\"\n";
-	   }
+        }
 
 	# create the classify object
Index: /trunk/gsdl/perllib/colcfg.pm
===================================================================
--- /trunk/gsdl/perllib/colcfg.pm	(revision 14111)
+++ /trunk/gsdl/perllib/colcfg.pm	(revision 14112)
@@ -30,4 +30,5 @@
 use cfgread;
 use cfgread4gs3;
+use gsprintf 'gsprintf';
 use strict;
 
@@ -160,4 +161,33 @@
 }
 
+sub get_collect_cfg_name {
+    my ($out) = @_;
+
+    # First check if there's a
+    # gsdl/collect/COLLECTION/custom/COLLECTION/etc/collect.cfg file. This
+    # customization was added for DLC by Stefan, 30/6/2007.
+    my $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'}, "etc", "collect.cfg");
+
+    if (-e $configfilename) {
+        return ($configfilename, "gs2");
+    }
+
+    # Now check if there is a collect.cfg file in the usual place, i.e. it is gs2.
+    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
+    if (-e $configfilename) {
+        return ($configfilename, "gs2");
+    }
+
+    # If we get to here we check if there is a collectionConfig.xml file,
+    # i.e. it is gs3.
+    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");    
+    if (-e $configfilename) {
+        return ($configfilename, "gs3");
+    }
+
+    # Error. No collection configuration file.
+    (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
+}
+
 1;
 
Index: /trunk/gsdl/perllib/plugin.pm
===================================================================
--- /trunk/gsdl/perllib/plugin.pm	(revision 14111)
+++ /trunk/gsdl/perllib/plugin.pm	(revision 14112)
@@ -48,9 +48,12 @@
 
     # find the plugin
-    my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/plugins", 
+    my $customplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'}, 
+                                             'perllib', 'plugins', "${pluginname}.pm");
+    my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, 'perllib', 'plugins', 
 					  "${pluginname}.pm");
-    my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'},"perllib/plugins", 
+    my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'}, 'perllib', 'plugins', 
 					   "${pluginname}.pm");
-    if (-e $colplugname) { require $colplugname; }
+    if (-e $customplugname) { require $customplugname; }
+    elsif (-e $colplugname) { require $colplugname; }
     elsif (-e $mainplugname) { require $mainplugname; }
     else {
@@ -91,9 +94,12 @@
 
 	# find the plugin
-	my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/plugins", 
+        my $customplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'}, 
+                                                 'perllib', 'plugins', "${pluginname}.pm");
+	my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, 'perllib', 'plugins', 
 					      "${pluginname}.pm");
-	my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'},"perllib/plugins", 
+	my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'}, 'perllib', 'plugins',
 					       "${pluginname}.pm");
-	if (-e $colplugname) { require $colplugname; }
+        if (-e $customplugname) { require $customplugname; }
+	elsif (-e $colplugname) { require $colplugname; }
 	elsif (-e $mainplugname) { require $mainplugname; }
 	else {
