File:  [LON-CAPA] / loncom / interface / lonhelpmenu.pm
Revision 1.23: download - view: text, annotated - select for diffs
Thu Mar 23 22:32:10 2006 UTC (18 years, 2 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
-start_page
-eliminate calls to bodytag in favor of start_page
- elimintate call to xmlbegin

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

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