--- loncom/interface/londocs.pm 2008/12/21 15:47:50 1.314.2.2
+++ loncom/interface/londocs.pm 2010/05/23 20:44:10 1.325.2.9
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.314.2.2 2008/12/21 15:47:50 raeburn Exp $
+# $Id: londocs.pm,v 1.325.2.9 2010/05/23 20:44:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,6 +26,8 @@
# http://www.lon-capa.org/
#
+
+
package Apache::londocs;
use strict;
@@ -53,15 +55,10 @@ my %alreadyseen=();
my $hadchanges;
-# Available help topics
my %help=();
-# Mapread read maps into LONCAPA::map:: global arrays
-# @order and @resources, determines status
-# sets @order - pointer to resources in right order
-# sets @resources - array with the resources with correct idx
-#
+
sub mapread {
my ($coursenum,$coursedom,$map)=@_;
@@ -81,20 +78,20 @@ sub storemap {
return ($errtext,0);
}
-# ----------------------------------------- Return hash with valid author names
+
sub authorhosts {
my %outhash=();
my $home=0;
my $other=0;
- foreach (keys %env) {
- if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
+ foreach my $key (keys(%env)) {
+ if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
my $role=$1;
my $realm=$2;
- my ($start,$end)=split(/\./,$env{$_});
+ my ($start,$end)=split(/\./,$env{$key});
if (($start) && ($start>time)) { next; }
if (($end) && (time>$end)) { next; }
- my $ca; my $cd;
+ my ($ca,$cd);
if ($1 eq 'au') {
$ca=$env{'user.name'};
$cd=$env{'user.domain'};
@@ -116,21 +113,21 @@ sub authorhosts {
}
return ($home,$other,%outhash);
}
-# ------------------------------------------------------ Generate "dump" button
+
sub dumpbutton {
my ($home,$other,%outhash)=&authorhosts();
- my $type = &Apache::loncommon::course_type();
+ my $crstype = &Apache::loncommon::course_type();
if ($home+$other==0) { return ''; }
if ($home) {
return '
'.
' '.
+ &mt('Dump '.$crstype.' DOCS to Construction Space').'" />'.
&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').
'
';
} else {
return ''.
- &mt('Dump '.$type.
+ &mt('Dump '.$crstype.
' DOCS to Construction Space: available on other servers').
'
';
}
@@ -141,14 +138,15 @@ sub clean {
$title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
return $title;
}
-# -------------------------------------------------------- Actually dump course
+
+
sub dumpcourse {
my ($r) = @_;
- my $type = &Apache::loncommon::course_type();
- $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
- '');
+ '
');
}
}
-# ------------------------------------------------------ Generate "export" button
+
sub exportbutton {
- my $type = &Apache::loncommon::course_type();
- return ''.
- '
'.
+ my $crstype = &Apache::loncommon::course_type();
+ return '
'.
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'
';
}
+
+
sub exportcourse {
my $r=shift;
- my $type = &Apache::loncommon::course_type();
+ my $crstype = &Apache::loncommon::course_type();
my %discussiontime = &Apache::lonnet::dump('discussiontimes',
$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
- my $numdisc = keys %discussiontime;
+ my $numdisc = keys(%discussiontime);
my $navmap = Apache::lonnavmaps::navmap->new();
+ if (!defined($navmap)) {
+ $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package').
+ '
'.&mt('IMS Export Failed').' '.
+ '
');
+ if ($crstype eq 'Community') {
+ $r->print(&mt('Unable to retrieve information about community contents'));
+ } else {
+ $r->print(&mt('Unable to retrieve information about course contents'));
+ }
+ $r->print('
');
+ if ($crstype eq 'Community') {
+ $r->print(&mt('Return to Community Editor'));
+ } else {
+ $r->print(&mt('Return to Course Editor'));
+ }
+ $r->print(' ');
+ &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
+ return;
+ }
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
my $curRes;
my $outcome;
@@ -293,7 +312,17 @@ sub exportcourse {
my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
if (@exportitems == 0 && @discussions == 0) {
- $outcome = '
As you did not select any content items or discussions for export, an IMS package has not been created. Please
go back to select either content items or discussions for export';
+ $outcome =
+ '
'
+ .&mt('As you did not select any content items or discussions'
+ .' for export, an IMS package has not been created.')
+ .'
'
+ .'
'
+ .&mt('Please [_1]go back[_2] to select either content items'
+ .' or discussions for export.'
+ ,''
+ ,' ')
+ .'
';
} else {
my $now = time;
my %symbs;
@@ -316,35 +345,53 @@ sub exportcourse {
open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
close(OUTPUT);
chdir $cwd;
- $outcome .= &mt('Download the zip file from
IMS '.lc($type).' archive ',$imszipfile,);
+ $outcome .= '
'
+ .&mt('[_1]Your IMS package[_2] is ready for download.'
+ ,'',' ')
+ .'
';
if ($copyresult) {
- $outcome .= &mt('The following errors occurred during export - [_1]',$copyresult);
+ $outcome .= '
'
+ .&mt('The following errors occurred during export - [_1]'
+ ,$copyresult)
+ .'
';
}
} else {
- $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.').'
';
+ $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.')
+ .'
'
+ .'
'
+ .&mt('Go Back')
+ .'
';
}
}
- $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
+ $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export'));
$r->print($outcome);
$r->print(&Apache::loncommon::end_page());
} else {
- my $display;
- $display = '
';
my $curRes;
my $depth = 0;
my $count = 0;
@@ -353,13 +400,13 @@ sub exportcourse {
my %parent = ();
my %children = ();
my $lastcontainer = $startcount;
- my @bgcolors = ('#F6F6F6','#FFFFFF');
- $display .= ''.
- ' '.
+ $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package',
+ $scripttag));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($crstype).' to IMS content package'));
+ $r->print($display.
+ '
'.
'
'.
- &Apache::loncommon::end_page());
+ &mt('Export').'" />');
}
}
@@ -499,7 +551,7 @@ sub create_ims_store {
my $manifestfilename = $$tempexport.$manifest;
if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) {
$$manifestok=1;
- print $ims_manifest
+ print $ims_manifest
''."\n".
'is_sequence() || $curRes->is_page()) {
$lastcontainer = $count;
}
- if (grep/^$count$/,@$exportitems) {
+ if (grep(/^$count$/,@$exportitems)) {
&get_dependencies($exportitems,\%parent,$depth,\@dependencies);
}
}
@@ -581,7 +633,7 @@ sub build_package {
if (ref($curRes)) {
$count ++;
- if ((grep/^$count$/,@$exportitems) || (grep/^$count$/,@dependencies)) {
+ if ((grep(/^$count$/,@$exportitems)) || (grep(/^$count$/,@dependencies))) {
my $symb = $curRes->symb();
my $isvisible = 'true';
my $resourceref;
@@ -615,11 +667,11 @@ sub build_package {
' '."\n".
' '."\n";
- foreach (@hrefs) {
+ foreach my $item (@hrefs) {
$imsresources .=
- ' '."\n";
+ ' '."\n";
}
- if (grep/^$count$/,@$discussions) {
+ if (grep(/^$count$/,@$discussions)) {
my $ressymb = $symb;
my $mode;
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
@@ -660,8 +712,8 @@ sub build_package {
sub get_dependencies {
my ($exportitems,$parent,$depth,$dependencies) = @_;
if ($depth > 1) {
- if ((!grep/^$$parent{$depth}$/,@$exportitems) && (!grep/^$$parent{$depth}$/,@$dependencies)) {
- push @$dependencies, $$parent{$depth};
+ if ((!grep(/^$$parent{$depth}$/,@$exportitems)) && (!grep(/^$$parent{$depth}$/,@$dependencies))) {
+ push(@{$dependencies},$$parent{$depth});
if ($depth > 2) {
&get_dependencies($exportitems,$parent,$depth-1,$dependencies);
}
@@ -867,7 +919,7 @@ sub extract_media {
my $copiedfile;
if ($copiedfile = Apache::File->new('>'.$destination)) {
print $copiedfile $embed_content;
- push @{$href}, 'resources/'.$count.'/res/'.$filename;
+ push(@{$href},'resources/'.$count.'/res/'.$filename);
my $attrib_regexp = '';
if (@{$allfiles{$embed_file}} > 1) {
$attrib_regexp = join('|',@{$allfiles{$embed_file}});
@@ -911,8 +963,7 @@ sub store_template {
}
}
-# Imports the given (name, url) resources into the course
-# coursenum, coursedom, and folder must precede the list
+
sub group_import {
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
@@ -958,7 +1009,7 @@ sub group_import {
}
sub breadcrumbs {
- my ($where,$allowed,$type)=@_;
+ my ($allowed,$crstype)=@_;
&Apache::lonhtmlcommon::clear_breadcrumbs();
my (@folders);
if ($env{'form.pagepath'}) {
@@ -993,9 +1044,9 @@ sub breadcrumbs {
if ($4 ne '') { $is_random_order = 1; }
if ($folder eq 'supplemental') {
if ($allowed) {
- $name = &mt('Supplemental '.$type.' Documents');
+ $name = &mt('Supplemental '.$crstype.' Documents');
} else {
- $name = &mt($type.' Documents');
+ $name = &mt($crstype.' Documents');
}
}
&Apache::lonhtmlcommon::add_breadcrumb(
@@ -1047,7 +1098,7 @@ sub log_docs {
'currentfolder' => $env{'form.folder'});
if ($parmidx) {
$storehash{'parameter_res'}=$oldresources[$parmidx];
- foreach my $parm (keys %parmaction) {
+ foreach my $parm (keys(%parmaction)) {
$storehash{'parameter_action_'.$parm}=$parmaction{$parm};
$storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
}
@@ -1074,9 +1125,9 @@ sub log_docs {
}
-#
-# Docs Change Log
-#
+
+
+
sub docs_change_log {
my ($r)=@_;
my $folder=$env{'form.folder'};
@@ -1220,7 +1271,7 @@ sub update_paste_buffer {
&Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
($title) = &parse_supplemental_title($title);
} elsif ($env{'docs.markedcopy_supplemental'}) {
- &Apache::lonnet::delenv('docs\\.markedcopy_supplemental');
+ &Apache::lonnet::delenv('docs.markedcopy_supplemental');
}
$url=~s{http(:|:)//https(:|:)//}{https$2//};
@@ -1271,7 +1322,9 @@ ENDPASTE
sub do_paste_from_buffer {
my ($coursenum,$coursedom,$folder) = @_;
- return 0 if (!$env{'form.pastemarked'});
+ if (!$env{'form.pastemarked'}) {
+ return;
+ }
# paste resource to end of list
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
@@ -1279,7 +1332,7 @@ sub do_paste_from_buffer {
# Maps need to be copied first
if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
$title=&mt('Copy of').' '.$title;
- my $newid=$$.time;
+ my $newid=$$.int(rand(100)).time;
my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
my $path = $1;
@@ -1308,13 +1361,21 @@ sub do_paste_from_buffer {
}
my $storefn=$newurl;
$storefn=~s{^/\w+/$match_domain/$match_username/}{};
- &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
- &Apache::lonnet::getfile($url));
+ my $paste_map_result =
+ &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
+ &Apache::lonnet::getfile($url));
+ if ($paste_map_result eq '/adm/notfound.html') {
+ if ($url=~/\.page$/) {
+ return &mt('Paste failed: an error occurred saving the composite page');
+ } else {
+ return &mt('Paste failed: an error occurred saving the folder');
+ }
+ }
$url = $newurl;
}
# published maps can only exists once, so remove it from paste buffer when done
if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
- &Apache::lonnet::delenv('docs\\.markedcopy');
+ &Apache::lonnet::delenv('docs.markedcopy');
}
if ($url=~ m{/smppg$}) {
my $db_name = &Apache::lonsimplepage::get_db_name($url);
@@ -1351,6 +1412,7 @@ sub do_paste_from_buffer {
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
push(@LONCAPA::map::order, $newidx);
+ return 'ok';
# Store the result
}
@@ -1441,7 +1503,7 @@ sub handle_edit_cmd {
}
sub editor {
- my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
+ my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype)=@_;
my $container= ($env{'form.pagepath'}) ? 'page'
: 'sequence';
@@ -1458,7 +1520,7 @@ sub editor {
}
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
- &breadcrumbs($folder,$allowed,$type);
+ &breadcrumbs($allowed,$crstype);
$r->print($breadcrumbtrail);
# ------------------------------------------------------------ Process commands
@@ -1483,9 +1545,14 @@ sub editor {
}
if ($env{'form.pastemarked'}) {
- &do_paste_from_buffer($coursenum,$coursedom,$folder);
- ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
- return $errtext if ($fatal);
+ my $paste_res =
+ &do_paste_from_buffer($coursenum,$coursedom,$folder);
+ if ($paste_res eq 'ok') {
+ ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
+ return $errtext if ($fatal);
+ } elsif ($paste_res ne '') {
+ $r->print(''.$paste_res.'
');
+ }
}
$r->print($upload_output);
@@ -1497,10 +1564,10 @@ sub editor {
# Group import/search
if ($env{'form.importdetail'}) {
my @imports;
- foreach (split(/\&/,$env{'form.importdetail'})) {
- if (defined($_)) {
+ foreach my $item (split(/\&/,$env{'form.importdetail'})) {
+ if (defined($item)) {
my ($name,$url,$residx)=
- map {&unescape($_)} split(/\=/,$_);
+ map {&unescape($_)} split(/\=/,$item);
push(@imports, [$name, $url, $residx]);
}
}
@@ -1552,7 +1619,7 @@ sub editor {
unless ($name) { $name=(split(/\//,$url))[-1]; }
unless ($name) { $idx++; next; }
$r->print(&entryline($idx,$name,$url,$folder,$allowed,$res,
- $coursenum));
+ $coursenum,$crstype));
$idx++;
$shown++;
}
@@ -1630,7 +1697,7 @@ sub process_file_upload {
return 'failed';
} else {
if ($parseaction eq 'parse') {
- my $total_embedded = keys(%{$allfiles});
+ my $total_embedded = scalar(keys(%{$allfiles}));
if ($total_embedded > 0) {
my $num = 0;
my $state = '
@@ -1691,6 +1758,7 @@ sub parse_supplemental_title {
$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
my $name = &Apache::loncommon::plainname($uname,$udom);
$name = &HTML::Entities::encode($name,'"<>&\'');
+ $renametitle = &HTML::Entities::encode($renametitle,'"<>&\'');
$title=''.&Apache::lonlocal::locallocaltime($time).' '.
$name.': '.$foldertitle;
}
@@ -1703,7 +1771,7 @@ sub parse_supplemental_title {
# --------------------------------------------------------------- An entry line
sub entryline {
- my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
+ my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
my ($foldertitle,$pagetitle,$renametitle);
if (&is_supplemental_title($title)) {
@@ -1756,7 +1824,7 @@ sub entryline {
'';
for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
if ($i==$incindex) {
- $selectbox.='('.$i.') ';
+ $selectbox.='('.$i.') ';
} else {
$selectbox.=''.$i.' ';
}
@@ -1777,8 +1845,8 @@ sub entryline {
# no copy for published maps
$nocopy = 1;
} else {
- foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
- my ($title,$url,$ext,$type)=split(/\:/,$_);
+ foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
+ my ($title,$url,$ext,$type)=split(/\:/,$item);
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
$nocopy=1;
last;
@@ -1880,6 +1948,7 @@ END
}
my $orig_url = $url;
+ $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
my $symb=&Apache::lonnet::symbclean(
@@ -1942,7 +2011,7 @@ END
my $ro_set=
((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
$rand_order_text ='
- '.&mt('Random Order').' ';
+ '.&mt('Random Order').' ';
}
if ($ispage) {
my $pagename=&escape($pagetitle);
@@ -1968,30 +2037,36 @@ END
} 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.='
'.($url?'':'').' '.($url?' ':'').'
- '.($url?"":'').$title.($url?' ':' '.&mt('(re-initialize course to access)').' ').$external."
+ '.($url?"":'').$title.($url?' ':' '.$reinit.' ').$external."
";
if (($allowed) && ($folder!~/^supplemental/)) {
my %lt=&Apache::lonlocal::texthash(
'hd' => 'Hidden',
'ec' => 'URL hidden');
my $enctext=
- ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
+ ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':'');
my $hidtext=
- ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
+ ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':'');
$line.=(<
$form_start
- $lt{'hd'}
+ $lt{'hd'}
$form_end
$form_start
- $lt{'ec'}
+ $lt{'ec'}
$form_end
$form_start $rand_order_text $form_end
@@ -2002,7 +2077,13 @@ ENDPARMS
return $line;
}
-# ---------------------------------------------------------------- tie the hash
+=pod
+
+=item tiehash()
+
+tie the hash
+
+=cut
sub tiehash {
my ($mode)=@_;
@@ -2028,7 +2109,8 @@ sub untiehash {
return OK;
}
-# --------------------------------------------------------------- check on this
+
+
sub checkonthis {
my ($r,$url,$level,$title)=@_;
@@ -2067,7 +2149,7 @@ sub checkonthis {
if (($errorcount) ||
($warningcount)) {
if ($errorcount) {
- $r->print(''.
+ $r->print(''.
&mt('[quant,_1,error]',$errorcount).' ');
}
if ($warningcount) {
@@ -2081,9 +2163,9 @@ sub checkonthis {
}
my $dependencies=
&Apache::lonnet::metadata($url,'dependencies');
- foreach (split(/\,/,$dependencies)) {
- if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
- &checkonthis($r,$_,$level+1);
+ foreach my $dep (split(/\,/,$dependencies)) {
+ if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
+ &checkonthis($r,$dep,$level+1);
}
}
} elsif ($result eq 'unavailable') {
@@ -2092,7 +2174,7 @@ sub checkonthis {
unless ($url=~/\$/) {
$r->print(''.&mt('not found').' ');
} else {
- $r->print(''.&mt('unable to verify variable URL').' ');
+ $r->print(''.&mt('unable to verify variable URL').' ');
}
} else {
$r->print(''.&mt('access denied').' ');
@@ -2102,49 +2184,61 @@ sub checkonthis {
}
-#
-# ----------------------------------------------------------------- List Symbs
-#
+
+=pod
+
+=item list_symbs()
+
+List Symbs
+
+=cut
+
sub list_symbs {
my ($r) = @_;
+ my $crstype = &Apache::loncommon::course_type();
$r->print(&Apache::loncommon::start_page('Symb List'));
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
my $navmap = Apache::lonnavmaps::navmap->new();
- $r->print("\n");
- foreach my $res ($navmap->retrieveResources()) {
- $r->print($res->compTitle()."\t".$res->symb()."\n");
+ if (!defined($navmap)) {
+ $r->print(''.&mt('Retrieval of List Failed').' '.
+ ''.
+ &mt('Unable to retrieve information about course contents').
+ '
');
+ &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
+ } else {
+ $r->print("\n");
+ foreach my $res ($navmap->retrieveResources()) {
+ $r->print($res->compTitle()."\t".$res->symb()."\n");
+ }
+ $r->print("\n \n");
}
- $r->print("\n \n");
$r->print(''.&mt('Return to DOCS').' ');
}
-#
-# -------------------------------------------------------------- Verify Content
-#
sub verifycontent {
my ($r) = @_;
- my $type = &Apache::loncommon::course_type();
+ my $crstype = &Apache::loncommon::course_type();
my $loaderror=&Apache::lonnet::overloaderror($r);
if ($loaderror) { return $loaderror; }
- $r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents'));
+ $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents'));
$hashtied=0;
undef %alreadyseen;
%alreadyseen=();
&tiehash();
- foreach (keys %hash) {
- if ($hash{$_}=~/\.(page|sequence)$/) {
- if (($_=~/^src_/) && ($alreadyseen{&unescape($hash{$_})})) {
+ foreach my $key (keys(%hash)) {
+ if ($hash{$key}=~/\.(page|sequence)$/) {
+ if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
$r->print(''.
- &mt('The following sequence or page is included more than once in your '.$type.': ').
- &unescape($hash{$_}).' '.
+ &mt('The following sequence or page is included more than once in your '.$crstype.': ').
+ &unescape($hash{$key}).' '.
&mt('Note that grading records for problems included in this sequence or folder will overlap. '));
}
}
- if (($_=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$_})})) {
- &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
+ if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
+ &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
}
}
&untiehash();
@@ -2153,8 +2247,6 @@ sub verifycontent {
}
-# -------------------------------------------------------------- Check Versions
-
sub devalidateversioncache {
my $src=shift;
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
@@ -2163,9 +2255,9 @@ sub devalidateversioncache {
sub checkversions {
my ($r) = @_;
- my $type = &Apache::loncommon::course_type();
- $r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
- $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions"));
+ my $crstype = &Apache::loncommon::course_type();
+ $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions"));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions"));
my $header='';
my $startsel='';
my $monthsel='';
@@ -2184,16 +2276,16 @@ sub checkversions {
my %newsetversions=();
if ($env{'form.setmostrecent'}) {
$haschanged=1;
- foreach (keys %hash) {
- if ($_=~/^ids\_(\/res\/.+)$/) {
+ foreach my $key (keys(%hash)) {
+ if ($key=~/^ids\_(\/res\/.+)$/) {
$newsetversions{$1}='mostrecent';
&devalidateversioncache($1);
}
}
} elsif ($env{'form.setcurrent'}) {
$haschanged=1;
- foreach (keys %hash) {
- if ($_=~/^ids\_(\/res\/.+)$/) {
+ foreach my $key (keys(%hash)) {
+ if ($key=~/^ids\_(\/res\/.+)$/) {
my $getvers=&Apache::lonnet::getversion($1);
if ($getvers>0) {
$newsetversions{$1}=$getvers;
@@ -2203,11 +2295,11 @@ sub checkversions {
}
} elsif ($env{'form.setversions'}) {
$haschanged=1;
- foreach (keys %env) {
- if ($_=~/^form\.set_version_(.+)$/) {
+ foreach my $key (keys(%env)) {
+ if ($key=~/^form\.set_version_(.+)$/) {
my $src=$1;
- if (($env{$_}) && ($env{$_} ne $setversions{$src})) {
- $newsetversions{$src}=$env{$_};
+ if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
+ $newsetversions{$src}=$env{$key};
&devalidateversioncache($src);
}
}
@@ -2226,10 +2318,10 @@ sub checkversions {
&changewarning($r,'');
if ($env{'form.timerange'} eq 'all') {
# show all documents
- $header=&mt('All Documents in '.$type);
+ $header=&mt('All Documents in '.$crstype);
$allsel=1;
- foreach (keys %hash) {
- if ($_=~/^ids\_(\/res\/.+)$/) {
+ foreach my $key (keys(%hash)) {
+ if ($key=~/^ids\_(\/res\/.+)$/) {
my $src=$1;
$changes{$src}=1;
}
@@ -2239,7 +2331,7 @@ sub checkversions {
%changes=&Apache::lonnet::dump
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
- my $firstkey=(keys %changes)[0];
+ my $firstkey=(keys(%changes))[0];
unless ($firstkey=~/^error\:/) {
unless ($env{'form.timerange'}) {
$env{'form.timerange'}=604800;
@@ -2271,7 +2363,7 @@ sub checkversions {
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
my %lt=&Apache::lonlocal::texthash
- ('st' => 'Version changes since start of '.$type,
+ ('st' => 'Version changes since start of '.$crstype,
'lm' => 'Version changes since last Month',
'lw' => 'Version changes since last Week',
'sy' => 'Version changes since Yesterday',
@@ -2280,9 +2372,9 @@ sub checkversions {
'fi' => 'File',
'md' => 'Modification Date',
'mr' => 'Most recently published Version',
- 've' => 'Version used in '.$type,
- 'vu' => 'Set Version to be used in '.$type,
-'sv' => 'Set Versions to be used in '.$type.' according to Selections below',
+ 've' => 'Version used in '.$crstype,
+ 'vu' => 'Set Version to be used in '.$crstype,
+'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
'di' => 'Differences');
@@ -2303,14 +2395,14 @@ sub checkversions {
ENDHEADERS
- foreach (sort keys %changes) {
- if ($changes{$_}>$starttime) {
- my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
- my $currentversion=&Apache::lonnet::getversion($_);
+ 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($_);
+ my $linkurl=&Apache::lonnet::clutter($key);
$r->print(
''.
&Apache::lonnet::gettitle($linkurl).
@@ -2329,7 +2421,7 @@ ENDHEADERS
' Most Recent: '.
''.$currentversion.' '.
' '.
- 'In '.$type.': '.
+ ' In '.$crstype.': '.
'');
# Used in course
my $usedversion=$hash{'version_'.$linkurl};
@@ -2346,7 +2438,7 @@ ENDHEADERS
('select_form_order' =>
['',1..$currentversion,'mostrecent'],
'' => '',
- 'mostrecent' => 'most recent',
+ 'mostrecent' => &mt('most recent'),
map {$_,$_} (1..$currentversion))));
$r->print(' ');
my $lastold=1;
@@ -2447,23 +2539,27 @@ sub changewarning {
$message='Changes will become active for your current session after [_1], or the next time you log in.';
}
$r->print("\n\n".
-''."\n".
+''."\n".
''."\n\n");
+ &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
+$help{'Caching'}.''."\n\n");
+
}
-# =========================================== Breadcrumbs for special functions
sub init_breadcrumbs {
my ($form,$text)=@_;
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
- text=>"Edit ".&Apache::loncommon::course_type(),
+ text=>&Apache::loncommon::course_type().' Editor',
faq=>273,
bug=>'Instructor Interface',
help => 'Docs_Adding_Course_Doc'});
@@ -2473,22 +2569,24 @@ sub init_breadcrumbs {
bug=>'Instructor Interface'});
}
-# ================================================================ Main Handler
+
+
+
sub handler {
my $r = shift;
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK if $r->header_only;
- my $type = &Apache::loncommon::course_type();
+ my $crstype = &Apache::loncommon::course_type();
# --------------------------------------------- Initialize help topics for this
- foreach ('Adding_Course_Doc','Main_Course_Documents',
- 'Adding_External_Resource','Navigate_Content',
- 'Adding_Folders','Docs_Overview', 'Load_Map',
- 'Supplemental','Score_Upload_Form','Adding_Pages',
- 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
- 'Check_Resource_Versions','Verify_Content') {
- $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
+ foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
+ 'Adding_External_Resource','Navigate_Content',
+ 'Adding_Folders','Docs_Overview', 'Load_Map',
+ 'Supplemental','Score_Upload_Form','Adding_Pages',
+ 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
+ 'Check_Resource_Versions','Verify_Content') {
+ $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
}
# Composite help files
$help{'Syllabus'} = &Apache::loncommon::help_open_topic(
@@ -2522,7 +2620,7 @@ sub handler {
&init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space');
&dumpcourse($r);
} elsif ($allowed && $env{'form.exportcourse'}) {
- &init_breadcrumbs('exportcourse','Export '.&Apache::loncommon::course_type().' to IMS');
+ &init_breadcrumbs('exportcourse','IMS Export');
&exportcourse($r);
} else {
# is this a standard course?
@@ -2551,7 +2649,7 @@ sub handler {
}
if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
$env{'form.folderpath'} = 'supplemental&'.
- &escape(&mt('Supplemental '.$type.' Documents')).'&'.
+ &escape(&mt('Supplemental '.$crstype.' Documents')).'&'.
$env{'form.folderpath'};
}
&Apache::loncommon::store_course_settings('docs_folderpath',
@@ -2606,9 +2704,15 @@ sub handler {
$script .= &editing_js($udom,$uname);
}
# -------------------------------------------------------------------- Body tag
- $script = '';
- $r->print(&Apache::loncommon::start_page("$type Documents", $script,
- {'force_register' => $showdoc,}).
+ $script = ''."\n";
+ my $brcrum = [{href=>"/adm/createuser",text=>"Edit $crstype"}];
+ $r->print(&Apache::loncommon::start_page("Edit $crstype", $script,
+ {'force_register' => $showdoc,
+ 'bread_crumbs' => $brcrum}).
&Apache::loncommon::help_open_menu('','',273,'RAT'));
my %allfiles = ();
@@ -2647,12 +2751,12 @@ sub handler {
}
my @attributes = ();
if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
- @attributes = split/:/,$env{'form.embedded_attrib_'.$i};
+ @attributes = split(/:/,$env{'form.embedded_attrib_'.$i});
} else {
@attributes = ($env{'form.embedded_attrib_'.$i});
}
- foreach (@attributes) {
- push(@{$attribs{$i}},&unescape($_));
+ foreach my $attr (@attributes) {
+ push(@{$attribs{$i}},&unescape($attr));
}
if ($javacodebase) {
$codebase{$i} = $javacodebase;
@@ -2670,7 +2774,7 @@ sub handler {
my $updateflag = 0;
my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
if ($getstatus eq 'ok') {
- foreach my $item (keys %newname) {
+ foreach my $item (keys(%newname)) {
if ($newname{$item} ne $origname{$item}) {
my $attrib_regexp = '';
if (@{$attribs{$item}} > 1) {
@@ -2701,8 +2805,8 @@ sub handler {
unless ($showdoc || $upload_result eq 'phasetwo') {
# -----------------------------------------------------------------------------
my %lt=&Apache::lonlocal::texthash(
- 'uplm' => 'Upload a new main '.lc($type).' document',
- 'upls' => 'Upload a new supplemental '.lc($type).' document',
+ 'uplm' => 'Upload a new main '.lc($crstype).' document',
+ 'upls' => 'Upload a new supplemental '.lc($crstype).' document',
'impp' => 'Import a document',
'pubd' => 'Published documents',
'copm' => 'All documents out of a published map into this folder',
@@ -2719,22 +2823,33 @@ sub handler {
'extr' => 'External Resource',
'syll' => 'Syllabus',
'navc' => 'Navigate Contents',
- 'sipa' => 'Simple Page',
+ 'sipa' => 'Simple Course Page',
'sipr' => 'Simple Problem',
'drbx' => 'Drop Box',
'scuf' => 'Score Upload Form',
- 'bull' => 'Bulletin Board',
- 'mypi' => 'My Personal Info',
- 'grpo' => 'Group Files',
+ 'bull' => 'Discussion Board',
+ 'mypi' => 'My Personal Information Page',
+ 'grpo' => 'Group Portfolios',
'rost' => 'Course Roster',
'abou' => 'About User',
- 'imsf' => 'Import IMS package',
+ 'imsf' => 'IMS Import',
+ 'imsl' => 'Import IMS package',
'file' => 'File',
'title' => 'Title',
'comment' => 'Comment',
'parse' => 'If HTML file, upload embedded images/multimedia files'
);
# -----------------------------------------------------------------------------
+ my %tabtitles = (
+ main => {
+ Course => &mt('Main Course Documents'),
+ Community => &mt('Main Community Documents'),
+ },
+ supplemental => {
+ Course => &mt('Supplemental Course Documents'),
+ Community => &mt('Supplemental Community Documents'),
+ },
+ );
if ($allowed) {
&update_paste_buffer($coursenum,$coursedom);
my $dumpbut=&dumpbutton();
@@ -2750,8 +2865,7 @@ sub handler {
if (!$folderpath) {
if ($env{'form.folder'} eq '' ||
$env{'form.folder'} eq 'supplemental') {
- $folderpath='default&'.
- &escape(&mt('Main '.$type.' Documents'));
+ $folderpath='default&'.&escape($tabtitles{'main'}{$crstype});
}
}
unless ($env{'form.pagepath'}) {
@@ -2794,7 +2908,7 @@ sub handler {
ENDCOURSEVERIFY
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
- &mt('Editing the Table of Contents for your '.$type)));
+ &mt('Editing the Table of Contents for your '.$crstype)));
}
# --------------------------------------------------------- Standard documents
$r->print('');
@@ -2806,24 +2920,29 @@ ENDCOURSEVERIFY
my $folder=$env{'form.folder'};
if ($folder eq '' || $folder eq 'supplemental') {
$folder='default';
- $env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents'));
+ $env{'form.folderpath'}='default&'.&escape(&mt('Main '.$crstype.' Documents'));
$uploadtag = ' ';
}
my $postexec='';
if ($folder eq 'default') {
- $r->print('');
+ $r->print(''."\n"
+ );
} else {
#$postexec='self.close();';
}
$hadchanges=0;
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
- $upload_output,$type);
+ $upload_output,$crstype);
if ($error) {
$r->print(''.$error.'
');
}
if ($hadchanges) {
- &mark_hash_old()
+ &mark_hash_old();
}
&changewarning($r,$postexec);
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
@@ -2870,27 +2989,27 @@ $uploadtag
ENDFORM
unless ($env{'form.pagepath'}) {
@@ -2900,13 +3019,13 @@ ENDFORM
$uploadtag
- $help{'Adding_External_Resource'}
ENDFORM
}
@@ -2919,7 +3038,7 @@ ENDFORM
$help{'Adding_Folders'}
@@ -2928,7 +3047,7 @@ value="$lt{'newf'}" />$help{'Adding_Fold
$help{'Adding_Pages'}
@@ -2955,7 +3074,7 @@ $uploadtag
$help{'Simple Page'}
+onclick="javascript:makesmppage();" /> $help{'Simple Page'}
@@ -2988,7 +3107,7 @@ $uploadtag
+onclick="javascript:makebulboard();" />
$help{'Bulletin Board'}
@@ -3006,7 +3125,7 @@ $uploadtag
+onclick="javascript:makeabout();" />
@@ -3066,9 +3185,9 @@ ENDBLOCK
if ($folder =~ /^supplemental$/ &&
(($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
$env{'form.folderpath'} = 'supplemental&'.
- &escape(&mt('Supplemental '.$type.' Documents'));
+ &escape($tabtitles{'supplemental'}{$crstype});
}
- my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
+ my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);
if ($error) {
$r->print(''.$error.'
');
}
@@ -3095,7 +3214,7 @@ ENDBLOCK
$lt{'comment'}:
-