Annotation of loncom/html/res/adm/pages/annotator/admannotations.pm, revision 1.4
1.1 tyszkabe 1: #!/usr/bin/perl -T
2: #
3: # This will take annotations and then plug them into a page.
4: #
5: # 08/25/00 Ben Tyszka
6: #
7: #
8: #
9: ##################
10:
1.2 tyszkabe 11: package Apache::admannotations;
1.1 tyszkabe 12:
13: use strict;
14: use CGI qw(:all);
15: use Apache::Constants qw(:common);
16: use Apache::lonnet;
17:
18: # --------------------------------------------------------------Put annotation
19:
20: sub write_annotation {
21: my $url_old=shift;
1.4 ! tyszkabe 22: my $annotation=shift;
1.2 tyszkabe 23: Apache::lonnet::put("annotations",($url_old => $annotation));
1.1 tyszkabe 24: return;
25: }
26:
27: # --------------------------------------------------------------Get annotation
28:
29: sub get_annotation {
30: my $url_new=shift;
1.2 tyszkabe 31: my %annotation=Apache::lonnet::get("annotations",($url_new));
32: return %annotation;
1.1 tyszkabe 33: }
34:
35: # ------------------------------------------------------------Construct editor
36:
37: sub construct_editor {
38: my $url_new=shift;
1.2 tyszkabe 39: my %annot_hash=@_;
1.1 tyszkabe 40: return(<<END_HTML)
1.2 tyszkabe 41: <html>
42: <head>
43: <title>Annotations</title>
1.4 ! tyszkabe 44: <script language="JavaScript">
! 45: mainhost=window.opener.opener;
! 46: function getDomain() {
! 47: document.annotInfo.url_new.value=mainhost.location.href;
! 48: return true;
1.2 tyszkabe 49: }
1.1 tyszkabe 50: </script>
1.2 tyszkabe 51: </head>
52: <body BGCOLOR=\"#BBBBBB\">
1.4 ! tyszkabe 53: <FORM name="annotInfo" method="post" action="http://kirk.lite.msu.edu/adm/annotations" onSubmit="getDomain();">
1.2 tyszkabe 54: <TEXTAREA NAME="annotation" WRAP=ON ROWS=12 COLS=36>$annot_hash{$url_new}</TEXTAREA><br>
1.4 ! tyszkabe 55: <!-- <INPUT TYPE=Reset value="Undo Changes"> -->
1.2 tyszkabe 56: <INPUT TYPE="hidden" name="url_old" value="$url_new")>
1.4 ! tyszkabe 57: <INPUT TYPE="hidden" name="url_new">
1.2 tyszkabe 58: <INPUT TYPE=submit name=submit value="Save">
1.1 tyszkabe 59: <INPUT TYPE=submit name=submit value="Update">
60: </FORM>
1.2 tyszkabe 61: </body>
62: </html>
1.1 tyszkabe 63: END_HTML
64: }
65:
66: # ----------------------------------------------------------------Main Handler
67:
68: sub handler {
69: my $r=shift;
70: my $url_old;
71: my $annotation;
72: $r->content_type('text/html');
73: $r->send_http_header;
74: if ($url_old=param("url_old")) {
75: $annotation=param("annotation");
76: write_annotation($url_old,$annotation);
77: }
78: if (my $url_new=param("url_new")) {
1.4 ! tyszkabe 79: my %annot_hash;
1.2 tyszkabe 80: # $r->print("$url_new \n"); #debug line
81: # $r->print($url_old); #debug line
82: # $r->print("<--the url_new <BR>\n"); #debug line
83: # $r->print($annotation); #debug line
84: # $r->print("<--first annotation <BR>\n"); #debug line
85: # Apache::lonnet::put("annotations",($url_new => $annotation)); #debug line
86: # my %annot_hash=Apache::lonnet::get("annotations",($url_new)); #debug line
87: # $r->print( keys(%phony_var)); #debug line
88: # $r->print(" = are the keys<BR>\n"); #debug line
89: # $r->print("$phony_var{$url_new} = $url_new"); #debug line
90: # $r->print("<--test put-get<BR>\n"); #debug line
91: # $r->print($annotation); #debug line
1.4 ! tyszkabe 92: # $r->print("<--annotation<BR>\n"); #debug line
1.3 tyszkabe 93: if ($url_old eq $url_new) {
94: %annot_hash=($url_new => $annotation);
95: } else {
96: %annot_hash=get_annotation($url_new);
97: }
1.2 tyszkabe 98: # $r->print($annotation); #debug line
99: # $r->print("<--annotation again<BR>\n"); #debug line
1.4 ! tyszkabe 100: my $page=construct_editor($url_new,%annot_hash);
! 101: $r->print($page);
! 102: }
1.1 tyszkabe 103: return OK;
104: }
105:
106: 1;
107: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>