--- loncom/interface/londocs.pm 2002/11/18 15:21:31 1.37 +++ loncom/interface/londocs.pm 2003/01/20 17:30:31 1.45 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.37 2002/11/18 15:21:31 www Exp $ +# $Id: londocs.pm,v 1.45 2003/01/20 17:30:31 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,20 +122,25 @@ 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=$ENV{'form.title'}; + my $comment= + &HTML::Entities::decode($ENV{'form.title'}); $comment=~s/\/\>\;/g; $comment=~s/\:/\:/g; @@ -185,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) { @@ -197,7 +221,7 @@ sub entryline { Remove - + Rename END } @@ -220,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 @@ -556,6 +569,15 @@ ENDNEWSCRIPT unless ($showdoc) { if ($allowed) { $r->print(< + + + + +
+ + +
@@ -563,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 for your current session after , or the next time you log in.

'); + } my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. '.sequence'; $r->print(<
@@ -591,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">
@@ -658,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); @@ -668,7 +694,7 @@ ENDFORM '.sequence'; $r->print(<
@@ -686,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">