Diff for /loncom/interface/lonhelpmenu.pm between versions 1.42 and 1.43

version 1.42, 2013/08/08 14:31:54 version 1.43, 2013/12/30 00:34:49
Line 62  sub handler { Line 62  sub handler {
         $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'};
       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,$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,$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;
 }  }
Line 75  sub display_help_banner { Line 85  sub display_help_banner {
     my ($r,$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 $location=&Apache::loncommon::lonhttpdurl("/adm");
     my $dom = $env{'request.role.domain'};      my $dom = $env{'request.role.domain'};
     my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);  
     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[  // <![CDATA[
 function gohelpdesk() {  function gohelpdesk() {
     var actiontype = null;      var actiontype = null;
Line 107  function gohelpdesk() { Line 116  function gohelpdesk() {
         return;          return;
     }      }
 }  }
   
 SCRIPT_ONE  SCRIPT_ONE
         $scripttag .= (<<'SCRIPT_TWO');          $scripttag .= (<<'SCRIPT_TWO');
 function validmail(field) {  function validmail(field) {
Line 130  function validmail(field) { Line 140  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('Help',$scripttag,      my $menu = &helpmenu_items($dom,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
  {'only_body'   => 1,});      if ($menu) {
     $r->print($start_page);          $r->print("<ul id=\"LC_secondary_menu\">$menu</ul>");
       }
     my $width = ($stayOnPage) ? '95%' : '600';      if ($stayOnPage && $env{'user.adv'}) {
     $r->print('<table id="LC_helpmenu" width="'.$width.'">');          $r->print('<br />');
       } 
       $r->print(&Apache::loncommon::end_page());
   }
   
   sub helpmenu_items {
       my ($dom,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage) = @_;
       my $location=&Apache::loncommon::lonhttpdurl("/adm");
     my $general_help = &Apache::loncommon::general_help();      my $general_help = &Apache::loncommon::general_help();
     $r->print('      my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);
   <tr>      my %lt = &Apache::lonlocal::texthash(
    <td width="5" height="50">&nbsp;</td>                                              general       => 'General help',
    <td>                                              component     => 'Topic help',
     <fieldset><legend><img src="'.$location.'/lonIcons/minilogo.gif" height="20" width="29" alt="('.&mt('LON-CAPA help/support').')" />&nbsp;&nbsp;'.&mt('LON-CAPA help/support').'</legend>                                              faq           => 'FAQ',
  <table id="LC_helpmenu_links">                                              helpdesk      => 'Ask helpdesk',
    <tr>                                              bugs          => 'Report a bug',
  <td><span class="LC_nobreak"><a href="/adm/help/'.$general_help.'.hlp" target="bodyframe">                                              manuals_web   => 'Online manuals',
   <img src="'.$location.'/help/help.png" border="0" alt="('.&mt('General help').')" />&nbsp;'.&mt('General Help').'</a>&nbsp;</span></td>');                                              manuals_pdf   => 'Printable manuals',
                                               lastloc       => 'Go back',
                                               close         => 'Close',
                                            );
       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   => $origurl,
                                      img    => '/res/adm/pages/tolastloc.png',
                                      alt    => $lt{'lastloc'},
                                      text   => $lt{'lastloc'},
                                      target => '_top',
                                   },
                       close    => {
                                      href   => 'javascript:window.close()',
                                      img    => $location.'/lonIcons/close.gif',
                                      alt    => $lt{'close'},
                                      text   => $lt{'close'},
                                      target => '_top',
                                   },
       );
       my %help_submenu = (
                              manuals_web => [
                                               ['/adm/help/course.manual.access.hlp','Course Coordination','course'],
                                               ['/adm/help/course.manual.access.hlp','Authoring','author'],
                                             ],
                              manuals_pdf => [
                                               ['/adm/help/course.manual.pdf','Course Coordination','course'],
                                               ['/adm/help/course.manual.pdf','Authoring','author'],
                                             ],
                          );
       my @order = ('general');
     if ($component_url) {      if ($component_url) {
  $r->print("<td><span class=\"LC_nobreak\"><a href=\"$component_url\" target=\"bodyframe\">".          push(@order,'component');
   '<img src="'.$location.'/help/help.png" border="0" alt="('.&mt('Topic help').')" />&nbsp;'.$topic.'</a>&nbsp;</span></td>');      }
       if ($requestmail) {
           push(@order,'helpdesk');
       }
       if ($env{'user.adv'} && $faq) {
           push(@order,'faq');
     }      }
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {      if (($env{'user.adv'}) && (($helpconfig{'helpsettings'}{'submitbugs'} eq '1') || ($helpconfig{'helpsettings'}{'submitbugs'} eq ''))) {
         $r->print('          push(@order,'bugs');
             <td><span class="LC_nobreak">&nbsp;<a href="javascript:gohelpdesk()"><img src="'.$location.'/lonIcons/helpdesk.gif" border="0" alt="('.&mt('Ask helpdesk').')" />&nbsp;'.&mt('Ask helpdesk').'</a>&nbsp;</span></td>');  
     }  
     if ($faq && $env{'user.adv'}) {  
         $r->print('  
              <td><span class="LC_nobreak">&nbsp;<a href="'.$faqbaseurl.'/fom/cache/'.$faq.'.html" target="bodyframe"><img src="'.$location.'/lonMisc/smallFAQ.gif" border="0" alt="('.&mt('FAQ').')" />&nbsp;'.&mt('FAQ').'</a>&nbsp;</span>  
             </td>');  
     }  
     if ($env{'user.adv'}) {  
     if ($helpconfig{'helpsettings'}{'submitbugs'} eq '1' ||  
     $helpconfig{'helpsettings'}{'submitbugs'} eq '' ) {  
         $r->print('  
             <td><span class="LC_nobreak">&nbsp;<b><a href="'.$bugurl.'" target="bodyframe"><img src="'.$location.'/lonMisc/smallBug.gif" border="0" alt="('.&mt('Report a bug').')" />&nbsp;'.&mt('Report a bug').'</a>&nbsp;</b></span></td>');  
  }  
     }      }
     if ($stayOnPage) {      if ($stayOnPage) {
         $r->print('          push(@order,('manuals_web','manuals_pdf','lastloc'));
             <td><span class="LC_nobreak">&nbsp;<a href="'.$origurl.'" target="_top"><img src="'.$location.'/lonIcons/move_up.gif" border="0" alt="('.&mt('Return to last location').')" />&nbsp;'.&mt('Return to last location').'</a>&nbsp;</span></td>');  
     } else {      } else {
         $r->print('          push(@order,'close');
             <td><span class="LC_nobreak">&nbsp;<a href="javascript:window.close()" target="_top"><img src="$location/lonIcons/closepage.gif" border="0" alt="('.&mt('Close window').')" />&nbsp;'.&mt('Close').'</a>&nbsp;</span></td>');  
     }      }
     $r->print(<<END);      my $menu;
   </tr>      foreach my $title (@order) {
  </table>          my $menuitem = $items{$title};
 </fieldset>          next unless (ref($menuitem) eq 'HASH');
   </td>          if (defined($help_submenu{$title})) {
   <td width='100%'>&nbsp;</td>              my ($link,$target);
  </tr>              if ($menuitem->{href} ne '') {
  <tr>                  $link = $menuitem->{href};
   <td colspan='3' height='5'>&nbsp;</td>                  $target = 'bodyframe';
  </tr>              } else {
 </table>                  $link = '#';
 END              }
     $r->print(&Apache::loncommon::end_page());              my @helpsub;
               if (ref($help_submenu{$title}) eq 'ARRAY') {
                   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,$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 220  sub display_help_mainpage { Line 384  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,
        {'add_entries' => \%body_layout,                                                   {'only_body' => 1,}));
  'only_body'   => 1,});      }
     $r->print($start_page);      if ($stayOnPage) {
           $r->print('<div>');
       } 
     $r->print('<b>'.$lt{'chen'});      $r->print('<b>'.$lt{'chen'});
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {      if ($requestmail) {
         $r->print(', '.$lt{'orto'});          $r->print(', '.$lt{'orto'});
     } else {      } else {
         $r->print(".");          $r->print(".");
Line 247  sub display_help_mainpage { Line 413  sub display_help_mainpage {
             }              }
         }          }
     }      }
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {      if ($requestmail) {
         $r->print("          $r->print("
           <ul>            <ul>
            <li><a href=\"/adm/support?origurl=".&escape($origurl)."\">$lt{'cont'}</a></li>             <li><a href=\"/adm/support?origurl=".&escape($origurl)."\">$lt{'cont'}</a></li>
Line 282  sub display_help_mainpage { Line 448  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.42  
changed lines
  Added in v.1.43


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