File:  [LON-CAPA] / loncom / interface / lonhelpmenu.pm
Revision 1.28: download - view: text, annotated - select for diffs
Mon Jun 26 22:09:01 2006 UTC (17 years, 11 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- moving dfont styling to css

    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: use lib '/home/httpd/lib/perl/';
   36: use LONCAPA;
   37: 
   38: sub handler {
   39:     my ($r) = @_;
   40:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['page','function','faq','bug','topic','component_help','origurl','stayonpage']);
   41:     &Apache::loncommon::content_type($r,'text/html');
   42:     $r->send_http_header;
   43: 
   44:     if ($r->header_only) {
   45:         return OK;
   46:     }
   47:     my $faq = $env{'form.faq'};
   48:     my $bug = $env{'form.bug'};
   49:     my $topic = $env{'form.topic'};
   50:     my $function = $env{'form.function'};
   51:     my $component_help = $env{'form.component_help'};
   52:     my $origurl = $env{'form.origurl'};
   53:     my $stayOnPage = $env{'form.stayonpage'};
   54:     my $component_url = $component_help;
   55:     if ($component_url) {
   56:         $component_url = '/adm/help/'.$component_url.'.hlp';
   57:     }
   58:     my $bugurl = $Apache::lonnet::perlvar{'BugzillaHost'};
   59:     $bugurl .= 'enter_bug.cgi?product=LON-CAPA&bug_file_loc='.$origurl;
   60:     if ($bug) {
   61:         $bugurl .= '&component='.$bug;
   62:     }
   63:     my $faqbaseurl = $Apache::lonnet::perlvar{'FAQHost'};
   64:     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
   65:     if ($env{'form.page'} eq 'banner') {
   66:         &display_help_banner($r,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
   67:     } elsif ($env{'form.page'} eq 'body') {
   68:         &display_help_mainpage($r,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail);
   69:     }
   70:     return OK;
   71: }
   72: 
   73: sub display_help_banner {
   74:     my ($r,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
   75:     my $location=&Apache::loncommon::lonhttpdurl("/adm");
   76:     my $scripttag = '';
   77:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
   78:         my $displayurl = &escape($origurl);
   79:         $scripttag = (<<"SCRIPT_ONE");
   80: <script>
   81: function gohelpdesk() {
   82:     var actiontype = null;
   83:     try {
   84:         actiontype = parent.bodyframe.document.logproblem.action.value;
   85:     }
   86:     catch(error) {
   87:         parent.bodyframe.location = "/adm/support?origurl=$displayurl&function=$function";
   88:         return;
   89:     }
   90:     if (actiontype) {
   91:         var loc = parent.bodyframe.location.href;
   92:         if (loc.indexOf("/adm/support") > -1) {
   93:             if (parent.bodyframe.document.logproblem.action.value == "process") {
   94:                 if (validmail(parent.bodyframe.document.logproblem.email) == false) {
   95:                     alert("The e-mail address you entered: "+parent.bodyframe.document.logproblem.email.value+" is not a valid e-mail address.");
   96:                     return;
   97:                 }
   98:                 parent.bodyframe.document.logproblem.submit();
   99:                 return;
  100:             }
  101:         }
  102:         parent.bodyframe.location = "/adm/support?origurl=$displayurl&function=$function";
  103:         return;
  104:     }
  105: }
  106: SCRIPT_ONE
  107:         $scripttag .= (<<'SCRIPT_TWO');
  108: function validmail(field) {
  109:     var str = field.value;
  110:     if (window.RegExp) {
  111:         var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
  112:         var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"
  113:         var reg1 = new RegExp(reg1str);
  114:         var reg2 = new RegExp(reg2str);
  115:         if (!reg1.test(str) && reg2.test(str)) {
  116:             return true;
  117:         }
  118:         return false;
  119:     }
  120:     else
  121:     {
  122: 
  123:         if(str.indexOf("@") >= 0) {
  124:             return true;
  125:         }
  126:         return false;
  127:     }
  128: }
  129: </script>
  130: SCRIPT_TWO
  131:     }
  132: 
  133:     my %body_layout = 
  134: 	('rightmargin'  => "0",
  135: 	 'leftmargin'   => "0",
  136: 	 'marginwidth'  => "0",
  137: 	 'topmargin'    => "1",
  138: 	 'marginheight' => "1");
  139:     my $start_page = 
  140: 	&Apache::loncommon::start_page('',$scripttag,
  141: 				       {'function'    => $function,
  142: 					'add_entries' => \%body_layout,
  143: 					'only_body'   => 1,});
  144:     $r->print($start_page);
  145: 
  146:     my $width = ($stayOnPage) ? '700' : '600';
  147: 
  148:     $r->print('<table id="LC_helpmenu" width="'.$width.'">');
  149: 
  150:     $r->print(<<END);
  151:   <tr height="50">
  152:    <td width='5'>&nbsp;</td>
  153:    <td>
  154:     <fieldset><legend><img src="$location/lonIcons/minilogo.gif" height='20' width='29' valign='bottom' />&nbsp;&nbsp;LON-CAPA help/support</legend>
  155:  <table id="LC_helpmenu_links">
  156:    <tr>
  157: END
  158:     if ($component_url) {
  159: 	$r->print("<td><a href=\"$component_url\" target=\"bodyframe\">".
  160: 		  '<img src="'.$location.'/help/gif/smallHelp.gif" border="0" alt="(Topic help)" valign="middle" />&nbsp;Topic help</a>&nbsp;</td>');
  161:     }
  162:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
  163:         $r->print('
  164:             <td>&nbsp;<a href="javascript:gohelpdesk()"><img src="'.$location.'/lonIcons/helpdesk.gif" border="0" alt="(Ask helpdesk)" valign="middle" />&nbsp;Ask helpdesk</a>&nbsp;</td>');
  165:     }
  166:     if ($faq && $env{'user.adv'}) {
  167:         $r->print(<<END);
  168:             <td>
  169:              &nbsp;<a href="$faqbaseurl/fom/cache/$faq.html" target="bodyframe"><img src="$location/lonMisc/smallFAQ.gif" border="0" alt="(FAQ)" valign="middle" />&nbsp;FAQ</a>&nbsp;
  170:             </td>
  171: END
  172:     }
  173:     if ($env{'user.adv'}) {
  174:         $r->print(<<END);
  175:             <td>&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>
  176: END
  177:     }
  178:     if ($stayOnPage) {
  179:         $r->print(<<END);
  180:             <td>&nbsp;<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>&nbsp;</td>
  181: END
  182:     } else {
  183:         $r->print(<<END);
  184:             <td>&nbsp;<a href="javascript:window.close()" target="_top"><img src="$location/lonIcons/closepage.gif" border="0" alt="(Close window)" valign="bottom" />&nbsp;Close</a>&nbsp;</td>
  185: END
  186:     }
  187:     $r->print(<<END);
  188:   </tr>
  189:  </table>
  190: </fieldset>
  191:   </td>
  192:   <td width='5'>&nbsp;</td>
  193:  </tr>
  194:  <tr height='5'>
  195:   <td colspan='3' height='5'>&nbsp;</td>
  196:  </tr>
  197: </table>
  198: END
  199:     $r->print(&Apache::loncommon::end_page());
  200: }
  201: 
  202: sub display_help_mainpage {
  203:     my ($r,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail) = @_;
  204: 
  205:     my %lt =&Apache::lonlocal::texthash(
  206:         'topp' => 'Topic Page',
  207:         'chen' => 'Choose an entry below to go directly to a relevant help page',
  208:         'orto' => 'or to submit a help request to the LON-CAPA support staff at your institution.',
  209:         'vthp' => 'Visit the help page for ',
  210:         'disp' => 'Display the page in the inline help system that covers this topic.',
  211:         '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.',
  212:         'inhs' => 'Topical help system for',
  213: 	'noto' => 'There is no specific topical help item for',
  214:         'coth' => 'Consult the inline help system for this topic.',
  215:         'cont' => 'Contact the LON-CAPA support team',
  216:         'suhr' => 'Submit a help request to the team responsible for LON-CAPA support at this institution.',
  217:         'stuq' => 'Questions about course content should not be directed to the support team, but instead should be sent to the course instructor',
  218:         'faqo' => 'FAQ-O-Matic Help system',
  219:         '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.',
  220:         'lbug' => 'LON-CAPA Bugzilla bug/feature request tracking system',
  221:         '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.',
  222:         'suim' => ' Suggested improvements may include additional functionality, improved usability, or changes to wording used in LON-CAPA pages, including the embedded help system.'
  223:     );
  224: 
  225:     my %body_layout = 
  226: 	('topmargin'    => "0",
  227: 	 'marginheight' => "0");
  228:     my $start_page =
  229: 	&Apache::loncommon::start_page('Help Content',undef,
  230: 				       {'function'    => $function,
  231: 					'add_entries' => \%body_layout,
  232: 					'only_body'   => 1,});
  233:     $r->print($start_page);
  234:     $r->print($lt{'chen'});
  235:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
  236:         $r->print(', '.$lt{'orto'});
  237:     } else {
  238:         $r->print(".");
  239:     }
  240:     if ($topic) {
  241:         if ( ($component_url) || ($env{'user.adv'}) ) {
  242:             if ($component_url) {
  243:                 $r->print("
  244:           <ul>
  245:            <li><a href=\"$component_url\">$lt{'vthp'} $topic</a></li>
  246:           </ul>
  247:           <p>$lt{'disp'}</p>
  248:                 ");
  249:             } elsif ($env{'user.adv'}) {
  250:                 $r->print("
  251:               <ul>
  252:                <li><td align=\"center\">&nbsp;<a href=\"/adm/help/nohelptopic.html\">$lt{'noto'} $topic</a></li></ul>
  253:                <p>$lt{'coth'}</p>");
  254:             }
  255:         }
  256:     }
  257:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
  258:         $r->print("
  259:           <ul>
  260:            <li><a href=\"/adm/support?origurl=".&escape($origurl)."&function=$function\">$lt{'cont'}</a></li>
  261:           </ul>
  262:           <p>$lt{'suhr'}");
  263:          unless ($env{'user.adv'}) {
  264:              $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.'));
  265:          }
  266:          $r->print("</p>");
  267:     }
  268:     if ($faqbaseurl && $env{'user.adv'}) {
  269:         if (!defined($faq) ||$faq eq '') {
  270:             $faq = '1';
  271:         }
  272:         $r->print("
  273:           <ul>
  274:            <li><a href=\"$faqbaseurl/fom/cache/$faq.html\">$lt{'faqo'}</a></li>
  275:           </ul>
  276:           <p>$lt{'tfaq'}</p>
  277:         ");
  278:     }
  279:     if ($bugurl && $env{'user.adv'}) {
  280:         $bugurl .= '?'.$bug;
  281:         $r->print("
  282:           <ul>
  283:            <li><a href=\"$bugurl\">$lt{'lbug'}</a></li>
  284:           </ul>
  285:           <p>$lt{'crea'} $lt{'suim'}</p>
  286:         ");
  287:     }
  288:     $r->print(&Apache::loncommon::end_page());
  289: }
  290: 
  291: 1;

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