--- loncom/interface/lonindexer.pm 2007/06/26 23:06:17 1.160
+++ loncom/interface/lonindexer.pm 2010/04/14 16:11:34 1.181.4.6
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Directory Indexer
#
-# $Id: lonindexer.pm,v 1.160 2007/06/26 23:06:17 banghart Exp $
+# $Id: lonindexer.pm,v 1.181.4.6 2010/04/14 16:11:34 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -53,6 +53,7 @@ use Apache::lonmeta;
use Apache::File;
use Apache::lonlocal;
use Apache::lonsource();
+use Apache::groupsort();
use GDBM_File;
use LONCAPA qw(:match);
@@ -105,7 +106,7 @@ sub handler {
my $fileclr='#ffffe6';
my $line;
- my (@attrchk,@openpath);
+ my (@attrchk,@openpath,$typeselect);
my $uri=$r->uri;
# -------------------------------------- see if called from an interactive mode
@@ -128,13 +129,17 @@ sub handler {
if ($env{'form.launch'} eq '1') {
&start_fresh_session(\%dbfile);
}
-
while(my($key,$value)=each(%dbfile)) {
$hash{$key}=$value;
}
untie(%dbfile);
}
}
+# - Evaluate actions from previous page (both cumulatively and chronologically)
+ if ($env{'form.catalogmode'} eq 'import' || $hash{'form.catalogmode'} eq 'import') {
+ &Apache::groupsort::update_actions_hash(\%hash);
+ }
+
{
#Hijack lonindexer to verify a title and be close down.
if ($env{'form.launch'} eq '2') {
@@ -174,26 +179,26 @@ ENDSUBM
if ($env{'form.catalogmode'} eq 'interactive') {
$extrafield='
'.
'
';
+ ' class="LC_icon" />';
$colspan=" colspan='2' ";
my $cl=&mt('Close');
$closebutton=<
+
END
}
elsif ($env{'form.catalogmode'} eq 'import') {
$extrafield='
'.
'
';
+ ' class="LC_icon" />';
$colspan=" colspan='2' ";
my $cl=&mt('Close');
my $gi=&mt('Import');
$closebutton=<
+
END
$groupimportbutton=<
+onclick="javascript:select_group()" />
END
}
# Additions made by Matthew to make the browser a little easier to deal
@@ -242,7 +247,7 @@ END
#
#
if (!defined($mode) || ($mode ne 'edit' && $mode ne 'parmset')) {
- my $location = "/adm/groupsort?catalogmode=import&";
+ my $location = "/adm/groupsort?&inhibitmenu=yes&catalogmode=import&";
$location .= "mode=".$mode."&";
$location .= "acts=";
$catalogmodefunctions=<<"END";
@@ -269,6 +274,9 @@ END
function select_data(url) {
var location = "/res/?launch=2&form=$form&element=$element&titleelement=$titleelement&acts=" + url;
window.location=location;
+ if (window.opener.document.forms["$form"].elements["$element"].value != url) {
+ window.opener.unClean();
+ }
}
function select_group() {
window.location="$location"+document.forms.fileattr.acts.value;
@@ -311,10 +319,8 @@ function select_group() {
function changeURL(val) {
if (window.opener.document) {
- var elementname = "$element"+"_value";
- var checkboxname = "$element"+"_setparmval";
+ var elementname = "$element";
window.opener.document.forms["$form"].elements[elementname].value=val;
- window.opener.document.forms["$form"].elements[checkboxname].checked=true;
} else {
alert("The file you selected is: "+val);
}
@@ -346,20 +352,37 @@ function queue(val) {
END
}
+ my $inhibit_menu = "+'&".&Apache::loncommon::inhibit_menu_check()."'";
# ---------------------------------------------------------------- Print Header
+
my $js = <<"ENDHEADER";
ENDHEADER
my ($headerdom)=($uri=~m{^/res/($match_domain)/});
- $r->print(&Apache::loncommon::start_page('Browse Resources',$js,
- {'domain' => $headerdom,}));
-# - Evaluate actions from previous page (both cumulatively and chronologically)
- if ($env{'form.catalogmode'} eq 'import') {
- my $acts=$env{'form.acts'};
- my @Acts=split(/b/,$acts);
- my %ahash;
- my %achash;
- my $ac=0;
- # some initial hashes for working with data
- foreach (@Acts) {
- my ($state,$ref)=split(/a/);
- $ahash{$ref}=$state;
- $achash{$ref}=$ac;
- $ac++;
- }
- # sorting through the actions and changing the global database hash
- foreach (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) {
- my $key=$_;
- if ($ahash{$key} eq '1') {
- $hash{'store_'.$hash{'pre_'.$key.'_link'}}=
- $hash{'pre_'.$key.'_title'};
- $hash{'storectr_'.$hash{'pre_'.$key.'_link'}}=
- $hash{'storectr'}+0;
- $hash{'storectr'}++;
- }
- if ($ahash{$key} eq '0') {
- if ($hash{'store_'.$hash{'pre_'.$key.'_link'}}) {
- delete $hash{'store_'.$hash{'pre_'.$key.'_link'}};
- }
- }
- }
- # deleting the previously cached listing
- foreach (keys %hash) {
- if ($_ =~ /^pre_/ && $_ =~/link$/) {
- my $key = $_;
- $key =~ s/^pre_//;
- $key =~ s/_[^_]*$//;
- delete $hash{'pre_'.$key.'_title'};
- delete $hash{'pre_'.$key.'_link'};
- }
- }
+ my %args = (
+ 'domain' => $headerdom,
+ );
+ if ($env{'form.catalogmode'}) {
+ # "Popup mode"
+ $args{'only_body'} = 1;
+ }
+ $r->print(&Apache::loncommon::start_page('Browse Resources',$js,\%args));
+# ---------------------------------- get state of file types to be showing
+ if ($env{'form.only'}) {
+ $typeselect = $env{'form.only'};
+ } else {
+ $typeselect = '';
}
-
+
# ---------------------------------- get state of file attributes to be showing
if ($env{'form.attrs'}) {
- for (my $i=0; $i<=11; $i++) {
+ for (my $i=0; $i<=16; $i++) {
delete $hash{'display_attrs_'.$i};
if ($env{'form.attr'.$i} == 1) {
- $attrchk[$i] = 'checked';
+ $attrchk[$i] = 'checked="checked"';
$hash{'display_attrs_'.$i} = 1;
}
}
} else {
- for (my $i=0; $i<=11; $i++) {
- $attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1;
+ for (my $i=0; $i<=16; $i++) {
+ $attrchk[$i] = 'checked="checked"' if $hash{'display_attrs_'.$i} == 1;
}
}
+ my @file_categories = &Apache::loncommon::filecategories();
+ my %select_file_categories;
+ my @select_form_order = ('');
+ $select_file_categories{''} = &mt('All file types');
+ foreach my $cat (@file_categories) {
+ my $types = join(",",&Apache::loncommon::filecategorytypes($cat));
+ $select_file_categories{$types} = &mt($cat);
+ push(@select_form_order,$types);
+ }
+ $select_file_categories{'select_form_order'} = \@select_form_order;
+ my $type_element=
+ &Apache::loncommon::select_form(
+ $typeselect,
+ 'only',
+ %select_file_categories);
+ my $type_selector = '';
+
# ------------------------------- output state of file attributes to be showing
# All versions has to the last item
# since it does not take an extra col
- my %lt=&Apache::lonlocal::texthash(
- 'ti' => 'Title',
- 'si' => 'Size',
- 'la' => 'Last access',
- 'lm' => 'Last modified',
- 'st' => 'Statistics',
- 'au' => 'Author',
- 'kw' => 'Keywords',
- 'ln' => 'Language',
- 'sa' => 'Source Available',
- 'sr' => 'Show resource',
- 'li' => 'Linked/Related Resources',
- 'av' => 'All versions',
- 'ud' => 'Update Display'
- );
- $r->print(<
-
-