[LON-CAPA-cvs] cvs: loncom /interface lonindexer.pm lonsource.pm
taceyjo1
lon-capa-cvs@mail.lon-capa.org
Sat, 12 Jun 2004 01:08:12 -0000
taceyjo1 Fri Jun 11 21:08:12 2004 EDT
Added files:
/loncom/interface lonsource.pm
Modified files:
/loncom/interface lonindexer.pm
Log:
More of bug #78 you can now view the code and comming soon copy it to a directory in your construction space (which is proving to be slightly
more hard than expected)
Anyway
Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.108 loncom/interface/lonindexer.pm:1.109
--- loncom/interface/lonindexer.pm:1.108 Tue May 18 11:53:58 2004
+++ loncom/interface/lonindexer.pm Fri Jun 11 21:08:11 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Directory Indexer
#
-# $Id: lonindexer.pm,v 1.108 2004/05/18 15:53:58 albertel Exp $
+# $Id: lonindexer.pm,v 1.109 2004/06/12 01:08:11 taceyjo1 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -52,6 +52,7 @@
use Apache::lonmeta;
use Apache::File;
use Apache::lonlocal;
+use Apache::lonsource();
use GDBM_File;
# ---------------------------------------- variables used throughout the module
@@ -406,7 +407,7 @@
# ---------------------------------- get state of file attributes to be showing
if ($ENV{'form.attrs'}) {
- for (my $i=0; $i<=9; $i++) {
+ for (my $i=0; $i<=10; $i++) {
delete $hash{'display_attrs_'.$i};
if ($ENV{'form.attr'.$i} == 1) {
$attrchk[$i] = 'checked';
@@ -414,7 +415,7 @@
}
}
} else {
- for (my $i=0; $i<=9; $i++) {
+ for (my $i=0; $i<=10; $i++) {
$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1;
}
}
@@ -431,6 +432,7 @@
'au' => 'Author',
'kw' => 'Keywords',
'ln' => 'Language',
+ 'sa' => 'Source Available',
'sr' => 'Show resource',
'av' => 'All versions',
'ud' => 'Update Display'
@@ -446,6 +448,7 @@
<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="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>
<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>
@@ -511,6 +514,8 @@
$r->print("<td><b>".&mt("Usage Statistics")." <br />(".
&mt("Courses/Network Hits").")</b></td>\n")
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>');
# ----------------- read in what directories have previously been set to "open"
@@ -749,12 +754,11 @@
my $tabtag='</td>';
my $i=0;
- while ($i<=8) {
+ while ($i<=11) {
$tabtag=join('',$tabtag,"<td> </td>")
if $hash{'display_attrs_'.$i} == 1;
$i++;
}
-
my $valign = ($hash{'display_attrs_7'} == 1 ? 'top' : 'bottom');
# display uplink arrow
@@ -960,6 +964,8 @@
$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);
@@ -1002,7 +1008,17 @@
$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");
}
@@ -1079,6 +1095,9 @@
if ($hash{'display_attrs_8'} == 1) {
$r->print('<td> </td>');
}
+ if ($hash{'display_attrs_10'} == 1) {
+ $r->print('<td> </td>');
+ }
$r->print('</form></tr>');
}
Index: loncom/interface/lonsource.pm
+++ loncom/interface/lonsource.pm
# The LearningOnline Network with CAPA
# Publication Handler
#
# $Id: lonsource.pm,v 1.1 2004/06/12 01:08:11 taceyjo1 Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
###
package Apache::lonsource;
use strict;
use Apache::lonnet();
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonsequence();
use Apache::Constants qw(:common :http);
use Apache::lonmeta;
use Apache::File;
use Apache::lonlocal;
use HTML::Entities;
sub make_link {
my ($filename) = @_;
my $sourcelink = "http://".$ENV{'SERVER_NAME'}."/adm/source/?filename=".$filename;
return $sourcelink;
}
sub stage_2 {
my ($r, $filename) = @_;
$r->print("Comming Soon");
return OK;
}
sub print_item {
my ($r, $filename) = @_;
$filename = "/home/httpd/html".$filename;
my $file_output = &Apache::lonnet::getfile($filename);
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$file_output);
$r->print('<textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'.
&HTML::Entities::encode($file_output,'<>&"').'</textarea>');
return OK;
}
sub handler {
my $r=shift;
if($ENV{'form.action'} eq 'stage2') {
&stage_2($r, $ENV{'form.filename'});
} else {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['filename']);
return FORBIDDEN if !&Apache::lonnet::allowed('cre',$ENV{'form.filename'})
&Apache::loncommon::content_type($r,'text/html');
my $filename = $ENV{'form.filename'};
$r->send_http_header;
$r->print(' <form name="copy" action="/adm/source/" target="_parent" method="post">
<input type="button" value="Close Window" name="close" onClick="window.close()">
<input type="hidden" name="filename" value="'.$filename.'" />
<input type="hidden" name="action" value="stage2" />
<input type="submit" value="Copy to CSTR" />
</form>');
$r->print('<hr />');
&print_item($r, $ENV{'form.filename'});
}
return OK;
}
1;