\n");
+ $r->print(&Apache::loncommon::end_data_table());
&untiehash();
$r->print(
- '');
+ '');
}
}
-# ------------------------------------------------------ Generate "export" button
+=pod
+
+=item exportbutton()
+
+ Generate "export" button
+
+=cut
sub exportbutton {
my $type = &Apache::loncommon::course_type();
@@ -264,6 +327,12 @@ sub exportbutton {
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'';
}
+=pod
+
+=item exportcourse()
+
+=cut
+
sub exportcourse {
my $r=shift;
my $type = &Apache::loncommon::course_type();
@@ -309,10 +378,10 @@ sub exportcourse {
chdir $cwd;
$outcome .= &mt('Download the zip file from IMS '.lc($type).' archive ',$imszipfile,);
if ($copyresult) {
- $outcome .= 'The following errors occurred during export - '.$copyresult;
+ $outcome .= &mt('The following errors occurred during export - [_1]',$copyresult);
}
} else {
- $outcome = ' Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file. ';
+ $outcome = ' '.&mt('Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.').' ';
}
}
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
@@ -818,7 +887,7 @@ sub extract_media {
$dirpath = $url;
$container = '';
}
- &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content);
+ &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content);
foreach my $embed_file (keys(%allfiles)) {
my $filename;
if ($embed_file =~ m#([^/]+)$#) {
@@ -902,8 +971,15 @@ sub store_template {
}
}
-# Imports the given (name, url) resources into the course
-# coursenum, coursedom, and folder must precede the list
+=pod
+
+=item group_import()
+
+ Imports the given (name, url) resources into the course
+ coursenum, coursedom, and folder must precede the list
+
+=cut
+
sub group_import {
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
@@ -924,7 +1000,7 @@ sub group_import {
my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
'output',$1.$2);
if ($result != m|^/uploaded/|) {
- $errtext.='Map not saved: A network error occured when trying to save the new map. ';
+ $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
$fatal = 2;
}
if ($fatal) {
@@ -949,7 +1025,7 @@ sub group_import {
}
sub breadcrumbs {
- my ($where)=@_;
+ my ($where,$allowed,$type)=@_;
&Apache::lonhtmlcommon::clear_breadcrumbs();
my (@folders);
if ($env{'form.pagepath'}) {
@@ -966,7 +1042,7 @@ sub breadcrumbs {
my $is_random_order=0;
while (@folders) {
my $folder=shift(@folders);
- my $foldername=shift(@folders);
+ my $foldername=shift(@folders);
if ($folderpath) {$folderpath.='&';}
$folderpath.=$folder.'&'.$foldername;
my $url='/adm/coursedocs?folderpath='.
@@ -982,6 +1058,13 @@ sub breadcrumbs {
if ($2) { $ishidden=1; }
if ($3) { $isencrypted=1; }
if ($4 ne '') { $is_random_order = 1; }
+ if ($folder eq 'supplemental') {
+ if ($allowed) {
+ $name = &mt('Supplemental '.$type.' Documents');
+ } else {
+ $name = &mt($type.' Documents');
+ }
+ }
&Apache::lonhtmlcommon::add_breadcrumb(
{'href'=>$url.$cpinfo,
'title'=>$name,
@@ -1057,10 +1140,12 @@ sub log_docs {
}
}
+=pod
+
+=item docs_change_log()
+
+=cut
-#
-# Docs Change Log
-#
sub docs_change_log {
my ($r)=@_;
my $folder=$env{'form.folder'};
@@ -1201,12 +1286,15 @@ sub update_paste_buffer {
# Mark for copying
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
if (&is_supplemental_title($title)) {
+ &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
($title) = &parse_supplemental_title($title);
+ } elsif ($env{'docs.markedcopy_supplemental'}) {
+ &Apache::lonnet::delenv('docs\\.markedcopy_supplemental');
}
$url=~s{http(:|:)//https(:|:)//}{https$2//};
- &Apache::lonnet::appenv('docs.markedcopy_title' => $title,
- 'docs.markedcopy_url' => $url);
+ &Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
+ 'docs.markedcopy_url' => $url});
delete($env{'form.markcopy'});
}
@@ -1233,7 +1321,7 @@ ENDPASTE
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
$icon .= '/folder_closed.gif';
}
- my $icon = '';
+ $icon = '';
$r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
}
if ($container eq 'page') {
@@ -1250,7 +1338,7 @@ ENDPASTE
}
sub do_paste_from_buffer {
- my ($coursenum,$coursedom) = @_;
+ my ($coursenum,$coursedom,$folder) = @_;
return 0 if (!$env{'form.pastemarked'});
@@ -1292,6 +1380,20 @@ sub do_paste_from_buffer {
$url = &LONCAPA::map::qtunescape($url);
# Now insert the URL at the bottom
my $newidx = &LONCAPA::map::getresidx($url);
+ if ($env{'docs.markedcopy_supplemental'}) {
+ if ($folder =~ /^supplemental/) {
+ $title = $env{'docs.markedcopy_supplemental'};
+ } else {
+ (undef,undef,$title) =
+ &parse_supplemental_title($env{'docs.markedcopy_supplemental'});
+ }
+ } else {
+ if ($folder=~/^supplemental/) {
+ $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
+ $env{'user.domain'}.'___&&&___'.$title;
+ }
+ }
+
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
push(@LONCAPA::map::order, $newidx);
# Store the result
@@ -1370,7 +1472,7 @@ sub handle_edit_cmd {
}
sub editor {
- my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$which)=@_;
+ my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
my $container= ($env{'form.pagepath'}) ? 'page'
: 'sequence';
@@ -1387,7 +1489,7 @@ sub editor {
}
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
- &breadcrumbs($folder);
+ &breadcrumbs($folder,$allowed,$type);
$r->print($breadcrumbtrail);
# ------------------------------------------------------------ Process commands
@@ -1412,7 +1514,7 @@ sub editor {
}
if ($env{'form.pastemarked'}) {
- &do_paste_from_buffer($coursenum,$coursedom);
+ &do_paste_from_buffer($coursenum,$coursedom,$folder);
($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
return $errtext if ($fatal);
}
@@ -1489,8 +1591,9 @@ sub editor {
$r->print('
'.&mt('Currently no documents.').'
');
}
$r->print("\n\n");
-
- &print_paste_buffer($r,$container);
+ if ($allowed) {
+ &print_paste_buffer($r,$container);
+ }
return;
}
@@ -1571,8 +1674,8 @@ sub process_file_upload {
$$upload_output .=
'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA. '.
- &ask_for_embedded_content('/adm/coursedocs',
- $state,$allfiles,$codebase);
+ &Apache::loncommon::ask_for_embedded_content(
+ '/adm/coursedocs',$state,$allfiles,$codebase);
} else {
$$upload_output .= 'No embedded items identified ';
}
@@ -1582,55 +1685,6 @@ sub process_file_upload {
return $phase_status;
}
-sub ask_for_embedded_content {
- my ($actionurl,$state,$allfiles,$codebase,$args)=@_;
- my $upload_output = '
- ';
- return $upload_output;
-}
-
sub process_secondary_uploads {
my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
my $folder=$env{'form.folder'};
@@ -1754,7 +1808,7 @@ sub entryline {
# no copy for published maps
$nocopy = 1;
} else {
- foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) {
+ foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
my ($title,$url,$ext,$type)=split(/\:/,$_);
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
$nocopy=1;
@@ -1979,7 +2033,13 @@ ENDPARMS
return $line;
}
-# ---------------------------------------------------------------- tie the hash
+=pod
+
+=item tiehash()
+
+tie the hash
+
+=cut
sub tiehash {
my ($mode)=@_;
@@ -2005,7 +2065,15 @@ sub untiehash {
return OK;
}
-# --------------------------------------------------------------- check on this
+
+=pod
+
+=item checkonthis()
+
+check on this
+
+=cut
+
sub checkonthis {
my ($r,$url,$level,$title)=@_;
@@ -2014,6 +2082,9 @@ sub checkonthis {
$r->rflush();
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
$r->print("\n ");
+ if ($level==0) {
+ $r->print(" ");
+ }
for (my $i=0;$i<=$level*5;$i++) {
$r->print(' ');
}
@@ -2023,7 +2094,7 @@ sub checkonthis {
my $result=&Apache::lonnet::repcopy(
&Apache::lonnet::filelocation('',$url));
if ($result eq 'ok') {
- $r->print(''.&mt('ok').'');
+ $r->print(''.&mt('ok').'');
$r->rflush();
&Apache::lonnet::countacc($url);
$url=~/\.(\w+)$/;
@@ -2033,7 +2104,7 @@ sub checkonthis {
for (my $i=0;$i<=$level*5;$i++) {
$r->print(' ');
}
- $r->print('- '.&mt('Rendering').': ');
+ $r->print('- '.&mt('Rendering:').' ');
my ($errorcount,$warningcount)=split(/:/,
&Apache::lonnet::ssi_body($url,
('grade_target'=>'web',
@@ -2042,13 +2113,11 @@ sub checkonthis {
($warningcount)) {
if ($errorcount) {
$r->print(''.
- $errorcount.' '.
- &mt('error(s)').' ');
+ &mt('[quant,_1,error]',$errorcount).'');
}
if ($warningcount) {
$r->print(''.
- $warningcount.' '.
- &mt('warning(s)').'');
+ &mt('[quant,_1,warning]',$warningcount).'');
}
} else {
$r->print(''.&mt('ok').'');
@@ -2066,21 +2135,27 @@ 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').'');
}
} else {
$r->print(''.&mt('access denied').'');
}
- }
- }
+ }
+ }
}
-#
-# ----------------------------------------------------------------- List Symbs
-#
+
+=pod
+
+=item list_symbs()
+
+List Symbs
+
+=cut
+
sub list_symbs {
my ($r) = @_;
@@ -2096,9 +2171,14 @@ sub list_symbs {
}
-#
-# -------------------------------------------------------------- Verify Content
-#
+=pod
+
+=item verifycontent()
+
+Verify Content
+
+=cut
+
sub verifycontent {
my ($r) = @_;
my $type = &Apache::loncommon::course_type();
@@ -2128,8 +2208,13 @@ sub verifycontent {
&mt('Return to DOCS').'');
}
+=pod
+
+=item devalidateversioncache() & checkversions()
+
+Check Versions
-# -------------------------------------------------------------- Check Versions
+=cut
sub devalidateversioncache {
my $src=shift;
@@ -2433,7 +2518,13 @@ sub changewarning {
$help{'Caching'}.''."\n\n");
}
-# =========================================== Breadcrumbs for special functions
+=pod
+
+=item init_breadcrumbs()
+
+Breadcrumbs for special functions
+
+=cut
sub init_breadcrumbs {
my ($form,$text)=@_;
@@ -2449,7 +2540,15 @@ sub init_breadcrumbs {
bug=>'Instructor Interface'});
}
-# ================================================================ Main Handler
+
+=pod
+
+=item handler()
+
+Main Handler
+
+=cut
+
sub handler {
my $r = shift;
&Apache::loncommon::content_type($r,'text/html');
@@ -2513,6 +2612,26 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['folderpath','pagepath',
'pagesymb']);
+# No folderpath, no pagepath, see if we have something stored
+ if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
+ &Apache::loncommon::restore_course_settings('docs_folderpath',
+ {'folderpath' => 'scalar'});
+ }
+ if (!$env{'form.folderpath'}) {
+ &Apache::loncommon::restore_course_settings('docs_folderpath',
+ {'pagepath' => 'scalar'});
+ }
+ if ($env{'form.pagepath'}) {
+ $env{'form.folderpath'}='';
+ }
+ if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
+ $env{'form.folderpath'} = 'supplemental&'.
+ &escape(&mt('Supplemental '.$type.' Documents')).'&'.
+ $env{'form.folderpath'};
+ }
+ &Apache::loncommon::store_course_settings('docs_folderpath',
+ {'pagepath' => 'scalar',
+ 'folderpath' => 'scalar'});
if ($env{'form.folderpath'}) {
my (@folderpath)=split('&',$env{'form.folderpath'});
$env{'form.foldername'}=&unescape(pop(@folderpath));
@@ -2774,7 +2893,7 @@ ENDCOURSEVERIFY
}
$hadchanges=0;
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
- $upload_output);
+ $upload_output,$type);
if ($error) {
$r->print('