--- loncom/publisher/lonpubdir.pm 2003/09/25 22:30:06 1.40
+++ loncom/publisher/lonpubdir.pm 2008/01/17 04:50:57 1.108
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Construction Space Directory Lister
#
-# $Id: lonpubdir.pm,v 1.40 2003/09/25 22:30:06 www Exp $
+# $Id: lonpubdir.pm,v 1.108 2008/01/17 04:50:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,19 +25,6 @@
#
# http://www.lon-capa.org/
#
-#
-# (TeX Content Handler
-#
-# YEAR=2000
-# 05/29/00,05/30,10/11 Gerd Kortemeyer)
-#
-# 11/28,11/29,11/30,12/01,12/02,12/04,12/23 Gerd Kortemeyer
-# YEAR=2001
-# 03/23 Guy Albertelli
-# 03/24,03/29 Gerd Kortemeyer)
-# 03/31,04/03,05/09,06/23,08/18,08/20 Gerd Kortemeyer
-# 12/28 Gerd Kortemeyer
-#
###
package Apache::lonpubdir;
@@ -48,7 +35,13 @@ use File::Copy;
use Apache::Constants qw(:common :http :methods);
use Apache::loncacc;
use Apache::loncommon();
+use Apache::lonhtmlcommon();
+use Apache::londiff();
use Apache::lonlocal;
+use Apache::lonmsg;
+use Apache::lonmenu;
+use Apache::lonnet;
+use LONCAPA;
sub handler {
@@ -70,7 +63,7 @@ sub handler {
$fn,$r->dir_config('lonDefDomain'));
unless (($uname) && ($udom)) {
$r->log_reason($uname.' at '.$udom.
- ' trying to list directory '.$ENV{'form.filename'}.
+ ' trying to list directory '.$env{'form.filename'}.
' ('.$fn.') - not authorized',
$r->filename);
return HTTP_NOT_ACCEPTABLE;
@@ -81,7 +74,7 @@ sub handler {
$fn=~s/\/$//;
unless ($fn) {
- $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+ $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
' trying to list empty directory', $r->filename);
return HTTP_NOT_FOUND;
}
@@ -97,23 +90,36 @@ sub handler {
my $targetdir=$udom.'/'.$uname.$thisdisfn; # Publiction target directory.
my $linkdir='/priv/'.$uname.$thisdisfn; # Full URL name of constr space.
-
+ my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom);
&startpage($r, $uname, $udom, $thisdisfn); # Put out the start of page.
-
- # Start off the diretory table.
+ if ($env{'environment.remote'} eq 'off') {
+ &dircontrols($r,$uname,$udom,$thisdisfn); # Put out actions for directory,
+ # browse/upload + new file page.
+ } else {
+ &pubbuttons($r,$uname,$thisdisfn);
+ }
+ &resourceactions($r,$uname,$udom,$thisdisfn); #Put out form used for printing/deletion etc.
- $r->print('
'.
- ''.&mt('Actions').' | '.&mt('Name').' | '.
- &mt('Title').' | '.
- ''.&mt('Status').' | '.&mt('Last Modified').
- ' |
');
+ my $numdir = 0;
+ my $numres = 0;
+
+ # Start off the directory table.
+ $r->print(''.&mt('Directory Contents:').'
');
+ $r->print(''.
+ ''.&mt('Type').' | '.
+ ''.&mt('Actions').' | '.
+ ''.&mt('Name').' | '.
+ ''.&mt('Title').' | '.
+ ''.&mt('Status').' | '.
+ ''.&mt('Last Modified').
+ ' |
'."\n");
my $filename;
my $dirptr=16384; # Mask indicating a directory in stat.cmode.
opendir(DIR,$fn);
- my @files=sort(readdir(DIR));
+ my @files=sort {uc($a) cmp uc($b)} (readdir(DIR));
foreach my $filename (@files) {
my ($cdev,$cino,$cmode,$cnlink,
$cuid,$cgid,$crdev,$csize,
@@ -123,17 +129,17 @@ sub handler {
my $extension='';
if ($filename=~/\.(\w+)$/) { $extension=$1; }
if ($cmode&$dirptr) {
- putdirectory($r, $thisdisfn, $linkdir, $filename, $cmtime);
+ putdirectory($r, $thisdisfn, $linkdir, $filename, $cmtime,$targetdir,\%bombs,\$numdir);
} elsif (&Apache::loncommon::fileembstyle($extension) ne 'hdn') {
- putresource($r, $uname, $filename, $thisdisfn, $resdir,
- $targetdir, $linkdir, $cmtime);
+ putresource($r, $udom, $uname, $filename, $thisdisfn, $resdir,
+ $targetdir, $linkdir, $cmtime,\%bombs,\$numres);
} else {
# "hidden" extension and not a directory, so hide it away.
}
}
closedir(DIR);
- $r->print('