--- loncom/interface/loncommon.pm 2015/04/07 15:13:35 1.1075.2.92 +++ loncom/interface/loncommon.pm 2013/04/25 17:58:40 1.1124 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.92 2015/04/07 15:13:35 raeburn Exp $ +# $Id: loncommon.pm,v 1.1124 2013/04/25 17:58:40 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -69,14 +69,12 @@ use Apache::lontexconvert(); use Apache::lonclonecourse(); use Apache::lonuserutils(); use Apache::lonuserstate(); -use Apache::courseclassifier(); use LONCAPA qw(:DEFAULT :match); use DateTime::TimeZone; use DateTime::Locale::Catalog; +use Text::Aspell; use Authen::Captcha; use Captcha::reCAPTCHA; -use Crypt::DES; -use DynaLoader; # for Crypt::DES version # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -161,6 +159,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; @@ -195,14 +194,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); @@ -666,7 +666,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)); @@ -902,12 +902,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; } } @@ -1017,6 +1017,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 @@ -1237,11 +1264,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 { @@ -1292,9 +1315,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; @@ -1357,40 +1378,32 @@ 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 ($link,$banner_link); - unless ($env{'request.noversionuri'} =~ m{^/adm/helpmenu}) { - $link = ($stay_on_page) ? "javascript:helpMenu('display')" - : "javascript:helpMenu('open')"; - $banner_link = &update_help_link(undef,undef,undef,undef,$stay_on_page); - } + my $stay_on_page = 1; + + my $link = ($stay_on_page) ? "javascript:helpMenu('display')" + : "javascript:helpMenu('open')"; + my $banner_link = &update_help_link(undef,undef,undef,undef,$stay_on_page); + my $title = &mt('Get help'); - if ($link) { - return <<"END"; + + return <<"END"; $banner_link -$text + $text END - } else { - return ' '.$text.' '; - } } sub help_menu_js { - my ($httphost) = @_; + my ($text) = @_; my $stayOnPage = 1; my $width = 620; my $height = 600; my $helptopic=&general_help(); - my $details_link = $httphost.'/adm/help/'.$helptopic.'.hlp'; + my $details_link = '/adm/help/'.$helptopic.'.hlp'; my $nothing=&Apache::lonhtmlcommon::javascript_nothing(); my $start_page = &Apache::loncommon::start_page('Help Menu', undef, {'frameset' => 1, 'js_ready' => 1, - 'use_absolute' => $httphost, 'add_entries' => { 'border' => '0', 'rows' => "110,*",},}); @@ -1422,10 +1435,9 @@ function helpMenu(target) { return; } function writeHelp(caller) { - caller.document.writeln('$start_page\\n\\n'); - caller.document.writeln('\\n$end_page'); - caller.document.close(); - caller.focus(); + caller.document.writeln('$start_page\\n\\n\\n$end_page') + caller.document.close() + caller.focus() } // END LON-CAPA Internal --> // ]]> @@ -1737,6 +1749,8 @@ RESIZE =head1 Excel and CSV file utility routines +=over 4 + =cut ############################################################### @@ -1744,8 +1758,6 @@ RESIZE =pod -=over 4 - =item * &csv_translate($text) Translate $text to allow it to be output as a 'comma separated values' @@ -2194,7 +2206,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 @@ -2212,7 +2224,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$/); @@ -3847,15 +3835,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.=' '; } @@ -3864,15 +3846,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(); @@ -4322,20 +4298,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 = ''; @@ -4345,8 +4324,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}); @@ -4610,12 +4588,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; @@ -4772,28 +4750,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'}; - } } } } @@ -4959,7 +4932,7 @@ sub designparm { Inputs: $url (usually will be undef). -Returns: Path to Authoring Space containing the resource or +Returns: Path to Construction Space containing the resource or directory being viewed (or for which action is being taken). If $url is provided, and begins /priv// the path will be that portion of the $context argument. @@ -5022,7 +4995,7 @@ Input: (optional) filename from which br is appropriate for use in building the breadcrumb trail. Returns: HTML div with CSTR path and recent box - To be included on Authoring Space pages + To be included on Construction Space pages =cut @@ -5053,7 +5026,7 @@ sub CSTR_pageheader { my $output = '
' .&Apache::loncommon::help_open_menu('','',3,'Authoring') #FIXME: Broken? Where is it? - .''.&mt('Authoring Space:').' ' + .''.&mt('Construction Space:').' ' .'
' #FIXME lonpubdir: target="_parent" .&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv/'.$udom,undef,undef); @@ -5112,9 +5085,6 @@ 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, @@ -5136,7 +5106,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')) @@ -5144,7 +5114,6 @@ sub bodytag { $public = 1; } if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); } - my $httphost = $args->{'use_absolute'}; $function = &get_users_function() if (!$function); my $img = &designparm($function.'.img',$domain); @@ -5160,10 +5129,7 @@ sub bodytag { @design{keys(%$addentries)} = @$addentries{keys(%$addentries)}; # role and realm - my ($role,$realm) = split(m{\./},$env{'request.role'},2); - if ($realm) { - $realm = '/'.$realm; - } + my ($role,$realm) = split(/\./,$env{'request.role'},2); if ($role eq 'ca') { my ($rdom,$rname) = ($realm =~ m{^/($match_domain)/($match_username)$}); $realm = &plainname($rname,$rdom); @@ -5189,14 +5155,16 @@ sub bodytag { my $bodytag = "". &Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'}); - &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); - - if (($bodyonly) || ($no_nav_bar) || ($env{'form.inhibitmenu'} eq 'yes')) { + if ($bodyonly) { return $bodytag; - } + } + my $name = &plainname($env{'user.name'},$env{'user.domain'}); if ($public) { undef($role); + } else { + $name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'}, + undef,'LC_menubuttons_link'); } my $titleinfo = '

'.$title.'

'; @@ -5212,78 +5180,60 @@ sub bodytag { } $role = '('.$role.')' if $role; + &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); - if ($env{'request.state'} eq 'construct') { $forcereg=1; } - - + if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { + return $bodytag; + } - 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 # } - $bodytag .= Apache::lonhtmlcommon::scripttag( - Apache::lonmenu::utilityfunctions($httphost), 'start'); - 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|
$name $role
+ $realm $dc_info
|; return $bodytag; } unless ($env{'request.symb'} =~ m/\.page___\d+___/) { - $bodytag .= qq|
$left $role
|; + $bodytag .= qq|
$name $role
|; } - $bodytag .= $right; + $bodytag .= Apache::lonhtmlcommon::scripttag( + Apache::lonmenu::utilityfunctions(), 'start'); + + $bodytag .= Apache::lonmenu::primary_menu(); if ($dc_info) { $dc_info = &dc_courseid_toggle($dc_info); } $bodytag .= qq|
$realm $dc_info
|; - #if directed to not display the secondary menu, don't. - if ($args->{'no_secondary_menu'}) { - return $bodytag; - } #don't show menus for public users if (!$public){ - $bodytag .= Apache::lonmenu::secondary_menu($httphost); + $bodytag .= Apache::lonmenu::secondary_menu(); $bodytag .= Apache::lonmenu::serverform(); $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); 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 @@ -5293,54 +5243,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 { @@ -5372,19 +5274,12 @@ 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; - foreach my $attr (sort(keys(%$attr_ref))) { + foreach my $attr (keys(%$attr_ref)) { $attr_string .= " $attr=\"".$attr_ref->{$attr}.'" '; } return $attr_string; @@ -5515,14 +5410,6 @@ form, .inline { vertical-align:middle; } -.LC_floatleft { - float: left; -} - -.LC_floatright { - float: right; -} - .LC_400Box { width:400px; } @@ -6598,14 +6485,6 @@ div.LC_edit_problem_saves { white-space: nowrap; } -.LC_edit_problem_latexhelper{ - text-align: right; -} - -#LC_edit_problem_colorful div{ - margin-left: 40px; -} - img.stift { border-width: 0; vertical-align: middle; @@ -6620,7 +6499,6 @@ div.LC_createcourse { } .LC_dccid { - float: right; margin: 0.2em 0 0 0; padding: 0; font-size: 90%; @@ -6693,10 +6571,6 @@ fieldset { /* overflow: hidden; */ } -article.geogebraweb div { - margin: 0; -} - fieldset > legend { font-weight: bold; padding: 0 5px 0 5px; @@ -6722,6 +6596,7 @@ fieldset > legend { } ol.LC_primary_menu { + float: right; margin: 0; padding: 0; background-color: $pgbg_or_bgcolor; @@ -6833,7 +6708,6 @@ ul#LC_secondary_menu li { font-weight: bold; line-height: 1.8em; border-right: 1px solid black; - vertical-align: middle; float: left; } @@ -7376,7 +7250,6 @@ sub headtag { my $function = $args->{'function'} || &get_users_function(); my $domain = $args->{'domain'} || &determinedomain(); my $bgcolor = $args->{'bgcolor'} || &designparm($function.'.pgbg',$domain); - my $httphost = $args->{'use_absolute'}; my $url = join(':',$env{'user.name'},$env{'user.domain'}, $Apache::lonnet::perlvar{'lonVersion'}, #time(), @@ -7387,23 +7260,20 @@ sub headtag { my $result = ''. - &font_settings($args); + &font_settings(); - 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'} && !$args->{'frameset'}) { - $result .= &help_menu_js($httphost); + $result .= &help_menu_js(); $result.=&modal_window(); $result.=&togglebox_script(); $result.=&wishlist_window(); @@ -7432,99 +7302,15 @@ 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; - } - } - $result.=< - -OFFLOAD - } - } - } - } - } - } } if (!defined($title)) { $title = 'The LearningOnline Network with CAPA'; } if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); } $result .= ' LON-CAPA '.$title.'' - .'{'frameset'}) { - $result .= ' /'; - } - $result .= '>' + .'' .$inhibitprint .$head_extra; - if ($env{'browser.mobile'}) { - $result .= ' - -'; - } return $result.''; } @@ -7534,21 +7320,15 @@ OFFLOAD Returns neccessary to set the proper encoding -Inputs: optional reference to HASH -- $args passed to &headtag() +Inputs: none =cut sub font_settings { - my ($args) = @_; my $headerstring=''; - if ((!$env{'browser.mathml'} && $env{'browser.unicode'}) || - ((ref($args) eq 'HASH') && ($args->{'browser.unicode'}))) { + if (!$env{'browser.mathml'} && $env{'browser.unicode'}) { $headerstring.= - '{'frameset'}) { - $headerstring.= ' /'; - } - $headerstring .= '>'."\n"; + ''; } return $headerstring; } @@ -7593,7 +7373,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 '') { @@ -7640,7 +7420,6 @@ Inputs: none =cut sub xml_begin { - my ($is_frameset) = @_; my $output=''; if ($env{'browser.mathml'}) { @@ -7652,12 +7431,9 @@ sub xml_begin { .'' .''; - } elsif ($is_frameset) { - $output=''."\n". - ''."\n"; } else { - $output=''."\n". - ''."\n"; + $output='' + .''; } return $output; } @@ -7701,16 +7477,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 @@ -7726,7 +7500,7 @@ sub start_page { my ($result,@advtools); if (! exists($args->{'skip_phases'}{'head'}) ) { - $result .= &xml_begin($args->{'frameset'}) . &headtag($title, $head_extra, $args); + $result .= &xml_begin() . &headtag($title, $head_extra, $args); } if (! exists($args->{'skip_phases'}{'body'}) ) { @@ -7740,8 +7514,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); } } @@ -7781,11 +7555,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; } @@ -7832,13 +7601,9 @@ function set_wishlistlink(title, path) { title = document.title; 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'); } @@ -7879,15 +7644,14 @@ var modalWindow = { $(".LCmodal-overlay").click(function(){modalWindow.close();}); } }; - var openMyModal = function(source,width,height,scrolling,transparency,style) + var openMyModal = function(source,width,height,scrolling) { - source = source.replace("'","'"); modalWindow.windowId = "myModal"; modalWindow.width = width; modalWindow.height = height; - modalWindow.content = ""; + modalWindow.content = "