Annotation of loncom/interface/lonhelpmenu.pm, revision 1.18
1.1 raeburn 1: # The LearningOnline Network with CAPA
2: # generate frame-based help system
3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
26:
27: package Apache::lonhelpmenu;
28:
29: use strict;
30: use lib qw(/home/httpd/lib/perl);
31: use Apache::Constants qw(:common);
32: use Apache::loncommon();
1.18 ! raeburn 33: use Apache::lonlocal;
1.1 raeburn 34:
1.2 albertel 35: sub handler {
36: my ($r) = @_;
1.8 raeburn 37: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['page','color','function','faq','bug','topic','component_help','origurl','stayonpage']);
1.2 albertel 38: &Apache::loncommon::content_type($r,'text/html');
1.1 raeburn 39: $r->send_http_header;
40:
41: if ($r->header_only) {
42: return OK;
43: }
1.3 albertel 44: my $color = $ENV{'form.color'};
45: my $faq = $ENV{'form.faq'};
46: my $bug = $ENV{'form.bug'};
47: my $topic = $ENV{'form.topic'};
48: my $function = $ENV{'form.function'};
49: my $component_help = $ENV{'form.component_help'};
1.1 raeburn 50: my $origurl = $ENV{'form.origurl'};
1.8 raeburn 51: my $stayOnPage = $ENV{'form.stayonpage'};
1.1 raeburn 52: my $component_url = $component_help;
53: if ($component_url) {
54: $component_url = '/adm/help/'.$component_url.'.hlp';
55: }
56: my $bugurl = $Apache::lonnet::perlvar{'BugzillaHost'};
57: $bugurl .= 'enter_bug.cgi?product=LON-CAPA&bug_file_loc='.$origurl;
58: if ($bug) {
59: $bugurl .= '&component='.$bug;
60: }
61: my $faqbaseurl = $Apache::lonnet::perlvar{'FAQHost'};
62: my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
63: if ($ENV{'form.page'} eq 'banner') {
1.8 raeburn 64: &display_help_banner($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
1.1 raeburn 65: } elsif ($ENV{'form.page'} eq 'body') {
1.3 albertel 66: &display_help_mainpage($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail);
1.1 raeburn 67: }
68: return OK;
69: }
70:
71: sub display_help_banner {
1.8 raeburn 72: my ($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
1.1 raeburn 73: my $bodytag = &Apache::loncommon::bodytag('',$function,'rightmargin="0" leftmargin="0" marginwidth="0" topmargin="1" marginheight="1"',1);
1.5 albertel 74: $bodytag=~s/[\n\r]/ /g;
1.1 raeburn 75: my $fontcolor = &Apache::loncommon::designparm($function.'.font');
76: my $alinkcolor = &Apache::loncommon::designparm($function.'.alink');
77: my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink');
78: my $pagecolor = &Apache::loncommon::designparm($function.'.pgbg');
79: my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
1.14 albertel 80: my $location=&Apache::loncommon::lonhttpdurl("/adm");
1.8 raeburn 81: if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {
1.17 raeburn 82: $tablecolor = '#EEEE99';
1.8 raeburn 83: }
1.17 raeburn 84: my $scripttag = '';
85: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
86: my $displayurl = &Apache::lonnet::escape($origurl);
87: $scripttag = (<<"SCRIPT_ONE");
88: <script>
89: function gohelpdesk() {
90: var actiontype = null;
91: try {
92: actiontype = parent.bodyframe.document.logproblem.action.value;
93: }
94: catch(error) {
95: parent.bodyframe.location = "/adm/support?origurl=$displayurl&function=$function";
96: return;
97: }
98: if (actiontype) {
99: var loc = parent.bodyframe.location.href;
100: if (loc.indexOf("/adm/support") > -1) {
101: if (parent.bodyframe.document.logproblem.action.value == "process") {
102: if (validmail(parent.bodyframe.document.logproblem.email) == false) {
103: alert("The e-mail address you entered: "+parent.bodyframe.document.logproblem.email.value+" is not a valid e-mail address.");
104: return;
105: }
106: parent.bodyframe.document.logproblem.submit();
107: return;
108: }
109: }
110: parent.bodyframe.location = "/adm/support?origurl=$displayurl&function=$function";
111: return;
112: }
113: }
114: SCRIPT_ONE
115: $scripttag .= (<<'SCRIPT_TWO');
116: function validmail(field) {
117: var str = field.value;
118: if (window.RegExp) {
119: var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
120: var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
121: var reg1 = new RegExp(reg1str);
122: var reg2 = new RegExp(reg2str);
123: if (!reg1.test(str) && reg2.test(str)) {
124: return true;
125: }
126: return false;
127: }
128: else
129: {
1.8 raeburn 130:
1.17 raeburn 131: if(str.indexOf("@") >= 0) {
132: return true;
133: }
134: return false;
135: }
136: }
137: </script>
138: SCRIPT_TWO
139: }
1.1 raeburn 140: $r->print(<<END);
141: <html>
142: <head>
143: <title>Help Banner</title>
144: <style type="text/css">
145: <!--
146: a:link {text-decoration: none; color: $fontcolor; }
147: a:visited {text-decoration: none; color: $fontcolor; }
148: a:active {text-decoration: none; color: $fontcolor; }
149: a:hover {text-decoration: underline; color: $vlinkcolor; }
150: -->
151: </style>
1.17 raeburn 152: $scripttag
1.1 raeburn 153: </head>
154: $bodytag
1.8 raeburn 155: END
156: if ($stayOnPage) {
157: $r->print('<table width="700" border="0" cellspacing="0" cellpadding="0" height="55">');
158: } else {
159: $r->print('<table width="600" border="0" cellspacing="0" cellpadding="0" height="55">');
160: }
161: $r->print(<<END);
1.1 raeburn 162: <tr height="50">
163: <td width='5'> </td>
164: <td>
1.12 albertel 165: <fieldset><legend><img src="$location/lonIcons/minilogo.gif" height='20' width='29' valign='bottom' /> <b><font size="+1">LON-CAPA help/support</font></b></legend>
1.1 raeburn 166: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
167: <tr>
168: <td>
169: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
170: <tr>
171: <td>
172: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
173: <tr>
174: <td>
175: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
176: <tr bgcolor="$tablecolor">
177: END
178: if (($component_url) || ($ENV{'user.adv'})) {
179: if ($component_url) {
180: $r->print("
1.18 ! raeburn 181: <td align=\"center\"><b><a href=\"$component_url\" target=\"bodyframe\">");
1.8 raeburn 182: } elsif ($ENV{'user.adv'}) {
1.16 raeburn 183: $r->print('<td align="center"> <b><a href="/adm/help/nohelptopic.html" target="bodyframe">');
1.1 raeburn 184: }
1.8 raeburn 185: $r->print('
1.15 raeburn 186: <img src="'.$location.'/help/gif/smallHelp.gif" border="0" alt="(Topic help)" valign="middle" /> Topic help</a></b> </td>');
1.1 raeburn 187: }
1.11 raeburn 188: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.1 raeburn 189: $r->print('
1.17 raeburn 190: <td align="center"> <b><a href="javascript:gohelpdesk()"><img src="'.$location.'/lonIcons/helpdesk.gif" border="0" alt="(Ask helpdesk)" valign="middle" /> Ask helpdesk</a></b> </td>');
1.1 raeburn 191: }
1.7 albertel 192: if ($faq && $ENV{'user.adv'}) {
1.15 raeburn 193: $r->print(<<END);
1.1 raeburn 194: <td align="center">
1.13 albertel 195: <b><a href="$faqbaseurl/fom/cache/$faq.html" target="bodyframe"><img src="$location/lonMisc/smallFAQ.gif" border="0" alt="(FAQ)" valign="middle" /> FAQ</a></b>
1.1 raeburn 196: </td>
1.7 albertel 197: END
198: }
199: if ($ENV{'user.adv'}) {
1.15 raeburn 200: $r->print(<<END);
1.13 albertel 201: <td align="center"> <b><a href="$bugurl" target="bodyframe"><img src="$location/lonMisc/smallBug.gif" border="0" alt="(Report a bug)" valign="middle" /> Report a bug</a> </b></td>
1.1 raeburn 202: END
203: }
1.8 raeburn 204: if ($stayOnPage) {
205: $r->print(<<END);
1.13 albertel 206: <td align="center"> <b><a href="$origurl" target="_top"><img src="$location/lonIcons/move_up.gif" border="0" alt="(Return to last location)" valign="middle" /> Return to last location</a></b> </td>
1.8 raeburn 207: END
208: } else {
209: $r->print(<<END);
1.13 albertel 210: <td align="center"> <b><a href="javascript:window.close()" target="_top"><img src="$location/lonIcons/closepage.gif" border="0" alt="(Close window)" valign="bottom" /> Close</a></b> </td>
1.8 raeburn 211: END
212: }
1.1 raeburn 213: $r->print(<<END);
214: </tr>
215: </table>
216: </td>
217: </tr>
218: </table>
219: </td>
220: </tr>
221: </table>
222: </td>
223: </tr>
224: </table>
225: </fieldset>
226: </td>
227: <td width='5'> </td>
228: </tr>
229: <tr height='5'>
230: <td colspan='3' height='5'> </td>
231: </tr>
232: </table>
233: </body>
234: </html>
235: END
236: }
237:
238: sub display_help_mainpage {
239: my ($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail) = @_;
240: my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0"',1);
1.4 albertel 241: $bodytag=~s/[\n\r]/ /g;
1.8 raeburn 242: my %lt =&Apache::lonlocal::texthash(
243: 'heco' => 'Help Content',
244: 'topp' => 'Topic Page',
245: 'chen' => 'Choose an entry below to go directly to a relevant help page',
246: 'orto' => 'or to submit a help request to the LON-CAPA support staff at your institution.',
247: 'vthp' => 'Visit the help page for ',
248: 'disp' => 'Display the page in the inline help system that covers this topic.',
249: 'crac' => 'Create an account for yourself in the LON-CAPA Bugzilla tracking system, if you wish to report bugs you have encountered in the LON-CAPA software, or if you have suggestions for improvements in LON-CAPA.',
250: 'inhs' => 'Inline help system for',
251: 'coth' => 'Consult the inline help system for this topic.',
252: 'cont' => 'Contact the LON-CAPA support team',
253: 'suhr' => 'Submit a help request to the team responsible for LON-CAPA support at this institution.',
1.18 ! raeburn 254: 'stuq' => 'Questions about course content should not be directed to the support team, but instead should be sent to the course instructor',
1.8 raeburn 255: 'faqo' => 'FAQ-O-Matic Help system',
256: 'tfaq' => 'The FAQ-O-Matic is a compendium of answers provided to common questions asked by users of LON-CAPA over the past couple of years.',
257: 'lbug' => 'LON-CAPA Bugzilla bug/feature request tracking system',
258: 'crea' => 'Create an account for yourself in the LON-CAPA Bugzilla tracking system, if you wish to report bugs you have encountered in the LON-CAPA software,or if you have suggestions for improvements in LON-CAPA.',
259: 'suim' => ' Suggested improvements may include additional functionality, improved usability, or changes to wording used in LON-CAPA pages, including the embedded help system.'
260: );
261:
1.1 raeburn 262: $r->print(<<END);
263: <html>
264: <head>
1.8 raeburn 265: <title>$lt{'heco'}</title>
1.1 raeburn 266: </head>
267: $bodytag
268: END
1.8 raeburn 269: $r->print($lt{'chen'});
1.11 raeburn 270: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.8 raeburn 271: $r->print(', '.$lt{'orto'});
1.1 raeburn 272: } else {
273: $r->print(".");
274: }
275: if ($topic) {
276: if ( ($component_url) || ($ENV{'user.adv'}) ) {
277: if ($component_url) {
278: $r->print("
279: <ul>
1.8 raeburn 280: <li><a href=\"$component_url\">$lt{'vthp'} $topic</a></li>
1.1 raeburn 281: </ul>
1.8 raeburn 282: <p>$lt{'disp'}</p>
1.1 raeburn 283: ");
284: } elsif ($ENV{'user.adv'}) {
285: $r->print("
286: <ul>
1.8 raeburn 287: <li><td align=\"center\"> <a href=\"/adm/help/nohelptopic.html\">$lt{'inhs'} $topic</a></li></ul>
288: <p>$lt{'coth'}</p>");
1.1 raeburn 289: }
290: }
291: }
1.11 raeburn 292: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.1 raeburn 293: $r->print("
294: <ul>
1.9 raeburn 295: <li><a href=\"/adm/support?origurl=".&Apache::lonnet::escape($origurl)."&function=$function\">$lt{'cont'}</a></li>
1.1 raeburn 296: </ul>
1.18 ! raeburn 297: <p>$lt{'suhr'}");
! 298: unless ($ENV{'user.adv'}) {
! 299: $r->print('<br /><b>'.&mt('Note').'</b>: '.$lt{'stuq'}.'. '.&mt('This can be done using the').' <a href="/adm/communicate" target="_top">'.&mt('COM').'</a> '.&mt('button, or the FDBK button when viewing a content page.'));
! 300: }
! 301: $r->print("</p>");
1.1 raeburn 302: }
303: if ($faqbaseurl && $ENV{'user.adv'}) {
304: if (!defined($faq) ||$faq eq '') {
305: $faq = '1';
306: }
307: $r->print("
1.11 raeburn 308: <ul>
1.8 raeburn 309: <li><a href=\"$faqbaseurl/fom/cache/$faq.html\">$lt{'faqo'}</a></li>
1.1 raeburn 310: </ul>
1.8 raeburn 311: <p>$lt{'tfaq'}</p>
1.1 raeburn 312: ");
313: }
314: if ($bugurl && $ENV{'user.adv'}) {
315: $bugurl .= '?'.$bug;
316: $r->print("
317: <ul>
1.8 raeburn 318: <li><a href=\"$bugurl\">$lt{'lbug'}</a></li>
1.1 raeburn 319: </ul>
1.8 raeburn 320: <p>$lt{'crea'} $lt{'suim'}</p>
1.1 raeburn 321: ");
322: }
323: $r->print(<<END);
324: </body>
325: </html>
326: END
327: }
328:
329: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>