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

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.14    ! tyszkabe   54: this.bookmarks=new addFolder("Stuff",6,"bookmarks");
1.13      www        55: //-----------------------------------------------------------------------------
1.9       tyszkabe   56: //                         The FOLLOWING data is supplied by the Perl Module
1.13      www        57: //-----------------------------------------------------------------------------
1.9       tyszkabe   58: $bookmarks
1.13      www        59: //-----------------------------------------------------------------------------
1.9       tyszkabe   60: //                         The PRECEDING data is supplied by the Perl Module
1.13      www        61: //-----------------------------------------------------------------------------
1.4       tyszkabe   62: }
                     63: </script>
1.13      www        64: <script src="/res/adm/includes/bookmarklib.js" language="JavaScript"></script>
1.8       tyszkabe   65: <script language="JavaScript">
                     66:        bookmarkpal = new buildUserTree();
                     67: </script>
1.4       tyszkabe   68: </head>
1.11      tyszkabe   69: <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   70:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5       tyszkabe   71:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ul.html" marginwidth="0" marginheight="0" scrolling="no">
                     72:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_uu.html" marginwidth="0" marginheight="0" scrolling="no">
                     73:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ur.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   74:  </FRAMESET>
                     75:  <FRAMESET name="contentb" cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5       tyszkabe   76:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_left.html" marginwidth="0" marginheight="0" scrolling="no">
1.7       tyszkabe   77:   <FRAME name="content" src="/res/adm/pages/bookmarkmenu/loading_bookmarks.html" marginwidth="0" marginheight="0" scrolling="yes">
1.5       tyszkabe   78:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_right.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   79:  </FRAMESET>
                     80:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5       tyszkabe   81:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_left.html" marginwidth="0" marginheight="0" scrolling="no">
                     82:   <FRAME name="toolbar" src="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" marginwidth="0" marginheight="0" scrolling="no">
                     83:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_right.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   84:  </FRAMESET>
                     85:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5       tyszkabe   86:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ll.html" marginwidth="0" marginheight="0" scrolling="no">
                     87:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_bb.html" marginwidth="0" marginheight="0" scrolling="no">
                     88:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_lr.html" marginwidth="0" marginheight="0" scrolling="no">
1.4       tyszkabe   89:  </FRAMESET>
                     90: </FRAMESET>
                     91: </html>
1.2       tyszkabe   92: END_HTML
1.1       tyszkabe   93: }
                     94: 
1.13      www        95: # -------------------------------------------------------Construct Error window
1.5       tyszkabe   96: 
                     97: sub construct_error {
                     98:   my $error_message=shift;
                     99:   return(<<END_ERROR)
                    100: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
                    101: <html>
                    102:  <head>
                    103:   <title>
                    104:    Bookmark Tree Viewer/Editor  V3
                    105:   </title>
                    106:  </head>
                    107:  <body bgcolor="#BBBBBB">
                    108:   <table bgcolor="#FFFFFF" width="100%" height="90%" align="center">
                    109:    <td>
                    110:     <i>
                    111:      $error_message
                    112:     </i>
                    113:    </td>
                    114:   </table>
                    115:   <center>
                    116:    <form>
                    117:     <input type=button name="close" value="close window" onClick="javascript:window.close();">
                    118:    </form>
                    119:   </center>
                    120:  </body>
                    121: </html>
                    122: END_ERROR
                    123: }
                    124: 
1.13      www       125: # ---------------------------------------------Construct toolbar (after saving)
1.6       tyszkabe  126: 
                    127: sub construct_toolbar {
                    128:   return(<<END_TOOLBAR)
                    129: <html>
                    130: <body>
1.7       tyszkabe  131: <div align="bottom">
                    132: <center>
                    133: Bookmarks saved. 
                    134: [ <a href="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" target="toolbar">Continue</a> ]
                    135: </center>
                    136: </div>
1.6       tyszkabe  137: </body>
                    138: </html>
                    139: END_TOOLBAR
                    140: }
                    141: 
1.13      www       142: # -----------------------------------------------------------------Main Handler
1.1       tyszkabe  143: 
                    144: sub handler {
1.6       tyszkabe  145:   my $r=shift;
                    146:   my %marks;
                    147:   my $save_mark;
                    148:   my $page;
                    149:   $r->content_type('text/html');
                    150:   $r->send_http_header;
1.9       tyszkabe  151:   if (exists($ENV{'form.hiddenbookmarks'})) {
                    152:       $marks{'bookmarks'}=$ENV{'form.hiddenbookmarks'};
                    153:       write_bookmarks($marks{'bookmarks'});
                    154:       if ($marks{'bookmarks'} eq 'recover') {    #if statement is all debug stuff
1.10      tyszkabe  155: 	  my $recover=defaultmarks();
1.9       tyszkabe  156: 	  $r->print("BOOKMARK RECOVERY");
                    157: 	  write_bookmarks($recover);
                    158:       }
                    159:       $page=construct_toolbar();
1.6       tyszkabe  160:   } else {
1.9       tyszkabe  161:       %marks=get_bookmarks();
                    162:       if (exists($marks{"con_lost"})) {
                    163: 	  $page=construct_error("Connection broken with home server. Please contact your system administrator");
                    164:       } else {
1.10      tyszkabe  165: 	  if ($marks{'bookmarks'} eq "") {
                    166: 	      $marks{'bookmarks'}=defaultmarks();
                    167: 	  }
1.9       tyszkabe  168: 	  $page = construct_editor($marks{'bookmarks'});
                    169:       }
1.6       tyszkabe  170:   }
                    171:   $r->print($page);
                    172:   return OK;
1.1       tyszkabe  173: }
1.9       tyszkabe  174: 
                    175: ####################################
                    176: #
1.12      tyszkabe  177: #          Here is a listing of default bookmarks. They have replaced 'recover'
                    178: #          These will load after all bookmarks have been deleted.
1.10      tyszkabe  179: #                ben 10/12/2000
                    180: sub defaultmarks {
                    181:     return(<<END_MARKS);
                    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>