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

Last change on this file since 288 was 171, checked in by sjboddie, 25 years ago

changed verbosity level of warning message

  • Property svn:keywords set to Author Date Id Revision
File size: 1.2 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) = @_;
35
36 # pass this file by each of the plugins in turn until one
37 # is found which will process it
38 foreach $plugobj (@$pluginfo) {
39 if ($plugobj->read($pluginfo, $base_dir, $file,
40 $metadata, $processor)) {
41 return;
42 }
43 }
44
45 if ($processor->{'verbosity'} >= 2) {
46 print STDERR "WARNING - no plugin could process " .
47 &util::filename_cat($base_dir,$file) . "\n";
48 }
49}
50
51
521;
Note: See TracBrowser for help on using the repository browser.