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

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

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