version 1.103, 2004/05/10 08:34:50
|
version 1.109, 2004/06/12 01:08:11
|
Line 52 use Apache::Constants qw(:common);
|
Line 52 use Apache::Constants qw(:common);
|
use Apache::lonmeta; |
use Apache::lonmeta; |
use Apache::File; |
use Apache::File; |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::lonsource(); |
use GDBM_File; |
use GDBM_File; |
|
|
# ---------------------------------------- variables used throughout the module |
# ---------------------------------------- variables used throughout the module |
Line 127 sub handler {
|
Line 128 sub handler {
|
{ |
{ |
if ($ENV{'form.launch'} eq '1') { |
if ($ENV{'form.launch'} eq '1') { |
&start_fresh_session(); |
&start_fresh_session(); |
} |
} |
|
#Hijack lonindexer to verify a title and be close down. |
|
if ($ENV{'form.launch'} eq '2') { |
|
$r->content_type('text/html'); |
|
my $extra=''; |
|
if (defined($ENV{'form.titleelement'})) { |
|
my $verify_title = &Apache::lonnet::gettitle($ENV{'form.acts'}); |
|
&Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title"); |
|
$verify_title=~s/'/\\'/g; |
|
$extra='window.opener.document.forms["'.$ENV{'form.form'}.'"].elements["'.$ENV{'form.titleelement'}.'"].value=\''.$verify_title.'\';'; |
|
} |
|
$r->print(<<ENDSUBM); |
|
<html> |
|
<script type="text/javascript"> |
|
function load() { |
|
window.opener.document.forms["$ENV{'form.form'}"].elements["$ENV{'form.element'}"].value='$ENV{'form.acts'}'; |
|
$extra |
|
window.close(); |
|
} |
|
</script> |
|
<body onLoad=load();> |
|
</body> |
|
</html> |
|
ENDSUBM |
|
return OK; |
|
} |
|
|
# -------------------- refresh environment with user database values (in %hash) |
# -------------------- refresh environment with user database values (in %hash) |
&setvalues(\%hash,'form.catalogmode',\%ENV,'form.catalogmode' ); |
&setvalues(\%hash,'form.catalogmode',\%ENV,'form.catalogmode' ); |
|
|
Line 207 END
|
Line 234 END
|
$location .= "mode=".$mode."&"; |
$location .= "mode=".$mode."&"; |
$location .= "acts="; |
$location .= "acts="; |
$catalogmodefunctions=<<"END"; |
$catalogmodefunctions=<<"END"; |
function select_data(title,url) { |
function select_data(url) { |
changeTitle(title); |
|
changeURL(url); |
changeURL(url); |
self.close(); |
self.close(); |
} |
} |
function select_group() { |
function select_group() { |
window.location="$location"+document.forms.fileattr.acts.value; |
window.location="$location"+document.forms.fileattr.acts.value; |
} |
} |
function changeTitle(val) { |
|
if (opener.inf) { |
|
if (opener.inf.document.forms.resinfo.elements.t) { |
|
opener.inf.document.forms.resinfo.elements.t.value=val; |
|
} |
|
} |
|
} |
|
function changeURL(val) { |
function changeURL(val) { |
if (opener.inf) { |
if (opener.inf) { |
if (opener.inf.document.forms.resinfo.elements.u) { |
if (opener.inf.document.forms.resinfo.elements.u) { |
Line 235 END
|
Line 254 END
|
$location .= "form=$form&element=$element&mode=edit&acts="; |
$location .= "form=$form&element=$element&mode=edit&acts="; |
$catalogmodefunctions=<<END; |
$catalogmodefunctions=<<END; |
// mode = $mode |
// mode = $mode |
function select_data(title,url) { |
function select_data(url) { |
changeURL(url); |
var location = "/res/?launch=2&form=$form&element=$element&titleelement=$titleelement&acts=" + url; |
changeTitle(title); |
window.location=location; |
self.close(); |
|
} |
} |
|
|
function select_group() { |
function select_group() { |
window.location="$location"+document.forms.fileattr.acts.value; |
window.location="$location"+document.forms.fileattr.acts.value; |
} |
} |
Line 271 END
|
Line 288 END
|
$location .= "form=$form&element=$element&mode=parmset&acts="; |
$location .= "form=$form&element=$element&mode=parmset&acts="; |
$catalogmodefunctions=<<END; |
$catalogmodefunctions=<<END; |
// mode = $mode |
// mode = $mode |
function select_data(title,url) { |
function select_data(url) { |
changeURL(url); |
changeURL(url); |
self.close(); |
self.close(); |
} |
} |
Line 390 $r->print(&Apache::loncommon::bodytag('B
|
Line 407 $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<=9; $i++) { |
for (my $i=0; $i<=10; $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 398 $r->print(&Apache::loncommon::bodytag('B
|
Line 415 $r->print(&Apache::loncommon::bodytag('B
|
} |
} |
} |
} |
} else { |
} else { |
for (my $i=0; $i<=9; $i++) { |
for (my $i=0; $i<=10; $i++) { |
$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; |
$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; |
} |
} |
} |
} |
Line 415 $r->print(&Apache::loncommon::bodytag('B
|
Line 432 $r->print(&Apache::loncommon::bodytag('B
|
'au' => 'Author', |
'au' => 'Author', |
'kw' => 'Keywords', |
'kw' => 'Keywords', |
'ln' => 'Language', |
'ln' => 'Language', |
|
'sa' => 'Source Available', |
'sr' => 'Show resource', |
'sr' => 'Show resource', |
'av' => 'All versions', |
'av' => 'All versions', |
'ud' => 'Update Display' |
'ud' => 'Update Display' |
Line 430 $r->print(&Apache::loncommon::bodytag('B
|
Line 448 $r->print(&Apache::loncommon::bodytag('B
|
<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="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> |
</tr><tr> |
</tr><tr> |
<td><input type="checkbox" name="attr4" value="1" $attrchk[4] onClick="this.form.submit();" /> $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] onClick="this.form.submit();" /> $lt{'kw'}</td> |
<td><input type="checkbox" name="attr5" value="1" $attrchk[5] onClick="this.form.submit();" /> $lt{'kw'}</td> |
Line 495 END
|
Line 514 END
|
$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></td>\n") |
if ($hash{'display_attrs_8'} == 1); |
if ($hash{'display_attrs_8'} == 1); |
|
$r->print("<td><b>".&mt("Source Available")."</b></td>\n") |
|
if ($hash{'display_attrs_10'} == 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 713 sub display_line {
|
Line 734 sub display_line {
|
# or absolute paths (for example, from sequences) |
# or absolute paths (for example, from sequences) |
my $absolute; |
my $absolute; |
my $pathprefix; |
my $pathprefix; |
if ($line=~/^\/res\//) { |
if ($line=~m|^/res/| && $startdir ne '') { |
$absolute=1; |
$absolute=1; |
$pathprefix=''; |
$pathprefix=''; |
} else { |
} else { |
Line 733 sub display_line {
|
Line 754 sub display_line {
|
|
|
my $tabtag='</td>'; |
my $tabtag='</td>'; |
my $i=0; |
my $i=0; |
while ($i<=8) { |
while ($i<=11) { |
$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'); |
my $valign = ($hash{'display_attrs_7'} == 1 ? 'top' : 'bottom'); |
|
|
# display uplink arrow |
# display uplink arrow |
Line 841 sub display_line {
|
Line 861 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>"); |
my $metafile = grep /^\Q$filecom[0]\E\.meta\&/, @list; |
|
# my $metafile=1; |
my $metafile = $Apache::lonnet::perlvar{'lonDocRoot'}.$pathprefix. |
my $title; |
$filecom[0].'.meta'; |
|
if (-e $metafile) { |
|
$metafile=1; |
|
} else { |
|
$metafile=0; |
|
} |
if ($ENV{'form.catalogmode'} eq 'interactive') { |
if ($ENV{'form.catalogmode'} eq 'interactive') { |
$title=$listname; |
|
$title = &Apache::lonnet::metadata($filelink,'title') |
|
if ($metafile == 1); |
|
$title=$listname unless $title; |
|
my $titleesc=HTML::Entities::encode($title,'<>&"'); |
|
$titleesc=~s/\'/\\'/; #' (clean up this spare quote) |
|
$r->print("<a href=\"javascript:select_data(\'", |
$r->print("<a href=\"javascript:select_data(\'", |
$titleesc,"','",$filelink,"')\">"); |
$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 nowrap>"); |
$r->print("</td><td nowrap>"); |
} elsif ($ENV{'form.catalogmode'} eq 'groupimport') { |
} elsif ($ENV{'form.catalogmode'} eq 'groupimport') { |
$title=$listname; |
|
$title = &Apache::lonnet::metadata($filelink,'title') |
|
if ($metafile == 1); |
|
$title=$listname unless $title; |
|
my $titleesc=&HTML::Entities::encode($title,'<>&"'); |
|
$r->print("<form name='form$fnum'>\n"); |
$r->print("<form name='form$fnum'>\n"); |
$r->print("<input type='checkbox' name='filelink"."' ". |
$r->print("<input type='checkbox' name='filelink"."' ". |
"value='$filelink' onClick='". |
"value='$filelink' onClick='". |
Line 870 sub display_line {
|
Line 884 sub display_line {
|
$r->print("checked"); |
$r->print("checked"); |
} |
} |
$r->print(">\n"); |
$r->print(">\n"); |
$r->print("<input type='hidden' name='title"."' ". |
|
"value='$titleesc'>\n"); |
|
$r->print("</form>\n"); |
$r->print("</form>\n"); |
$r->print("</td><td nowrap>"); |
$r->print("</td><td nowrap>"); |
$hash{"pre_${fnum}_link"}=$filelink; |
$hash{"pre_${fnum}_link"}=$filelink; |
$hash{"pre_${fnum}_title"}=$titleesc; |
|
$fnum++; |
$fnum++; |
} |
} |
# Form to open or close sequences |
# Form to open or close sequences |
Line 925 sub display_line {
|
Line 936 sub display_line {
|
|
|
$r->print (" (<a href=\"javascript:openWindow('".$filelink. |
$r->print (" (<a href=\"javascript:openWindow('".$filelink. |
".meta', 'metadatafile', '500', '550', 'no', 'yes','no')\"; ". |
".meta', 'metadatafile', '500', '550', 'no', 'yes','no')\"; ". |
"TARGET=_self>metadata</a>) ") if ($metafile == 1); |
"TARGET=_self>metadata</a>) "); |
|
|
$r->print("</td>\n"); |
$r->print("</td>\n"); |
if ($hash{'display_attrs_0'} == 1) { |
if ($hash{'display_attrs_0'} == 1) { |
my $title = &Apache::lonnet::gettitle($filelink,'title') |
my $title = &Apache::lonnet::gettitle($filelink,'title'); |
if ($metafile == 1); |
|
$r->print('<td> '.($title eq '' ? ' ' : $title). |
$r->print('<td> '.($title eq '' ? ' ' : $title). |
' </td>'."\n"); |
' </td>'."\n"); |
} |
} |
Line 945 sub display_line {
|
Line 954 sub display_line {
|
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); |
|
$r->print('<td> '.($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); |
|
# $keywords = ' ' if (!$keywords); |
# $keywords = ' ' if (!$keywords); |
$r->print('<td> '.($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); |
|
$lang = &Apache::loncommon::languagedescription($lang); |
$lang = &Apache::loncommon::languagedescription($lang); |
$r->print('<td> '.($lang eq '' ? ' ' : $lang). |
$r->print('<td> '.($lang eq '' ? ' ' : $lang). |
" </td>\n"); |
" </td>\n"); |
Line 993 sub display_line {
|
Line 1001 sub display_line {
|
" </td>\n"); |
" </td>\n"); |
} |
} |
if ($hash{'display_attrs_8'} == 1) { |
if ($hash{'display_attrs_8'} == 1) { |
my (%stat) = &Apache::lonmeta::dynamicmeta($filelink) if ($metafile == 1); |
my (%stat) = &Apache::lonmeta::dynamicmeta($filelink); |
my $stat = (exists($stat{'course'}) ? $stat{'course'} : ''). |
my $stat = (exists($stat{'course'}) ? $stat{'course'} : ''). |
((exists($stat{'course'}) || exists($stat{'count'})) ? '/' : ''). |
((exists($stat{'course'}) || exists($stat{'count'})) ? '/' : ''). |
(exists($stat{'count'}) ? $stat{'count'} : ''); |
(exists($stat{'count'}) ? $stat{'count'} : ''); |
$r->print('<td align=center> '.($stat eq '' ? ' ' : $stat). |
$r->print('<td align=center> '.($stat eq '' ? ' ' : $stat). |
' </td>'."\n"); |
' </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 1077 sub display_line {
|
Line 1095 sub display_line {
|
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) { |
|
$r->print('<td> </td>'); |
|
} |
$r->print('</form></tr>'); |
$r->print('</form></tr>'); |
} |
} |
|
|