File:  [LON-CAPA] / loncom / interface / lonhelpmenu.pm
Revision 1.41: download - view: text, annotated - select for diffs
Fri Jul 19 17:11:09 2013 UTC (10 years, 10 months ago) by bisitz
Branches: MAIN
CVS tags: HEAD
Internationalization: Added missing &mt() calls and corresponding phrases

    1: # The LearningOnline Network with CAPA
    2: # generate frame-based help system
    3: #
    4: # $Id: lonhelpmenu.pm,v 1.41 2013/07/19 17:11:09 bisitz Exp $
    5: #
    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();
   35: use Apache::lonlocal;
   36: use Apache::lonnet;
   37: use lib '/home/httpd/lib/perl/';
   38: use LONCAPA;
   39: 
   40: sub handler {
   41:     my ($r) = @_;
   42:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['page','faq','bug','topic','component_help','origurl','stayonpage']);
   43:     &Apache::loncommon::content_type($r,'text/html');
   44:     $r->send_http_header;
   45: 
   46:     if ($r->header_only) {
   47:         return OK;
   48:     }
   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'};
   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'};
   60:     $bugurl .= 'enter_bug.cgi?product=LON-CAPA&bug_file_loc='.$origurl;
   61:     if ($bug) {
   62:         $bugurl .= '&component='.$bug;
   63:     }
   64:     my $faqbaseurl = $Apache::lonnet::perlvar{'FAQHost'};
   65:     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
   66:     if ($env{'form.page'} eq 'banner') {
   67:         &display_help_banner($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
   68:     } elsif ($env{'form.page'} eq 'body') {
   69:         &display_help_mainpage($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail);
   70:     }
   71:     return OK;
   72: }
   73: 
   74: sub display_help_banner {
   75:     my ($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
   76:     my $location=&Apache::loncommon::lonhttpdurl("/adm");
   77:     my $dom = $env{'request.role.domain'};
   78:     my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);
   79:     my $scripttag = '';
   80:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
   81:         my $displayurl = &escape($origurl);
   82:         $scripttag = (<<"SCRIPT_ONE");
   83: <script>
   84: function gohelpdesk() {
   85:     var actiontype = null;
   86:     try {
   87:         actiontype = parent.bodyframe.document.logproblem.action.value;
   88:     }
   89:     catch(error) {
   90:         parent.bodyframe.location = "/adm/support?origurl=$displayurl";
   91:         return;
   92:     }
   93:     if (actiontype) {
   94:         var loc = parent.bodyframe.location.href;
   95:         if (loc.indexOf("/adm/support") > -1) {
   96:             if (parent.bodyframe.document.logproblem.action.value == "process") {
   97:                 if (validmail(parent.bodyframe.document.logproblem.email) == false) {
   98:                     alert("The e-mail address you entered: "+parent.bodyframe.document.logproblem.email.value+" is not a valid e-mail address.");
   99:                     return;
  100:                 }
  101:                 parent.bodyframe.document.logproblem.submit();
  102:                 return;
  103:             }
  104:         }
  105:         parent.bodyframe.location = "/adm/support?origurl=$displayurl";
  106:         return;
  107:     }
  108: }
  109: SCRIPT_ONE
  110:         $scripttag .= (<<'SCRIPT_TWO');
  111: function validmail(field) {
  112:     var str = field.value;
  113:     if (window.RegExp) {
  114:         var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
  115:         var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"
  116:         var reg1 = new RegExp(reg1str);
  117:         var reg2 = new RegExp(reg2str);
  118:         if (!reg1.test(str) && reg2.test(str)) {
  119:             return true;
  120:         }
  121:         return false;
  122:     }
  123:     else
  124:     {
  125: 
  126:         if(str.indexOf("@") >= 0) {
  127:             return true;
  128:         }
  129:         return false;
  130:     }
  131: }
  132: </script>
  133: SCRIPT_TWO
  134:     }
  135: 
  136:     my %body_layout = 
  137: 	('rightmargin'  => "0",
  138: 	 'leftmargin'   => "0",
  139: 	 'marginwidth'  => "0",
  140: 	 'topmargin'    => "1",
  141: 	 'marginheight' => "1");
  142:     my $start_page = 
  143: 	&Apache::loncommon::start_page('',$scripttag,
  144: 				       {'add_entries' => \%body_layout,
  145: 					'only_body'   => 1,});
  146:     $r->print($start_page);
  147: 
  148:     my $width = ($stayOnPage) ? '95%' : '600';
  149:     $r->print('<table id="LC_helpmenu" width="'.$width.'">');
  150: 
  151:     my $general_help = &Apache::loncommon::general_help();
  152:     $r->print('
  153:   <tr height="50">
  154:    <td width="5">&nbsp;</td>
  155:    <td>
  156:     <fieldset><legend><img src="'.$location.'/lonIcons/minilogo.gif" height="20" width="29" valign="bottom" alt="('.&mt('LON-CAPA help/support').')" />&nbsp;&nbsp;'.&mt('LON-CAPA help/support').'</legend>
  157:  <table id="LC_helpmenu_links">
  158:    <tr>
  159: 	<td><span class="LC_nobreak"><a href="/adm/help/'.$general_help.'.hlp" target="bodyframe">
  160: 		  <img src="'.$location.'/help/help.png" border="0" alt="('.&mt('General help').')" valign="middle" />&nbsp;'.&mt('General Help').'</a>&nbsp;</span></td>');
  161:     if ($component_url) {
  162: 	$r->print("<td><span class=\"LC_nobreak\"><a href=\"$component_url\" target=\"bodyframe\">".
  163: 		  '<img src="'.$location.'/help/help.png" border="0" alt="('.&mt('Topic help').')" valign="middle" />&nbsp;'.$topic.'</a>&nbsp;</span></td>');
  164:     }
  165:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
  166:         $r->print('
  167:             <td><span class="LC_nobreak">&nbsp;<a href="javascript:gohelpdesk()"><img src="'.$location.'/lonIcons/helpdesk.gif" border="0" alt="('.&mt('Ask helpdesk').')" valign="middle" />&nbsp;'.&mt('Ask helpdesk').'</a>&nbsp;</span></td>');
  168:     }
  169:     if ($faq && $env{'user.adv'}) {
  170:         $r->print('
  171:              <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').')" valign="middle" />&nbsp;'.&mt('FAQ').'</a>&nbsp;</span>
  172:             </td>');
  173:     }
  174:     if ($env{'user.adv'}) {
  175:     	if ($helpconfig{'helpsettings'}{'submitbugs'} eq '1' ||
  176:     		$helpconfig{'helpsettings'}{'submitbugs'} eq '' ) {
  177:         	$r->print('
  178:             	<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').')" valign="middle" />&nbsp;'.&mt('Report a bug').'</a>&nbsp;</b></span></td>');
  179: 		}
  180:     }
  181:     if ($stayOnPage) {
  182:         $r->print('
  183:             <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').')" valign="middle" />&nbsp;'.&mt('Return to last location').'</a>&nbsp;</span></td>');
  184:     } else {
  185:         $r->print('
  186:             <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').')" valign="bottom" />&nbsp;'.&mt('Close').'</a>&nbsp;</span></td>');
  187:     }
  188:     $r->print(<<END);
  189:   </tr>
  190:  </table>
  191: </fieldset>
  192:   </td>
  193:   <td width='100%'>&nbsp;</td>
  194:  </tr>
  195:  <tr height='5'>
  196:   <td colspan='3' height='5'>&nbsp;</td>
  197:  </tr>
  198: </table>
  199: END
  200:     $r->print(&Apache::loncommon::end_page());
  201: }
  202: 
  203: sub display_help_mainpage {
  204:     my ($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail) = @_;
  205: 
  206:     my %lt =&Apache::lonlocal::texthash(
  207:         'topp' => 'Topic Page',
  208:         'chen' => 'Choose an entry below to go directly to a relevant help page',
  209:         'orto' => 'or to submit a help request to the LON-CAPA support staff at your institution.',
  210:         'vthp' => 'Visit the help page for ',
  211:         'disp' => 'Display the page in the inline help system that covers this topic.',
  212:         '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.',
  213:         'cont' => 'Contact the LON-CAPA support team',
  214:         'suhr' => 'Submit a help request to the team responsible for LON-CAPA support at this institution.',
  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:     );
  221: 
  222:     my %body_layout = 
  223: 	('topmargin'    => "0",
  224: 	 'marginheight' => "0");
  225:     my $start_page =
  226: 	&Apache::loncommon::start_page('Help Content',undef,
  227: 				       {'add_entries' => \%body_layout,
  228: 					'only_body'   => 1,});
  229:     $r->print($start_page);
  230:     $r->print('<b>'.$lt{'chen'});
  231:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
  232:         $r->print(', '.$lt{'orto'});
  233:     } else {
  234:         $r->print(".");
  235:     }
  236:     $r->print('</b>');
  237:     if ($topic) {
  238:         if ( ($component_url) || ($env{'user.adv'}) ) {
  239:             if ($component_url) {
  240:                 $r->print("
  241:           <ul>
  242:            <li><a href=\"$component_url\">$lt{'vthp'} $topic</a></li>
  243:           </ul>
  244:           <p>$lt{'disp'}</p>
  245:                 ");
  246:             }
  247:         }
  248:     }
  249:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
  250:         $r->print("
  251:           <ul>
  252:            <li><a href=\"/adm/support?origurl=".&escape($origurl)."\">$lt{'cont'}</a></li>
  253:           </ul>
  254:           <p>$lt{'suhr'}");
  255:          unless ($env{'user.adv'}) {
  256:              $r->print('<br />'.
  257:                        &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.'). 
  258:                        ' '.
  259:                        &mt('This can be done by clicking the [_1]Communicate[_2] link or the "Send Feedback" link when viewing a content page.',
  260:                           '<a href="/adm/communicate" target="_top">','</a>')); 
  261:          }
  262:          $r->print("</p>");
  263:     }
  264:     if ($faqbaseurl && $env{'user.adv'}) {
  265:         if (!defined($faq) ||$faq eq '') {
  266:             $faq = '1';
  267:         }
  268:         $r->print("
  269:           <ul>
  270:            <li><a href=\"$faqbaseurl/fom/cache/$faq.html\">$lt{'faqo'}</a></li>
  271:           </ul>
  272:           <p>$lt{'tfaq'}</p>
  273:         ");
  274:     }
  275:     if ($bugurl && $env{'user.adv'}) {
  276:         $bugurl .= '?'.$bug;
  277:         $r->print("
  278:           <ul>
  279:            <li><a href=\"$bugurl\">$lt{'lbug'}</a></li>
  280:           </ul>
  281:           <p>$lt{'crea'} $lt{'suim'}</p>
  282:         ");
  283:     }
  284:     $r->print(&Apache::loncommon::end_page());
  285: }
  286: 
  287: 1;

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