--- loncom/interface/londocs.pm 2007/07/04 00:21:42 1.286
+++ loncom/interface/londocs.pm 2007/07/12 01:04:36 1.288
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.286 2007/07/04 00:21:42 albertel Exp $
+# $Id: londocs.pm,v 1.288 2007/07/12 01:04:36 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -908,9 +908,7 @@ sub group_import {
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
while (@files) {
- my $name = shift(@files);
- my $url = shift(@files);
- #FIXME check if file exists before overwriting, might be restoring it
+ my ($name, $url, $residx) = @{ shift(@files) };
if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
&& ($caller eq 'londocs')
&& (!&Apache::lonnet::stat_file($url))) {
@@ -934,14 +932,17 @@ sub group_import {
}
}
if ($url) {
- my $idx = &LONCAPA::map::getresidx($url);
- $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
+ if (!$residx
+ || defined($LONCAPA::map::zombies[$residx])) {
+ $residx = &LONCAPA::map::getresidx($url,$residx);
+ push(@LONCAPA::map::order, $residx);
+ }
my $ext = 'false';
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
$url = &LONCAPA::map::qtunescape($url);
$name = &LONCAPA::map::qtunescape($name);
- $LONCAPA::map::resources[$idx] =
- join ':', ($name, $url, $ext, 'normal', 'res');
+ $LONCAPA::map::resources[$residx] =
+ join(':', ($name, $url, $ext, 'normal', 'res'));
}
}
return &storemap($coursenum, $coursedom, $folder.'.'.$container);
@@ -1199,6 +1200,8 @@ sub update_paste_buffer {
if (&is_supplemental_title($title)) {
($title) = &parse_supplemental_title($title);
}
+ $url=~s{http(:|:)//https(:|:)//}{https$2//};
+
&Apache::lonnet::appenv('docs.markedcopy_title' => $title,
'docs.markedcopy_url' => $url);
delete($env{'form.markcopy'});
@@ -1214,15 +1217,17 @@ ENDPASTE
$r->print(' ');
my $type;
- if ($env{'docs.markedcopy_url'} =~ m{^/adm/wrapper/ext}) {
+ if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
$type = &mt('External Resource');
- $r->print($type.': '.&Apache::map::qtescape($env{'docs.markedcopy_title'}));
+ $r->print($type.': '.
+ &LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
+ &LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')');
} else {
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
my $type = &Apache::loncommon::filedescription($extension);
my $icon = '';
- $r->print($icon.$type.': '. &parse_supplemental_title($env{'docs.markedcopy_title'}));
+ $r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
}
if ($container eq 'page') {
$r->print('
@@ -1344,8 +1349,8 @@ sub editor {
if ($env{'form.pastemarked'}) {
# paste resource to end of list
- my $url=$env{'docs.markedcopy_url'};
- my $title=$env{'docs.markedcopy_title'};
+ my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
+ my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
# Maps need to be copied first
if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) {
$title=&mt('Copy of').' '.$title;
@@ -1361,7 +1366,7 @@ sub editor {
}
$title = &LONCAPA::map::qtunescape($title);
my $ext='false';
- if ($url=~/^http\:\/\//) { $ext='true'; }
+ if ($url=~m{^http(|s)://}) { $ext='true'; }
$url = &LONCAPA::map::qtunescape($url);
# Now insert the URL at the bottom
my $newidx=&LONCAPA::map::getresidx($url);
@@ -1435,13 +1440,11 @@ sub editor {
# Group import/search
if ($env{'form.importdetail'}) {
my @imports;
-# &Apache::lonnet::logthis("imp detail ".$env{'form.importdetail'});
foreach (split(/\&/,$env{'form.importdetail'})) {
if (defined($_)) {
- my ($name,$url)=split(/\=/,$_);
- $name=&unescape($name);
- $url=&unescape($url);
- push @imports, $name, $url;
+ my ($name,$url,$residx)=
+ map {&unescape($_)} split(/\=/,$_);
+ push(@imports, [$name, $url, $residx]);
}
}
# Store the changed version
@@ -1556,7 +1559,7 @@ sub process_file_upload {
$parseaction,$allfiles,
$codebase);
my $ext='false';
- if ($url=~/^http\:\/\//) { $ext='true'; }
+ if ($url=~m{^http://}) { $ext='true'; }
$url = &LONCAPA::map::qtunescape($url);
my $comment=$env{'form.comment'};
$comment = &LONCAPA::map::qtunescape($comment);
@@ -1856,7 +1859,9 @@ END
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
}
}
- $url=~s-^http(\&colon\;|:)//-/adm/wrapper/ext/-;
+
+ my $orig_url = $url;
+ my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
my $symb=&Apache::lonnet::symbclean(
&Apache::lonnet::declutter('uploaded/'.
@@ -1879,6 +1884,7 @@ END
}
} elsif ($url=~m|^/ext/|) {
$url='/adm/wrapper'.$url;
+ $external = 1;
}
if (&Apache::lonnet::symbverify($symb,$url)) {
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
@@ -1932,12 +1938,18 @@ END
$url.='pagepath='.&escape($pagepath).
'&pagesymb='.&escape($symb).$cpinfo;
}
+ if ($external) {
+ my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
+ $external = ' '.&mt('Edit').'';
+ } else {
+ undef($external);
+ }
$line.='