--- loncom/interface/londocs.pm 2012/07/13 13:36:24 1.491 +++ loncom/interface/londocs.pm 2013/01/10 17:10:30 1.531 @@ -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.531 2013/01/10 17:10:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,7 +40,7 @@ use Apache::lonxml; 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 +69,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; @@ -148,7 +152,7 @@ sub dumpcourse { $r->print(&endContentScreen()); return ''; } - my ($ca,$cd)=split(/\@/,$env{'form.authorspace'}); + my ($ca,$cd)=split(/\:/,$env{'form.authorspace'}); $r->print('
'."\n". + &mt('The following files are either dependencies of a web page or references within a folder and/or composite page for which errors occurred during import:')."\n". + '
'.&mt('Done').'
'); + $r->print(&endContentScreen()); } @@ -2413,7 +2884,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 +2905,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 +2955,11 @@ sub checkversions { @@ -2504,110 +2975,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 +3093,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 +3133,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 +3205,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 +3266,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 +3282,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 +3297,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 +3356,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 +3429,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 +3438,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 = '
---|