--- loncom/interface/londocs.pm 2004/03/16 22:46:59 1.110
+++ loncom/interface/londocs.pm 2004/04/07 20:36:54 1.114
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.110 2004/03/16 22:46:59 raeburn Exp $
+# $Id: londocs.pm,v 1.114 2004/04/07 20:36:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -258,11 +258,54 @@ sub group_import {
return &storemap($coursenum, $coursedom, $folder.'.sequence');
}
-sub editor {
- my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
+sub breadcrumbs {
+ my ($where)=@_;
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ if ($where =~ /^default/) {
+ &Apache::lonhtmlcommon::add_breadcrumb({'href'=>'/adm/coursedocs',
+ 'title'=>'Main Course Documents',
+ 'text' =>'Main Course Documents'});
+ } elsif ($where =~ /^supplemental/) {
+ &Apache::lonhtmlcommon::add_breadcrumb({'href'=>'/adm/coursedocs',
+ 'title'=>'Supplemental Course Documents',
+ 'text' =>'Supplemental Course Documents'});
+
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb({'href'=>'/adm/coursedocs',
+ 'title'=>$where,
+ 'text' =>$where});
+ }
if ($ENV{'form.foldername'}) {
- $r->print('
Folder: '.$ENV{'form.foldername'}.'
');
+ my @folders;
+ if (defined($ENV{'form.folders'})) {
+ @folders=@{$ENV{'form.folders'}};
+ }
+ @folders=(@folders,$ENV{'form.folder'},
+ &Apache::lonnet::escape($ENV{'form.foldername'}));
+
+ 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();
+}
+
+sub editor {
+ my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
+
+ $r->print(&breadcrumbs($folder));
my $errtext='';
my $fatal=0;
($errtext,$fatal)=
@@ -280,7 +323,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);
@@ -398,7 +441,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('');
@@ -408,7 +451,7 @@ 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)),'"<>&\'');
@@ -433,7 +476,7 @@ sub entryline {
if ($ENV{'form.foldername'}) {
$foldername='&foldername='.
&Apache::lonnet::escape($ENV{'form.foldername'});
- $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'});
+ $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
}
$line.=(<
@@ -455,32 +498,41 @@ 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;
}
@@ -899,7 +951,13 @@ sub handler {
my $events='';
my $showdoc=0;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['folder','foldername']);
+ ['folderpath']);
+ if ($ENV{'form.folderpath'}) {
+ my (@folderpath)=split('&',$ENV{'form.folderpath'});
+ $ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
+ $ENV{'form.folder'}=pop(@folderpath);
+ $ENV{'form.folders'}=\@folderpath;
+ }
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
$showdoc=$1;
}
@@ -1119,13 +1177,15 @@ ENDCOURSEVERIFY
&mt('Editing the Table of Contents for your Course')));
}
# --------------------------------------------------------- Standard documents
- my $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'});
+ my $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
$r->print('');
if (($standard) && ($allowed) && (!$forcesupplement)) {
$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='default';
+ }
my $postexec='';
if ($folder eq 'default') {
$r->print('');
|