--- loncom/interface/londocs.pm 2017/02/18 23:39:15 1.621 +++ loncom/interface/londocs.pm 2017/04/25 22:18:59 1.624 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.621 2017/02/18 23:39:15 raeburn Exp $ +# $Id: londocs.pm,v 1.624 2017/04/25 22:18:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -659,6 +659,7 @@ sub group_import { my $marker = $2; my $info = $3; my ($toolid,%toolhash,%toolsettings); + my @extras = ('linktext','explanation','crslabel','crstitle'); my @toolinfo = split(/:/,$info); if ($residx) { %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum); @@ -668,9 +669,11 @@ sub group_import { } $toolid =~ s/\D//g; ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'}, + $toolhash{'linktext'},$toolhash{'explanation'}, $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo; - $toolhash{'crslabel'} = &unescape($toolhash{'crslabel'}); - $toolhash{'crstitle'} = &unescape($toolhash{'crstitle'}); + foreach my $item (@extras) { + $toolhash{$item} = &unescape($toolhash{$item}); + } if (ref($ltitoolsref) eq 'HASH') { my @deleted; if (ref($ltitoolsref->{$toolid}) eq 'HASH') { @@ -683,13 +686,22 @@ sub group_import { foreach my $item ('width','height') { $toolhash{$item} =~ s/^\s+//; $toolhash{$item} =~ s/\s+$//; + if ($toolhash{$item} =~ /\D/) { + delete($toolhash{$item}); + if ($residx) { + if ($toolsettings{$item}) { + push(@deleted,$item); + } + } + } } } } elsif ($residx) { $toolhash{'target'} = $toolsettings{'target'}; if ($toolhash{'target'} eq 'window') { - $toolhash{'width'} = $toolsettings{'width'}; - $toolhash{'height'} = $toolsettings{'height'}; + foreach my $item ('width','height') { + $toolhash{$item} = $toolsettings{$item}; + } } } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') { $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'}; @@ -699,31 +711,35 @@ sub group_import { } } if ($toolhash{'target'} eq 'iframe') { - delete($toolhash{'width'}); - delete($toolhash{'height'}); - if ($residx) { - if ($toolsettings{'width'}) { - push(@deleted,'width'); - } - if ($toolsettings{'height'}) { - push(@deleted,'height'); + foreach my $item ('width','height','linktext','explanation') { + delete($toolhash{$item}); + if ($residx) { + if ($toolsettings{$item}) { + push(@deleted,$item); + } } } } if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') { - foreach my $item ('label','title') { + foreach my $item ('label','title','linktext','explanation') { + my $crsitem; + if (($item eq 'label') || ($item eq 'title')) { + $crsitem = 'crs'.$item; + } else { + $crsitem = $item; + } if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) { - $toolhash{'crs'.$item} =~ s/^\s+//; - $toolhash{'crs'.$item} =~ s/\s+$//; - if ($toolhash{'crs'.$item} eq '') { - delete($toolhash{'crs'.$item}); + $toolhash{$crsitem} =~ s/^\s+//; + $toolhash{$crsitem} =~ s/\s+$//; + if ($toolhash{$crsitem} eq '') { + delete($toolhash{$crsitem}); } } else { - delete($toolhash{'crs'.$item}); + delete($toolhash{$crsitem}); } - if (($residx) && (exists($toolsettings{'crs'.$item}))) { - unless (exists($toolhash{'crs'.$item})) { - push(@deleted,'crs'.$item); + if (($residx) && (exists($toolsettings{$crsitem}))) { + unless (exists($toolhash{$crsitem})) { + push(@deleted,$crsitem); } } } @@ -920,7 +936,7 @@ sub docs_change_log { '// '."\n". @@ -3009,7 +3025,7 @@ sub handle_edit_cmd { sub editor { my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype, $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref, - $canedit,$navmapref,$hiddentop)=@_; + $canedit,$hostname,$navmapref,$hiddentop)=@_; my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container); if ($allowed) { (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain, @@ -3340,7 +3356,7 @@ sub editor { $coursenum,$coursedom,$crstype, $pathitem,$supplementalflag,$container, \%filters,\%curr_groups,$ltitoolsref,$canedit, - $isencrypted,$navmapref); + $isencrypted,$navmapref,$hostname); $idx++; $shown++; } @@ -3721,7 +3737,7 @@ sub is_supplemental_title { sub entryline { my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups, - $ltitoolsref,$canedit,$isencrypted,$navmapref)=@_; + $ltitoolsref,$canedit,$isencrypted,$navmapref,$hostname)=@_; my ($foldertitle,$renametitle,$oldtitle); if (&is_supplemental_title($title)) { ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title); @@ -3988,8 +4004,15 @@ END } elsif ($url!~/\.(sequence|page)$/) { $url='/adm/coursedocs/showdoc'.$url; } - } elsif ($url=~m|^/ext/|) { - $url='/adm/wrapper'.$url; + } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) { + my $wrapped = $1; + my $exturl = $2; + if ($wrapped eq '') { + $url='/adm/wrapper'.$url; + } + if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) { + $nomodal = 1; + } } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) { $url='/adm/wrapper'.$url; } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") { @@ -4060,10 +4083,19 @@ END if ($url =~ /^([^#]+)#([^#]+)$/) { $url = $1; $anchor = $2; + if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) { + if ($hostname ne '') { + $url = 'http://'.$hostname.$url; + } + $nomodal = 1; + } } } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) { if (($ENV{'SERVER_PORT'} == 443) && ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { + if ($hostname ne '') { + $url = 'http://'.$hostname.$url; + } $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1'; $nomodal = 1; } @@ -4200,7 +4232,8 @@ $form_end; $forceedit, undef,$symb, &escape($env{'form.folderpath'}), - $renametitle,'','',1,$suppanchor); + $renametitle,$hostname, + '','',1,$suppanchor); if ($jscall) { $editlink = ''.&mt('Edit').' '."\n"; @@ -4228,7 +4261,12 @@ $form_end; $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&'); } } - $link = &js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'. + if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) { + $link = 'http://'.$hostname.$url; + } else { + $link = $url; + } + $link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'. (($anchor ne '')?$anchor:'')); if ($nomodal) { $line.=''. @@ -5370,8 +5408,9 @@ sub handler { my $tabidstr = join("','",@tabids); %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom); my $posslti = keys(%ltitools); + my $hostname = $r->hostname(); $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti, - $londocroot,$canedit,\$navmap). + $londocroot,$canedit,$hostname,\$navmap). &history_tab_js(). &inject_data_js(). &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid). @@ -5773,7 +5812,7 @@ HIDDENFORM } # - + my $hostname = $r->hostname(); my $savefolderpath; if ($allowed) { @@ -6243,7 +6282,7 @@ unless ($container eq 'page') { unless (($supplementalflag || $toolsflag)) { my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, $supplementalflag,\%orderhash,$iconpath,$pathitem, - \%ltitools,$canedit,\$navmap,$hiddentop); + \%ltitools,$canedit,$hostname,\$navmap,$hiddentop); undef($navmap); if ($error) { $r->print('

'.$error.'

'); @@ -6392,7 +6431,7 @@ my %suporderhash = ( if ($supplementalflag) { my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, $supplementalflag,\%suporderhash,$iconpath,$pathitem, - \%ltitools,$canedit); + \%ltitools,$canedit,$hostname); if ($error) { $r->print('

'.$error.'

'); } else { @@ -6412,7 +6451,7 @@ my %suporderhash = ( } } elsif ($supplementalflag) { my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, - $supplementalflag,'',$iconpath,$pathitem); + $supplementalflag,'',$iconpath,$pathitem,'','',$hostname); if ($error) { $r->print('

'.$error.'

'); } @@ -6786,7 +6825,8 @@ END } sub editing_js { - my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,$londocroot,$canedit,$navmapref) = @_; + my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti, + $londocroot,$canedit,$hostname,$navmapref) = @_; my %js_lt = &Apache::lonlocal::texthash( p_mnf => 'Name of New Folder', t_mnf => 'New Folder', @@ -6863,6 +6903,19 @@ sub editing_js { } $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='. &HTML::Entities::encode($caller,'<>&"'); + if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) { + if (($ENV{'SERVER_PORT'} == 443) && + ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { + if ($hostname ne '') { + $backtourl = 'http://'.$hostname.$backtourl; + } + $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1'; + } + } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) { + if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) { + $backtourl = 'http://'.$hostname.$backtourl; + } + } if ($anchor ne '') { $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"'); }