--- loncom/interface/lonhtmlcommon.pm 2017/08/15 23:47:18 1.358.2.11.4.1 +++ loncom/interface/lonhtmlcommon.pm 2020/09/02 00:42:52 1.358.2.18 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.358.2.11.4.1 2017/08/15 23:47:18 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.358.2.18 2020/09/02 00:42:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -92,7 +92,7 @@ sub raw_href_to_link { sub entity_encode { my ($text)=@_; - return &HTML::Entities::encode($text, '<>&"'); + return &HTML::Entities::encode($text, '\'<>&"'); } sub direct_parm_link { @@ -671,7 +671,7 @@ ENDJS my $minuteselector = qq{}; my $secondselector= qq{}; my $cal_link; - if (!$nolink) { + unless (($nolink) || ($state eq 'disabled')) { $cal_link = qq{}; } # @@ -696,7 +696,7 @@ ENDJS $hourselector,$minuteselector,$secondselector). $tzone; } - if (!$nolink) { + unless (($nolink) || ($state eq 'disabled')) { $result .= &mt('[_1]Select Date[_2]',$cal_link,''); } $result .= "\n\n"; @@ -1009,10 +1009,13 @@ Inputs =item $number_to_do The total number of items being processed. +=item $preamble Optional HTML to display before the progress bar. + =back Returns a hash containing the progress state data structure. - +If $number_to_do is zero or null, an indeterminate progress bar will +be used. =item &Update_PrgWin() @@ -1082,20 +1085,20 @@ Returns: none # Create progress sub Create_PrgWin { - my ($r,$number_to_do)=@_; + my ($r,$number_to_do,$preamble)=@_; my %prog_state; $prog_state{'done'}=0; $prog_state{'firststart'}=&Time::HiRes::time(); $prog_state{'laststart'}=&Time::HiRes::time(); $prog_state{'max'}=$number_to_do; - &Apache::loncommon::LCprogressbar($r); + &Apache::loncommon::LCprogressbar($r,$prog_state{'max'},$preamble); return %prog_state; } # update progress sub Update_PrgWin { my ($r,$prog_state,$displayString)=@_; - &Apache::loncommon::LCprogressbarUpdate($r,undef,$displayString); + &Apache::loncommon::LCprogressbarUpdate($r,undef,$displayString,$$prog_state{'max'}); $$prog_state{'laststart'}=&Time::HiRes::time(); } @@ -1145,7 +1148,7 @@ sub Increment_PrgWin { if ($$prog_state{'max'}) { $percent=int(100.*$current/$$prog_state{'max'}); } - &Apache::loncommon::LCprogressbarUpdate($r,$percent,$timeinfo); + &Apache::loncommon::LCprogressbarUpdate($r,$percent,$timeinfo,$$prog_state{'max'}); $$prog_state{'laststart'}=&Time::HiRes::time(); } @@ -1265,9 +1268,9 @@ sub htmlareaheaders { ENDEDITOR } $s.=(< - - + + + @@ -2107,11 +2110,11 @@ sub docs_breadcrumbs { my $foldername=shift(@folders); if ($folderpath) {$folderpath.='&';} $folderpath.=$folder.'&'.$foldername; - my $url; + my $url = $env{'request.use_absolute'}; if ($allowed) { - $url = '/adm/coursedocs?folderpath='; + $url .= '/adm/coursedocs?folderpath='; } else { - $url = '/adm/supplemental?folderpath='; + $url .= '/adm/supplemental?folderpath='; } $url .= &escape($folderpath); my $name=&unescape($foldername); @@ -2536,9 +2539,9 @@ sub course_custom_roles { sub resource_info_box { - my ($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp)=@_; + my ($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp,$divforres)=@_; my $return=''; - if ($stuvcurrent ne '') { + if (($stuvcurrent ne '') || ($divforres)) { $return = '
'; } if ($symb) { @@ -2567,7 +2570,7 @@ sub resource_info_box { } else { $return='

'.&mt('No context provided.').'

'; } - if ($stuvcurrent ne '') { + if (($stuvcurrent ne '') || ($divforres)) { $return .= '
'; } return $return; @@ -3383,7 +3386,17 @@ function go(url) { if (url!='' && url!= null) { currentURL = null; currentSymb= null; - window.location.href=url; + var lcHostname = setLCHost(); + if (lcHostname!='' && lcHostname!= null) { + var RegExp = /^https?\:/; + if (RegExp.test(url)) { + window.location.href=url; + } else { + window.location.href=lcHostname+url; + } + } else { + window.location.href=url; + } } } @@ -3402,8 +3415,8 @@ ENDUTILITY sub jump_to_editres { my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath, - $title,$idx,$suppurl,$todocs,$suppanchor) = @_; - my ($jscall,$anchor); + $title,$hostname,$idx,$suppurl,$todocs,$suppanchor) = @_; + my ($jscall,$anchor,$usehttp,$usehttps,$is_ext); if ($switchserver) { if ($home) { $cfile = '/adm/switchserver?otherserver='.$home.'&role='. @@ -3423,9 +3436,37 @@ sub jump_to_editres { } } else { unless ($cfile =~ m{^/priv/}) { - if ($cfile =~ m{^(/adm/wrapper/ext/[^#]+)#([^#]+)$}) { + if ($cfile =~ m{^(/adm/wrapper/ext/([^#]+))(?:|#([^#]+))$}) { $cfile = $1; - $anchor = $2; + my $extlink = $2; + $anchor = $3; + $is_ext = 1; + if (($extlink !~ /^https:/) && ($ENV{'SERVER_PORT'} == 443)) { + unless (&Apache::lonnet::uses_sts()) { + $usehttp = 1; + } + } elsif ($env{'request.use_absolute'}) { + if ($env{'request.use_absolute'} =~ m{^https://}) { + $usehttps = 1; + } + } + } elsif ($cfile =~ m{^/?public/($match_domain)/($match_courseid)/syllabus}) { + if ($ENV{'SERVER_PORT'} == 443) { + my ($cdom,$cnum) = ($1,$2); + if (($env{'request.course.id'}) && + ($env{'course.'.$env{'request.course.id'}.'.num'} eq $cnum) && + ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $cdom)) { + if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) { + unless (&Apache::lonnet::uses_sts()) { + $usehttp = 1; + } + } + } + } elsif ($env{'request.use_absolute'}) { + if ($env{'request.use_absolute'} =~ m{^https://}) { + $usehttps = 1; + } + } } if ($symb) { if ($anchor ne '') { @@ -3451,6 +3492,16 @@ sub jump_to_editres { } if ($forceedit) { $cfile .= (($cfile=~/\?/)?'&':'?').'forceedit=1'; + if ($usehttps) { + $cfile = $env{'request.use_absolute'}.(($cfile =~ /^\//)? '':'/').$cfile; + } + } elsif ($usehttp) { + if ($hostname ne '') { + $cfile = 'http://'.$hostname.(($cfile =~ /^\//)? '':'/').$cfile; + } + $cfile .= (($cfile=~/\?/)?'&':'?').'usehttp=1'; + } elsif ($usehttps) { + $cfile = $env{'request.use_absolute'}.(($cfile =~ /^\//)? '':'/').$cfile; } if ($forcereg) { $cfile .= (($cfile=~/\?/)?'&':'?').'register=1';