--- loncom/interface/londocs.pm 2002/11/18 15:21:31 1.37 +++ loncom/interface/londocs.pm 2003/02/04 18:23:21 1.47 @@ -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.47 2003/02/04 18:23:21 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,12 @@ my %hash; my $hashtied; my %alreadyseen=(); +my $hadchanges; + +# Available help topics + +my %help=(); + # Mapread read maps into lonratedt::global arrays # @order and @resources, determines status # sets @order - pointer to resources in right order @@ -59,6 +66,7 @@ sub mapread { sub storemap { my ($coursenum,$coursedom,$map)=@_; + $hadchanges=1; return &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. $map,1); @@ -118,20 +126,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; @@ -157,6 +170,7 @@ sub editor { my $ext='false'; if ($url=~/^http\:\/\//) { $ext='true'; } $url=~s/\:/\:/g; + $name=~s/\:/\:/g; $Apache::lonratedt::resources[$idx]= $name.':'.$url.':'.$ext.':normal:res'; } @@ -185,6 +199,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 +226,7 @@ sub entryline { Remove - + Rename END } @@ -220,17 +249,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 @@ -555,7 +581,18 @@ ENDNEWSCRIPT &Apache::loncommon::bodytag('Course Documents','',$events)); unless ($showdoc) { if ($allowed) { + $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', + 'Editing the Table of Contents for your Course')); $r->print(< + + + + +
+ + +
@@ -563,16 +600,24 @@ ENDNEWSCRIPT ENDCOURSEVERIFY } # --------------------------------------------------------- Standard documents - $r->print(''); + $r->print('
'); if (($standard) && ($allowed) && (!$forcesupplement)) { - $r->print(' +

Main Course Documents

'); + $r->print('

Main Course Documents'. + ($allowed?' '.$help{'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(<
@@ -588,17 +633,15 @@ Title:
- + $help{'Uploading_From_Harddrive'}
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"> +$help{'Importing_LON-CAPA_Resource'}
@@ -606,35 +649,36 @@ Title:
+value="New Folder" /> $help{'Adding_Folders'}
+value="External Resource" /> $help{'Adding_External_Resource'}
- -
+ + $help{'Creating_From_Template'}
+$help{'Navigate_Content'}
+onClick="javascript:makesmppage();" /> $help{'Creating_From_Template'}
@@ -642,14 +686,14 @@ onClick="javascript:makesmppage();" /> -
+$help{'Creating_From_Template'}
-
+$help{'Creating_From_Template'}
ENDFORM @@ -658,7 +702,8 @@ ENDFORM # ----------------------------------------------------- Supplemental documents if (!$forcestandard) { $r->print( - '

Supplemental Course Documents

'); + '

Supplemental Course Documents'. + ($allowed?' '.$help{'Supplemental'}:'').'

'); my $folder=$ENV{'form.folder'}; unless ($folder=~/supplemental/) { $folder='supplemental'; } &editor($r,$coursenum,$coursedom,$folder,$allowed); @@ -668,7 +713,7 @@ ENDFORM '.sequence'; $r->print(< + @@ -683,16 +728,15 @@ ENDFORM - + $help{'Uploading_From_Harddrive'}
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">$help{'Importing_LON-CAPA_Resource'}
@@ -701,7 +745,7 @@ ENDFORM +value="New Folder" /> $help{'Adding_Folders'}
@@ -709,7 +753,7 @@ value="New Folder" /> +value="External Resource" /> $help{'Adding_External_Resource'}
@@ -717,14 +761,14 @@ value="External Resource" /> -
+$help{'Creating_From_Template'}
-
+$help{'Creating_From_Template'}
ENDSUPFORM