File:  [LON-CAPA] / loncom / interface / lonhelpmenu.pm
Revision 1.19: download - view: text, annotated - select for diffs
Thu Feb 17 08:29:42 2005 UTC (19 years, 4 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- <html> -> &Apache::lonxml::xmlbegin, thus valid doctypes are now getting output, Yeah! StandardsCmpliance

- backing out the encoding changes for now

- some xhtml cleanups
- one icon -> lonhttpd

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

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