--- loncom/interface/londocs.pm 2010/08/14 04:28:21 1.432 +++ loncom/interface/londocs.pm 2010/08/16 00:30:47 1.433 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.432 2010/08/14 04:28:21 raeburn Exp $ +# $Id: londocs.pm,v 1.433 2010/08/16 00:30:47 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2721,6 +2721,17 @@ sub handler { '<input type="hidden" name="pagesymb" value="" />'; $uploadtag = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'. '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'; + } 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 = '<input type="hidden" name="folderpath" value="" />'; + $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />'; } if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) { $showdoc='/'.$1; @@ -3013,18 +3024,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 = '<input type="hidden" name="folderpath" value="" />'; - $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />'; - } $r->print(<<HIDDENFORM); <form name="renameform" method="post" action="/adm/coursedocs"> <input type="hidden" name="title" /> @@ -3589,6 +3588,12 @@ sub editing_js { p_ctr2b => '?[_98]' ); + my $crstype = &Apache::loncommon::course_type(); + my $docs_folderpath = $env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}; + my $docs_pagepath = $env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'}; + my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents'; + my $toplevelsupp = 'supplemental&Supplemental%20'.$crstype.'%20Documents'; + return <<ENDNEWSCRIPT; function makenewfolder(targetform,folderseq) { var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}'); @@ -3817,6 +3822,26 @@ 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 reg = new RegExp("^supplemental"); + if (pageId == 'mainCourseDocuments') { + if (reg.test(storedpath)) { + document.simpleedit.folderpath.value = '$toplevelmain'; + document.uploaddocument.folderpath.value = '$toplevelmain'; + document.newext.folderpath.value = '$toplevelmain'; + } + } else { + if (!reg.test(storedpath)) { + document.simpleedit.folderpath.value = '$toplevelsupp'; + document.supuploaddocument.folderpath.value = '$toplevelsupp'; + document.supnewext.folderpath.value = '$toplevelsupp'; + } + } + } return false; }