--- loncom/interface/londocs.pm 2019/08/16 14:22:49 1.665
+++ loncom/interface/londocs.pm 2021/02/09 22:12:33 1.675
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.665 2019/08/16 14:22:49 raeburn Exp $
+# $Id: londocs.pm,v 1.675 2021/02/09 22:12:33 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -833,26 +833,27 @@ sub group_import {
}
my $ext = 'false';
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
- $name = &LONCAPA::map::qtunescape($name);
- if ($name eq '') {
- $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
- }
if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
my $filepath = $1;
- my $fname = $name;
- if ($fname =~ /^\W+$/) {
+ my $fname;
+ if ($name eq '') {
+ $name = &mt('Web Page');
$fname = 'web';
} else {
- $fname =~ s/\W/_/g;
- }
- if (length($fname) > 15) {
- $fname = substr($fname,0,14);
+ $fname = $name;
+ $fname=&Apache::lonnet::clean_filename($fname);
+ if ($fname eq '') {
+ $fname = 'web';
+ } elsif (length($fname) > 15) {
+ $fname = substr($fname,0,14);
+ }
}
+ my $title = &Apache::loncommon::cleanup_html($name);
my $initialtext = &mt('Replace with your own content.');
my $newhtml = <
-$name
+$title
$initialtext
@@ -874,6 +875,7 @@ END
return (&mt('Failed to save new web page.'),1);
}
}
+ $name = &LONCAPA::map::qtunescape($name);
$url = &LONCAPA::map::qtunescape($url);
$LONCAPA::map::resources[$residx] =
join(':', ($name, $url, $ext, 'normal', 'res'));
@@ -1217,13 +1219,19 @@ sub update_paste_buffer {
# Construct identifiers for current contents of user's paste buffer
if (@currpaste) {
foreach my $suffix (@currpaste) {
- my $cid = $env{'docs.markedcopy_crs_'.$suffix};
- my $url = $env{'docs.markedcopy_url_'.$suffix};
- my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
- if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
- ($url ne '')) {
- $pasteurls{$cid.'_'.$url.'_'.$mapidx} = 1;
- }
+ my $cid = $env{'docs.markedcopy_crs_'.$suffix};
+ my $url = $env{'docs.markedcopy_url_'.$suffix};
+ my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
+ if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
+ ($url ne '')) {
+ if ($url eq '/res/lib/templates/simpleproblem.problem') {
+ $pasteurls{$cid.'_'.$mapidx} = 1;
+ } elsif ($url =~ m{^/res/$match_domain/$match_username/}) {
+ $pasteurls{$url} = 1;
+ } else {
+ $pasteurls{$cid.'_'.$url} = 1;
+ }
+ }
}
}
@@ -1232,7 +1240,7 @@ sub update_paste_buffer {
my @pathitems = split(/\&/,$env{'form.folderpath'});
my @folderconf = split(/\:/,$pathitems[-1]);
- my $ispage = $folderconf[4];
+ my $ispage = $folderconf[5];
foreach my $item (@possibles) {
my ($orderidx,$cmd) = split(/:/,$item);
@@ -1245,7 +1253,13 @@ sub update_paste_buffer {
$env{'form.folderpath'},\%curr_groups);
next if ($denied{'copy'});
$url=~s{http(:|:)//https(:|:)//}{https$2//};
- next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx}));
+ if ($url eq '/res/lib/templates/simpleproblem.problem') {
+ next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx}));
+ } elsif ($url =~ m{^/res/$match_domain/$match_username/}) {
+ next if (exists($pasteurls{$url}));
+ } else {
+ next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
+ }
my ($suffix,$errortxt,$locknotfreed) =
&new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
if ($suffix ne '') {
@@ -4145,11 +4159,19 @@ END
my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
my $orig_url = $url;
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
- $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
+ if ($container eq 'page') {
+ $url=~s{^http(|s)(:|:)//}{/ext/};
+ } else {
+ $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
+ }
if (!$supplementalflag && $residx && $symb) {
if ((!$isfolder) && (!$ispage)) {
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
- $url=&Apache::lonnet::clutter($url);
+ if (($url =~ m{^ext/}) && ($container eq 'page')) {
+ $url=&Apache::lonnet::clutter_with_no_wrapper($url);
+ } else {
+ $url=&Apache::lonnet::clutter($url);
+ }
if ($url=~/^\/*uploaded\//) {
$url=~/\.(\w+)$/;
my $embstyle=&Apache::loncommon::fileembstyle($1);
@@ -4163,7 +4185,7 @@ END
} elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
my $wrapped = $1;
my $exturl = $2;
- if ($wrapped eq '') {
+ if (($wrapped eq '') && ($container ne 'page')) {
$url='/adm/wrapper'.$url;
}
if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
@@ -4183,11 +4205,9 @@ END
if (&Apache::lonnet::symbverify($symb,$url)) {
my $shownsymb = $symb;
if ($isexternal) {
- if ($url =~ /^([^#]+)#([^#]+)$/) {
- $url = $1;
- $anchor = $2;
- my $escan = &escape('#');
- $shownsymb =~ s/^([^\#]+)#([^\#]+)$/$1$escan$2/;
+ $url =~ s/\#[^#]+$//;
+ if ($container eq 'page') {
+ $url = &Apache::lonnet::clutter($url);
}
}
unless ($env{'request.role.adv'}) {
@@ -4842,7 +4862,7 @@ sub short_urls {
$r->rflush();
my $readonly;
if ($canedit) {
- my ($numnew,$errors) = &Apache::loncommon::make_short_symbs($cdom,$cnum,$navmap);
+ my ($numnew,$errors) = &Apache::loncommon::get_requested_shorturls($cdom,$cnum,$navmap);
if ($numnew) {
$r->print(''.&mt('Created [quant,_1,URL]',$numnew).'
');
}
@@ -4877,7 +4897,7 @@ sub contentverifyform {
&mt('No').''.(' 'x2).
'
'.
- ''.
+ ''.
''.
'
');
$r->print(&endContentScreen());
@@ -5637,7 +5657,7 @@ sub handler {
undef($env{'form.folderpath'});
} else {
$folderurl = "uploaded/$coursedom/$coursenum/$folder";
- if ((split(/\:/,$pathitems[-1]))[4]) {
+ if ((split(/\:/,$pathitems[-1]))[5]) {
$folderurl .= '.page';
} else {
$folderurl .= '.sequence';
@@ -6567,13 +6587,19 @@ NSYLFORM
$help{'Group Portfolio'}
NGFFORM
- @specialdocumentsforma=(
+ if ($container eq 'page') {
+ @specialdocumentsforma=(
+ {'
'=>$newwebpageform},
+ );
+ } else {
+ @specialdocumentsforma=(
{'
'=>$newpageform},
{'
'=>$newsylform},
{'
'=>$newnavform},
{'
'=>$newsmppageform},
{'
'=>$newwebpageform},
- );
+ );
+ }
$specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
my @external = (
@@ -6619,11 +6645,11 @@ my %orderhash = (
'bb' => ['Import',$importpubform],
'cc' => ['External',$externalform],
'dd' => ['Grading',$gradingform],
+ 'ff' => ['Other',$specialdocumentsform],
);
unless ($container eq 'page') {
$orderhash{'00'} = ['Newfolder',$newfolderform];
$orderhash{'ee'} = ['Collaboration',$communityform];
- $orderhash{'ff'} = ['Other',$specialdocumentsform];
}
$hadchanges=0;
@@ -7376,7 +7402,7 @@ function makewebpage(type) {
}
if (title) {
var webpage = formname.importdetail.value;
- formname.importdetail.value = escape(title)+'='+webpage;
+ formname.importdetail.value = encodeURIComponent(title)+'='+webpage;
formname.submit();
}
}