--- loncom/interface/londocs.pm 2013/01/09 04:31:57 1.529
+++ loncom/interface/londocs.pm 2013/03/13 00:29:09 1.536
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.529 2013/01/09 04:31:57 raeburn Exp $
+# $Id: londocs.pm,v 1.536 2013/03/13 00:29:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -152,7 +152,7 @@ sub dumpcourse {
$r->print(&endContentScreen());
return '';
}
- my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
+ my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
$r->print('
'.&mt('Copying Files').'
');
my $title=$env{'form.authorfolder'};
$title=&clean($title);
@@ -289,7 +289,7 @@ sub group_import {
$env{'form.output'}=$newmapstr;
my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
'output',$1.$2);
- if ($result != m|^/uploaded/|) {
+ if ($result !~ m{^/uploaded/}) {
$errtext.='Map not saved: A network error occurred when trying to save the new map. ';
$fatal = 2;
}
@@ -300,7 +300,7 @@ sub group_import {
if ($url) {
if (($caller eq 'londocs') &&
($folder =~ /^default/)) {
- unless ($donechk) {
+ if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
my $cid = $coursedom.'_'.$coursenum;
$allmaps =
@@ -325,6 +325,48 @@ sub group_import {
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
$url = &LONCAPA::map::qtunescape($url);
$name = &LONCAPA::map::qtunescape($name);
+ if ($name eq '') {
+ $name = &mt('Web Page');
+ }
+ if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
+ my $filepath = $1;
+ my $fname = $name;
+ if ($fname =~ /^\W+$/) {
+ $fname = 'web';
+ } else {
+ $fname =~ s/\W/_/g;
+ }
+ if (length($fname > 15)) {
+ $fname = substr($fname,0,14);
+ }
+ my $initialtext = &mt('Replace with your own content.');
+ my $newhtml = <
+
+
+
+$name
+
+
+$initialtext
+
+
+END
+ $env{'form.output'}=$newhtml;
+ my $result =
+ &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
+ 'output',
+ "$filepath/$residx/$fname.html");
+ if ($result =~ m{^/uploaded/}) {
+ $url = $result;
+ if ($filepath =~ /^supplemental/) {
+ $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
+ $env{'user.domain'}.'___&&&___'.$name;
+ }
+ } else {
+ return (&mt('Failed to save new web page.'),1);
+ }
+ }
$LONCAPA::map::resources[$residx] =
join(':', ($name, $url, $ext, 'normal', 'res'));
}
@@ -335,9 +377,10 @@ sub group_import {
removefrommap => \%removefrommap,
removeparam => \%removeparam,
);
- &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
+ my ($result,$msgsarray,$lockerror) =
+ &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
if (keys(%import_errors) > 0) {
- $fixuperrors =
+ $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";
@@ -346,6 +389,18 @@ sub group_import {
}
$fixuperrors .= '
'."\n";
}
+ if (ref($msgsarray) eq 'ARRAY') {
+ if (@{$msgsarray} > 0) {
+ $fixuperrors .= ''.
+ join('
',@{$msgsarray}).
+ '
';
+ }
+ }
+ if ($lockerror) {
+ $fixuperrors .= ''.
+ $lockerror.
+ '
';
+ }
}
my ($errtext,$fatal) =
&storemap($coursenum, $coursedom, $folder.'.'.$container,1);
@@ -735,7 +790,7 @@ sub print_paste_buffer {
$buffer = $type.': '.
&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')';
- } else {
+ } else {
my $icon = &Apache::loncommon::icon($extension);
if ($extension eq 'sequence' &&
$env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
@@ -747,19 +802,36 @@ sub print_paste_buffer {
}
if ($canpaste) {
$r->print('