Annotation of loncom/interface/lonhelpmenu.pm, revision 1.34
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.25 www 35: use lib '/home/httpd/lib/perl/';
36: use LONCAPA;
1.1 raeburn 37:
1.2 albertel 38: sub handler {
39: my ($r) = @_;
1.29 albertel 40: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['page','faq','bug','topic','component_help','origurl','stayonpage']);
1.2 albertel 41: &Apache::loncommon::content_type($r,'text/html');
1.1 raeburn 42: $r->send_http_header;
43:
44: if ($r->header_only) {
45: return OK;
46: }
1.20 albertel 47: my $faq = $env{'form.faq'};
48: my $bug = $env{'form.bug'};
49: my $topic = $env{'form.topic'};
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.29 albertel 65: &display_help_banner($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
1.20 albertel 66: } elsif ($env{'form.page'} eq 'body') {
1.29 albertel 67: &display_help_mainpage($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail);
1.1 raeburn 68: }
69: return OK;
70: }
71:
72: sub display_help_banner {
1.29 albertel 73: my ($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
1.14 albertel 74: my $location=&Apache::loncommon::lonhttpdurl("/adm");
1.17 raeburn 75: my $scripttag = '';
76: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.25 www 77: my $displayurl = &escape($origurl);
1.17 raeburn 78: $scripttag = (<<"SCRIPT_ONE");
79: <script>
80: function gohelpdesk() {
81: var actiontype = null;
82: try {
83: actiontype = parent.bodyframe.document.logproblem.action.value;
84: }
85: catch(error) {
1.29 albertel 86: parent.bodyframe.location = "/adm/support?origurl=$displayurl";
1.17 raeburn 87: return;
88: }
89: if (actiontype) {
90: var loc = parent.bodyframe.location.href;
91: if (loc.indexOf("/adm/support") > -1) {
92: if (parent.bodyframe.document.logproblem.action.value == "process") {
93: if (validmail(parent.bodyframe.document.logproblem.email) == false) {
94: alert("The e-mail address you entered: "+parent.bodyframe.document.logproblem.email.value+" is not a valid e-mail address.");
95: return;
96: }
97: parent.bodyframe.document.logproblem.submit();
98: return;
99: }
100: }
1.29 albertel 101: parent.bodyframe.location = "/adm/support?origurl=$displayurl";
1.17 raeburn 102: return;
103: }
104: }
105: SCRIPT_ONE
106: $scripttag .= (<<'SCRIPT_TWO');
107: function validmail(field) {
108: var str = field.value;
109: if (window.RegExp) {
110: var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
1.22 albertel 111: var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"
1.17 raeburn 112: var reg1 = new RegExp(reg1str);
113: var reg2 = new RegExp(reg2str);
114: if (!reg1.test(str) && reg2.test(str)) {
115: return true;
116: }
117: return false;
118: }
119: else
120: {
1.8 raeburn 121:
1.17 raeburn 122: if(str.indexOf("@") >= 0) {
123: return true;
124: }
125: return false;
126: }
127: }
128: </script>
129: SCRIPT_TWO
130: }
1.22 albertel 131:
1.24 albertel 132: my %body_layout =
133: ('rightmargin' => "0",
134: 'leftmargin' => "0",
135: 'marginwidth' => "0",
136: 'topmargin' => "1",
137: 'marginheight' => "1");
1.22 albertel 138: my $start_page =
139: &Apache::loncommon::start_page('',$scripttag,
1.29 albertel 140: {'add_entries' => \%body_layout,
1.22 albertel 141: 'only_body' => 1,});
142: $r->print($start_page);
143:
1.32 albertel 144: my $width = ($stayOnPage) ? '95%' : '600';
1.27 albertel 145: $r->print('<table id="LC_helpmenu" width="'.$width.'">');
146:
1.31 albertel 147: my $general_help = &Apache::loncommon::general_help();
1.8 raeburn 148: $r->print(<<END);
1.1 raeburn 149: <tr height="50">
150: <td width='5'> </td>
151: <td>
1.27 albertel 152: <fieldset><legend><img src="$location/lonIcons/minilogo.gif" height='20' width='29' valign='bottom' /> LON-CAPA help/support</legend>
1.26 albertel 153: <table id="LC_helpmenu_links">
154: <tr>
1.33 raeburn 155: <td><span class="LC_nobreak"><a href="/adm/help/$general_help.hlp" target="bodyframe">
1.34 ! www 156: <img src="/res/adm/pages/help.png" border="0" alt="(General help)" valign="middle" /> General Help</a> </span></td>
1.1 raeburn 157: END
1.21 www 158: if ($component_url) {
1.33 raeburn 159: $r->print("<td><span class=\"LC_nobreak\"><a href=\"$component_url\" target=\"bodyframe\">".
1.34 ! www 160: '<img src="/res/adm/pages/help.png" border="0" alt="(Topic help)" valign="middle" /> '.$topic.'</a> </span></td>');
1.1 raeburn 161: }
1.11 raeburn 162: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.1 raeburn 163: $r->print('
1.33 raeburn 164: <td><span class="LC_nobreak"> <a href="javascript:gohelpdesk()"><img src="'.$location.'/lonIcons/helpdesk.gif" border="0" alt="(Ask helpdesk)" valign="middle" /> Ask helpdesk</a> </span></td>');
1.1 raeburn 165: }
1.20 albertel 166: if ($faq && $env{'user.adv'}) {
1.15 raeburn 167: $r->print(<<END);
1.33 raeburn 168: <td><span class="LC_nobreak"> <a href="$faqbaseurl/fom/cache/$faq.html" target="bodyframe"><img src="$location/lonMisc/smallFAQ.gif" border="0" alt="(FAQ)" valign="middle" /> FAQ</a> </span>
1.1 raeburn 169: </td>
1.7 albertel 170: END
171: }
1.20 albertel 172: if ($env{'user.adv'}) {
1.15 raeburn 173: $r->print(<<END);
1.33 raeburn 174: <td><span class="LC_nobreak" <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></span></td>
1.1 raeburn 175: END
176: }
1.8 raeburn 177: if ($stayOnPage) {
178: $r->print(<<END);
1.33 raeburn 179: <td><span class="LC_nobreak"> <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> </span></td>
1.8 raeburn 180: END
181: } else {
182: $r->print(<<END);
1.33 raeburn 183: <td><span class="LC_nobreak" <a href="javascript:window.close()" target="_top"><img src="$location/lonIcons/closepage.gif" border="0" alt="(Close window)" valign="bottom" /> Close</a> </span></td>
1.8 raeburn 184: END
185: }
1.1 raeburn 186: $r->print(<<END);
187: </tr>
188: </table>
189: </fieldset>
190: </td>
1.33 raeburn 191: <td width='100%'> </td>
1.1 raeburn 192: </tr>
193: <tr height='5'>
194: <td colspan='3' height='5'> </td>
195: </tr>
196: </table>
197: END
1.22 albertel 198: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 199: }
200:
201: sub display_help_mainpage {
1.29 albertel 202: my ($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail) = @_;
1.22 albertel 203:
1.8 raeburn 204: my %lt =&Apache::lonlocal::texthash(
205: 'topp' => 'Topic Page',
206: 'chen' => 'Choose an entry below to go directly to a relevant help page',
207: 'orto' => 'or to submit a help request to the LON-CAPA support staff at your institution.',
208: 'vthp' => 'Visit the help page for ',
209: 'disp' => 'Display the page in the inline help system that covers this topic.',
210: '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 211: 'inhs' => 'Topical help system for',
1.8 raeburn 212: 'cont' => 'Contact the LON-CAPA support team',
213: 'suhr' => 'Submit a help request to the team responsible for LON-CAPA support at this institution.',
1.18 raeburn 214: '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 215: 'faqo' => 'FAQ-O-Matic Help system',
216: '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.',
217: 'lbug' => 'LON-CAPA Bugzilla bug/feature request tracking system',
218: '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.',
219: 'suim' => ' Suggested improvements may include additional functionality, improved usability, or changes to wording used in LON-CAPA pages, including the embedded help system.'
220: );
1.22 albertel 221:
1.24 albertel 222: my %body_layout =
223: ('topmargin' => "0",
224: 'marginheight' => "0");
1.22 albertel 225: my $start_page =
226: &Apache::loncommon::start_page('Help Content',undef,
1.29 albertel 227: {'add_entries' => \%body_layout,
1.22 albertel 228: 'only_body' => 1,});
229: $r->print($start_page);
1.30 www 230: $r->print('<b>'.$lt{'chen'});
1.11 raeburn 231: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.8 raeburn 232: $r->print(', '.$lt{'orto'});
1.1 raeburn 233: } else {
234: $r->print(".");
235: }
1.30 www 236: $r->print('</b>');
1.1 raeburn 237: if ($topic) {
1.20 albertel 238: if ( ($component_url) || ($env{'user.adv'}) ) {
1.1 raeburn 239: if ($component_url) {
240: $r->print("
241: <ul>
1.8 raeburn 242: <li><a href=\"$component_url\">$lt{'vthp'} $topic</a></li>
1.1 raeburn 243: </ul>
1.8 raeburn 244: <p>$lt{'disp'}</p>
1.1 raeburn 245: ");
246: }
247: }
248: }
1.11 raeburn 249: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.1 raeburn 250: $r->print("
251: <ul>
1.29 albertel 252: <li><a href=\"/adm/support?origurl=".&escape($origurl)."\">$lt{'cont'}</a></li>
1.1 raeburn 253: </ul>
1.18 raeburn 254: <p>$lt{'suhr'}");
1.20 albertel 255: unless ($env{'user.adv'}) {
1.18 raeburn 256: $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.'));
257: }
258: $r->print("</p>");
1.1 raeburn 259: }
1.20 albertel 260: if ($faqbaseurl && $env{'user.adv'}) {
1.1 raeburn 261: if (!defined($faq) ||$faq eq '') {
262: $faq = '1';
263: }
264: $r->print("
1.11 raeburn 265: <ul>
1.8 raeburn 266: <li><a href=\"$faqbaseurl/fom/cache/$faq.html\">$lt{'faqo'}</a></li>
1.1 raeburn 267: </ul>
1.8 raeburn 268: <p>$lt{'tfaq'}</p>
1.1 raeburn 269: ");
270: }
1.20 albertel 271: if ($bugurl && $env{'user.adv'}) {
1.1 raeburn 272: $bugurl .= '?'.$bug;
273: $r->print("
274: <ul>
1.8 raeburn 275: <li><a href=\"$bugurl\">$lt{'lbug'}</a></li>
1.1 raeburn 276: </ul>
1.8 raeburn 277: <p>$lt{'crea'} $lt{'suim'}</p>
1.1 raeburn 278: ");
279: }
1.22 albertel 280: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 281: }
282:
283: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>