--- loncom/interface/lonhtmlcommon.pm 2005/08/05 18:14:40 1.111 +++ loncom/interface/lonhtmlcommon.pm 2005/10/04 19:59:15 1.112 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.111 2005/08/05 18:14:40 www Exp $ +# $Id: lonhtmlcommon.pm,v 1.112 2005/10/04 19:59:15 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1217,6 +1217,264 @@ returns: nothing ############################################################ ############################################################ +# Nested table routines. +# +# Routines to display form items in a multi-row table with 2 columns. +# Uses nested tables to divide form elements into segments. +# For examples of use see loncom/interface/lonnotify.pm +# +# Can be used in following order: ... +# &start_pick_box() +# row1 +# row2 +# row3 ... etc. +# &submit_row(0 +# &end_pickbox() +# +# where row1, row 2 etc. are chosen from &role_select_row,&course_select_row, +# &status_select_row and &email_default_row +# +# Can also be used in following order: +# +# &start_pick_box() +# &row_title() +# &row_closure() +# &row_title() +# &row_closure() ... etc. +# &submit_row() +# &end_pick_box() +# +# In general a &submit_row() call should proceed the call to &end_pick_box(), +# as this routine adds a button for form submission. +# &submit_row(0 does not require a &row_closure after it. +# +# &start_pick_box() creates a bounding table with 1-pixel wide black border. +# rows should be placed between calls to &start_pick_box() and &end_pick_box. +# +# &row_title() adds a title in the left column for each segment. +# &row_closure() closes a row with a 1-pixel wide black line. +# +# &role_select_row() provides a select box from which to choose 1 or more roles +# &course_select_row provides ways of picking groups of courses +# radio buttons: all, by category or by picking from a course picker pop-up +# note: by category option is only displayed if a domain has implemented +# selection by year, semester, department, number etc. +# +# &status_select_row() provides a select box from which to choose 1 or more +# access types (current access, prior access, and future access) +# +# &email_default_row() provides text boxes for default e-mail suffixes for +# different authentication types in a domain. +# +# &row_title() and &row_closure() are called internally by the &*_select_row +# routines, but can also be called directly to start and end rows which have +# needs that are not accommodated by the *_select_row() routines. + +sub start_pick_box { + my ($table_width) = @_; + my $output = <<"END"; + + + + +
+ + + + +
+ +END + return $output; +} + +sub end_pick_box { + my $output = <<"END"; +
+
+
+END + return $output; +} + +sub row_title { + my ($col_width,$tablecolor,$title) = @_; + my $output = <<"ENDONE"; + + + + + + +
$title: +
+ + + + +ENDONE + return $output; +} + +sub row_closure { + my $output .= <<"ENDTWO"; + +
+ + + + +
+ + +ENDTWO + return $output; +} + +sub role_select_row { + my ($roles,$col_width,$tablecolor,$title) = @_; + my $output = &row_title($col_width,$tablecolor,$title); + $output .= qq| + + \n|; + $output .= &row_closure(); + return $output; +} + +sub course_select_row { + my ($col_width,$tablecolor,$title,$formname,$totcodes,$codetitles,$idlist,$idlist_titles) = @_; + my $output = &row_title($col_width,$tablecolor,$title); + $output .= " \n"; + $output .= qq| + + |; + my $courseform=''.&Apache::loncommon::selectcourse_link + ($formname,'pickcourse','pickdomain','coursedesc').''; + if ($totcodes > 0) { + $output .= ''.&mt('All courses'); + my $numtitles = @$codetitles; + if ($numtitles > 0) { + $output .= '
'.&mt('Pick courses by category:').'
'; + $output .= ''; + for (my $i=1; $i<$numtitles; $i++) { + $output .= ''; + } + $output .= '
'.$$codetitles[0].'
'."\n". + '
'.$$codetitles[$i].'
'."\n". + ''."\n". + '

'; + } + } + $output .= ''.&mt('Pick specific course(s):').' '.$courseform.'  selected.
'."\n"; + $output .= &row_closure(); + return $output; +} + +sub status_select_row { + my ($types,$col_width,$tablecolor,$title) = @_; + my $output = &row_title($col_width,$tablecolor,$title); + $output .= qq| + + \n|; + $output .= &row_closure(); + return $output; +} + +sub email_default_row { + my ($authtypes,$col_width,$tablecolor,$title,$descrip) = @_; + my $output = &row_title($col_width,$tablecolor,$title); + my @rowcols = ('#eeeeee','#dddddd'); + $output .= ' '.$descrip.' + + + + '."\n"; + my $rownum = 0; + foreach my $auth (sort keys (%{$authtypes})) { + my ($userentry,$size); + my $rowiter = $rownum%2; + if ($auth =~ /^krb/) { + $userentry = ''; + $size = 25; + } else { + $userentry = 'username@'; + $size = 15; + } + $output .= ''; + $rownum ++; + } + $output .= "
'.&mt('Authentication Method').'      '.&mt('Username -> e-mail conversion').'
'.$$authtypes{$auth}.'   '.$userentry.'
+ \n"; + $output .= &row_closure(); + return $output; +} + + +sub submit_row { + my ($col_width,$tablecolor,$title,$cmd,$submit_text) = @_; + my $output .= &row_title($col_width,$tablecolor,$title); + $output .= qq| + +
+ +   +

+ \n|; + return $output; +} 1;