source: trunk/gsdl/perllib/plugin.pm@ 418

Last change on this file since 418 was 315, checked in by sjboddie, 25 years ago
  • removed old infodb stuff
  • changed the way classifiers work
  • added maxdocs and allclassifications options
  • no longer get doctype from collect.cfg but instead set it directly in plugins that don't use the default
  • Property svn:keywords set to Author Date Id Revision
File size: 1.3 KB
Line 
1# functions to handle using the plugins
2
3package plugin;
4
5require util;
6
7sub load_plugins {
8 my ($collection, $plugin_list) = @_;
9 my @plugin_objects = ();
10
11 foreach $plugin (@$plugin_list) {
12 # find the plugin
13 my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/plugins",
14 "${plugin}.pm");
15 my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'},"perllib/plugins",
16 "${plugin}.pm");
17 if (-e $colplugname) { require $colplugname; }
18 elsif (-e $mainplugname) { require $mainplugname; }
19 else { die "ERROR - couldn't find plugin $plugin\n"; }
20
21 # create a plugin object
22 my ($plugobj);
23 eval ("\$plugobj = new $plugin()");
24 die "$@" if $@;
25
26 # add this object to the list
27 push (@plugin_objects, $plugobj);
28 }
29
30 return \@plugin_objects;
31}
32
33sub read {
34 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs) = @_;
35
36 my $rv = 0;
37
38 # pass this file by each of the plugins in turn until one
39 # is found which will process it
40 foreach $plugobj (@$pluginfo) {
41 $rv = $plugobj->read($pluginfo, $base_dir, $file,
42 $metadata, $processor, $maxdocs);
43 return $rv if defined $rv;
44 }
45
46 if ($processor->{'verbosity'} >= 2) {
47 print STDERR "WARNING - no plugin could process " .
48 &util::filename_cat($base_dir,$file) . "\n";
49 }
50 return 0;
51}
52
53
541;
Note: See TracBrowser for help on using the repository browser.