--- loncom/interface/londocs.pm 2007/05/22 00:38:25 1.273 +++ loncom/interface/londocs.pm 2007/06/29 20:14:18 1.279 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.273 2007/05/22 00:38:25 albertel Exp $ +# $Id: londocs.pm,v 1.279 2007/06/29 20:14:18 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -904,15 +904,16 @@ sub store_template { # Imports the given (name, url) resources into the course # coursenum, coursedom, and folder must precede the list 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/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) && ($caller eq 'londocs')) { + 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 + if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) + && ($caller eq 'londocs') + && (!&Apache::lonnet::stat_file($url))) { + my $errtext = ''; my $fatal = 0; my $newmapstr = ''."\n". @@ -1154,7 +1155,7 @@ sub docs_change_log { for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0]; my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0]; - if ($oldname ne $newname) { + if ($oldname ne '' && $oldname ne $newname) { $r->print(&LONCAPA::map::qtescape($newname)); } } @@ -1184,7 +1185,6 @@ sub docs_change_log { || $shown<=$env{'form.show'})) { last; } } $r->print(&Apache::loncommon::end_data_table()); - $r->print(&Apache::loncommon::end_page()); } sub editor { @@ -1445,13 +1445,14 @@ sub editor { $r->print('

'.&mt('Caution: this folder is set to randomly pick a subset of resources. Adding or removing resources from this folder will change the set of resources that the students see, resulting in spurious or missing credit for completed problems, not limited to ones you modify. Do not modify the contents of this folder if it is in active student use.').'

'); } $r->print(''); - foreach (@LONCAPA::map::order) { - my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$_]); + foreach my $res (@LONCAPA::map::order) { + my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); $name=&LONCAPA::map::qtescape($name); $url=&LONCAPA::map::qtescape($url); unless ($name) { $name=(split(/\//,$url))[-1]; } unless ($name) { $idx++; next; } - $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum)); + $r->print(&entryline($idx,$name,$url,$folder,$allowed,$res, + $coursenum)); $idx++; $shown++; } @@ -1465,11 +1466,19 @@ sub editor { ENDPASTE - $r->print( - ' '.&Apache::loncommon::filedescription( - (split(/\./,$env{'form.markedcopy_url'}))[-1]).': '. - $env{'form.markedcopy_title'}); + $r->print(' '); + + my $type; + if ($env{'form.markedcopy_url'} =~ m{^/adm/wrapper/ext}) { + $type = &mt('External Resource'); + $r->print($type.': '. $env{'form.markedcopy_title'}); + } else { + my $extension = (split(/\./,$env{'form.markedcopy_url'}))[-1]; + my $type = &Apache::loncommon::filedescription($extension); + my $icon = ''; + $r->print($icon.$type.': '. $env{'form.markedcopy_title'}); + } if ($container eq 'page') { $r->print(< @@ -1583,14 +1592,19 @@ sub ask_for_embedded_content { &Apache::loncommon::start_data_table(); my $num = 0; - foreach my $embed_file (keys(%{$allfiles})) { + foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%{$allfiles})) { $upload_output .= &Apache::loncommon::start_data_table_row(). '
'.$embed_file.''; - if ($args->{'error_on_invalid_names'} + if ($args->{'ignore_remote_references'} + && $embed_file =~ m{^\w+://}) { + $upload_output.=''.&mt("URL points to other server.").''; + } elsif ($args->{'error_on_invalid_names'} && $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) { $upload_output.=''.&mt("Invalid characters").''; + } else { + $upload_output .=' '; @@ -1611,7 +1625,8 @@ sub ask_for_embedded_content { } $upload_output .= &Apache::loncommon::end_data_table().'
- + + '.&mt('(only files for which a location has been provided will be uploaded)').' '; return $upload_output; }