version 1.61, 2003/02/20 19:41:26
|
version 1.70, 2003/07/21 18:35:25
|
Line 62 use strict;
|
Line 62 use strict;
|
use Apache::lonnet(); |
use Apache::lonnet(); |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
|
use Apache::lonmeta; |
use Apache::File; |
use Apache::File; |
use GDBM_File; |
use GDBM_File; |
|
|
Line 84 my @Omit = ();
|
Line 85 my @Omit = ();
|
# ----------------------------- Handling routine called via Apache and mod_perl |
# ----------------------------- Handling routine called via Apache and mod_perl |
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
|
my $c = $r->connection(); |
$r->content_type('text/html'); |
$r->content_type('text/html'); |
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::no_cache($r); |
$r->send_http_header; |
$r->send_http_header; |
return OK if $r->header_only; |
return OK if $r->header_only; |
$fnum=0; |
$fnum=0; |
$dnum=0; |
$dnum=0; |
untie %hash; |
|
|
|
# Deal with stupid global variables (is there a way around making |
# Deal with stupid global variables (is there a way around making |
# these global to this package? It is just so wrong....) |
# these global to this package? It is just so wrong....) |
Line 124 sub handler {
|
Line 125 sub handler {
|
|
|
$extrafield=''; |
$extrafield=''; |
my $diropendb = |
my $diropendb = |
"/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db"; |
"/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_indexer.db"; |
|
%hash = (); |
if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { |
{ |
|
my %dbfile; |
|
if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { |
|
while(my($key,$value)=each(%dbfile)) { |
|
$hash{$key}=$value; |
|
} |
|
untie(%dbfile); |
|
} |
|
} |
|
{ |
if ($ENV{'form.launch'} eq '1') { |
if ($ENV{'form.launch'} eq '1') { |
&start_fresh_session(); |
&start_fresh_session(); |
} |
} |
Line 309 END
|
Line 319 END
|
|
|
<script type="text/javascript"> |
<script type="text/javascript"> |
$catalogmodefunctions |
$catalogmodefunctions |
function openWindow(url, wdwName, w, h, toolbar,scrollbar) { |
function openWindow(url, wdwName, w, h, toolbar,scrollbar,locationbar) { |
var options = "width=" + w + ",height=" + h + ","; |
var options = "width=" + w + ",height=" + h + ","; |
options += "resizable=yes,scrollbars="+scrollbar+",status=no,"; |
options += "resizable=yes,scrollbars="+scrollbar+",status=no,"; |
options += "menubar=no,toolbar="+toolbar+",location=no,directories=no"; |
options += "menubar=no,toolbar="+toolbar+",location="+locationbar+",directories=no"; |
var newWin = window.open(url, wdwName, options); |
var newWin = window.open(url, wdwName, options); |
newWin.focus(); |
newWin.focus(); |
} |
} |
Line 368 $r->print(&Apache::loncommon::bodytag('B
|
Line 378 $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'} ne '') { |
for (my $i=0; $i<=8; $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) { |
$attrchk[$i] = 'checked'; |
$attrchk[$i] = 'checked'; |
Line 376 $r->print(&Apache::loncommon::bodytag('B
|
Line 386 $r->print(&Apache::loncommon::bodytag('B
|
} |
} |
} |
} |
} else { |
} else { |
for (my $i=0; $i<=8; $i++) { |
for (my $i=0; $i<=9; $i++) { |
$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; |
$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; |
} |
} |
} |
} |
Line 390 $r->print(&Apache::loncommon::bodytag('B
|
Line 400 $r->print(&Apache::loncommon::bodytag('B
|
<td><input type="checkbox" name="attr1" value="1" $attrchk[1] /> Size</td> |
<td><input type="checkbox" name="attr1" value="1" $attrchk[1] /> Size</td> |
<td><input type="checkbox" name="attr2" value="1" $attrchk[2] /> Last access</td> |
<td><input type="checkbox" name="attr2" value="1" $attrchk[2] /> Last access</td> |
<td><input type="checkbox" name="attr3" value="1" $attrchk[3] /> Last modified</td> |
<td><input type="checkbox" name="attr3" value="1" $attrchk[3] /> Last modified</td> |
<td rowspan="2"><input type="checkbox" name="attr8" value="1" $attrchk[8] /> Show Resource</td></tr><tr> |
<td><input type="checkbox" name="attr8" value="1" $attrchk[8] /> Statistics</td></tr><tr> |
<td><input type="checkbox" name="attr4" value="1" $attrchk[4] /> Author</td> |
<td><input type="checkbox" name="attr4" value="1" $attrchk[4] /> Author</td> |
<td><input type="checkbox" name="attr5" value="1" $attrchk[5] /> Keywords</td> |
<td><input type="checkbox" name="attr5" value="1" $attrchk[5] /> Keywords</td> |
<td><input type="checkbox" name="attr6" value="1" $attrchk[6] /> Language</td> |
<td><input type="checkbox" name="attr6" value="1" $attrchk[6] /> Language</td> |
<td><input type="checkbox" name="attr7" value="1" $attrchk[7] /> All versions</td> |
<td><input type="checkbox" name="attr7" value="1" $attrchk[7] /> Show Resource</td> |
|
<td><input type="checkbox" name="attr9" value="1" $attrchk[9] /> All versions</td> |
|
<td> </td> |
</tr></table> |
</tr></table> |
<input type="hidden" name="dirPointer" value="on" /> |
<input type="hidden" name="dirPointer" value="on" /> |
<input type="hidden" name="acts" value="" /> |
<input type="hidden" name="acts" value="" /> |
Line 428 END
|
Line 440 END
|
$r->print("<td><b>Language</b></td>\n") |
$r->print("<td><b>Language</b></td>\n") |
if ($hash{'display_attrs_6'} == 1); |
if ($hash{'display_attrs_6'} == 1); |
$r->print("<td><b>Resource</b></td>\n") |
$r->print("<td><b>Resource</b></td>\n") |
|
if ($hash{'display_attrs_7'} == 1); |
|
$r->print("<td><b>Usage Statistics <br />(Courses/Network Hits)</b></td>\n") |
if ($hash{'display_attrs_8'} == 1); |
if ($hash{'display_attrs_8'} == 1); |
$r->print('</tr>'); |
$r->print('</tr>'); |
|
|
Line 492 END
|
Line 506 END
|
|
|
# --------------------------------------------------- end the output and return |
# --------------------------------------------------- end the output and return |
$r->print('</body></html>'."\n"); |
$r->print('</body></html>'."\n"); |
untie(%hash); |
# } else { |
} else { |
# $r->print('<html><head></head><body>Unable to tie hash to db '. |
$r->print('<html><head></head><body>Unable to tie hash to db '. |
# 'file</body></html>'); |
'file</body></html>'); |
# return OK; |
return OK; |
} |
|
if(! $c->aborted()) { |
|
my %dbfile; |
|
if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_NEWDB(),0640)) { |
|
while (my($key,$value) = each(%hash)) { |
|
$dbfile{$key}=$value; |
|
} |
|
untie(%dbfile); |
|
} |
} |
} |
|
|
return OK; |
return OK; |
} |
} |
|
|
# ----------------------------------------------- recursive scan of a directory |
# ----------------------------------------------- recursive scan of a directory |
sub scanDir { |
sub scanDir { |
my ($r,$startdir,$indent,$hashref)=@_; |
my ($r,$startdir,$indent,$hashref)=@_; |
|
my $c = $r->connection(); |
my ($compuri,$curdir); |
my ($compuri,$curdir); |
my $dirptr=16384; |
my $dirptr=16384; |
$indent++; |
$indent++; |
Line 511 sub scanDir {
|
Line 535 sub scanDir {
|
my %dupdirs = %dirs; |
my %dupdirs = %dirs; |
my @list=&get_list($r,$startdir); |
my @list=&get_list($r,$startdir); |
foreach my $line (@list) { |
foreach my $line (@list) { |
|
return if ($c->aborted()); |
my ($strip,$dom,undef,$testdir,undef)=split(/\&/,$line,5); |
my ($strip,$dom,undef,$testdir,undef)=split(/\&/,$line,5); |
next if $strip =~ /.*\.meta$/; |
next if $strip =~ /.*\.meta$/; |
my (@fileparts) = split(/\./,$strip); |
my (@fileparts) = split(/\./,$strip); |
if ($hash{'display_attrs_7'} != 1) { |
if ($hash{'display_attrs_9'} != 1) { |
if (scalar(@fileparts) >= 3) { |
if (scalar(@fileparts) >= 3) { |
my $fext = pop @fileparts; |
my $fext = pop @fileparts; |
my $ov = pop @fileparts; |
my $ov = pop @fileparts; |
my $fname = join ('.',@fileparts,$fext); |
my $fname = join ('.',@fileparts,$fext); |
next if (grep /$fname/,@list and $ov =~ /\d+/); |
next if (grep /\Q$fname\E/,@list and $ov =~ /\d+/); |
} |
} |
} |
} |
|
|
Line 638 sub display_line {
|
Line 663 sub display_line {
|
my $tabtag='</td>'; |
my $tabtag='</td>'; |
my $i=0; |
my $i=0; |
|
|
while ($i<=6) { |
while ($i<=8) { |
$tabtag=join('',$tabtag,"<td> </td>") |
$tabtag=join('',$tabtag,"<td> </td>") |
if $hash{'display_attrs_'.$i} == 1; |
if $hash{'display_attrs_'.$i} == 1; |
$i++; |
$i++; |
} |
} |
|
|
|
my $valign = ($hash{'display_attrs_7'} == 1 ? 'top' : 'bottom'); |
|
|
# display uplink arrow |
# display uplink arrow |
if ($filecom[1] eq 'viewOneUp') { |
if ($filecom[1] eq 'viewOneUp') { |
$r->print("<tr bgcolor=$fileclr>$extrafield"); |
$r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield"); |
$r->print("<td valign=bottom>\n"); |
$r->print("<td>\n"); |
$r->print ('<form method="post" name="dirpathUP" action="'.$startdir. |
$r->print ('<form method="post" name="dirpathUP" action="'.$startdir. |
'/" '. |
'/" '. |
'onSubmit="return rep_dirpath(\'UP\','. |
'onSubmit="return rep_dirpath(\'UP\','. |
Line 663 sub display_line {
|
Line 690 sub display_line {
|
$r->print("Up $tabtag</tr></form>\n"); |
$r->print("Up $tabtag</tr></form>\n"); |
return OK; |
return OK; |
} |
} |
|
# Do we have permission to look at this? |
|
|
|
return OK if (!&Apache::lonnet::allowed('bre',$startdir.$filecom[0])); |
|
|
# display domain |
# display domain |
if ($filecom[1] eq 'domain') { |
if ($filecom[1] eq 'domain') { |
$r->print ('<input type="hidden" name="dirPointer" value="on">'."\n") |
$r->print ('<input type="hidden" name="dirPointer" value="on">'."\n") |
if ($ENV{'form.dirPointer'} eq "on"); |
if ($ENV{'form.dirPointer'} eq "on"); |
$r->print("<tr bgcolor=$fileclr>$extrafield"); |
$r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield"); |
$r->print("<td valign=bottom>"); |
$r->print("<td>"); |
&begin_form ($r,$filecom[0].'/'); |
&begin_form ($r,$filecom[0].'/'); |
my $anchor = $filecom[0].'/'; |
my $anchor = $filecom[0].'/'; |
$anchor =~ s/\///g; |
$anchor =~ s/\///g; |
Line 693 sub display_line {
|
Line 723 sub display_line {
|
# display user directory |
# display user directory |
} |
} |
if ($filecom[1] eq 'user') { |
if ($filecom[1] eq 'user') { |
$r->print("<tr bgcolor=$fileclr>$extrafield"); |
$r->print("<tr valign=$valign bgcolor=$fileclr>$extrafield"); |
$r->print("<td valign=bottom nowrap>\n"); |
$r->print("<td nowrap>\n"); |
my $curdir = $startdir.$filecom[0].'/'; |
my $curdir = $startdir.$filecom[0].'/'; |
my $anchor = $curdir; |
my $anchor = $curdir; |
$anchor =~ s/\///g; |
$anchor =~ s/\///g; |
Line 720 sub display_line {
|
Line 750 sub display_line {
|
# display file |
# display file |
if ($fnptr == 0 and $filecom[3] ne '') { |
if ($fnptr == 0 and $filecom[3] ne '') { |
my $filelink = $startdir.$filecom[0]; |
my $filelink = $startdir.$filecom[0]; |
return OK if (!&Apache::lonnet::allowed('bre',$filelink)); |
|
my @file_ext = split (/\./,$listname); |
my @file_ext = split (/\./,$listname); |
my $curfext = $file_ext[-1]; |
my $curfext = $file_ext[-1]; |
if (@Omit) { |
if (@Omit) { |
Line 738 sub display_line {
|
Line 767 sub display_line {
|
$iconname = $curfext.".gif" unless |
$iconname = $curfext.".gif" unless |
(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn'); |
(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn'); |
# |
# |
$r->print("<tr bgcolor=$fileclr><td nowrap valign='bottom'>"); |
$r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap>"); |
my $metafile = grep /^$filecom[0]\.meta\&/, @list; |
my $metafile = grep /^\Q$filecom[0]\E\.meta\&/, @list; |
my $title; |
my $title; |
if ($ENV{'form.catalogmode'} eq 'interactive') { |
if ($ENV{'form.catalogmode'} eq 'interactive') { |
$title=$listname; |
$title=$listname; |
Line 752 sub display_line {
|
Line 781 sub display_line {
|
$titleesc,"','",$filelink,"')\">"); |
$titleesc,"','",$filelink,"')\">"); |
$r->print("<img src='",$iconpath,"select.gif' border='0' /></a>". |
$r->print("<img src='",$iconpath,"select.gif' border='0' /></a>". |
"\n"); |
"\n"); |
$r->print("</td><td valign='bottom' nowrap>"); |
$r->print("</td><td nowrap>"); |
} |
} |
elsif ($ENV{'form.catalogmode'} eq 'groupimport') { |
elsif ($ENV{'form.catalogmode'} eq 'groupimport') { |
$title=$listname; |
$title=$listname; |
Line 771 sub display_line {
|
Line 800 sub display_line {
|
$r->print("<input type='hidden' name='title"."' ". |
$r->print("<input type='hidden' name='title"."' ". |
"value='$titleesc'>\n"); |
"value='$titleesc'>\n"); |
$r->print("</form>\n"); |
$r->print("</form>\n"); |
$r->print("</td><td valign='bottom' nowrap>"); |
$r->print("</td><td nowrap>"); |
$hash{"pre_${fnum}_link"}=$filelink; |
$hash{"pre_${fnum}_link"}=$filelink; |
$hash{"pre_${fnum}_title"}=$titleesc; |
$hash{"pre_${fnum}_title"}=$titleesc; |
$fnum++; |
$fnum++; |
Line 795 sub display_line {
|
Line 824 sub display_line {
|
|
|
$r->print("<img src=$iconpath$iconname border='0' />\n"); |
$r->print("<img src=$iconpath$iconname border='0' />\n"); |
$r->print (" <a href=\"javascript:openWindow('".$filelink. |
$r->print (" <a href=\"javascript:openWindow('".$filelink. |
"', 'metadatafile', '450', '500', 'no', 'yes')\";". |
"', 'previewfile', '450', '500', 'no', 'yes','yes')\";". |
" TARGET=_self>$listname</a> "); |
" TARGET=_self>$listname</a> "); |
|
|
$r->print (" (<a href=\"javascript:openWindow('".$filelink. |
$r->print (" (<a href=\"javascript:openWindow('".$filelink. |
".meta', 'metadatafile', '400', '450', 'no', 'yes')\"; ". |
".meta', 'metadatafile', '400', '450', 'no', 'yes','no')\"; ". |
"TARGET=_self>metadata</a>) ") if ($metafile == 1); |
"TARGET=_self>metadata</a>) ") if ($metafile == 1); |
|
|
$r->print("</td>\n"); |
$r->print("</td>\n"); |
if ($hash{'display_attrs_0'} == 1) { |
if ($hash{'display_attrs_0'} == 1) { |
my $title = &Apache::lonnet::metadata($filelink,'title') |
my $title = &Apache::lonnet::gettitle($filelink,'title') |
if ($metafile == 1); |
if ($metafile == 1); |
$r->print('<td valign=bottom> '.($title eq '' ? ' ' : $title). |
$r->print('<td> '.($title eq '' ? ' ' : $title). |
' </td>'."\n"); |
' </td>'."\n"); |
} |
} |
$r->print('<td align=right valign=bottom> ', |
$r->print('<td align=right> ', |
$filecom[8]," </td>\n") |
$filecom[8]," </td>\n") |
if $hash{'display_attrs_1'} == 1; |
if $hash{'display_attrs_1'} == 1; |
$r->print('<td valign=bottom> '. |
$r->print('<td> '. |
(localtime($filecom[9]))." </td>\n") |
(localtime($filecom[9]))." </td>\n") |
if $hash{'display_attrs_2'} == 1; |
if $hash{'display_attrs_2'} == 1; |
$r->print('<td valign=bottom> '. |
$r->print('<td> '. |
(localtime($filecom[10]))." </td>\n") |
(localtime($filecom[10]))." </td>\n") |
if $hash{'display_attrs_3'} == 1; |
if $hash{'display_attrs_3'} == 1; |
|
|
if ($hash{'display_attrs_4'} == 1) { |
if ($hash{'display_attrs_4'} == 1) { |
my $author = &Apache::lonnet::metadata($filelink,'author') |
my $author = &Apache::lonnet::metadata($filelink,'author') |
if ($metafile == 1); |
if ($metafile == 1); |
$r->print('<td valign=bottom> '.($author eq '' ? ' ' : $author). |
$r->print('<td> '.($author eq '' ? ' ' : $author). |
" </td>\n"); |
" </td>\n"); |
} |
} |
if ($hash{'display_attrs_5'} == 1) { |
if ($hash{'display_attrs_5'} == 1) { |
my $keywords = &Apache::lonnet::metadata($filelink,'keywords') |
my $keywords = &Apache::lonnet::metadata($filelink,'keywords') |
if ($metafile == 1); |
if ($metafile == 1); |
# $keywords = ' ' if (!$keywords); |
# $keywords = ' ' if (!$keywords); |
$r->print('<td valign=bottom> '.($keywords eq '' ? ' ' : $keywords). |
$r->print('<td> '.($keywords eq '' ? ' ' : $keywords). |
" </td>\n"); |
" </td>\n"); |
} |
} |
if ($hash{'display_attrs_6'} == 1) { |
if ($hash{'display_attrs_6'} == 1) { |
my $lang = &Apache::lonnet::metadata($filelink,'language') |
my $lang = &Apache::lonnet::metadata($filelink,'language') |
if ($metafile == 1); |
if ($metafile == 1); |
$lang = &Apache::loncommon::languagedescription($lang); |
$lang = &Apache::loncommon::languagedescription($lang); |
$r->print('<td valign=bottom> '.($lang eq '' ? ' ' : $lang). |
$r->print('<td> '.($lang eq '' ? ' ' : $lang). |
" </td>\n"); |
" </td>\n"); |
} |
} |
if ($hash{'display_attrs_8'} == 1) { |
if ($hash{'display_attrs_7'} == 1) { |
my $output=''; |
my $output=''; |
my $embstyle=&Apache::loncommon::fileembstyle($curfext); |
my $embstyle=&Apache::loncommon::fileembstyle($curfext); |
if ($embstyle eq 'ssi') { |
if ($embstyle eq 'ssi') { |
Line 852 sub display_line {
|
Line 881 sub display_line {
|
$Apache::lonnet::hostname{&Apache::lonnet::homeserver($2,$1)}. |
$Apache::lonnet::hostname{&Apache::lonnet::homeserver($2,$1)}. |
'/cgi-bin/thumbnail.gif?url='.$filelink.'" />'; |
'/cgi-bin/thumbnail.gif?url='.$filelink.'" />'; |
} |
} |
$r->print('<td valign=bottom> '.($output eq '' ? ' ':$output). |
$r->print('<td> '.($output eq '' ? ' ':$output). |
" </td>\n"); |
" </td>\n"); |
} |
} |
|
if ($hash{'display_attrs_8'} == 1) { |
|
my (%stat) = &Apache::lonmeta::dynamicmeta($filelink) if ($metafile == 1); |
|
my $stat = ($stat{'course'} eq '' ? '' : $stat{'course'}). |
|
(($stat{'course'} ne '' || $stat{'count'} ne '') ? '/' : ''). |
|
($stat{'count'} eq '' ? '' : $stat{'count'}); |
|
$r->print('<td align=center> '.($stat eq '' ? ' ' : $stat). |
|
' </td>'."\n"); |
|
} |
|
|
$r->print("</tr>\n"); |
$r->print("</tr>\n"); |
} |
} |
|
|
Line 865 sub display_line {
|
Line 903 sub display_line {
|
my $curdir = $startdir.$filecom[0].'/'; |
my $curdir = $startdir.$filecom[0].'/'; |
my $anchor = $curdir; |
my $anchor = $curdir; |
$anchor =~ s/\///g; |
$anchor =~ s/\///g; |
$r->print("<tr bgcolor=$fileclr>$extrafield<td valign=bottom>"); |
$r->print("<tr bgcolor=$fileclr>$extrafield<td valign=$valign>"); |
&begin_form ($r,$curdir); |
&begin_form ($r,$curdir); |
my $indentm1 = $indent-1; |
my $indentm1 = $indent-1; |
if ($indentm1 < 11 and $indentm1 > 0) { |
if ($indentm1 < 11 and $indentm1 > 0) { |
Line 943 sub setvalues {
|
Line 981 sub setvalues {
|
sub cleanup { |
sub cleanup { |
if (tied(%hash)){ |
if (tied(%hash)){ |
&Apache::lonnet::logthis('Cleanup indexer: hash'); |
&Apache::lonnet::logthis('Cleanup indexer: hash'); |
unless (untie(%hash)) { |
|
&Apache::lonnet::logthis('Failed cleanup indexer: hash'); |
|
} |
|
} |
} |
} |
} |
|
|