--- loncom/interface/londocs.pm 2002/10/20 18:42:53 1.34 +++ loncom/interface/londocs.pm 2003/01/19 11:57:24 1.44 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.34 2002/10/20 18:42:53 www Exp $ +# $Id: londocs.pm,v 1.44 2003/01/19 11:57:24 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,6 +35,7 @@ use Apache::loncommon; use Apache::lonratedt; use Apache::lonratsrv; use Apache::lonxml; +use HTML::Entities; use GDBM_File; my $iconpath; @@ -44,6 +45,8 @@ my %hash; my $hashtied; my %alreadyseen=(); +my $hadchanges; + # Mapread read maps into lonratedt::global arrays # @order and @resources, determines status # sets @order - pointer to resources in right order @@ -59,6 +62,7 @@ sub mapread { sub storemap { my ($coursenum,$coursedom,$map)=@_; + $hadchanges=1; return &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. $map,1); @@ -118,15 +122,32 @@ sub editor { } $#Apache::lonratedt::order--; } elsif ($cmd eq 'up') { + if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) { my $i=$Apache::lonratedt::order[$idx-1]; $Apache::lonratedt::order[$idx-1]= $Apache::lonratedt::order[$idx]; $Apache::lonratedt::order[$idx]=$i; + } } elsif ($cmd eq 'down') { + if (defined($Apache::lonratedt::order[$idx+1])) { my $i=$Apache::lonratedt::order[$idx+1]; $Apache::lonratedt::order[$idx+1]= $Apache::lonratedt::order[$idx]; $Apache::lonratedt::order[$idx]=$i; + } + } elsif ($cmd eq 'rename') { + my ($rtitle,@rrest)=split(/\:/, + $Apache::lonratedt::resources[ + $Apache::lonratedt::order[$idx]]); + my $comment= + &HTML::Entities::decode($ENV{'form.title'}); + $comment=~s/\/\>\;/g; + $comment=~s/\:/\:/g; + $Apache::lonratedt::resources[ + $Apache::lonratedt::order[$idx]]= + $comment.':'.join(':',@rrest); + } # Store the changed version &storemap($coursenum,$coursedom,$folder.'.sequence'); @@ -161,7 +182,7 @@ sub editor { foreach (@Apache::lonratedt::order) { my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]); unless ($name) { $name=(split(/\//,$url))[-1]; } - unless ($name) { $name='EMPTY'; } + unless ($name) { $name='NO RESOURCE'; $url='/adm/notfound.html'; } $r->print(&entryline($idx,$name,$url,$folder,$allowed)); $idx++; } @@ -173,6 +194,21 @@ sub editor { sub entryline { my ($index,$title,$url,$folder,$allowed)=@_; + $title=~s/\&colon\;/\:/g; + $title=&HTML::Entities::encode(&HTML::Entities::decode( + &Apache::lonnet::unescape($title)),'\"\<\>\&\''); + my $renametitle=$title; + my $foldertitle=$title; + if ($title=~ + /^(\d+)\_\_\_\&\;\&\;\&\;\_\_\_(\w+)\_\_\_\&\;\&\;\&\;\_\_\_(\w+)\_\_\_\&\;\&\;\&\;\_\_\_(.*)$/ + ) { + $foldertitle=&Apache::lontexconvert::msgtexconverted($4); + $renametitle=$4; + $title=''.localtime($1).' '. + &Apache::loncommon::plainname($2,$3).':
'. + $foldertitle; + } + $renametitle=~s/\"\;/\\\"/g; my $line=''; # Edit commands if ($allowed) { @@ -183,7 +219,10 @@ sub entryline { DOWN -Remove + +Remove + +Rename END } # Figure out what kind of a resource this is @@ -205,17 +244,6 @@ END } } $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//; -# Title - $title=&Apache::lonnet::unescape($title); - my $foldertitle=$title; - if ($title=~ - /^(\d+)\_\_\_\&\&\&\_\_\_(\w+)\_\_\_\&\&\&\_\_\_(\w+)\_\_\_\&\&\&\_\_\_(.*)$/ - ) { - $foldertitle=&Apache::lontexconvert::msgtexconverted($4); - $title=''.localtime($1).' '. - &Apache::loncommon::plainname($2,$3).':
'. - $foldertitle; - } if ($isfolder) { $url.='&foldername='.$foldertitle; } $line.=' + ENDNEWSCRIPT } # -------------------------------------------------------------------- Body tag @@ -531,6 +569,15 @@ ENDNEWSCRIPT unless ($showdoc) { if ($allowed) { $r->print(< + + + + +
+ + +
@@ -538,16 +585,22 @@ ENDNEWSCRIPT ENDCOURSEVERIFY } # --------------------------------------------------------- Standard documents - $r->print(''); + $r->print('
'); if (($standard) && ($allowed) && (!$forcesupplement)) { - $r->print(' +

Main Course Documents

'); + $r->print('

Main Course Documents

'); my $folder=$ENV{'form.folder'}; unless ($folder=~/^default/) { $folder='default'; } + $hadchanges=0; &editor($r,$coursenum,$coursedom,$folder,$allowed); + if ($hadchanges) { + $r->print(''. +'

Changes will become active after or at next login.

'); + } my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. '.sequence'; $r->print(<
@@ -566,13 +619,11 @@ Title:
+
Upload a new main course document Import a published document Special documents -
- - + +"javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="Search"> +"javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="Import">
@@ -633,7 +684,7 @@ ENDFORM # ----------------------------------------------------- Supplemental documents if (!$forcestandard) { $r->print( - '

Supplemental Course Documents

'); + '

Supplemental Course Documents

'); my $folder=$ENV{'form.folder'}; unless ($folder=~/supplemental/) { $folder='supplemental'; } &editor($r,$coursenum,$coursedom,$folder,$allowed); @@ -643,7 +694,7 @@ ENDFORM '.sequence'; $r->print(<
@@ -661,13 +712,12 @@ ENDFORM
Upload a new supplemental course document Import a published document Special documents -
- + +"javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="Search"> +"javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="Import">