--- loncom/interface/londocs.pm 2010/01/13 14:32:57 1.412 +++ loncom/interface/londocs.pm 2010/12/25 04:40:15 1.434.2.3 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.412 2010/01/13 14:32:57 wenzelju Exp $ +# $Id: londocs.pm,v 1.434.2.3 2010/12/25 04:40:15 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -120,14 +120,19 @@ sub dumpbutton { my $crstype = &Apache::loncommon::course_type(); if ($home+$other==0) { return ''; } if ($home) { - my $link = "".&mt('Dump '.$crstype.' DOCS to Construction Space').""; - return $link.' '. - &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').'
'; - } else { - return '
'. - &mt('Dump '.$crstype. - ' DOCS to Construction Space: available on other servers'). - '
'; + my $link = + "" + .&mt('Dump '.$crstype.' Documents to Construction Space') + .''; + return + $link.' ' + .&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs') + .'
'; + } else { + return + &mt('Dump '.$crstype.' Documents to Construction Space: available on other servers'); } } @@ -142,9 +147,9 @@ sub clean { sub dumpcourse { my ($r) = @_; my $crstype = &Apache::loncommon::course_type(); - $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' DOCS to Construction Space'). + $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Documents to Construction Space'). '
'); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' DOCS to Construction Space')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' Documents to Construction Space')); my ($home,$other,%outhash)=&authorhosts(); unless ($home) { return ''; } my $origcrsid=$env{'request.course.id'}; @@ -255,7 +260,7 @@ sub dumpcourse { $r->print(&Apache::loncommon::end_data_table()); &untiehash(); $r->print( - '

'); + '

'); } } @@ -263,7 +268,7 @@ sub dumpcourse { sub exportbutton { my $crstype = &Apache::loncommon::course_type(); - return "".&mt('IMS Export')."". + return "".&mt('IMS Export')."". &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'
'; } @@ -341,20 +346,20 @@ sub exportcourse { open(OUTPUT, "zip -r $imszip * 2> /dev/null |"); close(OUTPUT); chdir $cwd; + $outcome .= '

' + .&mt('[_1]Your IMS package[_2] is ready for download.' + ,'','') + .'

'; if ($copyresult) { $outcome .= '

' .&mt('The following errors occurred during export - [_1]' ,$copyresult) .'

'; } - $outcome .= '

' - .&mt('[_1]Your IMS package[_2] is ready for download.' - ,'','') - .'

'; } else { $outcome = '

' .&mt('Unfortunately you will not be able to retrieve' - .' an IMS archive of this posts at this time,' + .' an IMS archive of your course at this time,' .' because there was a problem creating a' .' manifest file.') .'

' @@ -368,24 +373,26 @@ sub exportcourse { $r->print($outcome); $r->print(&Apache::loncommon::end_page()); } else { - my $display; - $display = '
'."\n"; - $display .= '

' - .&mt('Choose which items you wish to export from your '.$crstype.'.') - .'

'; - $display .= '
'. + my $display=''."\n". + '

'. + &mt('Choose which items you wish to export from your '.$crstype.'.'). + '

'. + '
'. ''.&mt('Content items').''. ''. '  
'. - '
'. - ''.&mt('Discussion posts').''. - ''. - '  '. - '
'; + ' onclick="javascript:uncheckAll(document.exportdoc.archive)" />
'; + if ($numdisc > 0) { + $display .= '
'. + ''.&mt('Discussion posts').''. + ''. + '  '. + '
'; + } + $display .= '
'; my $curRes; my $depth = 0; my $count = 0; @@ -396,15 +403,11 @@ sub exportcourse { my $lastcontainer = $startcount; $display .= &Apache::loncommon::start_data_table() .&Apache::loncommon::start_data_table_header_row() - .''.&mt('Export content item?').'' - .''; + .''.&mt('Export content item?').''; if ($numdisc > 0) { - $display .= &mt('Export discussion posts?'); - } else { - $display .= ' '; + $display .= ''.&mt('Export discussion posts?').''; } - $display .= '' - .&Apache::loncommon::end_data_table_header_row(); + $display .= &Apache::loncommon::end_data_table_header_row(); while ($curRes = $it->next()) { if (ref($curRes)) { $count ++; @@ -425,37 +428,33 @@ sub exportcourse { $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; } } + my $currelem = $count+$boards+$startcount; $display .= &Apache::loncommon::start_data_table_row() .''."\n" .'is_sequence()) || ($curRes->is_page())) { - my $checkitem = $count + $boards + $startcount; - $display .= 'onclick="javascript:propagateCheck('."'$checkitem'".')"'; + $lastcontainer = $currelem; + $display .= 'onclick="javascript:propagateCheck('."'$currelem'".')"'; } $display .= ' />'."\n"; for (my $i=0; $i<$depth; $i++) { - $display .= '' - .''."\n"; + $display .= ('' x2)."\n"; } if ($curRes->is_sequence()) { $display .= ' '."\n"; - $lastcontainer = $count + $startcount + $boards; } elsif ($curRes->is_page()) { $display .= ' '."\n"; - $lastcontainer = $count + $startcount + $boards; } - my $currelem = $count+$boards+$startcount; $children{$parent{$depth}} .= $currelem.':'; $display .= ' '.$curRes->title().''."\n"; # Existing discussion posts? if ($discussiontime{$ressymb} > 0) { $boards ++; - $currelem = $count+$boards+$startcount; $display .= '' .'' .''."\n"; - } else { + } elsif ($numdisc > 0) { $display .= ' '."\n"; } $display .= &Apache::loncommon::end_data_table_row(); @@ -1608,13 +1607,12 @@ sub editor { my $shown=0; if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) { $r->print('
'. - '

'.&mt('Parameters:'). - '

'); + ''); if ($randompick>=0) { $r->print('

' .&mt('Caution: this folder is set to randomly pick a subset' @@ -1638,7 +1636,9 @@ sub editor { $r->print('

'); } - my $output; + my $output; + + &Apache::loncommon::start_data_table_count(); #setup a row counter foreach my $res (@LONCAPA::map::order) { my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); $name=&LONCAPA::map::qtescape($name); @@ -1650,6 +1650,8 @@ sub editor { $idx++; $shown++; } + &Apache::loncommon::end_data_table_count(); + if ($shown) { $r->print(&Apache::loncommon::start_data_table()); if ($allowed) { @@ -1680,11 +1682,10 @@ sub editor { sub process_file_upload { my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; # upload a file, if present - my $parseaction; - if ($env{'form.parserflag'}) { + my ($parseaction,$showupload,$nextphase,$mimetype); + if ($env{'form.parserflag'}) { $parseaction = 'parse'; } - my $phase_status; my $folder=$env{'form.folder'}; if ($folder eq '') { $folder='default'; @@ -1703,7 +1704,8 @@ sub process_file_upload { $LONCAPA::map::resources[1]=''; } if ($fatal) { - return 'failed'; + $$upload_output = '

'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'

'; + return; } my $destination = 'docs/'; if ($folder =~ /^supplemental/) { @@ -1714,13 +1716,23 @@ sub process_file_upload { } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { $destination .= $2.'/'; } -# this is for a course, not a user, so set coursedoc flag -# probably the only place in the system where this should be "1" +# this is for a course, not a user, so set context to coursedoc. my $newidx=&LONCAPA::map::getresidx(); $destination .= $newidx; - my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination, + my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination, $parseaction,$allfiles, - $codebase); + $codebase,undef,undef,undef,undef, + undef,undef,\$mimetype); + if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) { + my $stored = $1; + $showupload = '

'.&mt('Uploaded [_1]',''. + $stored.'').'

'; + } else { + my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$}); + + $$upload_output = '

'.&mt('Unable to save file [_1].',''.$filename.'').'

'; + return; + } my $ext='false'; if ($url=~m{^http://}) { $ext='true'; } $url = &LONCAPA::map::qtunescape($url); @@ -1737,51 +1749,37 @@ sub process_file_upload { ($errtext,$fatal)=&storemap($coursenum,$coursedom, $folder.'.'.$container); if ($fatal) { - $$upload_output .= '

'.$errtext.'

'; - return 'failed'; + $$upload_output = '

'.$errtext.'

'; + return; } else { - if ($parseaction eq 'parse') { + if ($parseaction eq 'parse' && $mimetype eq 'text/html') { + $$upload_output = $showupload; my $total_embedded = scalar(keys(%{$allfiles})); if ($total_embedded > 0) { - my $num = 0; - my $state = ' - - - - - '; - $phase_status = 'phasetwo'; - - $$upload_output .= - 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.
'. - &Apache::loncommon::ask_for_embedded_content( - '/adm/coursedocs',$state,$allfiles,$codebase); + my $uploadphase = 'upload_embedded'; + my $primaryurl = &HTML::Entities::encode($url,'<>&"'); + my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx); + my ($embedded,$num) = + &Apache::loncommon::ask_for_embedded_content( + '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url}); + if ($embedded) { + if ($num) { + $$upload_output .= + '

'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'

'.$embedded; + $nextphase = $uploadphase; + } else { + $$upload_output .= $embedded; + } + } else { + $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'
'; + } } else { - $$upload_output .= 'No embedded items identified
'; + $$upload_output .= &mt('No embedded items identified').'
'; } } } } - return $phase_status; -} - -sub process_secondary_uploads { - my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_; - my $folder=$env{'form.folder'}; - my $destination = 'docs/'; - if ($folder =~ /^supplemental/) { - $destination = 'supplemental/'; - } - if (($folder eq 'default') || ($folder eq 'supplemental')) { - $destination .= 'default/'; - } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { - $destination .= $2.'/'; - } - $destination .= $newidx; - my ($url,$filename); - $url=&Apache::lonnet::userfileupload($formname.$num,1,$destination); - ($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$}); - return $filename; + return $nextphase; } sub is_supplemental_title { @@ -1802,6 +1800,7 @@ sub parse_supplemental_title { $foldertitle=&Apache::lontexconvert::msgtexconverted($4); my $name = &Apache::loncommon::plainname($uname,$udom); $name = &HTML::Entities::encode($name,'"<>&\''); + $renametitle = &HTML::Entities::encode($renametitle,'"<>&\''); $title=''.&Apache::lonlocal::locallocaltime($time).' '. $name.':
'.$foldertitle; } @@ -1845,7 +1844,7 @@ sub entryline { } if ($env{'form.pagepath'}) { $type = $container = 'page'; - $esc_path=&escape($path = $env{'form.pagepath'}); + $esc_path=&escape($env{'form.pagepath'}); $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"'); $symb=&escape($env{'form.pagesymb'}); } @@ -2249,19 +2248,17 @@ sub list_symbs { } else { $r->print("
\n");
         foreach my $res ($navmap->retrieveResources()) {
-	    $r->print($res->compTitle()."\t".$res->symb()."\n");
+            $r->print($res->compTitle()."\t".$res->symb()."\n");
         }
         $r->print("\n
\n"); } - $r->print(''.&mt('Return to DOCS').''); + $r->print('
'.&mt('Back to Course Editor').''); } sub verifycontent { my ($r) = @_; my $crstype = &Apache::loncommon::course_type(); - my $loaderror=&Apache::lonnet::overloaderror($r); - if ($loaderror) { return $loaderror; } $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents')); $hashtied=0; @@ -2272,9 +2269,9 @@ sub verifycontent { if ($hash{$key}=~/\.(page|sequence)$/) { if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) { $r->print('
'. - &mt('The following sequence or page is included more than once in your '.$crstype.': '). + &mt('The following sequence or page is included more than once in your '.$crstype.':').' '. &unescape($hash{$key}).'
'. - &mt('Note that grading records for problems included in this sequence or folder will overlap.
')); + &mt('Note that grading records for problems included in this sequence or folder will overlap.').'
'); } } if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) { @@ -2282,8 +2279,13 @@ sub verifycontent { } } &untiehash(); - $r->print('

'.&mt('Done').'.

'.''. - &mt('Return to DOCS').''); + $r->print( + '

'.&mt('Done').'

' + .'
' + .'

' + .&mt('Back to Course Editor') + .'

' + ); } @@ -2475,11 +2477,11 @@ ENDHEADERS # Set version $r->print(&Apache::loncommon::select_form($setversions{$linkurl}, 'set_version_'.$linkurl, - ('select_form_order' => + {'select_form_order' => ['',1..$currentversion,'mostrecent'], '' => '', 'mostrecent' => &mt('most recent'), - map {$_,$_} (1..$currentversion)))); + map {$_,$_} (1..$currentversion)})); $r->print(''); my $lastold=1; for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { @@ -2533,7 +2535,7 @@ ENDHEADERS } } $r->print('
'); - $r->print('

'.&mt('Done').'.

'); + $r->print('

'.&mt('Done').'

'); &untiehash(); } @@ -2657,7 +2659,7 @@ sub handler { &init_breadcrumbs('versions','Check/Set Resource Versions'); &checkversions($r); } elsif ($allowed && $env{'form.dumpcourse'}) { - &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space'); + &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Documents to Construction Space'); &dumpcourse($r); } elsif ($allowed && $env{'form.exportcourse'}) { &init_breadcrumbs('exportcourse','IMS Export'); @@ -2712,9 +2714,22 @@ sub handler { $env{'form.pagename'}=&unescape(pop(@pagepath)); $env{'form.folder'}=pop(@pagepath); $containertag = ''. - ''; - $uploadtag = ''. - ''; + ''; + $uploadtag = + ''. + ''. + ''; + } else { + my $folderpath=$env{'form.folderpath'}; + if (!$folderpath) { + if ($env{'form.folder'} eq '' || + $env{'form.folder'} eq 'supplemental') { + $folderpath='default&'. + &escape(&mt('Main '.$crstype.' Documents')); + } + } + $containertag = ''; + $uploadtag = ''; } if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) { $showdoc='/'.$1; @@ -2806,110 +2821,67 @@ sub create_form_ul { my %allfiles = (); my %codebase = (); - my ($upload_result,$upload_output); + my ($upload_result,$upload_output,$uploadphase); if ($allowed) { if (($env{'form.uploaddoc.filename'}) && ($env{'form.cmd'}=~/^upload_(\w+)/)) { -# Process file upload - phase one - upload and parse primary file. - undef($hadchanges); - $upload_result = &process_file_upload(\$upload_output,$coursenum, - $coursedom,\%allfiles, - \%codebase,$1); + my $context = $1; + # Process file upload - phase one - upload and parse primary file. + undef($hadchanges); + $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom, + \%allfiles,\%codebase,$context); if ($hadchanges) { &mark_hash_old(); } - if ($upload_result eq 'phasetwo') { - $r->print($upload_output); - } - } elsif ($env{'form.phasetwo'}) { - my %newname = (); - my %origname = (); - my %attribs = (); - my $updateflag = 0; - my $residx = $env{'form.newidx'}; - my $primary_url = &unescape($env{'form.primaryurl'}); -# Process file upload - phase two - gather secondary files. - for (my $i=0; $i<$env{'form.phasetwo'}; $i++) { - if ($env{'form.embedded_item_'.$i.'.filename'}) { - my $javacodebase; - $newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx); - $origname{$i} = &unescape($env{'form.embedded_orig_'.$i}); - if (exists($env{'form.embedded_codebase_'.$i})) { - $javacodebase = &unescape($env{'form.embedded_codebase_'.$i}); - $origname{$i} =~ s#^\Q$javacodebase\E/##; - } - my @attributes = (); - if ($env{'form.embedded_attrib_'.$i} =~ /:/) { - @attributes = split(/:/,$env{'form.embedded_attrib_'.$i}); - } else { - @attributes = ($env{'form.embedded_attrib_'.$i}); - } - foreach my $attr (@attributes) { - push(@{$attribs{$i}},&unescape($attr)); - } - if ($javacodebase) { - $codebase{$i} = $javacodebase; - $codebase{$i} =~ s#/$##; - $updateflag = 1; - } - } - unless ($newname{$i} eq $origname{$i}) { - $updateflag = 1; - } - } -# Process file upload - phase three - modify primary file - if ($updateflag) { - my ($content,$rtncode); - my $updateflag = 0; - my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode); - if ($getstatus eq 'ok') { - foreach my $item (keys(%newname)) { - if ($newname{$item} ne $origname{$item}) { - my $attrib_regexp = ''; - if (@{$attribs{$item}} > 1) { - $attrib_regexp = join('|',@{$attribs{$item}}); - } else { - $attrib_regexp = $attribs{$item}[0]; - } - if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) { - } - $content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi; - } - if (exists($codebase{$item})) { - $content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs - } - } -# Save edited file. - my $saveresult; - my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; - my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; - my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult); - } else { - &Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus); - } - } + $r->print($upload_output); + } elsif ($env{'form.phase'} eq 'upload_embedded') { + # Process file upload - phase two - upload embedded objects + $uploadphase = 'check_embedded'; + my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"'); + my $state = &embedded_form_elems($uploadphase,$primaryurl, + $env{'form.newidx'}); + my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; + my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; + my ($destination,$dir_root) = &embedded_destination(); + my $url_root = '/uploaded/'.$docudom.'/'.$docuname; + my $actionurl = '/adm/coursedocs'; + my ($result,$flag) = + &Apache::loncommon::upload_embedded('coursedoc',$destination, + $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state, + $actionurl); + $r->print($result.&return_to_editor()); + } elsif ($env{'form.phase'} eq 'check_embedded') { + # Process file upload - phase three - modify references in HTML file + $uploadphase = 'modified_orightml'; + my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; + my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; + my ($destination,$dir_root) = &embedded_destination(); + $r->print(&Apache::loncommon::modify_html_refs('coursedoc',$destination, + $docuname,$docudom,undef, + $dir_root). + &return_to_editor()); } } - unless ($showdoc || $upload_result eq 'phasetwo') { + unless ($showdoc || $uploadphase) { # ----------------------------------------------------------------------------- my %lt=&Apache::lonlocal::texthash( 'uplm' => 'Upload a new main '.lc($crstype).' document', 'upls' => 'Upload a new supplemental '.lc($crstype).' document', 'impp' => 'Import a document', 'copm' => 'All documents out of a published map into this folder', - 'upld' => 'Upload Document', + 'upld' => 'Import Document', 'srch' => 'Search', 'impo' => 'Import', 'book' => 'Import Bookmarks', 'selm' => 'Select Map', 'load' => 'Load Map', - 'reco' => 'Recover Deleted Resources', + 'reco' => 'Recover Deleted Documents', 'newf' => 'New Folder', 'newp' => 'New Composite Page', 'extr' => 'External Resource', 'syll' => 'Syllabus', - 'navc' => 'Navigate Contents', + 'navc' => 'Table of Contents', 'sipa' => 'Simple Course Page', 'sipr' => 'Simple Problem', 'drbx' => 'Drop Box', @@ -2952,7 +2924,7 @@ CHBO $fileupload
$lt{'title'}:
- + $uploadtag
@@ -2972,9 +2944,9 @@ FUFORM SEDFFORM my @simpleeditdefaultforma = ( - { ''.$lt{srch}.'' => "$uploadtag$lt{'srch'}" }, - { ''.$lt{impo}.'' => "$lt{'impo'}$help{'Importing_LON-CAPA_Resource'}" }, - { ''.$lt{book}.'' => "$lt{'book'}" }, + { ''.$lt{srch}.'' => "$uploadtag$lt{'srch'}" }, + { ''.$lt{impo}.'' => "$lt{'impo'}$help{'Importing_LON-CAPA_Resource'}" }, + { ''.$lt{book}.'' => "$lt{'book'}" }, ); $simpleeditdefaultform .= create_form_ul(create_list_elements(@simpleeditdefaultforma)); $simpleeditdefaultform .=(< $uploadtag - $lt{'extr'}$help{'Adding_External_Resource'} + $lt{'extr'}$help{'Adding_External_Resource'} ERFORM @@ -3007,18 +2979,6 @@ ERFORM 'sl' => 'Show Log' ); - my $folderpath=$env{'form.folderpath'}; - if (!$folderpath) { - if ($env{'form.folder'} eq '' || - $env{'form.folder'} eq 'supplemental') { - $folderpath='default&'. - &escape(&mt('Main '.$crstype.' Documents')); - } - } - unless ($env{'form.pagepath'}) { - $containertag = ''; - $uploadtag = ''; - } $r->print(< @@ -3055,14 +3015,16 @@ HIDDENFORM $activeClass = 0; } } - $r->print('
  • '.$tabtitles{'main'}{$crstype}.'
  • '); + $r->print('
  • '.$tabtitles{'main'}{$crstype}.'
  • '); $active = ''; if (!$forcestandard || ($env{'form.folderpath'}=~/^supplemental/)) { if($activeClass == 1){ $active = 'class="active"'; } } - $r->print('
  • '.$tabtitles{'supplemental'}{$crstype}.'
  • '); + $r->print('
  • '.$tabtitles{'supplemental'}{$crstype}.'
  • '); $r->print(''); } else { $r->print('
    '); @@ -3110,14 +3072,14 @@ HIDDENFORM my $recoverform=(< - $lt{'reco'} + $lt{'reco'} RFORM my $imspform=(< - $lt{'imsf'} + $lt{'imsf'} IMSPFORM @@ -3127,7 +3089,7 @@ IMSPFORM $uploadtag - $lt{'navc'} + $lt{'navc'} $help{'Navigate_Content'} NNFORM @@ -3136,7 +3098,7 @@ NNFORM $uploadtag - $lt{'sipa'} + $lt{'sipa'} $help{'Simple Page'} NSPFORM @@ -3146,7 +3108,7 @@ NSPFORM $uploadtag - $lt{'sipr'} + $lt{'sipr'} $help{'Simple Problem'} @@ -3157,7 +3119,7 @@ NSPROBFORM $uploadtag - $lt{'drbx'} + $lt{'drbx'} NDBFORM @@ -3166,7 +3128,7 @@ NDBFORM $uploadtag - $lt{'scuf'} + $lt{'scuf'} $help{'Score_Upload_Form'} NEXUFORM @@ -3176,7 +3138,7 @@ NEXUFORM $uploadtag - $lt{'bull'} + $lt{'bull'} $help{'Bulletin Board'} NBFORM @@ -3187,7 +3149,7 @@ NBFORM $uploadtag - $lt{'mypi'} + $lt{'mypi'} $help{'My Personal Information Page'} NAMFORM @@ -3197,7 +3159,7 @@ NAMFORM $uploadtag - $lt{'abou'} + $lt{'abou'} NASOFORM @@ -3208,7 +3170,7 @@ NASOFORM $uploadtag - $lt{'rost'} + $lt{'rost'} $help{'Course Roster'} NROSTFORM @@ -3226,7 +3188,7 @@ my $newfolderb; - $lt{'newp'} + $lt{'newp'} $help{'Adding_Pages'} NPFORM @@ -3237,7 +3199,7 @@ NPFORM - $lt{'newf'}$help{'Adding_Folders'} + $lt{'newf'}$help{'Adding_Folders'} NFFORM @@ -3247,7 +3209,7 @@ NFFORM $uploadtag - $lt{'syll'} + $lt{'syll'} $help{'Syllabus'} @@ -3259,51 +3221,59 @@ NSYLFORM $uploadtag - $lt{'grpo'} + $lt{'grpo'} $help{'Group Portfolio'} NGFFORM @specialdocumentsforma=( - {''.$lt{newp}.''=>$newpageform}, - {''.$lt{syll}.''=>$newsylform}, - {''.$lt{grpo}.''=>$newgroupfileform}, - ); - - } - push @specialdocumentsforma, ({''.$lt{navc}.''=>$newnavform}, - {''.$lt{sipa}.''=>$newsmppageform}, - {''.$lt{sipr}.''=>$newsmpproblemform}, - {''.$lt{drbx}.''=>$newdropboxform}, - {''.$lt{scuf}.''=>$newexuploadform}, - {''.$lt{bull}.''=>$newbulform}, - {''.$lt{mypi}.''=>$newaboutmeform}, - {''.$lt{abou}.''=>$newaboutsomeoneform}, - {''.$lt{rost}.''=>$newrosterform},); + {''.$lt{newp}.''=>$newpageform}, + {''.$lt{syll}.''=>$newsylform}, + {''.$lt{grpo}.''=>$newgroupfileform}, + ); + + my @importdoc = ( + {''.$lt{extr}.''=>$extresourcesform}, + {''.$lt{imsf}.''=>$imspform},); + $fileuploadform = create_form_ul(create_list_elements(@importdoc)) . '
    ' . $fileuploadform; + + push @specialdocumentsforma, ({''.$lt{navc}.''=>$newnavform}, + {''.$lt{sipa}.''=>$newsmppageform}, + {''.$lt{sipr}.''=>$newsmpproblemform}, + {''.$lt{drbx}.''=>$newdropboxform}, + {''.$lt{scuf}.''=>$newexuploadform}, + {''.$lt{bull}.''=>$newbulform}, + {''.$lt{mypi}.''=>$newaboutmeform}, + {''.$lt{abou}.''=>$newaboutsomeoneform}, + {''.$lt{rost}.''=>$newrosterform},); $specialdocumentsform = create_form_ul(create_list_elements(@specialdocumentsforma)); + } if($env{'form.pagepath'}) { @specialdocumentsforma=( - {''.&mt('Simple Problem').''=>$newsmpproblemform}, - {''.&mt('Score Upload Form').''=>$newexuploadform} + {''.&mt('Simple Problem').''=>$newsmpproblemform}, + {''.&mt('Score Upload Form').''=>$newexuploadform} ); $specialdocumentsform= create_form_ul(create_list_elements(@specialdocumentsforma)); } my @tools = ( - {''.$lt{extr}.''=>$extresourcesform}, - {''.$lt{imsf}.''=>$imspform}, - {''.$lt{reco}.''=>$recoverform}, +# {''.$lt{extr}.''=>$extresourcesform}, +# {''.$lt{imsf}.''=>$imspform}, + {''.$lt{reco}.''=>$recoverform}, ); my %orderhash = ( - '00' => ['Newfolder',$newfolderform], - 'aa' => ['Upload Document',$fileuploadform], + 'aa' => ['Import Documents',$fileuploadform], 'bb' => ['Published Resources',$simpleeditdefaultform], 'cc' => ['Special Documents',$specialdocumentsform], - 'dd' => ['Tools', create_form_ul(create_list_elements(@tools)).&generate_admin_options($containertag,$uploadtag,\%help,\%env)], + 'dd' => ['Tools', create_form_ul(create_list_elements(@tools)).&generate_admin_options(\%help,\%env)], ); +unless($env{'form.pagepath'}) { + $orderhash{'00'} = ['Newfolder',$newfolderform]; +} + my $tid='1'; $hadchanges=0; my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype); @@ -3319,8 +3289,6 @@ $r->print(&generate_edit_table($tid,\%or $r->print(''); } - if ($env{'form.pagepath'}) { - } # ----------------------------------------------------- Supplemental documents $active = 'style="display: none;"'; if($activeClass == 1){ @@ -3370,7 +3338,7 @@ SUPDOCFORM - $lt{'newf'} + $lt{'newf'} $help{'Adding_Folders'} SNFFORM @@ -3381,7 +3349,7 @@ SNFFORM - $lt{'extr'} $help{'Adding_External_Resource'} + $lt{'extr'} $help{'Adding_External_Resource'} SNEFORM @@ -3391,7 +3359,7 @@ SNEFORM - $lt{'syll'} + $lt{'syll'} $help{'Syllabus'} SNSFORM @@ -3402,20 +3370,26 @@ SNSFORM - $lt{'mypi'} + $lt{'mypi'} $help{'My Personal Information Page'} SNAMFORM my @specialdocs = ( - {''.$lt{extr}.''=>$supnewextform}, - {''.$lt{syll}.''=>$supnewsylform}, - {''.$lt{mypi}.''=>$supnewaboutmeform}, + {''.$lt{syll}.'' + =>$supnewsylform}, + {''.$lt{mypi}.'' + =>$supnewaboutmeform}, ); +my @supimportdoc = ( + {''.$lt{extr}.'' + =>$supnewextform}, + ); +$supupdocform = create_form_ul(create_list_elements(@supimportdoc)) . '
    ' . $supupdocform; my %suporderhash = ( '00' => ['Supnewfolder', $supnewfolderform], - 'ee' => ['Upload Document',$supupdocform], + 'ee' => ['Import Documents',$supupdocform], 'ff' => ['Special Documents',create_form_ul(create_list_elements(@specialdocs))] ); @@ -3447,7 +3421,7 @@ $r->print(''); '); } } else { - unless ($upload_result eq 'phasetwo') { + unless ($uploadphase) { # -------------------------------------------------------- This is showdoc mode $r->print("

    ".&mt('Uploaded Document').' - '. &Apache::lonnet::gettitle($r->uri).'

    '. @@ -3460,30 +3434,71 @@ $r->print(''); return OK; } +sub embedded_form_elems { + my ($phase,$primaryurl,$newidx) = @_; + my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); + return < + + + + +STATE +} + +sub embedded_destination { + my $folder=$env{'form.folder'}; + my $destination = 'docs/'; + if ($folder =~ /^supplemental/) { + $destination = 'supplemental/'; + } + if (($folder eq 'default') || ($folder eq 'supplemental')) { + $destination .= 'default/'; + } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { + $destination .= $2.'/'; + } + $destination .= $env{'form.newidx'}; + my $dir_root = '/userfiles'; + return ($destination,$dir_root); +} + +sub return_to_editor { + my $actionurl = '/adm/coursedocs'; + return '

    '."\n". + '
    '."\n". + ''.&mt('Return to Editor'). + '

    '; +} + sub generate_admin_options { - my ($containertag,$uploadtag,$help_ref,$env_ref) = @_; - my %lt=&Apache::lonlocal::texthash( + my ($help_ref,$env_ref) = @_; + my %lt=&Apache::lonlocal::texthash( 'vc' => 'Verify Content', 'cv' => 'Check/Set Resource Versions', 'ls' => 'List Symbs', 'sl' => 'Show Log', 'imse' => 'IMS Export', - 'dcd' => 'Dump Course DOCS to Construction Space: available on other servers' + 'dcd' => 'Dump Course Documents to Construction Space: available on other servers' ); my %help = %{$help_ref}; my %env = %{$env_ref}; my $dumpbut=&dumpbutton(); my $exportbut=&exportbutton(); my @list = ( - {''.$lt{vc}.''=>"$lt{'vc'}$help{'Verify_Content'}"}, - {''.$lt{cv}.''=>"$lt{'cv'}$help{'Check_Resource_Versions'}"}, + {''.$lt{vc}.'' + => "$lt{'vc'}$help{'Verify_Content'}"}, + {''.$lt{cv}.'' + =>"$lt{'cv'}$help{'Check_Resource_Versions'}"}, ); if($dumpbut ne ''){ - push @list, {''.$lt{dcd}.''=>$dumpbut}; + push @list, {''.$lt{dcd}.''=>$dumpbut}; } - push @list, ({''.$lt{imse}.''=>$exportbut}, - {''.$lt{ls}.''=>"$lt{'ls'}"}, - {''.$lt{sl}.''=>"$lt{'sl'}"}, + push @list, ({''.$lt{imse}.'' + =>$exportbut}, + {''.$lt{ls}.'' + =>"$lt{'ls'}"}, + {''.$lt{sl}.'' + =>"$lt{'sl'}"}, ); return '
    '.create_form_ul(create_list_elements(@list)).'
    '; @@ -3500,7 +3515,7 @@ sub generate_edit_table { if($env{'form.active'} ne ''){ $activetab = $env{'form.active'}; } - $form = '
    '; + $form = '
    '; $form .= '
    '; @@ -3561,6 +3578,18 @@ sub editing_js { p_ctr2b => '?[_98]' ); + my $crstype = &Apache::loncommon::course_type(); + my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"'); + my $docs_pagepath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'},'<>&"'); + my $main_container_page; + if ($docs_folderpath eq '') { + if ($docs_pagepath ne '') { + $main_container_page = 1; + } + } + my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents'; + my $toplevelsupp = 'supplemental&Supplemental%20'.$crstype.'%20Documents'; + return <