Annotation of loncom/html/res/adm/pages/bookmarkmenu/admbookmarks.pm, revision 1.2
1.1 tyszkabe 1: #!/usr/bin/perl -T
2: #
1.2 ! tyszkabe 3: # This will take annotations and then plug them into a page.
1.1 tyszkabe 4: #
1.2 ! tyszkabe 5: # 08/25/00 Ben Tyszka
1.1 tyszkabe 6: #
7: #
1.2 ! tyszkabe 8: #
! 9: ##################
1.1 tyszkabe 10:
1.2 ! tyszkabe 11: package Apache::admannotations;
1.1 tyszkabe 12:
13: use strict;
14: use CGI qw(:all);
1.2 ! tyszkabe 15: use Apache::Constants qw(:common);
1.1 tyszkabe 16: use Apache::lonnet;
17:
1.2 ! tyszkabe 18: ##########################
! 19: #
! 20: # The following are fake get and put functions.
! 21: # DELETE the following get and put functions and edit the calls
! 22: # once the module is working.
! 23: #
! 24: #
! 25: #sub get {
! 26: # return "This is a sample annotation/n hopefully it'll look nice on the screen";
! 27: #}
! 28: #
! 29: #sub put {
! 30: # return;
! 31: #}
! 32: #
! 33: #
! 34: # DELETE everything within this comment block
! 35: #
! 36: ##########################
! 37:
! 38: # --------------------------------------------------------------Put annotation
1.1 tyszkabe 39:
1.2 ! tyszkabe 40: sub write_annotation {
! 41: my $url_old=shift;
! 42: my $annotation=shift;
! 43: Apache::lonnet::put("annotations",($url_old => $annotation));
! 44: return;
1.1 tyszkabe 45: }
46:
1.2 ! tyszkabe 47: # --------------------------------------------------------------Get annotation
! 48:
! 49: sub get_annotation {
! 50: my $url_new=shift;
! 51: my $annotation=Apache::lonnet::get("annotations",($url_new));
! 52: return $annotation;
! 53: }
! 54:
! 55: # ------------------------------------------------------------Construct editor
! 56:
! 57: sub construct_editor {
! 58: my $url_new=shift;
! 59: my $annotation=shift;
! 60: return(<<END_HTML)
! 61: <HTML>
! 62: <HEAD>
! 63: <script LANGUAGE="JavaScript">
! 64: <!-- Window open function
! 65: //
! 66: //var anotval = "$annotation";
! 67: //var url_new = "$url_new";
! 68: //
! 69: //clienthost=window.location.host;
! 70: //clientwindow=opener.opener;
! 71: //
! 72: //function windowCheck() {
! 73: // if ( clientwindow.closed ) {
! 74: // clientwindow=window.open("http://"+clienthost+"/");
! 75: // }
! 76: //}
! 77: //
! 78: //function onClose() {
! 79: // windowcheck();
! 80: // clientwindow.window.location.href="http://"+oldnotesurl;
! 81: //}
! 82: //
! 83: //windowCheck();
! 84: //-->
! 85: </script>
! 86: </HEAD>
! 87: <BODY BGCOLOR=\"#BBBBBB\">
! 88: <FORM action="http://kirk.lite.msu.edu/adm/annotations" method=post>
! 89: <TEXTAREA NAME="annotation" WRAP=ON ROWS=12 COLS=36>$annotation</TEXTAREA><BR>
! 90: <INPUT TYPE=Reset value="Undo Changes">
! 91: <INPUT TYPE="hidden" name="url_old" value=opener.clientwindow.location.href>
! 92: <INPUT TYPE="hidden" name="url_new" value=opener.clientwindow.location.href>
! 93: <INPUT TYPE=submit name=submit value="Save">
! 94: <INPUT TYPE=submit name=submit value="Update">
! 95: </FORM>
! 96: </BODY>
! 97: </HTML>
1.1 tyszkabe 98:
1.2 ! tyszkabe 99: END_HTML
1.1 tyszkabe 100: }
101:
1.2 ! tyszkabe 102: # ----------------------------------------------------------------Main Handler
1.1 tyszkabe 103:
104: sub handler {
105: my $r=shift;
1.2 ! tyszkabe 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);
1.1 tyszkabe 113: }
1.2 ! tyszkabe 114: if (my $url_new=param("url_new")) {
! 115: unless ($url_old eq $url_new) {
! 116: $annotation=get_annotation($url_new);
! 117: }
! 118: my $page = construct_editor($url_new,$annotation);
! 119: $r->print($page);
1.1 tyszkabe 120: }
121: return OK;
122: }
123:
124: 1;
125: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>