--- loncom/interface/loncommon.pm 2006/04/14 21:09:51 1.338 +++ loncom/interface/loncommon.pm 2006/04/21 22:00:56 1.346 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.338 2006/04/14 21:09:51 albertel Exp $ +# $Id: loncommon.pm,v 1.346 2006/04/21 22:00:56 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -63,6 +63,7 @@ use Apache::lonlocal; use HTML::Entities; use Apache::lonhtmlcommon(); use Apache::loncoursedata(); +use Apache::lontexconvert(); my $readit; @@ -2770,21 +2771,24 @@ other decorations will be returned. sub bodytag { my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,$customtitle, $notopbar,$bgcolor,$notitle)=@_; + $title=&mt($title); + $function = &get_users_function() if (!$function); - my $img=&designparm($function.'.img',$domain); - my $pgbg= $bgcolor || &designparm($function.'.pgbg',$domain); - my $tabbg=&designparm($function.'.tabbg',$domain); - my $font=&designparm($function.'.font',$domain); - my $link=&designparm($function.'.link',$domain); - my $alink=&designparm($function.'.alink',$domain); - my $vlink=&designparm($function.'.vlink',$domain); - my $sidebg=&designparm($function.'.sidebg',$domain); -# Accessibility font enhance - my $addstyle=''; - if ($env{'browser.fontenhance'} eq 'on') { - $addstyle=' font-size: x-large;'; - } + my $img = &designparm($function.'.img',$domain); + my $tabbg = &designparm($function.'.tabbg',$domain); + my $font = &designparm($function.'.font',$domain); + my $sidebg = &designparm($function.'.sidebg',$domain); + my $pgbg = $bgcolor || &designparm($function.'.pgbg',$domain); + + my %design = ( 'style' => 'margin-top: 0px', + 'bgcolor' => $pgbg, + 'text' => $font, + 'alink' => &designparm($function.'.alink',$domain), + 'vlink' => &designparm($function.'.vlink',$domain), + 'link' => &designparm($function.'.link',$domain),); + @$addentries{keys(%design)} = @design{keys(%design)}; + # role and realm my ($role,$realm) =&Apache::lonnet::plaintext((split(/\./,$env{'request.role'}))[0]); @@ -2804,17 +2808,7 @@ sub bodytag { # construct main body tag my $bodytag = < -h1, h2, h3, th { font-family: Arial, Helvetica, sans-serif } -a:focus { color: red; background: yellow } -table.thinborder { border-collapse: collapse; } -table.thinborder tr th, table.thinborder tr td { border-style: solid; border-width: 1px} -form, .inline { display: inline; } -.center { text-align: center; } -.filename {font-family: monospace;} - - + END $bodytag .= &Apache::lontexconvert::init_math_support(); @@ -2968,11 +2962,44 @@ sub make_attr_string { } if ($register) { - $attr_ref->{'onload'} = &Apache::lonmenu::loadevents(). - $attr_ref->{'onload'}; - $attr_ref->{'onunload'} = &Apache::lonmenu::unloadevents(). - $attr_ref->{'onunload'}; + my ($on_load,$on_unload); + foreach my $key (keys(%{$attr_ref})) { + if (lc($key) eq 'onload') { + $on_load.=$attr_ref->{$key}.';'; + delete($attr_ref->{$key}); + + } elsif (lc($key) eq 'onunload') { + $on_unload.=$attr_ref->{$key}.';'; + delete($attr_ref->{$key}); + } + } + $attr_ref->{'onload'} = + &Apache::lonmenu::loadevents(). $on_load; + $attr_ref->{'onunload'}= + &Apache::lonmenu::unloadevents().$on_unload; + } + +# Accessibility font enhance + if ($env{'browser.fontenhance'} eq 'on') { + my $style; + foreach my $key (keys(%{$attr_ref})) { + if (lc($key) eq 'style') { + $style.=$attr_ref->{$key}.';'; + delete($attr_ref->{$key}); + } + } + $attr_ref->{'style'}=$style.'; font-size: x-large;'; + } + + if ($env{'browser.blackwhite'} eq 'on') { + delete($attr_ref->{'font'}); + delete($attr_ref->{'link'}); + delete($attr_ref->{'alink'}); + delete($attr_ref->{'vlink'}); + delete($attr_ref->{'bgcolor'}); + delete($attr_ref->{'background'}); } + my $attr_string; foreach my $attr (keys(%$attr_ref)) { $attr_string .= " $attr=\"".$attr_ref->{$attr}.'" '; @@ -3014,6 +3041,81 @@ sub endbodytag { return $endbodytag; } +sub standard_css { + my ($function,$domain,$bgcolor) = @_; + my $function = &get_users_function() if (!$function); + my $img = &designparm($function.'.img',$domain); + my $tabbg = &designparm($function.'.tabbg',$domain); + my $font = &designparm($function.'.font',$domain); + my $sidebg = &designparm($function.'.sidebg',$domain); + my $pgbg = $bgcolor || &designparm($function.'.pgbg',$domain); + + my $alink = &designparm($function.'.alink',$domain); + my $vlink = &designparm($function.'.vlink',$domain); + my $link = &designparm($function.'.link',$domain); + my $sans = 'Arial,Helvetica,sans-serif'; + return < +h1, h2, h3, th { font-family: $sans } +a:focus { color: red; background: yellow } +table.thinborder { border-collapse: collapse; } +table.thinborder tr th, table.thinborder tr td { border-style: solid; border-width: 1px} +form, .inline { display: inline; } +.center { text-align: center; } +.filename {font-family: monospace;} + +table#LC_top_nav, table#LC_menubuttons, table#LC_nav_location { + width: 100%; + background: $pgbg; + border: 0px; + border-spacing: 1px; + padding: 0px; + margin: 0px; + border-collapse: separate; +} +table#LC_menubuttons_mainmenu { + background: $pgbg; + border: 0px; + border-spacing: 1px; + padding: 0px; + margin: 0px; + border-collapse: separate; +} +table#LC_menubuttons img, table#LC_menubuttons_mainmenu img { + border: 0px; +} +table#LC_top_nav td { + background: $tabbg; +} +table#LC_top_nav td a, div#LC_top_nav a { + color: $font; + font-family: $sans; +} +.LC_menubuttons_inline_text { + color: $font; + font-family: $sans; + font-size: smaller; +} + +td.LC_menubuttons_text { + color: $font; + font-family: $sans; +} +td.LC_menubuttons_img { + background: $tabbg; +} +.LC_current_location { + font-family: $sans; + background: $tabbg; +} +.LC_new_mail { + font-family: $sans; + font-weight: bold; +} + +END +} + =pod =over 4 @@ -3041,7 +3143,8 @@ sub headtag { my $result = ''. - &Apache::lonxml::fontsettings(). + &standard_css(). + &font_settings(). &Apache::lonhtmlcommon::htmlareaheaders(); if ($args->{'force_register'}) { @@ -3054,7 +3157,7 @@ sub headtag { $env{'internal.head.redirect'} = $url; $result.=< - + ADDMETA } if (!defined($title)) { @@ -3069,6 +3172,66 @@ ADDMETA =over 4 +=item * &font_settings() + +Returns neccessary to set the proper encoding + +Inputs: none + +=back + +=cut + +sub font_settings { + my $headerstring=''; + if (($env{'browser.os'} eq 'mac') && (!$env{'browser.mathml'})) { + $headerstring.= + ''; + } elsif (!$env{'browser.mathml'} && $env{'browser.unicode'}) { + $headerstring.= + ''; + } + return $headerstring; +} + +=pod + +=over 4 + +=item * &xml_begin() + +Returns the needed doctype and + +Inputs: none + +=back + +=cut + +sub xml_begin { + my $output=''; + + &Apache::lonhtmlcommon::init_htmlareafields(); + + if ($env{'browser.mathml'}) { + $output='' + #.''."\n" +# .'] >' + .'' + .''; + } else { + $output=''; + } + return $output; +} + +=pod + +=over 4 + =item * &endheadtag() Returns a uniform for LON-CAPA web pages. @@ -3157,7 +3320,7 @@ sub start_page { my $result; if (! exists($args->{'skip_phases'}{'head'}) ) { $result.= - &Apache::lonxml::xmlbegin(). + &xml_begin(). &headtag($title,$head_extra,\%head_args).&endheadtag(); }