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

Diff of /Sprout/ResultHelper.pm

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

revision 1.2, Wed Jul 25 16:20:20 2007 UTC revision 1.3, Mon Aug 20 23:16:59 2007 UTC
# Line 396  Line 396 
396              # will contain the name of each column, its value, and its download format.              # will contain the name of each column, its value, and its download format.
397              my @actualCols = ();              my @actualCols = ();
398              for (my $i = 0; $i <= $#keepCols; $i++) {              for (my $i = 0; $i <= $#keepCols; $i++) {
399                    Trace("Keep flag for $i is $keepCols[$i].") if T(4);
400                  if ($keepCols[$i]) {                  if ($keepCols[$i]) {
401                      push @actualCols, [$colHdrs->[$i], $self->GetRunTimeValues($cols->[$i]), $keepCols[$i]];                      push @actualCols, [$colHdrs->[$i], $self->GetRunTimeValues($cols->[$i]), $keepCols[$i]];
402                  }                  }
403              }              }
404                Trace(scalar(@actualCols) . " columns kept.") if T(4);
405              # Now it's time to do the actual writing, so we need to know if this              # Now it's time to do the actual writing, so we need to know if this
406              # is XML or tab-delimited.              # is XML or tab-delimited.
407              if ($dlType eq 'tbl') {              if ($dlType eq 'tbl') {
# Line 407  Line 409 
409                  my @actual = map { HtmlCleanup($_->[1], $_->[2]) } @actualCols;                  my @actual = map { HtmlCleanup($_->[1], $_->[2]) } @actualCols;
410                  # Return the line of data.                  # Return the line of data.
411                  push @retVal, join("\t", @actual);                  push @retVal, join("\t", @actual);
412                    Trace("Output line is\n" . join("\n", @actual)) if T(4);
413              } elsif ($dlType eq 'xml') {              } elsif ($dlType eq 'xml') {
414                  # Convert to XML. Since a single XML tag can contain multiple lines, we re-split them.                  # Convert to XML.
415                  # This is important, because when the lines are output we need to insure the correct                  my @actual = ();
416                  # EOL character is used.                  for my $actualCol (@actualCols) {
417                  my @actual = map { split /\n/, "<$_->[0]>" . XmlCleanup($_->[1], $_->[2]) . "</$_->[0]>" } @actualCols;                      # First we need the column name. This is the column header for an ordinary column,
418                        # and the title for an extra column.
419                        my $colName;
420                        if (ref $actualCol->[0]) {
421                            # Here we have an extra column.
422                            $colName = $actualCol->[0]->{title};
423                            # Remove internal spaces to make it name-like.
424                            $colName =~ s/\s+//g;
425                        } else {
426                            # For a normal column, the value is the name.
427                            $colName = $actualCol->[0];
428                        }
429                        # Create the tag for this column.  Since a single XML tag can contain multiple
430                        # lines, we re-split them. This is important, because when the lines are output
431                        # we need to insure the correct EOL character is used.
432                        push @actual, split /\n/, "<$colName>" . XmlCleanup($actualCol->[1], $actualCol->[2]) . "</$colName>";
433                    }
434                  # Return the XML object.                  # Return the XML object.
435                  push @retVal, XML_INDENT x 1 . "<Item id=\"$objectID\">";                  push @retVal, XML_INDENT x 1 . "<Item id=\"$objectID\">";
436                  push @retVal, map { XML_INDENT x 2 . $_ } @actual;                  push @retVal, map { XML_INDENT x 2 . $_ } @actual;
# Line 523  Line 542 
542          $retVal = ButtonToLink($htmlText);          $retVal = ButtonToLink($htmlText);
543      } elsif ($type eq 'align') {      } elsif ($type eq 'align') {
544          # Here we have multiple lines. Convert the new-lines to serial commas.          # Here we have multiple lines. Convert the new-lines to serial commas.
545            $retVal = $htmlText;
546          $retVal =~ s/<br\s*\/?>/, /g;          $retVal =~ s/<br\s*\/?>/, /g;
547      } else {      } else {
548          # Here we have normal HTML. Start by taking the raw text.          # Here we have normal HTML. Start by taking the raw text.
# Line 530  Line 550 
550          # Delete any tags. This is a very simplistic algorithm that will fail if there          # Delete any tags. This is a very simplistic algorithm that will fail if there
551          # is a right angle bracket inside a parameter string.          # is a right angle bracket inside a parameter string.
552          $retVal =~ s/<[^>]+>//g;          $retVal =~ s/<[^>]+>//g;
553            # Convert &nbsp; marks to real spaces.
554            $retVal =~ s/&nbsp;/ /g;
555          # Unescape the & tags.          # Unescape the & tags.
556          $retVal = CGI::unescapeHTML($retVal);          $retVal = CGI::unescapeHTML($retVal);
557      }      }
# Line 577  Line 599 
599      } elsif ($type eq 'align') {      } elsif ($type eq 'align') {
600          # Here we have aligned text. This is converted into an XML array of lines.          # Here we have aligned text. This is converted into an XML array of lines.
601          # First, we find the break tags.          # First, we find the break tags.
602            Trace("Alignment cleanup of: $htmlText") if T(4);
603          my @lines = split /<br[^>]+>/, $htmlText;          my @lines = split /<br[^>]+>/, $htmlText;
604            Trace(scalar(@lines) . " lines found.") if T(4);
605          # Format the lines as an XML array. The extra new-line causes the first array          # Format the lines as an XML array. The extra new-line causes the first array
606          # element to be on a separate line from the first item tag.          # element to be on a separate line from the first item tag.
607          $retVal = "\n" . map { XML_INDENT . "<line>$_</line>\n" } @lines;          $retVal = "\n" . join("", map { XML_INDENT . "<line>$_</line>\n" } @lines);
608      } elsif ($type eq 'list') {      } elsif ($type eq 'list') {
609          # Here we have a comma-delimited list of possibly-linked strings. We will convert it to          # Here we have a comma-delimited list of possibly-linked strings. We will convert it to
610          # an XML array. First, we get the pieces.          # an XML array. First, we get the pieces.
# Line 924  Line 948 
948          # removed and the parameter attached to the incoming run-time key.          # removed and the parameter attached to the incoming run-time key.
949          if ($colName =~ /(\S+):(.+)/) {          if ($colName =~ /(\S+):(.+)/) {
950              $colName = $1;              $colName = $1;
951              $realRunTimeKey = $2;              $realRunTimeKey = ", '$2'";
952          }          }
953          # Get the result helper type.          # Get the result helper type.
954          my $rhType = $self->{type};          my $rhType = $self->{type};

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3