--- loncom/interface/londocs.pm 2012/11/14 01:09:32 1.507
+++ loncom/interface/londocs.pm 2012/12/04 00:39:48 1.520
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.507 2012/11/14 01:09:32 raeburn Exp $
+# $Id: londocs.pm,v 1.520 2012/12/04 00:39:48 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;
@@ -312,61 +313,6 @@ 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',@_);
}
@@ -445,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{^/}{};
@@ -463,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));
@@ -813,16 +758,9 @@ sub print_paste_buffer {
}
}
$r->print('
'.$othercrs);
- if ($container eq 'page') {
- $r->print('
-
-
-');
- } else {
- $r->print('
+ $r->print('
');
- }
$r->print('');
} else {
$r->print(&mt('Paste buffer contains:').' '.$buffer.
@@ -1743,13 +1681,18 @@ sub handle_edit_cmd {
sub editor {
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
- $supplementalflag,$orderhash,$iconpath,$uploadtag)=@_;
- my $container= ($env{'form.pagepath'}) ? 'page'
- : 'sequence';
-
- my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
- &breadcrumbs($allowed,$crstype);
- $r->print($breadcrumbtrail);
+ $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';
+ }
my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
@@ -1912,35 +1855,67 @@ sub editor {
unless ($name) { $idx++; next; }
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
$coursenum,$coursedom,$crstype,
- $uploadtag,$supplementalflag);
+ $pathitem,$supplementalflag,$container);
$idx++;
$shown++;
}
&Apache::loncommon::end_data_table_count();
-
- 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').' | ';
+
+ 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;
}
- $to_show .= &Apache::loncommon::end_data_table_header_row();
+ $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
+ .''
+ .&mt('Currently no documents.')
+ .'
'
+ .&Apache::loncommon::end_scrollbox();
}
- $to_show .= $output.' '
- .&Apache::loncommon::end_data_table()
- .'
'
- .&Apache::loncommon::end_scrollbox();
} else {
- $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
- .''
- .&mt('Currently no documents.')
- .'
'
- .&Apache::loncommon::end_scrollbox();
+ if ($shown) {
+ $to_show = ''
+ .&Apache::loncommon::start_data_table('LC_tableOfContent')
+ .$output
+ .&Apache::loncommon::end_data_table()
+ .'
';
+ } else {
+ $to_show = ''
+ .&mt('Currently no documents.')
+ .'
'
+ }
}
my $tid = 1;
if ($supplementalflag) {
@@ -1952,19 +1927,6 @@ 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;
@@ -1985,7 +1947,7 @@ sub process_file_upload {
my $errtext='';
my $fatal=0;
my $container='sequence';
- if ($env{'form.pagepath'}) {
+ if ($env{'form.folderpath'} =~ /:1$/) {
$container='page';
}
($errtext,$fatal)=
@@ -2075,7 +2037,6 @@ 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,
@@ -2130,16 +2091,14 @@ sub is_supplemental_title {
sub entryline {
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
- $crstype,$uploadtag,$supplementalflag)=@_;
- my ($foldertitle,$pagetitle,$renametitle);
+ $crstype,$pathitem,$supplementalflag,$container)=@_;
+ my ($foldertitle,$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];
@@ -2150,34 +2109,34 @@ sub entryline {
my $line=&Apache::loncommon::start_data_table_row();
my ($form_start,$form_end,$form_common);
# Edit commands
- my ($container, $type, $esc_path, $path, $symb);
+ my ($type, $esc_path, $path, $symb);
+ if ($container eq 'page') {
+ $type = 'page';
+ } else {
+ $type = 'folder';
+ }
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'},'<>&"');
}
- if ($env{'form.pagepath'}) {
- $type = $container = 'page';
- $esc_path=&escape($env{'form.pagepath'});
- $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
- }
my $isexternal;
- if (!$supplementalflag && $residx) {
+ if ($residx) {
my $currurl = $url;
$currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
if ($currurl =~ m{^/adm/wrapper/ext/}) {
$isexternal = 1;
}
- 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 (!$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));
+ }
}
- my %lt;
+ my ($renamelink,%lt);
if ($allowed) {
my $incindex=$index+1;
my $selectbox='';
@@ -2274,7 +2233,7 @@ sub entryline {
$nocopy=1;
}
}
- my ($copylink,$cutlink,$removelink,$renamelink);
+ my ($copylink,$cutlink,$removelink);
my $skip_confirm = 0;
if ( $folder =~ /^supplemental/
|| ($url =~ m{( /smppg$
@@ -2287,22 +2246,22 @@ sub entryline {
$skip_confirm = 1;
}
- if ($nocopy) {
+ if ($nocopy) {
$copylink=(<$lt{'cp'}
ENDCOPY
} else {
$copylink=(<$lt{'cp'}
+$lt{'cp'}
ENDCOPY
}
- if ($nocut) {
+ if ($nocut) {
$cutlink=(<$lt{'ct'}
ENDCUT
} else {
$cutlink=(<$lt{'ct'}
+$lt{'ct'}
ENDCUT
}
if ($noremove) {
@@ -2311,12 +2270,14 @@ ENDCUT
ENDREM
} else {
$removelink=(<$lt{'rm'}
+$lt{'rm'}
ENDREM
}
- $renamelink=(<$lt{'rn'}
+ unless ($isexternal) {
+ $renamelink=(<$lt{'rn'}
ENDREN
+ }
$form_start = '
@@ -3840,7 +3755,7 @@ NDBFORM
my $newexuploadform=(<
- $uploadtag
+ $pathitem
$help{'Score_Upload_Form'}
@@ -3850,7 +3765,7 @@ NEXUFORM
my $newbulform=(<
- $uploadtag
+ $pathitem
$help{'Bulletin Board'}
@@ -3860,7 +3775,7 @@ NBFORM
my $newaboutmeform=(<
- $uploadtag
+ $pathitem
@@ -3871,7 +3786,7 @@ NAMFORM
my $newaboutsomeoneform=(<
- $uploadtag
+ $pathitem
@@ -3881,7 +3796,7 @@ NASOFORM
my $newrosterform=(<
- $uploadtag
+ $pathitem
@@ -3913,7 +3828,7 @@ NPFORM
$newfolderform=(<
-
+ $pathitem
$lt{'newf'}$help{'Adding_Folders'}
@@ -3923,7 +3838,7 @@ NFFORM
my $newsylform=(<
- $uploadtag
+ $pathitem
@@ -3935,7 +3850,7 @@ NSYLFORM
my $newgroupfileform=(<
- $uploadtag
+ $pathitem
@@ -3952,10 +3867,16 @@ NGFFORM
my @importdoc = (
- {'
'=>$extresourcesform},
- {'
'=>$imspform},
- {'
'=>$fileuploadform,
- });
+ {'
'=>$extresourcesform}
+ );
+ unless ($container eq 'page') {
+ push(@importdoc,
+ {'
'=>$imspform}
+ );
+ }
+ push(@importdoc,
+ {'
'=>$fileuploadform}
+ );
$fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
@gradingforma=(
@@ -3980,16 +3901,16 @@ my %orderhash = (
'bb' => ['Published Content',$importpubform],
'cc' => ['Grading Resources',$gradingform],
);
-unless ($env{'form.pagepath'}) {
+unless ($container eq 'page') {
$orderhash{'00'} = ['Newfolder',$newfolderform];
$orderhash{'dd'} = ['Collaboration',$communityform];
- $orderhash{'ee'} = ['Special Documents',$specialdocumentsform];
+ $orderhash{'ee'} = ['Special Pages',$specialdocumentsform];
}
$hadchanges=0;
unless (($supplementalflag || $toolsflag)) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
- $supplementalflag,\%orderhash,$iconpath,$uploadtag);
+ $supplementalflag,\%orderhash,$iconpath,$pathitem);
if ($error) {
$r->print(''.$error.'
');
}
@@ -4013,18 +3934,17 @@ unless ($env{'form.pagepath'}) {
} elsif ($allowed) {
$env{'form.folderpath'} = $savefolderpath;
}
- $env{'form.pagepath'} = '';
+ $pathitem = '';
if ($allowed) {
my $folderseq=
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
- my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
-
my $supupdocform=(<