Ignore:
Timestamp:
2000-07-13T10:21:53+12:00 (24 years ago)
Author:
sjboddie
Message:

merged changes to trunk into New_Config_Format branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/New_Config_Format-branch/gsdl/perllib/classify/SectionList.pm

    r838 r1279  
    2727# (excluding top level) rather than just top level document
    2828# itself
    29 # options are:
    30 # metadata=Metaname -- (optional) all documents with Metaname metadata
    31 #                      will be included in list. if not included all documents
    32 #                      will be included in list.
    33 # sort=Meta         -- (optional) sort documents in list alphabetically by
    34 #                      Meta. by default it will sort by Metaname, if neither
    35 #                      are set documents will be in build (random) order.
    36 #                      Meta may be Filename to sort by original filename or
    37 #                      nosort to force not to sort
    38 # title=Title       -- (optional) the title field for this classification.
    39 #                      if not included title field will be Metaname.
    40 #                      if metadata is also not included title will be 'List'
    4129
    4230package SectionList;
    4331
     32use List;
    4433use sorttools;
    4534
    46 sub new {
    47     my ($class, @options) = @_;
    48 
    49     my $list = [];
    50     my ($metaname, $title, $sortname);
    51 
    52     foreach $option (@options) {
    53     if ($option =~ /^metadata=(.*)$/i) {
    54         $metaname = $1;
    55         $list = {};
    56     } elsif ($option =~ /^title=(.*)$/i) {
    57         $title = $1;
    58     } elsif ($option =~ /^sort=(.*)$/i) {
    59         $sortname = $1;
    60     }
    61     }
    62 
    63     if (!defined $title) {
    64     if (defined $metaname) {
    65         $title = $metaname;
    66     } else {
    67         $title = 'List';
    68     }
    69     }
    70 
    71     if (defined $sortname && $sortname =~ /^nosort$/i) {
    72     $sortname = undef;
    73     } elsif (!defined $sortname && defined $metaname) {
    74     $sortname = $metaname;
    75     }
    76 
    77     return bless {
    78     'list'=>$list,
    79     'metaname' => $metaname,
    80     'title' => $title,
    81     'sortname' => $sortname
    82     }, $class;
    83 }
    84 
    85 sub init {
    86     my $self = shift (@_);
    87 
    88     if (defined $self->{'sortname'}) {
    89     $self->{'list'} = {};
    90     } else {
    91     $self->{'list'} = [];
    92     }
     35sub BEGIN {
     36    @ISA = ('List');
    9337}
    9438
    9539sub classify {
    9640    my $self = shift (@_);
    97     my ($doc_obj,@options) = @_;
     41    my ($doc_obj, @options) = @_;
    9842   
    9943    my $thissection = undef;
     
    175119}
    176120
    177 sub get_classify_info {
    178     my $self = shift (@_);
    179 
    180     my @list = ();
    181     if (defined $self->{'sortname'}) {
    182     if (keys %{$self->{'list'}}) {
    183         @list = sort {$self->{'list'}->{$a}
    184               cmp $self->{'list'}->{$b};} keys %{$self->{'list'}};
    185     }
    186     } else {
    187     @list = @{$self->{'list'}};
    188     }
    189 
    190     # organise into classification structure
    191     my %classifyinfo = ('thistype'=>'Invisible',
    192             'childtype'=>'VList',
    193             'Title'=>$self->{'title'},
    194             'contains'=>[]);
    195     foreach $OID (@list) {
    196     push (@{$classifyinfo{'contains'}}, {'OID'=>$OID});
    197     }
    198 
    199     return \%classifyinfo;
    200 }
    201 
    202 
    2031211;
Note: See TracChangeset for help on using the changeset viewer.