--- loncom/interface/lonhtmlcommon.pm 2002/08/30 15:35:08 1.9 +++ loncom/interface/lonhtmlcommon.pm 2009/02/18 19:28:45 1.201 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.9 2002/08/30 15:35:08 stredwic Exp $ +# $Id: lonhtmlcommon.pm,v 1.201 2009/02/18 19:28:45 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,370 +25,2105 @@ # # http://www.lon-capa.org/ # +###################################################################### +###################################################################### + +=pod + +=head1 NAME + +Apache::lonhtmlcommon - routines to do common html things + +=head1 SYNOPSIS + +Referenced by other mod_perl Apache modules. + +=head1 INTRODUCTION + +lonhtmlcommon is a collection of subroutines used to present information +in a consistent html format, or provide other functionality related to +html. + +=head2 General Subroutines + +=over 4 + +=cut + +###################################################################### +###################################################################### package Apache::lonhtmlcommon; use strict; +use Time::Local; +use Time::HiRes; +use Apache::lonlocal; +use Apache::lonnet; +use LONCAPA; -sub AscendOrderOptions { - my ($order, $page, $formName)=@_; - my $OpSel1 = ''; - my $OpSel2 = ''; +############################################## +############################################## - if($order eq 'Ascending') { - $OpSel1 = ' selected'; - } else { - $OpSel2 = ' selected'; - } +=pod - my $Str = ''; - $Str .= ''."\n"; + my $buttontext=&mt('Edit Math'); + return <$help_text +ENDDRAGMATH +} - return $Str; +############################################## + +=pod + +=item dragmath_js + +Javascript used to open pop-up window containing dragmath applet which +can be used to paste LaTeX into a textarea. + +=cut + +sub dragmath_js { + my ($popup) = @_; + return < + function mathedit(textarea, doc) { + targetEntry = textarea; + targetDoc = doc; + newwin = window.open("/adm/dragmath/applet/$popup.html","","width=565,height=500,resizable"); + } + + +ENDDRAGMATHJS } -sub MapOptions { - my ($data, $page, $formName)=@_; - my $Str = ''; - $Str .= ''."\n"; +############################################## +############################################## - return $Str; +sub recent_filename { + my $area=shift; + return 'nohist_recent_'.&escape($area); } -sub ProblemOptions { - my ($data, $page, $map, $formName)=@_; - my $Str = ''; - $Str .= '\n"; + foreach my $value (sort(keys(%recent))) { + unless ($value =~/^error\:/) { + my $escaped = &Apache::loncommon::escape_url($value); + &Apache::loncommon::inhibit_menu_check(\$escaped); + $return.="\n'; } } - $Str .= '= $n)) {last;} } - $Str .= '>All Problems'."\n"; - $Str .= ''."\n"; + return %return_hash; +} + +sub get_recent_frozen { + my ($area) = @_; + my %recent=&Apache::lonnet::dump(&recent_filename($area)); + +# Create hash with all 'frozen' items + my %return_hash = (); + foreach my $item (keys(%recent)) { + my ($thistime,$thisvalue)=(split(/\&/,$recent{$item})); + if ($thistime eq 'always_include') { + $return_hash{$item} = &unescape($thisvalue); + } + } + return %return_hash; +} + + +=pod + +=item textbox + +=cut + +############################################## +############################################## +sub textbox { + my ($name,$value,$size,$special) = @_; + $size = 40 if (! defined($size)); + $value = &HTML::Entities::encode($value,'<>&"'); + my $Str = ''; return $Str; } -sub PartOptions { - my ($data, $page, $parts, $formName)=@_; - my $Str = ''; +############################################## +############################################## - if(!defined($parts)) { - return ''; - } +=pod - $Str .= '}; + # Month + my @Months = qw/January February March April May June + July August September October November December/; + # Pad @Months with a bogus value to make indexing easier + unshift(@Months,'If you can read this an error occurred'); + if ($includeempty) { $monthselector.=""; } + for(my $m = 1;$m <=$#Months;$m++) { + $monthselector .= qq{