--- loncom/interface/londocs.pm 2013/01/04 00:11:59 1.527
+++ loncom/interface/londocs.pm 2013/08/05 12:56:58 1.555
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.527 2013/01/04 00:11:59 raeburn Exp $
+# $Id: londocs.pm,v 1.555 2013/08/05 12:56:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,7 +40,6 @@ use Apache::lonxml;
use Apache::lonclonecourse;
use Apache::lonnavmaps;
use Apache::lonnavdisplay();
-use Apache::lonuserstate();
use Apache::lonextresedit();
use HTML::Entities;
use HTML::TokeParser;
@@ -153,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);
@@ -271,7 +270,9 @@ 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)$})
@@ -288,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;
}
@@ -297,6 +298,24 @@ sub group_import {
}
}
if ($url) {
+ if (($caller eq 'londocs') &&
+ ($folder =~ /^default/)) {
+ if (($url =~ /\.(page|sequence)$/) && (!$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);
@@ -304,13 +323,86 @@ sub group_import {
}
my $ext = 'false';
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
- $url = &LONCAPA::map::qtunescape($url);
$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+$/) {
+ $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
+
+