Diff for /loncom/interface/lonmenu.pm between versions 1.240 and 1.252

version 1.240, 2008/09/04 22:47:20 version 1.252, 2009/02/13 20:20:30
Line 36 Line 36
 # browser.interface is 'textual'  # browser.interface is 'textual'
 #  #
   
   =head1 NAME
   
   Apache::lonmenu
   
   =head1 SYNOPSIS
   
   Coordinates the response to clicking an image.
   
   This is part of the LearningOnline Network with CAPA project
   described at http://www.lon-capa.org.
   
   =head1 SUBROUTINES
   
   =over
   
   =item show_course()
   
   Little texts
   
   =item initlittle()
   
   =item menubuttons()
   
   This gets called at the top of the body section
   
   =item show_return_link()
   
   =item registerurl()
   
   This gets called in the header section
   
   =item innerregister()
   
   This gets called in order to register a URL, both with the Remote
   and in the body of the document
   
   =item loadevents()
   
   =item unloadevents()
   
   =item startupremote()
   
   =item setflags()
   
   =item maincall()
   
   =item load_remote_msg()
   
   =item get_menu_name()
   
   =item reopenmenu()
   
   =item open()
   
   Open the menu
   
   =item clear()
   
   =item switch()
   
   Switch a button or create a link
   Switch acts on the javascript that is executed when a button is clicked.  
   The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
   
   =item secondlevel()
   
   =item openmenu()
   
   =item inlinemenu()
   
   =item rawconfig()
   
   =item close()
   
   =item footer()
   
   =item utilityfunctions()
   
   =item serverform()
   
   =item constspaceform()
   
   =item get_nav_status()
   
   =item convert_menu_function()
   
   FIXME this needs to move into mydesktab and the other locations 
   the text is generated
   
   =item hidden_button_check()
   
   =item roles_selector()
   
   =item jump_to_role()
   
   =back
   
   =cut
   
 package Apache::lonmenu;  package Apache::lonmenu;
   
 use strict;  use strict;
Line 53  my @inlineremote; Line 152  my @inlineremote;
   
   
   
 # ================================================================ Little texts  
 sub show_course {  sub show_course {
     my $course = !$env{'user.adv'};      my $course = !$env{'user.adv'};
     if (!$env{'user.adv'}) {      if (!$env{'user.adv'}) {
Line 84  sub initlittle { Line 182  sub initlittle {
                                        );                                         );
 }  }
   
 # ============================= This gets called at the top of the body section  
   
 sub menubuttons {  sub menubuttons {
     my $forcereg=shift;      my $forcereg=shift;
     my $registration=shift;      my $registration=shift;
Line 111  sub menubuttons { Line 207  sub menubuttons {
   
     my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");      my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
     $logo = '<td class="LC_top_nav_logo"><a href="/adm/about.html"><img src="'.      $logo = '<td class="LC_top_nav_logo"><a href="/adm/about.html"><img src="'.
  $logo.'" alt="LON-CAPA Logo" /></a></td>';   $logo.'" alt="LON-CAPA Logo" class="LC_noBorder" /></a></td>';
   
     if ($env{'request.state'} eq 'construct') {      if ($env{'request.state'} eq 'construct') {
         if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {          if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
Line 203  ENDMAINMENU Line 299  ENDMAINMENU
      </td>       </td>
     </tr>      </tr>
   </table>    </table>
 </font>  
 ENDINLINEMENU  ENDINLINEMENU
         }          }
         $roles = '<td><a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a></td>';          $roles = '<td><a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a></td>';
Line 251  ENDCRELOAD Line 346  ENDCRELOAD
         }          }
         my $form=&serverform();          my $form=&serverform();
  my $utility=&utilityfunctions();   my $utility=&utilityfunctions();
  my $remote;  
  if ($env{'user.adv'}) {  
     $remote = '<td><a href="/adm/remote?action=launch&amp;url='.$escurl.'" target="_top">'.$lt{'launch'}.'</a></td>'  
  }  
   
         my $helplink=&Apache::loncommon::top_nav_help('Help');          my $helplink=&Apache::loncommon::top_nav_help('Help');
  return (<<ENDINLINEMENU);   return (<<ENDINLINEMENU);
Line 272  $reloadlink Line 363  $reloadlink
 $navmaps  $navmaps
 $docs  $docs
 $groups  $groups
 $remote  
 $roles  $roles
 <td class="LC_top_nav_help">$helplink</td>  <td style="width: 2.0em;">$helplink</td>
 <td class="LC_top_nav_exit"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td>  <td style="width: 2.0em;"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td>
 </tr>  </tr>
 </table>  </table>
 $form  $form
Line 302  sub show_return_link { Line 392  sub show_return_link {
      ));       ));
 }  }
   
 # ====================================== This gets called in the header section  
   
 sub registerurl {  sub registerurl {
     my ($forcereg) = @_;      my ($forcereg) = @_;
Line 327  sub registerurl { Line 416  sub registerurl {
     return $result.$force_title;      return $result.$force_title;
 }  }
   
 # =========== This gets called in order to register a URL, both with the Remote  
 # =========== and in the body of the document  
   
 sub innerregister {  sub innerregister {
     my ($forcereg, $titletable) = @_;      my ($forcereg, $titletable) = @_;
     my $result = '';      my $result = '';
Line 519  c&8&1 Line 605  c&8&1
 c&8&2  c&8&2
 s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document  s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
 s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1  s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
 s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&&1  
 ENDMENUITEMS  ENDMENUITEMS
   
   my $currentURL = &Apache::loncommon::get_symb();
   my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
   my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
   $menuitems.="s&9&3&";
   if(length($annotation) > 0){
    $menuitems.="anot2.gif";
   }else{
    $menuitems.="anot.gif";
   }
   $menuitems.="&anno-[_1]&tations[_1]&annotate()&";
   $menuitems.="Make notes and annotations about this resource&&1\n";
   
             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {              unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
  if (!$env{'request.enc'}) {   if (!$env{'request.enc'}) {
     $menuitems.=(<<ENDREALRES);      $menuitems.=(<<ENDREALRES);
Line 721  sub unloadevents() { Line 818  sub unloadevents() {
     return 'LONCAPAstale();';      return 'LONCAPAstale();';
 }  }
   
 # ============================================================= Start up remote  
   
 sub startupremote {  sub startupremote {
     my ($lowerurl)=@_;      my ($lowerurl)=@_;
Line 835  sub get_menu_name { Line 931  sub get_menu_name {
     return 'LCmenu'.$hostid;      return 'LCmenu'.$hostid;
 }  }
   
 # ================================================================= Reopen menu  
   
 sub reopenmenu {  sub reopenmenu {
    if (($env{'browser.interface'} eq 'textual') ||     if (($env{'browser.interface'} eq 'textual') ||
Line 845  sub reopenmenu { Line 940  sub reopenmenu {
    return('window.open('.$nothing.',"'.$menuname.'","",false);');     return('window.open('.$nothing.',"'.$menuname.'","",false);');
 }   } 
   
 # =============================================================== Open the menu  
   
 sub open {  sub open {
     my $returnval='';      my $returnval='';
Line 933  sub switch { Line 1027  sub switch {
        my $pic=         my $pic=
    '<img alt="'.$text.'" src="'.     '<img alt="'.$text.'" src="'.
    &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).     &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
    '" align="'.($nobreak==3?'right':'left').'" />';     '" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />';
        if ($env{'browser.interface'} eq 'faketextual') {         if ($env{'browser.interface'} eq 'faketextual') {
 # Accessibility  # Accessibility
    if ($nobreak==3) {     if ($nobreak==3) {
        $inlineremote[$idx]="\n".         $inlineremote[$idx]="\n".
    '<td class="LC_menubuttons_text" align="right">'.$text.     '<td class="LC_menubuttons_text" align="right">'.$text.
    '</td><td class="LC_menubuttons_img" align="left">'.     '</td><td align="left">'.
    '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';     '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
    } elsif ($nobreak) {     } elsif ($nobreak) {
        $inlineremote[$idx]="\n<tr>".         $inlineremote[$idx]="\n<tr>".
    '<td class="LC_menubuttons_img" align="left">'.     '<td align="left">'.
    '<a href="javascript:'.$act.';">'.$pic.'</a></td>     '<a href="javascript:'.$act.';">'.$pic.'</a></td>
                     <td class="LC_menubuttons_text" align="left"><a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$text.'</span></a></td>';                      <td class="LC_menubuttons_text" align="left"><a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$text.'</span></a></td>';
    } else {     } else {
        $inlineremote[$idx]="\n<tr>".         $inlineremote[$idx]="\n<tr>".
    '<td class="LC_menubuttons_img" align="left">'.     '<td align="left">'.
    '<a href="javascript:'.$act.';">'.$pic.     '<a href="javascript:'.$act.';">'.$pic.
    '</a></td><td class="LC_menubuttons_text" colspan="3">'.     '</a></td><td class="LC_menubuttons_text" colspan="3">'.
    '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';     '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
Line 995  sub inlinemenu { Line 1089  sub inlinemenu {
     &rawconfig(1);      &rawconfig(1);
     my $output='<table id="LC_mainmenu"><tr>';      my $output='<table id="LC_mainmenu"><tr>';
     for (my $col=1; $col<=2; $col++) {      for (my $col=1; $col<=2; $col++) {
         $output.='<td class="LC_mainmenu_column">';          $output.='<td class="LC_mainmenu_col_fieldset">';
         for (my $row=1; $row<=8; $row++) {  
             foreach my $cat (keys(%category_members)) {  
                if ($category_positions{$cat} ne "$col,$row") { next; }  
                $output.='<table id="LC_menubuttons_mainmenu"><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';  
                my %active=();  
                foreach my $menu_item (split(/\:/,$category_members{$cat})) {  
                   if ($inlineremote[$menu_item]) {  
                      $active{$menu_item}=1;  
                   }  
                }    
                foreach my $item (sort(keys(%active))) {  
                   $output.=$inlineremote[$item];  
                }  
                $output.='</table>';  
             }  
          }  
          $output.="</td>";  
     }  
     $output.="</tr></table>";  
     return $output;  
 }  
   
 sub inlinemenu_new {  
     undef(@inlineremote);  
     undef(%category_members);  
     &rawconfig(1);  
     my $output='<table id="LC_mainmenu"><tr>';  
     for (my $col=1; $col<=2; $col++) {  
         $output.='<td class="LC_mainmenu_column">';  
         for (my $row=1; $row<=8; $row++) {          for (my $row=1; $row<=8; $row++) {
             foreach my $cat (keys(%category_members)) {              foreach my $cat (keys(%category_members)) {
                if ($category_positions{$cat} ne "$col,$row") { next; }                 if ($category_positions{$cat} ne "$col,$row") { next; }
                $output.='<table id="LC_menubuttons_mainmenu"><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';                 #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
                  $output.='<div class="LC_ContentBoxSpecial">';
          $output.='<h4 class="LC_hcell">'.&mt($category_names{$cat}).'</h4>';
                  $output.='<table>';
                my %active=();                 my %active=();
                foreach my $menu_item (split(/\:/,$category_members{$cat})) {                 foreach my $menu_item (split(/\:/,$category_members{$cat})) {
                   if ($inlineremote[$menu_item]) {                    if ($inlineremote[$menu_item]) {
Line 1039  sub inlinemenu_new { Line 1107  sub inlinemenu_new {
                   $output.=$inlineremote[$item];                    $output.=$inlineremote[$item];
                }                 }
                $output.='</table>';                 $output.='</table>';
                  $output.='</div>';
             }              }
          }           }
          $output.="</td>";           $output.="</td>";
Line 1155  sub rawconfig { Line 1224  sub rawconfig {
                     }                      }
                 }                  }
             }              }
           } elsif ($pro eq 'tools') {
               my @tools = ('aboutme','blog','portfolio');
               if (grep(/^\Q$prt\E$/,@tools)) {
                   if (!&Apache::lonnet::usertools_access($env{'user.name'},
                                                          $env{'user.domain'},
                                                          $prt,undef,'tools')) {
                       $output.=&clear($row,$col);
                       next;
                   }
               } elsif ($prt eq 'reqcrs') {
                   my $showreqcrs = 0;
                   foreach my $type ('official','unofficial') {
                       if (&Apache::lonnet::usertools_access($env{'user.name'},
                                                       $env{'user.domain'},
                                                       $type,undef,'requestcourses')) {
                           $showreqcrs = 1;
                           last;
                       }
                   }
                   if (!$showreqcrs) {
                       $output.=&clear($row,$col);
                       next;
                   }
               }
               $prt='any';
               $output.=&secondlevel(
             $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
         }          }
     }      }
     unless (($env{'browser.interface'} eq 'textual') ||      unless (($env{'browser.interface'} eq 'textual') ||
Line 1378  function set_bookmark() { Line 1474  function set_bookmark() {
    +"type='text' name='title' size=45 value='"+clienttitle+"' />"     +"type='text' name='title' size=45 value='"+clienttitle+"' />"
    +"<br />Address:<br /><input type='text' name='address' size='45' "     +"<br />Address:<br /><input type='text' name='address' size='45' "
    +"value='"+clienthref+"' /><br /><center><input type='submit' "     +"value='"+clienthref+"' /><br /><center><input type='submit' "
    +"value='Save' /> <input type='button' value='Close (no save)' "     +"value='Save' /> <input type='button' value='Close' "
    +"onclick='javascript:window.close();' /><\\/center><\\/td>"     +"onclick='javascript:window.close();' /><\\/center><\\/td>"
    +"<\\/tr><\\/table><\\/form><\\/center>"     +"<\\/tr><\\/table><\\/form><\\/center>"
    +'$end_page_bookmark' );     +'$end_page_bookmark' );

Removed from v.1.240  
changed lines
  Added in v.1.252


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