--- loncom/interface/loncommon.pm 2024/04/14 17:12:27 1.1429 +++ loncom/interface/loncommon.pm 2025/02/18 02:38:06 1.1457 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1429 2024/04/14 17:12:27 raeburn Exp $ +# $Id: loncommon.pm,v 1.1457 2025/02/18 02:38:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1174,7 +1174,8 @@ sub linked_select_forms { $menuorder, $onchangefirst, $onchangesecond, - $suffix + $suffix, + $haslabel ) = @_; my $second = "document.$formname.$secondselectname"; my $first = "document.$formname.$firstselectname"; @@ -1240,13 +1241,18 @@ END $result.=">".&mt($hashref->{$value}->{'text'})."</option>\n"; } $result .= "</select>\n"; + if ($haslabel) { + $result .= '</label>'; + } my %select2; if (ref($hashref->{$firstdefault}) eq 'HASH') { if (ref($hashref->{$firstdefault}->{'select2'}) eq 'HASH') { %select2 = %{$hashref->{$firstdefault}->{'select2'}}; } } - $result .= $middletext; + if ($middletext ne '') { + $result .= '<label>'.$middletext; + } $result .= "<select size=\"1\" name=\"$secondselectname\""; if ($onchangesecond) { $result .= ' onchange="'.$onchangesecond.'"'; @@ -1264,6 +1270,9 @@ END $result.=">".&mt($select2{$value})."</option>\n"; } $result .= "</select>\n"; + if ($middletext ne '') { + $result .= '</label>'; + } # return $debug; return $result; } # end of sub linked_select_forms { @@ -2300,7 +2309,7 @@ sub import_crsauthor_form { dire => 'Directory', se => 'Select', ); - $output = $lt{'dire'}.': '. + $output = '<label>'.$lt{'dire'}.': '. '<select id="'.$firstselectname.'" name="'.$firstselectname.'" '. 'onchange="populateCrsSelects(this.form,'."'$firstselectname','$secondselectname',1,'$js_only',0,1,0,0,0".');">'. '<option value="" selected="selected">'.$lt{'se'}.'</option>'; @@ -2311,10 +2320,10 @@ sub import_crsauthor_form { next if ($key eq '/'); $output .= '<option value="'.$key.'">'.$key.'</option>'."\n"; } - $output .= '</select><br />'."\n". + $output .= '</select></label><br /><label>'."\n". $lt{'fnam'}.': <select id="'.$secondselectname.'" name="'.$secondselectname.'">'."\n". '<option value="" selected="selected"></option>'."\n". - '</select>'."\n". + '</select></label>'."\n". '<input type="hidden" id="crsres_include_'.$suffix.'" value="'.$only.'" />'; return ($numdirs,$output); } @@ -2476,7 +2485,7 @@ END <domain>$cdom</domain> <highestgradelevel>0</highestgradelevel> <keywords></keywords> -<language>notset </language> +<language>notset</language> <lastrevisiondate>$now</lastrevisiondate> <lowestgradelevel>0</lowestgradelevel> <mime>rights</mime> @@ -3066,7 +3075,7 @@ sub select_level_form { =pod -=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms,$disabled) +=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms,$disabled,$id) Returns a string containing a <select name='$name' size='1'> form to allow a user to select the domain to preform an operation in. @@ -3085,17 +3094,22 @@ The optional $excdoms is a reference to The optional $disabled argument, if true, adds the disabled attribute to the select tag. +The option $id argument is the value (if any) to set as the (unique) id attribute for the select tag. + =cut #------------------------------------------- sub select_dom_form { - my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms,$disabled) = @_; + my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms,$disabled,$id) = @_; if ($onchange) { $onchange = ' onchange="'.$onchange.'"'; } if ($disabled) { $disabled = ' disabled="disabled"'; } + if ($id ne '') { + $id = ' id="'.$id.'"'; + } my (@domains,%exclude); if (ref($incdoms) eq 'ARRAY') { @domains = sort {lc($a) cmp lc($b)} (@{$incdoms}); @@ -3106,7 +3120,7 @@ sub select_dom_form { if (ref($excdoms) eq 'ARRAY') { map { $exclude{$_} = 1; } @{$excdoms}; } - my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange$disabled>\n"; + my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange$disabled$id>\n"; foreach my $dom (@domains) { next if ($exclude{$dom}); $selectdomain.="<option value=\"$dom\" ". @@ -3950,6 +3964,21 @@ sub passwd_validation_js { } else { $alertmsg = &mt('A secret did not satisfy requirement(s):').'\n\n'; } + } elsif ($context eq 'ltitools') { + my %domconfig = &Apache::lonnet::get_dom('configuration',['toolsec'],$domain); + if (ref($domconfig{'toolsec'}) eq 'HASH') { + if (ref($domconfig{'toolsec'}{'rules'}) eq 'HASH') { + %passwdconf = %{$domconfig{'toolsec'}{'rules'}}; + } + } + if ($id eq 'add') { + $alertmsg = &mt('Secret for added external tool did not satisfy requirement(s):').'\n\n'; + } elsif ($id =~ /^\d+$/) { + my $pos = $id+1; + $alertmsg = &mt('Secret for external tool [_1] did not satisfy requirement(s):','#'.$pos).'\n\n'; + } else { + $alertmsg = &mt('A secret did not satisfy requirement(s):').'\n\n'; + } } else { %passwdconf = &Apache::lonnet::get_passwdconf($domain); $alertmsg = &mt('Initial password did not satisfy requirement(s):').'\n\n'; @@ -5676,7 +5705,8 @@ sub blockcheck { } unless ($has_evb) { if (($activity eq 'printout') || ($activity eq 'grades') || ($activity eq 'search') || - ($activity eq 'boards') || ($activity eq 'groups') || ($activity eq 'chat')) { + ($activity eq 'index') || ($activity eq 'boards') || ($activity eq 'groups') || + ($activity eq 'chat')) { if ($udom eq $cdom) { $check_ipaccess = 1; } @@ -5767,8 +5797,8 @@ sub blockcheck { if (($activity eq 'boards' || $activity eq 'chat' || $activity eq 'groups' || $activity eq 'printout' || - $activity eq 'search' || $activity eq 'reinit' || - $activity eq 'alert') && + $activity eq 'search' || $activity eq 'index' || + $activity eq 'reinit' || $activity eq 'alert') && ($env{'request.course.id'})) { foreach my $key (keys(%live_courses)) { if ($key ne $env{'request.course.id'}) { @@ -6103,6 +6133,8 @@ END_MYBLOCK $text = &mt('Gradebook Blocked'); } elsif ($activity eq 'search') { $text = &mt('Search Blocked'); + } elsif ($activity eq 'index') { + $text = &mt('Content Index Blocked'); } elsif ($activity eq 'alert') { $text = &mt('Checking Critical Messages Blocked'); } elsif ($activity eq 'reinit') { @@ -6536,7 +6568,7 @@ Input: (optional) filename from which br If page header is being requested for use in a frameset, then the second (option) argument -- frameset will be true, and the target attribute set for links should be target="_parent". - If $title is supplied as the thitd arg, that will be used to + If $title is supplied as the third arg, that will be used to the left of the breadcrumbs tail for the current path. Returns: HTML div with CSTR path and recent box @@ -6699,7 +6731,8 @@ sub permitted_editors { $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; if (($env{'request.editurl'} =~ m{^/priv/\Q$cdom/$cnum\E/}) || - ($env{'request.editurl'} =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/})) { + ($env{'request.editurl'} =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/}) || + ($uri =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/})) { $is_course = 1; } elsif ($env{'request.editurl'} =~ m{^/priv/($match_domain)/($match_username)/}) { ($audom,$auname) = ($1,$2); @@ -6861,7 +6894,6 @@ sub bodytag { my $hostname = $args->{'hostname'}; $function = &get_users_function() if (!$function); - my $img = &designparm($function.'.img',$domain); my $font = &designparm($function.'.font',$domain); my $pgbg = $bgcolor || &designparm($function.'.pgbg',$domain); @@ -6915,8 +6947,6 @@ sub bodytag { $role = &Apache::lonnet::plaintext($role); } - if (!$realm) { $realm=' '; } - my $extra_body_attr = &make_attr_string($forcereg,\%design); # construct main body tag @@ -6940,7 +6970,6 @@ sub bodytag { undef($role); } unless ($ltimenu->{'coursetitle'}) { - $realm=' '; $showcrstitle = 0; } } @@ -6950,7 +6979,6 @@ sub bodytag { undef($role); } unless ($menuref->{'crs'}) { - $realm=' '; $showcrstitle = 0; } } @@ -6984,8 +7012,12 @@ sub bodytag { # $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls # } - $bodytag .= Apache::lonhtmlcommon::scripttag( - Apache::lonmenu::utilityfunctions($httphost), 'start'); + my $need_endlcint; + unless ($args->{'switchserver'}) { + $bodytag .= Apache::lonhtmlcommon::scripttag( + Apache::lonmenu::utilityfunctions($httphost), 'start'); + $need_endlcint = 1; + } my $collapsible; if ($args->{'collapsible_header'} ne '') { @@ -7014,30 +7046,42 @@ END $args->{'links_disabled'}, $args->{'links_target'}, $collapsible); - + my $labeltext = &HTML::Entities::encode(&mt('Primary links')); if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { if ($dc_info) { $dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|; } - $bodytag .= qq|<div id="LC_nav_bar">$left $role<br /> - <em>$realm</em> $dc_info</div>|; + $bodytag .= qq|<div id="LC_nav_bar" role="navigation" aria-label="$labeltext">$left $role</div>|; + unless (($realm eq '') && ($dc_info eq '')) { + $bodytag .= qq|<div id="LC_realm" role="complementary"><em>$realm</em> $dc_info</div>|; + } + if ($need_endlcint) { + $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); + } return $bodytag; } + $bodytag .= '<div class="LC_landmark" style="margin: 3px 0 0 0;" role="navigation" aria-label="'.$labeltext.'">'; unless ($env{'request.symb'} =~ m/\.page___\d+___/) { $bodytag .= qq|<div id="LC_nav_bar">$left $role</div>|; } - $bodytag .= $right; + $bodytag .= $right.'</div>'; if ($dc_info) { $dc_info = &dc_courseid_toggle($dc_info); } - $bodytag .= qq|<div id="LC_realm">$realm $dc_info</div>|; + unless (($realm eq '') && ($dc_info eq '')) { + $bodytag .= qq|<div id="LC_realm" role="complementary">$realm $dc_info</div>|; + } + $bodytag .= qq|<div style="clear: both; margin: 5px 0 0 0;"></div>|; } #if directed to not display the secondary menu, don't. if ($args->{'no_secondary_menu'}) { + if ($need_endlcint) { + $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); + } return $bodytag; } #don't show menus for public users @@ -7050,7 +7094,9 @@ END $args->{'links_target'}); } $bodytag .= Apache::lonmenu::serverform(); - $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); + if ($need_endlcint) { + $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); + } if ($env{'request.state'} eq 'construct') { $bodytag .= &Apache::lonmenu::innerregister($forcereg, $args->{'bread_crumbs'},'','',$hostname, @@ -7066,11 +7112,13 @@ END $args->{'bread_crumbs'}, $advtoolsref,'',$hostname); } - }else{ - # this is to seperate menu from content when there's no secondary - # menu. Especially needed for public accessible ressources. + } else { + # this is to separate menu from content when there's no secondary + # menu. Especially needed for publicly accessible resources. $bodytag .= '<hr style="clear:both" />'; - $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); + if ($need_endlcint) { + $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); + } } if ($args->{'collapsible_header'} ne '') { $bodytag .= $args->{'collapsible_header'}. @@ -7205,7 +7253,6 @@ Inputs: (all optional) sub standard_css { my ($function,$domain,$bgcolor) = @_; $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 $fontmenu = &designparm($function.'.fontmenu', $domain); @@ -7258,6 +7305,7 @@ body { line-height:130%; font-size:0.83em; color:$font; + background-color: $pgbg_or_bgcolor; } a:focus, @@ -7269,6 +7317,26 @@ form, .inline { display: inline; } +.LC_landmark { + margin: 0; + padding: 0; + border: none; +} + +.LC_visually_hidden:not(:focus):not(:active) { + clip-path: inset(50%); + height: 1px; + overflow: hidden; + position: absolute; + white-space: nowrap; + width: 1px; + display: inline; +} + +.LC_heading_2 { + font-size: 1.17em; +} + .LC_menus_content.shown{ display: block; } @@ -7281,6 +7349,10 @@ form, .inline { text-align:right; } +.LC_center { + text-align:center; +} + .LC_middle { vertical-align:middle; } @@ -7933,29 +8005,58 @@ table#LC_helpmenu fieldset legend { font-size: larger; } -table#LC_helpmenu_links { - width: 100%; - border: 1px solid black; +.LC_helpdesk_headbox { + border: 2px groove threedface; + padding: 1em; +} + +h1.LC_helpdesk_legend { + float: left; + margin: -1.7em 0 0; + padding: 0 .5em; background: $pgbg; + font-size: 1em; + font-weight: bold; +} + +h1.LC_helpdesk_title { + display: inline; + font-size: 1em; + line-height: 2.5em; + margin: 0; padding: 0; - border-spacing: 1px; + vertical-align: bottom; } -table#LC_helpmenu_links tr td { - padding: 1px; +.LC_helpdesk_links { + border: 1px solid black; + padding: 3px; background: $tabbg; text-align: center; font-weight: bold; + display: inline; + margin-right: -6px; +} + +.LC_helpdesk_img, +.LC_helpdesk_text { + padding: 0; + margin: 0; + border: 0; + display: inline; } -table#LC_helpmenu_links a:link, -table#LC_helpmenu_links a:visited, -table#LC_helpmenu_links a:active { +.LC_helpdesk_img a:link, +.LC_helpdesk_img a:visited, +.LC_helpdesk_img a:active, +.LC_helpdesk_text a:link, +.LC_helpdesk_text a:visited, +.LC_helpdesk_text a:active { text-decoration: none; color: $font; } -table#LC_helpmenu_links a:hover { +div.LC_helpdesk_text a:hover { text-decoration: underline; color: $vlink; } @@ -7982,7 +8083,7 @@ table.LC_pick_box { border-spacing: 1px; } -table.LC_pick_box td.LC_pick_box_title { +table.LC_pick_box th.LC_pick_box_title { background: $sidebg; font-weight: bold; text-align: left; @@ -8185,6 +8286,29 @@ table.LC_prior_tries td { padding: 6px; } +.LC_prob_status { + margin-top: 5px; + padding-top: 0; + padding-left: 0; + padding-bottom: 0; + padding-right: 5px; +} + +.LC_mail_actions { + float: left; + padding: 0; + margin: 6px; +} + +.LC_vertical_line { + width: 1px; + background-color: black; + height: 4em; + float: left; + margin: 0; + padding: 0; +} + span.LC_prior_numerical, span.LC_prior_string, span.LC_prior_custom, @@ -9075,7 +9199,7 @@ ul#LC_toolbar { padding: 0; margin: 2px; list-style:none; - position:relative; + display:inline; background-color:white; overflow: auto; } @@ -9103,6 +9227,13 @@ a.LC_toolbarItem { background-color:transparent; } +.LC_navtools { + display: inline-block; + padding: 0; + margin: 2px; + vertical-align: middle; +} + ul.LC_funclist { margin: 0; padding: 0.5em 1em 0.5em 0; @@ -9409,7 +9540,7 @@ sub headtag { $inhibitprint = &print_suppression(); } - if (!$args->{'frameset'}) { + if (!$args->{'frameset'} && !$args->{'switchserver'}) { $result .= &Apache::lonhtmlcommon::htmlareaheaders(); } if ($args->{'force_register'} && $env{'request.noversionuri'} !~ m{^/res/adm/pages/}) { @@ -9417,7 +9548,8 @@ sub headtag { } if (!$args->{'no_nav_bar'} && !$args->{'only_body'} - && !$args->{'frameset'}) { + && !$args->{'frameset'} + && !$args->{'switchserver'}) { $result .= &help_menu_js($httphost); $result.=&modal_window(); $result.=&togglebox_script(); @@ -9613,8 +9745,12 @@ OFFLOAD $title = 'The LearningOnline Network with CAPA'; } if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); } - $result .= '<title> LON-CAPA '.$title.'</title>' - .'<link rel="stylesheet" type="text/css" href="'.$url.'"'; + if ($title =~ /^LON-CAPA\s+/) { + $result .= '<title> '.$title.'</title>'; + } else { + $result .= '<title> LON-CAPA '.$title.'</title>'; + } + $result .= "\n".'<link rel="stylesheet" type="text/css" href="'.$url.'"'; if (!$args->{'frameset'}) { $result .= ' /'; } @@ -9629,10 +9765,14 @@ OFFLOAD } if ($clientmobile) { $result .= ' -<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes" />'; } - $result .= '<meta name="google" content="notranslate" />'."\n"; + $result .= '<meta name="google" content="notranslate"'; + if (!$args->{'frameset'}) { + $result .= ' /'; + } + $result .= '>'."\n"; return $result.'</head>'; } @@ -9813,6 +9953,11 @@ $args - additional optional args support no_auto_mt_title -> prevent &mt()ing the title arg bread_crumbs -> Array containing breadcrumbs bread_crumbs_component -> if exists show it as headline else show only the breadcrumbs + bread_crumbs_style -> breadcrumbs are contained within <div id="LC_breadcrumbs">, + and &standard_css() contains CSS for #LC_breadcrumbs, if you want + to override those values, or add to them, specify the value to + include in the style attribute to include in the div tag by using + bread_crumbs_style (e.g., overflow: visible) bread_crumbs_nomenu -> if true will pass false as the value of $menulink to lonhtmlcommon::breadcrumbs group -> includes the current group, if page is for a @@ -9981,9 +10126,12 @@ sub start_page { } #if bread_crumbs_component exists show it as headline else show only the breadcrumbs if(exists($args->{'bread_crumbs_component'})){ - $result .= &Apache::lonhtmlcommon::breadcrumbs($args->{'bread_crumbs_component'},'',$menulink); + $result .= &Apache::lonhtmlcommon::breadcrumbs($args->{'bread_crumbs_component'}, + '',$menulink,'', + $args->{'bread_crumbs_style'}); } else { - $result .= &Apache::lonhtmlcommon::breadcrumbs('','',$menulink); + $result .= &Apache::lonhtmlcommon::breadcrumbs('','',$menulink,'', + $args->{'bread_crumbs_style'}); } } } @@ -18071,6 +18219,12 @@ sub init_user_environment { } else { $userenv{'editors'} = 'edit,xml'; } + if ($userenv{'authorarchive'}) { + $userenv{'canarchive'} = 1; + } elsif (($userenv{'authorarchive'} eq '') && + ($domdef{'archive'})) { + $userenv{'canarchive'} = 1; + } } $userenv{'canrequest.author'} = @@ -18959,8 +19113,8 @@ sub needs_coursereinit { $update = 'supp'; } } - return ($update); } + return ($update); } return (); } @@ -19491,9 +19645,9 @@ sub create_captcha { if (-e $Apache::lonnet::perlvar{'lonCaptchaDir'}.'/'.$md5sum.'.png') { $output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n". '<span class="LC_nobreak">'. - &mt('Type in the letters/numbers shown below').' '. + '<label>'.&mt('Type in the letters/numbers shown below').' '. '<input type="text" size="5" name="code" value="" autocomplete="new-password" />'. - '</span><br />'. + '</label></span><br />'. '<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png" alt="captcha" />'; last; }