|
From: <jas...@us...> - 2003-04-27 00:52:40
|
Update of /cvsroot/genex/genex-server/Mason/workspace/comps
In directory sc8-pr-cvs1:/tmp/cvs-serv15732
Modified Files:
objs2table.mason tableize.mason
Log Message:
now returns a list in array context and prints out HTML in scalar context
Index: objs2table.mason
===================================================================
RCS file: /cvsroot/genex/genex-server/Mason/workspace/comps/objs2table.mason,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** objs2table.mason 22 Apr 2003 01:19:40 -0000 1.1
--- objs2table.mason 27 Apr 2003 00:52:36 -0000 1.2
***************
*** 1,7 ****
- % foreach my $row (@rows) {
- <tr><% $row %></tr>
- % }
<%args>
$objects
</%args>
<%once>
--- 1,7 ----
<%args>
$objects
+ $check=>0
+ $check_header=>''
+ $check_name=>''
</%args>
<%once>
***************
*** 9,12 ****
--- 9,16 ----
</%once>
<%init>;
+ # make sure we get all the info we need for checkboxes
+ die "Must include check_header and check_name"
+ if $check and not ($check_header and $check_name);
+
my @rows;
my $cgi = CGI->new('');
***************
*** 21,24 ****
--- 25,33 ----
push(@rows,$cgi->th(\@column_copy));
+ # include the header if we've been asked to have a checkbox column
+ if ($check) {
+ $rows[0] = "<th>$check_header</th>" . $rows[0];
+ }
+
foreach my $object (@{$objects}) {
my %tmp_values;
***************
*** 33,37 ****
--- 42,57 ----
push(@values, $tmp_values{$name2column{$_}});
}
+
+ # add the checkbox if we've been asked to
+ unshift(@values,
+ qq[<input type="checkbox" name="$check_name" value="$tmp_values{$name2column{'Accession Number'}}"></input>])
+ if $check;
+
push(@rows,$cgi->td([map {!defined $_ ? ' ' : $_} @values]));
+ }
+ if (wantarray) {
+ return @rows;
+ } else {
+ $m->print('<tr>' . join("</tr>\n<tr>",@rows) . '</tr>');
}
</%init>
Index: tableize.mason
===================================================================
RCS file: /cvsroot/genex/genex-server/Mason/workspace/comps/tableize.mason,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tableize.mason 22 Apr 2003 01:19:40 -0000 1.1
--- tableize.mason 27 Apr 2003 00:52:36 -0000 1.2
***************
*** 1,5 ****
- <table>
- <% $result %>
- </table>
<%args>
$rows => 1
--- 1,2 ----
***************
*** 26,37 ****
# rearrange into a pretty table
! my($row,$column);
unshift(@$colheaders,'') if @$colheaders && @$rowheaders;
- $result .= "<tr>" if @{$colheaders};
foreach (@{$colheaders}) {
$result .= "<th>$_</th>";
}
for ($row=0;$row<$rows;$row++) {
! $result .= "<tr>";
$result .= "<th>$rowheaders->[$row]</th>" if @$rowheaders;
for ($column=0;$column<$columns;$column++) {
--- 23,35 ----
# rearrange into a pretty table
! my(@rows,$row,$column);
unshift(@$colheaders,'') if @$colheaders && @$rowheaders;
foreach (@{$colheaders}) {
$result .= "<th>$_</th>";
}
+ push(@rows,$result) if @{$colheaders};
+
for ($row=0;$row<$rows;$row++) {
! $result = '';
$result .= "<th>$rowheaders->[$row]</th>" if @$rowheaders;
for ($column=0;$column<$columns;$column++) {
***************
*** 39,44 ****
if defined($elements[$column*$rows + $row]);
}
! $result .= "</tr>";
}
</%init>
--- 37,48 ----
if defined($elements[$column*$rows + $row]);
}
! push(@rows,$result);
}
+
+ if (wantarray) {
+ return @rows;
+ } else {
+ $m->print('<table><tr>' . join("</tr>\n<tr>",@rows) . '</tr></table>');
+ }
</%init>
|