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

1.28    ! albertel    1: # The LearningOnline Network with CAPA
        !             2: # The bookmarks handler
1.1       tyszkabe    3: #
1.28    ! albertel    4: # $Id: gplheader.pl,v 1.1 2001/11/29 18:19:27 www Exp $
        !             5: #
        !             6: # Copyright Michigan State University Board of Trustees
        !             7: #
        !             8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
        !             9: #
        !            10: # LON-CAPA is free software; you can redistribute it and/or modify
        !            11: # it under the terms of the GNU General Public License as published by
        !            12: # the Free Software Foundation; either version 2 of the License, or
        !            13: # (at your option) any later version.
        !            14: #
        !            15: # LON-CAPA is distributed in the hope that it will be useful,
        !            16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            18: # GNU General Public License for more details.
        !            19: #
        !            20: # You should have received a copy of the GNU General Public License
        !            21: # along with LON-CAPA; if not, write to the Free Software
        !            22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        !            23: #
        !            24: # /home/httpd/html/adm/gpl.txt
        !            25: #
        !            26: # http://www.lon-capa.org/
1.1       tyszkabe   27: #
1.2       tyszkabe   28: # 08/25/00 Ben Tyszka
1.16      tyszkabe   29: #
1.1       tyszkabe   30: #
1.2       tyszkabe   31: #
                     32: ##################
1.1       tyszkabe   33: 
1.5       tyszkabe   34: package Apache::admbookmarks;
1.1       tyszkabe   35: 
                     36: use strict;
1.2       tyszkabe   37: use Apache::Constants qw(:common);
1.8       tyszkabe   38: use Apache::lonnet();
1.1       tyszkabe   39: 
1.4       tyszkabe   40: # --------------------------------------------------------------Put bookmarks
1.1       tyszkabe   41: 
1.4       tyszkabe   42: sub write_bookmarks {
1.3       tyszkabe   43:     my $marks=shift;
1.27      albertel   44:     Apache::lonnet::put("bookmarks",{'bookmarks' => $marks});
1.2       tyszkabe   45:     return;
1.1       tyszkabe   46: }
                     47: 
1.4       tyszkabe   48: # --------------------------------------------------------------Get bookmarks
1.2       tyszkabe   49: 
1.4       tyszkabe   50: sub get_bookmarks {
1.26      albertel   51:     my %bookmark=Apache::lonnet::get('bookmarks',['bookmarks']);
                     52:     my ($errormsg) = $bookmark{'bookmarks'};
                     53:     if ($errormsg =~ /^error/) { %bookmark = ('bookmarks' => ''); }
                     54: 
1.5       tyszkabe   55:     return %bookmark;
1.2       tyszkabe   56: }
                     57: 
1.4       tyszkabe   58: # ---------------------------------------------------Construct bookmark editor
1.2       tyszkabe   59: 
                     60: sub construct_editor {
1.9       tyszkabe   61:     my $bookmarks=shift;
1.2       tyszkabe   62:     return(<<END_HTML) 
1.4       tyszkabe   63: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
                     64: <html>
                     65: <head>
                     66: <title>
1.8       tyszkabe   67: Bookmark Tree Viewer/Editor
1.4       tyszkabe   68: </title>
1.16      tyszkabe   69: 
1.18      tyszkabe   70: <script src="/res/adm/pages/bookmarkmenu/bookmarklib.js" language="JavaScript"></script>
1.16      tyszkabe   71: 
1.4       tyszkabe   72: <script LANGUAGE="JavaScript">
1.16      tyszkabe   73: function initialize() {
                     74: window.tree = new newTree();
                     75: //-------------------------------------------------------------------------------
1.9       tyszkabe   76: //                         The FOLLOWING data is supplied by the Perl Module
1.16      tyszkabe   77: //-------------------------------------------------------------------------------
1.9       tyszkabe   78: $bookmarks
1.16      tyszkabe   79: //-------------------------------------------------------------------------------
1.9       tyszkabe   80: //                         The PRECEDING data is supplied by the Perl Module
1.16      tyszkabe   81: //-------------------------------------------------------------------------------
                     82: window.tree.redraw();
1.4       tyszkabe   83: }
1.8       tyszkabe   84: </script>
1.4       tyszkabe   85: </head>
1.25      harris41   86: <FRAMESET rows="25, *, 40, 25, 1" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 frameborder="0" border="0" framespacing="0" onLoad="Javascript:buildBookmarkMenu();initialize();">
1.4       tyszkabe   87:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.16      tyszkabe   88:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
                     89:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
                     90:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.4       tyszkabe   91:  </FRAMESET>
1.16      tyszkabe   92:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
                     93:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.18      tyszkabe   94:   <FRAME src="/res/adm/pages/bookmarkmenu/blank.html" marginwidth="0" marginheight="0" scrolling="yes">
1.16      tyszkabe   95:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.4       tyszkabe   96:  </FRAMESET>
                     97:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.16      tyszkabe   98:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.18      tyszkabe   99:   <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" marginwidth="0" marginheight="0" scrolling="no">
1.16      tyszkabe  100:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.4       tyszkabe  101:  </FRAMESET>
                    102:  <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.16      tyszkabe  103:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
                    104:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
                    105:   <FRAME marginwidth="0" marginheight="0" scrolling="no" src="javascript:''">
1.4       tyszkabe  106:  </FRAMESET>
1.25      harris41  107: <frame name=closechildren src="/res/adm/pages/bookmarkmenu/closechildren.html" noresize noscroll>
1.4       tyszkabe  108: </FRAMESET>
                    109: </html>
1.2       tyszkabe  110: END_HTML
1.1       tyszkabe  111: }
                    112: 
1.16      tyszkabe  113: # ---------------------------------------------------------------Construct Error window
1.5       tyszkabe  114: 
                    115: sub construct_error {
                    116:   my $error_message=shift;
                    117:   return(<<END_ERROR)
                    118: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
                    119: <html>
                    120:  <head>
                    121:   <title>
                    122:    Bookmark Tree Viewer/Editor  V3
                    123:   </title>
                    124:  </head>
                    125:  <body bgcolor="#BBBBBB">
                    126:   <table bgcolor="#FFFFFF" width="100%" height="90%" align="center">
                    127:    <td>
                    128:     <i>
                    129:      $error_message
                    130:     </i>
                    131:    </td>
                    132:   </table>
                    133:   <center>
                    134:    <form>
                    135:     <input type=button name="close" value="close window" onClick="javascript:window.close();">
                    136:    </form>
                    137:   </center>
                    138:  </body>
                    139: </html>
                    140: END_ERROR
                    141: }
                    142: 
1.16      tyszkabe  143: # --------------------------------------------Construct toolbar (after saving)
1.6       tyszkabe  144: 
                    145: sub construct_toolbar {
                    146:   return(<<END_TOOLBAR)
                    147: <html>
                    148: <body>
1.7       tyszkabe  149: <div align="bottom">
                    150: <center>
                    151: Bookmarks saved. 
1.20      tyszkabe  152: [ <a href="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" target="_self">Continue</a> ]
1.7       tyszkabe  153: </center>
                    154: </div>
1.6       tyszkabe  155: </body>
                    156: </html>
                    157: END_TOOLBAR
                    158: }
                    159: 
1.21      tyszkabe  160: # ---------------------------------------------Add bookmark from remote control
                    161: 
                    162: sub add_bookmark {
                    163:     my $location=shift;
                    164:     my $title=shift;
1.22      tyszkabe  165:     my $bookmarks=shift;
                    166:     my $page='';
1.23      harris41  167:     $bookmarks .= "window.tree.bookmarks.addLink(\"$title\",\"$location\");\n";
1.22      tyszkabe  168: #	$marks{'bookmarks'} += qq/\nwindow.tree.bookmarks.addlink("$title","$location");\n/;
1.23      harris41  169:     write_bookmarks($bookmarks);
1.24      harris41  170:     $page="<html><body>$bookmarks<p>Bookmarks successfully saved<script language=\"JavaScript\">window.close()</script></body></html>";
1.22      tyszkabe  171:     return($page);
1.21      tyszkabe  172: }
                    173: 
1.16      tyszkabe  174: # ----------------------------------------------------------------Main Handler
1.1       tyszkabe  175: 
                    176: sub handler {
1.6       tyszkabe  177:   my $r=shift;
                    178:   my %marks;
                    179:   my $save_mark;
                    180:   my $page;
                    181:   $r->content_type('text/html');
                    182:   $r->send_http_header;
1.22      tyszkabe  183:   if (defined($ENV{'form.hiddenbookmarks'})) {
                    184:       $marks{'bookmarks'}=$ENV{'form.hiddenbookmarks'};
                    185:       write_bookmarks($marks{'bookmarks'});
                    186:       $page=construct_toolbar();
1.6       tyszkabe  187:   } else {
1.22      tyszkabe  188:       %marks=get_bookmarks();
                    189:       if (exists($marks{"con_lost"})) {
                    190: 	  #$page = construct_editor($marks{'bookmarks'});  # Delete this line and uncomment next
                    191: 	  # in order to re-enable connection detection
                    192: 	  $page=construct_error("Connection broken with home server. Please contact your system administrator");
1.9       tyszkabe  193:       } else {
1.22      tyszkabe  194: 	  if (defined($ENV{'form.address'})) {
                    195: 	      $page=add_bookmark($ENV{'form.address'},$ENV{'form.title'},$marks{'bookmarks'});
1.21      tyszkabe  196: 	  } else {
                    197: 	      if ($marks{'bookmarks'} eq "") {
1.26      albertel  198: 		  #$marks{'bookmarks'}=defaultmarks();
1.21      tyszkabe  199: 	      }
                    200: 	      $page = construct_editor($marks{'bookmarks'});
1.10      tyszkabe  201: 	  }
1.9       tyszkabe  202:       }
1.6       tyszkabe  203:   }
                    204:   $r->print($page);
                    205:   return OK;
1.1       tyszkabe  206: }
1.9       tyszkabe  207: 
                    208: ####################################
                    209: #
1.16      tyszkabe  210: #            The following was used for debugging when the bookmarks get corrupted
                    211: #                            ben  10/12/2000
                    212: sub recovermarks {
                    213:     return(<<END_MARKS);
                    214: window.tree.bookmarks.addFolder("Default Bookmarks",true);
                    215: window.tree.bookmarks.p[0].addFolder("Michigan State University",true);
                    216: window.tree.bookmarks.p[0].p[0].addLink("Main Website","http://www.msu.edu");
                    217: window.tree.bookmarks.p[0].p[0].addLink("College of Natural Science","http://www.ns.msu.edu");
                    218: window.tree.bookmarks.p[0].p[0].addLink("College of Engineering","http://www.egr.msu.edu");
                    219: window.tree.bookmarks.p[0].p[0].addLink("Dept. of Mathematics","http://www.math.msu.edu");
                    220: window.tree.bookmarks.p[0].p[0].addLink("Lite Lab","http://www.lite.msu.edu");
                    221: window.tree.bookmarks.p[0].p[0].addLink("Physics and Astronomy","http://www.pa.msu.edu");
                    222: window.tree.bookmarks.p[0].addFolder("Lon-Capa",false);
                    223: window.tree.bookmarks.p[0].p[1].addLink("Lon-Capa org","http://lon-capa.org");
                    224: window.tree.bookmarks.p[0].p[1].addLink("Lite Lab","http://www.lite.msu.edu");
1.17      tyszkabe  225: lwindow.tree.bookmarks.p[0].addLink("Redhat","http://redhat.com");
1.16      tyszkabe  226: window.tree.bookmarks.p[0].addLink("Debian","http://debian.org");
                    227: window.tree.bookmarks.addLink("Other Bookmarks","http://kirk.lite.msu.edu");
                    228: END_MARKS
                    229: }
                    230: #
                    231: #
                    232: ##########################################
                    233: 
                    234: ##########################################
                    235: #
                    236: #          Here is a listing of default bookmarks. It may be used to replace 'recover'
                    237: #          eventually, but for now these will load after all bookmarks have been deleted.
1.10      tyszkabe  238: #                ben 10/12/2000
                    239: sub defaultmarks {
                    240:     return(<<END_MARKS);
1.16      tyszkabe  241: window.tree.bookmarks.addFolder("Default Bookmarks",true);
                    242: window.tree.bookmarks.p[0].addFolder("Michigan State University",true);
                    243: window.tree.bookmarks.p[0].p[0].addLink("Main Website","http://www.msu.edu");
                    244: window.tree.bookmarks.p[0].p[0].addLink("College of Natural Science","http://www.ns.msu.edu");
                    245: window.tree.bookmarks.p[0].p[0].addLink("College of Engineering","http://www.egr.msu.edu");
                    246: window.tree.bookmarks.p[0].p[0].addLink("Dept. of Mathematics","http://www.math.msu.edu");
                    247: window.tree.bookmarks.p[0].p[0].addLink("Lite Lab","http://www.lite.msu.edu");
                    248: window.tree.bookmarks.p[0].p[0].addLink("Physics and Astronomy","http://www.pa.msu.edu");
                    249: window.tree.bookmarks.p[0].addFolder("Lon-Capa",false);
                    250: window.tree.bookmarks.p[0].p[1].addLink("Lon-Capa org","http://lon-capa.org");
                    251: window.tree.bookmarks.p[0].p[1].addLink("Lite Lab","http://www.lite.msu.edu");
                    252: window.tree.bookmarks.p[0].addLink("Redhat","http://redhat.com");
                    253: window.tree.bookmarks.p[0].addLink("Debian","http://debian.org");
                    254: window.tree.bookmarks.addLink("Other Bookmarks","http://kirk.lite.msu.edu");
1.10      tyszkabe  255: END_MARKS
                    256: }
1.1       tyszkabe  257: 
                    258: 1;
                    259: __END__
1.8       tyszkabe  260: 
                    261: 
                    262: 
                    263: 
                    264: 

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