Annotation of loncom/interface/lonhelpmenu.pm, revision 1.42

1.1       raeburn     1: # The LearningOnline Network with CAPA
                      2: # generate frame-based help system
                      3: #
1.42    ! raeburn     4: # $Id: lonhelpmenu.pm,v 1.41 2013/07/19 17:11:09 bisitz Exp $
1.37      bisitz      5: #
1.1       raeburn     6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: package Apache::lonhelpmenu;
                     30: 
                     31: use strict;
                     32: use lib qw(/home/httpd/lib/perl);
                     33: use Apache::Constants qw(:common);
                     34: use Apache::loncommon();
1.18      raeburn    35: use Apache::lonlocal;
1.20      albertel   36: use Apache::lonnet;
1.25      www        37: use lib '/home/httpd/lib/perl/';
                     38: use LONCAPA;
1.1       raeburn    39: 
1.2       albertel   40: sub handler {
                     41:     my ($r) = @_;
1.29      albertel   42:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['page','faq','bug','topic','component_help','origurl','stayonpage']);
1.2       albertel   43:     &Apache::loncommon::content_type($r,'text/html');
1.1       raeburn    44:     $r->send_http_header;
                     45: 
                     46:     if ($r->header_only) {
                     47:         return OK;
                     48:     }
1.20      albertel   49:     my $faq = $env{'form.faq'};
                     50:     my $bug = $env{'form.bug'};
                     51:     my $topic = $env{'form.topic'};
                     52:     my $component_help = $env{'form.component_help'};
                     53:     my $origurl = $env{'form.origurl'};
                     54:     my $stayOnPage = $env{'form.stayonpage'};
1.1       raeburn    55:     my $component_url = $component_help;
                     56:     if ($component_url) {
                     57:         $component_url = '/adm/help/'.$component_url.'.hlp';
                     58:     }
                     59:     my $bugurl = $Apache::lonnet::perlvar{'BugzillaHost'};
1.42    ! raeburn    60:     $bugurl .= 'enter_bug.cgi?product=LON-CAPA&bug_file_loc='.$origurl;
1.1       raeburn    61:     if ($bug) {
1.42    ! raeburn    62:         $bugurl .= '&component='.$bug;
1.1       raeburn    63:     }
                     64:     my $faqbaseurl = $Apache::lonnet::perlvar{'FAQHost'};
                     65:     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
1.20      albertel   66:     if ($env{'form.page'} eq 'banner') {
1.29      albertel   67:         &display_help_banner($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
1.20      albertel   68:     } elsif ($env{'form.page'} eq 'body') {
1.29      albertel   69:         &display_help_mainpage($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail);
1.1       raeburn    70:     }
                     71:     return OK;
                     72: }
                     73: 
                     74: sub display_help_banner {
1.29      albertel   75:     my ($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
1.14      albertel   76:     my $location=&Apache::loncommon::lonhttpdurl("/adm");
1.38      jms        77:     my $dom = $env{'request.role.domain'};
1.39      jms        78:     my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);
1.17      raeburn    79:     my $scripttag = '';
                     80:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.25      www        81:         my $displayurl = &escape($origurl);
1.17      raeburn    82:         $scripttag = (<<"SCRIPT_ONE");
                     83: <script>
1.42    ! raeburn    84: // <![CDATA[
1.17      raeburn    85: function gohelpdesk() {
                     86:     var actiontype = null;
                     87:     try {
                     88:         actiontype = parent.bodyframe.document.logproblem.action.value;
                     89:     }
                     90:     catch(error) {
1.29      albertel   91:         parent.bodyframe.location = "/adm/support?origurl=$displayurl";
1.17      raeburn    92:         return;
                     93:     }
                     94:     if (actiontype) {
                     95:         var loc = parent.bodyframe.location.href;
                     96:         if (loc.indexOf("/adm/support") > -1) {
                     97:             if (parent.bodyframe.document.logproblem.action.value == "process") {
                     98:                 if (validmail(parent.bodyframe.document.logproblem.email) == false) {
                     99:                     alert("The e-mail address you entered: "+parent.bodyframe.document.logproblem.email.value+" is not a valid e-mail address.");
                    100:                     return;
                    101:                 }
                    102:                 parent.bodyframe.document.logproblem.submit();
                    103:                 return;
                    104:             }
                    105:         }
1.29      albertel  106:         parent.bodyframe.location = "/adm/support?origurl=$displayurl";
1.17      raeburn   107:         return;
                    108:     }
                    109: }
                    110: SCRIPT_ONE
                    111:         $scripttag .= (<<'SCRIPT_TWO');
                    112: function validmail(field) {
                    113:     var str = field.value;
                    114:     if (window.RegExp) {
                    115:         var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
1.22      albertel  116:         var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"
1.17      raeburn   117:         var reg1 = new RegExp(reg1str);
                    118:         var reg2 = new RegExp(reg2str);
                    119:         if (!reg1.test(str) && reg2.test(str)) {
                    120:             return true;
                    121:         }
                    122:         return false;
                    123:     }
                    124:     else
                    125:     {
1.8       raeburn   126: 
1.17      raeburn   127:         if(str.indexOf("@") >= 0) {
                    128:             return true;
                    129:         }
                    130:         return false;
                    131:     }
                    132: }
1.42    ! raeburn   133: // ]]>
1.17      raeburn   134: </script>
                    135: SCRIPT_TWO
                    136:     }
1.22      albertel  137: 
1.24      albertel  138:     my %body_layout = 
                    139: 	('rightmargin'  => "0",
                    140: 	 'leftmargin'   => "0",
                    141: 	 'marginwidth'  => "0",
                    142: 	 'topmargin'    => "1",
                    143: 	 'marginheight' => "1");
1.22      albertel  144:     my $start_page = 
1.42    ! raeburn   145: 	&Apache::loncommon::start_page('Help',$scripttag,
        !           146: 					{'only_body'   => 1,});
1.22      albertel  147:     $r->print($start_page);
                    148: 
1.32      albertel  149:     my $width = ($stayOnPage) ? '95%' : '600';
1.27      albertel  150:     $r->print('<table id="LC_helpmenu" width="'.$width.'">');
                    151: 
1.31      albertel  152:     my $general_help = &Apache::loncommon::general_help();
1.41      bisitz    153:     $r->print('
1.42    ! raeburn   154:   <tr>
        !           155:    <td width="5" height="50">&nbsp;</td>
1.1       raeburn   156:    <td>
1.42    ! raeburn   157:     <fieldset><legend><img src="'.$location.'/lonIcons/minilogo.gif" height="20" width="29" alt="('.&mt('LON-CAPA help/support').')" />&nbsp;&nbsp;'.&mt('LON-CAPA help/support').'</legend>
1.26      albertel  158:  <table id="LC_helpmenu_links">
                    159:    <tr>
1.41      bisitz    160: 	<td><span class="LC_nobreak"><a href="/adm/help/'.$general_help.'.hlp" target="bodyframe">
1.42    ! raeburn   161: 		  <img src="'.$location.'/help/help.png" border="0" alt="('.&mt('General help').')" />&nbsp;'.&mt('General Help').'</a>&nbsp;</span></td>');
1.21      www       162:     if ($component_url) {
1.33      raeburn   163: 	$r->print("<td><span class=\"LC_nobreak\"><a href=\"$component_url\" target=\"bodyframe\">".
1.42    ! raeburn   164: 		  '<img src="'.$location.'/help/help.png" border="0" alt="('.&mt('Topic help').')" />&nbsp;'.$topic.'</a>&nbsp;</span></td>');
1.1       raeburn   165:     }
1.11      raeburn   166:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.1       raeburn   167:         $r->print('
1.42    ! raeburn   168:             <td><span class="LC_nobreak">&nbsp;<a href="javascript:gohelpdesk()"><img src="'.$location.'/lonIcons/helpdesk.gif" border="0" alt="('.&mt('Ask helpdesk').')" />&nbsp;'.&mt('Ask helpdesk').'</a>&nbsp;</span></td>');
1.1       raeburn   169:     }
1.20      albertel  170:     if ($faq && $env{'user.adv'}) {
1.41      bisitz    171:         $r->print('
1.42    ! raeburn   172:              <td><span class="LC_nobreak">&nbsp;<a href="'.$faqbaseurl.'/fom/cache/'.$faq.'.html" target="bodyframe"><img src="'.$location.'/lonMisc/smallFAQ.gif" border="0" alt="('.&mt('FAQ').')" />&nbsp;'.&mt('FAQ').'</a>&nbsp;</span>
1.41      bisitz    173:             </td>');
1.7       albertel  174:     }
1.20      albertel  175:     if ($env{'user.adv'}) {
1.39      jms       176:     	if ($helpconfig{'helpsettings'}{'submitbugs'} eq '1' ||
                    177:     		$helpconfig{'helpsettings'}{'submitbugs'} eq '' ) {
1.41      bisitz    178:         	$r->print('
1.42    ! raeburn   179:             	<td><span class="LC_nobreak">&nbsp;<b><a href="'.$bugurl.'" target="bodyframe"><img src="'.$location.'/lonMisc/smallBug.gif" border="0" alt="('.&mt('Report a bug').')" />&nbsp;'.&mt('Report a bug').'</a>&nbsp;</b></span></td>');
1.38      jms       180: 		}
1.1       raeburn   181:     }
1.8       raeburn   182:     if ($stayOnPage) {
1.41      bisitz    183:         $r->print('
1.42    ! raeburn   184:             <td><span class="LC_nobreak">&nbsp;<a href="'.$origurl.'" target="_top"><img src="'.$location.'/lonIcons/move_up.gif" border="0" alt="('.&mt('Return to last location').')" />&nbsp;'.&mt('Return to last location').'</a>&nbsp;</span></td>');
1.8       raeburn   185:     } else {
1.41      bisitz    186:         $r->print('
1.42    ! raeburn   187:             <td><span class="LC_nobreak">&nbsp;<a href="javascript:window.close()" target="_top"><img src="$location/lonIcons/closepage.gif" border="0" alt="('.&mt('Close window').')" />&nbsp;'.&mt('Close').'</a>&nbsp;</span></td>');
1.8       raeburn   188:     }
1.1       raeburn   189:     $r->print(<<END);
                    190:   </tr>
                    191:  </table>
                    192: </fieldset>
                    193:   </td>
1.33      raeburn   194:   <td width='100%'>&nbsp;</td>
1.1       raeburn   195:  </tr>
1.42    ! raeburn   196:  <tr>
1.1       raeburn   197:   <td colspan='3' height='5'>&nbsp;</td>
                    198:  </tr>
                    199: </table>
                    200: END
1.22      albertel  201:     $r->print(&Apache::loncommon::end_page());
1.1       raeburn   202: }
                    203: 
                    204: sub display_help_mainpage {
1.29      albertel  205:     my ($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail) = @_;
1.22      albertel  206: 
1.8       raeburn   207:     my %lt =&Apache::lonlocal::texthash(
                    208:         'topp' => 'Topic Page',
                    209:         'chen' => 'Choose an entry below to go directly to a relevant help page',
                    210:         'orto' => 'or to submit a help request to the LON-CAPA support staff at your institution.',
                    211:         'vthp' => 'Visit the help page for ',
                    212:         'disp' => 'Display the page in the inline help system that covers this topic.',
                    213:         '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.',
                    214:         'cont' => 'Contact the LON-CAPA support team',
                    215:         'suhr' => 'Submit a help request to the team responsible for LON-CAPA support at this institution.',
                    216:         'faqo' => 'FAQ-O-Matic Help system',
                    217:         '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.',
                    218:         'lbug' => 'LON-CAPA Bugzilla bug/feature request tracking system',
                    219:         '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.',
                    220:         'suim' => ' Suggested improvements may include additional functionality, improved usability, or changes to wording used in LON-CAPA pages, including the embedded help system.'
                    221:     );
1.22      albertel  222: 
1.24      albertel  223:     my %body_layout = 
                    224: 	('topmargin'    => "0",
                    225: 	 'marginheight' => "0");
1.22      albertel  226:     my $start_page =
                    227: 	&Apache::loncommon::start_page('Help Content',undef,
1.29      albertel  228: 				       {'add_entries' => \%body_layout,
1.22      albertel  229: 					'only_body'   => 1,});
                    230:     $r->print($start_page);
1.30      www       231:     $r->print('<b>'.$lt{'chen'});
1.11      raeburn   232:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.8       raeburn   233:         $r->print(', '.$lt{'orto'});
1.1       raeburn   234:     } else {
                    235:         $r->print(".");
                    236:     }
1.30      www       237:     $r->print('</b>');
1.1       raeburn   238:     if ($topic) {
1.20      albertel  239:         if ( ($component_url) || ($env{'user.adv'}) ) {
1.1       raeburn   240:             if ($component_url) {
                    241:                 $r->print("
                    242:           <ul>
1.8       raeburn   243:            <li><a href=\"$component_url\">$lt{'vthp'} $topic</a></li>
1.1       raeburn   244:           </ul>
1.8       raeburn   245:           <p>$lt{'disp'}</p>
1.1       raeburn   246:                 ");
                    247:             }
                    248:         }
                    249:     }
1.11      raeburn   250:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
1.1       raeburn   251:         $r->print("
                    252:           <ul>
1.29      albertel  253:            <li><a href=\"/adm/support?origurl=".&escape($origurl)."\">$lt{'cont'}</a></li>
1.1       raeburn   254:           </ul>
1.18      raeburn   255:           <p>$lt{'suhr'}");
1.20      albertel  256:          unless ($env{'user.adv'}) {
1.40      raeburn   257:              $r->print('<br />'.
                    258:                        &mt('[_1]Note[_2]: questions about course content should not be directed to the support team, but instead should be sent to the course instructor.'). 
                    259:                        ' '.
                    260:                        &mt('This can be done by clicking the [_1]Communicate[_2] link or the "Send Feedback" link when viewing a content page.',
                    261:                           '<a href="/adm/communicate" target="_top">','</a>')); 
1.18      raeburn   262:          }
                    263:          $r->print("</p>");
1.1       raeburn   264:     }
1.20      albertel  265:     if ($faqbaseurl && $env{'user.adv'}) {
1.1       raeburn   266:         if (!defined($faq) ||$faq eq '') {
                    267:             $faq = '1';
                    268:         }
                    269:         $r->print("
1.11      raeburn   270:           <ul>
1.8       raeburn   271:            <li><a href=\"$faqbaseurl/fom/cache/$faq.html\">$lt{'faqo'}</a></li>
1.1       raeburn   272:           </ul>
1.8       raeburn   273:           <p>$lt{'tfaq'}</p>
1.1       raeburn   274:         ");
                    275:     }
1.20      albertel  276:     if ($bugurl && $env{'user.adv'}) {
1.1       raeburn   277:         $bugurl .= '?'.$bug;
                    278:         $r->print("
                    279:           <ul>
1.8       raeburn   280:            <li><a href=\"$bugurl\">$lt{'lbug'}</a></li>
1.1       raeburn   281:           </ul>
1.8       raeburn   282:           <p>$lt{'crea'} $lt{'suim'}</p>
1.1       raeburn   283:         ");
                    284:     }
1.22      albertel  285:     $r->print(&Apache::loncommon::end_page());
1.1       raeburn   286: }
                    287: 
                    288: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>