File:  [LON-CAPA] / loncom / interface / lonhelpmenu.pm
Revision 1.18: download - view: text, annotated - select for diffs
Mon Dec 20 21:11:41 2004 UTC (19 years, 5 months ago) by raeburn
Branches: MAIN
CVS tags: version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, HEAD
Fix bug #3490.

    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();
   33: use Apache::lonlocal;
   34: 
   35: sub handler {
   36:     my ($r) = @_;
   37:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['page','color','function','faq','bug','topic','component_help','origurl','stayonpage']);
   38:     &Apache::loncommon::content_type($r,'text/html');
   39:     $r->send_http_header;
   40: 
   41:     if ($r->header_only) {
   42:         return OK;
   43:     }
   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'};
   50:     my $origurl = $ENV{'form.origurl'};
   51:     my $stayOnPage = $ENV{'form.stayonpage'};
   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') {
   64:         &display_help_banner($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
   65:     } elsif ($ENV{'form.page'} eq 'body') {
   66:         &display_help_mainpage($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail);
   67:     }
   68:     return OK;
   69: }
   70: 
   71: sub display_help_banner {
   72:     my ($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
   73:     my $bodytag = &Apache::loncommon::bodytag('',$function,'rightmargin="0" leftmargin="0" marginwidth="0" topmargin="1" marginheight="1"',1);
   74:     $bodytag=~s/[\n\r]/ /g;
   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');
   80:     my $location=&Apache::loncommon::lonhttpdurl("/adm");
   81:     if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {
   82:         $tablecolor = '#EEEE99';
   83:     }
   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:     {
  130: 
  131:         if(str.indexOf("@") >= 0) {
  132:             return true;
  133:         }
  134:         return false;
  135:     }
  136: }
  137: </script>
  138: SCRIPT_TWO
  139:     }
  140:     $r->print(<<END);
  141: <html>
  142: <head>
  143: <title>Help Banner</title>
  144: <style type="text/css">
  145: <!--
  146:  a:link {text-decoration: none; color: $fontcolor; }
  147:  a:visited {text-decoration: none; color: $fontcolor; }
  148:  a:active {text-decoration: none; color: $fontcolor; }
  149:  a:hover {text-decoration: underline; color: $vlinkcolor; }
  150: -->
  151: </style>
  152: $scripttag
  153: </head>
  154: $bodytag
  155: END
  156:     if ($stayOnPage) {
  157:         $r->print('<table width="700" border="0" cellspacing="0" cellpadding="0" height="55">');
  158:     } else {
  159:         $r->print('<table width="600" border="0" cellspacing="0" cellpadding="0" height="55">');
  160:     }
  161:     $r->print(<<END);
  162:   <tr height="50">
  163:    <td width='5'>&nbsp;</td>
  164:    <td>
  165:     <fieldset><legend><img src="$location/lonIcons/minilogo.gif" height='20' width='29' valign='bottom' />&nbsp;&nbsp;<b><font size="+1">LON-CAPA help/support</font></b></legend>
  166:  <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
  167:   <tr>
  168:    <td>
  169:     <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
  170:      <tr>
  171:       <td>
  172:        <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
  173:         <tr>
  174:          <td>
  175: 	  <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
  176:            <tr bgcolor="$tablecolor">
  177: END
  178:     if (($component_url) || ($ENV{'user.adv'})) {
  179:         if ($component_url) {
  180:             $r->print("
  181:             <td align=\"center\"><b><a href=\"$component_url\" target=\"bodyframe\">");
  182:         } elsif ($ENV{'user.adv'}) {
  183:             $r->print('<td align="center">&nbsp;<b><a href="/adm/help/nohelptopic.html" target="bodyframe">');
  184:         }
  185:         $r->print('
  186:   <img src="'.$location.'/help/gif/smallHelp.gif" border="0" alt="(Topic help)" valign="middle" />&nbsp;Topic help</a></b>&nbsp;</td>');
  187:     }
  188:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
  189:         $r->print('
  190:             <td align="center">&nbsp;<b><a href="javascript:gohelpdesk()"><img src="'.$location.'/lonIcons/helpdesk.gif" border="0" alt="(Ask helpdesk)" valign="middle" />&nbsp;Ask helpdesk</a></b>&nbsp;</td>');
  191:     }
  192:     if ($faq && $ENV{'user.adv'}) {
  193:         $r->print(<<END);
  194:             <td align="center">
  195:              &nbsp;<b><a href="$faqbaseurl/fom/cache/$faq.html" target="bodyframe"><img src="$location/lonMisc/smallFAQ.gif" border="0" alt="(FAQ)" valign="middle" />&nbsp;FAQ</a></b>&nbsp;
  196:             </td>
  197: END
  198:     }
  199:     if ($ENV{'user.adv'}) {
  200:         $r->print(<<END);
  201:             <td align="center">&nbsp;<b><a href="$bugurl" target="bodyframe"><img src="$location/lonMisc/smallBug.gif" border="0" alt="(Report a bug)" valign="middle" />&nbsp;Report a bug</a>&nbsp;</b></td>
  202: END
  203:     }
  204:     if ($stayOnPage) {
  205:         $r->print(<<END);
  206:             <td align="center">&nbsp;<b><a href="$origurl" target="_top"><img src="$location/lonIcons/move_up.gif" border="0" alt="(Return to last location)" valign="middle" />&nbsp;Return to last location</a></b>&nbsp;</td>
  207: END
  208:     } else {
  209:         $r->print(<<END);
  210:             <td align="center">&nbsp;<b><a href="javascript:window.close()" target="_top"><img src="$location/lonIcons/closepage.gif" border="0" alt="(Close window)" valign="bottom" />&nbsp;Close</a></b>&nbsp;</td>
  211: END
  212:     }
  213:     $r->print(<<END);
  214:            </tr>
  215:           </table>
  216:          </td>
  217:         </tr>
  218:        </table>
  219:       </td>
  220:      </tr>
  221:     </table>
  222:    </td>
  223:   </tr>
  224:  </table>
  225: </fieldset>
  226:   </td>
  227:   <td width='5'>&nbsp;</td>
  228:  </tr>
  229:  <tr height='5'>
  230:   <td colspan='3' height='5'>&nbsp;</td>
  231:  </tr>
  232: </table>
  233: </body>
  234: </html>
  235: END
  236: }
  237: 
  238: sub display_help_mainpage {
  239:     my ($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail) = @_;
  240:     my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0"',1);
  241:     $bodytag=~s/[\n\r]/ /g;
  242:     my %lt =&Apache::lonlocal::texthash(
  243:         'heco' => 'Help Content',
  244:         'topp' => 'Topic Page',
  245:         'chen' => 'Choose an entry below to go directly to a relevant help page',
  246:         'orto' => 'or to submit a help request to the LON-CAPA support staff at your institution.',
  247:         'vthp' => 'Visit the help page for ',
  248:         'disp' => 'Display the page in the inline help system that covers this topic.',
  249:         '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.',
  250:         'inhs' => 'Inline help system for',
  251:         'coth' => 'Consult the inline help system for this topic.',
  252:         'cont' => 'Contact the LON-CAPA support team',
  253:         'suhr' => 'Submit a help request to the team responsible for LON-CAPA support at this institution.',
  254:         'stuq' => 'Questions about course content should not be directed to the support team, but instead should be sent to the course instructor',
  255:         'faqo' => 'FAQ-O-Matic Help system',
  256:         '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.',
  257:         'lbug' => 'LON-CAPA Bugzilla bug/feature request tracking system',
  258:         '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.',
  259:         'suim' => ' Suggested improvements may include additional functionality, improved usability, or changes to wording used in LON-CAPA pages, including the embedded help system.'
  260:     );
  261: 
  262:     $r->print(<<END);
  263: <html>
  264:  <head>
  265:   <title>$lt{'heco'}</title>
  266:  </head>
  267: $bodytag
  268: END
  269:     $r->print($lt{'chen'});
  270:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
  271:         $r->print(', '.$lt{'orto'});
  272:     } else {
  273:         $r->print(".");
  274:     }
  275:     if ($topic) {
  276:         if ( ($component_url) || ($ENV{'user.adv'}) ) {
  277:             if ($component_url) {
  278:                 $r->print("
  279:           <ul>
  280:            <li><a href=\"$component_url\">$lt{'vthp'} $topic</a></li>
  281:           </ul>
  282:           <p>$lt{'disp'}</p>
  283:                 ");
  284:             } elsif ($ENV{'user.adv'}) {
  285:                 $r->print("
  286:               <ul>
  287:                <li><td align=\"center\">&nbsp;<a href=\"/adm/help/nohelptopic.html\">$lt{'inhs'} $topic</a></li></ul>
  288:                <p>$lt{'coth'}</p>");
  289:             }
  290:         }
  291:     }
  292:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
  293:         $r->print("
  294:           <ul>
  295:            <li><a href=\"/adm/support?origurl=".&Apache::lonnet::escape($origurl)."&function=$function\">$lt{'cont'}</a></li>
  296:           </ul>
  297:           <p>$lt{'suhr'}");
  298:          unless ($ENV{'user.adv'}) {
  299:              $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.'));
  300:          }
  301:          $r->print("</p>");
  302:     }
  303:     if ($faqbaseurl && $ENV{'user.adv'}) {
  304:         if (!defined($faq) ||$faq eq '') {
  305:             $faq = '1';
  306:         }
  307:         $r->print("
  308:           <ul>
  309:            <li><a href=\"$faqbaseurl/fom/cache/$faq.html\">$lt{'faqo'}</a></li>
  310:           </ul>
  311:           <p>$lt{'tfaq'}</p>
  312:         ");
  313:     }
  314:     if ($bugurl && $ENV{'user.adv'}) {
  315:         $bugurl .= '?'.$bug;
  316:         $r->print("
  317:           <ul>
  318:            <li><a href=\"$bugurl\">$lt{'lbug'}</a></li>
  319:           </ul>
  320:           <p>$lt{'crea'} $lt{'suim'}</p>
  321:         ");
  322:     }
  323:     $r->print(<<END);
  324:  </body>
  325: </html>
  326: END
  327: }
  328: 
  329: 1;

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