Annotation of loncom/interface/lonhelpmenu.pm, revision 1.24
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.20 albertel 34: use Apache::lonnet;
1.1 raeburn 35:
1.2 albertel 36: sub handler {
37: my ($r) = @_;
1.8 raeburn 38: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['page','color','function','faq','bug','topic','component_help','origurl','stayonpage']);
1.2 albertel 39: &Apache::loncommon::content_type($r,'text/html');
1.1 raeburn 40: $r->send_http_header;
41:
42: if ($r->header_only) {
43: return OK;
44: }
1.20 albertel 45: my $color = $env{'form.color'};
46: my $faq = $env{'form.faq'};
47: my $bug = $env{'form.bug'};
48: my $topic = $env{'form.topic'};
49: my $function = $env{'form.function'};
50: my $component_help = $env{'form.component_help'};
51: my $origurl = $env{'form.origurl'};
52: my $stayOnPage = $env{'form.stayonpage'};
1.1 raeburn 53: my $component_url = $component_help;
54: if ($component_url) {
55: $component_url = '/adm/help/'.$component_url.'.hlp';
56: }
57: my $bugurl = $Apache::lonnet::perlvar{'BugzillaHost'};
58: $bugurl .= 'enter_bug.cgi?product=LON-CAPA&bug_file_loc='.$origurl;
59: if ($bug) {
60: $bugurl .= '&component='.$bug;
61: }
62: my $faqbaseurl = $Apache::lonnet::perlvar{'FAQHost'};
63: my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
1.20 albertel 64: if ($env{'form.page'} eq 'banner') {
1.8 raeburn 65: &display_help_banner($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
1.20 albertel 66: } elsif ($env{'form.page'} eq 'body') {
1.3 albertel 67: &display_help_mainpage($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail);
1.1 raeburn 68: }
69: return OK;
70: }
71:
72: sub display_help_banner {
1.8 raeburn 73: my ($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
1.1 raeburn 74: my $fontcolor = &Apache::loncommon::designparm($function.'.font');
75: my $alinkcolor = &Apache::loncommon::designparm($function.'.alink');
76: my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink');
77: my $pagecolor = &Apache::loncommon::designparm($function.'.pgbg');
78: my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
1.14 albertel 79: my $location=&Apache::loncommon::lonhttpdurl("/adm");
1.8 raeburn 80: if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {
1.17 raeburn 81: $tablecolor = '#EEEE99';
1.8 raeburn 82: }
1.17 raeburn 83: my $scripttag = '';
84: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
85: my $displayurl = &Apache::lonnet::escape($origurl);
86: $scripttag = (<<"SCRIPT_ONE");
87: <script>
88: function gohelpdesk() {
89: var actiontype = null;
90: try {
91: actiontype = parent.bodyframe.document.logproblem.action.value;
92: }
93: catch(error) {
94: parent.bodyframe.location = "/adm/support?origurl=$displayurl&function=$function";
95: return;
96: }
97: if (actiontype) {
98: var loc = parent.bodyframe.location.href;
99: if (loc.indexOf("/adm/support") > -1) {
100: if (parent.bodyframe.document.logproblem.action.value == "process") {
101: if (validmail(parent.bodyframe.document.logproblem.email) == false) {
102: alert("The e-mail address you entered: "+parent.bodyframe.document.logproblem.email.value+" is not a valid e-mail address.");
103: return;
104: }
105: parent.bodyframe.document.logproblem.submit();
106: return;
107: }
108: }
109: parent.bodyframe.location = "/adm/support?origurl=$displayurl&function=$function";
110: return;
111: }
112: }
113: SCRIPT_ONE
114: $scripttag .= (<<'SCRIPT_TWO');
115: function validmail(field) {
116: var str = field.value;
117: if (window.RegExp) {
118: var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
1.22 albertel 119: var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"
1.17 raeburn 120: var reg1 = new RegExp(reg1str);
121: var reg2 = new RegExp(reg2str);
122: if (!reg1.test(str) && reg2.test(str)) {
123: return true;
124: }
125: return false;
126: }
127: else
128: {
1.8 raeburn 129:
1.17 raeburn 130: if(str.indexOf("@") >= 0) {
131: return true;
132: }
133: return false;
134: }
135: }
136: </script>
137: SCRIPT_TWO
138: }
1.22 albertel 139:
1.24 ! albertel 140: my %body_layout =
! 141: ('rightmargin' => "0",
! 142: 'leftmargin' => "0",
! 143: 'marginwidth' => "0",
! 144: 'topmargin' => "1",
! 145: 'marginheight' => "1");
1.22 albertel 146: my $start_page =
147: &Apache::loncommon::start_page('',$scripttag,
148: {'function' => $function,
1.24 ! albertel 149: 'add_entries' => \%body_layout,
1.22 albertel 150: 'only_body' => 1,});
151: $r->print($start_page);
152:
1.8 raeburn 153: if ($stayOnPage) {
154: $r->print('<table width="700" border="0" cellspacing="0" cellpadding="0" height="55">');
155: } else {
156: $r->print('<table width="600" border="0" cellspacing="0" cellpadding="0" height="55">');
157: }
158: $r->print(<<END);
1.1 raeburn 159: <tr height="50">
160: <td width='5'> </td>
161: <td>
1.12 albertel 162: <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 163: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
164: <tr>
165: <td>
166: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
167: <tr>
168: <td>
169: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
170: <tr>
171: <td>
172: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
173: <tr bgcolor="$tablecolor">
174: END
1.21 www 175: if ($component_url) {
176: $r->print("<td align=\"center\"><b><a href=\"$component_url\" target=\"bodyframe\">".
177: '<img src="'.$location.'/help/gif/smallHelp.gif" border="0" alt="(Topic help)" valign="middle" /> Topic help</a></b> </td>');
1.1 raeburn 178: }
1.11 raeburn 179: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.1 raeburn 180: $r->print('
1.17 raeburn 181: <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 182: }
1.20 albertel 183: if ($faq && $env{'user.adv'}) {
1.15 raeburn 184: $r->print(<<END);
1.1 raeburn 185: <td align="center">
1.13 albertel 186: <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 187: </td>
1.7 albertel 188: END
189: }
1.20 albertel 190: if ($env{'user.adv'}) {
1.15 raeburn 191: $r->print(<<END);
1.13 albertel 192: <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 193: END
194: }
1.8 raeburn 195: if ($stayOnPage) {
196: $r->print(<<END);
1.13 albertel 197: <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 198: END
199: } else {
200: $r->print(<<END);
1.13 albertel 201: <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 202: END
203: }
1.1 raeburn 204: $r->print(<<END);
205: </tr>
206: </table>
207: </td>
208: </tr>
209: </table>
210: </td>
211: </tr>
212: </table>
213: </td>
214: </tr>
215: </table>
216: </fieldset>
217: </td>
218: <td width='5'> </td>
219: </tr>
220: <tr height='5'>
221: <td colspan='3' height='5'> </td>
222: </tr>
223: </table>
224: END
1.22 albertel 225: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 226: }
227:
228: sub display_help_mainpage {
229: my ($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail) = @_;
1.22 albertel 230:
1.8 raeburn 231: my %lt =&Apache::lonlocal::texthash(
232: 'topp' => 'Topic Page',
233: 'chen' => 'Choose an entry below to go directly to a relevant help page',
234: 'orto' => 'or to submit a help request to the LON-CAPA support staff at your institution.',
235: 'vthp' => 'Visit the help page for ',
236: 'disp' => 'Display the page in the inline help system that covers this topic.',
237: '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.',
1.21 www 238: 'inhs' => 'Topical help system for',
239: 'noto' => 'There is no specific topical help item for',
1.8 raeburn 240: 'coth' => 'Consult the inline help system for this topic.',
241: 'cont' => 'Contact the LON-CAPA support team',
242: 'suhr' => 'Submit a help request to the team responsible for LON-CAPA support at this institution.',
1.18 raeburn 243: '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 244: 'faqo' => 'FAQ-O-Matic Help system',
245: '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.',
246: 'lbug' => 'LON-CAPA Bugzilla bug/feature request tracking system',
247: '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.',
248: 'suim' => ' Suggested improvements may include additional functionality, improved usability, or changes to wording used in LON-CAPA pages, including the embedded help system.'
249: );
1.22 albertel 250:
1.24 ! albertel 251: my %body_layout =
! 252: ('topmargin' => "0",
! 253: 'marginheight' => "0");
1.22 albertel 254: my $start_page =
255: &Apache::loncommon::start_page('Help Content',undef,
256: {'function' => $function,
1.24 ! albertel 257: 'add_entries' => \%body_layout,
1.22 albertel 258: 'only_body' => 1,});
259: $r->print($start_page);
1.8 raeburn 260: $r->print($lt{'chen'});
1.11 raeburn 261: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.8 raeburn 262: $r->print(', '.$lt{'orto'});
1.1 raeburn 263: } else {
264: $r->print(".");
265: }
266: if ($topic) {
1.20 albertel 267: if ( ($component_url) || ($env{'user.adv'}) ) {
1.1 raeburn 268: if ($component_url) {
269: $r->print("
270: <ul>
1.8 raeburn 271: <li><a href=\"$component_url\">$lt{'vthp'} $topic</a></li>
1.1 raeburn 272: </ul>
1.8 raeburn 273: <p>$lt{'disp'}</p>
1.1 raeburn 274: ");
1.20 albertel 275: } elsif ($env{'user.adv'}) {
1.1 raeburn 276: $r->print("
277: <ul>
1.21 www 278: <li><td align=\"center\"> <a href=\"/adm/help/nohelptopic.html\">$lt{'noto'} $topic</a></li></ul>
1.8 raeburn 279: <p>$lt{'coth'}</p>");
1.1 raeburn 280: }
281: }
282: }
1.11 raeburn 283: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.1 raeburn 284: $r->print("
285: <ul>
1.9 raeburn 286: <li><a href=\"/adm/support?origurl=".&Apache::lonnet::escape($origurl)."&function=$function\">$lt{'cont'}</a></li>
1.1 raeburn 287: </ul>
1.18 raeburn 288: <p>$lt{'suhr'}");
1.20 albertel 289: unless ($env{'user.adv'}) {
1.18 raeburn 290: $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.'));
291: }
292: $r->print("</p>");
1.1 raeburn 293: }
1.20 albertel 294: if ($faqbaseurl && $env{'user.adv'}) {
1.1 raeburn 295: if (!defined($faq) ||$faq eq '') {
296: $faq = '1';
297: }
298: $r->print("
1.11 raeburn 299: <ul>
1.8 raeburn 300: <li><a href=\"$faqbaseurl/fom/cache/$faq.html\">$lt{'faqo'}</a></li>
1.1 raeburn 301: </ul>
1.8 raeburn 302: <p>$lt{'tfaq'}</p>
1.1 raeburn 303: ");
304: }
1.20 albertel 305: if ($bugurl && $env{'user.adv'}) {
1.1 raeburn 306: $bugurl .= '?'.$bug;
307: $r->print("
308: <ul>
1.8 raeburn 309: <li><a href=\"$bugurl\">$lt{'lbug'}</a></li>
1.1 raeburn 310: </ul>
1.8 raeburn 311: <p>$lt{'crea'} $lt{'suim'}</p>
1.1 raeburn 312: ");
313: }
1.22 albertel 314: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 315: }
316:
317: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>