Annotation of loncom/interface/lonhelpmenu.pm, revision 1.19
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.19 ! albertel 140: my $html=&Apache::lonxml::xmlbegin();
1.1 raeburn 141: $r->print(<<END);
1.19 ! albertel 142: $html
1.1 raeburn 143: <head>
144: <title>Help Banner</title>
145: <style type="text/css">
146: <!--
147: a:link {text-decoration: none; color: $fontcolor; }
148: a:visited {text-decoration: none; color: $fontcolor; }
149: a:active {text-decoration: none; color: $fontcolor; }
150: a:hover {text-decoration: underline; color: $vlinkcolor; }
151: -->
152: </style>
1.17 raeburn 153: $scripttag
1.1 raeburn 154: </head>
155: $bodytag
1.8 raeburn 156: END
157: if ($stayOnPage) {
158: $r->print('<table width="700" border="0" cellspacing="0" cellpadding="0" height="55">');
159: } else {
160: $r->print('<table width="600" border="0" cellspacing="0" cellpadding="0" height="55">');
161: }
162: $r->print(<<END);
1.1 raeburn 163: <tr height="50">
164: <td width='5'> </td>
165: <td>
1.12 albertel 166: <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 167: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
168: <tr>
169: <td>
170: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
171: <tr>
172: <td>
173: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
174: <tr>
175: <td>
176: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
177: <tr bgcolor="$tablecolor">
178: END
179: if (($component_url) || ($ENV{'user.adv'})) {
180: if ($component_url) {
181: $r->print("
1.18 raeburn 182: <td align=\"center\"><b><a href=\"$component_url\" target=\"bodyframe\">");
1.8 raeburn 183: } elsif ($ENV{'user.adv'}) {
1.16 raeburn 184: $r->print('<td align="center"> <b><a href="/adm/help/nohelptopic.html" target="bodyframe">');
1.1 raeburn 185: }
1.8 raeburn 186: $r->print('
1.15 raeburn 187: <img src="'.$location.'/help/gif/smallHelp.gif" border="0" alt="(Topic help)" valign="middle" /> Topic help</a></b> </td>');
1.1 raeburn 188: }
1.11 raeburn 189: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.1 raeburn 190: $r->print('
1.17 raeburn 191: <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 192: }
1.7 albertel 193: if ($faq && $ENV{'user.adv'}) {
1.15 raeburn 194: $r->print(<<END);
1.1 raeburn 195: <td align="center">
1.13 albertel 196: <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 197: </td>
1.7 albertel 198: END
199: }
200: if ($ENV{'user.adv'}) {
1.15 raeburn 201: $r->print(<<END);
1.13 albertel 202: <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 203: END
204: }
1.8 raeburn 205: if ($stayOnPage) {
206: $r->print(<<END);
1.13 albertel 207: <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 208: END
209: } else {
210: $r->print(<<END);
1.13 albertel 211: <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 212: END
213: }
1.1 raeburn 214: $r->print(<<END);
215: </tr>
216: </table>
217: </td>
218: </tr>
219: </table>
220: </td>
221: </tr>
222: </table>
223: </td>
224: </tr>
225: </table>
226: </fieldset>
227: </td>
228: <td width='5'> </td>
229: </tr>
230: <tr height='5'>
231: <td colspan='3' height='5'> </td>
232: </tr>
233: </table>
234: </body>
235: </html>
236: END
237: }
238:
239: sub display_help_mainpage {
240: my ($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail) = @_;
241: my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0"',1);
1.4 albertel 242: $bodytag=~s/[\n\r]/ /g;
1.8 raeburn 243: my %lt =&Apache::lonlocal::texthash(
244: 'heco' => 'Help Content',
245: 'topp' => 'Topic Page',
246: 'chen' => 'Choose an entry below to go directly to a relevant help page',
247: 'orto' => 'or to submit a help request to the LON-CAPA support staff at your institution.',
248: 'vthp' => 'Visit the help page for ',
249: 'disp' => 'Display the page in the inline help system that covers this topic.',
250: '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.',
251: 'inhs' => 'Inline help system for',
252: 'coth' => 'Consult the inline help system for this topic.',
253: 'cont' => 'Contact the LON-CAPA support team',
254: 'suhr' => 'Submit a help request to the team responsible for LON-CAPA support at this institution.',
1.18 raeburn 255: '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 256: 'faqo' => 'FAQ-O-Matic Help system',
257: '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.',
258: 'lbug' => 'LON-CAPA Bugzilla bug/feature request tracking system',
259: '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.',
260: 'suim' => ' Suggested improvements may include additional functionality, improved usability, or changes to wording used in LON-CAPA pages, including the embedded help system.'
261: );
1.19 ! albertel 262: my $html=&Apache::lonxml::xmlbegin();
1.1 raeburn 263: $r->print(<<END);
1.19 ! albertel 264: $html
1.1 raeburn 265: <head>
1.8 raeburn 266: <title>$lt{'heco'}</title>
1.1 raeburn 267: </head>
268: $bodytag
269: END
1.8 raeburn 270: $r->print($lt{'chen'});
1.11 raeburn 271: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.8 raeburn 272: $r->print(', '.$lt{'orto'});
1.1 raeburn 273: } else {
274: $r->print(".");
275: }
276: if ($topic) {
277: if ( ($component_url) || ($ENV{'user.adv'}) ) {
278: if ($component_url) {
279: $r->print("
280: <ul>
1.8 raeburn 281: <li><a href=\"$component_url\">$lt{'vthp'} $topic</a></li>
1.1 raeburn 282: </ul>
1.8 raeburn 283: <p>$lt{'disp'}</p>
1.1 raeburn 284: ");
285: } elsif ($ENV{'user.adv'}) {
286: $r->print("
287: <ul>
1.8 raeburn 288: <li><td align=\"center\"> <a href=\"/adm/help/nohelptopic.html\">$lt{'inhs'} $topic</a></li></ul>
289: <p>$lt{'coth'}</p>");
1.1 raeburn 290: }
291: }
292: }
1.11 raeburn 293: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.1 raeburn 294: $r->print("
295: <ul>
1.9 raeburn 296: <li><a href=\"/adm/support?origurl=".&Apache::lonnet::escape($origurl)."&function=$function\">$lt{'cont'}</a></li>
1.1 raeburn 297: </ul>
1.18 raeburn 298: <p>$lt{'suhr'}");
299: unless ($ENV{'user.adv'}) {
300: $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.'));
301: }
302: $r->print("</p>");
1.1 raeburn 303: }
304: if ($faqbaseurl && $ENV{'user.adv'}) {
305: if (!defined($faq) ||$faq eq '') {
306: $faq = '1';
307: }
308: $r->print("
1.11 raeburn 309: <ul>
1.8 raeburn 310: <li><a href=\"$faqbaseurl/fom/cache/$faq.html\">$lt{'faqo'}</a></li>
1.1 raeburn 311: </ul>
1.8 raeburn 312: <p>$lt{'tfaq'}</p>
1.1 raeburn 313: ");
314: }
315: if ($bugurl && $ENV{'user.adv'}) {
316: $bugurl .= '?'.$bug;
317: $r->print("
318: <ul>
1.8 raeburn 319: <li><a href=\"$bugurl\">$lt{'lbug'}</a></li>
1.1 raeburn 320: </ul>
1.8 raeburn 321: <p>$lt{'crea'} $lt{'suim'}</p>
1.1 raeburn 322: ");
323: }
324: $r->print(<<END);
325: </body>
326: </html>
327: END
328: }
329:
330: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>