Annotation of loncom/html/res/adm/pages/annotator/admannotations.pm, revision 1.5
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.5 ! tyszkabe 40: return(<<END_HTML)
1.2 tyszkabe 41: <html>
42: <head>
43: <title>Annotations</title>
1.5 ! tyszkabe 44: <script language="JavaScript">
1.4 tyszkabe 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.5 ! tyszkabe 53: <center>
! 54: <FORM name="annotInfo" method="post" action="http://kirk.lite.msu.edu/adm/annotations" onSubmit="return getDomain();">
1.2 tyszkabe 55: <TEXTAREA NAME="annotation" WRAP=ON ROWS=12 COLS=36>$annot_hash{$url_new}</TEXTAREA><br>
56: <INPUT TYPE="hidden" name="url_old" value="$url_new")>
1.5 ! tyszkabe 57: <INPUT TYPE="hidden" name="url_new" value="">
! 58: <INPUT TYPE=submit name=submit value="Save and Update">
! 59: <INPUT TYPE=button name="close" value="close (no save)" onClick="javascript:window.close();">
! 60: </FORM>
! 61: </center>
1.2 tyszkabe 62: </body>
63: </html>
1.1 tyszkabe 64: END_HTML
65: }
66:
1.5 ! tyszkabe 67: # --------------------------------------------Constructs the can't edit window
! 68:
! 69: sub construct_nonedit {
! 70: return(<<END_HTML2)
! 71: <html><head>
! 72: <title>Annotations</title>
! 73: <script language="JavaScript">
! 74: mainhost=window.opener.opener;
! 75: function getDomain() {
! 76: document.annotInfo.url_new.value=mainhost.location.href;
! 77: return true;
! 78: }
! 79: </script>
! 80: </head>
! 81: <body BGCOLOR=\"#BBBBBB\">
! 82: <center>
! 83: <FORM name="annotInfo" method="post" action="http://kirk.lite.msu.edu/adm/annotations" onSubmit="getDomain();">
! 84: <table bgcolor="#FFFFFF" width="99%" height="80%" align="center">
! 85: <td>
! 86: <i>
! 87: Cannot annotate current window. Please point your browser to a Lon-CAPA page and then 'continue'.
! 88: </i>
! 89: </td>
! 90: </table>
! 91: <INPUT TYPE="hidden" name="url_old" value="")>
! 92: <INPUT TYPE="hidden" name="url_new" value="">
! 93: <INPUT TYPE=submit name=submit value="continue">
! 94: <INPUT TYPE=button name="close" value="close (no save)" onClick="javascript:window.close();">
! 95: </FORM>
! 96: </center>
! 97: </body>
! 98: </html>
! 99: END_HTML2
! 100: }
! 101:
1.1 tyszkabe 102: # ----------------------------------------------------------------Main Handler
103:
104: sub handler {
1.5 ! tyszkabe 105: my $r=shift;
! 106: my $url_old;
! 107: my $annotation;
! 108: $r->content_type('text/html');
! 109: $r->send_http_header;
! 110: if ($url_old=param("url_old")) {
! 111: $annotation=param("annotation");
! 112: write_annotation($url_old,$annotation);
! 113: }
! 114: if (my $url_new=param("url_new")) {
! 115: my %annot_hash;
! 116: if ($url_old eq $url_new) {
! 117: %annot_hash=($url_new => $annotation);
! 118: } else {
! 119: %annot_hash=get_annotation($url_new);
1.1 tyszkabe 120: }
1.5 ! tyszkabe 121: my $page=construct_editor($url_new,%annot_hash);
! 122: $r->print($page);
! 123: } else {
! 124: my $page=construct_nonedit();
! 125: $r->print($page);
! 126: }
! 127: return OK;
1.1 tyszkabe 128: }
129:
130: 1;
131: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>