version 1.79, 2003/10/24 21:09:24
|
version 1.87, 2004/01/26 19:55:44
|
Line 25
|
Line 25
|
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
# YEAR=1999 |
|
# 5/21/99, 5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14 Gerd Kortemeyer) |
|
# 11/23 Gerd Kortemeyer |
|
# YEAR=2000 |
|
# 07/20-08/04 H.K. Ng |
|
# YEAR=2001 |
|
# 05/9-05/19/2001 H. K. Ng |
|
# 05/21/2001 H. K. Ng |
|
# 05/23/2001 H. K. Ng |
|
# 6/26,7/8 H. K. Ng |
|
# 8/14 H. K. Ng |
|
# 11/30 Matthew Hall |
|
# YEAR=2002 |
|
# 6/29/2002 H. K. Ng |
|
# |
|
### |
### |
|
|
############################################################################### |
############################################################################### |
Line 61 package Apache::lonindexer;
|
Line 46 package Apache::lonindexer;
|
use strict; |
use strict; |
use Apache::lonnet(); |
use Apache::lonnet(); |
use Apache::loncommon(); |
use Apache::loncommon(); |
|
use Apache::lonhtmlcommon(); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::lonmeta; |
use Apache::lonmeta; |
use Apache::File; |
use Apache::File; |
Line 68 use Apache::lonlocal;
|
Line 54 use Apache::lonlocal;
|
use GDBM_File; |
use GDBM_File; |
|
|
# ---------------------------------------- variables used throughout the module |
# ---------------------------------------- variables used throughout the module |
my %hash; # tied to a user-specific gdbm file |
my %hash; # global user-specific gdbm file |
my %dirs; # keys are directories, values are the open/close status |
my %dirs; # keys are directories, values are the open/close status |
my %language; # has the reference information present in language.tab |
my %language; # has the reference information present in language.tab |
|
|
Line 130 sub handler {
|
Line 116 sub handler {
|
%hash = (); |
%hash = (); |
{ |
{ |
my %dbfile; |
my %dbfile; |
if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { |
if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_READER(),0640)) { |
while(my($key,$value)=each(%dbfile)) { |
while(my($key,$value)=each(%dbfile)) { |
$hash{$key}=$value; |
$hash{$key}=$value; |
} |
} |
Line 374 $r->print(&Apache::loncommon::bodytag('B
|
Line 360 $r->print(&Apache::loncommon::bodytag('B
|
$achash{$ref}=$ac; |
$achash{$ref}=$ac; |
$ac++; |
$ac++; |
} |
} |
# sorting through the actions and changing the tied database hash |
# sorting through the actions and changing the global database hash |
foreach (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) { |
foreach (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) { |
my $key=$_; |
my $key=$_; |
if ($ahash{$key} eq '1') { |
if ($ahash{$key} eq '1') { |
Line 403 $r->print(&Apache::loncommon::bodytag('B
|
Line 389 $r->print(&Apache::loncommon::bodytag('B
|
} |
} |
|
|
# ---------------------------------- get state of file attributes to be showing |
# ---------------------------------- get state of file attributes to be showing |
if ($ENV{'form.attrs'} ne '') { |
if ($ENV{'form.attrs'}) { |
for (my $i=0; $i<=9; $i++) { |
for (my $i=0; $i<=9; $i++) { |
delete $hash{'display_attrs_'.$i}; |
delete $hash{'display_attrs_'.$i}; |
if ($ENV{'form.attr'.$i} == 1) { |
if ($ENV{'form.attr'.$i} == 1) { |
Line 416 $r->print(&Apache::loncommon::bodytag('B
|
Line 402 $r->print(&Apache::loncommon::bodytag('B
|
$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; |
$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; |
} |
} |
} |
} |
|
|
# ------------------------------- output state of file attributes to be showing |
# ------------------------------- output state of file attributes to be showing |
# All versions has to the last item |
# All versions has to the last item |
# since it does not take an extra col |
# since it does not take an extra col |
Line 432 $r->print(&Apache::loncommon::bodytag('B
|
Line 419 $r->print(&Apache::loncommon::bodytag('B
|
'av' => 'All versions', |
'av' => 'All versions', |
'ud' => 'Update Display' |
'ud' => 'Update Display' |
); |
); |
|
my $Displayfileattributes=&mt('Display file attributes'); |
$r->print(<<END); |
$r->print(<<END); |
<form method="post" name="fileattr" action="$uri" |
<form method="post" name="fileattr" action="$uri" |
enctype="application/x-www-form-urlencoded"> |
enctype="application/x-www-form-urlencoded"> |
<b><font color="#666666">Display file attributes</font></b><br /> |
<b><font color="#666666">$Displayfileattributes</font></b><br /> |
<table border=0><tr> |
<table border=0><tr> |
<td><input type="checkbox" name="attr0" value="1" $attrchk[0] /> $lt{'ti'}</td> |
<td><input type="checkbox" name="attr0" value="1" $attrchk[0] onClick="this.form.submit();" /> $lt{'ti'}</td> |
<td><input type="checkbox" name="attr1" value="1" $attrchk[1] /> $lt{'si'}</td> |
<td><input type="checkbox" name="attr1" value="1" $attrchk[1] onClick="this.form.submit();" /> $lt{'si'}</td> |
<td><input type="checkbox" name="attr2" value="1" $attrchk[2] /> $lt{'la'}</td> |
<td><input type="checkbox" name="attr2" value="1" $attrchk[2] onClick="this.form.submit();" /> $lt{'la'}</td> |
<td><input type="checkbox" name="attr3" value="1" $attrchk[3] /> $lt{'lm'}</td> |
<td><input type="checkbox" name="attr3" value="1" $attrchk[3] onClick="this.form.submit();" /> $lt{'lm'}</td> |
<td><input type="checkbox" name="attr8" value="1" $attrchk[8] /> $lt{'st'}</td> |
<td><input type="checkbox" name="attr8" value="1" $attrchk[8] onClick="this.form.submit();" /> $lt{'st'}</td> |
</tr><tr> |
</tr><tr> |
<td><input type="checkbox" name="attr4" value="1" $attrchk[4] /> $lt{'au'}</td> |
<td><input type="checkbox" name="attr4" value="1" $attrchk[4] onClick="this.form.submit();" /> $lt{'au'}</td> |
<td><input type="checkbox" name="attr5" value="1" $attrchk[5] /> $lt{'kw'}</td> |
<td><input type="checkbox" name="attr5" value="1" $attrchk[5] onClick="this.form.submit();" /> $lt{'kw'}</td> |
<td><input type="checkbox" name="attr6" value="1" $attrchk[6] /> $lt{'ln'}</td> |
<td><input type="checkbox" name="attr6" value="1" $attrchk[6] onClick="this.form.submit();" /> $lt{'ln'}</td> |
<td><input type="checkbox" name="attr7" value="1" $attrchk[7] /> $lt{'sr'}</td> |
<td><input type="checkbox" name="attr7" value="1" $attrchk[7] onClick="this.form.submit();" /> $lt{'sr'}</td> |
<td><input type="checkbox" name="attr9" value="1" $attrchk[9] /> $lt{'av'}</td> |
<td><input type="checkbox" name="attr9" value="1" $attrchk[9] onClick="this.form.submit();" /> $lt{'av'}</td> |
<td> </td> |
<td> </td> |
</tr></table> |
</tr></table> |
<input type="hidden" name="dirPointer" value="on" /> |
<input type="hidden" name="attrs" value="1" /> |
|
<input type="submit" name="updatedisplay" value="$lt{'ud'}" /> |
<input type="hidden" name="acts" value="" /> |
<input type="hidden" name="acts" value="" /> |
<input type="submit" name="attrs" value="$lt{'ud'}" /> |
$closebutton $groupimportbutton |
$closebutton |
|
$groupimportbutton |
|
</form> |
|
END |
END |
|
# ---------------------------------------------------------------- Bread crumbs |
|
$r->print(&Apache::lonhtmlcommon::crumbs($uri,'','', |
|
(($ENV{'form.catalogmode'} eq 'groupimport')? |
|
'document.forms.fileattr':'')). |
|
&Apache::lonhtmlcommon::select_recent('residx','resrecent', |
|
'this.form.action=this.form.resrecent.options[this.form.resrecent.selectedIndex].value;this.form.submit();'). |
|
'</form>'); |
|
# ------------------------------------------------------ Remember where we were |
|
&Apache::loncommon::storeresurl($uri); |
|
&Apache::lonhtmlcommon::store_recent('residx',$uri,$uri); |
# ----------------- output starting row to the indexed file/directory hierarchy |
# ----------------- output starting row to the indexed file/directory hierarchy |
my $titleclr="#ddffff"; |
my $titleclr="#ddffff"; |
# $r->print(&initdebug()); |
# $r->print(&initdebug()); |
Line 512 END
|
Line 507 END
|
} |
} |
} |
} |
|
|
my $bredir = $ENV{'form.dirPointer'}; |
|
my $toplevel; |
my $toplevel; |
my $indent = 0; |
my $indent = 0; |
$uri = $uri.'/' if $uri !~ /.*\/$/; |
$uri = $uri.'/' if $uri !~ /.*\/$/; |
|
|
if ($bredir ne 'on') { |
|
$hash{'top.level'} = $uri; |
|
$toplevel = $uri; |
|
|
|
} else { |
$hash{'top.level'} = $uri; |
$toplevel = $hash{'top.level'}; |
$toplevel = $uri; |
} |
|
|
|
# -------------------------------- if not at top level, provide an uplink arrow |
# -------------------------------- if not at top level, provide an uplink arrow |
if ($toplevel ne '/res/'){ |
if ($toplevel ne '/res/'){ |
Line 548 END
|
Line 538 END
|
|
|
# --------------------------------------------------- end the output and return |
# --------------------------------------------------- end the output and return |
$r->print('</body></html>'."\n"); |
$r->print('</body></html>'."\n"); |
# } else { |
|
# $r->print('<html><head></head><body>Unable to tie hash to db '. |
|
# 'file</body></html>'); |
|
# return OK; |
|
} |
} |
if(! $c->aborted()) { |
if(! $c->aborted()) { |
|
# write back into the temporary file |
my %dbfile; |
my %dbfile; |
if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_NEWDB(),0640)) { |
if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_NEWDB(),0640)) { |
while (my($key,$value) = each(%hash)) { |
while (my($key,$value) = each(%hash)) { |
Line 620 sub get_list {
|
Line 607 sub get_list {
|
my ($r,$uri)=@_; |
my ($r,$uri)=@_; |
my @list; |
my @list; |
(my $luri = $uri) =~ s/\//_/g; |
(my $luri = $uri) =~ s/\//_/g; |
|
if ($ENV{'form.updatedisplay'}) { |
if ($ENV{'form.attrs'} eq &mt('Update Display')) { |
|
foreach (keys %hash) { |
foreach (keys %hash) { |
delete $hash{$_} if ($_ =~ /^dirlist_files_/); |
delete $hash{$_} if ($_ =~ /^dirlist_files_/); |
} |
} |
} |
} |
|
|
if ($hash{'dirlist_files'.$luri}) { |
if ($hash{'dirlist_files_'.$luri}) { |
@list = split(/\n/,$hash{'dirlist_files_'.$luri}); |
@list = split(/\n/,$hash{'dirlist_files_'.$luri}); |
} else { |
} else { |
@list = &Apache::lonnet::dirlist($uri); |
@list = &Apache::lonnet::dirlist($uri); |
$hash{'dirlist_files_'.$luri} = join('\n',@list); |
$hash{'dirlist_files_'.$luri} = join("\n",@list); |
} |
} |
return @list=&match_ext($r,@list); |
return @list=&match_ext($r,@list); |
} |
} |
Line 684 sub match_ext {
|
Line 670 sub match_ext {
|
push @trimlist,$line; |
push @trimlist,$line; |
} |
} |
} |
} |
@trimlist = sort (@trimlist); |
@trimlist = sort {uc($a) cmp uc($b)} (@trimlist); |
return @trimlist; |
return @trimlist; |
} |
} |
|
|
Line 739 sub display_line {
|
Line 725 sub display_line {
|
|
|
# display domain |
# display domain |
if ($filecom[1] eq 'domain') { |
if ($filecom[1] eq 'domain') { |
$r->print ('<input type="hidden" name="dirPointer" value="on">'."\n") |
|
if ($ENV{'form.dirPointer'} eq "on"); |
|
$r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield"); |
$r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield"); |
$r->print("<td>"); |
$r->print("<td>"); |
&begin_form ($r,$filecom[0]); |
&begin_form ($r,$filecom[0]); |
Line 805 sub display_line {
|
Line 789 sub display_line {
|
return OK if ($skip > 0); |
return OK if ($skip > 0); |
} |
} |
# Set the icon for the file |
# Set the icon for the file |
my $iconname = "unknown.gif"; |
my $iconname = &Apache::loncommon::icon($listname); |
my $embstyle = &Apache::loncommon::fileembstyle($curfext); |
|
# The unless conditional that follows is a bit of overkill |
|
$iconname = $curfext.".gif" unless |
|
(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn'); |
|
# |
|
$r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap>"); |
$r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap>"); |
my $metafile = grep /^\Q$filecom[0]\E\.meta\&/, @list; |
my $metafile = grep /^\Q$filecom[0]\E\.meta\&/, @list; |
my $title; |
my $title; |
Line 866 sub display_line {
|
Line 845 sub display_line {
|
".gif border='0' />\n") if $rem > 0; |
".gif border='0' />\n") if $rem > 0; |
} |
} |
|
|
$r->print("<img src=$iconpath$iconname border='0' />\n"); |
$r->print("<img src='$iconname' border='0' />\n"); |
$r->print (" <a href=\"javascript:openWindow('".$filelink. |
$r->print (" <a href=\"javascript:openWindow('".$filelink. |
"', 'previewfile', '450', '500', 'no', 'yes','yes')\";". |
"', 'previewfile', '450', '500', 'no', 'yes','yes')\";". |
" TARGET=_self>$listname</a> "); |
" TARGET=_self>$listname</a> "); |
Line 942 sub display_line {
|
Line 921 sub display_line {
|
|
|
# -- display directory |
# -- display directory |
if ($fnptr == $dirptr) { |
if ($fnptr == $dirptr) { |
my @file_ext = split (/\./,$listname); |
|
my $curfext = $file_ext[scalar(@file_ext)-1]; |
|
my $curdir = $startdir.$filecom[0].'/'; |
my $curdir = $startdir.$filecom[0].'/'; |
my $anchor = $curdir; |
my $anchor = $curdir; |
$anchor =~ s/\///g; |
$anchor =~ s/\///g; |
Line 973 sub display_line {
|
Line 950 sub display_line {
|
$r->print ('<a href="javascript:gothere(\''.$curdir.'\')"><img src="'. |
$r->print ('<a href="javascript:gothere(\''.$curdir.'\')"><img src="'. |
$iconpath.'folder_'.$diropen.'.gif" border="0" /></a>'. |
$iconpath.'folder_'.$diropen.'.gif" border="0" /></a>'. |
"\n"); |
"\n"); |
$r->print ("$listname$tabtag</tr></form>\n"); |
$r->print ("$listname</td>\n"); |
|
# Attributes |
|
my $filelink = $startdir.$filecom[0].'/default'; |
|
|
|
if ($hash{'display_attrs_0'} == 1) { |
|
my $title = &Apache::lonnet::gettitle($filelink,'title'); |
|
$r->print('<td> '.($title eq '' ? ' ' : $title). |
|
' </td>'."\n"); |
|
} |
|
$r->print('<td align=right> ', |
|
$filecom[8]," </td>\n") |
|
if $hash{'display_attrs_1'} == 1; |
|
$r->print('<td> '. |
|
(localtime($filecom[9]))." </td>\n") |
|
if $hash{'display_attrs_2'} == 1; |
|
$r->print('<td> '. |
|
(localtime($filecom[10]))." </td>\n") |
|
if $hash{'display_attrs_3'} == 1; |
|
|
|
if ($hash{'display_attrs_4'} == 1) { |
|
my $author = &Apache::lonnet::metadata($filelink,'author'); |
|
$r->print('<td> '.($author eq '' ? ' ' : $author). |
|
" </td>\n"); |
|
} |
|
if ($hash{'display_attrs_5'} == 1) { |
|
my $keywords = &Apache::lonnet::metadata($filelink,'keywords'); |
|
# $keywords = ' ' if (!$keywords); |
|
$r->print('<td> '.($keywords eq '' ? ' ' : $keywords). |
|
" </td>\n"); |
|
} |
|
if ($hash{'display_attrs_6'} == 1) { |
|
my $lang = &Apache::lonnet::metadata($filelink,'language'); |
|
$lang = &Apache::loncommon::languagedescription($lang); |
|
$r->print('<td> '.($lang eq '' ? ' ' : $lang). |
|
" </td>\n"); |
|
} |
|
if ($hash{'display_attrs_7'} == 1) { |
|
$r->print('<td> </td>'); |
|
} |
|
if ($hash{'display_attrs_8'} == 1) { |
|
$r->print('<td> </td>'); |
|
} |
|
$r->print('</form></tr>'); |
} |
} |
|
|
} |
} |
Line 990 sub begin_form {
|
Line 1009 sub begin_form {
|
'enctype="application/x-www-form-urlencoded">'."\n"); |
'enctype="application/x-www-form-urlencoded">'."\n"); |
$r->print ('<input type="hidden" name="openuri" value="'.$uri.'">'. |
$r->print ('<input type="hidden" name="openuri" value="'.$uri.'">'. |
"\n"); |
"\n"); |
$r->print ('<input type="hidden" name="dirPointer" value="on">'."\n"); |
|
$dnum++; |
$dnum++; |
} |
} |
|
|