--- loncom/interface/londocs.pm 2012/07/13 13:36:24 1.491 +++ loncom/interface/londocs.pm 2012/12/29 17:37:21 1.525 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.491 2012/07/13 13:36:24 raeburn Exp $ +# $Id: londocs.pm,v 1.525 2012/12/29 17:37:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonclonecourse; use Apache::lonnavmaps; use Apache::lonnavdisplay(); use Apache::lonuserstate(); +use Apache::lonextresedit(); use HTML::Entities; use HTML::TokeParser; use GDBM_File; @@ -69,10 +70,14 @@ sub mapread { } sub storemap { - my ($coursenum,$coursedom,$map)=@_; + my ($coursenum,$coursedom,$map,$contentchg)=@_; + my $report; + if (($contentchg) && ($map =~ /^default/)) { + $report = 1; + } my ($outtext,$errtext)= &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. - $map,1); + $map,1,$report); if ($errtext) { return ($errtext,2); } $hadchanges=1; @@ -305,67 +310,11 @@ sub group_import { join(':', ($name, $url, $ext, 'normal', 'res')); } } - return &storemap($coursenum, $coursedom, $folder.'.'.$container); -} - -sub breadcrumbs { - my ($allowed,$crstype)=@_; - &Apache::lonhtmlcommon::clear_breadcrumbs(); - my (@folders); - if ($env{'form.pagepath'}) { - @folders = split('&',$env{'form.pagepath'}); - } else { - @folders=split('&',$env{'form.folderpath'}); - } - my $folderpath; - my $cpinfo=''; - my $plain=''; - my $randompick=-1; - my $isencrypted=0; - my $ishidden=0; - my $is_random_order=0; - while (@folders) { - my $folder=shift(@folders); - my $foldername=shift(@folders); - if ($folderpath) {$folderpath.='&';} - $folderpath.=$folder.'&'.$foldername; - my $url; - if ($allowed) { - $url = '/adm/coursedocs?folderpath='; - } else { - $url = '/adm/supplemental?folderpath='; - } - $url .= &escape($folderpath); - my $name=&unescape($foldername); -# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername - $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//; - if ($1 ne '') { - $randompick=$1; - } else { - $randompick=-1; - } - if ($2) { $ishidden=1; } - if ($3) { $isencrypted=1; } - if ($4 ne '') { $is_random_order = 1; } - if ($folder eq 'supplemental') { - $name = &mt('Supplemental '.$crstype.' Content'); - } - &Apache::lonhtmlcommon::add_breadcrumb( - {'href'=>$url.$cpinfo, - 'title'=>$name, - 'text'=>$name, - 'no_mt'=>1, - }); - $plain.=$name.' > '; - } - $plain=~s/\>\;\s*$//; - return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', - undef, undef, 1 ),$randompick,$ishidden, - $isencrypted,$plain,$is_random_order); + return &storemap($coursenum, $coursedom, $folder.'.'.$container,1); } sub log_docs { - return &Apache::lonnet::instructor_log('docslog',@_); + return &Apache::lonnet::write_log('course','docslog',@_); } { @@ -442,17 +391,15 @@ sub docs_change_log { my %orderhash; my $container='sequence'; my $pathitem; - if ($env{'form.pagepath'}) { + if ($env{'form.folderpath'} =~ /\:1$/) { $container='page'; - $pathitem = ''; - } else { - my $folderpath=$env{'form.folderpath'}; - if ($folderpath eq '') { - $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents')); - } - $pathitem = ''; } + my $folderpath=$env{'form.folderpath'}; + if ($folderpath eq '') { + $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents').':::::'); + } + $pathitem = ''; my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container"; my $jumpto = $readfile; $jumpto =~ s{^/}{}; @@ -460,7 +407,8 @@ sub docs_change_log { if ($supplementalflag) { $tid = 2; } - my ($breadcrumbtrail) = &breadcrumbs($allowed,$crstype); + my ($breadcrumbtrail) = + &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1); $r->print($breadcrumbtrail. &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto, $readfile)); @@ -612,7 +560,7 @@ sub docs_change_log { } sub update_paste_buffer { - my ($coursenum,$coursedom) = @_; + my ($coursenum,$coursedom,$folder) = @_; return if (!defined($env{'form.markcopy'})); return if (!defined($env{'form.copyfolder'})); @@ -633,75 +581,204 @@ sub update_paste_buffer { } $url=~s{http(:|:)//https(:|:)//}{https$2//}; - &Apache::lonnet::appenv({'docs.markedcopy_title' => $title, - 'docs.markedcopy_url' => $url}); + (my $cmd,undef)=split('_',$env{'form.cmd'}); + + my %addtoenv = ( + 'docs.markedcopy_title' => $title, + 'docs.markedcopy_url' => $url, + 'docs.markedcopy_cmd' => $cmd, + ); + &Apache::lonnet::delenv('docs.markedcopy_nested'); + &Apache::lonnet::delenv('docs.markedcopy_nestednames'); + if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) { + my $prefix = $1; + my $subdir =$2; + if ($subdir eq '') { + $subdir = $prefix; + } + my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps); + &contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps, + \%hierarchy,\%titles,\%allmaps); + if (ref($hierarchy{$url}) eq 'HASH') { + my ($nested,$nestednames); + &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames); + $nested =~ s/\&$//; + $nestednames =~ s/\Q___&&&___\E$//; + if ($nested ne '') { + $addtoenv{'docs.markedcopy_nested'} = $nested; + } + if ($nestednames ne '') { + $addtoenv{'docs.markedcopy_nestednames'} = $nestednames; + } + } + } + &Apache::lonnet::appenv(\%addtoenv); delete($env{'form.markcopy'}); } +sub recurse_uploaded_maps { + my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_; + if (ref($hierarchy->{$url}) eq 'HASH') { + my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}})); + my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}})); + my (@uploaded,@names,%shorter); + for (my $i=0; $i<@maps; $i++) { + my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$}); + if ($inner ne '') { + push(@uploaded,$inner); + push(@names,&escape($titles[$i])); + $shorter{$maps[$i]} = $inner; + } + } + $$nestref .= "$dir:".join(',',@uploaded).'&'; + $$namesref .= "$dir:".(join(',',@names)).'___&&&___'; + foreach my $map (@maps) { + if ($shorter{$map} ne '') { + &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref); + } + } + } + return; +} + sub print_paste_buffer { - my ($r,$container,$folder) = @_; + my ($r,$container,$folder,$coursedom,$coursenum) = @_; return if (!defined($env{'docs.markedcopy_url'})); - my $is_external; + my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent); my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1]; if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { $is_external = 1; } - my $canpaste; + my ($canpaste,$nopaste,$othercrs,$areachange,$is_uploaded_map); if ($folder =~ /^supplemental/) { - $canpaste = &supp_pasteable($env{'docs.markedcopy_url'}); + $canpaste = &supp_pasteable($env{'docs.markedcopy_url'}); + unless ($canpaste) { + $nopaste = &mt('Paste into Supplemental Content unavailable for this type of content.'); + } } else { $canpaste = 1; } - my $pasteinfo; if ($canpaste) { - $pasteinfo = '
'; + } + } elsif ($supplementalflag && !$allowed) { + $url .= ($url =~ /\?/) ? '&':'?'; + $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"'); + if ($title) { + $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"'); + } + if ($isexternal && $orderidx) { + $url .= '&idx='.$orderidx; + } } - if ($ispage) { - my $pagename=&escape($pagetitle); - my $pagepath; - my $folderpath=$env{'form.folderpath'}; - if ($folderpath) { $pagepath = $folderpath.'&' }; - $pagepath.=$pagearg.'&'.$pagename; - my $symb=$env{'form.pagesymb'}; - if (!$symb) { - my $path='uploaded/'. - $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. - $env{'course.'.$env{'request.course.id'}.'.num'}.'/'; - $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence', - $residx, - $path.$pagearg.'.page'); - } - $url.='pagepath='.&escape($pagepath). - '&pagesymb='.&escape($symb).$cpinfo; - } - if (($external) && ($allowed)) { - my $form = ($folder =~ /^default/)? 'newext' : 'supnewext'; - $external = ' '.&mt('Edit').''; - } else { - undef($external); + my ($tdalign,$tdwidth); + if ($allowed) { + my $fileloc = + &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url)); + if ($isexternal) { + ($editlink,$extresform) = + &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem); + } elsif (!$isfolder && !$ispage) { + my ($cfile,$home,$switchserver,$forceedit,$forceview) = + &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url); + if (($cfile ne '') && ($symb ne '' || $supplementalflag)) { + my $jscall = + &Apache::lonhtmlcommon::jump_to_editres($cfile,$home, + $switchserver, + $forceedit, + undef,$symb, + &escape($env{'form.folderpath'}), + $renametitle,'','',1); + if ($jscall) { + $editlink = ''.&mt('Edit').' '."\n"; + } + } + } + $tdalign = ' align="right" valign="top"'; + $tdwidth = ' width="80%"'; } my $reinit; if ($crstype eq 'Community') { $reinit = &mt('(re-initialize community to access)'); } else { $reinit = &mt('(re-initialize course to access)'); - } - $line.=''.&mt('Done').'
'); + $r->print(&endContentScreen()); } @@ -2413,7 +2798,7 @@ sub checkversions { if ($env{'form.timerange'} eq 'all') { # show all documents $header=&mt('All Documents in '.$crstype); - $allsel=1; + $allsel=' selected="selected"'; foreach my $key (keys(%hash)) { if ($key=~/^ids\_(\/res\/.+)$/) { my $src=$1; @@ -2434,19 +2819,19 @@ sub checkversions { .&mt('seconds'); if ($env{'form.timerange'}==-1) { $seltext='since start of course'; - $startsel='selected'; + $startsel=' selected="selected"'; $env{'form.timerange'}=time; } $starttime=time-$env{'form.timerange'}; if ($env{'form.timerange'}==2592000) { $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; - $monthsel='selected'; + $monthsel=' selected="selected"'; } elsif ($env{'form.timerange'}==604800) { $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; - $weeksel='selected'; + $weeksel=' selected="selected"'; } elsif ($env{'form.timerange'}==86400) { $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; - $daysel='selected'; + $daysel=' selected="selected"'; } $header=&mt('Content changed').' '.$seltext; } else { @@ -2484,11 +2869,11 @@ sub checkversions { @@ -2504,110 +2889,93 @@ $lt{'sc'}: -'.&mt('Resources').' | '. - "$lt{'mr'} | ". - "$lt{'ve'} | ". - "$lt{'vu'} | ". - ''.&mt('History').' | '. - ''); + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''.&mt('Resources').' | '. + "$lt{'mr'} | ". + "$lt{'ve'} | ". + "$lt{'vu'} | ". + ''.&mt('History').' | '. + &Apache::loncommon::end_data_table_header_row() + ); foreach my $key (sort(keys(%changes))) { - if ($changes{$key}>$starttime) { - my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); - my $currentversion=&Apache::lonnet::getversion($key); - if ($currentversion<0) { - $currentversion=''.&mt('Could not be determined.').''; - } - my $linkurl=&Apache::lonnet::clutter($key); + #excludes not versionable problems from resource version history: + next unless ($changes{$key}>$starttime && $key !~ /^\/res\/lib\/templates/); + my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); + my $currentversion=&Apache::lonnet::getversion($key); + if ($currentversion<0) { + $currentversion=''.&mt('Could not be determined.').''; + } + my $linkurl=&Apache::lonnet::clutter($key); $r->print( - &Apache::loncommon::end_data_table_header_row(). &Apache::loncommon::start_data_table_row(). - ''.&Apache::lonnet::gettitle($linkurl).' '. + ' | '.&Apache::lonnet::gettitle($linkurl).' '. ''.$linkurl.' | '.
- ''.$currentversion.' ('. + ' | '.$currentversion.' ('. &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).') | '.
- ''); -# Used in course - my $usedversion=$hash{'version_'.$linkurl}; - if (($usedversion) && ($usedversion ne 'mostrecent')) { - if($usedversion != $currentversion){ + ' | ' + ); + # Used in course + my $usedversion=$hash{'version_'.$linkurl}; + if (($usedversion) && ($usedversion ne 'mostrecent')) { + if ($usedversion != $currentversion) { $r->print(''.$usedversion.''); - }else{ + } else { $r->print($usedversion); } - } else { - $r->print($currentversion); - } - $r->print(' | '); -# Set version - $r->print(&Apache::loncommon::select_form($setversions{$linkurl}, - 'set_version_'.$linkurl, - {'select_form_order' => - ['',1..$currentversion,'mostrecent'], - '' => '', - 'mostrecent' => &mt('most recent'), - map {$_,$_} (1..$currentversion)})); - my $lastold=1; - for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { - my $url=$root.'.'.$prevvers.'.'.$extension; - if (&Apache::lonnet::metadata($url,'lastrevisiondate')< - $starttime) { - $lastold=$prevvers; - } - } - # - # Code to figure out how many version entries should go in - # each of the four columns - my $entries_per_col = 0; - my $num_entries = ($currentversion-$lastold); - if ($num_entries % $num_ver_col == 0) { - $entries_per_col = $num_entries/$num_ver_col; } else { - $entries_per_col = $num_entries/$num_ver_col + 1; + $r->print($currentversion); } - my $entries_count = 0; - $r->print(' | ');
- my $cols_output = 1;
- for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
- my $url=$root.'.'.$prevvers.'.'.$extension;
- $r->print(''.&mt('Version').' '.$prevvers.' ('.
- &Apache::lonlocal::locallocaltime(
- &Apache::lonnet::metadata($url,
- 'lastrevisiondate')
- ).
- ')');
- if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
- $r->print(' '.&mt('Diffs').'');
- }
- $r->print(' '); - if (++$entries_count % $entries_per_col == 0) { - $r->print(' | ');
- if ($cols_output != $num_ver_col) {
- $r->print(''); - $cols_output++; - } - } - } - while($cols_output++ < $num_ver_col) { - $r->print(' | '); + $r->print(' | '); + # Set version + $r->print(&Apache::loncommon::select_form( + $setversions{$linkurl}, + 'set_version_'.$linkurl, + {'select_form_order' => ['',1..$currentversion,'mostrecent'], + '' => '', + 'mostrecent' => &mt('most recent'), + map {$_,$_} (1..$currentversion)})); + my $lastold=1; + for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { + my $url=$root.'.'.$prevvers.'.'.$extension; + if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) { + $lastold=$prevvers; + } + } + $r->print(' | '); + # List all available versions + $r->print('');
+ for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
+ my $url=$root.'.'.$prevvers.'.'.$extension;
+ $r->print(
+ ''
+ .''
+ .&mt('Version [_1]',$prevvers).''
+ .' ('.&Apache::lonlocal::locallocaltime(
+ &Apache::lonnet::metadata($url,'lastrevisiondate'))
+ .')');
+ if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
+ $r->print(
+ ' &').
+ '" target="diffs">'.&mt('Diffs').'');
}
- }
+ $r->print(' '); + } + $r->print(' | '.&Apache::loncommon::end_data_table_row());
}
- $r->print(''.&Apache::loncommon::end_data_table_row().
- &Apache::loncommon::end_data_table().
- '');
+ $r->print(
+ &Apache::loncommon::end_data_table().
+ ''.
+ ''
+ );
&untiehash();
+ $r->print(&endContentScreen());
}
sub mark_hash_old {
@@ -2639,11 +3007,6 @@ sub changewarning {
my $pathvar='folderpath';
my $path=&escape($env{'form.folderpath'});
if (!defined($url)) {
- if (defined($env{'form.pagepath'})) {
- $pathvar='pagepath';
- $path=&escape($env{'form.pagepath'});
- $path.='&pagesymb='.&escape($env{'form.pagesymb'});
- }
$url='/adm/coursedocs?'.$pathvar.'='.$path;
}
my $course_type = &Apache::loncommon::course_type();
@@ -2684,9 +3047,9 @@ sub init_breadcrumbs {
sub create_list_elements {
my @formarr = @_;
my $list = '';
- for my $button (@formarr){
- for my $picture(keys %$button) {
- $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});
+ foreach my $button (@formarr){
+ foreach my $picture (keys(%{$button})) {
+ $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
}
}
return $list;
@@ -2756,7 +3119,8 @@ sub handler {
'Adding_External_Resource','Navigate_Content',
'Adding_Folders','Docs_Overview', 'Load_Map',
'Supplemental','Score_Upload_Form','Adding_Pages',
- 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
+ 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
+ 'Uploading_From_Harddrive',
'Check_Resource_Versions','Verify_Content') {
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
}
@@ -2816,9 +3180,9 @@ sub handler {
# Get the parameters that may be needed
#
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['folderpath','pagepath',
- 'pagesymb','forcesupplement','forcestandard',
- 'tools','symb','command']);
+ ['folderpath',
+ 'forcesupplement','forcestandard',
+ 'tools','symb','command','supppath']);
# 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
@@ -2832,7 +3196,7 @@ sub handler {
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
- if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) {
+ if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) {
$supplementalflag=0;
}
if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
@@ -2847,106 +3211,58 @@ sub handler {
my $addentries = {};
my $container;
my $containertag;
- my $uploadtag;
+ my $pathitem;
# Do we directly jump somewhere?
- if ($env{'form.command'} eq 'direct') {
- my ($mapurl,$id,$resurl);
+ if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
if ($env{'form.symb'} ne '') {
- ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
- if ($resurl=~/\.(sequence|page)$/) {
- $mapurl=$resurl;
- } elsif ($resurl eq 'adm/navmaps') {
- $mapurl=$env{'course.'.$env{'request.course.id'}.'.url'};
- }
- my $mapresobj;
- my $navmap = Apache::lonnavmaps::navmap->new();
- if (ref($navmap)) {
- $mapresobj = $navmap->getResourceByUrl($mapurl);
- }
- $mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1};
- my $type=$2;
- my $path;
- if (ref($mapresobj)) {
- my $pcslist = $mapresobj->map_hierarchy();
- if ($pcslist ne '') {
- foreach my $pc (split(/,/,$pcslist)) {
- next if ($pc <= 1);
- my $res = $navmap->getByMapPc($pc);
- if (ref($res)) {
- my $thisurl = $res->src();
- $thisurl=~s{^.*/([^/]+)\.\w+$}{$1};
- my $thistitle = $res->title();
- $path .= '&'.
- &Apache::lonhtmlcommon::entity_encode($thisurl).'&'.
- &Apache::lonhtmlcommon::entity_encode($thistitle).
- ':'.$res->randompick().
- ':'.$res->randomout().
- ':'.$res->encrypted().
- ':'.$res->randomorder();
- }
- }
- }
- $path .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
- &Apache::lonhtmlcommon::entity_encode($mapresobj->title()).
- ':'.$mapresobj->randompick().
- ':'.$mapresobj->randomout().
- ':'.$mapresobj->encrypted().
- ':'.$mapresobj->randomorder();
- } else {
- my $maptitle = &Apache::lonnet::gettitle($mapurl);
- $path = '&default&...::::'.
- '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
- &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
- }
- $path = 'default&'.
- &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
- $path;
- if ($type eq 'sequence') {
- $env{'form.folderpath'}=$path;
- $env{'form.pagepath'}='';
- } else {
- $env{'form.pagepath'}=$path;
- $env{'form.folderpath'}='';
- }
+ $env{'form.folderpath'}=
+ &Apache::loncommon::symb_to_docspath($env{'form.symb'});
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
+ $env{'form.command'}.'_'.$env{'form.symb'}});
} elsif ($env{'form.supppath'} ne '') {
$env{'form.folderpath'}=$env{'form.supppath'};
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
+ $env{'form.command'}.'_'.$env{'form.supppath'}});
}
} elsif ($env{'form.command'} eq 'editdocs') {
- $env{'form.folderpath'} = 'default&'.
- &Apache::lonhtmlcommon::entity_encode('Main Course Content');
- $env{'form.pagepath'}='';
+ $env{'form.folderpath'} = 'default&'.
+ &Apache::lonhtmlcommon::entity_encode('Main Course Content').
+ ':::::';
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
} elsif ($env{'form.command'} eq 'editsupp') {
- $env{'form.folderpath'} = 'default&'.
+ $env{'form.folderpath'} = 'supplemental&'.
&Apache::lonhtmlcommon::entity_encode('Supplemental Content');
- $env{'form.pagepath'}='';
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
+ } elsif ($env{'form.command'} eq 'contents') {
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
+ } elsif ($env{'form.command'} eq 'home') {
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
}
+
# 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'})) {
+# No folderpath, and in edit mode, see if we have something stored
+ if ((!$env{'form.folderpath'}) && $allowed) {
&Apache::loncommon::restore_course_settings($stored_folderpath,
- {'folderpath' => 'scalar'});
+ {'folderpath' => 'scalar'});
+ unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
+ undef($env{'form.folderpath'});
+ }
}
# If we are not allowed to make changes, all we can see are supplemental docs
if (!$allowed) {
- $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'});
- }
# 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_base()
@@ -2954,48 +3270,42 @@ sub handler {
$env{'form.folderpath'};
}
# If after all of this, we still don't have any paths, make them
- unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) {
+ unless ($env{'form.folderpath'}) {
if ($supplementalflag) {
$env{'form.folderpath'}=&supplemental_base();
} else {
- $env{'form.folderpath'}='default';
+ $env{'form.folderpath'}='default'.&escape(&mt('Main '.$crstype.' Documents')).
+ ':::::';
}
}
# Store this
unless ($toolsflag) {
- &Apache::loncommon::store_course_settings($stored_folderpath,
- {'pagepath' => 'scalar',
- 'folderpath' => 'scalar'});
+ if ($allowed) {
+ &Apache::loncommon::store_course_settings($stored_folderpath,
+ {'folderpath' => 'scalar'});
+ }
+ my $folderpath;
if ($env{'form.folderpath'}) {
- my (@folderpath)=split('&',$env{'form.folderpath'});
- $env{'form.foldername'}=&unescape(pop(@folderpath));
- $env{'form.folder'}=pop(@folderpath);
- $container='sequence';
- }
- if ($env{'form.pagepath'}) {
- my (@pagepath)=split('&',$env{'form.pagepath'});
- $env{'form.pagename'}=&unescape(pop(@pagepath));
- $env{'form.folder'}=pop(@pagepath);
- $container='page';
- $containertag = ''.
- '';
- $uploadtag =
- ''.
- ''.
- '';
+ $folderpath = $env{'form.folderpath'};
+ my (@folders)=split('&',$env{'form.folderpath'});
+ $env{'form.foldername'}=&unescape(pop(@folders));
+ if ($env{'form.foldername'} =~ /\:1$/) {
+ $container = 'page';
+ } else {
+ $container = 'sequence';
+ }
+ $env{'form.folder'}=pop(@folders);
} 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'));
- }
+ if ($env{'form.folder'} eq '' ||
+ $env{'form.folder'} eq 'supplemental') {
+ $folderpath='default&'.
+ &escape(&mt('Main '.$crstype.' Documents')).
+ ':::::';
}
- $containertag = '';
- $uploadtag = '';
}
+ $containertag = '';
+ $pathitem = '';
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
$showdoc='/'.$1;
}
@@ -3033,7 +3343,7 @@ sub handler {
@tabids = ('002','ee2','ff2');
} else {
@tabids = ('aa1','bb1','cc1','ff1');
- unless ($env{'form.pagepath'}) {
+ unless ($env{'form.folderpath'} =~ /\:1$/) {
unshift(@tabids,'001');
push(@tabids,('dd1','ee1'));
}
@@ -3042,11 +3352,19 @@ sub handler {
$script .= &editing_js($udom,$uname,$supplementalflag).
&history_tab_js().
&inject_data_js().
- &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr);
+ &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr).
+ &Apache::lonextresedit::extedit_javascript();
$addentries = {
onload => "javascript:resize_scrollbox('contentscroll','1','1');",
};
}
+ if ($env{'docs.markedcopy_url'}) {
+ $script .= &paste_popup_js();
+ }
+ my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
+ &mt('Switch server?');
+
+
}
# -------------------------------------------------------------------- Body tag
$script = '
---|