--- loncom/interface/londocs.pm 2002/09/10 19:01:09 1.22
+++ 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.22 2002/09/10 19:01:09 www Exp $
+# $Id: londocs.pm,v 1.47 2003/02/04 18:23:21 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -29,15 +29,28 @@
package Apache::londocs;
use strict;
-use Apache::Constants qw(:common);
+use Apache::Constants qw(:common :http);
use Apache::lonnet;
use Apache::loncommon;
use Apache::lonratedt;
use Apache::lonratsrv;
use Apache::lonxml;
+use HTML::Entities;
+use GDBM_File;
my $iconpath;
+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
@@ -53,6 +66,7 @@ sub mapread {
sub storemap {
my ($coursenum,$coursedom,$map)=@_;
+ $hadchanges=1;
return
&Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
$map,1);
@@ -112,15 +126,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;
+ $comment=~s/\:/\:/g;
+ $Apache::lonratedt::resources[
+ $Apache::lonratedt::order[$idx]]=
+ $comment.':'.join(':',@rrest);
+
}
# Store the changed version
&storemap($coursenum,$coursedom,$folder.'.sequence');
@@ -139,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';
}
@@ -155,7 +187,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++;
}
@@ -167,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='
File | Modification Date | +Version | Differences |
---|---|---|---|
'.$linkurl. + ' | '. + localtime($changes{$_}).' | '.$currentversion.' | '. + '');
+ my $lastold=1;
+ for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
+ my $url=$root.'.'.$prevvers.'.'.$extension;
+ if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
+ $starttime) {
+ $lastold=$prevvers;
+ }
+ }
+ for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
+ my $url=$root.'.'.$prevvers.'.'.$extension;
+ $r->print('Version '.$prevvers.' ('.
+ localtime(&Apache::lonnet::metadata($url,'lastrevisiondate')).
+ ')');
+ if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
+ $r->print(' Diffs');
+ }
+ $r->print(' '); + } + $r->print(' |
No content modifications yet.
'); + } + &untiehash(); + } else { # is this a standard course? my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//); @@ -298,17 +537,21 @@ function makenewext(targetname) { } function makesmppage() { - var title=prompt('Listed Title for the Page'); + var title=prompt('Listed Title for the Page'); + if (title) { this.document.forms.newsmppg.importdetail.value= title+'=/adm/$udom/$uname/$now/smppg'; this.document.forms.newsmppg.submit(); + } } function makebulboard() { - var title=prompt('Listed Title for the Bulletin Board'); + var title=prompt('Listed Title for the Bulletin Board'); + if (title) { this.document.forms.newbul.importdetail.value= title+'=/adm/$udom/$uname/$now/bulletinboard'; this.document.forms.newbul.submit(); + } } function finishpick() { @@ -319,23 +562,62 @@ function finishpick() { ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+ '";this.document.forms.'+form+'.submit();'); } + +function changename(folder,index,oldtitle) { + var title=prompt('New Title',oldtitle); + if (title) { + this.document.forms.renameform.title.value=title; + this.document.forms.renameform.cmd.value='rename_'+index; + this.document.forms.renameform.folder.value=folder; + this.document.forms.renameform.submit(); + } +} + ENDNEWSCRIPT } # -------------------------------------------------------------------- Body tag $r->print(''. &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(<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(''); + } my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. '.sequence'; + $r->print(<
'); + $r->print(' Supplemental Course Documents'); + $r->print( + 'Supplemental Course Documents'. + ($allowed?' '.$help{'Supplemental'}:'').''); my $folder=$ENV{'form.folder'}; unless ($folder=~/supplemental/) { $folder='supplemental'; } &editor($r,$coursenum,$coursedom,$folder,$allowed); @@ -430,7 +713,7 @@ ENDFORM '.sequence'; $r->print(<
|
It is recommended that you use an up-to-date virus scanner before handling this file.