Diff for /loncom/interface/lonhelpmenu.pm between versions 1.28 and 1.46

version 1.28, 2006/06/26 22:09:01 version 1.46, 2018/05/08 01:19:06
Line 1 Line 1
 # The LearningOnline Network with CAPA  # The LearningOnline Network with CAPA
 # generate frame-based help system  # generate frame-based help system
 #  #
   # $Id$
   #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
Line 34  use Apache::lonlocal; Line 36  use Apache::lonlocal;
 use Apache::lonnet;  use Apache::lonnet;
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA;  use LONCAPA;
   use HTML::Entities();
   
 sub handler {  sub handler {
     my ($r) = @_;      my ($r) = @_;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['page','function','faq','bug','topic','component_help','origurl','stayonpage']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['page','faq','bug','topic','component_help','origurl','stayonpage']);
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
   
Line 47  sub handler { Line 50  sub handler {
     my $faq = $env{'form.faq'};      my $faq = $env{'form.faq'};
     my $bug = $env{'form.bug'};      my $bug = $env{'form.bug'};
     my $topic = $env{'form.topic'};      my $topic = $env{'form.topic'};
     my $function = $env{'form.function'};  
     my $component_help = $env{'form.component_help'};      my $component_help = $env{'form.component_help'};
     my $origurl = $env{'form.origurl'};      my $origurl = $env{'form.origurl'};
     my $stayOnPage = $env{'form.stayonpage'};      my $stayOnPage = $env{'form.stayonpage'};
Line 56  sub handler { Line 58  sub handler {
         $component_url = '/adm/help/'.$component_url.'.hlp';          $component_url = '/adm/help/'.$component_url.'.hlp';
     }      }
     my $bugurl = $Apache::lonnet::perlvar{'BugzillaHost'};      my $bugurl = $Apache::lonnet::perlvar{'BugzillaHost'};
     $bugurl .= 'enter_bug.cgi?product=LON-CAPA&bug_file_loc='.$origurl;      $bugurl .= 'enter_bug.cgi?product=LON-CAPA&bug_file_loc='.$origurl;
     if ($bug) {      if ($bug) {
         $bugurl .= '&component='.$bug;          $bugurl .= '&component='.$bug;
     }      }
     my $faqbaseurl = $Apache::lonnet::perlvar{'FAQHost'};      my $faqbaseurl = $Apache::lonnet::perlvar{'FAQHost'};
     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};      my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
       $origurl = &unescape($origurl);
       my $defdom;
       if ($env{'request.course.id'}) {
           $defdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
       } elsif ($env{'request.role.domain'}) {
           $defdom = $env{'request.role.domain'};
       } else {
           $defdom = &Apache::lonnet::default_login_domain();
       }
       my $requestmail = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
                                                                  $defdom,$origmail);
     if ($env{'form.page'} eq 'banner') {      if ($env{'form.page'} eq 'banner') {
         &display_help_banner($r,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);          &display_help_banner($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
     } elsif ($env{'form.page'} eq 'body') {      } elsif ($env{'form.page'} eq 'body') {
         &display_help_mainpage($r,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail);          &display_help_mainpage($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
     }      }
     return OK;      return OK;
 }  }
   
 sub display_help_banner {  sub display_help_banner {
     my ($r,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;      my ($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
     my $location=&Apache::loncommon::lonhttpdurl("/adm");      my $dom = $env{'request.role.domain'};
     my $scripttag = '';      my $scripttag = '';
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {      if ($requestmail) {
         my $displayurl = &escape($origurl);          my $displayurl = &escape($origurl);
         $scripttag = (<<"SCRIPT_ONE");          $scripttag = (<<"SCRIPT_ONE");
 <script>  <script type="text/javascript">
   // <![CDATA[
 function gohelpdesk() {  function gohelpdesk() {
     var actiontype = null;      var actiontype = null;
     try {      try {
         actiontype = parent.bodyframe.document.logproblem.action.value;          actiontype = parent.bodyframe.document.logproblem.action.value;
     }      }
     catch(error) {      catch(error) {
         parent.bodyframe.location = "/adm/support?origurl=$displayurl&function=$function";          parent.bodyframe.location = "/adm/support?origurl=$displayurl";
         return;          return;
     }      }
     if (actiontype) {      if (actiontype) {
Line 99  function gohelpdesk() { Line 113  function gohelpdesk() {
                 return;                  return;
             }              }
         }          }
         parent.bodyframe.location = "/adm/support?origurl=$displayurl&function=$function";          parent.bodyframe.location = "/adm/support?origurl=$displayurl";
         return;          return;
     }      }
 }  }
   
 SCRIPT_ONE  SCRIPT_ONE
         $scripttag .= (<<'SCRIPT_TWO');          $scripttag .= (<<'SCRIPT_TWO');
 function validmail(field) {  function validmail(field) {
Line 126  function validmail(field) { Line 141  function validmail(field) {
         return false;          return false;
     }      }
 }  }
   
   // ]]>
 </script>  </script>
 SCRIPT_TWO  SCRIPT_TWO
     }      }
   
     my %body_layout =       if ($stayOnPage) {
  ('rightmargin'  => "0",   $r->print(&Apache::loncommon::start_page('Help',$scripttag,
  'leftmargin'   => "0",           {'no_secondary_menu' => 1,}));
  'marginwidth'  => "0",      } else {
  'topmargin'    => "1",          $r->print(&Apache::loncommon::start_page('Help',$scripttag,
  'marginheight' => "1");                                                   {'only_body' => 1,}));
     my $start_page =       }
  &Apache::loncommon::start_page('',$scripttag,      my $menu = &helpmenu_items($dom,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
        {'function'    => $function,      if ($menu) {
  'add_entries' => \%body_layout,          $r->print("<ul id=\"LC_secondary_menu\">$menu</ul>");
  'only_body'   => 1,});      }
     $r->print($start_page);      if ($stayOnPage && $env{'user.adv'}) {
           $r->print('<br />');
     my $width = ($stayOnPage) ? '700' : '600';      } 
       $r->print(&Apache::loncommon::end_page());
     $r->print('<table id="LC_helpmenu" width="'.$width.'">');  }
   
     $r->print(<<END);  sub helpmenu_items {
   <tr height="50">      my ($dom,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
    <td width='5'>&nbsp;</td>      my $location=&Apache::loncommon::lonhttpdurl("/adm");
    <td>      my $general_help = &Apache::loncommon::general_help();
     <fieldset><legend><img src="$location/lonIcons/minilogo.gif" height='20' width='29' valign='bottom' />&nbsp;&nbsp;LON-CAPA help/support</legend>      my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);
  <table id="LC_helpmenu_links">      my %lt = &Apache::lonlocal::texthash(
    <tr>                                              general       => 'General help',
 END                                              component     => 'Topic help',
                                               faq           => 'FAQ',
                                               helpdesk      => 'Ask helpdesk',
                                               bugs          => 'Report a bug',
                                               manuals_web   => 'Online manuals',
                                               manuals_pdf   => 'Printable manuals',
                                               lastloc       => 'Go back',
                                               close         => 'Close',
                                            );
       my $target = '_top';
       if (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) {
           $target = '_parent';
       }
       my %items = (
                       general => {
                                    href => '/adm/help/'.$general_help.'.hlp',
                                    img  => $location.'/help/help.png',
                                    alt  => $lt{'general'},
                                    text => $lt{'general'},
                                  },
                       component => {
                                      href => $component_url,
                                      img  => $location.'/help/help.png',
                                      alt  => $lt{'component'},
                                      text => $topic,
                                    },
                       faq      => {
                                      href => $faqbaseurl.'fom/cache/'.$faq.'.html',
                                      img  => $location.'/lonMisc/smallFAQ.gif',
                                      alt  => $lt{'faq'},
                                      text => $lt{'faq'},                                   
                                    },
                       helpdesk => {
                                      href    => '#',
                                      onclick => 'gohelpdesk()',
                                      img  => $location.'/lonIcons/helpdesk.gif',    
                                      alt  => $lt{'helpdesk'},
                                      text => $lt{'helpdesk'},
                                   },
                       bugs     => {
                                      href => $bugurl,
                                      img  => $location.'/lonMisc/smallBug.gif', 
                                      alt  => $lt{'bugs'},
                                      text => $lt{'bugs'},
                                   },
                       manuals_web  => {
                                          href => '',
                                          img  => $location.'/lonIcons/html.gif',
                                          alt  => $lt{'manuals_web'},
                                          text => $lt{'manuals_web'},
                                       },
                       manuals_pdf  => {
                                          href => '',
                                          img  => $location.'/lonIcons/pdf.gif',
                                          alt  => $lt{'manuals_pdf'},
                                          text => $lt{'manuals_pdf'},
                                       },
                       lastloc  => {
                                      href   => &HTML::Entities::encode($origurl,'"&<>'),
                                      img    => '/res/adm/pages/tolastloc.png',
                                      alt    => $lt{'lastloc'},
                                      text   => $lt{'lastloc'},
                                      target => $target,
                                   },
                       close    => {
                                      href   => 'javascript:window.close()',
                                      img    => $location.'/lonIcons/close.gif',
                                      alt    => $lt{'close'},
                                      text   => $lt{'close'},
                                      target => $target,
                                   },
       );
       my %help_submenu = (
                              manuals_web => [
                                               ['/adm/help/course.manual.access.hlp','Course Coordination','course'],
                                               ['/adm/help/author.manual.access.hlp','Authoring','author'],
                                             ],
                              manuals_pdf => [
                                               ['/adm/help/course.manual.pdf','Course Coordination','course'],
                                               ['/adm/help/author.manual.pdf','Authoring','author'],
                                             ],
                          );
       my @order = ('general');
     if ($component_url) {      if ($component_url) {
  $r->print("<td><a href=\"$component_url\" target=\"bodyframe\">".          push(@order,'component');
   '<img src="'.$location.'/help/gif/smallHelp.gif" border="0" alt="(Topic help)" valign="middle" />&nbsp;Topic help</a>&nbsp;</td>');  
     }      }
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {      if ($requestmail) {
         $r->print('          push(@order,'helpdesk');
             <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>');      }
     }      if ($env{'user.adv'} && $faq) {
     if ($faq && $env{'user.adv'}) {          push(@order,'faq');
         $r->print(<<END);      }
             <td>      if (($env{'user.adv'}) && (($helpconfig{'helpsettings'}{'submitbugs'} eq '1') || ($helpconfig{'helpsettings'}{'submitbugs'} eq ''))) {
              &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;          push(@order,'bugs');
             </td>  
 END  
     }  
     if ($env{'user.adv'}) {  
         $r->print(<<END);  
             <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>  
 END  
     }      }
     if ($stayOnPage) {      if ($stayOnPage) {
         $r->print(<<END);          push(@order,('manuals_web','manuals_pdf','lastloc'));
             <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>  
 END  
     } else {      } else {
         $r->print(<<END);          push(@order,'close');
             <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>      }
 END      my $menu;
     }      foreach my $title (@order) {
     $r->print(<<END);          my $menuitem = $items{$title};
   </tr>          next unless (ref($menuitem) eq 'HASH');
  </table>          if (defined($help_submenu{$title})) {
 </fieldset>              my ($link,$target);
   </td>              if ($menuitem->{href} ne '') {
   <td width='5'>&nbsp;</td>                  $link = $menuitem->{href};
  </tr>                  $target = 'bodyframe';
  <tr height='5'>              } else {
   <td colspan='3' height='5'>&nbsp;</td>                  $link = '#';
  </tr>              }
 </table>              my @helpsub;
 END              if (ref($help_submenu{$title}) eq 'ARRAY') {
     $r->print(&Apache::loncommon::end_page());                  foreach my $item (@{$help_submenu{$title}}) {
                       if (ref($item) eq 'ARRAY') {
                           if (($item->[2] eq 'course') || ($item->[2] eq 'author')) {
                               next unless($env{'user.adv'});
                           }
                           push(@helpsub,$item);
                       }
                   }
                   if (@helpsub > 0) {
                       my $img;
                       if ($menuitem->{img}) {
                           $img = '<img class="LC_noBorder" style="vertical-align:top" src="'.$menuitem->{img}.'" alt="'.$menuitem->{alt}.'" />';
                       }
                       $menu .= &create_submenu($link,$img,$target,$menuitem->{text},\@helpsub,1);
                   } elsif ($link ne '#') {
                       $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.$menuitem->{text}.'</a></li>';
                   }
               }
           } else {
               $menu .= &build_menuitem($menuitem);
           }
       }
       return $menu;
   }
   
   sub build_menuitem {
       my ($menuitem) = @_;
       return '' unless(ref($menuitem) eq 'HASH');
       my $link;
       if ($menuitem->{img}) {
           $link = '<img style="vertical-align:top" class="LC_noBorder" src="'.$menuitem->{img}.'" alt="'.$menuitem->{alt}.'" />&nbsp;';
       }
       if ($menuitem->{text}) {
           $link .= $menuitem->{text};
       }
       my $target;
       if ($menuitem->{target}) {
           $target = $menuitem->{target};
       } else {
           $target = 'bodyframe';
       }
       my $onclick;
       if ($menuitem->{onclick}) {
           $onclick = ' onclick="'.$menuitem->{onclick}.';return false"';
       }
       return '<li><a href="'.$menuitem->{href}.'" target="'.$target.'"'.$onclick.'>'.$link.'</a></li>',
   }
   
   sub create_submenu {
       my ($link,$img,$target,$title,$submenu,$translate) = @_;
       return unless (ref($submenu) eq 'ARRAY');
       my $disptarget;
       if ($target ne '') {
           $disptarget = ' target="'.$target.'"';
       }
       my $menu = '<li class="LC_hoverable">'.$img.
                  '<a href="'.$link.'"'.$disptarget.'>'.
                  '<span class="LC_nobreak">'.$title.
                  '<span class="LC_fontsize_small" style="font-weight:normal;">'.
                  ' &#9660;</span></span></a>'.
                  '<ul>';
       my $count = 0;
       my $numsub = scalar(@{$submenu});
       foreach my $item (@{$submenu}) {
           $count ++;
           if (ref($item) eq 'ARRAY') {
               my $href = $item->[0];
               my $borderbot;
               if ($count == $numsub) {
                   $borderbot = 'border-bottom:1px solid black;';
               }
               $menu .= '<li style="margin:0;padding:0;'.
                        $borderbot.'"><a href="'.$href.'" target="bodyframe">';
               if ($translate) {
                   $menu .= &mt($item->[1]);
               } else {
                   $menu .= $item->[1];
               }
               $menu .= '</a></li>';
           }
       }
       $menu .= '</ul></li>';
       return $menu;
 }  }
   
 sub display_help_mainpage {  sub display_help_mainpage {
     my ($r,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail) = @_;      my ($r,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
   
     my %lt =&Apache::lonlocal::texthash(      my %lt =&Apache::lonlocal::texthash(
         'topp' => 'Topic Page',          'topp' => 'Topic Page',
Line 209  sub display_help_mainpage { Line 380  sub display_help_mainpage {
         'vthp' => 'Visit the help page for ',          'vthp' => 'Visit the help page for ',
         'disp' => 'Display the page in the inline help system that covers this topic.',          'disp' => 'Display the page in the inline help system that covers this topic.',
         '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.',          '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.',
         'inhs' => 'Topical help system for',  
  'noto' => 'There is no specific topical help item for',  
         'coth' => 'Consult the inline help system for this topic.',  
         'cont' => 'Contact the LON-CAPA support team',          'cont' => 'Contact the LON-CAPA support team',
         'suhr' => 'Submit a help request to the team responsible for LON-CAPA support at this institution.',          'suhr' => 'Submit a help request to the team responsible for LON-CAPA support at this institution.',
         'stuq' => 'Questions about course content should not be directed to the support team, but instead should be sent to the course instructor',  
         'faqo' => 'FAQ-O-Matic Help system',          'faqo' => 'FAQ-O-Matic Help system',
         '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.',          '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.',
         'lbug' => 'LON-CAPA Bugzilla bug/feature request tracking system',          'lbug' => 'LON-CAPA Bugzilla bug/feature request tracking system',
Line 222  sub display_help_mainpage { Line 389  sub display_help_mainpage {
         'suim' => ' Suggested improvements may include additional functionality, improved usability, or changes to wording used in LON-CAPA pages, including the embedded help system.'          'suim' => ' Suggested improvements may include additional functionality, improved usability, or changes to wording used in LON-CAPA pages, including the embedded help system.'
     );      );
   
     my %body_layout =       if ($stayOnPage) {
  ('topmargin'    => "0",   $r->print(&Apache::loncommon::start_page('Help Content',undef,
  'marginheight' => "0");                   {'no_secondary_menu' => 1,}));
     my $start_page =      } else {
  &Apache::loncommon::start_page('Help Content',undef,          $r->print(&Apache::loncommon::start_page('Help Content',undef,
        {'function'    => $function,                                                   {'only_body' => 1,}));
  'add_entries' => \%body_layout,      }
  'only_body'   => 1,});      my $target = '_top';
     $r->print($start_page);      if (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) {
     $r->print($lt{'chen'});          $target = '_parent';
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {      }
       if ($stayOnPage) {
           $r->print('<div>');
       } 
       $r->print('<b>'.$lt{'chen'});
       if ($requestmail) {
         $r->print(', '.$lt{'orto'});          $r->print(', '.$lt{'orto'});
     } else {      } else {
         $r->print(".");          $r->print(".");
     }      }
       $r->print('</b>');
     if ($topic) {      if ($topic) {
         if ( ($component_url) || ($env{'user.adv'}) ) {          if ( ($component_url) || ($env{'user.adv'}) ) {
             if ($component_url) {              if ($component_url) {
Line 246  sub display_help_mainpage { Line 419  sub display_help_mainpage {
           </ul>            </ul>
           <p>$lt{'disp'}</p>            <p>$lt{'disp'}</p>
                 ");                  ");
             } elsif ($env{'user.adv'}) {  
                 $r->print("  
               <ul>  
                <li><td align=\"center\">&nbsp;<a href=\"/adm/help/nohelptopic.html\">$lt{'noto'} $topic</a></li></ul>  
                <p>$lt{'coth'}</p>");  
             }              }
         }          }
     }      }
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {      if ($requestmail) {
         $r->print("          $r->print("
           <ul>            <ul>
            <li><a href=\"/adm/support?origurl=".&escape($origurl)."&function=$function\">$lt{'cont'}</a></li>             <li><a href=\"/adm/support?origurl=".&escape($origurl)."\">$lt{'cont'}</a></li>
           </ul>            </ul>
           <p>$lt{'suhr'}");            <p>$lt{'suhr'}");
          unless ($env{'user.adv'}) {           unless ($env{'user.adv'}) {
              $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.'));               $r->print('<br />'.
                          &mt('[_1]Note[_2]: questions about course content should not be directed to the support team, but instead should be sent to the course instructor.'). 
                          ' '.
                          &mt('This can be done by clicking the [_1]Communicate[_2] link or the "Send Feedback" link when viewing a content page.',
                             '<a href="/adm/communicate" target="'.$target.'">','</a>')); 
          }           }
          $r->print("</p>");           $r->print("</p>");
     }      }
Line 285  sub display_help_mainpage { Line 457  sub display_help_mainpage {
           <p>$lt{'crea'} $lt{'suim'}</p>            <p>$lt{'crea'} $lt{'suim'}</p>
         ");          ");
     }      }
       if ($stayOnPage) {
           $r->print('</div>');
       }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
 }  }
   

Removed from v.1.28  
changed lines
  Added in v.1.46


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