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

1.16      tyszkabe    1: #!/usr/bin/perl -T
1.1       tyszkabe    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.16      tyszkabe    6: #
1.1       tyszkabe    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.16      tyszkabe   21:     Apache::lonnet::put("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.16      tyszkabe   28:     my %bookmark=Apache::lonnet::get('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>
1.16      tyszkabe   43: 
1.18      tyszkabe   44: <script src="/res/adm/pages/bookmarkmenu/bookmarklib.js" language="JavaScript"></script>
1.16      tyszkabe   45: 
1.4       tyszkabe   46: <script LANGUAGE="JavaScript">
1.16      tyszkabe   47: function initialize() {
                     48: window.tree = new newTree();
                     49: //-------------------------------------------------------------------------------
1.9       tyszkabe   50: //                         The FOLLOWING data is supplied by the Perl Module
1.16      tyszkabe   51: //-------------------------------------------------------------------------------
1.9       tyszkabe   52: $bookmarks
1.16      tyszkabe   53: //-------------------------------------------------------------------------------
1.9       tyszkabe   54: //                         The PRECEDING data is supplied by the Perl Module
1.16      tyszkabe   55: //-------------------------------------------------------------------------------
                     56: window.tree.redraw();
1.4       tyszkabe   57: }
1.8       tyszkabe   58: </script>
1.4       tyszkabe   59: </head>
1.16      tyszkabe   60: <FRAMESET rows="25, *, 40, 25" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 frameborder="0" border="0" framespacing="0" onLoad="Javascript:buildBookmarkMenu();initialize();">
1.4       tyszkabe   61:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.16      tyszkabe   62:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
                     63:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
                     64:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.4       tyszkabe   65:  </FRAMESET>
1.16      tyszkabe   66:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
                     67:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.18      tyszkabe   68:   <FRAME src="/res/adm/pages/bookmarkmenu/blank.html" marginwidth="0" marginheight="0" scrolling="yes">
1.16      tyszkabe   69:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.4       tyszkabe   70:  </FRAMESET>
                     71:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.16      tyszkabe   72:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.18      tyszkabe   73:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" marginwidth="0" marginheight="0" scrolling="no">
1.16      tyszkabe   74:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.4       tyszkabe   75:  </FRAMESET>
                     76:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.16      tyszkabe   77:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
                     78:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
                     79:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.4       tyszkabe   80:  </FRAMESET>
                     81: </FRAMESET>
                     82: </html>
1.2       tyszkabe   83: END_HTML
1.1       tyszkabe   84: }
                     85: 
1.16      tyszkabe   86: # ---------------------------------------------------------------Construct Error window
1.5       tyszkabe   87: 
                     88: sub construct_error {
                     89:   my $error_message=shift;
                     90:   return(<<END_ERROR)
                     91: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
                     92: <html>
                     93:  <head>
                     94:   <title>
                     95:    Bookmark Tree Viewer/Editor  V3
                     96:   </title>
                     97:  </head>
                     98:  <body bgcolor="#BBBBBB">
                     99:   <table bgcolor="#FFFFFF" width="100%" height="90%" align="center">
                    100:    <td>
                    101:     <i>
                    102:      $error_message
                    103:     </i>
                    104:    </td>
                    105:   </table>
                    106:   <center>
                    107:    <form>
                    108:     <input type=button name="close" value="close window" onClick="javascript:window.close();">
                    109:    </form>
                    110:   </center>
                    111:  </body>
                    112: </html>
                    113: END_ERROR
                    114: }
                    115: 
1.16      tyszkabe  116: # --------------------------------------------Construct toolbar (after saving)
1.6       tyszkabe  117: 
                    118: sub construct_toolbar {
                    119:   return(<<END_TOOLBAR)
                    120: <html>
                    121: <body>
1.7       tyszkabe  122: <div align="bottom">
                    123: <center>
                    124: Bookmarks saved. 
                    125: [ <a href="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" target="toolbar">Continue</a> ]
                    126: </center>
                    127: </div>
1.6       tyszkabe  128: </body>
                    129: </html>
                    130: END_TOOLBAR
                    131: }
                    132: 
1.16      tyszkabe  133: # ----------------------------------------------------------------Main Handler
1.1       tyszkabe  134: 
                    135: sub handler {
1.6       tyszkabe  136:   my $r=shift;
                    137:   my %marks;
                    138:   my $save_mark;
                    139:   my $page;
                    140:   $r->content_type('text/html');
                    141:   $r->send_http_header;
1.9       tyszkabe  142:   if (exists($ENV{'form.hiddenbookmarks'})) {
                    143:       $marks{'bookmarks'}=$ENV{'form.hiddenbookmarks'};
                    144:       write_bookmarks($marks{'bookmarks'});
                    145:       if ($marks{'bookmarks'} eq 'recover') {    #if statement is all debug stuff
1.10      tyszkabe  146: 	  my $recover=defaultmarks();
1.9       tyszkabe  147: 	  $r->print("BOOKMARK RECOVERY");
                    148: 	  write_bookmarks($recover);
                    149:       }
                    150:       $page=construct_toolbar();
1.6       tyszkabe  151:   } else {
1.9       tyszkabe  152:       %marks=get_bookmarks();
                    153:       if (exists($marks{"con_lost"})) {
1.16      tyszkabe  154:       #$page = construct_editor($marks{'bookmarks'});  # Delete this line and uncomment next
                    155: 	                                               # in order to re-enable connection detection
1.9       tyszkabe  156: 	  $page=construct_error("Connection broken with home server. Please contact your system administrator");
                    157:       } else {
1.16      tyszkabe  158: 	  if ($marks{'bookmarks'} eq "") {
1.10      tyszkabe  159: 	      $marks{'bookmarks'}=defaultmarks();
                    160: 	  }
1.9       tyszkabe  161: 	  $page = construct_editor($marks{'bookmarks'});
                    162:       }
1.6       tyszkabe  163:   }
                    164:   $r->print($page);
                    165:   return OK;
1.1       tyszkabe  166: }
1.9       tyszkabe  167: 
                    168: ####################################
                    169: #
1.16      tyszkabe  170: #            The following was used for debugging when the bookmarks get corrupted
                    171: #                            ben  10/12/2000
                    172: sub recovermarks {
                    173:     return(<<END_MARKS);
                    174: window.tree.bookmarks.addFolder("Default Bookmarks",true);
                    175: window.tree.bookmarks.p[0].addFolder("Michigan State University",true);
                    176: window.tree.bookmarks.p[0].p[0].addLink("Main Website","http://www.msu.edu");
                    177: window.tree.bookmarks.p[0].p[0].addLink("College of Natural Science","http://www.ns.msu.edu");
                    178: window.tree.bookmarks.p[0].p[0].addLink("College of Engineering","http://www.egr.msu.edu");
                    179: window.tree.bookmarks.p[0].p[0].addLink("Dept. of Mathematics","http://www.math.msu.edu");
                    180: window.tree.bookmarks.p[0].p[0].addLink("Lite Lab","http://www.lite.msu.edu");
                    181: window.tree.bookmarks.p[0].p[0].addLink("Physics and Astronomy","http://www.pa.msu.edu");
                    182: window.tree.bookmarks.p[0].addFolder("Lon-Capa",false);
                    183: window.tree.bookmarks.p[0].p[1].addLink("Lon-Capa org","http://lon-capa.org");
                    184: window.tree.bookmarks.p[0].p[1].addLink("Lite Lab","http://www.lite.msu.edu");
1.17      tyszkabe  185: lwindow.tree.bookmarks.p[0].addLink("Redhat","http://redhat.com");
1.16      tyszkabe  186: window.tree.bookmarks.p[0].addLink("Debian","http://debian.org");
                    187: window.tree.bookmarks.addLink("Other Bookmarks","http://kirk.lite.msu.edu");
                    188: END_MARKS
                    189: }
                    190: #
                    191: #
                    192: ##########################################
                    193: 
                    194: ##########################################
                    195: #
                    196: #          Here is a listing of default bookmarks. It may be used to replace 'recover'
                    197: #          eventually, but for now these will load after all bookmarks have been deleted.
1.10      tyszkabe  198: #                ben 10/12/2000
                    199: sub defaultmarks {
                    200:     return(<<END_MARKS);
1.16      tyszkabe  201: window.tree.bookmarks.addFolder("Default Bookmarks",true);
                    202: window.tree.bookmarks.p[0].addFolder("Michigan State University",true);
                    203: window.tree.bookmarks.p[0].p[0].addLink("Main Website","http://www.msu.edu");
                    204: window.tree.bookmarks.p[0].p[0].addLink("College of Natural Science","http://www.ns.msu.edu");
                    205: window.tree.bookmarks.p[0].p[0].addLink("College of Engineering","http://www.egr.msu.edu");
                    206: window.tree.bookmarks.p[0].p[0].addLink("Dept. of Mathematics","http://www.math.msu.edu");
                    207: window.tree.bookmarks.p[0].p[0].addLink("Lite Lab","http://www.lite.msu.edu");
                    208: window.tree.bookmarks.p[0].p[0].addLink("Physics and Astronomy","http://www.pa.msu.edu");
                    209: window.tree.bookmarks.p[0].addFolder("Lon-Capa",false);
                    210: window.tree.bookmarks.p[0].p[1].addLink("Lon-Capa org","http://lon-capa.org");
                    211: window.tree.bookmarks.p[0].p[1].addLink("Lite Lab","http://www.lite.msu.edu");
                    212: window.tree.bookmarks.p[0].addLink("Redhat","http://redhat.com");
                    213: window.tree.bookmarks.p[0].addLink("Debian","http://debian.org");
                    214: window.tree.bookmarks.addLink("Other Bookmarks","http://kirk.lite.msu.edu");
1.10      tyszkabe  215: END_MARKS
                    216: }
1.1       tyszkabe  217: 
                    218: 1;
                    219: __END__
1.8       tyszkabe  220: 
                    221: 
                    222: 
                    223: 
                    224: 

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