--- loncom/interface/londocs.pm 2010/12/04 16:17:27 1.441 +++ loncom/interface/londocs.pm 2010/12/11 00:09:52 1.446 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.441 2010/12/04 16:17:27 www Exp $ +# $Id: londocs.pm,v 1.446 2010/12/11 00:09:52 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1521,12 +1521,11 @@ sub editor { $LONCAPA::map::resources[$idx]=''; } - my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order); - if ($allowed) { - ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = + my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = &breadcrumbs($allowed,$crstype); $r->print($breadcrumbtrail); - } else { + + unless ($allowed) { $randompick = -1; } @@ -2238,6 +2237,7 @@ sub list_symbs { my $crstype = &Apache::loncommon::course_type(); $r->print(&Apache::loncommon::start_page('Symb List')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List')); + &startContentScreen($r,'tools'); my $navmap = Apache::lonnavmaps::navmap->new(); if (!defined($navmap)) { $r->print('

'.&mt('Retrieval of List Failed').'

'. @@ -2252,7 +2252,6 @@ sub list_symbs { } $r->print("\n\n"); } - $r->print('
'.&mt('Back to Course Editor').''); } @@ -2261,6 +2260,7 @@ sub verifycontent { my $crstype = &Apache::loncommon::course_type(); $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents')); + &startContentScreen($r,'tools'); $hashtied=0; undef %alreadyseen; %alreadyseen=(); @@ -2279,13 +2279,7 @@ sub verifycontent { } } &untiehash(); - $r->print( - '

'.&mt('Done').'

' - .'
' - .'

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

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

'.&mt('Done').'

'); } @@ -2300,6 +2294,8 @@ sub checkversions { 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")); + &startContentScreen($r,'tools'); + my $header=''; my $startsel=''; my $monthsel=''; @@ -2629,6 +2625,46 @@ sub create_form_ul { return $ul; } +# +# Start tabs +# + +sub startContentScreen { + my ($r,$mode)=@_; + $r->print(''); + $r->print('
' + .'
'); + $r->print('
'); +} + +# +# End tabs +# + +sub endContentScreen { + my ($r)=@_; + $r->print('
'); +} + +sub supplemental_base { + return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Documents')); +} sub handler { my $r = shift; @@ -2637,7 +2673,7 @@ sub handler { return OK if $r->header_only; my $crstype = &Apache::loncommon::course_type(); - +# # --------------------------------------------- Initialize help topics for this foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', 'Adding_External_Resource','Navigate_Content', @@ -2682,45 +2718,86 @@ sub handler { &init_breadcrumbs('exportcourse','IMS Export'); &exportcourse($r); } else { -# is this a standard course? +# +# Done catching special calls +# The whole rest is for course and supplemental documents +# Get the parameters that may be needed +# + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['folderpath','pagepath', + 'pagesymb','forcesupplement','forcestandard']); + +# standard=1: this is a "new-style" course with an uploaded map as top level +# standard=2: this is a "old-style" course, and there is nothing we can do my $standard=($env{'request.course.uri'}=~/^\/uploaded\//); - my $forcestandard = 0; - my $forcesupplement; + +# Decide whether this should display supplemental or main content +# supplementalflag=1: show supplemental documents +# supplementalflag=0: show standard documents + + + my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); + if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) { + $supplementalflag=0; + } + if ($env{'form.forcesupplement'}) { $supplementalflag=1; } + if ($env{'form.forcestandard'}) { $supplementalflag=0; } + unless ($allowed) { $supplementalflag=1; } + unless ($standard) { $supplementalflag=1; } + my $script=''; my $showdoc=0; my $containertag; my $uploadtag; - - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['folderpath','pagepath', - 'pagesymb']); +# Where do we store these for when we come back? + my $stored_folderpath='docs_folderpath'; + if ($supplementalflag) { + $stored_folderpath='docs_sup_folderpath'; + } + # No folderpath, no pagepath, see if we have something stored if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) { - &Apache::loncommon::restore_course_settings('docs_folderpath', + &Apache::loncommon::restore_course_settings($stored_folderpath, {'folderpath' => 'scalar'}); } + +# If we are not allowed to make changes, all we can see are supplemental docs if (!$allowed) { - unless($env{'form.folderpath'} =~ /^supplemental/) { - $env{'form.folderpath'} = ''; + $env{'form.pagepath'}=''; + unless ($env{'form.folderpath'} =~ /^supplemental/) { + $env{'form.folderpath'} = &supplemental_base(); } } +# If we still not have a folderpath, see if we can resurrect at pagepath if (!$env{'form.folderpath'} && $allowed) { - &Apache::loncommon::restore_course_settings('docs_folderpath', + &Apache::loncommon::restore_course_settings($stored_folderpath, {'pagepath' => 'scalar'}); } - if ($env{'form.pagepath'}) { - $env{'form.folderpath'}=''; - } +# Make the zeroth entry in supplemental docs page paths, so we can get to top level if ($env{'form.folderpath'} =~ /^supplemental_\d+/) { - $env{'form.folderpath'} = 'supplemental&'. - &escape(&mt('Supplemental '.$crstype.' Documents')).'&'. + $env{'form.folderpath'} = &supplemental_base() + .'&'. $env{'form.folderpath'}; } - &Apache::loncommon::store_course_settings('docs_folderpath', +# If after all of this, we still don't have any paths, make them + unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) { + if ($supplementalflag) { + $env{'form.folderpath'}=&supplemental_base(); + } else { + $env{'form.folderpath'}='default'; + } + } + +# Store this + if ($allowed) { + &Apache::loncommon::store_course_settings($stored_folderpath, {'pagepath' => 'scalar', 'folderpath' => 'scalar'}); + } + + if ($env{'form.folderpath'}) { my (@folderpath)=split('&',$env{'form.folderpath'}); $env{'form.foldername'}=&unescape(pop(@folderpath)); @@ -2754,12 +2831,6 @@ sub handler { 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; - } - $forcesupplement=($env{'form.folder'}=~/^supplemental_/); - if ($allowed) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); $script=&Apache::lonratedt::editscript('simple'); @@ -2791,29 +2862,20 @@ sub handler { # Breadcrumbs &Apache::lonhtmlcommon::clear_breadcrumbs(); - if ($allowed) { + unless ($showdoc) { &Apache::lonhtmlcommon::add_breadcrumb({ - href=>"/adm/coursedocs",text=>"$crstype Editor"}); + href=>"/adm/coursedocs",text=>"$crstype Contents"}); - $r->print(&Apache::loncommon::start_page("$crstype Editor", $script, + $r->print(&Apache::loncommon::start_page("$crstype Contents", $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) { + } else { $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 = (); @@ -2929,12 +2991,7 @@ CHBO $checkbox 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 + $fileuploadform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$fileuploada,{class => 'LC_menubuttons_inline_text'})).''; my $simpleeditdefaultform=(< @@ -2945,7 +3002,7 @@ SEDFFORM { ''.$lt{impo}.'' => "$lt{'impo'}$help{'Importing_LON-CAPA_Resource'}" }, { ''.$lt{wish}.'' => "$lt{'wish'}" }, ); - $simpleeditdefaultform .= create_form_ul(create_list_elements(@simpleeditdefaultforma)); + $simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma)); $simpleeditdefaultform .=(<

@@ -2959,14 +3016,15 @@ SEDFFORM SEDFFORM - my $extresourcesform=(< - $uploadtag - - $lt{'extr'}$help{'Adding_External_Resource'} - + my $extresourcesform=(< + $uploadtag + + $lt{'extr'}$help{'Adding_External_Resource'} + ERFORM + if ($allowed) { &update_paste_buffer($coursenum,$coursedom); my %lt=&Apache::lonlocal::texthash( @@ -2990,57 +3048,21 @@ ERFORM HIDDENFORM } -# --------------------------------------------------------- Main tab structure - - my $activeClass = 1; - my $active = ''; - my %tabtitles = ( - main => { - Course => &mt('Main Course Documents'), - Community => &mt('Main Community Documents'), - }, - supplemental => { - Course => &mt('Supplemental Course Documents'), - Community => &mt('Supplemental Community Documents'), - }, - ); + +# Generate the tabs + &startContentScreen($r,($supplementalflag?'supdocs':'docs')); + + +# + + my $savefolderpath; + if ($allowed) { - $r->print('

'); - } else { - $r->print('
'); - } - $r->print('
' - .'
'); -# --------------------------------------------------------- Standard documents - my $savefolderpath; - $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/) { + if ($folder eq '' || $supplementalflag) { $folder='default'; $savefolderpath = $env{'form.folderpath'}; - $env{'form.folderpath'}='default&'.&escape($tabtitles{'main'}{$crstype}); + $env{'form.folderpath'}='default&'.&escape(&mt('Content')); $uploadtag = ''; } @@ -3231,7 +3253,7 @@ NGFFORM my @importdoc = ( {''.$lt{extr}.''=>$extresourcesform}, {''.$lt{imsf}.''=>$imspform},); - $fileuploadform = create_form_ul(create_list_elements(@importdoc)) . '
' . $fileuploadform; + $fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '
' . $fileuploadform; push @specialdocumentsforma, ({''.$lt{navc}.''=>$newnavform}, {''.$lt{sipa}.''=>$newsmppageform}, @@ -3243,7 +3265,7 @@ NGFFORM {''.$lt{abou}.''=>$newaboutsomeoneform}, {''.$lt{rost}.''=>$newrosterform},); - $specialdocumentsform = create_form_ul(create_list_elements(@specialdocumentsforma)); + $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma)); } if($env{'form.pagepath'}) { @@ -3252,7 +3274,7 @@ if($env{'form.pagepath'}) { {''.&mt('Simple Problem').''=>$newsmpproblemform}, {''.&mt('Score Upload Form').''=>$newexuploadform} ); - $specialdocumentsform= create_form_ul(create_list_elements(@specialdocumentsforma)); + $specialdocumentsform= &create_form_ul(&create_list_elements(@specialdocumentsforma)); } my @tools = ( @@ -3265,41 +3287,37 @@ my %orderhash = ( 'aa' => ['Import Documents',$fileuploadform], 'bb' => ['Published Resources',$simpleeditdefaultform], 'cc' => ['Special Documents',$specialdocumentsform], - 'dd' => ['Tools', create_form_ul(create_list_elements(@tools)).&generate_admin_options(\%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); - if ($error) { - $r->print('

'.$error.'

'); - } - if ($hadchanges) { - &mark_hash_old(); - } + unless ($supplementalflag) { + my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype); + if ($error) { + $r->print('

'.$error.'

'); + } + if ($hadchanges) { + &mark_hash_old(); + } - &changewarning($r,''); -$r->print(&generate_edit_table($tid,\%orderhash)); + &changewarning($r,''); + $r->print(&generate_edit_table('1',\%orderhash)); + } -$r->print('
'); } -# ----------------------------------------------------- Supplemental documents - $active = 'style="display: none;"'; - if($activeClass == 1){ - $active = 'style="display: block;"'; - } - $r->print('
'); + +# Supplemental documents start here + my $folder=$env{'form.folder'}; - unless ($folder=~/^supplemental/) { + unless ($supplementalflag) { $folder='supplemental'; } if ($folder =~ /^supplemental$/ && (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) { - $env{'form.folderpath'} = 'supplemental&'. - &escape(&mt('Supplemental '.$crstype.' Documents')); + $env{'form.folderpath'} = &supplemental_base(); } elsif ($allowed) { $env{'form.folderpath'} = $savefolderpath; } @@ -3328,7 +3346,7 @@ $r->print('
'); SUPDOCFORM - $supupdocform .= create_form_ul(Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'})).""; + $supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'})).""; my $supnewfolderform=(< @@ -3383,30 +3401,27 @@ my @supimportdoc = ( {''.$lt{extr}.'' =>$supnewextform}, ); -$supupdocform = create_form_ul(create_list_elements(@supimportdoc)) . '
' . $supupdocform; +$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '
' . $supupdocform; my %suporderhash = ( '00' => ['Supnewfolder', $supnewfolderform], 'ee' => ['Import Documents',$supupdocform], - 'ff' => ['Special Documents',create_form_ul(create_list_elements(@specialdocs))] + 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))] ); - - my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype); - if ($error) { - $r->print('

'.$error.'

'); + if ($supplementalflag) { + my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype); + if ($error) { + $r->print('

'.$error.'

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

'.$error.'

'); } } - -$r->print('
'); -$r->print('
'); - + &endContentScreen($r); if ($allowed) { $r->print(' @@ -3497,7 +3512,7 @@ sub generate_admin_options { {''.$lt{sl}.'' =>"$lt{'sl'}"}, ); - return '
'.create_form_ul(create_list_elements(@list)).'
'; + return '
'.&create_form_ul(&create_list_elements(@list)).'
'; } @@ -3585,7 +3600,7 @@ sub editing_js { } } my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents'; - my $toplevelsupp = 'supplemental&Supplemental%20'.$crstype.'%20Documents'; + my $toplevelsupp = &supplemental_base(); return <