');
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ }
}
- &dircontrols($r,$uname,$udom,$thisdisfn); # Put out actions for directory,
- # browse/upload + new file page.
+ # Put out actions for directory, browse/upload + new file page.
+ &dircontrols($r,$uname,$udom,$thisdisfn,$current_disk_usage,$disk_quota,$crsauthor);
&resourceactions($r,$uname,$udom,$thisdisfn); # Put out form used for printing/deletion etc.
my $numdir = 0;
my $numres = 0;
-
- # Retrieving value for "sortby" and "sortorder" from QUERY_STRING
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['sortby','sortorder']);
-
- # Sort by name as default, not reversed
- if (! exists($env{'form.sortby'})) { $env{'form.sortby'} = 'filename' }
- if (! exists($env{'form.sortorder'})) { $env{'form.sortorder'} = '' }
-
- my $sortby = $env{'form.sortby'};
- my $sortorder = $env{'form.sortorder'};
if ((@files == 0) && ($thisdisfn =~ m{^/$match_domain/$match_username})) {
if ($thisdisfn =~ m{^/$match_domain/$match_username$}) {
@@ -136,61 +170,116 @@ sub handler {
return OK;
}
- # Start off the directory table.
- $r->print(&Apache::loncommon::start_data_table()
- .&Apache::loncommon::start_data_table_header_row()
- .'
'
+ # Retrieving value for "sortby" and "sortorder" from QUERY_STRING
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['sortby','sortorder']);
+
+ # Sort by name as default, not reversed
+ if (! exists($env{'form.sortby'})) { $env{'form.sortby'} = 'filename' }
+ if (! exists($env{'form.sortorder'})) { $env{'form.sortorder'} = '' }
+ my $sortby = $env{'form.sortby'};
+ my $sortorder = $env{'form.sortorder'};
+
+ # Order in which columns are displayed from left to right
+ my @order = ('filetype','actions','filename','title',
+ 'pubstatus','cmtime','size');
+
+ # Up and down arrows to indicate sort order
+ my @arrows = (' ▲',' ▼','');
+
+ # Default sort order and column title
+ my %columns = (
+ filetype => {
+ order => 'ascending',
+ text => &mt('Type'),
+ },
+ actions => {
+ # Not sortable
+ text => &mt('Actions'),
+ },
+ filename => {
+ order => 'ascending',
+ text => &mt('Name'),
+ },
+ title => {
+ order => 'ascending',
+ text => &mt('Title'),
+ },
+ pubstatus => {
+ order => 'ascending',
+ text => &mt('Status'),
+ colspan => '2',
+ },
+ cmtime => {
+ order => 'descending',
+ text => &mt('Last Modified'),
+ },
+ size => {
+ order => 'ascending',
+ text => &mt('Size').' (kB)',
+ },
+ );
+
+ # Print column headers
+ my $output = '';
+ foreach my $key (@order) {
+ my $idx;
+ # Append an up or down arrow to sorted column
+ if ($sortby eq $key) {
+ $idx = ($columns{$key}{order} eq 'ascending') ? 0:1;
+ if ($sortorder eq 'rev') { $idx ++; }
+ $idx = $idx%2;
+ } else { $idx = 2; } # No arrow if column is not sorted
+ $output .= (($columns{$key}{order}) ?
+ '
'
+ .&Apache::loncommon::start_data_table_header_row() . $output
.&Apache::loncommon::end_data_table_header_row()
);
my $dirptr=16384; # Mask indicating a directory in stat.cmode.
my $filehash = {};
foreach my $filename (@files) {
- # Skip .DS_Store and hidden files
+ # Skip .DS_Store, .DAV and hidden files
my ($extension) = ($filename=~/\.(\w+)$/);
next if (($filename eq '.DS_Store')
+ || ($filename eq '.DAV')
|| (&Apache::loncommon::fileembstyle($extension) eq 'hdn')
|| ($filename =~ /^\._/));
my ($cmode,$csize,$cmtime)=(stat($fn.'/'.$filename))[2,7,9];
my $linkfilename = &HTML::Entities::encode('/priv'.$thisdisfn.'/'.$filename,'<>&"');
# Identify type of file according to icon used
- my ($filetype) = (&Apache::loncommon::icon($filename) =~ m{/(\w+).gif$});
+ my ($filetype) = (&Apache::loncommon::icon($filename) =~ m{/(\w+).gif$});
my $cstr_dir = $r->dir_config('lonDocRoot').'/priv'.$thisdisfn;
my $meta_same = &isMetaSame($cstr_dir, $resdir, $filename);
-
+
# Store size, title, and status for files but not directories
my $size = (!($cmode&$dirptr)) ? $csize/1024. : 0;
my ($status, $pubstatus, $title, $fulltitle);
if (!($cmode&$dirptr)) {
- ($status, $pubstatus) = &getStatus($resdir, $targetdir, $cstr_dir,
+ ($status, $pubstatus) = &getStatus($resdir, $targetdir, $cstr_dir,
$filename, $linkfilename, $cmtime, $meta_same);
- ($fulltitle, $title) = &getTitle($resdir, $targetdir, $filename,
- $linkfilename, $meta_same, \%bombs);
+ if (($crsauthor) && ($extension eq 'rights')) {
+ $title = &getTitleString($targetdir.'/'.$filename);
+ $fulltitle = $title;
+ } else {
+ ($fulltitle, $title) = &getTitle($resdir, $targetdir, $filename,
+ $linkfilename, $meta_same, \%bombs);
+ }
} else {
($status, $pubstatus) = ('','');
($fulltitle, $title) = ('','');
@@ -209,7 +298,7 @@ sub handler {
"linkfilename" => $linkfilename,
}
}
-
+
my @sorted_files;
# Sorting by something other than "Name". Name is the secondary key.
if ($sortby =~ m{cmtime|size}) { # Numeric fields
@@ -243,7 +332,7 @@ sub handler {
}
# Sort by "Name" is the default
- } else {
+ } else {
if ($sortorder eq "rev") {
@sorted_files = sort {uc($b) cmp uc($a)} (keys(%{$filehash}));
} else {
@@ -252,73 +341,103 @@ sub handler {
}
# Print the sorted resources
+ my %editors = &Apache::loncommon::permitted_editors();
foreach my $filename (@sorted_files) {
if ($filehash->{$filename}->{"cmode"}&$dirptr) { # Directories
- &putdirectory($r, $thisdisfn, $linkdir, $filename,
- $filehash->{$filename}->{"cmtime"},
+ &putdirectory($r, $thisdisfn, $linkdir, $filename,
+ $filehash->{$filename}->{"cmtime"},
$targetdir, \%bombs, \$numdir);
} else { # Files
&putresource($r, $udom, $uname, $filename, $thisdisfn, $resdir,
- $targetdir, $linkdir, $filehash->{$filename}->{"cmtime"},
- $filehash->{$filename}->{"size"}, \$numres,
+ $targetdir, $linkdir, $crsauthor,
+ $filehash->{$filename}->{"cmtime"},
+ $filehash->{$filename}->{"size"}, \$numres,
$filehash->{$filename}->{"linkfilename"},
$filehash->{$filename}->{"fulltitle"},
$filehash->{$filename}->{"status"},
- $filehash->{$filename}->{"pubstatus"});
+ $filehash->{$filename}->{"pubstatus"},
+ \%editors);
}
}
- $r->print( &Apache::loncommon::end_data_table()
- .&Apache::loncommon::end_page() );
-
- return OK;
+ $r->print(&Apache::loncommon::end_data_table()
+ .'
'
+ .&Apache::loncommon::start_data_table()
+ .'
'.&mt('Results in other directories:').'
'
+ .'
'
+ .'
'.&mt('Type').'
'
+ .'
'.&mt('Directory').'
'
+ .'
'.&mt('Name').'
'
+ .'
'.&mt('Title').'
'
+ .'
'.&mt('Status').'
'
+ .'
'.&mt('Last Modified').'
'
+ .'
'
+ .&Apache::loncommon::end_data_table()
+ .'
'
+ .&Apache::loncommon::end_page()
+ );
+ return OK;
}
# Output the header of the page. This includes:
-# - The HTML header
+# - The HTML header
# - The H1/H3 stuff which includes the directory.
#
-# startpage($r, $uame, $udom, $thisdisfn);
+# startpage($r, $uame, $udom, $thisdisfn, $current_disk_usage, $disk_quota);
# $r - The apache request object.
# $uname - User name.
# $udom - Domain name the user is logged in under.
# $thisdisfn - Displayable version of the filename.
+# $current_disk_usage - User's current disk usage (in kB).
+# $disk_quota - Disk quota for user's authoring space (in MB).
+# $crstype - Course type, if this is for "course author"
sub startpage {
- my ($r, $uname, $udom, $thisdisfn) = @_;
+ my ($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota, $crsauthor) = @_;
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
my $formaction='/priv'.$thisdisfn.'/';
$formaction=~s|/+|/|g;
- &Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction);
+
+ my $title;
+ if ($crsauthor) {
+ $title = 'Course Authoring';
+ } else {
+ $title = 'Authoring Space';
+ &Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction);
+ }
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb({
- 'text' => 'Authoring Space',
+ 'text' => $title,
'href' => &Apache::loncommon::authorspace($formaction),
});
- # breadcrumbs (and tools) will be created
+ # breadcrumbs (and tools) will be created
# in start_page->bodytag->innerregister
$env{'request.noversionuri'}=$formaction;
- $r->print(&Apache::loncommon::start_page('Authoring Space'));
-
- my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
- my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,"$londocroot/priv/$udom/$uname");
- my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in MB
- $disk_quota = 1000 * $disk_quota; # convert from MB to kB
-
+ my $js = '';
+ $r->print(&Apache::loncommon::start_page($title, $js));
+
+ $disk_quota = 1024 * $disk_quota; # convert from MB to kB
+
+ my $headertext = &mt('Directory');
+ if ($crsauthor) {
+ $headertext = &mt('Course Authoring Directory');
+ }
$r->print(&Apache::loncommon::head_subbox(
'