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

1.1       tyszkabe    1: #
1.2       tyszkabe    2: # This will take annotations and then plug them into a page.
1.1       tyszkabe    3: #
1.2       tyszkabe    4: # 08/25/00 Ben Tyszka
1.13    ! www         5: # 11/02/00 Gerd Kortemeyer
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;
1.2       tyszkabe   14: use Apache::Constants qw(:common);
1.8       tyszkabe   15: use Apache::lonnet();
1.1       tyszkabe   16: 
1.4       tyszkabe   17: # --------------------------------------------------------------Put bookmarks
1.1       tyszkabe   18: 
1.4       tyszkabe   19: sub write_bookmarks {
1.3       tyszkabe   20:     my $marks=shift;
1.13    ! www        21:     Apache::lonnet::put("nohist_bookmarks",('bookmarks' => $marks));
1.2       tyszkabe   22:     return;
1.1       tyszkabe   23: }
                     24: 
1.4       tyszkabe   25: # --------------------------------------------------------------Get bookmarks
1.2       tyszkabe   26: 
1.4       tyszkabe   27: sub get_bookmarks {
1.13    ! www        28:     my %bookmark=Apache::lonnet::get('nohist_bookmarks',('bookmarks'));
1.5       tyszkabe   29:     return %bookmark;
1.2       tyszkabe   30: }
                     31: 
1.4       tyszkabe   32: # ---------------------------------------------------Construct bookmark editor
1.2       tyszkabe   33: 
                     34: sub construct_editor {
1.9       tyszkabe   35:     my $bookmarks=shift;
1.2       tyszkabe   36:     return(<<END_HTML) 
1.4       tyszkabe   37: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
                     38: <html>
                     39: <head>
                     40: <title>
1.8       tyszkabe   41: Bookmark Tree Viewer/Editor
1.4       tyszkabe   42: </title>
                     43: <script LANGUAGE="JavaScript">
                     44: var addressCache = "";
                     45: var dragCache = "";
                     46: var lastDrug = "";
                     47: var lastIcon = "";
                     48: var image_num=0;
1.6       tyszkabe   49: var saveVar="";
1.4       tyszkabe   50: 
                     51: function buildUserTree() {
                     52: this.dropCache = "";
                     53: this.dragCache = "";
1.13    ! www        54: //-----------------------------------------------------------------------------
1.9       tyszkabe   55: //                         The FOLLOWING data is supplied by the Perl Module
1.13    ! www        56: //-----------------------------------------------------------------------------
1.9       tyszkabe   57: $bookmarks
1.13    ! www        58: //-----------------------------------------------------------------------------
1.9       tyszkabe   59: //                         The PRECEDING data is supplied by the Perl Module
1.13    ! www        60: //-----------------------------------------------------------------------------
1.4       tyszkabe   61: }
                     62: </script>
1.13    ! www        63: <script src="/res/adm/includes/bookmarklib.js" language="JavaScript"></script>
1.8       tyszkabe   64: <script language="JavaScript">
                     65:        bookmarkpal = new buildUserTree();
                     66: </script>
1.4       tyszkabe   67: </head>
1.11      tyszkabe   68: <FRAMESET rows="25, *, 40, 25" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 frameborder="0" border="0" framespacing="0" onLoad="Javascript:initializeTree();">
1.4       tyszkabe   69:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5       tyszkabe   70:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ul.html" marginwidth="0" marginheight="0" scrolling="no">
                     71:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_uu.html" marginwidth="0" marginheight="0" scrolling="no">
                     72:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ur.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   73:  </FRAMESET>
                     74:  <FRAMESET name="contentb" cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5       tyszkabe   75:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_left.html" marginwidth="0" marginheight="0" scrolling="no">
1.7       tyszkabe   76:   <FRAME name="content" src="/res/adm/pages/bookmarkmenu/loading_bookmarks.html" marginwidth="0" marginheight="0" scrolling="yes">
1.5       tyszkabe   77:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_right.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   78:  </FRAMESET>
                     79:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5       tyszkabe   80:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_left.html" marginwidth="0" marginheight="0" scrolling="no">
                     81:   <FRAME name="toolbar" src="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" marginwidth="0" marginheight="0" scrolling="no">
                     82:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_right.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   83:  </FRAMESET>
                     84:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5       tyszkabe   85:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ll.html" marginwidth="0" marginheight="0" scrolling="no">
                     86:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_bb.html" marginwidth="0" marginheight="0" scrolling="no">
                     87:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_lr.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   88:  </FRAMESET>
                     89: </FRAMESET>
                     90: </html>
1.2       tyszkabe   91: END_HTML
1.1       tyszkabe   92: }
                     93: 
1.13    ! www        94: # -------------------------------------------------------Construct Error window
1.5       tyszkabe   95: 
                     96: sub construct_error {
                     97:   my $error_message=shift;
                     98:   return(<<END_ERROR)
                     99: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
                    100: <html>
                    101:  <head>
                    102:   <title>
                    103:    Bookmark Tree Viewer/Editor  V3
                    104:   </title>
                    105:  </head>
                    106:  <body bgcolor="#BBBBBB">
                    107:   <table bgcolor="#FFFFFF" width="100%" height="90%" align="center">
                    108:    <td>
                    109:     <i>
                    110:      $error_message
                    111:     </i>
                    112:    </td>
                    113:   </table>
                    114:   <center>
                    115:    <form>
                    116:     <input type=button name="close" value="close window" onClick="javascript:window.close();">
                    117:    </form>
                    118:   </center>
                    119:  </body>
                    120: </html>
                    121: END_ERROR
                    122: }
                    123: 
1.13    ! www       124: # ---------------------------------------------Construct toolbar (after saving)
1.6       tyszkabe  125: 
                    126: sub construct_toolbar {
                    127:   return(<<END_TOOLBAR)
                    128: <html>
                    129: <body>
1.7       tyszkabe  130: <div align="bottom">
                    131: <center>
                    132: Bookmarks saved. 
                    133: [ <a href="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" target="toolbar">Continue</a> ]
                    134: </center>
                    135: </div>
1.6       tyszkabe  136: </body>
                    137: </html>
                    138: END_TOOLBAR
                    139: }
                    140: 
1.13    ! www       141: # -----------------------------------------------------------------Main Handler
1.1       tyszkabe  142: 
                    143: sub handler {
1.6       tyszkabe  144:   my $r=shift;
                    145:   my %marks;
                    146:   my $save_mark;
                    147:   my $page;
                    148:   $r->content_type('text/html');
                    149:   $r->send_http_header;
1.9       tyszkabe  150:   if (exists($ENV{'form.hiddenbookmarks'})) {
                    151:       $marks{'bookmarks'}=$ENV{'form.hiddenbookmarks'};
                    152:       write_bookmarks($marks{'bookmarks'});
                    153:       if ($marks{'bookmarks'} eq 'recover') {    #if statement is all debug stuff
1.10      tyszkabe  154: 	  my $recover=defaultmarks();
1.9       tyszkabe  155: 	  $r->print("BOOKMARK RECOVERY");
                    156: 	  write_bookmarks($recover);
                    157:       }
                    158:       $page=construct_toolbar();
1.6       tyszkabe  159:   } else {
1.9       tyszkabe  160:       %marks=get_bookmarks();
                    161:       if (exists($marks{"con_lost"})) {
                    162: 	  $page=construct_error("Connection broken with home server. Please contact your system administrator");
                    163:       } else {
1.10      tyszkabe  164: 	  if ($marks{'bookmarks'} eq "") {
                    165: 	      $marks{'bookmarks'}=defaultmarks();
                    166: 	  }
1.9       tyszkabe  167: 	  $page = construct_editor($marks{'bookmarks'});
                    168:       }
1.6       tyszkabe  169:   }
                    170:   $r->print($page);
                    171:   return OK;
1.1       tyszkabe  172: }
1.9       tyszkabe  173: 
                    174: ####################################
                    175: #
1.12      tyszkabe  176: #          Here is a listing of default bookmarks. They have replaced 'recover'
                    177: #          These will load after all bookmarks have been deleted.
1.10      tyszkabe  178: #                ben 10/12/2000
                    179: sub defaultmarks {
                    180:     return(<<END_MARKS);
                    181: this.bookmarks=new addFolder("Stuff",6,"bookmarks");
                    182: this.bookmarks.p[0]=new addFolder("Default Bookmarks",6,"bookmarks.p[0]");
                    183: this.bookmarks.p[0].p[0]=new addFolder("Michigan State University",6,"bookmarks.p[0].p[0]");
                    184: this.bookmarks.p[0].p[0].p[0]= new addLink("Main Website","http://www.msu.edu","bookmarks.p[0].p[0]",0);
                    185: this.bookmarks.p[0].p[0].p[1]= new addLink("College of Natural Science","http://www.ns.msu.edu","bookmarks.p[0].p[0]",1);
                    186: this.bookmarks.p[0].p[0].p[2]= new addLink("College of Engineering","http://www.egr.msu.edu","bookmarks.p[0].p[0]",2);
                    187: this.bookmarks.p[0].p[0].p[3]= new addLink("Dept. of Mathematics","http://www.math.msu.edu","bookmarks.p[0].p[0]",3);
                    188: this.bookmarks.p[0].p[0].p[4]= new addLink("Lite Lab","http://www.lite.msu.edu","bookmarks.p[0].p[0]",4);
                    189: this.bookmarks.p[0].p[0].p[5]= new addLink("Physics and Astronomy","http://www.pa.msu.edu","bookmarks.p[0].p[0]",5);
                    190: this.bookmarks.p[0].p[1]= new addFolder("Lon-Capa",6,"bookmarks.p[0].p[1]");
                    191: this.bookmarks.p[0].p[1].p[0]= new addLink("Lon-Capa org","http://lon-capa.org","bookmarks.p[0].p[1]",0);
                    192: this.bookmarks.p[0].p[1].p[1]= new addLink("Lite Lab","http://www.lite.msu.edu","bookmarks.p[0].p[1]",1);
                    193: this.bookmarks.p[0].p[2]= new addLink("Redhat","http://redhat.com","bookmarks.p[0]",2);
                    194: this.bookmarks.p[0].p[3]= new addLink("Debian","http://debian.org","bookmarks.p[0]",3);
                    195: this.bookmarks.p[1]= new addLink("Other Bookmarks","http://kirk.lite.msu.edu","bookmarks",1);
                    196: END_MARKS
                    197: }
1.1       tyszkabe  198: 
                    199: 1;
                    200: __END__
1.8       tyszkabe  201: 
                    202: 
                    203: 
                    204: 
                    205: 

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