--- loncom/interface/londocs.pm 2012/12/03 14:47:30 1.519 +++ loncom/interface/londocs.pm 2013/01/04 00:11:59 1.527 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.519 2012/12/03 14:47:30 raeburn Exp $ +# $Id: londocs.pm,v 1.527 2013/01/04 00:11:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -651,7 +651,7 @@ sub print_paste_buffer { $is_external = 1; } - my ($canpaste,$nopaste,$othercrs,$areachange,$is_uploaded_map); + my ($canpaste,$nopaste,$othercrs,$areachange); if ($folder =~ /^supplemental/) { $canpaste = &supp_pasteable($env{'docs.markedcopy_url'}); unless ($canpaste) { @@ -1543,7 +1543,7 @@ sub apply_fixups { if ($folder !~ /^supplemental/) { $report = 1; } - my ($outtext,$errtext) = + (my $outtext,$errtext) = &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report); if ($errtext) { return &mt('Paste failed: an error occurred saving the folder or page.'); @@ -1694,7 +1694,11 @@ sub editor { $container = 'sequence'; } - my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container"; + my $jumpto; + + unless ($supplementalflag) { + $jumpto = "'uploaded/$coursedom/$coursenum/$folder.$container'"; + } unless ($allowed) { $randompick = -1; @@ -1862,6 +1866,16 @@ sub editor { &Apache::loncommon::end_data_table_count(); if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) { + my $toolslink = '' + .'
' + .&Apache::loncommon::help_open_menu('Navigation Screen', + 'Navigation_Screen',undef,'RAT') + .''.&mt('Tools:').'

'; if ($shown) { if ($allowed) { $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll') @@ -1879,19 +1893,15 @@ sub editor { .'
' .&Apache::loncommon::end_scrollbox(); } else { - $to_show = '' - .'
'.&Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT') - .''.&mt('Tools:').'

' + $to_show .= $toolslink .&Apache::loncommon::start_data_table('LC_tableOfContent') .$output.' ' .&Apache::loncommon::end_data_table(); } } else { + if (!$allowed) { + $to_show .= $toolslink; + } $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll') .'
' .&mt('Currently no documents.') @@ -2437,7 +2447,7 @@ $form_common.' $forceedit, undef,$symb, &escape($env{'form.folderpath'}), - $renametitle); + $renametitle,'','',1); if ($jscall) { $editlink = ''.&mt('Edit').' '."\n"; @@ -2621,7 +2631,7 @@ sub checkonthis { $r->print(''.&mt('connection down').''); } elsif ($result eq 'not_found') { unless ($url=~/\$/) { - $r->print(''.&mt('not found').''); + $r->print(''.&mt('not found').''); } else { $r->print(''.&mt('unable to verify variable URL').''); } @@ -2667,7 +2677,7 @@ sub list_symbs { $r->print(&Apache::loncommon::start_data_table_row(). ''.$res->compTitle().''. ''.$res->symb().''. - &Apache::loncommon::start_data_table_row()); + &Apache::loncommon::end_data_table_row()); $count ++; } if (!$count) { @@ -2677,6 +2687,7 @@ sub list_symbs { } $r->print(&Apache::loncommon::end_data_table()); } + $r->print(&endContentScreen()); } @@ -2707,6 +2718,7 @@ sub verifycontent { } &untiehash(); $r->print('

'.&mt('Done').'

'); + $r->print(&endContentScreen()); } @@ -2786,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; @@ -2807,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 { @@ -2857,11 +2869,11 @@ sub checkversions {
$lt{'cd'}
@@ -2877,111 +2889,93 @@ $lt{'sc'}: - ENDHEADERS #number of columns for version history - my $num_ver_col = 1; $r->print( - &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(). - ''. - "". - "". - "". - ''. - ''); + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''. + "". + "". + "". + ''. + &Apache::loncommon::end_data_table_header_row() + ); foreach my $key (sort(keys(%changes))) { #excludes not versionable problems from resource version history: - if ($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); + 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(). - ''. - ''. - ''); - if ($cols_output != $num_ver_col) { - $r->print(''); + # List all available versions + $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 { @@ -3221,84 +3215,33 @@ sub handler { # 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(). - ':'.$res->is_page(); - } - } - } - $path =~ s/^\&//; - my $maptitle = $mapresobj->title(); - if ($mapurl eq 'default') { - $maptitle = 'Main Course Documents'; - } - $path .= (($path ne '')? '&' : ''). - &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. - &Apache::lonhtmlcommon::entity_encode($maptitle). - ':'.$mapresobj->randompick(). - ':'.$mapresobj->randomout(). - ':'.$mapresobj->encrypted(). - ':'.$mapresobj->randomorder(). - ':'.$mapresobj->is_page(); - } else { - my $maptitle = &Apache::lonnet::gettitle($mapurl); - my $ispage = (($type eq 'page')? 1 : ''); - if ($mapurl eq 'default') { - $maptitle = 'Main Course Documents'; - } - $path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. - &Apache::lonhtmlcommon::entity_encode($maptitle).':::::'.$ispage; - } - unless ($mapurl eq 'default') { - $path = 'default&'. - &Apache::lonhtmlcommon::entity_encode('Main Course Documents'). - ':::::&'.$path; - } - $env{'form.folderpath'}=$path; + $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.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'); + &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) { @@ -3309,6 +3252,9 @@ sub handler { if ((!$env{'form.folderpath'}) && $allowed) { &Apache::loncommon::restore_course_settings($stored_folderpath, {'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 @@ -4288,15 +4234,15 @@ sub generate_edit_table { my $form; my $activetab; my $active; - if($env{'form.active'} ne ''){ + if (($env{'form.active'} ne '') && ($env{'form.active'} ne 'aa')) { $activetab = $env{'form.active'}; } my $backicon = $iconpath.'clickhere.gif'; - my $backtext = &mt('Exit'); + my $backtext = &mt('Exit Editor'); $form = '
'. '
'.&mt('Resources').'$lt{'mr'}$lt{'ve'}$lt{'vu'}'.&mt('History').''.&mt('Resources').'$lt{'mr'}$lt{'ve'}$lt{'vu'}'.&mt('History').''.&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('
'); - $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(''); + 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('