[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 27 Aug 2008 13:07:41 -0000
raeburn Wed Aug 27 09:07:41 2008 EDT
Modified files:
/loncom/publisher lonpublisher.pm
Log:
- Improved data-tabling for keywords table.
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.246 loncom/publisher/lonpublisher.pm:1.247
--- loncom/publisher/lonpublisher.pm:1.246 Tue Aug 19 06:43:59 2008
+++ loncom/publisher/lonpublisher.pm Wed Aug 27 09:07:41 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.246 2008/08/19 10:43:59 bisitz Exp $
+# $Id: lonpublisher.pm,v 1.247 2008/08/27 13:07:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1260,36 +1260,42 @@
.'<input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.pubform.keywords)" />'
.'<input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.pubform.keywords)" />'
.'</p><br />'
- .&Apache::loncommon::start_data_table()
- .&Apache::loncommon::start_data_table_row();
-
+ .&Apache::loncommon::start_data_table();
+ my $cols_per_row = 10;
my $colcount=0;
+ my $wordcount=0;
+ my $numkeywords = scalar(keys(%keywords));
- foreach (sort keys %keywords) {
- $colcount++;
- $keywordout.='<td><label><input type="checkbox" name="keywords" value="'.$_.'"';
- if ($metadatafields{'keywords'}) {
- if ($metadatafields{'keywords'}=~/\Q$_\E/) {
- $keywordout.=' checked="on"';
- $env{'form.keywords'}.=$_.',';
- }
- } elsif (&Apache::loncommon::keyword($_)) {
- $keywordout.=' checked="on"';
- $env{'form.keywords'}.=$_.',';
- }
- $keywordout.=' />'.$_.'</label></td>';
- if ($colcount>=10) {
- $keywordout.=&Apache::loncommon::end_data_table_row()
- .&Apache::loncommon::start_data_table_row();
- $colcount=0;
- }
- }
- # Proper end of started table row:
- if ($colcount != 0) { # has still to be improved: if amount of keywords mod 10 == 0, then do not start another table row
- while ($colcount<10) {
- $keywordout.='<td> </td>';
- $colcount++;
+ foreach my $word (sort(keys(%keywords))) {
+ if ($colcount == 0) {
+ $keywordout .= &Apache::loncommon::start_data_table_row();
+ }
+ $colcount++;
+ $wordcount++;
+ if (($wordcount == $numkeywords) && ($colcount < $cols_per_row)) {
+ my $colspan = 1+$cols_per_row-$colcount;
+ $keywordout .= '<td colspan="'.$colspan.'">';
+ } else {
+ $keywordout .= '<td>';
}
+ $keywordout.='<label><input type="checkbox" name="keywords" value="'.$word.'"';
+ if ($metadatafields{'keywords'}) {
+ if ($metadatafields{'keywords'}=~/\Q$word\E/) {
+ $keywordout.=' checked="on"';
+ $env{'form.keywords'}.=$word.',';
+ }
+ } elsif (&Apache::loncommon::keyword($word)) {
+ $keywordout.=' checked="on"';
+ $env{'form.keywords'}.=$word.',';
+ }
+ $keywordout.=' />'.$word.'</label></td>';
+ if ($colcount == $cols_per_row) {
+ $keywordout.=&Apache::loncommon::end_data_table_row();
+ $colcount=0;
+ }
+ }
+ if ($colcount > 0) {
+ $keywordout .= &Apache::loncommon::end_data_table_row();
}
$env{'form.keywords'}=~s/\,$//;