--- loncom/interface/londocs.pm 2009/07/08 07:51:01 1.375 +++ loncom/interface/londocs.pm 2010/08/16 20:52:11 1.434.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.375 2009/07/08 07:51:01 tempelho Exp $ +# $Id: londocs.pm,v 1.434.2.1 2010/08/16 20:52:11 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,6 +35,7 @@ use Apache::Constants qw(:common :http); use Apache::imsexport; use Apache::lonnet; use Apache::loncommon; +use Apache::lonhtmlcommon; use LONCAPA::map(); use Apache::lonratedt(); use Apache::lonxml; @@ -116,17 +117,22 @@ sub authorhosts { sub dumpbutton { my ($home,$other,%outhash)=&authorhosts(); - my $type = &Apache::loncommon::course_type(); + my $crstype = &Apache::loncommon::course_type(); if ($home+$other==0) { return ''; } if ($home) { - return ''. - &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').'
'; - } else { - return '
'. - &mt('Dump '.$type. - ' 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'); } } @@ -140,10 +146,10 @@ sub clean { sub dumpcourse { my ($r) = @_; - my $type = &Apache::loncommon::course_type(); - $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space'). + my $crstype = &Apache::loncommon::course_type(); + $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Documents to Construction Space'). '
'); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$type.' 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'}; @@ -254,16 +260,15 @@ sub dumpcourse { $r->print(&Apache::loncommon::end_data_table()); &untiehash(); $r->print( - '

'); + '

'); } } sub exportbutton { - my $type = &Apache::loncommon::course_type(); - return ''. + my $crstype = &Apache::loncommon::course_type(); + return "".&mt('IMS Export')."". &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'
'; } @@ -271,18 +276,28 @@ sub exportbutton { sub exportcourse { my $r=shift; - my $type = &Apache::loncommon::course_type(); + my $crstype = &Apache::loncommon::course_type(); my %discussiontime = &Apache::lonnet::dump('discussiontimes', $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); my $numdisc = keys(%discussiontime); my $navmap = Apache::lonnavmaps::navmap->new(); if (!defined($navmap)) { - $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'). - '

IMS Export Failed

'. - '
'. - &mt('Unable to retrieve information about course contents'). - '
'.&mt('Return to Course Editor').''); - &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'}); + $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package'). + '

'.&mt('IMS Export Failed').'

'. + '
'); + if ($crstype eq 'Community') { + $r->print(&mt('Unable to retrieve information about community contents')); + } else { + $r->print(&mt('Unable to retrieve information about course contents')); + } + $r->print('
'); + if ($crstype eq 'Community') { + $r->print(&mt('Return to Community Editor')); + } else { + $r->print(&mt('Return to Course Editor')); + } + $r->print(''); + &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'}); return; } my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); @@ -298,7 +313,17 @@ sub exportcourse { my @exportitems = &Apache::loncommon::get_env_multiple('form.archive'); my @discussions = &Apache::loncommon::get_env_multiple('form.discussion'); if (@exportitems == 0 && @discussions == 0) { - $outcome = '
As you did not select any content items or discussions for export, an IMS package has not been created. Please go back to select either content items or discussions for export'; + $outcome = + '

' + .&mt('As you did not select any content items or discussions' + .' for export, an IMS package has not been created.') + .'

' + .'

' + .&mt('Please [_1]go back[_2] to select either content items' + .' or discussions for export.' + ,'' + ,'') + .'

'; } else { my $now = time; my %symbs; @@ -322,7 +347,7 @@ sub exportcourse { close(OUTPUT); chdir $cwd; $outcome .= '

' - .&mt('Download the zip file from [_1]IMS '.lc($type).' archive[_2]' + .&mt('[_1]Your IMS package[_2] is ready for download.' ,'','') .'

'; if ($copyresult) { @@ -332,32 +357,42 @@ sub exportcourse { .'

'; } } else { - $outcome = '
'.&mt('Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.').'
'; + $outcome = '

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

' + .'

' + .&mt('Go Back') + .'

'; } } - $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package')); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package')); + $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); $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 '.$type.'.') - .'

'; - $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; @@ -368,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 ++; @@ -397,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(); @@ -489,13 +516,13 @@ function containerCheck(item) { // ]]> |; - $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package', + $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package', $scripttag)); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); $r->print($display. '

'. '

'); + &mt('Export').'" />

'); } } @@ -980,7 +1007,7 @@ sub group_import { } sub breadcrumbs { - my ($where,$allowed,$type)=@_; + my ($allowed,$crstype)=@_; &Apache::lonhtmlcommon::clear_breadcrumbs(); my (@folders); if ($env{'form.pagepath'}) { @@ -995,6 +1022,15 @@ sub breadcrumbs { my $isencrypted=0; my $ishidden=0; my $is_random_order=0; + if (!$allowed) { + my $description = $env{'course.'.$env{'request.course.id'}.'.description'}; + &Apache::lonhtmlcommon::add_breadcrumb( + {'href' => '/adm/menu', + 'title'=> 'Go to main menu', + 'text' => $description, + }); + $plain .= $description.' >'; + } while (@folders) { my $folder=shift(@folders); my $foldername=shift(@folders); @@ -1014,11 +1050,7 @@ sub breadcrumbs { if ($3) { $isencrypted=1; } if ($4 ne '') { $is_random_order = 1; } if ($folder eq 'supplemental') { - if ($allowed) { - $name = &mt('Supplemental '.$type.' Documents'); - } else { - $name = &mt($type.' Documents'); - } + $name = &mt('Supplemental '.$crstype.' Documents'); } &Apache::lonhtmlcommon::add_breadcrumb( {'href'=>$url.$cpinfo, @@ -1030,7 +1062,7 @@ sub breadcrumbs { } $plain=~s/\>\;\s*$//; return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', - 'LC_docs_path', undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); + undef, undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); } sub log_docs { @@ -1254,10 +1286,11 @@ sub print_paste_buffer { my ($r,$container) = @_; return if (!defined($env{'docs.markedcopy_url'})); - $r->print(<

-ENDPASTE - $r->print(' '); + $r->print('

' + .''.&mt('Clipboard').'' + .'
' + .' ' + ); my $type; if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { @@ -1271,7 +1304,7 @@ ENDPASTE if ($extension eq 'sequence' && $env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) { $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); - $icon .= '/folder_closed.gif'; + $icon .= '/navmap.folder.closed.gif'; } $icon = ''; $r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}))); @@ -1286,7 +1319,7 @@ ENDPASTE '); } - $r->print('

'); + $r->print('
'); } sub do_paste_from_buffer { @@ -1473,8 +1506,7 @@ sub handle_edit_cmd { } sub editor { - my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_; - + my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype)=@_; my $container= ($env{'form.pagepath'}) ? 'page' : 'sequence'; @@ -1489,9 +1521,14 @@ sub editor { $LONCAPA::map::resources[$idx]=''; } - my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)= - &breadcrumbs($folder,$allowed,$type); - $r->print($breadcrumbtrail); + my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order); + if ($allowed) { + ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = + &breadcrumbs($allowed,$crstype); + $r->print($breadcrumbtrail); + } else { + $randompick = -1; + } # ------------------------------------------------------------ Process commands @@ -1569,34 +1606,73 @@ sub editor { my $idx=0; 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 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.').'

'); - } - if ($is_random_order) { - $r->print('

'.&mt('Caution: this folder is set to randomly order its contents. Adding or removing resources from this folder will change the order of resources shown.').'

'); + ($is_random_order?'
  • '.&mt('random order').'
  • ':''). + ''); + if ($randompick>=0) { + $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.') + .'

    ' + ); + } + if ($is_random_order) { + $r->print('

    ' + .&mt('Caution: this folder is set to randomly order its' + .' contents. Adding or removing resources from this folder' + .' will change the order of resources shown.') + .'

    ' + ); + } + $r->print(''); } - $r->print(''); + + 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); - $url=&LONCAPA::map::qtescape($url); - unless ($name) { $name=(split(/\//,$url))[-1]; } - unless ($name) { $idx++; next; } - $r->print(&entryline($idx,$name,$url,$folder,$allowed,$res, - $coursenum)); - $idx++; - $shown++; + 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; } + $output .= &entryline($idx,$name,$url,$folder,$allowed,$res, + $coursenum,$crstype); + $idx++; + $shown++; } - unless ($shown) { - $r->print(''); + &Apache::loncommon::end_data_table_count(); + + if ($shown) { + $r->print(&Apache::loncommon::start_data_table()); + if ($allowed) { + $r->print(&Apache::loncommon::start_data_table_header_row() + .'' + .'' + .''); + if ($folder !~ /^supplemental/) { + $->print(''); + } + $r->print(&Apache::loncommon::end_data_table_header_row()); + } + $r->print($output + .&Apache::loncommon::end_data_table() + ); + } else { + $r->print('

    ' + .&mt('Currently no documents.') + .'

    ' + ); } - $r->print("\n
    '.&mt('Currently no documents.').'
    '.&mt('Move').''.&mt('Actions').''.&mt('Document').''.&mt('Settings').'
    \n"); if ($allowed) { &print_paste_buffer($r,$container); } @@ -1667,7 +1743,7 @@ sub process_file_upload { return 'failed'; } else { if ($parseaction eq 'parse') { - my $total_embedded = keys(%{$allfiles}); + my $total_embedded = scalar(keys(%{$allfiles})); if ($total_embedded > 0) { my $num = 0; my $state = ' @@ -1728,6 +1804,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; } @@ -1740,8 +1817,7 @@ sub parse_supplemental_title { # --------------------------------------------------------------- An entry line sub entryline { - my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_; - + my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_; my ($foldertitle,$pagetitle,$renametitle); if (&is_supplemental_title($title)) { ($title,$foldertitle,$renametitle) = &parse_supplemental_title($title); @@ -1759,7 +1835,7 @@ sub entryline { $renametitle=~s/\\/\\\\/g; $renametitle=~s/\"\;/\\\"/g; $renametitle=~s/ /%20/g; - my $line=''; + my $line=&Apache::loncommon::start_data_table_row(); my ($form_start,$form_end); # Edit commands my ($container, $type, $esc_path, $path, $symb); @@ -1862,18 +1938,16 @@ END $form_end = ''; $line.=(< - - - - - - - -
    - $lt{ -
    - $lt{ -
    +
    + + $lt{ + +
    +
    + + $lt{ + +
    $form_start @@ -1900,7 +1974,7 @@ END my $pagefile; if ($uploaded) { if ($extension eq 'sequence') { - $icon=$iconpath.'/folder_closed.gif'; + $icon=$iconpath.'/navmap.folder.closed.gif'; $url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/; $url='/adm/coursedocs?'; $folderarg=$1; @@ -2000,18 +2074,24 @@ END $url.='pagepath='.&escape($pagepath). '&pagesymb='.&escape($symb).$cpinfo; } - if ($external) { + if (($external) && ($allowed)) { my $form = ($folder =~ /^default/)? 'newext' : 'supnewext'; $external = ' '.&mt('Edit').''; } else { undef($external); } + my $reinit; + if ($crstype eq 'Community') { + $reinit = &mt('(re-initialize community to access)'); + } else { + $reinit = &mt('(re-initialize course to access)'); + } $line.=' - + '.($url?'':'').''.($url?'':'').' - - '.($url?"":'').$title.($url?'':' '.&mt('(re-initialize course to access)').'').$external." + + '.($url?"":'').$title.($url?'':' '.$reinit.'').$external." "; if (($allowed) && ($folder!~/^supplemental/)) { my %lt=&Apache::lonlocal::texthash( @@ -2036,7 +2116,7 @@ END $form_start $parameterset $form_end ENDPARMS } - $line.=""; + $line.=&Apache::loncommon::end_data_table_row(); return $line; } @@ -2159,7 +2239,7 @@ List Symbs sub list_symbs { my ($r) = @_; - my $type = &Apache::loncommon::course_type(); + my $crstype = &Apache::loncommon::course_type(); $r->print(&Apache::loncommon::start_page('Symb List')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List')); my $navmap = Apache::lonnavmaps::navmap->new(); @@ -2168,25 +2248,23 @@ sub list_symbs { '
    '. &mt('Unable to retrieve information about course contents'). '
    '); - &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'}); + &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'}); } 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 $type = &Apache::loncommon::course_type(); - my $loaderror=&Apache::lonnet::overloaderror($r); - if ($loaderror) { return $loaderror; } - $r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents')); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents')); + my $crstype = &Apache::loncommon::course_type(); + $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents')); $hashtied=0; undef %alreadyseen; %alreadyseen=(); @@ -2195,9 +2273,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 '.$type.': '). + &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})})) { @@ -2205,8 +2283,13 @@ sub verifycontent { } } &untiehash(); - $r->print('

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

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

    '.&mt('Done').'

    ' + .'
    ' + .'

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

    ' + ); } @@ -2218,9 +2301,9 @@ sub devalidateversioncache { sub checkversions { my ($r) = @_; - my $type = &Apache::loncommon::course_type(); - $r->print(&Apache::loncommon::start_page("Check $type Document Versions")); - $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions")); + my $crstype = &Apache::loncommon::course_type(); + $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions")); + $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions")); my $header=''; my $startsel=''; my $monthsel=''; @@ -2281,7 +2364,7 @@ sub checkversions { &changewarning($r,''); if ($env{'form.timerange'} eq 'all') { # show all documents - $header=&mt('All Documents in '.$type); + $header=&mt('All Documents in '.$crstype); $allsel=1; foreach my $key (keys(%hash)) { if ($key=~/^ids\_(\/res\/.+)$/) { @@ -2326,7 +2409,7 @@ sub checkversions { $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); my %lt=&Apache::lonlocal::texthash - ('st' => 'Version changes since start of '.$type, + ('st' => 'Version changes since start of '.$crstype, 'lm' => 'Version changes since last Month', 'lw' => 'Version changes since last Week', 'sy' => 'Version changes since Yesterday', @@ -2335,9 +2418,9 @@ sub checkversions { 'fi' => 'File', 'md' => 'Modification Date', 'mr' => 'Most recently published Version', - 've' => 'Version used in '.$type, - 'vu' => 'Set Version to be used in '.$type, -'sv' => 'Set Versions to be used in '.$type.' according to Selections below', + 've' => 'Version used in '.$crstype, + 'vu' => 'Set Version to be used in '.$crstype, +'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below', 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)', 'sc' => 'Set all Resource Versions to current Version (Fix Versions)', 'di' => 'Differences'); @@ -2384,7 +2467,7 @@ ENDHEADERS 'Most Recent: '. ''.$currentversion.''. ''. - 'In '.$type.': '. + 'In '.$crstype.': '. ''); # Used in course my $usedversion=$hash{'version_'.$linkurl}; @@ -2398,11 +2481,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' => 'most recent', - map {$_,$_} (1..$currentversion)))); + 'mostrecent' => &mt('most recent'), + map {$_,$_} (1..$currentversion)})); $r->print(''); my $lastold=1; for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { @@ -2456,7 +2539,7 @@ ENDHEADERS } } $r->print(''); - $r->print('

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

    '); + $r->print('

    '.&mt('Done').'

    '); &untiehash(); } @@ -2521,7 +2604,7 @@ sub init_breadcrumbs { my ($form,$text)=@_; &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs", - text=>"Edit ".&Apache::loncommon::course_type(), + text=>&Apache::loncommon::course_type().' Editor', faq=>273, bug=>'Instructor Interface', help => 'Docs_Adding_Course_Doc'}); @@ -2539,7 +2622,7 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; - my $type = &Apache::loncommon::course_type(); + my $crstype = &Apache::loncommon::course_type(); # --------------------------------------------- Initialize help topics for this @@ -2580,10 +2663,10 @@ 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','Export '.&Apache::loncommon::course_type().' to IMS'); + &init_breadcrumbs('exportcourse','IMS Export'); &exportcourse($r); } else { # is this a standard course? @@ -2605,7 +2688,12 @@ sub handler { &Apache::loncommon::restore_course_settings('docs_folderpath', {'folderpath' => 'scalar'}); } - if (!$env{'form.folderpath'}) { + if (!$allowed) { + unless($env{'form.folderpath'} =~ /^supplemental/) { + $env{'form.folderpath'} = ''; + } + } + if (!$env{'form.folderpath'} && $allowed) { &Apache::loncommon::restore_course_settings('docs_folderpath', {'pagepath' => 'scalar'}); } @@ -2614,7 +2702,7 @@ sub handler { } if ($env{'form.folderpath'} =~ /^supplemental_\d+/) { $env{'form.folderpath'} = 'supplemental&'. - &escape(&mt('Supplemental '.$type.' Documents')).'&'. + &escape(&mt('Supplemental '.$crstype.' Documents')).'&'. $env{'form.folderpath'}; } &Apache::loncommon::store_course_settings('docs_folderpath', @@ -2630,14 +2718,29 @@ 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; } - unless ($showdoc) { # got called from remote + if ($showdoc) { # got called in sequence from course + $allowed=0; + } else { if (($env{'form.folder'}=~/^(?:group|default)_/) || ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) { $forcestandard = 1; @@ -2648,10 +2751,28 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); $script=&Apache::lonratedt::editscript('simple'); } - } else { # got called in sequence from course - $allowed=0; } +# subroutine to list form elements +sub create_list_elements { + my @formarr = @_; + my $list = ''; + for my $button (@formarr){ + for my $picture(keys %$button) { + #my $link = Apache::lonhtmlcommon::htmltag('a' ,$button->{$picture}, {href => "test"}); + $list .= Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'}); + } + } + return $list; +} + +# subroutine to create ul from list elements +sub create_form_ul { + my $list = shift; + my $ul = Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'}); + return $ul; +} + # get course data my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -2674,11 +2795,33 @@ sub handler { .$script."\n" .'// ]]>'."\n" .''."\n"; - my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}]; - $r->print(&Apache::loncommon::start_page("$type Documents", $script, - {'force_register' => $showdoc, - 'bread_crumbs' => $brcrum}). - &Apache::loncommon::help_open_menu('','',273,'RAT')); + + # Breadcrumbs + &Apache::lonhtmlcommon::clear_breadcrumbs(); + if ($allowed) { + &Apache::lonhtmlcommon::add_breadcrumb({ + href=>"/adm/coursedocs",text=>"$crstype Editor"}); + + $r->print(&Apache::loncommon::start_page("$crstype Editor", $script, + {'force_register' => $showdoc,}) + .&Apache::loncommon::help_open_menu('','',273,'RAT') + .&Apache::lonhtmlcommon::breadcrumbs( + 'Editing the Table of Contents for your '.$crstype, + 'Docs_Adding_Course_Doc') + ); + } elsif ($showdoc) { + $r->print(&Apache::loncommon::start_page("$crstype documents",undef, + {'force_register' => $showdoc,})); + } else { + my $folder=$env{'form.folder'}; + if ($folder eq '' || $folder eq 'supplemental') { + $env{'form.folderpath'} = 'supplemental&'. + &escape(&mt('Supplemental '.$crstype.' Documents')); + } + my ($breadcrumbtrail) = &breadcrumbs($allowed,$crstype); + $r->print(&Apache::loncommon::start_page("Supplemental documents"). + $breadcrumbtrail); + } my %allfiles = (); my %codebase = (); @@ -2770,23 +2913,22 @@ sub handler { unless ($showdoc || $upload_result eq 'phasetwo') { # ----------------------------------------------------------------------------- my %lt=&Apache::lonlocal::texthash( - 'uplm' => 'Upload a new main '.lc($type).' document', - 'upls' => 'Upload a new supplemental '.lc($type).' document', + 'uplm' => 'Upload a new main '.lc($crstype).' document', + 'upls' => 'Upload a new supplemental '.lc($crstype).' document', 'impp' => 'Import a document', - 'pubd' => 'Published Documents', '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', @@ -2796,16 +2938,16 @@ sub handler { 'grpo' => 'Group Portfolio', 'rost' => 'Course Roster', 'abou' => 'Personal Information Page for a User', - 'imsf' => 'Import IMS package', + 'imsf' => 'IMS Import', + 'imsl' => 'Import IMS package', 'file' => 'File', 'title' => 'Title', 'comment' => 'Comment', - 'parse' => 'Upload embedded images/multimedia files if HTML file!', + 'parse' => 'Upload embedded images/multimedia files if HTML file', 'nd' => 'Upload Document', 'pm' => 'Published Map', 'sd' => 'Special Document', 'mo' => 'More Options', - 'hao' => 'Hide all Options' ); # ----------------------------------------------------------------------------- my $fileupload=(< CHBO + my $fileuploada = " $help{'Uploading_From_Harddrive'}"; my $fileuploadform=(< @@ -2835,28 +2978,25 @@ CHBO $checkbox -
    -
    - - - $help{'Uploading_From_Harddrive'} - +FUFORM + #$list .= Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'}); + #$fileuploadform .= create_form_ul(create_list_elements(@fileuploada)); + $fileuploadform .= create_form_ul(Apache::lonhtmlcommon::htmltag('li',$fileuploada,{class => 'LC_menubuttons_inline_text'})); + $fileuploadform .= (< FUFORM my $simpleeditdefaultform=(< - $lt{'pubd'}
    - $uploadtag - -
    - - - $help{'Importing_LON-CAPA_Resource'} - -
    - +SEDFFORM + my @simpleeditdefaultforma = ( + { ''.$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 .=(<

    $lt{'copm'}
    @@ -2873,10 +3013,7 @@ SEDFFORM

    $uploadtag - - $help{'Adding_External_Resource'} - + $lt{'extr'}$help{'Adding_External_Resource'}
    ERFORM @@ -2889,18 +3026,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 '.$type.' Documents')); - } - } - unless ($env{'form.pagepath'}) { - $containertag = ''; - $uploadtag = ''; - } $r->print(< @@ -2916,36 +3041,56 @@ ERFORM HIDDENFORM } # --------------------------------------------------------- Main tab structure + my $activeClass = 1; my $active = ''; - $r->print('
    '); + $r->print('
    ' + .'
    '); # --------------------------------------------------------- Standard documents my $savefolderpath; - my $active = 'style="display: none;"'; + $active = 'style="display: none;"'; if($activeClass == 0){ $active = 'style="display: block;"'; } + if ($allowed) { $r->print('
    '); my $folder=$env{'form.folder'}; if ($folder eq '' || $folder=~/^supplemental/) { $folder='default'; $savefolderpath = $env{'form.folderpath'}; - $env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents')); + $env{'form.folderpath'}='default&'.&escape($tabtitles{'main'}{$crstype}); $uploadtag = ''; } @@ -2974,14 +3119,14 @@ HIDDENFORM my $recoverform=(< - + $lt{'reco'} RFORM my $imspform=(< - + $lt{'imsf'} IMSPFORM @@ -2991,10 +3136,8 @@ IMSPFORM $uploadtag - - + $lt{'navc'} $help{'Navigate_Content'} - NNFORM my $newsmppageform=(< $uploadtag - - $help{'Simple Page'} - + $lt{'sipa'} + $help{'Simple Page'} NSPFORM @@ -3014,10 +3155,8 @@ NSPFORM $uploadtag - - $help{'Simple Problem'} - + $lt{'sipr'} + $help{'Simple Problem'} NSPROBFORM @@ -3027,10 +3166,7 @@ NSPROBFORM $uploadtag - - - + $lt{'drbx'} NDBFORM @@ -3039,11 +3175,8 @@ NDBFORM $uploadtag - - + $lt{'scuf'} $help{'Score_Upload_Form'} - NEXUFORM @@ -3052,11 +3185,8 @@ NEXUFORM $uploadtag - - + $lt{'bull'} $help{'Bulletin Board'} - NBFORM @@ -3066,10 +3196,8 @@ NBFORM $uploadtag - - + $lt{'mypi'} $help{'My Personal Information Page'} - NAMFORM @@ -3078,10 +3206,7 @@ NAMFORM $uploadtag - - - + $lt{'abou'} NASOFORM @@ -3092,42 +3217,36 @@ NASOFORM $uploadtag - - + $lt{'rost'} $help{'Course Roster'} - NROSTFORM my $specialdocumentsform; +my @specialdocumentsforma; my $newfolderform; +my $newfolderb; unless ($env{'form.pagepath'}) { my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); - + my $newpageform=(< - - $help{'Adding_Pages'} - + $lt{'newp'} + $help{'Adding_Pages'} NPFORM + $newfolderform=(< - - $help{'Adding_Folders'} - + $lt{'newf'}$help{'Adding_Folders'} NFFORM @@ -3137,10 +3256,9 @@ NFFORM $uploadtag - - + $lt{'syll'} $help{'Syllabus'} - + NSYLFORM @@ -3150,36 +3268,62 @@ NSYLFORM $uploadtag - - + $lt{'grpo'} $help{'Group Portfolio'} - NGFFORM + @specialdocumentsforma=( + {''.$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="
    $newpageform
    $newsylform
    $newgroupfileform"; + $specialdocumentsform = create_form_ul(create_list_elements(@specialdocumentsforma)); } - $specialdocumentsform.="
    $newnavform
    $newsmppageform -
    $newsmpproblemform
    $newdropboxform -
    $newexuploadform
    $newbulform -
    $newaboutmeform
    $newaboutsomeoneform -
    $newrosterform"; + if($env{'form.pagepath'}) { - $specialdocumentsform="
    $newsmpproblemform
    $newexuploadform"; + + @specialdocumentsforma=( + {''.&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}, + ); + my %orderhash = ( - 'aa' => ['Upload Document',$fileuploadform.'
    '.$newfolderform], - 'bb' => ['Published Documents',$simpleeditdefaultform], + 'aa' => ['Import Documents',$fileuploadform], + 'bb' => ['Published Resources',$simpleeditdefaultform], 'cc' => ['Special Documents',$specialdocumentsform], - 'dd' => ['Tools',$extresourcesform.'
    '.$imspform.'
    '.$recoverform.'
    '.&generate_admin_options($containertag,$uploadtag,\%help,\%env)], - 'zz' => ['Hide all Options'], + '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'; -my $varcd = 'Main Course Documents'; -$r->print(&generate_edit_table($tid,$varcd,\%orderhash)); $hadchanges=0; - my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type); + my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype); if ($error) { $r->print('

    '.$error.'

    '); } @@ -3188,13 +3332,12 @@ $r->print(&generate_edit_table($tid,$var } &changewarning($r,''); - $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', - &mt('Editing the Table of Contents for your '.$type))); +$r->print(&generate_edit_table($tid,\%orderhash)); + $r->print('
    '); - if ($env{'form.pagepath'}) { - } + } # ----------------------------------------------------- Supplemental documents - my $active = 'style="display: none;"'; + $active = 'style="display: none;"'; if($activeClass == 1){ $active = 'style="display: block;"'; } @@ -3206,8 +3349,8 @@ $r->print('
    '); if ($folder =~ /^supplemental$/ && (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) { $env{'form.folderpath'} = 'supplemental&'. - &escape(&mt('Supplemental '.$type.' Documents')); - }else{ + &escape(&mt('Supplemental '.$crstype.' Documents')); + } elsif ($allowed) { $env{'form.folderpath'} = $savefolderpath; } $env{'form.pagepath'} = ''; @@ -3218,8 +3361,9 @@ $r->print('
    '); my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); + my $supupdocformbtn = "$help{'Uploading_From_Harddrive'}"; my $supupdocform=(< +
    $fileupload
    @@ -3229,42 +3373,30 @@ $r->print('
    ');

    $lt{'comment'}:
    - +
    - - - $help{'Uploading_From_Harddrive'} - - SUPDOCFORM + $supupdocform .= create_form_ul(Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'})).""; my $supnewfolderform=(< - - $help{'Adding_Folders'} - + $lt{'newf'} + $help{'Adding_Folders'} SNFFORM - + my $supnewextform=(< - - $help{'Adding_External_Resource'} - + $lt{'extr'} $help{'Adding_External_Resource'} SNEFORM @@ -3274,45 +3406,58 @@ SNEFORM - - + $lt{'syll'} $help{'Syllabus'} - SNSFORM my $supnewaboutmeform=(< +
    - - + $lt{'mypi'} $help{'My Personal Information Page'} -
    SNAMFORM - +my @specialdocs = ( + {''.$lt{syll}.'' + =>$supnewsylform}, + {''.$lt{mypi}.'' + =>$supnewaboutmeform}, + ); +my @supimportdoc = ( + {''.$lt{extr}.'' + =>$supnewextform}, + ); +$supupdocform = create_form_ul(create_list_elements(@supimportdoc)) . '
    ' . $supupdocform; my %suporderhash = ( - 'ee' => ['Upload Document',$supupdocform.'
    '.$supnewfolderform], - 'ff' => ['Special Documents',$supnewextform.'
    '.$supnewsylform.'
    '.$supnewaboutmeform], - 'zz' => ['Hide all Options'], + '00' => ['Supnewfolder', $supnewfolderform], + 'ee' => ['Import Documents',$supupdocform], + 'ff' => ['Special Documents',create_form_ul(create_list_elements(@specialdocs))] ); -my $tid='2'; -my $varscd = 'Supplemental Course Documents'; + my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype); + if ($error) { + $r->print('

    '.$error.'

    '); + } + my $tid='2'; + $r->print(&generate_edit_table($tid,\%suporderhash)); + } else { + my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype); + if ($error) { + $r->print('

    '.$error.'

    '); + } + } + -$r->print(&generate_edit_table($tid,$varscd,\%suporderhash)); -my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type); - if ($error) { - $r->print('

    '.$error.'

    '); - } -$r->print('
    '); - } $r->print(''); +$r->print(''); + + if ($allowed) { $r->print('
    @@ -3337,34 +3482,43 @@ $r->print(''); } 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' + 'sl' => 'Show Log', + 'imse' => 'IMS Export', + '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(); - return (< - $help{'Verify_Content'}
    - $help{'Check_Resource_Versions'}
    - $dumpbut - $exportbut - -
    - - -ENDOPTIONFORM + my @list = ( + {''.$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{imse}.'' + =>$exportbut}, + {''.$lt{ls}.'' + =>"$lt{'ls'}"}, + {''.$lt{sl}.'' + =>"$lt{'sl'}"}, + ); + return '
    '.create_form_ul(create_list_elements(@list)).'
    '; } sub generate_edit_table { - my ($tid,$varcd,$orderhash_ref) = @_; + my ($tid,$orderhash_ref) = @_; + return unless(ref($orderhash_ref) eq 'HASH'); my %orderhash = %{$orderhash_ref}; my $form; my $activetab; @@ -3372,37 +3526,35 @@ sub generate_edit_table { if($env{'form.active'} ne ''){ $activetab = $env{'form.active'}; } - $form = '

    '.&mt($varcd).'

    '; + $form = '
    '; $form .= ''; - $form .= '
    '; + $form .= '
    '; foreach my $field (keys(%orderhash)){ - if($field ne 'zz'){ - if($activetab eq '' || $activetab ne $field){ + if($field ne '00'){ + if($activetab eq '' || $activetab ne $field){ $active = 'style="display: none;"'; - }elsif($activetab eq $field){ + }elsif($activetab eq $field){ $active = 'style="display:block;"'; - } - $form .= '
    '.${$orderhash{$field}}[1] - .'
    '; + } + $form .= '
    '.${$orderhash{$field}}[1] + .'
    '; } } $form .= '
    '; @@ -3437,6 +3589,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 < 0 ){ - currentNav = document.getElementById(tabnav[0].id); + if(tabnav.length > 2 ){ + currentNav = document.getElementById(tabnav[1].id); currentLis = currentNav.getElementsByTagName('LI'); for(i = 0; i< currentLis.length; i++){ if(currentLis[i].className == 'active') { funcString = currentLis[i].onclick.toString(); tab = funcString.split('"'); + if(tab.length < 2) { + tab = funcString.split("'"); + } currentData = document.getElementById(tab[1]); currentData.style.display = 'block'; } @@ -3662,9 +3829,50 @@ function showPage(current, pageId, nav, current.className = 'active'; currentData = document.getElementById(pageId); currentData.style.display = 'block'; + if (nav == 'mainnav') { + var storedpath = "$docs_folderpath"; + if (storedpath == '') { + storedpath = "$docs_pagepath"; + } + var storedpage = "$main_container_page"; + var reg = new RegExp("^supplemental"); + if (pageId == 'mainCourseDocuments') { + if (storedpage == 1) { + document.simpleedit.folderpath.value = ''; + document.uploaddocument.folderpath.value = ''; + } else { + if (reg.test(storedpath)) { + document.simpleedit.folderpath.value = '$toplevelmain'; + document.uploaddocument.folderpath.value = '$toplevelmain'; + document.newext.folderpath.value = '$toplevelmain'; + } else { + document.simpleedit.folderpath.value = storedpath; + document.uploaddocument.folderpath.value = storedpath; + document.newext.folderpath.value = storedpath; + } + } + } else { + if (reg.test(storedpath)) { + document.simpleedit.folderpath.value = storedpath; + document.supuploaddocument.folderpath.value = storedpath; + document.supnewext.folderpath.value = storedpath; + } else { + document.simpleedit.folderpath.value = '$toplevelsupp'; + document.supuploaddocument.folderpath.value = '$toplevelsupp'; + document.supnewext.folderpath.value = '$toplevelsupp'; + } + } + } return false; } +function injectData(current, hiddenField, name, value) { + currentElement = document.getElementById(hiddenField); + currentElement.name = name; + currentElement.value = value; + current.submit(); +} + ENDNEWSCRIPT } 1;