--- loncom/interface/londocs.pm 2008/09/11 14:47:21 1.312
+++ loncom/interface/londocs.pm 2008/12/21 15:47:50 1.314.2.2
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.312 2008/09/11 14:47:21 bisitz Exp $
+# $Id: londocs.pm,v 1.314.2.2 2008/12/21 15:47:50 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -228,11 +228,19 @@ sub dumpcourse {
my $title=$origcrsdata{'description'};
$title=~s/[\/\s]+/\_/gs;
$title=&clean($title);
- $r->print('
'.&mt('Folder in Construction Space').'
');
+ $r->print(''.&mt('Folder in Construction Space').'
'
+ .'
');
&tiehash();
- $r->print(''.&mt('Filenames in Construction Space').'
\n");
+ $r->print(&Apache::loncommon::end_data_table());
&untiehash();
$r->print(
- '');
+ '');
}
}
@@ -1271,8 +1280,32 @@ sub do_paste_from_buffer {
if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
$title=&mt('Copy of').' '.$title;
my $newid=$$.time;
- $url=~/^(.+)\.(\w+)$/;
- my $newurl=$1.$newid.'.'.$2;
+ my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
+ if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
+ my $path = $1;
+ my $prefix = $2;
+ my $ancestor = $3;
+ if (length($ancestor) > 10) {
+ $ancestor = substr($ancestor,-10,10);
+ }
+ $oldid = $path.$prefix.$ancestor;
+ }
+ my $counter = 0;
+ my $newurl=$oldid.$newid.'.'.$ext;
+ my $is_unique = &uniqueness_check($newurl);
+ while (!$is_unique && $counter < 100) {
+ $counter ++;
+ $newid ++;
+ $newurl = $oldid.$newid;
+ $is_unique = &uniqueness_check($newurl);
+ }
+ if (!$is_unique) {
+ if ($url=~/\.page$/) {
+ return &mt('Paste failed: an error occurred creating a unique URL for the composite page');
+ } else {
+ return &mt('Paste failed: an error occurred creating a unique URL for the folder');
+ }
+ }
my $storefn=$newurl;
$storefn=~s{^/\w+/$match_domain/$match_username/}{};
&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
@@ -1321,6 +1354,20 @@ sub do_paste_from_buffer {
# Store the result
}
+sub uniqueness_check {
+ my ($newurl) = @_;
+ my $unique = 1;
+ foreach my $res (@LONCAPA::map::order) {
+ my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
+ $url=&LONCAPA::map::qtescape($url);
+ if ($newurl eq $url) {
+ $unique = 0;
+ last;
+ }
+ }
+ return $unique;
+}
+
my %parameter_type = ( 'randompick' => 'int_pos',
'hiddenresource' => 'string_yesno',
'encrypturl' => 'string_yesno',
@@ -1895,7 +1942,7 @@ END
my $ro_set=
((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
$rand_order_text ='
-';
+';
}
if ($ispage) {
my $pagename=&escape($pagetitle);
@@ -1990,6 +2037,9 @@ sub checkonthis {
$r->rflush();
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
$r->print("\n
");
+ if ($level==0) {
+ $r->print("
");
+ }
for (my $i=0;$i<=$level*5;$i++) {
$r->print(' ');
}
@@ -1999,7 +2049,7 @@ sub checkonthis {
my $result=&Apache::lonnet::repcopy(
&Apache::lonnet::filelocation('',$url));
if ($result eq 'ok') {
- $r->print(''.&mt('ok').'');
+ $r->print(''.&mt('ok').'');
$r->rflush();
&Apache::lonnet::countacc($url);
$url=~/\.(\w+)$/;
@@ -2009,7 +2059,7 @@ sub checkonthis {
for (my $i=0;$i<=$level*5;$i++) {
$r->print(' ');
}
- $r->print('- '.&mt('Rendering').': ');
+ $r->print('- '.&mt('Rendering:').' ');
my ($errorcount,$warningcount)=split(/:/,
&Apache::lonnet::ssi_body($url,
('grade_target'=>'web',
@@ -2018,13 +2068,11 @@ sub checkonthis {
($warningcount)) {
if ($errorcount) {
$r->print('
'.
- $errorcount.' '.
- &mt('error(s)').' ');
+ &mt('[quant,_1,error]',$errorcount).'');
}
if ($warningcount) {
$r->print(''.
- $warningcount.' '.
- &mt('warning(s)').'');
+ &mt('[quant,_1,warning]',$warningcount).'');
}
} else {
$r->print(''.&mt('ok').'');
@@ -2042,15 +2090,15 @@ sub checkonthis {
$r->print(''.&mt('connection down').'');
} elsif ($result eq 'not_found') {
unless ($url=~/\$/) {
- $r->print(''.&mt('not found').'');
+ $r->print(''.&mt('not found').'');
} else {
$r->print(''.&mt('unable to verify variable URL').'');
}
} else {
$r->print(''.&mt('access denied').'');
}
- }
- }
+ }
+ }
}