--- loncom/interface/londocs.pm 2004/09/09 18:56:01 1.141
+++ loncom/interface/londocs.pm 2004/09/14 01:21:49 1.142
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.141 2004/09/09 18:56:01 albertel Exp $
+# $Id: londocs.pm,v 1.142 2004/09/14 01:21:49 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -440,9 +440,31 @@ sub group_import {
my $coursenum = shift;
my $coursedom = shift;
my $folder = shift;
+ my $container = shift;
+ my $caller = shift;
while (@_) {
my $name = shift;
my $url = shift;
+ if (($url =~ m#^/uploaded/$coursedom/$coursenum/(default_\d+\.)(page|sequence)$#) && ($caller eq 'londocs')) {
+ my $errtext = '';
+ my $fatal = 0;
+ my $newmapstr = '';
+ $ENV{'form.output'}=$newmapstr;
+ my $home=&Apache::lonnet::homeserver($coursenum,$coursedom);
+ my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$home,
+ 'output',$1.$2);
+ if ($result != m|^/uploaded/|) {
+ $errtext.='Map not saved: A network error occured when trying to save the new map. ';
+ $fatal = 2;
+ }
+ if ($fatal) {
+ return ($errtext,$fatal);
+ }
+ }
if ($url) {
my $idx = $#Apache::lonratedt::resources + 1;
$Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
@@ -454,13 +476,18 @@ sub group_import {
join ':', ($name, $url, $ext, 'normal', 'res');
}
}
- return &storemap($coursenum, $coursedom, $folder.'.sequence');
+ return &storemap($coursenum, $coursedom, $folder.'.'.$container);
}
sub breadcrumbs {
my ($where)=@_;
&Apache::lonhtmlcommon::clear_breadcrumbs();
- my (@folders)=split('&',$ENV{'form.folderpath'});
+ my (@folders);
+ if ($ENV{'form.pagepath'}) {
+ @folders = split('&',$ENV{'form.pagepath'});
+ } else {
+ @folders=split('&',$ENV{'form.folderpath'});
+ }
my $folderpath;
while (@folders) {
my $folder=shift(@folders);
@@ -488,8 +515,12 @@ sub editor {
$r->print(&breadcrumbs($folder));
my $errtext='';
my $fatal=0;
+ my $container='sequence';
+ if ($ENV{'form.pagepath'}) {
+ $container='page';
+ }
($errtext,$fatal)=
- &mapread($coursenum,$coursedom,$folder.'.sequence');
+ &mapread($coursenum,$coursedom,$folder.'.'.$container);
if ($#Apache::lonratedt::order<1) {
$Apache::lonratedt::order[0]=1;
$Apache::lonratedt::resources[1]='';
@@ -557,7 +588,7 @@ sub editor {
}
# store the changed version
- ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
+ ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
if ($fatal) {
$r->print('
'.$errtext.'
');
return;
@@ -589,7 +620,7 @@ sub editor {
$Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
$newidx;
- ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
+ ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
if ($fatal) {
$r->print('
'.$errtext.'
');
return;
@@ -623,6 +654,7 @@ sub editor {
$Apache::lonratedt::order[$idx]=$i;
}
} elsif ($cmd eq 'rename') {
+ my $ratstr = $Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]];
my ($rtitle,@rrest)=split(/\:/,
$Apache::lonratedt::resources[
$Apache::lonratedt::order[$idx]]);
@@ -638,7 +670,7 @@ sub editor {
}
# Store the changed version
($errtext,$fatal)=&storemap($coursenum,$coursedom,
- $folder.'.sequence');
+ $folder.'.'.$container);
if ($fatal) {
$r->print('
'.$errtext.'
');
return;
@@ -657,7 +689,7 @@ sub editor {
}
# Store the changed version
($errtext,$fatal)=group_import($coursenum, $coursedom, $folder,
- @imports);
+ $container,'londocs',@imports);
if ($fatal) {
$r->print('
'.$errtext.'
');
return;
@@ -675,7 +707,7 @@ sub editor {
# Store the changed version
($errtext,$fatal)=&storemap($coursenum,$coursedom,
- $folder.'.sequence');
+ $folder.'.'.$container);
if ($fatal) {
$r->print('
'.$errtext.'
');
return;
@@ -709,6 +741,7 @@ sub entryline {
&Apache::lonnet::unescape($title)),'"<>&\'');
my $renametitle=$title;
my $foldertitle=$title;
+ my $pagetitle=$title;
my $orderidx=$Apache::lonratedt::order[$index];
if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) {
$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
@@ -720,11 +753,18 @@ sub entryline {
$renametitle=~s/\"\;/\\\"/g;
my $line='
';
# Edit commands
+ my $container;
my $folderpath;
if ($ENV{'form.folderpath'}) {
+ $container = 'sequence';
$folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'});
# $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
}
+ my $pagepath;
+ if ($ENV{'form.pagepath'}) {
+ $container = 'page';
+ $pagepath=&Apache::lonnet::escape($ENV{'form.pagepath'});
+ }
if ($allowed) {
my $incindex=$index+1;
my $selectbox='';
@@ -746,7 +786,28 @@ sub entryline {
'dw' => 'Move Down',
'rm' => 'Remove',
'rn' => 'Rename');
- $line.=(<
+
+
+