--- loncom/interface/lonhtmlcommon.pm 2002/08/30 15:35:08 1.9 +++ loncom/interface/lonhtmlcommon.pm 2008/07/07 11:02:05 1.176 @@ -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.176 2008/07/07 11:02:05 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,370 +25,1940 @@ # # 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"; +=item dragmath - return $Str; +Creates a button that will allow dragmath to edit an equation into +a specified textbox. + + textarea - Name of the text area to edit. +=cut + +############################################## +# TODO: Figure out a way to only emit the mathedit function once. +# per html output document. +# +############################################## + +sub dragmath { + my ($textarea) = @_; + + return < + function mathedit(textarea, doc) { + targetEntry = textarea; + targetDoc = doc; + newwin = window.open("/adm/dragmath/applet/EditMathPopup.html","","width=565,height=500,resizable"); + } + + +ENDDRAGMATH } -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;} + } + + 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{