--- loncom/interface/londocs.pm 2013/01/04 00:17:48 1.484.2.20
+++ loncom/interface/londocs.pm 2012/10/31 05:10:16 1.500
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.484.2.20 2013/01/04 00:17:48 raeburn Exp $
+# $Id: londocs.pm,v 1.500 2012/10/31 05:10:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,7 +41,6 @@ use Apache::lonclonecourse;
use Apache::lonnavmaps;
use Apache::lonnavdisplay();
use Apache::lonuserstate();
-use Apache::lonextresedit();
use HTML::Entities;
use HTML::TokeParser;
use GDBM_File;
@@ -313,6 +312,61 @@ sub group_import {
return &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
}
+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 $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,
+ '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);
+}
+
sub log_docs {
return &Apache::lonnet::write_log('course','docslog',@_);
}
@@ -391,15 +445,17 @@ sub docs_change_log {
my %orderhash;
my $container='sequence';
my $pathitem;
- if ($env{'form.folderpath'} =~ /\:1$/) {
+ if ($env{'form.pagepath'}) {
$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{^/}{};
@@ -407,8 +463,7 @@ sub docs_change_log {
if ($supplementalflag) {
$tid = 2;
}
- my ($breadcrumbtrail) =
- &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
+ my ($breadcrumbtrail) = &breadcrumbs($allowed,$crstype);
$r->print($breadcrumbtrail.
&generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
$readfile));
@@ -651,7 +706,7 @@ sub print_paste_buffer {
$is_external = 1;
}
- my ($canpaste,$nopaste,$othercrs,$areachange);
+ my ($canpaste,$nopaste,$othercrs,$areachange,$is_uploaded_map);
if ($folder =~ /^supplemental/) {
$canpaste = &supp_pasteable($env{'docs.markedcopy_url'});
unless ($canpaste) {
@@ -758,9 +813,16 @@ sub print_paste_buffer {
}
}
$r->print(' '.$othercrs);
- $r->print('
+ if ($container eq 'page') {
+ $r->print('
+
+
+');
+ } else {
+ $r->print('
');
+ }
$r->print('');
} else {
$r->print(&mt('Paste buffer contains:').' '.$buffer.
@@ -1543,7 +1605,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.');
@@ -1681,18 +1743,13 @@ sub handle_edit_cmd {
sub editor {
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
- $supplementalflag,$orderhash,$iconpath,$pathitem)=@_;
- my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
- if ($allowed) {
- (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
- $is_random_order,$container) =
- &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
- $r->print($breadcrumbtrail);
- } elsif ($env{'form.folderpath'} =~ /\:1$/) {
- $container = 'page';
- } else {
- $container = 'sequence';
- }
+ $supplementalflag,$orderhash,$iconpath)=@_;
+ my $container= ($env{'form.pagepath'}) ? 'page'
+ : 'sequence';
+
+ my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
+ &breadcrumbs($allowed,$crstype);
+ $r->print($breadcrumbtrail);
my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
@@ -1771,18 +1828,6 @@ sub editor {
if (defined($item)) {
my ($name,$url,$residx)=
map {&unescape($_)} split(/\=/,$item);
- if ($url=~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
- my ($suffix,$errortxt,$locknotfreed) =
- &newmap_suffix($1,$2,$coursedom,$coursenum);
- if ($locknotfreed) {
- $r->print($locknotfreed);
- }
- if ($suffix) {
- $url =~ s/_new\./_$suffix./;
- } else {
- return $errortxt;
- }
- }
push(@imports, [$name, $url, $residx]);
}
}
@@ -1854,68 +1899,35 @@ sub editor {
unless ($name) { $name=(split(/\//,$url))[-1]; }
unless ($name) { $idx++; next; }
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
- $coursenum,$coursedom,$crstype,
- $pathitem,$supplementalflag,$container);
+ $coursenum,$crstype);
$idx++;
$shown++;
}
&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')
- .&Apache::loncommon::start_data_table(undef,'contentlist')
- .&Apache::loncommon::start_data_table_header_row()
- .''.&mt('Move').' '
- .''.&mt('Actions').' '
- .''.&mt('Document').' ';
- if ($folder !~ /^supplemental/) {
- $to_show .= ''.&mt('Settings').' ';
- }
- $to_show .= &Apache::loncommon::end_data_table_header_row()
- .$output.' '
- .&Apache::loncommon::end_data_table()
- .' '
- .&Apache::loncommon::end_scrollbox();
- } else {
- $to_show .= $toolslink
- .&Apache::loncommon::start_data_table('LC_tableOfContent')
- .$output.' '
- .&Apache::loncommon::end_data_table();
- }
- } else {
- if (!$allowed) {
- $to_show .= $toolslink;
+
+ if ($shown) {
+ $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
+ .&Apache::loncommon::start_data_table(undef,'contentlist');
+ if ($allowed) {
+ $to_show .= &Apache::loncommon::start_data_table_header_row()
+ .''.&mt('Move').' '
+ .''.&mt('Actions').' '
+ .''.&mt('Document').' ';
+ if ($folder !~ /^supplemental/) {
+ $to_show .= ''.&mt('Settings').' ';
}
- $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
- .''
- .&mt('Currently no documents.')
- .'
'
- .&Apache::loncommon::end_scrollbox();
+ $to_show .= &Apache::loncommon::end_data_table_header_row();
}
+ $to_show .= $output.' '
+ .&Apache::loncommon::end_data_table()
+ .' '
+ .&Apache::loncommon::end_scrollbox();
} else {
- if ($shown) {
- $to_show = ''
- .&Apache::loncommon::start_data_table('LC_tableOfContent')
- .$output
- .&Apache::loncommon::end_data_table()
- .'
';
- } else {
- $to_show = ''
- .&mt('Currently no documents.')
- .'
'
- }
+ $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
+ .''
+ .&mt('Currently no documents.')
+ .'
'
+ .&Apache::loncommon::end_scrollbox();
}
my $tid = 1;
if ($supplementalflag) {
@@ -1927,6 +1939,19 @@ sub editor {
$readfile));
&print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
} else {
+ if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
+ #Function Box for Supplemental Content for users with mdc priv.
+ my $funcname = &mt('Folder Editor');
+ $r->print(
+ &Apache::loncommon::head_subbox(
+ &Apache::lonhtmlcommon::start_funclist().
+ &Apache::lonhtmlcommon::add_item_funclist(
+ ''.
+ ' '.
+ ' ').
+ &Apache::lonhtmlcommon::end_funclist()));
+ }
$r->print($to_show);
}
return;
@@ -1947,7 +1972,7 @@ sub process_file_upload {
my $errtext='';
my $fatal=0;
my $container='sequence';
- if ($env{'form.folderpath'} =~ /:1$/) {
+ if ($env{'form.pagepath'}) {
$container='page';
}
($errtext,$fatal)=
@@ -2037,6 +2062,7 @@ sub process_file_upload {
my $archiveurl = &HTML::Entities::encode($url,'<>&"');
my %archiveitems = (
folderpath => $env{'form.folderpath'},
+ pagepath => $env{'form.pagepath'},
cmd => $nextphase,
newidx => $newidx,
position => $position,
@@ -2090,53 +2116,41 @@ sub is_supplemental_title {
# --------------------------------------------------------------- An entry line
sub entryline {
- my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
- $crstype,$pathitem,$supplementalflag,$container)=@_;
- my ($foldertitle,$renametitle);
+ my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
+ my ($foldertitle,$pagetitle,$renametitle);
if (&is_supplemental_title($title)) {
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
+ $pagetitle = $foldertitle;
} else {
$title=&HTML::Entities::encode($title,'"<>&\'');
$renametitle=$title;
$foldertitle=$title;
+ $pagetitle=$title;
}
my $orderidx=$LONCAPA::map::order[$index];
+
$renametitle=~s/\\/\\\\/g;
$renametitle=~s/\"\;/\\\"/g;
$renametitle=~s/ /%20/g;
my $line=&Apache::loncommon::start_data_table_row();
my ($form_start,$form_end,$form_common);
# Edit commands
- my ($type, $esc_path, $path, $symb);
- if ($container eq 'page') {
- $type = 'page';
- } else {
- $type = 'folder';
- }
+ my ($container, $type, $esc_path, $path, $symb);
if ($env{'form.folderpath'}) {
+ $type = 'folder';
+ $container = 'sequence';
$esc_path=&escape($env{'form.folderpath'});
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
}
- my $isexternal;
- if ($residx) {
- my $currurl = $url;
- $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
- if ($currurl =~ m{^/adm/wrapper/ext/}) {
- $isexternal = 1;
- }
- if (!$supplementalflag) {
- my $path = 'uploaded/'.
- $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
- $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
- $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
- $residx,
- &Apache::lonnet::declutter($currurl));
- }
+ if ($env{'form.pagepath'}) {
+ $type = $container = 'page';
+ $esc_path=&escape($env{'form.pagepath'});
+ $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
+ $symb=&escape($env{'form.pagesymb'});
}
- my ($renamelink,%lt);
if ($allowed) {
my $incindex=$index+1;
my $selectbox='';
@@ -2159,20 +2173,13 @@ sub entryline {
}
$selectbox.='';
}
- %lt=&Apache::lonlocal::texthash(
+ my %lt=&Apache::lonlocal::texthash(
'up' => 'Move Up',
'dw' => 'Move Down',
'rm' => 'Remove',
'ct' => 'Cut',
'rn' => 'Rename',
- 'cp' => 'Copy',
- 'ex' => 'External Resource',
- 'ed' => 'Edit',
- 'pr' => 'Preview',
- 'sv' => 'Save',
- 'ul' => 'URL',
- 'ti' => 'Title',
- );
+ 'cp' => 'Copy');
my $nocopy=0;
my $nocut=0;
my $noremove=0;
@@ -2233,7 +2240,10 @@ sub entryline {
$nocopy=1;
}
}
- my ($copylink,$cutlink,$removelink);
+ my $copylink=' ';
+ my $cutlink=' ';
+ my $removelink=' ';
+
my $skip_confirm = 0;
if ( $folder =~ /^supplemental/
|| ($url =~ m{( /smppg$
@@ -2241,43 +2251,26 @@ sub entryline {
|/aboutme$
|/navmaps$
|/bulletinboard$
- |\.html$)}x)
- || $isexternal) {
+ |\.html$
+ |^/adm/wrapper/ext)}x)) {
$skip_confirm = 1;
}
- if ($nocopy) {
- $copylink=(<$lt{'cp'}
-ENDCOPY
- } else {
+ if (!$nocopy) {
$copylink=(<$lt{'cp'}
+$lt{'cp'}
ENDCOPY
}
- if ($nocut) {
- $cutlink=(<$lt{'ct'}
-ENDCUT
- } else {
+ if (!$nocut) {
$cutlink=(<$lt{'ct'}
+$lt{'ct'}
ENDCUT
}
- if ($noremove) {
- $removelink=(<$lt{'rm'}
-ENDREM
- } else {
+ if (!$noremove) {
$removelink=(<$lt{'rm'}
+$lt{'rm'}
ENDREM
}
- unless ($isexternal) {
- $renamelink=(<$lt{'rn'}
-ENDREN
- }
$form_start = '
';
- my $ro_set=
- ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
- $rand_order_text =
+ if ($rpicknum ne '') {
+ $rand_pick_text .= ': '.$rpicknum.' ';
+ }
+ $rand_pick_text .= '';
+ my $ro_set=
+ ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
+ $rand_order_text =
$form_start.
$form_common.'
'.&mt('Random Order').' ';
- }
- } 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;
- }
}
- 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%"';
+ 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);
+ }
+ if (($external) && ($allowed)) {
+ my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
+ $external = ' '.&mt('Edit').' ';
+ } else {
+ undef($external);
}
my $reinit;
if ($crstype eq 'Community') {
$reinit = &mt('(re-initialize community to access)');
} else {
$reinit = &mt('(re-initialize course to access)');
- }
- $line.=''.$editlink.$renamelink;
+ }
+ $line.=' ';
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
$line.=' ';
} elsif ($url) {
@@ -2468,7 +2457,7 @@ $form_common.'
} else {
$line.=' ';
}
- $line.=' ';
+ $line.=' ';
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
$line.=''.$title.' ';
} elsif ($url) {
@@ -2477,7 +2466,7 @@ $form_common.'
} else {
$line.=$title.' '.$reinit.' ';
}
- $line.="$extresform ";
+ $line.=$external."";
$rand_pick_text = ' ' if ($rand_pick_text eq '');
$rand_order_text = ' ' if ($rand_order_text eq '');
if (($allowed) && ($folder!~/^supplemental/)) {
@@ -2508,30 +2497,6 @@ ENDPARMS
return $line;
}
-sub newmap_suffix {
- my ($area,$container,$coursedom,$coursenum) = @_;
- my ($prefix,$idtype,$errtext,$locknotfreed);
- $prefix = 'docs';
- if ($area eq 'supplemental') {
- $prefix = 'supp';
- }
- $prefix .= $container;
- $idtype = 'concat';
- my ($suffix,$freedlock,$error) =
- &Apache::lonnet::get_timebased_id($prefix,'num','uploadedmaps',
- $coursedom,$coursenum);
- if (!$suffix) {
- $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
- if ($error) {
- $errtext .= ' '.$error;
- }
- }
- if ($freedlock ne 'ok') {
- $locknotfreed = ''.&mt('There was a problem removing a lockfile. This will prevent creation of additional folders or composite pages in this course. Please contact the domain coordinator for your LON-CAPA domain.').'
';
- }
- return ($suffix,$errtext,$locknotfreed);
-}
-
=pod
=item tiehash()
@@ -2627,7 +2592,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').' ');
}
@@ -2673,7 +2638,7 @@ sub list_symbs {
$r->print(&Apache::loncommon::start_data_table_row().
''.$res->compTitle().' '.
''.$res->symb().' '.
- &Apache::loncommon::end_data_table_row());
+ &Apache::loncommon::start_data_table_row());
$count ++;
}
if (!$count) {
@@ -2683,7 +2648,6 @@ sub list_symbs {
}
$r->print(&Apache::loncommon::end_data_table());
}
- $r->print(&endContentScreen());
}
@@ -2714,7 +2678,6 @@ sub verifycontent {
}
&untiehash();
$r->print(''.&mt('Done').'
');
- $r->print(&endContentScreen());
}
@@ -2794,7 +2757,7 @@ sub checkversions {
if ($env{'form.timerange'} eq 'all') {
# show all documents
$header=&mt('All Documents in '.$crstype);
- $allsel=' selected="selected"';
+ $allsel=1;
foreach my $key (keys(%hash)) {
if ($key=~/^ids\_(\/res\/.+)$/) {
my $src=$1;
@@ -2815,19 +2778,19 @@ sub checkversions {
.&mt('seconds');
if ($env{'form.timerange'}==-1) {
$seltext='since start of course';
- $startsel=' selected="selected"';
+ $startsel='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="selected"';
+ $monthsel='selected';
} elsif ($env{'form.timerange'}==604800) {
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
- $weeksel=' selected="selected"';
+ $weeksel='selected';
} elsif ($env{'form.timerange'}==86400) {
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
- $daysel=' selected="selected"';
+ $daysel='selected';
}
$header=&mt('Content changed').' '.$seltext;
} else {
@@ -2865,11 +2828,11 @@ sub checkversions {
$lt{'cd'}
-$lt{'al'}
-$lt{'st'}
-$lt{'lm'}
-$lt{'lw'}
-$lt{'sy'}
+$lt{'al'}
+$lt{'st'}
+$lt{'lm'}
+$lt{'lw'}
+$lt{'sy'}
@@ -2885,93 +2848,111 @@ $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().
- ''.&mt('Resources').' '.
- "$lt{'mr'} ".
- "$lt{'ve'} ".
- "$lt{'vu'} ".
- ''.&mt('History').' '.
- &Apache::loncommon::end_data_table_header_row()
- );
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ ''.&mt('Resources').' '.
+ "$lt{'mr'} ".
+ "$lt{'ve'} ".
+ "$lt{'vu'} ".
+ ''.&mt('History').' '.
+ '');
foreach my $key (sort(keys(%changes))) {
#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);
+ 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);
$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 {
- $r->print($currentversion);
+ $entries_per_col = $num_entries/$num_ver_col + 1;
}
- $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').' ');
+ 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(' ');
- }
- $r->print(' '.&Apache::loncommon::end_data_table_row());
+ }
}
- $r->print(
- &Apache::loncommon::end_data_table().
- ' '.
- ''
- );
+ $r->print(''.&Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table().
+ ' ');
&untiehash();
- $r->print(&endContentScreen());
}
sub mark_hash_old {
@@ -3003,6 +2984,11 @@ 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();
@@ -3043,9 +3029,9 @@ sub init_breadcrumbs {
sub create_list_elements {
my @formarr = @_;
my $list = '';
- foreach my $button (@formarr){
- foreach my $picture (keys(%{$button})) {
- $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
+ for my $button (@formarr){
+ for my $picture(keys %$button) {
+ $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});
}
}
return $list;
@@ -3068,6 +3054,7 @@ sub startContentScreen {
if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
$output .= ' '.&mt('Content Overview').' '."\n";
$output .= ' '.&mt('Content Search').' '."\n";
+ $output .= ' '.&mt('Content Index').' '."\n";
$output .= ''.&mt('Supplemental Content').' ';
} else {
$output .= ' '.&mt('Content Editor').' '."\n";
@@ -3114,8 +3101,7 @@ sub handler {
'Adding_External_Resource','Navigate_Content',
'Adding_Folders','Docs_Overview', 'Load_Map',
'Supplemental','Score_Upload_Form','Adding_Pages',
- 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
- 'Uploading_From_Harddrive',
+ 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
'Check_Resource_Versions','Verify_Content') {
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
}
@@ -3175,9 +3161,9 @@ sub handler {
# Get the parameters that may be needed
#
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['folderpath',
- 'forcesupplement','forcestandard',
- 'tools','symb','command','supppath']);
+ ['folderpath','pagepath',
+ 'pagesymb','forcesupplement','forcestandard',
+ 'tools','symb','command']);
# 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
@@ -3191,7 +3177,7 @@ sub handler {
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
- if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) {
+ if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) {
$supplementalflag=0;
}
if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
@@ -3206,25 +3192,80 @@ sub handler {
my $addentries = {};
my $container;
my $containertag;
- my $pathitem;
+ my $uploadtag;
# Do we directly jump somewhere?
if ($env{'form.command'} eq 'direct') {
my ($mapurl,$id,$resurl);
if ($env{'form.symb'} ne '') {
- $env{'form.folderpath'}=
- &Apache::loncommon::symb_to_docspath($env{'form.symb'});
+ ($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'}='';
+ }
} elsif ($env{'form.supppath'} ne '') {
$env{'form.folderpath'}=$env{'form.supppath'};
}
} elsif ($env{'form.command'} eq 'editdocs') {
$env{'form.folderpath'} = 'default&'.
- &Apache::lonhtmlcommon::entity_encode('Main Course Content').
- ':::::';
+ &Apache::lonhtmlcommon::entity_encode('Main Course Content');
+ $env{'form.pagepath'}='';
} elsif ($env{'form.command'} eq 'editsupp') {
$env{'form.folderpath'} = 'default&'.
&Apache::lonhtmlcommon::entity_encode('Supplemental Content');
+ $env{'form.pagepath'}='';
}
# Where do we store these for when we come back?
@@ -3233,21 +3274,24 @@ sub handler {
$stored_folderpath='docs_sup_folderpath';
}
-# No folderpath, and in edit mode, see if we have something stored
- if ((!$env{'form.folderpath'}) && $allowed) {
+# No folderpath, no pagepath, see if we have something stored
+ if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
&Apache::loncommon::restore_course_settings($stored_folderpath,
- {'folderpath' => 'scalar'});
- unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
- undef($env{'form.folderpath'});
- }
+ {'folderpath' => 'scalar'});
}
# 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()
@@ -3255,42 +3299,48 @@ sub handler {
$env{'form.folderpath'};
}
# If after all of this, we still don't have any paths, make them
- unless ($env{'form.folderpath'}) {
+ unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) {
if ($supplementalflag) {
$env{'form.folderpath'}=&supplemental_base();
} else {
- $env{'form.folderpath'}='default'.&escape(&mt('Main '.$crstype.' Documents')).
- ':::::';
+ $env{'form.folderpath'}='default';
}
}
# Store this
unless ($toolsflag) {
- if ($allowed) {
- &Apache::loncommon::store_course_settings($stored_folderpath,
- {'folderpath' => 'scalar'});
- }
- my $folderpath;
+ &Apache::loncommon::store_course_settings($stored_folderpath,
+ {'pagepath' => 'scalar',
+ 'folderpath' => 'scalar'});
if ($env{'form.folderpath'}) {
- $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);
+ 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 =
+ ' '.
+ ' '.
+ ' ';
} else {
- if ($env{'form.folder'} eq '' ||
- $env{'form.folder'} eq 'supplemental') {
- $folderpath='default&'.
- &escape(&mt('Main '.$crstype.' Documents')).
- ':::::';
+ 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 = ' ';
}
- $containertag = ' ';
- $pathitem = ' ';
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
$showdoc='/'.$1;
}
@@ -3328,7 +3378,7 @@ sub handler {
@tabids = ('002','ee2','ff2');
} else {
@tabids = ('aa1','bb1','cc1','ff1');
- unless ($env{'form.folderpath'} =~ /\:1$/) {
+ unless ($env{'form.pagepath'}) {
unshift(@tabids,'001');
push(@tabids,('dd1','ee1'));
}
@@ -3337,8 +3387,7 @@ sub handler {
$script .= &editing_js($udom,$uname,$supplementalflag).
&history_tab_js().
&inject_data_js().
- &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr).
- &Apache::lonextresedit::extedit_javascript();
+ &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr);
$addentries = {
onload => "javascript:resize_scrollbox('contentscroll','1','1');",
};
@@ -3346,10 +3395,6 @@ sub handler {
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 = '