Diff for /loncom/interface/lonmenu.pm between versions 1.211 and 1.231

version 1.211, 2007/04/11 19:38:59 version 1.231, 2007/11/09 20:57:29
Line 54  my @inlineremote; Line 54  my @inlineremote;
   
   
 # ================================================================ Little texts  # ================================================================ Little texts
   sub show_course {
       my $course = !$env{'user.adv'};
       if (!$env{'user.adv'}) {
    foreach my $env (keys(%env)) {
       next if ($env !~ m/^user\.priv\./);
       if ($env !~ m/^user\.priv\.(?:st|cm)/) {
    $course = 0;
    last;
       }
    }
       }
       return $course;
   }
   
 sub initlittle {  sub initlittle {
     return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',      return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
        'nav' => 'Navigate Contents',         'nav' => 'Navigate Contents',
        'main' => 'Main Menu',         'main' => 'Main Menu',
                                        'roles' => ($env{'user.adv'}?                                         'roles' => (&show_course()?
                                                     'Roles':'Courses'),                                                      'Courses':'Roles'),
                                        'docs' => 'Course Documents',                                         'docs' => 'Edit Course',
                                        'exit' => 'Exit',                                         'exit' => 'Exit',
                                        'login' => 'Log In',                                         'login' => 'Log In',
        'launch' => 'Launch Remote Control',         'launch' => 'Launch Remote Control',
Line 121  sub menubuttons { Line 134  sub menubuttons {
     $navmaps=(<<ENDNAV);      $navmaps=(<<ENDNAV);
 <a href="/adm/navmaps?postdata=$escurl&amp;postsymb=$escsymb" target="_top">$lt{'nav'}</a>  <a href="/adm/navmaps?postdata=$escurl&amp;postsymb=$escsymb" target="_top">$lt{'nav'}</a>
 ENDNAV  ENDNAV
             if (($env{'request.noversionuri'}=~/^\/adm\//) &&              if (&show_return_link()) {
          ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&  
          ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) {  
                 my $escreload=&escape('return:');                  my $escreload=&escape('return:');
                 $reloadlink=(<<ENDRELOAD);                  $reloadlink=(<<ENDRELOAD);
 <a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a>  <a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a>
Line 196  ENDINLINEMENU Line 207  ENDINLINEMENU
     $navmaps=(<<ENDNAV);      $navmaps=(<<ENDNAV);
 <td><a href="$link" target="_top">$lt{'nav'}</a></td>  <td><a href="$link" target="_top">$lt{'nav'}</a></td>
 ENDNAV  ENDNAV
 my $is_group = (&Apache::loncommon::course_type() eq 'Group');              my $is_group = (&Apache::loncommon::course_type() eq 'Group');
     if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {      if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
                 my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};                  my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};
  $docs=(<<ENDDOCS);   $docs=(<<ENDDOCS);
Line 208  ENDDOCS Line 219  ENDDOCS
 <td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td>  <td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td>
 ENDGROUPS  ENDGROUPS
             }              }
     if (      if (&show_return_link()) {
  ($env{'request.noversionuri'}=~m[^/(res|public)/] &&  
  $env{'request.symb'} eq '')  
  ||  
  (($env{'request.noversionuri'}=~/^\/adm\//) &&  
  ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&  
  ($env{'request.noversionuri'}!~  
         m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])  
   )  
  ) {  
                 my $escreload=&escape('return:');                  my $escreload=&escape('return:');
                 $reloadlink=(<<ENDRELOAD);                  $reloadlink=(<<ENDRELOAD);
 <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>  <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>
Line 274  ENDINLINEMENU Line 276  ENDINLINEMENU
     }      }
 }  }
   
   sub show_return_link {
       return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
        $env{'request.symb'} eq '')
       ||
       ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
       ||
       (($env{'request.noversionuri'}=~/^\/adm\//) &&
        ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
        ($env{'request.noversionuri'}!~
         m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
        ));
   }
   
 # ====================================== This gets called in the header section  # ====================================== This gets called in the header section
   
 sub registerurl {  sub registerurl {
Line 445  sub innerregister { Line 460  sub innerregister {
             # Finally, turn the button on or off              # Finally, turn the button on or off
             if ($cfile && !$const_space) {              if ($cfile && !$const_space) {
                 $editbutton=&switch                  $editbutton=&switch
                     ('','',6,1,'cstr.gif','edit[_1]','resource[_2]',                      ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
                      "go('".$cfile."');","Edit this resource");                       "go('".$cfile."');","Edit this resource");
             } elsif ($editbutton eq '') {              } elsif ($editbutton eq '') {
                 $editbutton=&clear(6,1);                  $editbutton=&clear(6,1);
Line 486  s&8&3&prt.gif&prepare[_1]&printout[_1]&g Line 501  s&8&3&prt.gif&prepare[_1]&printout[_1]&g
 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  s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&&1
 ENDMENUITEMS  ENDMENUITEMS
   
             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {              unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
         $menuitems.=(<<ENDREALRES);   if (!$env{'request.enc'}) {
       $menuitems.=(<<ENDREALRES);
 s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information  s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information
   ENDREALRES
                   }
           $menuitems.=(<<ENDREALRES);
 s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource  s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
 s&8&2&fdbk.gif&feedback[_1]&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource  s&8&2&fdbk.gif&feedback[_1]&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
 ENDREALRES  ENDREALRES
Line 502  ENDMENUITEMS Line 522  ENDMENUITEMS
         my $buttons='';          my $buttons='';
         foreach (split(/\n/,$menuitems)) {          foreach (split(/\n/,$menuitems)) {
     my ($command,@rest)=split(/\&/,$_);      my ($command,@rest)=split(/\&/,$_);
             if ($command eq 's') {              my $idx=10*$rest[0]+$rest[1];
  $buttons.=&switch('','',@rest);              if (&hidden_button_check() eq 'yes') {
             } else {                  if ($idx == 21 ||$idx == 23) {
                 $buttons.=&clear(@rest);                      $buttons.=&switch('','',@rest);
                   } else {
                       $buttons.=&clear(@rest);
                   }
               } else {  
                   if ($command eq 's') {
               $buttons.=&switch('','',@rest);
                   } else {
                       $buttons.=&clear(@rest);
                   }
             }              }
         }          }
   
Line 515  ENDMENUITEMS Line 544  ENDMENUITEMS
     my $inlinebuttons='';      my $inlinebuttons='';
     if ($addremote) {      if ($addremote) {
 # Registered, textual output  # Registered, textual output
   
  if ($env{'browser.interface'} eq 'textual') {   if ($env{'browser.interface'} eq 'textual') {
     $inlinebuttons=      $inlinebuttons=
                         join('',map { (defined($_)?$_:'') } @inlineremote);                          join('',map { (defined($_)?$_:'') } @inlineremote);
  } else {   } else {
     $inlinebuttons=(<<ENDINLINE);                      if ($env{'environment.icons'} eq 'iconsonly') {
                           $inlinebuttons=(<<ENDARROWSINLINE);
   <tr><td>
   $inlineremote[21] $inlineremote[23]
   ENDARROWSINLINE
                           if (&hidden_button_check() ne 'yes') {
                               $inlinebuttons .= (<<ENDINLINEICONS);
   $inlineremote[61] $inlineremote[63]
   $inlineremote[71] $inlineremote[72] $inlineremote[73]
   $inlineremote[81] $inlineremote[82] $inlineremote[83]
   $inlineremote[91] $inlineremote[92] $inlineremote[93]</td></tr>
   ENDINLINEICONS
                           }
                       } else {
    if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
       $inlinebuttons=(<<ENDFIRSTLINE);
 <tr><td>$inlineremote[21]</td><td>&nbsp;</td><td>$inlineremote[23]</td></tr>  <tr><td>$inlineremote[21]</td><td>&nbsp;</td><td>$inlineremote[23]</td></tr>
 <tr><td>$inlineremote[61]</td><td>$inlineremote[62]</td><td>$inlineremote[63]</td></tr>  ENDFIRSTLINE
 <tr><td>$inlineremote[71]</td><td>$inlineremote[72]</td><td>$inlineremote[73]</td></tr>                          }
 <tr><td>$inlineremote[81]</td><td>$inlineremote[82]</td><td>$inlineremote[83]</td></tr>                          if (&hidden_button_check() ne 'yes') { 
 <tr><td>$inlineremote[91]</td><td>$inlineremote[92]</td><td>$inlineremote[93]</td></tr>      foreach my $row (6..9) {
 ENDINLINE   if ($inlineremote[${row}.'1'] ne ''
                 }      || $inlineremote[$row.'2'] ne ''
       || $inlineremote[$row.'3'] ne '') {
       $inlinebuttons .= <<"ENDLINE";
   <tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
   ENDLINE
    }
       }
    }
       }
    }
     }      }
     $result =(<<ENDREGTEXT);      $result =(<<ENDREGTEXT);
 <script type="text/javascript">  <script type="text/javascript">
 // BEGIN LON-CAPA Internal  // BEGIN LON-CAPA Internal
 </script>  </script>
 $timesync  $timesync
 $newmail  
 $tablestart  $tablestart
 $inlinebuttons  $inlinebuttons
 $tableend  $tableend
   $newmail
 <script type="text/javascript">  <script type="text/javascript">
 // END LON-CAPA Internal  // END LON-CAPA Internal
 </script>  </script>
Line 756  sub load_remote_msg { Line 808  sub load_remote_msg {
 <p>$link</p>  <p>$link</p>
 ENDREMOTEFORM  ENDREMOTEFORM
 }  }
   
   sub get_menu_name {
       my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
       $hostid =~ s/\W//g;
       return 'LCmenu'.$hostid;
   }
   
 # ================================================================= Reopen menu  # ================================================================= Reopen menu
   
 sub reopenmenu {  sub reopenmenu {
    if (($env{'browser.interface'} eq 'textual') ||     if (($env{'browser.interface'} eq 'textual') ||
        ($env{'environment.remote'} eq 'off')) { return ''; }         ($env{'environment.remote'} eq 'off')) { return ''; }
    my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};     my $menuname = &get_menu_name();
    my $nothing = &Apache::lonhtmlcommon::javascript_nothing();     my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
    return('window.open('.$nothing.',"'.$menuname.'","",false);');     return('window.open('.$nothing.',"'.$menuname.'","",false);');
 }   } 
Line 774  sub open { Line 833  sub open {
         ($env{'environment.remote'} eq 'off')) {           ($env{'environment.remote'} eq 'off')) { 
  return '<script type="text/javascript">self.name="loncapaclient";</script>';   return '<script type="text/javascript">self.name="loncapaclient";</script>';
     }      }
     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};      my $menuname = &get_menu_name();
     unless (shift eq 'unix') {      
   #    unless (shift eq 'unix') {
 # resizing does not work on linux because of virtual desktop sizes  # resizing does not work on linux because of virtual desktop sizes
        $returnval.=(<<ENDRESIZE);  #       $returnval.=(<<ENDRESIZE);
 if (window.screen) {  #if (window.screen) {
     self.resizeTo(screen.availWidth-215,screen.availHeight-55);  #    self.resizeTo(screen.availWidth-215,screen.availHeight-55);
     self.moveTo(190,15);  #    self.moveTo(190,15);
 }  #}
 ENDRESIZE  #ENDRESIZE
     }  #    }
     $returnval.=(<<ENDOPEN);      $returnval.=(<<ENDOPEN);
 window.status='Opening LON-CAPA Remote Control';  window.status='Opening LON-CAPA Remote Control';
 var menu=window.open("/res/adm/pages/menu.html","$menuname",  var menu=window.open("/res/adm/pages/menu.html","$menuname",
Line 842  sub switch { Line 902  sub switch {
        }         }
    } else {     } else {
 # Inline Remote  # Inline Remote
          if ($env{'environment.icons'} ne 'classic') {
             $img=~s/\.gif$/\.png/;
          }
        if ($nobreak==2) { return ''; }         if ($nobreak==2) { return ''; }
        my $text=$top.' '.$bot;         my $text=$top.' '.$bot;
        $text=~s/\s*\-\s*//gs;         $text=~s/\s*\-\s*//gs;
   
        my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};  
        if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }  
        my $pic=         my $pic=
    '<img alt="'.$text.'" src="http://'.$ENV{'HTTP_HOST'}.     '<img alt="'.$text.'" src="'.
    ':'.$lonhttpdPort.'/res/adm/pages/'.$img.'" align="'.     &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
    ($nobreak==3?'right':'left').'" />';     '" align="'.($nobreak==3?'right':'left').'" />';
        if ($env{'browser.interface'} eq 'faketextual') {         if ($env{'browser.interface'} eq 'faketextual') {
 # Accessibility  # Accessibility
    if ($nobreak==3) {     if ($nobreak==3) {
Line 863  sub switch { Line 924  sub switch {
        $inlineremote[$idx]="\n<tr>".         $inlineremote[$idx]="\n<tr>".
    '<td class="LC_menubuttons_img" align="left">'.     '<td class="LC_menubuttons_img" align="left">'.
    '<a href="javascript:'.$act.';">'.$pic.'</a></td>     '<a href="javascript:'.$act.';">'.$pic.'</a></td>
                     <td class="LC_menubuttons_text" align="left">'.$text.'</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 class="LC_menubuttons_img" 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">'.
    $desc.'</td></tr>';     '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
    }     }
        } else {         } else {
 # Inline Menu  # Inline Menu
    $inlineremote[$idx]=             if ($env{'environment.icons'} eq 'iconsonly') {
    '<a href="javascript:'.$act.';">'.$pic.                $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
    '</a><span class="LC_menubuttons_inline_text">'.$desc.'</span>';             } else {
         $inlineremote[$idx]=
      '<a class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
      '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
              }
        }         }
    }     }
     return '';      return '';
Line 896  sub secondlevel { Line 961  sub secondlevel {
 }  }
   
 sub openmenu {  sub openmenu {
     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};      my $menuname = &get_menu_name();
     if (($env{'browser.interface'} eq 'textual') ||      if (($env{'browser.interface'} eq 'textual') ||
         ($env{'environment.remote'} eq 'off')) { return ''; }          ($env{'environment.remote'} eq 'off')) { return ''; }
     my $nothing = &Apache::lonhtmlcommon::javascript_nothing();      my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
Line 907  sub inlinemenu { Line 972  sub inlinemenu {
     undef(@inlineremote);      undef(@inlineremote);
     undef(%category_members);      undef(%category_members);
     &rawconfig(1);      &rawconfig(1);
     my $output='<table><tr>';      my $output='<table id="LC_mainmenu"><tr>';
     for (my $col=1; $col<=2; $col++) {      for (my $col=1; $col<=2; $col++) {
         $output.='<td>';          $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_menu_category">'.&mt($category_names{$cat}).'</td></tr>';                 $output.='<table id="LC_menubuttons_mainmenu"><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
                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 946  sub rawconfig { Line 1011  sub rawconfig {
     my $uname=$env{'user.name'};      my $uname=$env{'user.name'};
     my $udom=$env{'user.domain'};      my $udom=$env{'user.domain'};
     my $adv=$env{'user.adv'};      my $adv=$env{'user.adv'};
       my $show_course=&show_course();
     my $author=$env{'user.author'};      my $author=$env{'user.author'};
     my $crs='';      my $crs='';
     if ($env{'request.course.id'}) {      if ($env{'request.course.id'}) {
Line 985  sub rawconfig { Line 1051  sub rawconfig {
                $output.=&secondlevel(                 $output.=&secondlevel(
   $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);    $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
             }              }
    } elsif ($pro eq 'shc') {
               if ($show_course) {
                  $output.=&secondlevel(
             $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
               }
           } elsif ($pro eq 'nsc') {
               if (!$show_course) {
                  $output.=&secondlevel(
     $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
               }
         } elsif (($pro=~/^p(\w+)/) && ($prt)) {          } elsif (($pro=~/^p(\w+)/) && ($prt)) {
     if (&Apache::lonnet::allowed($1,$prt)) {      if (&Apache::lonnet::allowed($1,$prt)) {
                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
Line 1046  sub rawconfig { Line 1122  sub rawconfig {
 sub close {  sub close {
     if (($env{'browser.interface'} eq 'textual') ||      if (($env{'browser.interface'} eq 'textual') ||
         ($env{'environment.remote'} eq 'off')) { return ''; }          ($env{'environment.remote'} eq 'off')) { return ''; }
     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};      my $menuname = &get_menu_name();
     return(<<ENDCLOSE);      return(<<ENDCLOSE);
 <script type="text/javascript">  <script type="text/javascript">
 window.status='Accessing Remote Control';  window.status='Accessing Remote Control';
Line 1230  function annotate() { Line 1306  function annotate() {
    '$start_page_annotate'     '$start_page_annotate'
   +"<form name='goannotate' target='Annotator' method='post' "    +"<form name='goannotate' target='Annotator' method='post' "
   +"action='/adm/annotations'>"    +"action='/adm/annotations'>"
   +"<input type='hidden' name='urlnew' value='"+currentURL+"' />"    +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
   +"<\\/form>"    +"<\\/form>"
   +'$end_page_annotate');    +'$end_page_annotate');
    annotator.document.close();     annotator.document.close();
Line 1314  sub convert_menu_function { Line 1390  sub convert_menu_function {
     return $rolename;      return $rolename;
 }  }
   
   sub hidden_button_check {
       my $hidden;
       if ($env{'request.course.id'} eq '') {
           return;
       }
       if ($env{'request.role.adv'}) {
           return;
       }
       return &Apache::lonnet::EXT('resource.0.buttonshide'); 
   }
   
 # ================================================================ Main Program  # ================================================================ Main Program
   

Removed from v.1.211  
changed lines
  Added in v.1.231


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