Changeset 25957

Show
Ignore:
Timestamp:
17.07.2012 15:17:30 (7 years ago)
Author:
kjdon
Message:

adding in support for plugins knowing what version of greenstone (2/3) they are running in. gs_version now passed in when loading plugins, and '-gs_version 2/3' will be added to input args. base plugin class PrintInfo? defines the gs_version arg

Location:
main/trunk/greenstone2
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/pluginfo.pl

    r25499 r25957  
    7777    'type' => "string", 
    7878    'reqd' => "no" }, 
     79      { 'name' => "gs_version", 
     80    'desc' => "{pluginfo.gs_version}", 
     81    'type' => "string", 
     82    'reqd' => "no", 
     83    'hiddengli' => "yes" }, 
    7984      { 'name' => "xml", 
    8085    'desc' => "{scripts.xml}", 
     
    107112    my $site = ""; 
    108113    my $collection = ""; 
     114    my $gs_version = ""; 
    109115    my $xml = 0; 
    110116    my $listall = 0; 
     
    121127    die "\n"; 
    122128    } 
    123      
    124129    foreach my $strVariable (keys %$hashParsingResult) 
    125130    { 
     
    188193    if ($site ne "") { 
    189194    # assume Greenstone 3 
     195    $gs_version = "3" if $gs_version eq ""; 
    190196    if ($collection ne "") { 
    191197        $ENV{'GSDLCOLLECTDIR'} = &util::filename_cat ($ENV{'GSDL3HOME'}, "sites", $site, "collect", $collection); 
     
    196202    } 
    197203    else { 
     204    $gs_version = "2" if $gs_version eq ""; 
    198205    if ($collection ne "") { 
    199206        $ENV{'GSDLCOLLECTDIR'} = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $collection); 
     
    247254    foreach my $plugin (@plugin_list) { 
    248255        $plugin =~ s/\.pm$//; 
    249         my $plugobj = &plugin::load_plugin_for_info ($plugin); 
     256        my $plugobj = &plugin::load_plugin_for_info ($plugin, $gs_version); 
    250257        push (@plugobj_list, $plugobj); 
    251258    } 
     
    267274    } 
    268275    else { 
    269     &print_single_plugin($plugin, $xml, 1); 
     276    &print_single_plugin($plugin, $gs_version, $xml, 1); 
    270277    } 
    271278} 
     
    273280 
    274281sub print_single_plugin { 
    275     my ($plugin, $xml, $header) = @_; 
    276     my $plugobj = &plugin::load_plugin_for_info ($plugin); 
     282    my ($plugin, $gs_version, $xml, $header) = @_; 
     283    my $plugobj = &plugin::load_plugin_for_info ($plugin, $gs_version); 
    277284    if ($xml) { 
    278285    &gsprintf::set_print_xml_tags(); 
  • main/trunk/greenstone2/perllib/inexport.pm

    r24829 r25957  
    173173    } 
    174174 
     175    # set gs_verison 2/3 
     176    $self->{'gs_version'} = "2"; 
     177    if ((defined $site) && ($site ne "")) { 
     178    # gs3 
     179    $self->{'gs_version'} = "3"; 
     180    } 
    175181    # add collection's perllib dir  into include path in  
    176182    # case we have collection specific modules 
     
    364370    my $incremental_mode = $self->{'incremental_mode'}; 
    365371 
     372    my $gs_version = $self->{'gs_version'}; 
     373 
    366374    my $removeold   = $self->{'removeold'}; 
    367375    my $keepold     = $self->{'keepold'}; 
     
    433441    my @global_opts = (); 
    434442 
    435     my $pluginfo = &plugin::load_plugins ($plugins, $verbosity, $out, $faillog, \@global_opts, $plugin_incr_mode); 
     443    my $pluginfo = &plugin::load_plugins ($plugins, $verbosity, $out, $faillog, \@global_opts, $plugin_incr_mode, $gs_version); 
    436444    if (scalar(@$pluginfo) == 0) { 
    437445    &gsprintf($out, "{import.no_plugins_loaded}\n"); 
  • main/trunk/greenstone2/perllib/plugin.pm

    r25803 r25957  
    143143 
    144144sub load_plugin_for_info { 
    145     my ($pluginname) = shift @_; 
     145    my ($pluginname, $gs_version) = (@_); 
    146146    $pluginname = &get_valid_pluginname($pluginname); 
    147147    load_plugin_require($pluginname); 
     
    149149    # create a plugin object 
    150150    my ($plugobj); 
    151     my $options = "-gsdlinfo"; 
     151    my $options = "-gsdlinfo,-gs_version,$gs_version"; 
    152152     
    153153    eval ("\$plugobj = new \$pluginname([],[$options])"); 
     
    159159sub load_plugins { 
    160160    my ($plugin_list) = shift @_; 
    161     my $incremental_mode; 
    162     ($verbosity, $outhandle, $failhandle, $globaloptions, $incremental_mode) = @_; # globals 
     161    my ($incremental_mode, $gs_version); 
     162    ($verbosity, $outhandle, $failhandle, $globaloptions, $incremental_mode, $gs_version) = @_; # globals 
    163163    my @plugin_objects = (); 
    164164    $verbosity = 2 unless defined $verbosity; 
     
    182182    # put quotes around each option to the plugin, unless the option is already quoted 
    183183    map { $_ = "\"$_\"" unless ($_ =~ m/^\s*\".*\"\s*$/) ; } @$pluginoptions; 
    184     my $options = join (",", @$pluginoptions); 
     184    my $options = "-gs_version,$gs_version,".join (",", @$pluginoptions); 
    185185    if ($globals) { 
    186186        if (@$pluginoptions) { 
  • main/trunk/greenstone2/perllib/plugins/PrintInfo.pm

    r24347 r25957  
    4747use printusage; 
    4848 
    49 my $arguments = []; 
     49my $arguments = [ 
     50    { 'name' => "gs_version", 
     51      'desc' => "{PrintInfo.gs_version}", 
     52      'type' => "string", 
     53      'reqd' => "no", 
     54      'hiddengli' => "yes" } 
     55 
     56]; 
    5057 
    5158my $options = { 'name'     => "PrintInfo", 
     
    6269    my $plugin_name = (defined $pluginlist->[0]) ? $pluginlist->[0] : $class; 
    6370 
    64     if ($plugin_name eq $class) { 
     71   if ($plugin_name eq $class) { 
    6572    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments}); 
    6673    push(@{$hashArgOptLists->{"OptList"}},$options); 
    67     } 
     74   } 
    6875    my $self = {}; 
    6976    $self->{'outhandle'} = STDERR; 
    7077    $self->{'option_list'} = $hashArgOptLists->{"OptList"}; 
    7178    $self->{"info_only"} = 0; 
    72  
     79    $self->{'gs_version'} = "2"; 
    7380    # Check if gsdlinfo is in the argument list or not - if it is, don't parse  
    74     # the args, just return the object.   
     81    # the args, just return the object.  
     82    # gsdlinfo must come before gs_version. both are set by plugin.pm 
     83    my $v=0; 
    7584    foreach my $strArg (@{$args}) 
    7685    { 
    77     if($strArg eq "-gsdlinfo") 
     86    if ($v) { 
     87        $self->{'gs_version'} = $strArg; 
     88        last; 
     89    } 
     90    elsif($strArg eq "-gsdlinfo") 
    7891    { 
    7992        $self->{"info_only"} = 1; 
    80         return bless $self, $class; 
    81     } 
    82     } 
    83      
     93        #return bless $self, $class; 
     94    } 
     95    elsif ($strArg eq "-gs_version") { 
     96        $v = 1;      
     97    } 
     98    } 
     99 
     100    if ($self->{"info_only"}) { 
     101    return bless $self, $class; 
     102    } 
    84103    if (defined $auxiliary) { # don't parse the args here 
    85104    return bless $self, $class; 
     105    } 
     106 
     107    # now that we are passed printing out info, we do need to add in this class's options so that they are available for parsing.  
     108    if ($plugin_name ne $class) { 
     109    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments}); 
     110    push(@{$hashArgOptLists->{"OptList"}},$options); 
    86111    } 
    87112