Annotation of loncom/html/res/adm/pages/bookmarkmenu/admbookmarks.pm, revision 1.5

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.5     ! tyszkabe   11: package Apache::admbookmarks;
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.4       tyszkabe   18: # --------------------------------------------------------------Put bookmarks
1.1       tyszkabe   19: 
1.4       tyszkabe   20: sub write_bookmarks {
1.3       tyszkabe   21:     my $marks=shift;
1.4       tyszkabe   22:     Apache::lonnet::put("bookmarks",('bookmarks' => $marks));
1.2       tyszkabe   23:     return;
1.1       tyszkabe   24: }
                     25: 
1.4       tyszkabe   26: # --------------------------------------------------------------Get bookmarks
1.2       tyszkabe   27: 
1.4       tyszkabe   28: sub get_bookmarks {
1.5     ! tyszkabe   29:     my %bookmark=Apache::lonnet::get('bookmarks',('bookmarks'));
        !            30:     return %bookmark;
1.2       tyszkabe   31: }
                     32: 
1.4       tyszkabe   33: # ---------------------------------------------------Construct bookmark editor
1.2       tyszkabe   34: 
                     35: sub construct_editor {
                     36:     return(<<END_HTML) 
1.4       tyszkabe   37: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
                     38: <html>
                     39: <head>
                     40: <title>
                     41: Bookmark Tree Viewer/Editor  V3
                     42: </title>
                     43: 
                     44: <script LANGUAGE="JavaScript">
                     45: var addressCache = "";
                     46: var dragCache = "";
                     47: var lastDrug = "";
                     48: var lastIcon = "";
                     49: var image_num=0;
                     50: 
                     51: function buildUserTree() {
                     52: this.dropCache = "";
                     53: this.dragCache = "";
                     54: //-------------------------------------------------------------------------------
                     55: // The following is data that is supplied by the Perl Module
                     56: //-------------------------------------------------------------------------------
                     57: this.bookmarks = new addFolder("Stuff", 6, "bookmarks");
                     58: this.bookmarks.p[1]=new addLink("MSU Engine3ering", "http://www.egr.msu.edu", "bookmarks", 1);
                     59: this.bookmarks.p[2]=new addLink("MSU Engine2ering", "http://www.egr.msu.edu/~tyszkabe", "bookmarks", 2);
                     60: this.bookmarks.p[3]=new addFolder("more crap", 5, "bookmarks.p[3]");
                     61: this.bookmarks.p[3].p[1]=new addLink("more of a test","http://www.transam.com","bookmarks.p[3]",1);
                     62: this.bookmarks.p[3].p[2]=new addLink("ALL CAPS PLEASE!","http://www.bullwinkle.com","bookmarks.p[3]",2);
                     63: this.bookmarks.p[3].p[3]=new addFolder("double nested", 2, "bookmarks.p[3].p[3]");
                     64: this.bookmarks.p[3].p[3].p[1]=new addLink("Test 12","http://www.jealousy.com","bookmarks.p[3].p[3]",1);
                     65: this.bookmarks.p[3].p[3].p[2]=new addFolder("empty folder",1,"bookmarks.p[3].p[3].p[2]");
                     66: this.bookmarks.p[3].p[3].p[2].p[1]=new addLink("bury","http://www.cool.com","bookmarks.p[3].p[3].p[2]",1);
                     67: this.bookmarks.p[3].p[4]=new addLink("simon and Garfunkle","www.inneptitude.com","bookmarks.p[3]",4);
                     68: this.bookmarks.p[3].p[5]=new addLink("garbage in garbage out","www.holy.com","bookmarks.p[3]",5);
                     69: this.bookmarks.p[4]=new addLink("MSU Engin4eering","st4uffcom","bookmarks",4);
                     70: this.bookmarks.p[5]=new addFolder("more x2",3,"bookmarks.p[5]");
                     71: this.bookmarks.p[5].p[1]=new addLink("Whack a holy mole","www.whackamole.com","bookmarks.p[5]",1);
                     72: this.bookmarks.p[5].p[2]=new addLink("molly moldy mole","http://www.molemolemole.com","bookmarks.p[5]",2);
                     73: this.bookmarks.p[5].p[3]=new addLink("Thou art even more holy","www.holymoly.com","bookmarks.p[5]",3);
                     74: this.bookmarks.p[6]=new addLink("Google","http://www.google.com/","bookmarks",6);
                     75: }
                     76: </script>
                     77: <script src="/res/adm/pages/bookmarkmenu/bookmarklib.js" lanuage="JavaScript"></script>
                     78: </head>
                     79: <FRAMESET rows="25, *, 30, 25" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 frameborder="0" border="0" framespacing="0" >
                     80:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5     ! tyszkabe   81:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ul.html" marginwidth="0" marginheight="0" scrolling="no">
        !            82:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_uu.html" marginwidth="0" marginheight="0" scrolling="no">
        !            83:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ur.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   84:  </FRAMESET>
                     85:  <FRAMESET name="contentb" cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5     ! tyszkabe   86:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_left.html" marginwidth="0" marginheight="0" scrolling="no">
        !            87:   <FRAME name="content" src="/res/adm/pages/bookmarkmenu/loading_bookmarks.html" marginwidth="0" marginheight="0" scrolling="auto">
        !            88:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_right.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   89:  </FRAMESET>
                     90:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5     ! tyszkabe   91:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_left.html" marginwidth="0" marginheight="0" scrolling="no">
        !            92:   <FRAME name="toolbar" src="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" marginwidth="0" marginheight="0" scrolling="no">
        !            93:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_right.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   94:  </FRAMESET>
                     95:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5     ! tyszkabe   96:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ll.html" marginwidth="0" marginheight="0" scrolling="no">
        !            97:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_bb.html" marginwidth="0" marginheight="0" scrolling="no">
        !            98:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_lr.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   99:  </FRAMESET>
                    100: </FRAMESET>
                    101: </html>
1.2       tyszkabe  102: END_HTML
1.1       tyszkabe  103: }
                    104: 
1.5     ! tyszkabe  105: # ---------------------------------------------------------------Construct Error window
        !           106: 
        !           107: sub construct_error {
        !           108:   my $error_message=shift;
        !           109:   return(<<END_ERROR)
        !           110: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
        !           111: <html>
        !           112:  <head>
        !           113:   <title>
        !           114:    Bookmark Tree Viewer/Editor  V3
        !           115:   </title>
        !           116:  </head>
        !           117:  <body bgcolor="#BBBBBB">
        !           118:   <table bgcolor="#FFFFFF" width="100%" height="90%" align="center">
        !           119:    <td>
        !           120:     <i>
        !           121:      $error_message
        !           122:     </i>
        !           123:    </td>
        !           124:   </table>
        !           125:   <center>
        !           126:    <form>
        !           127:     <input type=button name="close" value="close window" onClick="javascript:window.close();">
        !           128:    </form>
        !           129:   </center>
        !           130:  </body>
        !           131: </html>
        !           132: END_ERROR
        !           133: }
        !           134: 
1.2       tyszkabe  135: # ----------------------------------------------------------------Main Handler
1.1       tyszkabe  136: 
                    137: sub handler {
                    138:     my $r=shift;
1.5     ! tyszkabe  139:     my %marks;
        !           140:     my $save_mark;
        !           141:     my $page;
1.2       tyszkabe  142:     $r->content_type('text/html');
                    143:     $r->send_http_header;
1.3       tyszkabe  144:     if ($save_mark=param("save_mark")) {
1.4       tyszkabe  145:          write_bookmarks($save_mark);
1.1       tyszkabe  146:     }
1.5     ! tyszkabe  147:     %marks=get_bookmarks();
        !           148:     if (exists($marks{"con_lost"})) {
        !           149:       $page = construct_editor($marks{"bookmarks"});  # Delete this line and uncomment next
        !           150:                                                       # in order to re-enable connection detection
        !           151: #      $page=construct_error("Connection broken with home server. Please contact your system administrator");
        !           152:     } else {
        !           153:       $page = construct_editor($marks{"bookmarks"});
1.1       tyszkabe  154:     }
1.5     ! tyszkabe  155:     $r->print($page);
1.1       tyszkabe  156:     return OK;
                    157: }
                    158: 
                    159: 1;
                    160: __END__

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