--- loncom/interface/londocs.pm 2010/12/08 02:08:21 1.445 +++ loncom/interface/londocs.pm 2011/01/16 13:29:50 1.448 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.445 2010/12/08 02:08:21 www Exp $ +# $Id: londocs.pm,v 1.448 2011/01/16 13:29:50 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() .'
'
@@ -2663,6 +2664,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');
@@ -2759,29 +2764,39 @@ sub handler {
&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($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'};
}
+# 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,
+ &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));
@@ -2846,29 +2861,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 = ();
@@ -3310,8 +3316,7 @@ unless($env{'form.pagepath'}) {
}
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;
}
@@ -3594,7 +3599,7 @@ sub editing_js {
}
}
my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents';
- my $toplevelsupp = 'supplemental&Supplemental%20'.$crstype.'%20Documents';
+ my $toplevelsupp = &supplemental_base();
return <