Ignore:
Timestamp:
2006-12-05T16:23:41+13:00 (15 years ago)
Author:
kjdon
Message:

added format_metadata_as_table method, which takes a metadata hash and returns soem text containing an HTML table of metadata names and values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/metadatautil.pm

    r13187 r13418  
    8484}
    8585
     86sub format_metadata_as_table {
     87    my ($metadata, $remove_namespace) = @_;
     88   
     89    my $text = "<table cellpadding=\"4\" cellspacing=\"0\">\n";
     90   
     91    foreach my $field (keys(%$metadata)) {
     92    # $metadata->{$field} may be an array reference
     93    if ($field eq "gsdlassocfile_tobe") {
     94        # ignore
     95    } else {
     96        my $no_ns = $field;
     97        if ($remove_namespace) {
     98        $no_ns =~ s/^\w+\.//;
     99        }
     100        if (ref ($metadata->{$field}) eq "ARRAY") {
     101        map {
     102            $text .= "<tr><td valign=top><nobr><b>$no_ns</b></nobr></td><td>".$_."</td></tr>";
     103        } @{$metadata->{$field}};
     104        } else {
     105        $text .= "<tr><td valign=top><nobr><b>$no_ns</b></nobr></td><td valign=top>$metadata->{$field}</td></tr>\n";
     106        }
     107    }
     108
     109    }
     110    $text .= "</table>\n";
     111    return $text;
     112}
     113
    861141;
Note: See TracChangeset for help on using the changeset viewer.