--- loncom/interface/loncommon.pm 2013/04/11 16:30:37 1.1122 +++ loncom/interface/loncommon.pm 2013/04/24 02:43:59 1.1123 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1122 2013/04/11 16:30:37 bisitz Exp $ +# $Id: loncommon.pm,v 1.1123 2013/04/24 02:43:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -7813,9 +7813,11 @@ sub LCprogressbar { $LCcurrentid=$$.'_'.$LCidcnt; my $starting=&mt('Starting'); my $content=(<
$starting
+

ENDPROGBAR &r_print($r,$content.&LCprogressbar_script($LCcurrentid)); } @@ -9558,18 +9560,23 @@ sub ask_for_embedded_content { my $heading = &mt('Upload embedded files'); my $buttontext = &mt('Upload'); - my $navmap; + my ($navmap,$cdom,$cnum); if ($env{'request.course.id'}) { - $navmap = Apache::lonnavmaps::navmap->new(); + if ($actionurl eq '/adm/dependencies') { + $navmap = Apache::lonnavmaps::navmap->new(); + } + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; } - if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { + if (($actionurl eq '/adm/portfolio') || + ($actionurl eq '/adm/coursegrp_portfolio')) { my $current_path='/'; if ($env{'form.currentpath'}) { $current_path = $env{'form.currentpath'}; } if ($actionurl eq '/adm/coursegrp_portfolio') { - $udom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - $uname = $env{'course.'.$env{'request.course.id'}.'.num'}; + $udom = $cdom; + $uname = $cnum; $url = '/userfiles/groups/'.$env{'form.group'}.'/portfolio'; } else { $udom = $env{'user.domain'}; @@ -9601,8 +9608,6 @@ sub ask_for_embedded_content { } } elsif ($actionurl eq '/adm/dependencies') { if ($env{'request.course.id'} ne '') { - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; if (ref($args) eq 'HASH') { $url = $args->{'docs_url'}; $title = $args->{'docs_title'}; @@ -9616,8 +9621,15 @@ sub ask_for_embedded_content { $heading = &mt('Status of dependencies in [_1]',"$title ($filename)"); } } + } elsif ($actionurl eq "/public/$cdom/$cnum/syllabus") { + $udom = $cdom; + $uname = $cnum; + $url = "/uploaded/$cdom/$cnum/portfolio/syllabus"; + $toplevel = $url; + $path = $url; + $fileloc = &Apache::lonnet::filelocation('',$toplevel).'/'; + $fileloc =~ s{^/}{}; } - my $now = time(); foreach my $embed_file (keys(%{$allfiles})) { my $absolutepath; if ($embed_file =~ m{^\w+://}) { @@ -9656,7 +9668,8 @@ sub ask_for_embedded_content { my $dirptr = 16384; foreach my $path (keys(%subdependencies)) { $currsubfile{$path} = {}; - if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { + if (($actionurl eq '/adm/portfolio') || + ($actionurl eq '/adm/coursegrp_portfolio')) { my ($sublistref,$listerror) = &Apache::lonnet::dirlist($url.$path,$udom,$uname,$getpropath); if (ref($sublistref) eq 'ARRAY') { @@ -9672,9 +9685,15 @@ sub ask_for_embedded_content { } } elsif (($actionurl eq '/adm/dependencies') || (($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && - ($args->{'context'} eq 'paste'))) { + ($args->{'context'} eq 'paste')) || + ($actionurl eq "/public/$cdom/$cnum/syllabus")) { if ($env{'request.course.id'} ne '') { - my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); + my $dir; + if ($actionurl eq "/public/$cdom/$cnum/syllabus") { + $dir = $fileloc; + } else { + ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); + } if ($dir ne '') { my ($sublistref,$listerror) = &Apache::lonnet::dirlist($dir.$path,$cdom,$cnum,$getpropath,undef,'/'); @@ -9722,7 +9741,8 @@ sub ask_for_embedded_content { } } my %currfile; - if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { + if (($actionurl eq '/adm/portfolio') || + ($actionurl eq '/adm/coursegrp_portfolio')) { my ($dirlistref,$listerror) = &Apache::lonnet::dirlist($url,$udom,$uname,$getpropath); if (ref($dirlistref) eq 'ARRAY') { @@ -9738,7 +9758,8 @@ sub ask_for_embedded_content { } } elsif (($actionurl eq '/adm/dependencies') || (($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && - ($args->{'context'} eq 'paste'))) { + ($args->{'context'} eq 'paste')) || + ($actionurl eq "/public/$cdom/$cnum/syllabus")) { if ($env{'request.course.id'} ne '') { my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); if ($dir ne '') { @@ -9787,28 +9808,38 @@ sub ask_for_embedded_content { ($args->{'context'} eq 'paste')) { $counter = scalar(keys(%existing)); $numpathchg = scalar(keys(%pathchanges)); - return ($output,$counter,$numpathchg,\%existing); + return ($output,$counter,$numpathchg,\%existing); + } elsif (($actionurl eq "/public/$cdom/$cnum/syllabus") && + (ref($args) eq 'HASH') && ($args->{'context'} eq 'rewrites')) { + $counter = scalar(keys(%existing)); + $numpathchg = scalar(keys(%pathchanges)); + return ($output,$counter,$numpathchg,\%existing,\%mapping); } foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%newfiles)) { if ($actionurl eq '/adm/dependencies') { next if ($embed_file =~ m{^\w+://}); } $upload_output .= &start_data_table_row(). - ' '. + ' '. ''.$embed_file.''; unless ($mapping{$embed_file} eq $embed_file) { - $upload_output .= '
'.&mt('changed from: [_1]',$mapping{$embed_file}).''; + $upload_output .= '
'. + &mt('changed from: [_1]',$mapping{$embed_file}).''; } - $upload_output .= ''; + $upload_output .= ''; if ($args->{'ignore_remote_references'} && $embed_file =~ m{^\w+://}) { - $upload_output.=''.&mt("URL points to other server.").''; + $upload_output.=''. + ''. + &mt("URL points to web address").''; $numremref++; } elsif ($args->{'error_on_invalid_names'} && $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) { - $upload_output.=''.&mt('Invalid characters').''; + $upload_output.=''. + &mt('Invalid characters').''; $numinvalid++; } else { - $upload_output .= &embedded_file_element('upload_embedded',$counter, + $upload_output .= ''. + &embedded_file_element('upload_embedded',$counter, $embed_file,\%mapping, $allfiles,$codebase,'upload'); $counter ++; @@ -9837,8 +9868,9 @@ sub ask_for_embedded_content { $counter ++; } else { $upload_output .= &start_data_table_row(). - ''.$embed_file.''; - ''.&mt('Already exists').''. + ' '. + ''.$embed_file.''. + ''.&mt('Already exists').''. &Apache::loncommon::end_data_table_row()."\n"; } } @@ -9933,7 +9965,7 @@ sub ask_for_embedded_content { $output = ''.&mt('Referenced files').':
'; if ($applies > 1) { $output .= - &mt('No files need to be uploaded, as one of the following applies to each reference:').'