--- loncom/interface/londocs.pm 2010/12/07 01:15:39 1.442 +++ loncom/interface/londocs.pm 2010/12/11 14:28:12 1.447 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.442 2010/12/07 01:15:39 www Exp $ +# $Id: londocs.pm,v 1.447 2010/12/11 14:28:12 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; } @@ -2636,33 +2635,18 @@ 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"; - $onclick=''; - } else { - $href='#'; - $onclick=' onclick="javascript:showPage(this,\'mainCourseDocuments\',\'mainnav\',\'maincoursedoc\');"'; - } - $r->print('
  •       '.&mt('Content Editor').'      
  • '); + $r->print('
  •       '.&mt('Content Editor').'      
  • '); } - if (($mode eq 'navmaps') || ($mode eq 'tools')) { - $href="/adm/coursedocs"; - $onclick=''; - } else { - $href='#'; - $onclick=' onclick="javascript:showPage(this,\'mainCourseDocuments\',\'mainnav\',\'maincoursedoc\');"'; - } - - $r->print('
  • '.&mt('Supplemental Documents').'
  • '); + $r->print('
  • '.&mt('Supplemental Documents').'
  • '); $r->print(''); $r->print('
    ' .'
    '); @@ -2678,6 +2662,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'); @@ -2685,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', @@ -2730,45 +2718,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']); +# 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 +2828,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 +2859,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,12 +2988,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=(< @@ -2993,7 +2999,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 .=(<

    @@ -3041,14 +3047,16 @@ HIDDENFORM } # Generate the tabs - &startContentScreen($r,'docs'); + &startContentScreen($r,($supplementalflag?'supdocs':'docs')); + + # my $savefolderpath; if ($allowed) { 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(&mt('Content')); @@ -3242,7 +3250,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}, @@ -3254,7 +3262,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'}) { @@ -3263,7 +3271,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 = ( @@ -3276,36 +3284,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 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; } @@ -3334,7 +3343,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=(< @@ -3389,20 +3398,20 @@ 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.'

    '); @@ -3500,7 +3509,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)).'
    '; } @@ -3588,7 +3597,7 @@ sub editing_js { } } my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents'; - my $toplevelsupp = 'supplemental&Supplemental%20'.$crstype.'%20Documents'; + my $toplevelsupp = &supplemental_base(); return <