--- loncom/interface/londocs.pm 2010/12/07 17:33:36 1.443 +++ loncom/interface/londocs.pm 2011/01/17 20:18:02 1.449 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.443 2010/12/07 17:33:36 www Exp $ +# $Id: londocs.pm,v 1.449 2011/01/17 20:18:02 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; } @@ -1653,7 +1652,8 @@ sub editor { &Apache::loncommon::end_data_table_count(); if ($shown) { - $r->print(&Apache::loncommon::start_data_table()); + $r->print(&Apache::loncommon::start_scrollbox('900px','880px','400px') + .&Apache::loncommon::start_data_table()); if ($allowed) { $r->print(&Apache::loncommon::start_data_table_header_row() .''.&mt('Move').'' @@ -1666,6 +1666,7 @@ sub editor { } $r->print($output .&Apache::loncommon::end_data_table() + .&Apache::loncommon::end_scrollbox() ); } else { $r->print('

' @@ -2636,33 +2637,19 @@ sub startContentScreen { $r->print('    '.&mt('Content Overview').'    '); my $active = ''; -# does this user have privileges to modify docs +# does this user have privileges to modify docs? my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); my $onclick; my $href; if ($allowed) { -# if (($mode eq 'navmaps') || ($mode eq 'tools')) { - $href="/adm/coursedocs?forcestandard=1"; - $onclick=''; -# } else { -# $href='#'; -# $onclick=' onclick="javascript:showPage(this,\'mainCourseDocuments\',\'mainnav\',\'maincoursedoc\');"'; -# } - $r->print('

  •       '.&mt('Content Editor').'      
  • '); - } -# if (($mode eq 'navmaps') || ($mode eq 'tools')) { - $href="/adm/coursedocs?forcesupplement=1"; - $onclick=''; -# } else { -# $href='#'; -# $onclick=' onclick="javascript:showPage(this,\'mainCourseDocuments\',\'mainnav\',\'maincoursedoc\');"'; -# } - - $r->print('
  • '.&mt('Supplemental Documents').'
  • '); + $r->print('
  •       '.&mt('Content Editor').'      
  • '); + } + $r->print('     '.&mt('Content Search').'     '); + $r->print('
  • '.&mt('Supplemental Documents').'
  • '); $r->print(''); $r->print('
    ' .'
    '); @@ -2678,6 +2665,10 @@ sub endContentScreen { $r->print('
    '); } +sub supplemental_base { + return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Documents')); +} + sub handler { my $r = shift; &Apache::loncommon::content_type($r,'text/html'); @@ -2730,45 +2721,83 @@ 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','forcesupplement','forcestandard']); +# 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 + &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)); @@ -2802,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'); @@ -2839,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 = (); @@ -2977,8 +2991,6 @@ 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'})).''; my $simpleeditdefaultform=(<