Ignore:
Timestamp:
2005-07-06T15:27:45+12:00 (19 years ago)
Author:
kjdon
Message:

Jeffrey's new parsing modifications, committed approx 6 July, 15.16

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify/AZCompactList.pm

    r10113 r10218  
    6262    'desc' => "{AZCompactList.sort}",
    6363    'type' => "string",
    64     'deft' => "Title",
     64#   'deft' => "Title",
    6565    'reqd' => "no" },
    6666      { 'name' => "removeprefix",
     
    121121
    122122sub new {
    123     my $class = shift (@_);
    124     my $self = new BasClas($class, @_);
    125 
    126     # 14-05-02 To allow for proper inheritance of arguments - John Thompson
    127     my $option_list = $self->{'option_list'};
    128     push( @{$option_list}, $options );
    129 
    130     if ($self->{'info_only'}) {
    131     # created from classinfo.pl - don't need to parse the arguments
    132     return bless $self, $class;
    133     }
    134 
    135     my ($metaname, $title, $removeprefix, $removesuffix);
    136     my $sortname = "Title";
    137     my $mingroup = 2;
    138     my $minnesting = 20;
    139     my $mincompact = 10;
    140     my $maxcompact = 30;
    141     my $doclevel = "top";
    142     my $firstvalueonly = 0;
    143     my $allvalues = 0;
    144     my $freqsort = 0;
    145     my $recopt   = undef;
    146 
    147     if (!parsargv::parse(\@_,
    148              q^metadata/.*/^, \$metaname,
    149              q^buttonname/.*/^, \$title,
    150              q^sort/.*/^, \$sortname,
    151              q^removeprefix/.*/^, \$removeprefix,
    152              q^removesuffix/.*/^, \$removesuffix,
    153              q^mingroup/.*/2^, \$mingroup,
    154              q^minnesting/.*/20^, \$minnesting,
    155              q^mincompact/.*/10^, \$mincompact,
    156              q^maxcompact/.*/30^, \$maxcompact,
    157              q^doclevel/.*/top^, \$doclevel,
    158              q^firstvalueonly^, \$firstvalueonly,
    159              q^allvalues^, \$allvalues,
    160              q^freqsort/.*/0^, \$freqsort,
    161              q^recopt/.*/-1^, \$recopt,  # Used in nested metadata such as -metadata Year/Organisation
    162 
    163              "allow_extra_options")) {
    164    
    165     print STDERR "\nIncorrect options passed to $class, check your collect.cfg file\n";
    166     $self->print_txt_usage("");  # Use default resource bundle
    167     die "\n";
    168     }
    169 
    170     if (!defined($metaname)) {
     123    my ($class) = shift (@_);
     124    my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
     125    push(@$pluginlist, $class);
     126
     127    if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
     128    if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
     129
     130    my $self = (defined $hashArgOptLists)? new BasClas($pluginlist,$inputargs,$hashArgOptLists): new BasClas($pluginlist,$inputargs);
     131
     132    if (!$self->{"metadata"}) {
    171133    my $outhandle = $self->{'outhandle'};
    172134    print $outhandle "AZCompactList Error: required option -metadata not supplied\n";
     
    175137    }
    176138
    177     $title = $self->generate_title_from_metadata($metaname) unless ($title);
    178     #$title = $metaname unless ($title);
    179 
     139    # Manually set $self parameters.
    180140    $self->{'list'} = {};
    181141    $self->{'listmetavalue'} = {};
     
    183143    $self->{'reclassify'} = {};
    184144    $self->{'reclassifylist'} = {};
    185     $self->{'metaname'} = $metaname;
    186     $self->{'title'} = "$title";     # title for the titlebar.
    187     $self->{'sortname'} = $sortname;
    188 
    189     if (defined($removeprefix) && $removeprefix) {
    190     $removeprefix =~ s/^\^//; # don't need a leading ^
    191     $self->{'removeprefix'} = $removeprefix;
    192     }
    193     if (defined($removesuffix) && $removesuffix) {
    194     $removesuffix =~ s/\$$//; # don't need a trailing $
    195     $self->{'removesuffix'} = $removesuffix;
    196     }
    197     $self->{'mingroup'} = $mingroup;
    198     $self->{'minnesting'} = $minnesting;
    199     $self->{'mincompact'} = $mincompact;
    200     $self->{'maxcompact'} = $maxcompact;
    201     $self->{'doclevel'} = $doclevel;
    202 
    203     if ($firstvalueonly != 0) {
    204     $firstvalueonly = 1;
    205     }
    206     $self->{'firstvalueonly'} = $firstvalueonly;
    207  
    208     if ($allvalues != 0) {
    209     $allvalues = 1;
    210     }
    211     $self->{'allvalues'} = $allvalues;
    212     if ($freqsort != 0) {
    213     $freqsort = 1;
    214     }
    215     $self->{'freqsort'} = $freqsort;
    216 
    217     if ($recopt == -1) {
    218     $recopt = undef;
    219     } else {
    220     $recopt = "on";
    221     }
    222     $self->{'recopt'} = $recopt;
     145
     146    $self->{'buttonname'} = $self->generate_title_from_metadata($self->{'metadata'}) unless ($self->{'buttonname'});
     147   
     148    if (defined($self->{"removeprefix"}) && $self->{"removeprefix"}) {
     149    $self->{"removeprefix"} =~ s/^\^//; # don't need a leading ^
     150    }
     151    if (defined($self->{"removesuffix"}) && $self->{"removesuffix"}) {
     152    $self->{"removesuffix"} =~ s/\$$//; # don't need a trailing $
     153    }
     154   
     155    $self->{'recopt'} = ($self->{'recopt'} == 0) ? undef : "on";
     156
     157    # Clean out the unused keys
     158    if($self->{"removeprefix"} eq "") {delete $self->{"removeprefix"};}
     159    if($self->{"removesuffix"} eq "") {delete $self->{"removesuffix"};}
    223160
    224161    return bless $self, $class;
     
    247184    my @sectionlist = ();
    248185    my $topsection = $doc_obj->get_top_section();
    249     my $metaname = $self->{'metaname'};
     186    my $metaname = $self->{'metadata'};
    250187    my $outhandle = $self->{'outhandle'};
    251188
     
    317254
    318255        my $formatted_metavalue =
    319           sorttools::format_metadata_for_sorting($self->{'metaname'},
     256          sorttools::format_metadata_for_sorting($self->{'metadata'},
    320257                             $metavalue, $doc_obj);
    321258       
     
    338275
    339276    # This is used in reclassify below for AZCompactSectionList
    340     my $sortmeta = $doc_obj->get_metadata_element($thissection, $self->{'sortname'});
     277    my $sortmeta = $doc_obj->get_metadata_element($thissection, $self->{'sort'});
    341278    $self->{'reclassify'}->{$full_doc_OID} = [$doc_obj,$sortmeta];
    342279    }
     
    413350    my $doclevel = $self->{'doclevel'};
    414351    my $mingroup = $self->{'mingroup'};
    415     my @metaname_list = split(/\/|\|/,$self->{'metaname'});
     352    my @metaname_list = split(/\/|\|/,$self->{'metadata'});
    416353    my $metaname = shift(@metaname_list);
    417354    my $hierarchical = 0;
     
    433370        # buttonname is also used for the node's title
    434371        push @args, ("-buttonname", "$metavalue");
    435         push @args, ("-sort", $self->{'sortname'});
    436 
     372        push @args, ("-sort", $self->{'sort'});
     373
     374        my $ptArgs = \@args;
    437375        if ($doclevel =~ m/^top(level)?/i)
    438376        {
    439             eval ("\$listclassobj = new List(\@args)");
    440             warn $@ if $@;
     377            eval ("\$listclassobj = new List([],\$ptArgs)");
    441378        }
    442379        else
    443380        {
    444             eval ("\$listclassobj = new SectionList(\@args)");
    445             warn $@ if $@;
     381            eval ("\$listclassobj = new SectionList([],\$ptArgs)");
    446382        }
    447383        }
     
    453389        # buttonname is also used for the node's title
    454390        push @args, ("-buttonname", "$metavalue");
    455         push @args, ("-sort", $self->{'sortname'});
     391        push @args, ("-sort", $self->{'sort'});
    456392
    457393        if (defined $self->{'removeprefix'}) {
     
    466402        push @args, "-recopt ";
    467403
    468         eval ("\$listclassobj = new AZCompactList(\@args)");
    469         warn $@ if $@;
    470         }
     404        my $ptArgs = \@args;
     405        eval ("\$listclassobj = new AZCompactList([],\$ptArgs)");
     406        }
     407       
    471408        if ($@) {
    472409        print $outhandle "$@";
     
    493430        }
    494431
    495         $formatted_node = &sorttools::format_metadata_for_sorting($self->{'metaname'}, $formatted_node);
     432        $formatted_node = &sorttools::format_metadata_for_sorting($self->{'metadata'}, $formatted_node);
    496433
    497434        # In case our formatted string is empty...
     
    671608    my $self = shift (@_);
    672609    my ($title, $childtype, $metaname, $thistype) = @_;
    673 
    674610    # organise into classification structure
    675611    my %classifyinfo = ('childtype'=>$childtype,
     
    694630
    695631    # top level
    696     my @metanames = split(/\/|\|/,$self->{'metaname'});
     632    my @metanames = split(/\/|\|/,$self->{'metadata'});
    697633    my $metaname = shift(@metanames);
    698634
     
    700636    $childtype = "VList" if (scalar (@$classlistref) <= $self->{'minnesting'});
    701637
     638    my $title = $self->{'buttonname'}; # should always be defined by now.
    702639    my $classifyinfo;
    703640    if (!defined($self->{'recopt'}))
    704641    {
    705     my $title = $self->{'title'}; # should always be defined by now....
    706     $title = $metaname unless defined $title;
    707642    $classifyinfo
    708643        = $self->get_entry ($title, $childtype, $metaname, "Invisible");
     
    710645    else
    711646    {
    712     my $title = $self->{'title'};
    713647    $classifyinfo
    714648        = $self->get_entry ($title, $childtype, $metaname, "VList");
Note: See TracChangeset for help on using the changeset viewer.