--- loncom/interface/londocs.pm 2004/02/13 14:59:48 1.106 +++ loncom/interface/londocs.pm 2004/04/24 05:20:54 1.118 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.106 2004/02/13 14:59:48 www Exp $ +# $Id: londocs.pm,v 1.118 2004/04/24 05:20:54 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -97,13 +97,15 @@ sub authorhosts { } else { ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); } - if (&Apache::lonnet::homeserver($ca,$cd) eq - $Apache::lonnet::perlvar{'lonHostID'}) { + my $allowed=0; + my $myhome=&Apache::lonnet::homeserver($ca,$cd); + my @ids=&Apache::lonnet::current_machine_ids(); + foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } } + if ($allowed) { $home++; $outhash{'home_'.$ca.'@'.$cd}=1; } else { - $outhash{'otherhome_'.$ca.'@'.$cd}= - &Apache::lonnet::homeserver($ca,$cd); + $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome; $other++; } } @@ -256,11 +258,34 @@ sub group_import { return &storemap($coursenum, $coursedom, $folder.'.sequence'); } +sub breadcrumbs { + my ($where)=@_; + &Apache::lonhtmlcommon::clear_breadcrumbs(); + my (@folders)=split('&',$ENV{'form.folderpath'}); + my $folderpath; + while (@folders) { + my $folder=shift(@folders); + my $foldername=shift(@folders); + if ($folderpath) {$folderpath.='&';} + $folderpath.=$folder.'&'.$foldername; + my $url='/adm/coursedocs?folderpath='. + &Apache::lonnet::escape($folderpath); + &Apache::lonhtmlcommon::add_breadcrumb( + {'href'=>$url, + 'title'=>&Apache::lonnet::unescape($foldername), + 'text'=>''. + &Apache::lonnet::unescape($foldername).'' + }); + + + } + return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,undef,undef,undef,0); +} + sub editor { my ($r,$coursenum,$coursedom,$folder,$allowed)=@_; - if ($ENV{'form.foldername'}) { - $r->print('

Folder: '.$ENV{'form.foldername'}.'

'); - } + + $r->print(&breadcrumbs($folder)); my $errtext=''; my $fatal=0; ($errtext,$fatal)= @@ -278,7 +303,7 @@ sub editor { # upload a file, if present if (($ENV{'form.uploaddoc.filename'}) && ($ENV{'form.cmd'}=~/^upload_(\w+)/)) { - if ($folder=~/^$1/) { + if ( ($folder=~/^$1/) || ($1 eq 'default') ) { # this is for a course, not a user, so set coursedoc flag # probably the only place in the system where this should be "1" my $url=&Apache::lonnet::userfileupload('uploaddoc',1); @@ -396,7 +421,7 @@ sub editor { my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]); unless ($name) { $name=(split(/\//,$url))[-1]; } unless ($name) { next; } - $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_)); + $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum)); $idx++; } $r->print(''); @@ -406,41 +431,44 @@ sub editor { # --------------------------------------------------------------- An entry line sub entryline { - my ($index,$title,$url,$folder,$allowed,$residx)=@_; + my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_; $title=~s/\&colon\;/\:/g; $title=&HTML::Entities::encode(&HTML::Entities::decode( - &Apache::lonnet::unescape($title)),'\"\<\>\&\''); + &Apache::lonnet::unescape($title)),'"<>&\''); my $renametitle=$title; my $foldertitle=$title; - if ($title=~ - /^(\d+)\_\_\_\&\;\&\;\&\;\_\_\_(\w+)\_\_\_\&\;\&\;\&\;\_\_\_(\w+)\_\_\_\&\;\&\;\&\;\_\_\_(.*)$/ - ) { - $foldertitle=&Apache::lontexconvert::msgtexconverted($4); - $renametitle=$4; - $title=''.&Apache::lonlocal::locallocaltime($1).' '. - &Apache::loncommon::plainname($2,$3).':
'. - $foldertitle; - } + if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) { + $foldertitle=&Apache::lontexconvert::msgtexconverted($4); + $renametitle=$4; + $title=''.&Apache::lonlocal::locallocaltime($1).' '. + &Apache::loncommon::plainname($2,$3).':
'. + $foldertitle; + } $renametitle=~s/\"\;/\\\"/g; my $line=''; # Edit commands - if ($allowed) { - my %lt=('up' => 'Move Up', - 'dw' => 'Move Down', - 'rm' => 'Remove', - 'rn' => 'Rename'); - $line.=(< 'Move Up', + 'dw' => 'Move Down', + 'rm' => 'Remove', + 'rn' => 'Rename'); + my $folderpath; + if ($ENV{'form.folderpath'}) { + $folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'}); + # $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"'); + } + $line.=(<
- + $lt{
- + $lt{
- + $lt{'rm'} - + $lt{'rn'} END } @@ -449,32 +477,39 @@ END my $uploaded=($url=~/^\/*uploaded\//); my $icon=&Apache::loncommon::icon($url); my $isfolder=0; + my $folderarg; if ($uploaded) { if ($extension eq 'sequence') { $icon=$iconpath.'/folder_closed.gif'; - $url=~/\/(\w+)\.sequence/; - $url='/adm/coursedocs?folder='.$1; + $url=~/$coursenum\/([\/\w]+)\.sequence$/; + $url='/adm/coursedocs?'; + $folderarg=$1; $isfolder=1; - } else { - $url=&Apache::lonnet::tokenwrapper($url); - } + } } $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//; - if (($residx) && ($folder!~/supplemental/)) { - $url.=(($url=~/\?/)?'&':'?').'symb='. - &Apache::lonnet::escape(&Apache::lonnet::symbclean( + if ((!$isfolder) && ($residx) && ($folder!~/supplemental/)) { + my $symb=&Apache::lonnet::symbclean( &Apache::lonnet::declutter('uploaded/'. $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'. $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder. '.sequence'). '___'.$residx.'___'. - &Apache::lonnet::declutter($url))); - } - if ($isfolder) { $url.='&foldername='. - &Apache::lonnet::escape($foldertitle); } - $line.=''. - "$title"; + &Apache::lonnet::declutter($url)); + (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); + $url=&Apache::lonnet::clutter($url); + $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb); + } + if ($isfolder) { + my $foldername=&Apache::lonnet::escape($foldertitle); + my $folderpath=$ENV{'form.folderpath'}; + if ($folderpath) { $folderpath.='&' }; + $folderpath.=$folderarg.'&'.$foldername; + $url.='folderpath='.&Apache::lonnet::escape($folderpath); + } + $line.=''. + "$title"; return $line; } @@ -502,7 +537,7 @@ sub checkonthis { $alreadyseen{$url}=1; $r->rflush(); if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) { - $r->print('
'); + $r->print("\n
"); for (my $i=0;$i<=$level*5;$i++) { $r->print(' '); } @@ -590,7 +625,8 @@ sub verifycontent { } } &untiehash(); - $r->print('

'.&mt('Done').'.

'); + $r->print('

'.&mt('Done').'.

'.''. + &mt('Return to DOCS').''); } # -------------------------------------------------------------- Check Versions @@ -637,7 +673,6 @@ sub checkversions { foreach (keys %ENV) { if ($_=~/^form\.set_version_(.+)$/) { my $src=$1; - &Apache::lonnet::logthis('Found: '.$1.' '.$ENV{$_}); if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) { $newsetversions{$src}=$ENV{$_}; } @@ -839,7 +874,9 @@ sub changewarning { $r->print( ''. '
'. -'

'. +'

'. &mt('Changes will become active for your current session after'). ' 'Bulletin Board', 'mypi' => 'My Personal Info', 'abou' => 'About User', + 'imsf' => 'Import IMS package', 'file' => 'File', 'title' => 'Title', 'comment' => 'Comment' @@ -1075,15 +1126,24 @@ ENDNEWSCRIPT 'vc' => 'Verify Content', 'cv' => 'Check/Set Resource Versions', ); + + my $folderpath=$ENV{'form.folderpath'}; + if (!$folderpath) { + if ($ENV{'form.folder'} eq '' || + $ENV{'form.folder'} eq 'supplemental') { + $folderpath='default&'. + &Apache::lonnet::escape(&mt('Main Course Documents')); + } + } $r->print(< - +
- +
@@ -1101,15 +1161,19 @@ ENDCOURSEVERIFY # --------------------------------------------------------- Standard documents $r->print('
'); if (($standard) && ($allowed) && (!$forcesupplement)) { - $r->print('

'.&mt('Main Course Documents'). - ($allowed?' '.$help{'Main_Course_Documents'}:'').'

'); + $r->print('
'); +# '

'.&mt('Main Course Documents'). +# ($allowed?' '.$help{'Main_Course_Documents'}:'').'

'); my $folder=$ENV{'form.folder'}; - unless ($folder=~/^default/) { $folder='default'; } + if ($folder eq '' || $folder eq 'supplemental') { + $folder='default'; + $ENV{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents')); + } my $postexec=''; if ($folder eq 'default') { $r->print(''); } else { - $postexec='self.close();'; + #$postexec='self.close();'; } $hadchanges=0; &editor($r,$coursenum,$coursedom,$folder,$allowed); @@ -1131,8 +1195,7 @@ $lt{'file'}:

$lt{'title'}:
- - + @@ -1142,13 +1205,10 @@ $lt{'title'}:
- - - + + - + $help{'Importing_LON-CAPA_Resource'}

@@ -1162,8 +1222,7 @@ $help{'Load_Map'}

- - + $help{'Adding_Fold
- - + $help{'Adding_Ext
- - + @@ -1191,8 +1248,7 @@ value="Syllabus=/public/$coursedom/$cour
- - + @@ -1201,8 +1257,7 @@ $help{'Navigate_Content'}
- - + $
- - +
- - +
- - +
- - + @@ -1249,14 +1300,18 @@ $help{'My Personal Info'}
- - +
+
+ + + +
ENDFORM @@ -1264,11 +1319,18 @@ ENDFORM } # ----------------------------------------------------- Supplemental documents if (!$forcestandard) { - $r->print( - '

'.&mt('Supplemental Course Documents'). - ($allowed?' '.$help{'Supplemental'}:'').'

'); + $r->print(''); +# '

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

'); my $folder=$ENV{'form.folder'}; - unless ($folder=~/supplemental/) { $folder='supplemental'; } + unless ($folder=~/^supplemental/) { + $folder='supplemental'; + } + if ($folder =~ /^supplemental$/ && + $ENV{'form.folderpath'} =~ /^default\&/) { + $ENV{'form.folderpath'}='supplemental&'. + &Apache::lonnet::escape(&mt('Supplemental Course Documents')); + } &editor($r,$coursenum,$coursedom,$folder,$allowed); if ($allowed) { my $folderseq= @@ -1286,8 +1348,8 @@ ENDFORM
$lt{'comment'}:
- - +
+ @@ -1297,8 +1359,7 @@ ENDFORM
- - + $help{'Adding_Fol
- - + $help{'Adding_Ext
- - + @@ -1327,8 +1386,7 @@ $help{'Syllabus'}
- - +