version 1.109, 2004/06/12 01:08:11
|
version 1.122, 2004/08/01 19:36:33
|
Line 59 use GDBM_File;
|
Line 59 use GDBM_File;
|
my %hash; # global 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 |
|
my %dynhash; # hash of hashes for dynamic metadata |
|
my %dynread; # hash of directories already read for dynamic metadata |
|
my %fieldnames; # Metadata fieldnames |
# ----- Values which are set by the handler subroutine and are accessible to |
# ----- Values which are set by the handler subroutine and are accessible to |
# ----- other methods. |
# ----- other methods. |
my $extrafield; # default extra table cell |
my $extrafield; # default extra table cell |
Line 86 sub handler {
|
Line 88 sub handler {
|
# these global to this package? It is just so wrong....) |
# these global to this package? It is just so wrong....) |
undef (@Only); |
undef (@Only); |
undef (@Omit); |
undef (@Omit); |
|
%fieldnames=&Apache::lonmeta::fieldnames(); |
|
|
# ------------------------------------- read in machine configuration variables |
# ------------------------------------- read in machine configuration variables |
my $iconpath= $r->dir_config('lonIconsURL') . "/"; |
my $iconpath= $r->dir_config('lonIconsURL') . "/"; |
Line 133 sub handler {
|
Line 136 sub handler {
|
if ($ENV{'form.launch'} eq '2') { |
if ($ENV{'form.launch'} eq '2') { |
$r->content_type('text/html'); |
$r->content_type('text/html'); |
my $extra=''; |
my $extra=''; |
if (defined($ENV{'form.titleelement'})) { |
if (defined($ENV{'form.titleelement'}) && |
|
$ENV{'form.titleelement'} ne '') { |
my $verify_title = &Apache::lonnet::gettitle($ENV{'form.acts'}); |
my $verify_title = &Apache::lonnet::gettitle($ENV{'form.acts'}); |
&Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title"); |
# &Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title"); |
$verify_title=~s/'/\\'/g; |
$verify_title=~s/'/\\'/g; |
$extra='window.opener.document.forms["'.$ENV{'form.form'}.'"].elements["'.$ENV{'form.titleelement'}.'"].value=\''.$verify_title.'\';'; |
$extra='window.opener.document.forms["'.$ENV{'form.form'}.'"].elements["'.$ENV{'form.titleelement'}.'"].value=\''.$verify_title.'\';'; |
} |
} |
Line 407 $r->print(&Apache::loncommon::bodytag('B
|
Line 411 $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'}) { |
if ($ENV{'form.attrs'}) { |
for (my $i=0; $i<=10; $i++) { |
for (my $i=0; $i<=11; $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 415 $r->print(&Apache::loncommon::bodytag('B
|
Line 419 $r->print(&Apache::loncommon::bodytag('B
|
} |
} |
} |
} |
} else { |
} else { |
for (my $i=0; $i<=10; $i++) { |
for (my $i=0; $i<=11; $i++) { |
$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; |
$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; |
} |
} |
} |
} |
Line 434 $r->print(&Apache::loncommon::bodytag('B
|
Line 438 $r->print(&Apache::loncommon::bodytag('B
|
'ln' => 'Language', |
'ln' => 'Language', |
'sa' => 'Source Available', |
'sa' => 'Source Available', |
'sr' => 'Show resource', |
'sr' => 'Show resource', |
|
'li' => 'Linked/Related Resources', |
'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">$Displayfileattributes</font></b><br /> |
<input type="checkbox" name="attr9" value="1" $attrchk[9] onClick="this.form.submit();" /> $lt{'av'} |
<table border=0><tr> |
<table border="0"> |
|
<tr> |
<td><input type="checkbox" name="attr0" value="1" $attrchk[0] onClick="this.form.submit();" /> $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="attr4" value="1" $attrchk[4] onClick="this.form.submit();" /> $lt{'au'}</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] onClick="this.form.submit();" /> $lt{'ln'}</td> |
|
</tr> |
|
<tr> |
<td><input type="checkbox" name="attr1" value="1" $attrchk[1] onClick="this.form.submit();" /> $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] onClick="this.form.submit();" /> $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] onClick="this.form.submit();" /> $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] onClick="this.form.submit();" /> $lt{'st'}</td> |
|
<td><input type="checkbox" name="attr10" value="1" $attrchk[10] onClick="this.form.submit();" /> $lt{'sa'}</td> |
<td><input type="checkbox" name="attr10" value="1" $attrchk[10] onClick="this.form.submit();" /> $lt{'sa'}</td> |
</tr><tr> |
</tr> |
<td><input type="checkbox" name="attr4" value="1" $attrchk[4] onClick="this.form.submit();" /> $lt{'au'}</td> |
<tr> |
<td><input type="checkbox" name="attr5" value="1" $attrchk[5] onClick="this.form.submit();" /> $lt{'kw'}</td> |
<td><input type="checkbox" name="attr8" value="1" $attrchk[8] onClick="this.form.submit();" /> $lt{'st'}</td> |
<td><input type="checkbox" name="attr6" value="1" $attrchk[6] onClick="this.form.submit();" /> $lt{'ln'}</td> |
<td><input type="checkbox" name="attr11" value="1" $attrchk[11] onClick="this.form.submit();" /> $lt{'li'}</td> |
<td><input type="checkbox" name="attr7" value="1" $attrchk[7] onClick="this.form.submit();" /> $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] onClick="this.form.submit();" /> $lt{'av'}</td> |
|
<td> </td> |
<td> </td> |
</tr></table> |
</tr> |
|
</table> |
<input type="hidden" name="attrs" value="1" /> |
<input type="hidden" name="attrs" value="1" /> |
<input type="submit" name="updatedisplay" value="$lt{'ud'}" /> |
<input type="submit" name="updatedisplay" value="$lt{'ud'}" /> |
<input type="hidden" name="acts" value="" /> |
<input type="hidden" name="acts" value="" /> |
Line 509 END
|
Line 518 END
|
if ($hash{'display_attrs_5'} == 1); |
if ($hash{'display_attrs_5'} == 1); |
$r->print("<td><b>".&mt("Language")."</b></td>\n") |
$r->print("<td><b>".&mt("Language")."</b></td>\n") |
if ($hash{'display_attrs_6'} == 1); |
if ($hash{'display_attrs_6'} == 1); |
$r->print("<td><b>".&mt("Resource")."</b></td>\n") |
|
if ($hash{'display_attrs_7'} == 1); |
|
$r->print("<td><b>".&mt("Usage Statistics")." <br />(". |
$r->print("<td><b>".&mt("Usage Statistics")." <br />(". |
&mt("Courses/Network Hits").")</b></td>\n") |
&mt("Courses/Network Hits").")</b> ".&mt('updated periodically')."</td>\n") |
if ($hash{'display_attrs_8'} == 1); |
if ($hash{'display_attrs_8'} == 1); |
$r->print("<td><b>".&mt("Source Available")."</b></td>\n") |
$r->print("<td><b>".&mt("Source Available")."</b></td>\n") |
if ($hash{'display_attrs_10'} == 1); |
if ($hash{'display_attrs_10'} == 1); |
|
$r->print("<td><b>".&mt("Linked/Related Resources")."</b></td>\n") |
|
if ($hash{'display_attrs_11'} == 1); |
|
$r->print("<td><b>".&mt("Resource")."</b></td>\n") |
|
if ($hash{'display_attrs_7'} == 1); |
$r->print('</tr>'); |
$r->print('</tr>'); |
|
|
# ----------------- read in what directories have previously been set to "open" |
# ----------------- read in what directories have previously been set to "open" |
Line 651 sub get_list {
|
Line 662 sub get_list {
|
if ($ENV{'form.updatedisplay'}) { |
if ($ENV{'form.updatedisplay'}) { |
foreach (keys %hash) { |
foreach (keys %hash) { |
delete $hash{$_} if ($_ =~ /^dirlist_files_/); |
delete $hash{$_} if ($_ =~ /^dirlist_files_/); |
|
delete $hash{$_} if ($_ =~ /^dirlist_timestamp_files_/); |
} |
} |
} |
} |
|
|
if ($hash{'dirlist_files_'.$luri}) { |
if (defined($hash{'dirlist_files_'.$luri}) && |
|
$hash{'dirlist_timestamp_files_'.$luri}+600 > (time)) { |
@list = split(/\n/,$hash{'dirlist_files_'.$luri}); |
@list = split(/\n/,$hash{'dirlist_files_'.$luri}); |
} elsif ($uri=~/\.(page|sequence)\/$/) { |
} elsif ($uri=~/\.(page|sequence)\/$/) { |
# is a page or a sequence |
# is a page or a sequence |
Line 670 sub get_list {
|
Line 683 sub get_list {
|
# is really a directory |
# is really a directory |
@list = &Apache::lonnet::dirlist($uri); |
@list = &Apache::lonnet::dirlist($uri); |
$hash{'dirlist_files_'.$luri} = join("\n",@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 { |
|
my $uri=shift; |
|
if (($hash{'display_attrs_8'}==1) || ($hash{'display_attrs_11'}==1)) { |
|
# We don't want the filename |
|
$uri=~s/\/[^\/]+$//; |
|
# Did we already see this? |
|
my $builddir=$uri; |
|
while ($builddir) { |
|
if ($dynread{$builddir}) { |
|
return 0; |
|
} |
|
$builddir=~s/\/[^\/]+$//; |
|
} |
|
# Actually get the data |
|
%dynhash= |
|
(%dynhash,&Apache::lonmeta::get_dynamic_metadata_from_sql($uri)); |
|
# Remember that we got it |
|
$dynread{$uri}=1; |
|
} |
|
} |
|
|
sub initdebug { |
sub initdebug { |
return <<ENDJS; |
return <<ENDJS; |
<script> |
<script> |
Line 790 sub display_line {
|
Line 825 sub display_line {
|
if($filecom[15] ne '1') { return OK if (!&Apache::lonnet::allowed('bre',$pathprefix.$filecom[0])); } |
if($filecom[15] ne '1') { return OK if (!&Apache::lonnet::allowed('bre',$pathprefix.$filecom[0])); } |
|
|
# make absolute links appear on different background |
# make absolute links appear on different background |
if ($absolute) { $fileclr='#aaaa88'; } |
if ($absolute) { $fileclr='#ccdd99'; } |
|
|
# display domain |
# display domain |
if ($filecom[1] eq 'domain') { |
if ($filecom[1] eq 'domain') { |
Line 860 sub display_line {
|
Line 895 sub display_line {
|
} |
} |
# Set the icon for the file |
# Set the icon for the file |
my $iconname = &Apache::loncommon::icon($listname); |
my $iconname = &Apache::loncommon::icon($listname); |
$r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap>"); |
$r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap='1' align='top'>"); |
|
|
my $metafile = $Apache::lonnet::perlvar{'lonDocRoot'}.$pathprefix. |
|
$filecom[0].'.meta'; |
|
if (-e $metafile) { |
|
$metafile=1; |
|
} else { |
|
$metafile=0; |
|
} |
|
if ($ENV{'form.catalogmode'} eq 'interactive') { |
if ($ENV{'form.catalogmode'} eq 'interactive') { |
$r->print("<a href=\"javascript:select_data(\'", |
$r->print("<a href=\"javascript:select_data(\'", |
$filelink,"')\">"); |
$filelink,"')\">"); |
Line 972 sub display_line {
|
Line 1000 sub display_line {
|
$r->print('<td> '.($lang eq '' ? ' ' : $lang). |
$r->print('<td> '.($lang eq '' ? ' ' : $lang). |
" </td>\n"); |
" </td>\n"); |
} |
} |
|
if ($hash{'display_attrs_8'} == 1) { |
|
# statistics |
|
&dynmetaread($filelink); |
|
$r->print("<td>"); |
|
&dynmetaprint($r,$filelink,'count'); |
|
&dynmetaprint($r,$filelink,'course'); |
|
&dynmetaprint($r,$filelink,'stdno'); |
|
&dynmetaprint($r,$filelink,'avetries'); |
|
&dynmetaprint($r,$filelink,'difficulty'); |
|
&dynmetaprint($r,$filelink,'disc'); |
|
&dynmetaprint($r,$filelink,'clear'); |
|
&dynmetaprint($r,$filelink,'technical'); |
|
&dynmetaprint($r,$filelink,'correct'); |
|
&dynmetaprint($r,$filelink,'helpful'); |
|
&dynmetaprint($r,$filelink,'depth'); |
|
$r->print(" </td>\n"); |
|
|
|
} |
|
if ($hash{'display_attrs_10'} == 1) { |
|
my $source = &Apache::lonnet::metadata($filelink,'sourceavail'); |
|
if($source eq 'open') { |
|
my $sourcelink = &Apache::lonsource::make_link($filelink,$listname); |
|
$r->print('<td>'."<a href=\"javascript:openWindow('".$sourcelink. |
|
"', 'previewsource', '700', '700', 'no', 'yes','yes')\";". |
|
" TARGET=_self>Yes</a> "."</td>\n"); |
|
} else { #A cuddled else. :P |
|
$r->print("<td> </td>\n"); |
|
} |
|
} |
|
if ($hash{'display_attrs_11'} == 1) { |
|
# links |
|
&dynmetaread($filelink); |
|
$r->print('<td>'); |
|
&dynmetaprint($r,$filelink,'goto_list'); |
|
&dynmetaprint($r,$filelink,'comefrom_list'); |
|
&dynmetaprint($r,$filelink,'sequsage_list'); |
|
&dynmetaprint($r,$filelink,'dependencies'); |
|
$r->print('</td>'); |
|
} |
if ($hash{'display_attrs_7'} == 1) { |
if ($hash{'display_attrs_7'} == 1) { |
|
# Show resource |
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 1000 sub display_line {
|
Line 1068 sub display_line {
|
$r->print('<td> '.($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); |
|
my $stat = (exists($stat{'course'}) ? $stat{'course'} : ''). |
|
((exists($stat{'course'}) || exists($stat{'count'})) ? '/' : ''). |
|
(exists($stat{'count'}) ? $stat{'count'} : ''); |
|
$r->print('<td align=center> '.($stat eq '' ? ' ' : $stat). |
|
' </td>'."\n"); |
|
} |
|
if ($hash{'display_attrs_10'} == 1) { |
|
my $source = &Apache::lonnet::metadata($filelink,'sourceavail'); |
|
if($source eq 'open') { |
|
my $sourcelink = &Apache::lonsource::make_link($filelink); |
|
$r->print('<td>'."<a href=\"javascript:openWindow('".$sourcelink. |
|
"', 'previewsource', '700', '700', 'no', 'yes','yes')\";". |
|
" TARGET=_self>Yes</a> "."</td>\n"); |
|
} else { #A cuddled else. :P |
|
$r->print('<td>'."</td>\n"); |
|
} |
|
} |
|
$r->print("</tr>\n"); |
$r->print("</tr>\n"); |
} |
} |
|
|
Line 1089 sub display_line {
|
Line 1138 sub display_line {
|
$r->print('<td> '.($lang eq '' ? ' ' : $lang). |
$r->print('<td> '.($lang eq '' ? ' ' : $lang). |
" </td>\n"); |
" </td>\n"); |
} |
} |
if ($hash{'display_attrs_7'} == 1) { |
|
$r->print('<td> </td>'); |
|
} |
|
if ($hash{'display_attrs_8'} == 1) { |
if ($hash{'display_attrs_8'} == 1) { |
$r->print('<td> </td>'); |
$r->print('<td> </td>'); |
} |
} |
if ($hash{'display_attrs_10'} == 1) { |
if ($hash{'display_attrs_10'} == 1) { |
|
$r->print('<td> </td>'); |
|
} |
|
if ($hash{'display_attrs_11'} == 1) { |
$r->print('<td> </td>'); |
$r->print('<td> </td>'); |
} |
} |
|
if ($hash{'display_attrs_7'} == 1) { |
|
$r->print('<td> </td>'); |
|
} |
$r->print('</form></tr>'); |
$r->print('</form></tr>'); |
} |
} |
|
|
} |
} |
|
|
|
sub dynmetaprint { |
|
my ($r,$filelink,$item)=@_; |
|
if ($dynhash{$filelink}->{$item}) { |
|
$r->print("\n<br />".$fieldnames{$item}.': '. |
|
&Apache::lonmeta::prettyprint($item, |
|
$dynhash{$filelink}->{$item}, |
|
(($ENV{'form.catalogmode'} ne 'groupimport')?'preview':''), |
|
'', |
|
(($ENV{'form.catalogmode'} eq 'groupimport')?'document.forms.fileattr':''),1)); |
|
} |
|
} |
|
|
# ------------------- prints the beginning of a form for directory or file link |
# ------------------- prints the beginning of a form for directory or file link |
sub begin_form { |
sub begin_form { |
my ($r,$uri) = @_; |
my ($r,$uri) = @_; |