File:  [LON-CAPA] / loncom / interface / lonhelpmenu.pm
Revision 1.21: download - view: text, annotated - select for diffs
Fri Jun 3 15:47:29 2005 UTC (18 years, 11 months ago) by www
Branches: MAIN
CVS tags: version_2_1_X, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, version_1_99_1, version_1_99_0, HEAD
Bug #3751:
* if there is no topical help, don't send them to the "Missing Page"
* it there is topical help, respect it

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

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