[Bio] / Sprout / CustomAttributes.pm Repository:
ViewVC logotype

Diff of /Sprout/CustomAttributes.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25, Sun May 6 10:16:52 2007 UTC revision 1.26, Mon Jun 11 18:44:40 2007 UTC
# Line 1835  Line 1835 
1835      if ($idValue =~ /^([A-Za-z]+):(.+)/) {      if ($idValue =~ /^([A-Za-z]+):(.+)/) {
1836          # Here we have a typed ID.          # Here we have a typed ID.
1837          ($type, $id) = ($1, $2);          ($type, $id) = ($1, $2);
1838            # Fix the case sensitivity on PDB IDs.
1839            if ($type eq 'PDB') { $id = lc $id; }
1840      } elsif ($idValue =~ /fig\|/) {      } elsif ($idValue =~ /fig\|/) {
1841          # Here we have a feature ID.          # Here we have a feature ID.
1842          ($type, $id) = (Feature => $idValue);          ($type, $id) = (Feature => $idValue);
# Line 2009  Line 2011 
2011      return $retVal;      return $retVal;
2012  }  }
2013    
2014    
2015    =head3 AttributeTable
2016    
2017    C<< my $tableHtml = CustomAttributes::AttributeTable($cgi, @attrList); >>
2018    
2019    Format the attribute data into an HTML table.
2020    
2021    =over 4
2022    
2023    =item cgi
2024    
2025    CGI query object used to generate the HTML
2026    
2027    =item attrList
2028    
2029    List of attribute results, in the format returned by the L</GetAttributes> or
2030    L</QueryAttributes> methods.
2031    
2032    =item RETURN
2033    
2034    Returns an HTML table displaying the attribute keys and values.
2035    
2036    =back
2037    
2038    =cut
2039    
2040    sub AttributeTable {
2041        # Get the parameters.
2042        my ($cgi, @attrList) = @_;
2043        # Accumulate the table rows.
2044        my @html = ();
2045        for my $attrData (@attrList) {
2046            # Format the object ID and key.
2047            my @columns = map { CGI::escapeHTML($_) } @{$attrData}[0,1];
2048            # Now we format the values. These remain unchanged unless one of them is a URL.
2049            my $lastValue = scalar(@{$attrData}) - 1;
2050            push @columns, map { $_ =~ /^http:/ ? $cgi->a({ href => $_ }, $_) : $_ } @{$attrData}[2 .. $lastValue];
2051            # Assemble the values into a table row.
2052            push @html, $cgi->Tr($cgi->td(\@columns));
2053        }
2054        # Format the table in the return variable.
2055        my $retVal = $cgi->table({ border => 2 }, $cgi->Tr($cgi->th(['Object', 'Key', 'Values'])), @html);
2056        # Return it.
2057        return $retVal;
2058    }
2059  1;  1;

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3