--- loncom/interface/loncommon.pm 2016/09/15 04:18:38 1.1075.2.112 +++ loncom/interface/loncommon.pm 2014/04/23 10:11:26 1.1185 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.112 2016/09/15 04:18:38 raeburn Exp $ +# $Id: loncommon.pm,v 1.1185 2014/04/23 10:11:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -72,12 +72,10 @@ use Apache::lonuserstate(); use Apache::courseclassifier(); use LONCAPA qw(:DEFAULT :match); use DateTime::TimeZone; -use DateTime::Locale; -use Encode(); +use DateTime::Locale::Catalog; +use Text::Aspell; use Authen::Captcha; use Captcha::reCAPTCHA; -use JSON::DWIW; -use LWP::UserAgent; use Crypt::DES; use DynaLoader; # for Crypt::DES version @@ -164,6 +162,7 @@ sub ssi_with_retries { # ----------------------------------------------- Filetypes/Languages/Copyright my %language; my %supported_language; +my %supported_codes; my %latex_language; # For choosing hyphenation in my %latex_language_bykey; # for choosing hyphenation from metadata my %cprtag; @@ -198,14 +197,15 @@ BEGIN { while (my $line = <$fh>) { next if ($line=~/^\#/); chomp($line); - my ($key,$two,$country,$three,$enc,$val,$sup,$latex)=(split(/\t/,$line)); + my ($key,$code,$country,$three,$enc,$val,$sup,$latex)=(split(/\t/,$line)); $language{$key}=$val.' - '.$enc; if ($sup) { $supported_language{$key}=$sup; + $supported_codes{$key} = $code; } if ($latex) { $latex_language_bykey{$key} = $latex; - $latex_language{$two} = $latex; + $latex_language{$code} = $latex; } } close($fh); @@ -535,7 +535,7 @@ ENDAUTHORBRW sub coursebrowser_javascript { my ($domainfilter,$sec_element,$formname,$role_element,$crstype, - $credits_element,$instcode) = @_; + $credits_element) = @_; my $wintitle = 'Course_Browser'; if ($crstype eq 'Community') { $wintitle = 'Community_Browser'; @@ -586,12 +586,6 @@ sub coursebrowser_javascript { var ownername = document.forms[formid].ccuname.value; var ownerdom = document.forms[formid].ccdomain.options[document.forms[formid].ccdomain.selectedIndex].value; url += '&cloner='+ownername+':'+ownerdom; - if (type == 'Course') { - url += '&crscode='+document.forms[formid].crscode.value; - } - } - if (formname == 'requestcrs') { - url += '&crsdom=$domainfilter&crscode=$instcode'; } if (multflag !=null && multflag != '') { url += '&multiple='+multflag; @@ -675,7 +669,7 @@ if (!Array.prototype.indexOf) { var n = 0; if (arguments.length > 0) { n = Number(arguments[1]); - if (n !== n) { // shortcut for verifying if it's NaN + if (n !== n) { // shortcut for verifying if it is NaN n = 0; } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { n = (n > 0 || -1) * Math.floor(Math.abs(n)); @@ -911,12 +905,12 @@ sub check_uncheck_jscript { function checkAll(field) { if (field.length > 0) { for (i = 0; i < field.length; i++) { - if (!field[i].disabled) { + if (!field[i].disabled) { field[i].checked = true; } } } else { - if (!field.disabled) { + if (!field.disabled) { field.checked = true; } } @@ -967,16 +961,15 @@ sub select_datelocale { } $output .= '> '; } - my @languages = &Apache::lonlocal::preferred_languages(); my (@possibles,%locale_names); - my @locales = DateTime::Locale->ids(); - foreach my $id (@locales) { - if ($id ne '') { - my ($en_terr,$native_terr); - my $loc = DateTime::Locale->load($id); - if (ref($loc)) { - $en_terr = $loc->name(); - $native_terr = $loc->native_name(); + my @locales = DateTime::Locale::Catalog::Locales; + foreach my $locale (@locales) { + if (ref($locale) eq 'HASH') { + my $id = $locale->{'id'}; + if ($id ne '') { + my $en_terr = $locale->{'en_territory'}; + my $native_terr = $locale->{'native_territory'}; + my @languages = &Apache::lonlocal::preferred_languages(); if (grep(/^en$/,@languages) || !@languages) { if ($en_terr ne '') { $locale_names{$id} = '('.$en_terr.')'; @@ -990,8 +983,7 @@ sub select_datelocale { $locale_names{$id} = '('.$en_terr.')'; } } - $locale_names{$id} = Encode::encode('UTF-8',$locale_names{$id}); - push(@possibles,$id); + push (@possibles,$id); } } } @@ -1002,7 +994,7 @@ sub select_datelocale { } $output.=">$item"; if ($locale_names{$item} ne '') { - $output.=' '.$locale_names{$item}; + $output.=" $locale_names{$item}\n"; } $output.="\n"; } @@ -1028,6 +1020,33 @@ sub select_language { =pod + +=item * &list_languages() + +Returns an array reference that is suitable for use in language prompters. +Each array element is itself a two element array. The first element +is the language code. The second element a descsriptiuon of the +language itself. This is suitable for use in e.g. +&Apache::edit::select_arg (once dereferenced that is). + +=cut + +sub list_languages { + my @lang_choices; + + foreach my $id (&languageids()) { + my $code = &supportedlanguagecode($id); + if ($code) { + my $selector = $supported_codes{$id}; + my $description = &plainlanguagedescription($id); + push (@lang_choices, [$selector, $description]); + } + } + return \@lang_choices; +} + +=pod + =item * &linked_select_forms(...) linked_select_forms returns a string containing a block @@ -1248,11 +1267,7 @@ sub help_open_topic { $topic=~s/\W/\_/g; if (!$stayOnPage) { - if ($env{'browser.mobile'}) { - $link = "javascript:openMyModal('/adm/help/${filename}.hlp',$width,$height,'yes');"; - } else { - $link = "javascript:void(open('/adm/help/${filename}.hlp', 'Help_for_$topic', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))"; - } + $link = "javascript:openMyModal('/adm/help/${filename}.hlp',$width,$height,'yes');"; } elsif ($stayOnPage eq 'popup') { $link = "javascript:void(open('/adm/help/${filename}.hlp', 'Help_for_$topic', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))"; } else { @@ -1303,9 +1318,7 @@ sub helpLatexCheatsheet { unless ($not_author) { $out .= ' ' .&help_open_topic('Authoring_Output_Tags',&mt('Output Tags'),$stayOnPage,undef,600) - .' ' - .&help_open_topic('Authoring_Multilingual_Problems',&mt('Languages'),$stayOnPage,undef,600) - .''; + .''; } $out .= ''; # End cheatsheet return $out; @@ -1368,10 +1381,8 @@ sub help_open_menu { sub top_nav_help { my ($text) = @_; $text = &mt($text); - my $stay_on_page; - unless ($env{'environment.remote'} eq 'on') { - $stay_on_page = 1; - } + my $stay_on_page = 1; + my ($link,$banner_link); unless ($env{'request.noversionuri'} =~ m{^/adm/helpmenu}) { $link = ($stay_on_page) ? "javascript:helpMenu('display')" @@ -1401,9 +1412,9 @@ sub help_menu_js { &Apache::loncommon::start_page('Help Menu', undef, {'frameset' => 1, 'js_ready' => 1, - 'use_absolute' => $httphost, + 'use_absolute' => $httphost, 'add_entries' => { - 'border' => '0', + 'border' => '0', 'rows' => "110,*",},}); my $end_page = &Apache::loncommon::end_page({'frameset' => 1, @@ -1744,242 +1755,6 @@ RESIZE } -sub colorfuleditor_js { - return <<"COLORFULEDIT" - -COLORFULEDIT -} - -sub xmleditor_js { - return < - -XMLEDIT -} - -sub insert_folding_button { - my $curDepth = $Apache::lonxml::curdepth; - my $lastresource = $env{'request.ambiguous'}; - - return ""; -} - - =pod =head1 Excel and CSV file utility routines @@ -2441,7 +2216,7 @@ The optional $onchange argument specifie The optional $incdoms is a reference to an array of domains which will be the only available options. -The optional $excdoms is a reference to an array of domains which will be excluded from the available options. +The optional $excdoms is a reference to an array of domains which will be excluded from the available options. =cut @@ -2459,7 +2234,7 @@ sub select_dom_form { } if ($includeempty) { @domains=('',@domains); } if (ref($excdoms) eq 'ARRAY') { - map { $exclude{$_} = 1; } @{$excdoms}; + map { $exclude{$_} = 1; } @{$excdoms}; } my $selectdomain = "'. - &mt('Hide').''; - } - $prevattempts .= ''; + ''.&mt('Transaction [_1]',$version).''; if (@hidden) { foreach my $key (sort(keys(%lasthash))) { next if ($key =~ /\.foilorder$/); @@ -4094,15 +3855,9 @@ sub get_previous_attempt { } } else { if ($key =~ /\./) { - my $value = $returnhash{$version.':'.$key}; - if ($key =~ /\.rndseed$/) { - my ($id) = ($key =~ /^(.+)\.rndseed$/); - if (exists($returnhash{$version.':'.$id.'.rawrndseed'})) { - $value = $returnhash{$version.':'.$id.'.rawrndseed'}; - } - } - $prevattempts.=''.&format_previous_attempt_value($key,$value). - ' '; + my $value = &format_previous_attempt_value($key, + $returnhash{$version.':'.$key}); + $prevattempts.=''.$value.' '; } else { $prevattempts.=' '; } @@ -4111,15 +3866,9 @@ sub get_previous_attempt { } else { foreach my $key (sort(keys(%lasthash))) { next if ($key =~ /\.foilorder$/); - my $value = $returnhash{$version.':'.$key}; - if ($key =~ /\.rndseed$/) { - my ($id) = ($key =~ /^(.+)\.rndseed$/); - if (exists($returnhash{$version.':'.$id.'.rawrndseed'})) { - $value = $returnhash{$version.':'.$id.'.rawrndseed'}; - } - } - $prevattempts.=''.&format_previous_attempt_value($key,$value). - ' '; + my $value = &format_previous_attempt_value($key, + $returnhash{$version.':'.$key}); + $prevattempts.=''.$value.' '; } } $prevattempts.=&end_data_table_row(); @@ -4144,7 +3893,7 @@ sub get_previous_attempt { if ($key =~/$regexp$/ && (defined &$gradesub)) { $value = &$gradesub($value); } - $prevattempts.=''.$value.' '; + $prevattempts.=''. $value.' '; } else { $prevattempts.=' '; } @@ -4160,7 +3909,7 @@ sub get_previous_attempt { if ($key =~/$regexp$/ && (defined &$gradesub)) { $value = &$gradesub($value); } - $prevattempts.=''.$value.' '; + $prevattempts.=''.$value.' '; } } $prevattempts.= &end_data_table_row().&end_data_table(); @@ -4181,11 +3930,13 @@ sub get_previous_attempt { sub format_previous_attempt_value { my ($key,$value) = @_; if (($key =~ /timestamp/) || ($key=~/duedate/)) { - $value = &Apache::lonlocal::locallocaltime($value); + $value = &Apache::lonlocal::locallocaltime($value); } elsif (ref($value) eq 'ARRAY') { - $value = '('.join(', ', @{ $value }).')'; + $value = &HTML::Entities::encode('('.join(', ', @{ $value }).')','"<>&'); } elsif ($key =~ /answerstring$/) { my %answers = &Apache::lonnet::str2hash($value); + my @answer = %answers; + %answers = map {&HTML::Entities::encode($_, '"<>&')} @answer; my @anskeys = sort(keys(%answers)); if (@anskeys == 1) { my $answer = $answers{$anskeys[0]}; @@ -4208,7 +3959,7 @@ sub format_previous_attempt_value { } } } else { - $value = &unescape($value); + $value = &HTML::Entities::encode(&unescape($value), '"<>&'); } return $value; } @@ -4569,20 +4320,23 @@ sub findallcourses { ############################################### sub blockcheck { - my ($setters,$activity,$uname,$udom,$url,$is_course) = @_; + my ($setters,$activity,$uname,$udom,$url) = @_; - if (defined($udom) && defined($uname)) { - # If uname and udom are for a course, check for blocks in the course. - if (($is_course) || (&Apache::lonnet::is_course($udom,$uname))) { - my ($startblock,$endblock,$triggerblock) = - &get_blocks($setters,$activity,$udom,$uname,$url); - return ($startblock,$endblock,$triggerblock); - } - } else { + if (!defined($udom)) { $udom = $env{'user.domain'}; + } + if (!defined($uname)) { $uname = $env{'user.name'}; } + # If uname and udom are for a course, check for blocks in the course. + + if (&Apache::lonnet::is_course($udom,$uname)) { + my ($startblock,$endblock,$triggerblock) = + &get_blocks($setters,$activity,$udom,$uname,$url); + return ($startblock,$endblock,$triggerblock); + } + my $startblock = 0; my $endblock = 0; my $triggerblock = ''; @@ -4592,8 +4346,7 @@ sub blockcheck { # boards, chat or groups, check for blocking in current course only. if (($activity eq 'boards' || $activity eq 'chat' || - $activity eq 'groups' || $activity eq 'printout') && - ($env{'request.course.id'})) { + $activity eq 'groups') && ($env{'request.course.id'})) { foreach my $key (keys(%live_courses)) { if ($key ne $env{'request.course.id'}) { delete($live_courses{$key}); @@ -4857,12 +4610,12 @@ sub parse_block_record { } sub blocking_status { - my ($activity,$uname,$udom,$url,$is_course) = @_; + my ($activity,$uname,$udom,$url) = @_; my %setters; # check for active blocking my ($startblock,$endblock,$triggerblock) = - &blockcheck(\%setters,$activity,$uname,$udom,$url,$is_course); + &blockcheck(\%setters,$activity,$uname,$udom,$url); my $blocked = 0; if ($startblock && $endblock) { $blocked = 1; @@ -4874,9 +4627,9 @@ sub blocking_status { # build a link to a popup window containing the details my $querystring = "?activity=$activity"; # $uname and $udom decide whose portfolio the user is trying to look at - if (($activity eq 'port') || ($activity eq 'passwd')) { - $querystring .= "&udom=$udom" if ($udom =~ /^$match_domain$/); - $querystring .= "&uname=$uname" if ($uname =~ /^$match_username$/); + if ($activity eq 'port') { + $querystring .= "&udom=$udom" if $udom; + $querystring .= "&uname=$uname" if $uname; } elsif ($activity eq 'docs') { $querystring .= '&url='.&HTML::Entities::encode($url,'&"'); } @@ -4895,17 +4648,13 @@ END_MYBLOCK my $popupUrl = "/adm/blockingstatus/$querystring"; my $text = &mt('Communication Blocked'); - my $class = 'LC_comblock'; if ($activity eq 'docs') { $text = &mt('Content Access Blocked'); - $class = ''; } elsif ($activity eq 'printout') { $text = &mt('Printing Blocked'); - } elsif ($activity eq 'passwd') { - $text = &mt('Password Changing Blocked'); } $output .= <<"END_BLOCK"; -
+
$text @@ -4921,13 +4670,13 @@ END_BLOCK ############################################### sub check_ip_acc { - my ($acc,$clientip)=@_; + my ($acc)=@_; &Apache::lonxml::debug("acc is $acc"); if (!defined($acc) || $acc =~ /^\s*$/ || $acc =~/^\s*no\s*$/i) { return 1; } my $allowed=0; - my $ip=$ENV{'REMOTE_ADDR'} || $clientip || $env{'request.host'}; + my $ip=$env{'request.host'} || $ENV{'REMOTE_ADDR'}; my $name; foreach my $pattern (split(',',$acc)) { @@ -5023,28 +4772,23 @@ sub get_domainconf { if (keys(%{$domconfig{'login'}})) { foreach my $key (keys(%{$domconfig{'login'}})) { if (ref($domconfig{'login'}{$key}) eq 'HASH') { - if (($key eq 'loginvia') || ($key eq 'headtag')) { - if (ref($domconfig{'login'}{$key}) eq 'HASH') { - foreach my $hostname (keys(%{$domconfig{'login'}{$key}})) { - if (ref($domconfig{'login'}{$key}{$hostname}) eq 'HASH') { - if ($key eq 'loginvia') { - if ($domconfig{'login'}{'loginvia'}{$hostname}{'server'}) { - my $server = $domconfig{'login'}{'loginvia'}{$hostname}{'server'}; - $designhash{$udom.'.login.loginvia'} = $server; - if ($domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'} eq 'custom') { - $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'custompath'}; - } else { - $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'}; - } + if ($key eq 'loginvia') { + if (ref($domconfig{'login'}{'loginvia'}) eq 'HASH') { + foreach my $hostname (keys(%{$domconfig{'login'}{'loginvia'}})) { + if (ref($domconfig{'login'}{'loginvia'}{$hostname}) eq 'HASH') { + if ($domconfig{'login'}{'loginvia'}{$hostname}{'server'}) { + my $server = $domconfig{'login'}{'loginvia'}{$hostname}{'server'}; + $designhash{$udom.'.login.loginvia'} = $server; + if ($domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'} eq 'custom') { + + $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'custompath'}; + } else { + $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'}; } - } elsif ($key eq 'headtag') { - if ($domconfig{'login'}{'headtag'}{$hostname}{'url'}) { - $designhash{$udom.'.login.headtag_'.$hostname} = $domconfig{'login'}{'headtag'}{$hostname}{'url'}; + if ($domconfig{'login'}{'loginvia'}{$hostname}{'exempt'}) { + $designhash{$udom.'.login.loginvia_exempt_'.$hostname} = $domconfig{'login'}{'loginvia'}{$hostname}{'exempt'}; } } - if ($domconfig{'login'}{$key}{$hostname}{'exempt'}) { - $designhash{$udom.'.login.'.$key.'_exempt_'.$hostname} = $domconfig{'login'}{$key}{$hostname}{'exempt'}; - } } } } @@ -5363,11 +5107,11 @@ Inputs: =item * $bgcolor, used to override the bgcolor on a webpage to a specific value -=item * $no_inline_link, if true and in remote mode, don't show the - 'Switch To Inline Menu' link - =item * $args, optional argument valid values are no_auto_mt_title -> prevents &mt()ing the title arg + inherit_jsmath -> when creating popup window in a page, + should it have jsmath forced on by the + current page =item * $advtoolsref, optional argument, ref to an array containing inlineremote items to be added in "Functions" menu below @@ -5384,7 +5128,7 @@ other decorations will be returned. sub bodytag { my ($title,$function,$addentries,$bodyonly,$domain,$forcereg, - $no_nav_bar,$bgcolor,$no_inline_link,$args,$advtoolsref)=@_; + $no_nav_bar,$bgcolor,$args,$advtoolsref)=@_; my $public; if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) @@ -5435,7 +5179,7 @@ sub bodytag { # construct main body tag my $bodytag = "". - &Apache::lontexconvert::init_math_support(); + &Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'}); &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); @@ -5459,25 +5203,9 @@ sub bodytag { $dc_info =~ s/\s+$//; } - $role = '('.$role.')' if ($role && !$env{'browser.mobile'}); + $role = '('.$role.')' if $role; - if ($env{'request.state'} eq 'construct') { $forcereg=1; } - - - - my $funclist; - if (($env{'environment.remote'} eq 'on') && ($env{'request.state'} ne 'construct')) { - $bodytag .= Apache::lonhtmlcommon::scripttag(Apache::lonmenu::utilityfunctions($httphost), 'start')."\n". - Apache::lonmenu::serverform(); - my $forbodytag; - &Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, - $forcereg,$args->{'group'}, - $args->{'bread_crumbs'}, - $advtoolsref,'',\$forbodytag); - unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') { - $funclist = $forbodytag; - } - } else { + if ($env{'request.state'} eq 'construct') { $forcereg=1; } # if ($env{'request.state'} eq 'construct') { # $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls @@ -5489,11 +5217,11 @@ sub bodytag { my ($left,$right) = Apache::lonmenu::primary_menu(); if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { - if ($dc_info) { + if ($dc_info) { $dc_info = qq|$dc_info|; - } - $bodytag .= qq|
$left $role
- $realm $dc_info
|; + } + $bodytag .= qq|
$left $role
+ $realm $dc_info
|; return $bodytag; } @@ -5508,7 +5236,7 @@ sub bodytag { } $bodytag .= qq|
$realm $dc_info
|; - #if directed to not display the secondary menu, don't. + #if directed to not display the secondary menu, don't. if ($args->{'no_secondary_menu'}) { return $bodytag; } @@ -5520,18 +5248,15 @@ sub bodytag { if ($env{'request.state'} eq 'construct') { $bodytag .= &Apache::lonmenu::innerregister($forcereg, $args->{'bread_crumbs'}); - } elsif ($forcereg) { + } elsif ($forcereg) { $bodytag .= &Apache::lonmenu::innerregister($forcereg,undef, $args->{'group'}); } else { - my $forbodytag; - &Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, - $forcereg,$args->{'group'}, - $args->{'bread_crumbs'}, - $advtoolsref,'',\$forbodytag); - unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') { - $bodytag .= $forbodytag; - } + $bodytag .= + &Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, + $forcereg,$args->{'group'}, + $args->{'bread_crumbs'}, + $advtoolsref); } }else{ # this is to seperate menu from content when there's no secondary @@ -5541,54 +5266,6 @@ sub bodytag { } return $bodytag; - } - -# -# Top frame rendering, Remote is up -# - - my $imgsrc = $img; - if ($img =~ /^\/adm/) { - $imgsrc = &lonhttpdurl($img); - } - my $upperleft=''.$function.''; - - my $help=($no_inline_link?'' - :&Apache::loncommon::top_nav_help('Help')); - - # Explicit link to get inline menu - my $menu= ($no_inline_link?'' - :''.&mt('Switch to Inline Menu Mode').''); - - if ($dc_info) { - $dc_info = qq|($dc_info)|; - } - - my $name = &plainname($env{'user.name'},$env{'user.domain'}); - unless ($public) { - $name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'}, - undef,'LC_menubuttons_link'); - } - - unless ($env{'form.inhibitmenu'}) { - $bodytag .= qq|
$name $role
-
    -
  1. $help
  2. -
  3. $menu
  4. -
$realm $dc_info
|; - } - if ($env{'request.state'} eq 'construct') { - if (!$public){ - if ($env{'request.state'} eq 'construct') { - $funclist = &Apache::lonhtmlcommon::scripttag( - &Apache::lonmenu::utilityfunctions($httphost), 'start'). - &Apache::lonhtmlcommon::scripttag('','end'). - &Apache::lonmenu::innerregister($forcereg, - $args->{'bread_crumbs'}); - } - } - } - return $bodytag."\n".$funclist; } sub dc_courseid_toggle { @@ -5620,15 +5297,8 @@ sub make_attr_string { delete($attr_ref->{$key}); } } - if ($env{'environment.remote'} eq 'on') { - $attr_ref->{'onload'} = - &Apache::lonmenu::loadevents(). $on_load; - $attr_ref->{'onunload'}= - &Apache::lonmenu::unloadevents().$on_unload; - } else { - $attr_ref->{'onload'} = $on_load; - $attr_ref->{'onunload'}= $on_unload; - } + $attr_ref->{'onload'} = $on_load; + $attr_ref->{'onunload'}= $on_unload; } my $attr_string; @@ -5662,6 +5332,7 @@ sub endbodytag { unless ((ref($args) eq 'HASH') && ($args->{'notbody'})) { $endbodytag=''; } + $endbodytag=&Apache::lontexconvert::jsMath_process()."\n".$endbodytag; if ( exists( $env{'internal.head.redirect'} ) ) { if (!(ref($args) eq 'HASH' && $args->{'noredirectlink'})) { $endbodytag= @@ -5836,17 +5507,6 @@ div.LC_confirm_box .LC_success img { vertical-align: middle; } -.LC_maxwidth { - max-width: 100%; - height: auto; -} - -.LC_textsize_mobile { - \@media only screen and (max-device-width: 480px) { - -webkit-text-size-adjust:100%; -moz-text-size-adjust:100%; -ms-text-size-adjust:100%; - } -} - .LC_icon { border: none; vertical-align: middle; @@ -5968,10 +5628,6 @@ table#LC_menubuttons img { vertical-align: middle; } -.LC_breadcrumbs_hoverable { - background: $sidebg; -} - td.LC_table_cell_checkbox { text-align: center; } @@ -6829,7 +6485,7 @@ div.LC_edit_problem_footer, div.LC_edit_problem_footer div, div.LC_edit_problem_editxml_header, div.LC_edit_problem_editxml_header div { - z-index: 100; + margin-top: 5px; } div.LC_edit_problem_header_title { @@ -6845,17 +6501,14 @@ table.LC_edit_problem_header_title { background: $tabbg; } -div.LC_edit_actionbar { - background-color: $sidebg; - margin: 0; - padding: 0; - line-height: 200%; +div.LC_edit_problem_discards { + float: left; + padding-bottom: 5px; } -div.LC_edit_actionbar div{ - padding: 0; - margin: 0; - display: inline-block; +div.LC_edit_problem_saves { + float: right; + padding-bottom: 5px; } .LC_edit_opt { @@ -6871,10 +6524,6 @@ div.LC_edit_actionbar div{ margin-left: 40px; } -#LC_edit_problem_codemirror div{ - margin-left: 0px; -} - img.stift { border-width: 0; vertical-align: middle; @@ -6962,10 +6611,6 @@ fieldset { /* overflow: hidden; */ } -article.geogebraweb div { - margin: 0; -} - fieldset > legend { font-weight: bold; padding: 0 5px 0 5px; @@ -7005,48 +6650,23 @@ ol.LC_primary_menu li { vertical-align: middle; text-align: left; list-style: none; - position: relative; float: left; - z-index: 100; /* will be displayed above codemirror and underneath the help-layer */ - line-height: 1.5em; } -ol.LC_primary_menu li a -ol.LC_primary_menu li p { +ol.LC_primary_menu li a { display: block; margin: 0; padding: 0 5px 0 10px; text-decoration: none; } -ol.LC_primary_menu li p span.LC_primary_menu_innertitle { - display: inline-block; - width: 95%; - text-align: left; -} - -ol.LC_primary_menu li p span.LC_primary_menu_innerarrow { - display: inline-block; - width: 5%; - float: right; - text-align: right; - font-size: 70%; -} - -ol.LC_primary_menu ul { +ol.LC_primary_menu li ul { display: none; - width: 15em; + width: 10em; background-color: $data_table_light; - position: absolute; - top: 100%; -} - -ol.LC_primary_menu ul ul { - left: 100%; - top: 0; } -ol.LC_primary_menu li:hover > ul, ol.LC_primary_menu li.hover > ul { +ol.LC_primary_menu li:hover ul, ol.LC_primary_menu li.hover ul { display: block; position: absolute; margin: 0; @@ -7055,21 +6675,15 @@ ol.LC_primary_menu li:hover > ul, ol.LC_ } ol.LC_primary_menu li:hover li, ol.LC_primary_menu li.hover li { -/* First Submenu -> size should be smaller than the menu title of the whole menu */ font-size: 90%; vertical-align: top; float: none; border-left: 1px solid black; border-right: 1px solid black; -/* A dark bottom border to visualize different menu options; -overwritten in the create_submenu routine for the last border-bottom of the menu */ - border-bottom: 1px solid $data_table_dark; } -ol.LC_primary_menu li li p:hover { - color:$button_hover; - text-decoration:none; - background-color:$data_table_dark; +ol.LC_primary_menu li:hover li a, ol.LC_primary_menu li.hover li a { + background-color:$data_table_light; } ol.LC_primary_menu li li a:hover { @@ -7077,11 +6691,6 @@ ol.LC_primary_menu li li a:hover { background-color:$data_table_dark; } -/* Font-size equal to the size of the predecessors*/ -ol.LC_primary_menu li:hover li li { - font-size: 100%; -} - ol.LC_primary_menu li img { vertical-align: bottom; height: 1.1em; @@ -7138,7 +6747,6 @@ ul#LC_secondary_menu li { font-weight: bold; line-height: 1.8em; border-right: 1px solid black; - vertical-align: middle; float: left; } @@ -7694,16 +7302,13 @@ sub headtag { ''. &font_settings($args); - my $inhibitprint; - if ($args->{'print_suppress'}) { - $inhibitprint = &print_suppression(); - } + my $inhibitprint = &print_suppression(); if (!$args->{'frameset'}) { $result .= &Apache::lonhtmlcommon::htmlareaheaders(); } - if ($args->{'force_register'}) { - $result .= &Apache::lonmenu::registerurl(1); + if ($args->{'force_register'} && $env{'request.noversionuri'} !~ m{^/res/adm/pages/}) { + $result .= Apache::lonxml::display_title(); } if (!$args->{'no_nav_bar'} && !$args->{'only_body'} @@ -7737,82 +7342,6 @@ sub headtag { ADDMETA - } else { - unless (($args->{'frameset'}) || ($args->{'js_ready'}) || ($args->{'only_body'}) || ($args->{'no_nav_bar'})) { - my $requrl = $env{'request.uri'}; - if ($requrl eq '') { - $requrl = $ENV{'REQUEST_URI'}; - $requrl =~ s/\?.+$//; - } - unless (($requrl =~ m{^/adm/(?:switchserver|login|authenticate|logout|groupsort|cleanup|helper|slotrequest|grades)(\?|$)}) || - (($requrl =~ m{^/res/}) && (($env{'form.submitted'} eq 'scantron') || - ($env{'form.grade_symb'}) || ($Apache::lonhomework::scantronmode)))) { - my $dom_in_use = $Apache::lonnet::perlvar{'lonDefDomain'}; - unless (&Apache::lonnet::allowed('mau',$dom_in_use)) { - my %domdefs = &Apache::lonnet::get_domain_defaults($dom_in_use); - if (ref($domdefs{'offloadnow'}) eq 'HASH') { - my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; - if ($domdefs{'offloadnow'}{$lonhost}) { - my $newserver = &Apache::lonnet::spareserver(30000,undef,1,$dom_in_use); - if (($newserver) && ($newserver ne $lonhost)) { - my $numsec = 5; - my $timeout = $numsec * 1000; - my ($newurl,$locknum,%locks,$msg); - if ($env{'request.role.adv'}) { - ($locknum,%locks) = &Apache::lonnet::get_locks(); - } - my $disable_submit = 0; - if ($requrl =~ /$LONCAPA::assess_re/) { - $disable_submit = 1; - } - if ($locknum) { - my @lockinfo = sort(values(%locks)); - $msg = &mt('Once the following tasks are complete: ')."\\n". - join(", ",sort(values(%locks)))."\\n". - &mt('your session will be transferred to a different server, after you click "Roles".'); - } else { - if (($requrl =~ m{^/res/}) && ($env{'form.submitted'} =~ /^part_/)) { - $msg = &mt('Your LON-CAPA submission has been recorded')."\\n"; - } - $msg .= &mt('Your current LON-CAPA session will be transferred to a different server in [quant,_1,second].',$numsec); - $newurl = '/adm/switchserver?otherserver='.$newserver; - if (($env{'request.role'}) && ($env{'request.role'} ne 'cm')) { - $newurl .= '&role='.$env{'request.role'}; - } - if ($env{'request.symb'}) { - $newurl .= '&symb='.$env{'request.symb'}; - } else { - $newurl .= '&origurl='.$requrl; - } - } - &js_escape(\$msg); - $result.=< - -OFFLOAD - } - } - } - } - } - } } if (!defined($title)) { $title = 'The LearningOnline Network with CAPA'; @@ -7823,16 +7352,10 @@ OFFLOAD if (!$args->{'frameset'}) { $result .= ' /'; } - $result .= '>' + $result .= '>' .$inhibitprint .$head_extra; - my $clientmobile; - if (($env{'user.name'} eq '') && ($env{'user.domain'} eq '')) { - (undef,undef,undef,undef,undef,undef,$clientmobile) = &decode_user_agent(); - } else { - $clientmobile = $env{'browser.mobile'}; - } - if ($clientmobile) { + if ($env{'browser.mobile'}) { $result .= ' '; @@ -7855,12 +7378,12 @@ sub font_settings { my $headerstring=''; if ((!$env{'browser.mathml'} && $env{'browser.unicode'}) || ((ref($args) eq 'HASH') && ($args->{'browser.unicode'}))) { - $headerstring.= - '{'frameset'}) { - $headerstring.= ' /'; + $headerstring.= ' /'; } - $headerstring .= '>'."\n"; + $headerstring .= '>'."\n"; } return $headerstring; } @@ -7905,7 +7428,7 @@ sub print_suppression { } my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $blocked = &blocking_status('printout',$cnum,$cdom,undef,1); + my $blocked = &blocking_status('printout',$cnum,$cdom); if ($blocked) { my $checkrole = "cm./$cdom/$cnum"; if ($env{'request.course.sec'} ne '') { @@ -8013,13 +7536,14 @@ $args - additional optional args support skip_phases -> hash ref of head -> skip the generation body -> skip all generation - no_inline_link -> if true and in remote mode, don't show the - 'Switch To Inline Menu' link no_auto_mt_title -> prevent &mt()ing the title arg + inherit_jsmath -> when creating popup window in a page, + should it have jsmath forced on by the + current page bread_crumbs -> Array containing breadcrumbs bread_crumbs_component -> if exists show it as headline else show only the breadcrumbs - group -> includes the current group, if page is for a - specific group + group -> includes the current group, if page is for a + specific group =back @@ -8049,8 +7573,8 @@ sub start_page { $args->{'function'}, $args->{'add_entries'}, $args->{'only_body'}, $args->{'domain'}, $args->{'force_register'}, $args->{'no_nav_bar'}, - $args->{'bgcolor'}, $args->{'no_inline_link'}, - $args, \@advtools); + $args->{'bgcolor'}, $args, + \@advtools); } } @@ -8090,11 +7614,6 @@ sub start_page { }else{ $result .= &Apache::lonhtmlcommon::breadcrumbs(); } - } elsif (($env{'environment.remote'} eq 'on') && - ($env{'form.inhibitmenu'} ne 'yes') && - ($env{'request.noversionuri'} =~ m{^/res/}) && - ($env{'request.noversionuri'} !~ m{^/res/adm/pages/})) { - $result .= '

'; } return $result; } @@ -8142,12 +7661,10 @@ function set_wishlistlink(title, path) { title = title.replace(/^LON-CAPA /,''); } title = encodeURIComponent(title); - title = title.replace("'","\\\'"); if (!path) { path = location.pathname; } path = encodeURIComponent(path); - path = path.replace("'","\\\'"); Win = window.open('/adm/wishlist?mode=newLink&setTitle='+title+'&setPath='+path, 'wishlistNewLink','width=560,height=350,scrollbars=0'); } @@ -8190,13 +7707,12 @@ var modalWindow = { }; var openMyModal = function(source,width,height,scrolling,transparency,style) { - source = source.replace("'","'"); modalWindow.windowId = "myModal"; modalWindow.width = width; modalWindow.height = height; - modalWindow.content = ""; + modalWindow.content = "