--- loncom/interface/lonhtmlcommon.pm 2005/11/21 21:20:06 1.120 +++ loncom/interface/lonhtmlcommon.pm 2006/06/01 19:30:49 1.131 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.120 2005/11/21 21:20:06 albertel Exp $ +# $Id: lonhtmlcommon.pm,v 1.131 2006/06/01 19:30:49 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,6 +60,8 @@ use Time::Local; use Time::HiRes; use Apache::lonlocal; use Apache::lonnet; +use lib '/home/httpd/lib/perl/'; +use LONCAPA; ############################################## ############################################## @@ -93,7 +95,7 @@ sub authorbombs { sub recent_filename { my $area=shift; - return 'nohist_recent_'.&Apache::lonnet::escape($area); + return 'nohist_recent_'.&escape($area); } sub store_recent { @@ -115,7 +117,7 @@ sub store_recent { } # store new value &Apache::lonnet::put($file,{ $name => - time.'&'.&Apache::lonnet::escape($value) }); + time.'&'.&escape($value) }); } sub remove_recent { @@ -134,7 +136,7 @@ sub select_recent { unless ($_=~/^error\:/) { my $escaped = &Apache::loncommon::escape_url($_); $return.="\n'; } } @@ -158,7 +160,7 @@ sub get_recent { my $idx = 1; foreach (reverse sort keys %time_hash) { $return_hash{$time_hash{$_}} = - &Apache::lonnet::unescape((split(/\&/,$recent{$_}))[1]); + &unescape((split(/\&/,$recent{$_}))[1]); if ($n && ($idx++ >= $n)) {last;} } @@ -178,6 +180,7 @@ sub get_recent { sub textbox { my ($name,$value,$size,$special) = @_; $size = 40 if (! defined($size)); + $value = &HTML::Entities::encode($value,'<>&"'); my $Str = ''; return $Str; @@ -524,7 +527,7 @@ sub get_date_from_form { if (($year<70) || ($year>137)) { return undef; } if (defined($sec) && defined($min) && defined($hour) && defined($day) && defined($month) && defined($year) && - eval(&timelocal($sec,$min,$hour,$day,$month,$year))) { + eval('&timelocal($sec,$min,$hour,$day,$month,$year)')) { return &timelocal($sec,$min,$hour,$day,$month,$year); } else { return undef; @@ -803,20 +806,25 @@ sub Create_PrgWin { $prog_state{'type'}=$type; if ($type eq 'popup') { $prog_state{'window'}='popwin'; - my $html=&Apache::lonxml::xmlbegin(); + my $start_page = + &Apache::loncommon::start_page($title,undef, + {'only_body' => 1, + 'bgcolor' => '#88DDFF', + 'js_ready' => 1}); + my $end_page = &Apache::loncommon::end_page({'js_ready' => 1}); + #the whole function called through timeout is due to issues #in mozilla Read BUG #2665 if you want to know the whole story - &r_print($r,'"); $prog_state{'formname'}='popremain'; @@ -974,7 +982,14 @@ sub crumbs { # --------------------- A function that generates a window for the spellchecker sub spellheader { - my $html=&Apache::lonxml::xmlbegin(); + my $start_page= + &Apache::loncommon::start_page('Speller Suggestions',undef, + {'only_body' => 1, + 'js_ready' => 1, + 'bgcolor' => '#DDDDDD',}); + my $end_page= + &Apache::loncommon::end_page({'js_ready' => 1}); + my $nothing=&javascript_nothing(); return (< @@ -983,7 +998,7 @@ var checkwin; function spellcheckerwindow() { checkwin=window.open($nothing,'spellcheckwin','height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'); - checkwin.document.writeln('$html
'); + checkwin.document.writeln('$start_page
<\\/form>$end_page'); checkwin.document.close(); } // END LON-CAPA Internal --> @@ -1003,6 +1018,22 @@ ENDLINK # ------------------------------------------------- Output headers for HTMLArea +{ + my @htmlareafields; + sub init_htmlareafields { + undef(@htmlareafields); + } + + sub add_htmlareafields { + my (@newfields) = @_; + push(@htmlareafields,@newfields); + } + + sub get_htmlareafields { + return @htmlareafields; + } +} + sub htmlareaheaders { if (&htmlareablocked()) { return ''; } unless (&htmlareabrowser()) { return ''; } @@ -1050,7 +1081,7 @@ sub disablelink { if (defined($#fields)) { unless ($#fields>=0) { return ''; } } - return ''.&mt('Disable WYSIWYG Editor').''; + return ''.&mt('Disable WYSIWYG Editor').''; } sub enablelink { @@ -1058,7 +1089,7 @@ sub enablelink { if (defined($#fields)) { unless ($#fields>=0) { return ''; } } - return ''.&mt('Enable WYSIWYG Editor').''; + return ''.&mt('Enable WYSIWYG Editor').''; } # ----------------------------------------- Script to activate only some fields @@ -1137,20 +1168,9 @@ returns: nothing my @Crumbs; sub breadcrumbs { - my ($color,$component,$component_help,$function,$domain,$menulink, - $helplink) = @_; - if (! defined($color)) { - if (! defined($function)) { - $function = &Apache::loncommon::get_users_function(); - } - $color = &Apache::loncommon::designparm($function.'.tabbg', - $domain); - } + my ($component,$component_help,$menulink,$helplink) = @_; # - my $Str = "\n". - ''. - '
'. - ''; + my $Str = "\n".''; + $Str .= $links.''; # if (defined($component)) { - $Str .= ''; + $Str .= ''; } $Str .= '
'; # # Make the faq and bug data cascade my $faq = ''; @@ -1205,17 +1225,19 @@ returns: nothing # $icons .= &Apache::loncommon::help_open_bug($bug); # } if ($helplink ne 'nohelp') { - $icons .= &Apache::loncommon::help_open_menu($color,$component,$component_help,$function,$faq,$bug); + $icons .= &Apache::loncommon::help_open_menu(undef,$component, + $component_help, + undef,$faq,$bug); } if ($icons ne '') { $Str .= $icons.' '; } # - $Str .= $links.''. - ''.&mt($component).''. + &mt($component).'
'."\n"; # @@ -1410,11 +1432,11 @@ sub course_select_row { |; my $courseform=''.&Apache::loncommon::selectcourse_link ($formname,'pickcourse','pickdomain','coursedesc','',1).''; + $output .= ''.&mt('All courses').'
'; if ($totcodes > 0) { - $output .= ''.&mt('All courses'); my $numtitles = @$codetitles; if ($numtitles > 0) { - $output .= '
'.&mt('Pick courses by category:').'
'; + $output .= ''.&mt('Pick courses by category:').'
'; $output .= '
'.$$codetitles[0].'
'."\n". '