Annotation of loncom/html/res/adm/pages/annotator/admannotations.pm, revision 1.1

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: 
        !            11: package Apache::admannotation;
        !            12: 
        !            13: use strict;
        !            14: use CGI qw(:all);
        !            15: use Apache::Constants qw(:common);
        !            16: use Apache::lonnet;
        !            17: 
        !            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
        !            39: 
        !            40: sub write_annotation {
        !            41:     my $url_old=shift;
        !            42:     my $annotation=shift;
        !            43:     put("annotations",($url_old,$annotation));
        !            44:     return;
        !            45: }
        !            46: 
        !            47: # --------------------------------------------------------------Get annotation
        !            48: 
        !            49: sub get_annotation {
        !            50:     my $url_new=shift;
        !            51:     my $annotation=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/annotate" method=post>
        !            89:     <TEXTAREA NAME="annotation" WRAP=ON ROWS=12 COLS=36>$annotation</TEXTAREA><BR>
        !            90:     <INPUT TYPE=Reset value="Reset">
        !            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="Update">
        !            94:  </FORM>
        !            95: </BODY>
        !            96: </HTML>
        !            97: 
        !            98: END_HTML
        !            99: }
        !           100: 
        !           101: # ----------------------------------------------------------------Main Handler
        !           102: 
        !           103: sub handler {
        !           104:     my $r=shift;
        !           105:     my $url_old;
        !           106:     my $annotation;
        !           107:     $r->content_type('text/html');
        !           108:     $r->send_http_header;
        !           109:     if ($url_old=param("url_old")) {
        !           110:          $annotation=param("annotation");
        !           111:          write_annotation($url_old,$annotation);
        !           112:     }
        !           113:     if (my $url_new=param("url_new")) {
        !           114:          unless ($url_old eq $url_new) {
        !           115:               $annotation=get_annotation($url_new);
        !           116: 	 }
        !           117: 	 my $page = construct_editor($url_new,$annotation);
        !           118: 	 $r->print($page);
        !           119:     }
        !           120:     return OK;
        !           121: }
        !           122: 
        !           123: 1;
        !           124: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>