--- loncom/interface/londocs.pm 2013/01/09 17:23:58 1.484.2.23
+++ loncom/interface/londocs.pm 2012/11/30 14:46:21 1.512
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.484.2.23 2013/01/09 17:23:58 raeburn Exp $
+# $Id: londocs.pm,v 1.512 2012/11/30 14:46:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,6 +40,7 @@ use Apache::lonxml;
use Apache::lonclonecourse;
use Apache::lonnavmaps;
use Apache::lonnavdisplay();
+use Apache::lonuserstate();
use Apache::lonextresedit();
use HTML::Entities;
use HTML::TokeParser;
@@ -270,9 +271,7 @@ sub dumpcourse {
sub group_import {
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
- my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
- %removeparam,$importuploaded,$fixuperrors);
- $allmaps = {};
+
while (@files) {
my ($name, $url, $residx) = @{ shift(@files) };
if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
@@ -298,24 +297,6 @@ sub group_import {
}
}
if ($url) {
- if (($caller eq 'londocs') &&
- ($folder =~ /^default/)) {
- unless ($donechk) {
- my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
- my $cid = $coursedom.'_'.$coursenum;
- $allmaps =
- &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
- $chome,$cid);
- $donechk = 1;
- }
- if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
- &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
- \%addedmaps,\%hierarchy,\%titles,$allmaps);
- $importuploaded = 1;
- } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
- next if ($allmaps->{$url});
- }
- }
if (!$residx
|| defined($LONCAPA::map::zombies[$residx])) {
$residx = &LONCAPA::map::getresidx($url,$residx);
@@ -329,27 +310,7 @@ sub group_import {
join(':', ($name, $url, $ext, 'normal', 'res'));
}
}
- if ($importuploaded) {
- my %import_errors;
- my %updated = (
- removefrommap => \%removefrommap,
- removeparam => \%removeparam,
- );
- &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
- if (keys(%import_errors) > 0) {
- $fixuperrors =
- '
'."\n".
- &mt('The following files are either dependencies of a web page or references within a folder and/or composite page for which errors occurred during import:')."\n".
- '
'."\n";
- foreach my $key (sort(keys(%import_errors))) {
- $fixuperrors .= ''.$key.' '."\n";
- }
- $fixuperrors .= ' '."\n";
- }
- }
- my ($errtext,$fatal) =
- &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
- return ($errtext,$fatal,$fixuperrors);
+ return &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
}
sub log_docs {
@@ -430,15 +391,18 @@ sub docs_change_log {
my %orderhash;
my $container='sequence';
my $pathitem;
- if ($env{'form.folderpath'} =~ /\:1$/) {
+ if ($env{'form.pagepath'}) {
$container='page';
+ $pathitem = ' ';
+ } else {
+ my $folderpath=$env{'form.folderpath'};
+ if ($folderpath eq '') {
+ $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents'));
+ }
+ $pathitem = ' ';
}
- my $folderpath=$env{'form.folderpath'};
- if ($folderpath eq '') {
- $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents').':::::');
- }
- $pathitem = ' ';
my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
my $jumpto = $readfile;
$jumpto =~ s{^/}{};
@@ -690,7 +654,7 @@ sub print_paste_buffer {
$is_external = 1;
}
- my ($canpaste,$nopaste,$othercrs,$areachange);
+ my ($canpaste,$nopaste,$othercrs,$areachange,$is_uploaded_map);
if ($folder =~ /^supplemental/) {
$canpaste = &supp_pasteable($env{'docs.markedcopy_url'});
unless ($canpaste) {
@@ -797,9 +761,16 @@ sub print_paste_buffer {
}
}
$r->print(' '.$othercrs);
- $r->print('
+ if ($container eq 'page') {
+ $r->print('
+
+
+');
+ } else {
+ $r->print('
');
+ }
$r->print('');
} else {
$r->print(&mt('Paste buffer contains:').' '.$buffer.
@@ -934,23 +905,30 @@ sub do_paste_from_buffer {
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%newsubdir,%newurls);
$oldurl = $url;
if ($is_map) {
+ if ($folder =~ /^default/) {
+ my $lastchange = &Apache::lonnet::get_coursechange($coursedom,$coursenum);
+ if ($lastchange > $env{'request.course.tied'}) {
+ &reinit_role($coursedom,$coursenum,$env{"course.$env{'request.course.id'}.home"});
+ }
+ }
# If pasting a map, check if map contains other maps
- my ($allmaps,%hierarchy,%titles);
- $allmaps = {};
+ my (%allmaps,%hierarchy,%titles);
if ($folder =~ /^default/) {
- $allmaps =
- &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
- $env{"course.$env{'request.course.id'}.home"},
- $env{'request.course.id'});
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (defined($navmap)) {
+ foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_map() },1,0,1)) {
+ $allmaps{$res->src()} = 1;
+ }
+ }
}
&contained_map_check($url,$folder,\%removefrommap,\%removeparam,
- \%addedmaps,\%hierarchy,\%titles,$allmaps);
+ \%addedmaps,\%hierarchy,\%titles,\%allmaps);
if ($url=~ m{^/uploaded/}) {
my $newurl;
unless ($env{'form.docs.markedcopy_options'} eq 'move') {
($newurl,my $error) =
&get_newmap_url($url,$folder,$prefixchg,$coursedom,$coursenum,
- $srcdom,$srcnum,\$title,$allmaps,\%newurls);
+ $srcdom,$srcnum,\$title,\%allmaps,\%newurls);
if ($error) {
return ($error);
}
@@ -966,14 +944,14 @@ sub do_paste_from_buffer {
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum) || ($prefixchg) ||
(($newurl ne '') && ($newurl ne $url))) {
unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,
- $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
+ \%allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
\%zombies,\%params,\%mapmoves,\%mapchanges,\%tomove,
\%newsubdir,\%newurls)) {
$mapmoves{$url} = 1;
}
$url = $newurl;
} elsif ($env{'docs.markedcopy_nested'}) {
- &url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,$allmaps,\%rewrites,
+ &url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,\%allmaps,\%rewrites,
\%retitles,\%copies,\%dbcopies,\%zombies,\%params,\%mapmoves,
\%mapchanges,\%tomove,\%newsubdir,\%newurls);
}
@@ -982,7 +960,7 @@ sub do_paste_from_buffer {
&Apache::lonnet::delenv('docs.markedcopy');
# if pasting published map (main content are only) check map is not already in course
if ($folder =~ /^default/) {
- if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
+ if ($allmaps{$url}) {
return (&mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.'));
}
}
@@ -1048,28 +1026,11 @@ sub do_paste_from_buffer {
}
# Apply any changes to maps, or copy dependencies for uploaded HTML pages
my ($result,$save_err);
- my %updated = (
- rewrites => \%rewrites,
- zombies => \%zombies,
- removefrommap => \%removefrommap,
- removeparam => \%removeparam,
- dbcopies => \%dbcopies,
- retitles => \%retitles,
- );
- my %info = (
- newsubdir => \%newsubdir,
- params => \%params,
- before => \%before,
- after => \%after,
- );
- my %moves = (
- copies => \%copies,
- docmoves => \%docmoves,
- mapmoves => \%mapmoves,
- );
$result =
- &apply_fixups($folder,$is_map,$coursedom,$coursenum,$errors,
- \%updated,\%info,\%moves,$prefixchg,$oldurl,$url,'paste');
+ &apply_fixups($folder,$is_map,$prefixchg,$coursedom,$coursenum,$oldurl,
+ $url,\%removefrommap,\%removeparam,\%rewrites,\%retitles,
+ \%copies,\%dbcopies,\%zombies,\%params,\%docmoves,
+ \%mapmoves,\%newsubdir,$errors,\%before,\%after);
if ($result eq 'ok') {
if ($is_map) {
my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
@@ -1229,7 +1190,7 @@ sub contained_map_check {
$titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
} else {
if ($allmaps->{$ressrc}) {
- $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
+ $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
} elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
} else {
@@ -1253,6 +1214,15 @@ sub contained_map_check {
return;
}
+sub reinit_role {
+ my ($cdom,$cnum,$chome) = @_;
+ my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
+ unless ($ferr) {
+ &Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,$cdom.'_'.$cnum);
+ }
+ return;
+}
+
sub url_paste_fixups {
my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$allmaps,$rewrites,$retitles,$copies,
$dbcopies,$zombies,$params,$mapmoves,$mapchanges,$tomove,$newsubdir,$newurls) = @_;
@@ -1371,71 +1341,23 @@ sub url_paste_fixups {
}
sub apply_fixups {
- my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
- $oldurl,$url,$caller) = @_;
- my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
- %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves);
- if (ref($updated) eq 'HASH') {
- if (ref($updated->{'rewrites'}) eq 'HASH') {
- %rewrites = %{$updated->{'rewrites'}};
- }
- if (ref($updated->{'zombies'}) eq 'HASH') {
- %zombies = %{$updated->{'zombies'}};
- }
- if (ref($updated->{'removefrommap'}) eq 'HASH') {
- %removefrommap = %{$updated->{'removefrommap'}};
- }
- if (ref($updated->{'removeparam'}) eq 'HASH') {
- %removeparam = %{$updated->{'removeparam'}};
- }
- if (ref($updated->{'dbcopies'}) eq 'HASH') {
- %dbcopies = %{$updated->{'dbcopies'}};
- }
- if (ref($updated->{'retitles'}) eq 'HASH') {
- %retitles = %{$updated->{'retitles'}};
- }
- }
- if (ref($info) eq 'HASH') {
- if (ref($info->{'newsubdir'}) eq 'HASH') {
- %newsubdir = %{$info->{'newsubdir'}};
- }
- if (ref($info->{'params'}) eq 'HASH') {
- %params = %{$info->{'params'}};
- }
- if (ref($info->{'before'}) eq 'HASH') {
- %before = %{$info->{'before'}};
- }
- if (ref($info->{'after'}) eq 'HASH') {
- %after = %{$info->{'after'}};
- }
- }
- if (ref($moves) eq 'HASH') {
- if (ref($moves->{'copies'}) eq 'HASH') {
- %copies = %{$moves->{'copies'}};
- }
- if (ref($moves->{'docmoves'}) eq 'HASH') {
- %docmoves = %{$moves->{'docmoves'}};
- }
- if (ref($moves->{'mapmoves'}) eq 'HASH') {
- %mapmoves = %{$moves->{'mapmoves'}};
- }
- }
- foreach my $key (keys(%copies),keys(%docmoves)) {
+ my ($folder,$is_map,$prefixchg,$cdom,$cnum,$oldurl,$url,$removefrommap,
+ $removeparam,$rewrites,$retitles,$copies,$dbcopies,$zombies,$params,
+ $docmoves,$mapmoves,$newsubdir,$errors,$before,$after) = @_;
+ foreach my $key (keys(%{$copies}),keys(%{$docmoves})) {
my @allcopies;
- if (exists($copies{$key})) {
- if (ref($copies{$key}) eq 'HASH') {
- my %added;
- foreach my $innerkey (keys(%{$copies{$key}})) {
- if (($innerkey ne '') && (!$added{$innerkey})) {
- push(@allcopies,$innerkey);
- $added{$innerkey} = 1;
- }
+ if (ref($copies->{$key}) eq 'HASH') {
+ my %added;
+ foreach my $innerkey (keys(%{$copies->{$key}})) {
+ if (($innerkey ne '') && (!$added{$innerkey})) {
+ push(@allcopies,$innerkey);
+ $added{$innerkey} = 1;
}
- undef(%added);
}
+ undef(%added);
}
if ($key eq $oldurl) {
- if ((exists($docmoves{$key}))) {
+ if ((exists($docmoves->{$key}))) {
unless (grep(/^\Q$oldurl\E/,@allcopies)) {
push(@allcopies,$oldurl);
}
@@ -1449,16 +1371,16 @@ sub apply_fixups {
my $content = &Apache::lonnet::getfile($item);
unless ($content eq '-1') {
my $storefn;
- if (($key eq $oldurl) && (exists($docmoves{$key}))) {
- $storefn = $docmoves{$key};
+ if (($key eq $oldurl) && (ref($docmoves) eq 'HASH') && (exists($docmoves->{$key}))) {
+ $storefn = $docmoves->{$key};
} else {
$storefn = $relpath;
$storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
- if ($prefixchg && $before{'doc'} && $after{'doc'}) {
- $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
+ if ($prefixchg) {
+ $storefn =~ s/^\Q$before->{'doc'}\E/$after->{'doc'}/;
}
- if ($newsubdir{$key}) {
- $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}#;
+ if ($newsubdir->{$key}) {
+ $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir->{$key}#;
}
}
©_dependencies($item,$storefn,$relpath,$errors,\$content);
@@ -1466,7 +1388,7 @@ sub apply_fixups {
&Apache::lonclonecourse::writefile($env{'request.course.id'},
$storefn.$fname,$content);
if ($copyurl eq '/adm/notfound.html') {
- if (exists($docmoves{$oldurl})) {
+ if ((ref($docmoves) eq 'HASH') && (exists($docmoves->{$oldurl}))) {
return &mt('Paste failed: an error occurred copying the file.');
} elsif (ref($errors) eq 'HASH') {
$errors->{$item} = 1;
@@ -1477,14 +1399,14 @@ sub apply_fixups {
}
}
}
- foreach my $key (keys(%mapmoves)) {
+ foreach my $key (keys(%{$mapmoves})) {
my $storefn=$key;
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
- if ($prefixchg && $before{'map'} && $after{'map'}) {
- $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
+ if ($prefixchg) {
+ $storefn =~ s/^\Q$before->{'map'}\E/$after->{'map'}/;
}
- if ($newsubdir{$key}) {
- $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
+ if ($newsubdir->{$key}) {
+ $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir->{$key}/;
}
my $mapcontent = &Apache::lonnet::getfile($key);
if ($mapcontent eq '-1') {
@@ -1504,39 +1426,48 @@ sub apply_fixups {
}
my %updates;
if ($is_map) {
- if (ref($updated) eq 'HASH') {
- foreach my $type (keys(%{$updated})) {
- if (ref($updated->{$type}) eq 'HASH') {
- foreach my $key (keys(%{$updated->{$type}})) {
- $updates{$key} = 1;
- }
- }
- }
+ foreach my $key (keys(%{$rewrites})) {
+ $updates{$key} = 1;
+ }
+ foreach my $key (keys(%{$zombies})) {
+ $updates{$key} = 1;
+ }
+ foreach my $key (keys(%{$removefrommap})) {
+ $updates{$key} = 1;
+ }
+ foreach my $key (keys(%{$removeparam})) {
+ $updates{$key} = 1;
+ }
+ foreach my $key (keys(%{$dbcopies})) {
+ $updates{$key} = 1;
+ }
+ foreach my $key (keys(%{$retitles})) {
+ $updates{$key} = 1;
}
foreach my $key (keys(%updates)) {
my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
- if (ref($rewrites{$key}) eq 'HASH') {
- %torewrite = %{$rewrites{$key}};
+ if (ref($rewrites->{$key}) eq 'HASH') {
+ %torewrite = %{$rewrites->{$key}};
}
- if (ref($retitles{$key}) eq 'HASH') {
- %toretitle = %{$retitles{$key}};
+ if (ref($retitles->{$key}) eq 'HASH') {
+ %toretitle = %{$retitles->{$key}};
}
- if (ref($removefrommap{$key}) eq 'HASH') {
- %toremove = %{$removefrommap{$key}};
+ if (ref($removefrommap->{$key}) eq 'HASH') {
+ %toremove = %{$removefrommap->{$key}};
}
- if (ref($removeparam{$key}) eq 'HASH') {
- %remparam = %{$removeparam{$key}};
+ if (ref($removeparam->{$key}) eq 'HASH') {
+ %remparam = %{$removeparam->{$key}};
}
- if (ref($zombies{$key}) eq 'HASH') {
- %zombie = %{$zombies{$key}};
+ if (ref($zombies->{$key}) eq 'HASH') {
+ %zombie = %{$zombies->{$key}};
}
- if (ref($dbcopies{$key}) eq 'HASH') {
- foreach my $item (keys(%{$dbcopies{$key}})) {
+ if (ref($dbcopies->{$key}) eq 'HASH') {
+ foreach my $item (keys(%{$dbcopies->{$key}})) {
$newdb{$item} = &dbcopy($item);
}
}
- if (ref($params{$key}) eq 'HASH') {
- %currparam = %{$params{$key}};
+ if (ref($params->{$key}) eq 'HASH') {
+ %currparam = %{$params->{$key}};
}
my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
if ($fatal) {
@@ -1550,41 +1481,40 @@ sub apply_fixups {
}
}
}
- for (my $i=0; $i<@LONCAPA::map::order; $i++) {
- my $idx = $LONCAPA::map::order[$i];
- if (defined($LONCAPA::map::resources[$idx])) {
+ for (my $i=0; $i<@LONCAPA::map::resources; $i++) {
+ if (defined($LONCAPA::map::resources[$i])) {
my $changed;
- my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
- if ((exists($toremove{$idx})) && ($toremove{$idx} eq $src)) {
+ my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$i]);
+ if ($toremove{$src} eq $i) {
splice(@LONCAPA::map::order,$i,1);
- if (ref($currparam{$idx}) eq 'ARRAY') {
- foreach my $name (@{$currparam{$idx}}) {
- &LONCAPA::map::delparameter($idx,'parameter_'.$name);
+ if (ref($currparam{$i}) eq 'ARRAY') {
+ foreach my $name (@{$currparam{$i}}) {
+ &LONCAPA::map::delparameter($i,'parameter_'.$name);
}
}
next;
}
my $origsrc = $src;
- if ((exists($toretitle{$src})) && ($toretitle{$src} eq $idx)) {
+ if ((exists($toretitle{$src})) && ($toretitle{$src} eq $i)) {
if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
$changed = 1;
}
}
- if ((exists($torewrite{$src})) && ($torewrite{$src} eq $idx)) {
+ if ((exists($torewrite{$src})) && ($torewrite{$src} eq $i)) {
$src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
if ($origsrc =~ m{^/uploaded/}) {
- if ($prefixchg && $before{'map'} && $after{'map'}) {
+ if ($prefixchg) {
if ($src =~ /\.(page|sequence)$/) {
- $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
+ $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before->{'map'}\E#$1$after->{'map'}#;
} else {
- $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
+ $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before->{'doc'}\E#$1$after->{'doc'}#;
}
}
- if ($newsubdir{$origsrc}) {
+ if ($newsubdir->{$origsrc}) {
if ($src =~ /\.(page|sequence)$/) {
- $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
+ $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir->{$origsrc}#;
} else {
- $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$origsrc}#;
+ $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir->{$origsrc}#;
}
}
}
@@ -1594,7 +1524,7 @@ sub apply_fixups {
$changed = 1;
}
if ($changed) {
- $LONCAPA::map::resources[$idx] = join(':',($title,$src,$ext,$type));
+ $LONCAPA::map::resources[$i] = join(':',($title,$src,$ext,$type));
}
}
}
@@ -1612,23 +1542,21 @@ sub apply_fixups {
} else {
$storefn = $key;
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
- if ($prefixchg && $before{'map'} && $after{'map'}) {
- $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
+ if ($prefixchg) {
+ $storefn =~ s/^\Q$before->{'map'}\E/$after->{'map'}/;
}
- if ($newsubdir{$key}) {
- $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
+ if ($newsubdir->{$key}) {
+ $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir->{$key}/;
}
}
my $report;
if ($folder !~ /^supplemental/) {
$report = 1;
}
- (my $outtext,$errtext) =
+ my ($outtext,$errtext) =
&LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
if ($errtext) {
- if ($caller eq 'paste') {
- return &mt('Paste failed: an error occurred saving the folder or page.');
- }
+ return &mt('Paste failed: an error occurred saving the folder or page.');
}
}
}
@@ -1764,23 +1692,16 @@ sub handle_edit_cmd {
sub editor {
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
$supplementalflag,$orderhash,$iconpath,$pathitem)=@_;
- my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
+ my $container= ($env{'form.pagepath'}) ? 'page'
+ : 'sequence';
+ my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order);
if ($allowed) {
- (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
- $is_random_order,$container) =
+ (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
&Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
$r->print($breadcrumbtrail);
- } elsif ($env{'form.folderpath'} =~ /\:1$/) {
- $container = 'page';
- } else {
- $container = 'sequence';
}
- my $jumpto;
-
- unless ($supplementalflag) {
- $jumpto = "'uploaded/$coursedom/$coursenum/$folder.$container'";
- }
+ my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
unless ($allowed) {
$randompick = -1;
@@ -1872,13 +1793,9 @@ sub editor {
push(@imports, [$name, $url, $residx]);
}
}
- ($errtext,$fatal,my $fixuperrors) =
- &group_import($coursenum, $coursedom, $folder,$container,
- 'londocs',@imports);
+ ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
+ $container,'londocs',@imports);
return $errtext if ($fatal);
- if ($fixuperrors) {
- $r->print($fixuperrors);
- }
}
# Loading a complete map
if ($env{'form.loadmap'}) {
@@ -1945,23 +1862,13 @@ sub editor {
unless ($name) { $idx++; next; }
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
$coursenum,$coursedom,$crstype,
- $pathitem,$supplementalflag,$container);
+ $pathitem,$supplementalflag);
$idx++;
$shown++;
}
&Apache::loncommon::end_data_table_count();
if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) {
- my $toolslink = ''
- .&Apache::loncommon::help_open_menu('Navigation Screen',
- 'Navigation_Screen',undef,'RAT')
- .' '.&mt('Tools:').' '
- .'
';
if ($shown) {
if ($allowed) {
$to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
@@ -1979,15 +1886,19 @@ sub editor {
.' '
.&Apache::loncommon::end_scrollbox();
} else {
- $to_show .= $toolslink
+ $to_show = ''.&Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT')
+ .' '.&mt('Tools:').' '
+ .'
'
.&Apache::loncommon::start_data_table('LC_tableOfContent')
.$output.' '
.&Apache::loncommon::end_data_table();
}
} else {
- if (!$allowed) {
- $to_show .= $toolslink;
- }
$to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
.''
.&mt('Currently no documents.')
@@ -2037,7 +1948,7 @@ sub process_file_upload {
my $errtext='';
my $fatal=0;
my $container='sequence';
- if ($env{'form.folderpath'} =~ /:1$/) {
+ if ($env{'form.pagepath'}) {
$container='page';
}
($errtext,$fatal)=
@@ -2127,6 +2038,7 @@ sub process_file_upload {
my $archiveurl = &HTML::Entities::encode($url,'<>&"');
my %archiveitems = (
folderpath => $env{'form.folderpath'},
+ pagepath => $env{'form.pagepath'},
cmd => $nextphase,
newidx => $newidx,
position => $position,
@@ -2181,14 +2093,16 @@ sub is_supplemental_title {
sub entryline {
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
- $crstype,$pathitem,$supplementalflag,$container)=@_;
- my ($foldertitle,$renametitle);
+ $crstype,$pathitem,$supplementalflag)=@_;
+ my ($foldertitle,$pagetitle,$renametitle);
if (&is_supplemental_title($title)) {
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
+ $pagetitle = $foldertitle;
} else {
$title=&HTML::Entities::encode($title,'"<>&\'');
$renametitle=$title;
$foldertitle=$title;
+ $pagetitle=$title;
}
my $orderidx=$LONCAPA::map::order[$index];
@@ -2199,17 +2113,19 @@ sub entryline {
my $line=&Apache::loncommon::start_data_table_row();
my ($form_start,$form_end,$form_common);
# Edit commands
- my ($type, $esc_path, $path, $symb);
- if ($container eq 'page') {
- $type = 'page';
- } else {
- $type = 'folder';
- }
+ my ($container, $type, $esc_path, $path, $symb);
if ($env{'form.folderpath'}) {
+ $type = 'folder';
+ $container = 'sequence';
$esc_path=&escape($env{'form.folderpath'});
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
}
+ if ($env{'form.pagepath'}) {
+ $type = $container = 'page';
+ $esc_path=&escape($env{'form.pagepath'});
+ $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
+ }
my $isexternal;
if ($residx) {
my $currurl = $url;
@@ -2226,7 +2142,7 @@ sub entryline {
&Apache::lonnet::declutter($currurl));
}
}
- my ($renamelink,%lt);
+ my %lt;
if ($allowed) {
my $incindex=$index+1;
my $selectbox='';
@@ -2323,7 +2239,7 @@ sub entryline {
$nocopy=1;
}
}
- my ($copylink,$cutlink,$removelink);
+ my ($copylink,$cutlink,$removelink,$renamelink);
my $skip_confirm = 0;
if ( $folder =~ /^supplemental/
|| ($url =~ m{( /smppg$
@@ -2342,7 +2258,7 @@ sub entryline {
ENDCOPY
} else {
$copylink=(<
$lt{'cp'}
+$lt{'cp'}
ENDCOPY
}
if ($nocut) {
@@ -2351,7 +2267,7 @@ ENDCOPY
ENDCUT
} else {
$cutlink=(<$lt{'ct'}
+$lt{'ct'}
ENDCUT
}
if ($noremove) {
@@ -2360,14 +2276,12 @@ ENDCUT
ENDREM
} else {
$removelink=(<$lt{'rm'}
+$lt{'rm'}
ENDREM
}
- unless ($isexternal) {
- $renamelink=(<$lt{'rn'}
+ $renamelink=(<$lt{'rn'}
ENDREN
- }
$form_start = '