'
+ .&Apache::loncommon::end_scrollbox();
+ }
+ my $tid = 1;
+ if ($supplementalflag) {
+ $tid = 2;
}
if ($allowed) {
+ $r->print(&generate_edit_table($tid,$orderhash,$to_show));
&print_paste_buffer($r,$container);
+ } else {
+ $r->print($to_show);
}
return;
}
@@ -1682,11 +1799,10 @@ sub editor {
sub process_file_upload {
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
# upload a file, if present
- my $parseaction;
- if ($env{'form.parserflag'}) {
+ my ($parseaction,$showupload,$nextphase,$mimetype);
+ if ($env{'form.parserflag'}) {
$parseaction = 'parse';
}
- my $phase_status;
my $folder=$env{'form.folder'};
if ($folder eq '') {
$folder='default';
@@ -1705,7 +1821,8 @@ sub process_file_upload {
$LONCAPA::map::resources[1]='';
}
if ($fatal) {
- return 'failed';
+ $$upload_output = '
'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'
';
+ return;
}
my $destination = 'docs/';
if ($folder =~ /^supplemental/) {
@@ -1716,13 +1833,23 @@ sub process_file_upload {
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
$destination .= $2.'/';
}
-# this is for a course, not a user, so set coursedoc flag
-# probably the only place in the system where this should be "1"
+# this is for a course, not a user, so set context to coursedoc.
my $newidx=&LONCAPA::map::getresidx();
$destination .= $newidx;
- my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
+ my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
$parseaction,$allfiles,
- $codebase);
+ $codebase,undef,undef,undef,undef,
+ undef,undef,\$mimetype);
+ if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
+ my $stored = $1;
+ $showupload = '
');
+
+ my $active = '';
+# does this user have privileges to modify docs?
+ my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+ my $onclick;
+ my $href;
+
+ if ($allowed) {
+ $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;
@@ -2624,7 +2793,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',
@@ -2669,45 +2838,96 @@ 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 $addentries = {};
my $containertag;
my $uploadtag;
+# Do we directly jump somewhere?
+ if ($env{'form.command'} eq 'direct') {
+ (my $mapurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
+ my $maptitle = &Apache::lonnet::gettitle($mapurl);
+ $mapurl=~s{^.*/([^/]+)\.\w+$}{$1};
+ $env{'form.folderpath'}=
+ 'default&'.&Apache::lonhtmlcommon::entity_encode('Main Course Documents').
+ '&default&...::::&'.
+ &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
+ &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
+ }
+
+# Where do we store these for when we come back?
+ my $stored_folderpath='docs_folderpath';
+ if ($supplementalflag) {
+ $stored_folderpath='docs_sup_folderpath';
+ }
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['folderpath','pagepath',
- 'pagesymb']);
# 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));
@@ -2718,9 +2938,22 @@ sub handler {
$env{'form.pagename'}=&unescape(pop(@pagepath));
$env{'form.folder'}=pop(@pagepath);
$containertag = ''.
- '';
- $uploadtag = ''.
- '';
+ '';
+ $uploadtag =
+ ''.
+ ''.
+ '';
+ } 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 = '';
+ $uploadtag = '';
}
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
$showdoc='/'.$1;
@@ -2728,38 +2961,12 @@ 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');
}
}
-# subroutine to list form elements
-sub create_list_elements {
- my @formarr = @_;
- my $list = '';
- for my $button (@formarr){
- for my $picture(keys %$button) {
- #my $link = Apache::lonhtmlcommon::htmltag('a' ,$button->{$picture}, {href => "test"});
- $list .= Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});
- }
- }
- return $list;
-}
-
-# subroutine to create ul from list elements
-sub create_form_ul {
- my $list = shift;
- my $ul = Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
- return $ul;
-}
-
# get course data
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -2774,7 +2981,22 @@ sub create_form_ul {
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
if ($allowed) {
- $script .= &editing_js($udom,$uname);
+ my @tabids;
+ if ($supplementalflag) {
+ @tabids = ('002','ee2','ff2');
+ } else {
+ @tabids = ('aa1','bb1','cc1','ff1');
+ unless ($env{'form.pagepath'}) {
+ unshift(@tabids,'001');
+ push(@tabids,('dd1','ee1'));
+ }
+ }
+ my $tabidstr = join("','",@tabids);
+ $script .= &editing_js($udom,$uname).
+ &resize_contentdiv_js($tabidstr);
+ $addentries = {
+ onload => "javascript:resize_contentdiv('contentscroll','1','1');",
+ };
}
# -------------------------------------------------------------------- Body tag
$script = '