--- loncom/interface/londocs.pm 2006/11/22 03:56:36 1.255 +++ loncom/interface/londocs.pm 2007/07/04 00:21:42 1.286 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.255 2006/11/22 03:56:36 raeburn Exp $ +# $Id: londocs.pm,v 1.286 2007/07/04 00:21:42 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,7 @@ use HTML::Entities; use GDBM_File; use Apache::lonlocal; use Cwd; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); my $iconpath; @@ -99,7 +99,7 @@ sub authorhosts { $ca=$env{'user.name'}; $cd=$env{'user.domain'}; } else { - ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); + ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/); } my $allowed=0; my $myhome=&Apache::lonnet::homeserver($ca,$cd); @@ -122,16 +122,17 @@ sub dumpbutton { my ($home,$other,%outhash)=&authorhosts(); my $type = &Apache::loncommon::course_type(); if ($home+$other==0) { return ''; } - my $output='
'.
'$url.$cpinfo,
'title'=>$name,
'text'=>''.
- $name.''
+ $name.'',
+ 'no_mt'=>1,
});
$plain.=$name.' > ';
}
@@ -1025,7 +1024,8 @@ sub log_docs {
sub log_differences {
my ($plain)=@_;
- my %storehash=('folder' => $plain);
+ my %storehash=('folder' => $plain,
+ 'currentfolder' => $env{'form.folder'});
if ($parmidx) {
$storehash{'parameter_res'}=$oldresources[$parmidx];
foreach my $parm (keys %parmaction) {
@@ -1060,9 +1060,9 @@ sub log_docs {
#
sub docs_change_log {
my ($r)=@_;
+ my $folder=$env{'form.folder'};
$r->print(&Apache::loncommon::start_page('Course Document Change Log'));
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
-
my %docslog=&Apache::lonnet::dump('nohist_docslog',
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
@@ -1083,12 +1083,8 @@ sub docs_change_log {
'randompick' => 'Randomly pick',
'set' => 'set to',
'del' => 'deleted');
-
- my $countselect =
- &Apache::lonmeta::selectbox('show',$env{'form.show'},undef,
- (&mt('all'),10,20,50,100,1000,10000));
-
- $r->print('
+ENDPASTE + $r->print(' '); + + my $type; + if ($env{'docs.markedcopy_url'} =~ m{^/adm/wrapper/ext}) { + $type = &mt('External Resource'); + $r->print($type.': '.&Apache::map::qtescape($env{'docs.markedcopy_title'})); + } else { + my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1]; + my $type = &Apache::loncommon::filedescription($extension); + my $icon = ''; + $r->print($icon.$type.': '. &parse_supplemental_title($env{'docs.markedcopy_title'})); + } + if ($container eq 'page') { + $r->print(' + + +'); + } else { + $r->print(' + +'); + } + $r->print('
'); } sub editor { - my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output)=@_; + my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$which)=@_; my $errtext=''; my $fatal=0; my $container='sequence'; if ($env{'form.pagepath'}) { $container='page'; } - ($errtext,$fatal)= - &mapread($coursenum,$coursedom,$folder.'.'.$container); + ($errtext,$fatal) = &mapread($coursenum,$coursedom,$folder.'.'.$container); if ($#LONCAPA::map::order<1) { my $idx=&LONCAPA::map::getresidx(); if ($idx<=0) { $idx=1; } $LONCAPA::map::order[0]=$idx; $LONCAPA::map::resources[$idx]=''; } - if (defined($env{'form.markcopy'})) { -# Mark for copying - my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]); - $env{'form.markedcopy_title'}=$title; - $env{'form.markedcopy_url'}=$url; - } + my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain)=&breadcrumbs($folder); $r->print($breadcrumbtrail); if ($fatal) { - $r->print(''.$errtext.'
'); + $r->print(''.$errtext.'
'); } else { # ------------------------------------------------------------ Process commands @@ -1212,31 +1267,37 @@ sub editor { if ($env{'form.changeparms'}) { my $idx=$env{'form.setparms'}; # set parameters - if ($env{'form.randpick_'.$idx}) { - &LONCAPA::map::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos'); - &remember_parms($idx,'randompick','set',$env{'form.randpick_'.$idx}); - } else { - &LONCAPA::map::delparameter($idx,'parameter_randompick'); - &remember_parms($idx,'randompick','del'); + if ($env{'form.changeparms'} eq 'randompick') { + if ($env{'form.randpick_'.$idx}) { + &LONCAPA::map::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos'); + &remember_parms($idx,'randompick','set',$env{'form.randpick_'.$idx}); + } else { + &LONCAPA::map::delparameter($idx,'parameter_randompick'); + &remember_parms($idx,'randompick','del'); + } + } + if ($env{'form.changeparms'} eq 'hiddenresource') { + if ($env{'form.hidprs_'.$idx}) { + &LONCAPA::map::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno'); + &remember_parms($idx,'hiddenresource','set',$env{'form.hidprs_'.$idx}); + } else { + &LONCAPA::map::delparameter($idx,'parameter_hiddenresource'); + &remember_parms($idx,'hiddenresource','del'); + } + } + if ($env{'form.changeparms'} eq 'encrypturl') { + if ($env{'form.encprs_'.$idx}) { + &LONCAPA::map::storeparameter($idx,'parameter_encrypturl','yes','string_yesno'); + &remember_parms($idx,'encrypturl','set',$env{'form.encprs_'.$idx}); + } else { + &LONCAPA::map::delparameter($idx,'parameter_encrypturl'); + &remember_parms($idx,'encrypturl','del'); + } } - if ($env{'form.hidprs_'.$idx}) { - &LONCAPA::map::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno'); - &remember_parms($idx,'hiddenresource','set',$env{'form.hidprs_'.$idx}); - } else { - &LONCAPA::map::delparameter($idx,'parameter_hiddenresource'); - &remember_parms($idx,'hiddenresource','del'); - } - if ($env{'form.encprs_'.$idx}) { - &LONCAPA::map::storeparameter($idx,'parameter_encrypturl','yes','string_yesno'); - &remember_parms($idx,'encrypturl','set',$env{'form.encprs_'.$idx}); - } else { - &LONCAPA::map::delparameter($idx,'parameter_encrypturl'); - &remember_parms($idx,'encrypturl','del'); - } # store the changed version ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); if ($fatal) { - $r->print(''.$errtext.'
'); + $r->print(''.$errtext.'
'); return; } } @@ -1276,15 +1337,15 @@ sub editor { # store the changed version ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); if ($fatal) { - $r->print(''.$errtext.'
'); + $r->print(''.$errtext.'
'); return; } } - + if ($env{'form.pastemarked'}) { # paste resource to end of list - my $url=$env{'form.markedcopy_url'}; - my $title=$env{'form.markedcopy_title'}; + my $url=$env{'docs.markedcopy_url'}; + my $title=$env{'docs.markedcopy_title'}; # Maps need to be copied first if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) { $title=&mt('Copy of').' '.$title; @@ -1292,18 +1353,16 @@ sub editor { $url=~/^(.+)\.(\w+)$/; my $newurl=$1.$newid.'.'.$2; my $storefn=$newurl; - $storefn=~s/^\/\w+\/\w+\/\w+\///; + $storefn=~s{^/\w+/$match_domain/$match_username/}{}; &Apache::lonclonecourse::writefile ($env{'request.course.id'},$storefn, &Apache::lonnet::getfile($url)); $url=$newurl; } - $title=~s/\\<\;/g; - $title=~s/\>/\>\;/g; - $title=~s/\:/\:/g; + $title = &LONCAPA::map::qtunescape($title); my $ext='false'; if ($url=~/^http\:\/\//) { $ext='true'; } - $url=~s/\:/\:/g; + $url = &LONCAPA::map::qtunescape($url); # Now insert the URL at the bottom my $newidx=&LONCAPA::map::getresidx($url); $LONCAPA::map::resources[$newidx]= @@ -1312,7 +1371,7 @@ sub editor { # Store the result ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); if ($fatal) { - $r->print(''.$errtext.'
'); + $r->print(''.$errtext.'
'); return; } @@ -1355,26 +1414,21 @@ sub editor { my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; my ($rtitle,@rrest)=split(/\:/, $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]); - my $comment= - &HTML::Entities::decode($env{'form.title'}); - $comment=~s/\\<\;/g; - $comment=~s/\>/\>\;/g; - $comment=~s/\:/\:/g; + my $comment=$env{'form.title'}; + $comment = &LONCAPA::map::qtunescape($comment); if ($comment=~/\S/) { $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]= $comment.':'.join(':',@rrest); } # Devalidate title cache - my $renamed_url=$rrest[0]; -# Has the :-escaping - $renamed_url=~s/\&colon\;/\:/g; + my $renamed_url=&LONCAPA::map::qtescape($rrest[0]); &Apache::lonnet::devalidate_title_cache($renamed_url); } # Store the changed version ($errtext,$fatal)=&storemap($coursenum,$coursedom, $folder.'.'.$container); if ($fatal) { - $r->print(''.$errtext.'
'); + $r->print(''.$errtext.'
'); return; } } @@ -1394,7 +1448,7 @@ sub editor { ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder, $container,'londocs',@imports); if ($fatal) { - $r->print(''.$errtext.'
'); + $r->print(''.$errtext.'
'); return; } } @@ -1411,15 +1465,16 @@ sub editor { ($errtext,$fatal)=&storemap($coursenum,$coursedom, $folder.'.'.$container); if ($fatal) { - $r->print(''.$errtext.'
'); + $r->print(''.$errtext.'
'); return; } } else { - $r->print(''.&mt('No map selected.').'
'); + $r->print(''.&mt('No map selected.').'
'); + } } &log_differences($plain); - } + } # ---------------------------------------------------------------- End commands # ---------------------------------------------------------------- Print screen my $idx=0; @@ -1434,14 +1489,15 @@ sub editor { if ($randompick>=0) { $r->print(''.&mt('Caution: this folder is set to randomly pick a subset of resources. Adding or removing resources from this folder will change the set of resources that the students see, resulting in spurious or missing credit for completed problems, not limited to ones you modify. Do not modify the contents of this folder if it is in active student use.').'
'); } - $r->print(''.&mt('Currently no documents.').' |
'.$errtext.'
'; + $$upload_output .= ''.$errtext.'
'; return 'failed'; } else { if ($parseaction eq 'parse') { my $total_embedded = keys(%{$allfiles}); if ($total_embedded > 0) { my $num = 0; - $$upload_output .= 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.- - |
- - |
- - |
- - |
+ + | +
+ + | +
\n"); foreach my $res ($navmap->retrieveResources()) { @@ -2005,6 +2091,7 @@ sub verifycontent { 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')); $hashtied=0; undef %alreadyseen; %alreadyseen=(); @@ -2012,9 +2099,9 @@ sub verifycontent { foreach (keys %hash) { if ($hash{$_}=~/\.(page|sequence)$/) { if (($_=~/^src_/) && ($alreadyseen{&unescape($hash{$_})})) { - $r->print('
'. + $r->print('
'. &mt('The following sequence or page is included more than once in your '.$type.': '). - &unescape($hash{$_}).'
'. + &unescape($hash{$_}).'
'); + $r->print(' | ||||||||||||||||||||||
');
# ''.&mt('Main Course Documents'). # ($allowed?' '.$help{'Main_Course_Documents'}:'').''); my $folder=$env{'form.folder'}; @@ -2628,7 +2746,7 @@ ENDCOURSEVERIFY } my $postexec=''; if ($folder eq 'default') { - $r->print(''); + $r->print(''); } else { #$postexec='self.close();'; } @@ -2648,54 +2766,56 @@ ENDCOURSEVERIFY } my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; $r->print(<$lt{'uplm'} |
-$lt{'impp'} |
-$lt{'spec'} |
+
|
'. -&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."