--- loncom/interface/lonindexer.pm 2006/04/10 21:40:08 1.142
+++ loncom/interface/lonindexer.pm 2009/03/19 15:01:24 1.195
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Directory Indexer
#
-# $Id: lonindexer.pm,v 1.142 2006/04/10 21:40:08 albertel Exp $
+# $Id: lonindexer.pm,v 1.195 2009/03/19 15:01:24 jms Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -53,7 +53,9 @@ use Apache::lonmeta;
use Apache::File;
use Apache::lonlocal;
use Apache::lonsource();
+use Apache::groupsort();
use GDBM_File;
+use LONCAPA qw(:match);
# ---------------------------------------- variables used throughout the module
my %hash; # global user-specific gdbm file
@@ -102,9 +104,9 @@ sub handler {
my $lonhost = $r->dir_config('lonHostID');
my $tabdir = $r->dir_config('lonTabDir');
- my $fileclr='#ffffe6';
+#SB my $fileclr='#ffffe6';
my $line;
- my (@attrchk,@openpath);
+ my (@attrchk,@openpath,$typeselect);
my $uri=$r->uri;
# -------------------------------------- see if called from an interactive mode
@@ -119,21 +121,26 @@ sub handler {
$extrafield='';
my $diropendb =
- "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_indexer.db";
+ "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_sel_res.db";
%hash = ();
{
my %dbfile;
- if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_READER(),0640)) {
+ if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_WRITER(),0640)) {
+ if ($env{'form.launch'} eq '1') {
+ &start_fresh_session(\%dbfile);
+ }
while(my($key,$value)=each(%dbfile)) {
$hash{$key}=$value;
}
untie(%dbfile);
}
}
- {
- if ($env{'form.launch'} eq '1') {
- &start_fresh_session();
+# - 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') {
&Apache::loncommon::content_type($r,'text/html');
@@ -170,19 +177,21 @@ ENDSUBM
# --------------------- define extra fields and buttons in case of special mode
if ($env{'form.catalogmode'} eq 'interactive') {
- $extrafield='
'.
- '
';
+#SB $extrafield='
'.
+ $extrafield='
'.
+ '
';
$colspan=" colspan='2' ";
my $cl=&mt('Close');
$closebutton=<
END
}
- elsif ($env{'form.catalogmode'} eq 'groupimport') {
- $extrafield='
\n")
if ($hash{'display_attrs_8'} == 1);
- $r->print("
".&mt("Source Available")."
\n")
+ $r->print("
".&mt("Source Available")."
\n")
if ($hash{'display_attrs_10'} == 1);
- $r->print("
".&mt("Linked/Related Resources")."
\n")
+ $r->print("
".&mt("Linked/Related Resources")."
\n")
if ($hash{'display_attrs_11'} == 1);
- $r->print("
".&mt("Resource")."
\n")
+ $r->print("
".&mt("Resource")."
\n")
if ($hash{'display_attrs_7'} == 1);
- $r->print('
');
+ $r->print("
".&mt("Subject")."
\n")
+ if ($hash{'display_attrs_12'} == 1);
+ $r->print("
".&mt("Notes")."
\n")
+ if ($hash{'display_attrs_13'} == 1);
+ $r->print("
".&mt("Abstract")."
\n")
+ if ($hash{'display_attrs_14'} == 1);
+ $r->print("
".&mt("Grade Level")."
\n")
+ if ($hash{'display_attrs_15'} == 1);
+ $r->print("
".&mt("Standards")."
\n")
+ if ($hash{'display_attrs_16'} == 1);
+
+ $r->print(&Apache::loncommon::end_data_table_header_row());
+
+
# ----------------- read in what directories have previously been set to "open"
foreach (keys %hash) {
@@ -578,14 +643,13 @@ END
# -------- recursively go through all the directories and output as appropriate
&scanDir ($r,$toplevel,$indent,\%hash);
-
-# ---------------------------- embed hidden information useful for group import
- $r->print("");
# -------------------------------------------------------------- end the tables
- $r->print('
');
- $r->print('
');
+ $r->print(&Apache::loncommon::end_data_table());
+
+# ---------------------------- embed hidden information useful for group import
+ $r->print("");
# --------------------------------------------------- end the output and return
$r->print(&Apache::loncommon::end_page()."\n");
@@ -621,7 +685,7 @@ sub scanDir {
next if($strip =~ /.*\.meta$/ | $obs eq '1');
my (@fileparts) = split(/\./,$strip);
if ($hash{'display_attrs_9'} != 1) {
-# if not all versions to be shown
+ # if not all versions to be shown
if (scalar(@fileparts) >= 3) {
my $fext = pop @fileparts;
my $ov = pop @fileparts;
@@ -677,7 +741,7 @@ sub get_list {
$uri=~s/\/+/\//g;
foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$uri))) {
my @ratpart=split(/\:/,$_);
- push @list,$ratpart[1];
+ push(@list,&LONCAPA::map::qtescape($ratpart[1]));
}
$hash{'dirlist_files_'.$luri} = join("\n",@list);
} else {
@@ -686,7 +750,7 @@ sub get_list {
$hash{'dirlist_files_'.$luri} = join("\n",@list);
$hash{'dirlist_timestamp_files_'.$luri} = time;
}
- return @list=&match_ext($r,@list);
+ return @list=&match_ext($r,@list);
}
sub dynmetaread {
@@ -704,7 +768,7 @@ sub dynmetaread {
}
# Actually get the data
%dynhash=
- (%dynhash,&Apache::lonmeta::get_dynamic_metadata_from_sql($uri));
+ (%dynhash,&Apache::lonmeta::get_dynamic_metadata_from_sql($uri.'/'));
# Remember that we got it
$dynread{$uri}=1;
}
@@ -782,7 +846,7 @@ sub display_line {
$pathprefix=$startdir;
}
my $dirptr=16384;
- my $fileclr="#ffffe6";
+#SB my $fileclr="#ffffe6";
my $iconpath= $r->dir_config('lonIconsURL') . '/';
my @filecom = split (/\&/,$line);
@@ -791,12 +855,14 @@ sub display_line {
my $fnptr = $filecom[3]&$dirptr;
my $msg = &mt('View').' '.$filecom[0].' '.&mt('resources');
$msg = &mt('Close').' '.$filecom[0].' '.&mt('directory') if $diropen eq 'opened';
+ my $nowOpen = ($diropen eq 'opened' ? 1 : 0);
my $tabtag='';
my $i=0;
- while ($i<=11) {
+ while ($i<=16) {
$tabtag=join('',$tabtag,"
")
- if $hash{'display_attrs_'.$i} == 1;
+ if ($i != 9 &&
+ $hash{'display_attrs_'.$i} == 1);
$i++;
}
my $valign = ($hash{'display_attrs_7'} == 1 ? 'top' : 'bottom');
@@ -808,7 +874,9 @@ sub display_line {
$updir='/'.(split(/\.(page|sequence)\/\//,$startdir))[-1];
$updir=~s/\/+/\//g;
- $r->print("
\n");
+ $r->print(&mt("Up")."$tabtag");
+ $r->print(&Apache::loncommon::end_data_table_row());
return OK;
}
# Do we have permission to look at this?
@@ -830,90 +900,102 @@ sub display_line {
if($filecom[15] ne '1') { return OK if (!&Apache::lonnet::allowed('bre',$pathprefix.$filecom[0])); }
# make absolute links appear on different background
- if ($absolute) { $fileclr='#ccdd99'; }
+#SB if ($absolute) { $fileclr='#ccdd99'; }
# display domain
if ($filecom[1] eq 'domain') {
$r->print (''."\n")
if ($env{'form.dirPointer'} eq "on");
- $r->print("
'."\n");
- return OK;
+ $r->print ($listname.'');
+
+ if (defined($plainname) && $plainname) { $r->print(" ($plainname) "); }
+ $r->print(''.$tabtag);
+ $r->print(&Apache::loncommon::end_data_table_row());
+ return OK;
}
# display file
- if (($fnptr == 0 and $filecom[3] ne '') or $absolute) {
- my $filelink = $pathprefix.$filecom[0];
- my @file_ext = split (/\./,$listname);
- my $curfext = $file_ext[-1];
- if (@Omit) {
- foreach (@Omit) { return OK if ($curfext eq $_); }
- }
- if (@Only) {
- my $skip = 1;
- foreach (@Only) { $skip = 0 if ($curfext eq $_); }
- return OK if ($skip > 0);
- }
- # Set the icon for the file
- my $iconname = &Apache::loncommon::icon($listname);
- $r->print("
");
+ if (($fnptr == 0 and $filecom[3] ne '') or $absolute) {
+ my $title;
+ my $filelink = $pathprefix.$filecom[0];
+ if ($hash{'display_attrs_0'} == 1) {
+ $title = &Apache::lonnet::gettitle($filelink);
+ }
+ my @file_ext = split (/\./,$listname);
+ my $curfext = $file_ext[-1];
+ if (@Omit) {
+ foreach (@Omit) { return OK if (lc($curfext) eq $_); }
+ }
+ if (@Only) {
+ my $skip = 1;
+ foreach (@Only) { $skip = 0 if (lc($curfext) eq $_); }
+ return OK if ($skip > 0);
+ }
+ # Set the icon for the file
+ my $iconname = &Apache::loncommon::icon($listname);
+#SB $r->print("