Annotation of loncom/html/res/adm/pages/bookmarkmenu/admbookmarks.pm, revision 1.25
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.25 ! harris41 60: <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 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>
1.25 ! harris41 81: <frame name=closechildren src="/res/adm/pages/bookmarkmenu/closechildren.html" noresize noscroll>
1.4 tyszkabe 82: </FRAMESET>
83: </html>
1.2 tyszkabe 84: END_HTML
1.1 tyszkabe 85: }
86:
1.16 tyszkabe 87: # ---------------------------------------------------------------Construct Error window
1.5 tyszkabe 88:
89: sub construct_error {
90: my $error_message=shift;
91: return(<<END_ERROR)
92: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
93: <html>
94: <head>
95: <title>
96: Bookmark Tree Viewer/Editor V3
97: </title>
98: </head>
99: <body bgcolor="#BBBBBB">
100: <table bgcolor="#FFFFFF" width="100%" height="90%" align="center">
101: <td>
102: <i>
103: $error_message
104: </i>
105: </td>
106: </table>
107: <center>
108: <form>
109: <input type=button name="close" value="close window" onClick="javascript:window.close();">
110: </form>
111: </center>
112: </body>
113: </html>
114: END_ERROR
115: }
116:
1.16 tyszkabe 117: # --------------------------------------------Construct toolbar (after saving)
1.6 tyszkabe 118:
119: sub construct_toolbar {
120: return(<<END_TOOLBAR)
121: <html>
122: <body>
1.7 tyszkabe 123: <div align="bottom">
124: <center>
125: Bookmarks saved.
1.20 tyszkabe 126: [ <a href="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" target="_self">Continue</a> ]
1.7 tyszkabe 127: </center>
128: </div>
1.6 tyszkabe 129: </body>
130: </html>
131: END_TOOLBAR
132: }
133:
1.21 tyszkabe 134: # ---------------------------------------------Add bookmark from remote control
135:
136: sub add_bookmark {
137: my $location=shift;
138: my $title=shift;
1.22 tyszkabe 139: my $bookmarks=shift;
140: my $page='';
1.23 harris41 141: $bookmarks .= "window.tree.bookmarks.addLink(\"$title\",\"$location\");\n";
1.22 tyszkabe 142: # $marks{'bookmarks'} += qq/\nwindow.tree.bookmarks.addlink("$title","$location");\n/;
1.23 harris41 143: write_bookmarks($bookmarks);
1.24 harris41 144: $page="<html><body>$bookmarks<p>Bookmarks successfully saved<script language=\"JavaScript\">window.close()</script></body></html>";
1.22 tyszkabe 145: return($page);
1.21 tyszkabe 146: }
147:
1.16 tyszkabe 148: # ----------------------------------------------------------------Main Handler
1.1 tyszkabe 149:
150: sub handler {
1.6 tyszkabe 151: my $r=shift;
152: my %marks;
153: my $save_mark;
154: my $page;
155: $r->content_type('text/html');
156: $r->send_http_header;
1.22 tyszkabe 157: if (defined($ENV{'form.hiddenbookmarks'})) {
158: $marks{'bookmarks'}=$ENV{'form.hiddenbookmarks'};
159: write_bookmarks($marks{'bookmarks'});
160: $page=construct_toolbar();
1.6 tyszkabe 161: } else {
1.22 tyszkabe 162: %marks=get_bookmarks();
163: if (exists($marks{"con_lost"})) {
164: #$page = construct_editor($marks{'bookmarks'}); # Delete this line and uncomment next
165: # in order to re-enable connection detection
166: $page=construct_error("Connection broken with home server. Please contact your system administrator");
1.9 tyszkabe 167: } else {
1.22 tyszkabe 168: if (defined($ENV{'form.address'})) {
169: $page=add_bookmark($ENV{'form.address'},$ENV{'form.title'},$marks{'bookmarks'});
1.21 tyszkabe 170: } else {
171: if ($marks{'bookmarks'} eq "") {
172: $marks{'bookmarks'}=defaultmarks();
173: }
174: $page = construct_editor($marks{'bookmarks'});
1.10 tyszkabe 175: }
1.9 tyszkabe 176: }
1.6 tyszkabe 177: }
178: $r->print($page);
179: return OK;
1.1 tyszkabe 180: }
1.9 tyszkabe 181:
182: ####################################
183: #
1.16 tyszkabe 184: # The following was used for debugging when the bookmarks get corrupted
185: # ben 10/12/2000
186: sub recovermarks {
187: return(<<END_MARKS);
188: window.tree.bookmarks.addFolder("Default Bookmarks",true);
189: window.tree.bookmarks.p[0].addFolder("Michigan State University",true);
190: window.tree.bookmarks.p[0].p[0].addLink("Main Website","http://www.msu.edu");
191: window.tree.bookmarks.p[0].p[0].addLink("College of Natural Science","http://www.ns.msu.edu");
192: window.tree.bookmarks.p[0].p[0].addLink("College of Engineering","http://www.egr.msu.edu");
193: window.tree.bookmarks.p[0].p[0].addLink("Dept. of Mathematics","http://www.math.msu.edu");
194: window.tree.bookmarks.p[0].p[0].addLink("Lite Lab","http://www.lite.msu.edu");
195: window.tree.bookmarks.p[0].p[0].addLink("Physics and Astronomy","http://www.pa.msu.edu");
196: window.tree.bookmarks.p[0].addFolder("Lon-Capa",false);
197: window.tree.bookmarks.p[0].p[1].addLink("Lon-Capa org","http://lon-capa.org");
198: window.tree.bookmarks.p[0].p[1].addLink("Lite Lab","http://www.lite.msu.edu");
1.17 tyszkabe 199: lwindow.tree.bookmarks.p[0].addLink("Redhat","http://redhat.com");
1.16 tyszkabe 200: window.tree.bookmarks.p[0].addLink("Debian","http://debian.org");
201: window.tree.bookmarks.addLink("Other Bookmarks","http://kirk.lite.msu.edu");
202: END_MARKS
203: }
204: #
205: #
206: ##########################################
207:
208: ##########################################
209: #
210: # Here is a listing of default bookmarks. It may be used to replace 'recover'
211: # eventually, but for now these will load after all bookmarks have been deleted.
1.10 tyszkabe 212: # ben 10/12/2000
213: sub defaultmarks {
214: return(<<END_MARKS);
1.16 tyszkabe 215: window.tree.bookmarks.addFolder("Default Bookmarks",true);
216: window.tree.bookmarks.p[0].addFolder("Michigan State University",true);
217: window.tree.bookmarks.p[0].p[0].addLink("Main Website","http://www.msu.edu");
218: window.tree.bookmarks.p[0].p[0].addLink("College of Natural Science","http://www.ns.msu.edu");
219: window.tree.bookmarks.p[0].p[0].addLink("College of Engineering","http://www.egr.msu.edu");
220: window.tree.bookmarks.p[0].p[0].addLink("Dept. of Mathematics","http://www.math.msu.edu");
221: window.tree.bookmarks.p[0].p[0].addLink("Lite Lab","http://www.lite.msu.edu");
222: window.tree.bookmarks.p[0].p[0].addLink("Physics and Astronomy","http://www.pa.msu.edu");
223: window.tree.bookmarks.p[0].addFolder("Lon-Capa",false);
224: window.tree.bookmarks.p[0].p[1].addLink("Lon-Capa org","http://lon-capa.org");
225: window.tree.bookmarks.p[0].p[1].addLink("Lite Lab","http://www.lite.msu.edu");
226: window.tree.bookmarks.p[0].addLink("Redhat","http://redhat.com");
227: window.tree.bookmarks.p[0].addLink("Debian","http://debian.org");
228: window.tree.bookmarks.addLink("Other Bookmarks","http://kirk.lite.msu.edu");
1.10 tyszkabe 229: END_MARKS
230: }
1.1 tyszkabe 231:
232: 1;
233: __END__
1.8 tyszkabe 234:
235:
236:
237:
238:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>