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

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

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