Diff for /loncom/interface/lonmenu.pm between versions 1.369.2.17 and 1.370

version 1.369.2.17, 2012/08/03 17:35:32 version 1.370, 2012/05/15 01:41:27
Line 26 Line 26
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 #  #
   # There is one parameter controlling the action of this module:
   #
   
 =head1 NAME  =head1 NAME
   
Line 33  Apache::lonmenu Line 35  Apache::lonmenu
   
 =head1 SYNOPSIS  =head1 SYNOPSIS
   
 Loads contents of /home/httpd/lonTabs/mydesk.tab,   Coordinates the response to clicking an image.
 used to generate inline menu, and Main Menu page.   
   
 This is part of the LearningOnline Network with CAPA project  This is part of the LearningOnline Network with CAPA project
 described at http://www.lon-capa.org.  described at http://www.lon-capa.org.
Line 73  It is set to 'done' in the BEGIN block o Line 74  It is set to 'done' in the BEGIN block o
 =item @primary_menu  =item @primary_menu
   
 The elements of this array reference arrays that are made up of the components  The elements of this array reference arrays that are made up of the components
 of those lines of mydesk.tab that start with prim:.  of those lines of mydesk.tab that start with prim.
 It is used by primary_menu() to generate the corresponding menu.  It is used by primary_menu() to generate the corresponding menu.
 It gets filled in the BEGIN block of this module.  It gets filled in the BEGIN block of this module.
   
 =item %primary_sub_menu  
   
 The keys of this hash reference are the names of items in the primary_menu array   
 which have sub-menus.  For each key, the corresponding value is a reference to  
 an array containing components extracted from lines in mydesk.tab which begin  
 with primsub:.  
 This hash, which is used by primary_menu to generate sub-menus, is populated in  
 the BEGIN block.  
   
 =item @secondary_menu  =item @secondary_menu
   
 The elements of this array reference arrays that are made up of the components  The elements of this array reference arrays that are made up of the components
Line 115  entries from mydesk.tab Line 107  entries from mydesk.tab
   
 Same as primary_menu() but operates on @secondary_menu.  Same as primary_menu() but operates on @secondary_menu.
   
 =item create_submenu()  
   
 Creates XHTML for unordered list of sub-menu items which belong to a  
 particular top-level menu item. Uses hover pseudo class in css to display  
 dropdown list when mouse hovers over top-level item. Support for IE6  
 (no hover psuedo class) via LC_hoverable class for <li> tag for top-  
 level item, which employs jQuery to handle behavior on mouseover.  
   
 Inputs: 4 - (a) link and (b) target for anchor href in top level item,  
             (c) title for text wrapped by anchor tag in top level item.  
             (d) reference to array of arrays of sub-menu items.  
   
 =item innerregister()  =item innerregister()
   
 This gets called in order to register a URL in the body of the document  This gets called in order to register a URL 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 clear()
   
 =item switch()  =item switch()
Line 169  The javascript is usually similar to "go Line 129  The javascript is usually similar to "go
   
 =item utilityfunctions()  =item utilityfunctions()
   
 Output from this routine is a number of javascript functions called by  
 items in the inline menu, and in some cases items in the Main Menu page.   
   
 =item serverform()  =item serverform()
   
 =item constspaceform()  =item constspaceform()
Line 202  use HTML::Entities(); Line 159  use HTML::Entities();
 use Apache::lonwishlist();  use Apache::lonwishlist();
   
 use vars qw(@desklines %category_names %category_members %category_positions   use vars qw(@desklines %category_names %category_members %category_positions 
             $readdesk @primary_menu %primary_submenu @secondary_menu %secondary_submenu);              $readdesk @primary_menu @secondary_menu);
   
 my @inlineremote;  my @inlineremote;
   
Line 225  sub prep_menuitem { Line 182  sub prep_menuitem {
   
 # primary_menu() evaluates @primary_menu and returns XHTML for the menu  # primary_menu() evaluates @primary_menu and returns XHTML for the menu
 # that contains following links:  # that contains following links:
 # About, Message, Personal, Roles, Help, Logout  # About, Message, Roles, Help, Logout
 # @primary_menu is filled within the BEGIN block of this module with   # @primary_menu is filled within the BEGIN block of this module with 
 # entries from mydesk.tab  # entries from mydesk.tab
 sub primary_menu {  sub primary_menu {
Line 255  sub primary_menu { Line 212  sub primary_menu {
         next if    $$menuitem[4]        eq 'courses'   ##'Roles' wanted          next if    $$menuitem[4]        eq 'courses'   ##'Roles' wanted
                 && !&Apache::loncommon::show_course(); ##                  && !&Apache::loncommon::show_course(); ##
                   
         my $title = $menuitem->[3];              
         if (defined($primary_submenu{$title})) {          if ($$menuitem[3] eq 'Help') { # special treatment for helplink
             my ($link,$target);  
             if ($menuitem->[0] ne '') {  
                 $link = $menuitem->[0];  
                 $target = '_top';  
             } else {  
                 $link = '#';  
             }  
             my @primsub;  
             if (ref($primary_submenu{$title}) eq 'ARRAY') {  
                 foreach my $item (@{$primary_submenu{$title}}) {  
                     next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));   
                     next if (($item->[2] eq 'reqcrs') && (!&check_for_rcrs()));  
                     next if ((($item->[2] eq 'portfolio') ||   
                              ($item->[2] eq 'blog')) &&   
                              (!&Apache::lonnet::usertools_access('','',$item->[2],  
                                                            undef,'tools')));  
                     push(@primsub,$item);  
                 }  
                 if (@primsub > 0) {  
                     $menu .= &create_submenu($link,$target,$title,\@primsub);  
                 } elsif ($link) {  
                     $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';  
                 }  
             }  
         } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink  
             if ($public) {              if ($public) {
                 my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};                  my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
                 my $defdom = &Apache::lonnet::default_login_domain();                  my $defdom = &Apache::lonnet::default_login_domain();
Line 337  sub secondary_menu { Line 269  sub secondary_menu {
                                                ? "/$env{'request.course.sec'}"                                                 ? "/$env{'request.course.sec'}"
                                                : '');                                                 : '');
     my $canedit       = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});      my $canedit       = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
     my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};      my $canviewgrps   = &Apache::lonnet::allowed('vcg', $crs_sec); 
     my $canviewgrps   = &Apache::lonnet::allowed('vcg', $crs_sec);      my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); 
     my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);      my $canviewwnew   = &Apache::lonnet::allowed('whn', $crs_sec); 
     my $canviewwnew   = &Apache::lonnet::allowed('whn', $crs_sec);  
     my $canmodpara    = &Apache::lonnet::allowed('opa', $crs_sec);      my $canmodpara    = &Apache::lonnet::allowed('opa', $crs_sec);
     my $canvgr        = &Apache::lonnet::allowed('vgr', $crs_sec);      my $canvgr        = &Apache::lonnet::allowed('vgr', $crs_sec);
     my $canmgr        = &Apache::lonnet::allowed('mgr', $crs_sec);      my $canmgr        = &Apache::lonnet::allowed('mgr', $crs_sec); 
     my $author        = &getauthor();      my $author        = &getauthor();
   
     my %groups = &Apache::lonnet::get_active_groups(      my %groups = &Apache::lonnet::get_active_groups(
Line 359  sub secondary_menu { Line 290  sub secondary_menu {
                 && !$env{'request.course.id'};                  && !$env{'request.course.id'};
         next if    $$menuitem[4]   =~ /^mdc/          next if    $$menuitem[4]   =~ /^mdc/
                 && !$canedit;                  && !$canedit;
         next if    $$menuitem[4]  eq 'mdcCourse'  
                 && ($crstype eq 'Community');  
         next if    $$menuitem[4]  eq 'mdcCommunity'  
                 && ($crstype eq 'Course');  
         next if    $$menuitem[4]  eq 'nvgr'          next if    $$menuitem[4]  eq 'nvgr'
                 && $canvgr;                  && $canvgr;
         next if    $$menuitem[4]  eq 'vgr'          next if    $$menuitem[4]  eq 'vgr'
Line 370  sub secondary_menu { Line 297  sub secondary_menu {
         next if    $$menuitem[4]   eq 'cst'          next if    $$menuitem[4]   eq 'cst'
                 && !$canmodifyuser;                  && !$canmodifyuser;
         next if    $$menuitem[4]   eq 'ncst'          next if    $$menuitem[4]   eq 'ncst'
                 && ($canmodifyuser || !$canviewroster);                  && $canmodifyuser;
         next if    $$menuitem[4]   eq 'mgr'          next if    $$menuitem[4]   eq 'mgr'
                 && !$canmgr;                  && !$canmgr;
         next if    $$menuitem[4]   eq 'nmgr'          next if    $$menuitem[4]   eq 'nmgr'
Line 379  sub secondary_menu { Line 306  sub secondary_menu {
                 && !$canviewwnew;                  && !$canviewwnew;
         next if    $$menuitem[4]   eq 'opa'          next if    $$menuitem[4]   eq 'opa'
                 && !$canmodpara;                  && !$canmodpara;
         next if    $$menuitem[4]   eq 'nvcg'          next if    $$menuitem[4]   =~ /showgroups$/
                 && ($canviewgrps || !%groups);                  && !$canviewgrps
                   && !%groups;
         next if    $$menuitem[4]    eq 'author'          next if    $$menuitem[4]    eq 'author'
                 && !$author;                  && !$author;
   
         my $title = $menuitem->[3];          if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
         if (defined($secondary_submenu{$title})) {  
             my ($link,$target);  
             if ($menuitem->[0] ne '') {  
                 $link = $menuitem->[0];  
                 $target = '_top';  
             } else {  
                 $link = '#';  
             }  
             my @scndsub;     
             if (ref($secondary_submenu{$title}) eq 'ARRAY') {  
                 foreach my $item (@{$secondary_submenu{$title}}) {  
                     if (ref($item) eq 'ARRAY') {  
                         next if ($item->[2] eq 'vgr' && !$canvgr);  
                         next if ($item->[2] eq 'opa' && !$canmodpara);  
                         next if ($item->[2] eq 'cst' && !$canmodifyuser);  
                         next if ($item->[2] eq 'mgr' && !$canmgr);  
                         next if ($item->[2] eq 'vcg' && !$canviewgrps);  
                         push(@scndsub,$item);   
                     }  
                 }  
                 if (@scndsub > 0) {  
                     $menu .= &create_submenu($link,$target,$title,\@scndsub);  
                 } elsif ($link) {  
                     $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';  
                 }  
             }  
         } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {  
             # special treatment for role selector              # special treatment for role selector
             my $roles_selector = &roles_selector(              my $roles_selector = &roles_selector(
                         $env{'course.' . $env{'request.course.id'} . '.domain'},                          $env{'course.' . $env{'request.course.id'} . '.domain'},
                         $env{'course.' . $env{'request.course.id'} . '.num'}  );                          $env{'course.' . $env{'request.course.id'} . '.num'}  );
   
             $menu .= $roles_selector ? "<li style=\"padding: 0 0.8em;\">$roles_selector</li>"              $menu .= $roles_selector ? "<li>$roles_selector</li>"
                                      : '';                                       : '';
         } else {          } else {
             $menu .= &prep_menuitem(\@$menuitem);              $menu .= &prep_menuitem(\@$menuitem);
Line 447  sub secondary_menu { Line 348  sub secondary_menu {
     return "<ul id=\"LC_secondary_menu\">$menu</ul>";      return "<ul id=\"LC_secondary_menu\">$menu</ul>";
 }  }
   
 sub create_submenu {  
     my ($link,$target,$title,$submenu) = @_;  
     return unless (ref($submenu) eq 'ARRAY');  
     my $disptarget;  
     if ($target ne '') {  
         $disptarget = ' target="'.$target.'"';  
     }  
     my $menu = '<li class="LC_hoverable">'.  
                '<a href="'.$link.'"'.$disptarget.'>'.   
                '<span class="LC_nobreak">'.&mt($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 $borderbot;  
             if ($count == $numsub) {  
                 $borderbot = 'border-bottom:1px solid black;';  
             }  
             $menu .= '<li style="margin:0;padding:0;'.  
                      $borderbot.'"><a href="'.$item->[0].'">'.  
                      &mt($item->[1]).'</a></li>';  
         }  
     }  
     $menu .= '</ul></li>';  
     return $menu;  
 }  
   
 sub registerurl {  
     my ($forcereg) = @_;  
     my $result = '';  
     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }  
     my $force_title='';  
     if ($env{'request.state'} eq 'construct') {  
         $force_title=&Apache::lonxml::display_title();  
     }  
     if (($env{'environment.remote'} eq 'off') ||  
         ((($env{'request.publicaccess'}) ||  
          (!&Apache::lonnet::is_on_map(  
            &unescape($env{'request.noversionuri'})))) &&  
         (!$forcereg))) {  
         return  
         $result  
        .'<script type="text/javascript">'."\n"  
        .'// <![CDATA['."\n"  
        .'function LONCAPAreg(){;} function LONCAPAstale(){}'."\n"  
        .'// ]]>'."\n"  
        .'</script>'  
        .$force_title;  
     }  
 # Graphical display after login only  
     if ($env{'request.registered'} && !$forcereg) { return ''; }  
     $result.=&innerregister($forcereg);  
     return $result.$force_title;  
 }  
   
 sub innerregister {  sub innerregister {
     my ($forcereg,$bread_crumbs) = @_;      my ($forcereg,$bread_crumbs) = @_;
     my $const_space = ($env{'request.state'} eq 'construct');      my $const_space = ($env{'request.state'} eq 'construct');
Line 515  sub innerregister { Line 357  sub innerregister {
   
     $env{'request.registered'} = 1;      $env{'request.registered'} = 1;
   
     my $noremote = ($env{'environment.remote'} eq 'off');  
   
     undef(@inlineremote);      undef(@inlineremote);
   
     my $reopen=&Apache::lonmenu::reopenmenu();  
   
     my $newmail='';  
   
     if (&Apache::lonmsg::newmail() && !$noremote) {  
         # We have new mail and remote is up  
         $newmail= 'swmenu.setstatus("you have","messages");';  
     }  
   
     my $resurl;       my $resurl; 
     if ( $env{'request.symb'} && $env{'request.course.id'} ) {      if ( $env{'request.symb'} && $env{'request.course.id'} ) {
   
Line 566  sub innerregister { Line 397  sub innerregister {
         &Apache::lonhtmlcommon::clear_breadcrumbs();          &Apache::lonhtmlcommon::clear_breadcrumbs();
         &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});          &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
     }      }
     my $timesync   = ( $noremote ? '' : 'swmenu.syncclock(1000*'.time.');' );  
 # =============================================================================  # =============================================================================
 # ============================ This is for URLs that actually can be registered  # ============================ This is for URLs that actually can be registered
     unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})      return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/}) 
                        || ($forcereg)) {                         || $forcereg );
         unless ($noremote) {  
 # Not registered, graphical  
            return (<<ENDDONOTREGTHIS);  
   
 <script type="text/javascript">  
 // <![CDATA[  
 // BEGIN LON-CAPA Internal  
 var swmenu=null;  
   
     function LONCAPAreg() {  
           swmenu=$reopen  
           $timesync  
           swmenu.currentStale=1;  
           swmenu.clearbut(2,1);  
           swmenu.clearbut(2,3);  
           swmenu.clearbut(8,1);  
           swmenu.clearbut(8,2);  
           swmenu.clearbut(8,3);  
           if (swmenu.currentURL) {  
              swmenu.switchbutton  
               (3,1,'reload.gif','return','location','go(currentURL)');  
           } else {  
               swmenu.clearbut(3,1);  
           }  
     }  
   
     function LONCAPAstale() {  
     }  
   
 // END LON-CAPA Internal  
 // ]]>  
 </script>  
 ENDDONOTREGTHIS  
   
         }  
         return '';  
     }  
   
 # -- This applies to homework problems for users with grading privileges  # -- This applies to homework problems for users with grading privileges
  my $crs='/'.$env{'request.course.id'};   my $crs='/'.$env{'request.course.id'};
Line 788  ENDDONOTREGTHIS Line 581  ENDDONOTREGTHIS
         ###          ###
         ###          ###
 # Prepare the rest of the buttons  # Prepare the rest of the buttons
         my ($menuitems,$got_prt,$got_wishlist);          my $menuitems;
         if ($const_space) {          if ($const_space) {
 #  #
 # We are in construction space  # We are in construction space
Line 824  ENDMENUITEMS Line 617  ENDMENUITEMS
         } elsif ( defined($env{'request.course.id'}) &&           } elsif ( defined($env{'request.course.id'}) && 
  $env{'request.symb'} ne '' ) {   $env{'request.symb'} ne '' ) {
 #  #
 # We are in a course and looking at a registered URL  # We are in a course and looking at a registred URL
 # Should probably be in mydesk.tab  # Should probably be in mydesk.tab
 #  #
     $menuitems=(<<ENDMENUITEMS);      $menuitems=(<<ENDMENUITEMS);
Line 836  c&8&1 Line 629  c&8&1
 c&8&2  c&8&2
 s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document  s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
 ENDMENUITEMS  ENDMENUITEMS
             $got_prt = 1;              if (&Apache::lonnet::allowed('bre', $env{'request.course.id'}) eq 'F' && $env{'request.uri'} =~ /^\/res/) {
             if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)  
                 && (!$env{'request.enc'})) {  
                 # wishlist is only available for users with access to resource-pool                  # wishlist is only available for users with access to resource-pool
                 # and links can only be set for resources within the resource-pool                  # and links can only be set for resources within the resource-pool
                 $menuitems .= (<<ENDMENUITEMS);                  $menuitems .= (<<ENDMENUITEMS);
 s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1  s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1
 ENDMENUITEMS  ENDMENUITEMS
                 $got_wishlist = 1;  
             }              }
   
 my $currentURL = &Apache::loncommon::get_symb();  my $currentURL = &Apache::loncommon::get_symb();
Line 860  $menuitems.="&Notes&&annotate()&"; Line 650  $menuitems.="&Notes&&annotate()&";
 $menuitems.="Make notes and annotations about this resource&&1\n";  $menuitems.="Make notes and annotations about this resource&&1\n";
   
             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {              unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
  if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) {   if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
     $menuitems.=(<<ENDREALRES);      $menuitems.=(<<ENDREALRES);
 s&6&3&catalog.png&Info&info[_1]&catalog_info()&Show Metadata  s&6&3&catalog.png&Info&info[_1]&catalog_info()&Show Metadata
 ENDREALRES  ENDREALRES
                 }                  }
                 unless ($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/docs/}) {          $menuitems.=(<<ENDREALRES);
             $menuitems.=(<<ENDREALRES);  
 s&8&1&eval.png&Evaluate&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource  s&8&1&eval.png&Evaluate&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
 ENDREALRES  
                 }  
                 $menuitems.=(<<ENDREALRES);  
 s&8&2&fdbk.png&Communicate&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource  s&8&2&fdbk.png&Communicate&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
 ENDREALRES  ENDREALRES
     }      }
         }          }
  if ($env{'request.uri'} =~ /^\/res/) {   if ($env{'request.uri'} =~ /^\/res/) {
             unless ($got_prt) {      $menuitems .= (<<ENDMENUITEMS);
         $menuitems .= (<<ENDMENUITEMS);  
 s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document  s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
 ENDMENUITEMS  ENDMENUITEMS
                 $got_prt = 1;              if (&Apache::lonnet::allowed('bre', $env{'request.course.id'}) eq 'F') {
             }                  # wishlist is only available for users with access to resource-pool
             unless ($got_wishlist) {                  $menuitems .= (<<ENDMENUITEMS);
                 if (($env{'user.adv'}) && (!$env{'request.enc'})) {  s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in in your personal Stored Links repository&&1
                     # wishlist is only available for users with access to resource-pool  
                     $menuitems .= (<<ENDMENUITEMS);  
 s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1  
 ENDMENUITEMS  ENDMENUITEMS
                     $got_wishlist = 1;  
                 }  
             }              }
  }   }
         my $buttons='';          my $buttons='';
Line 910  ENDMENUITEMS Line 690  ENDMENUITEMS
                 }                  }
             }              }
         }          }
         if ($noremote) {  
     my $addremote=0;      my $addremote=0;
     foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }      foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
             if ($addremote) {      if ($addremote) {
   
                 &Apache::lonhtmlcommon::clear_breadcrumb_tools();          &Apache::lonhtmlcommon::clear_breadcrumb_tools();
   
                 &Apache::lonhtmlcommon::add_breadcrumb_tool(              &Apache::lonhtmlcommon::add_breadcrumb_tool(
                     'navigation', @inlineremote[21,23]);                  'navigation', @inlineremote[21,23]);
   
                 my $countdown = &countdown_timer();          if(hidden_button_check() ne 'yes') {
                 if (&hidden_button_check() eq 'yes') {              &Apache::lonhtmlcommon::add_breadcrumb_tool(
                     if ($countdown) {                  'tools', @inlineremote[93,91,81,82,83]);
                         &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);  
                     }  
                 } else {  
                     my @tools = @inlineremote[93,91,81,82,83];  
                     if ($countdown) {  
                         unshift(@tools,$countdown);  
                     }  
                     &Apache::lonhtmlcommon::add_breadcrumb_tool(  
                         'tools',@tools);  
   
                     #publish button in construction space              #publish button in construction space
                     if ($env{'request.state'} eq 'construct'){              if ($env{'request.state'} eq 'construct'){
                         &Apache::lonhtmlcommon::add_breadcrumb_tool(                  &Apache::lonhtmlcommon::add_breadcrumb_tool(
                             'advtools', $inlineremote[63]);                       'advtools', $inlineremote[63]);
                     } else {              } else {
                         &Apache::lonhtmlcommon::add_breadcrumb_tool(                  &Apache::lonhtmlcommon::add_breadcrumb_tool(
                             'tools', $inlineremote[63]);                       'tools', $inlineremote[63]);
                     }              }
                     unless ($env{'request.noversionuri'}=~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {              
                         &Apache::lonhtmlcommon::add_breadcrumb_tool(              unless ($env{'request.noversionuri'}=~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
                             'advtools', @inlineremote[61,71,72,73,74,92]);                  &Apache::lonhtmlcommon::add_breadcrumb_tool(
                     }                      'advtools', @inlineremote[61,71,72,73,74,92]);
                 }  
             }              }
         } else {  
             my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));  
             $requri=&Apache::lonenc::check_encrypt(&unescape($requri));  
             my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});  
             my $navstatus=&get_nav_status();  
             my $clearcstr;  
   
             if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }  
             return <<ENDREGTHIS;  
   
 <script type="text/javascript">  
 // <![CDATA[  
 // BEGIN LON-CAPA Internal  
 var swmenu=null;  
   
     function LONCAPAreg() {  
           swmenu=$reopen;  
           swmenu.clearTimeout(swmenu.menucltim);  
           $timesync  
           $newmail  
           $buttons  
           swmenu.currentURL="$requri";  
           swmenu.reloadURL=swmenu.currentURL+window.location.search;  
           swmenu.currentSymb="$cursymb";  
           swmenu.reloadSymb="$cursymb";  
           swmenu.currentStale=0;  
           $navstatus  
           $hwkadd  
           $editbutton  
     }  
   
     function LONCAPAstale() {  
           swmenu=$reopen  
           swmenu.currentStale=1;  
           if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {  
              swmenu.switchbutton  
              (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');  
           }  
           swmenu.clearbut(7,2);  
           swmenu.clearbut(7,3);  
           swmenu.menucltim=swmenu.setTimeout(  
  'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+  
  'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',  
                           2000);  
       }  
   
 // END LON-CAPA Internal  
 // ]]>  
 </script>  
 ENDREGTHIS  
         }          }
       }
   
     return   &Apache::lonhtmlcommon::scripttag('', 'start')      return   &Apache::lonhtmlcommon::scripttag('', 'start')
            . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)             . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
Line 1040  sub edit_course_upload { Line 761  sub edit_course_upload {
     return $cfile;      return $cfile;
 }  }
   
 sub loadevents() {  
     if ($env{'request.state'} eq 'construct' ||  
         $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }  
     return 'LONCAPAreg();';  
 }  
   
 sub unloadevents() {  
     if ($env{'request.state'} eq 'construct' ||  
         $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }  
     return 'LONCAPAstale();';  
 }  
   
 sub startupremote {  
     my ($lowerurl)=@_;  
     unless ($env{'environment.remote'} eq 'on') {  
         return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');  
     }  
 #  
 # The Remote actually gets launched!  
 #  
     my $configmenu=&rawconfig();  
     my $esclowerurl=&escape($lowerurl);  
     my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');  
     return(<<ENDREMOTESTARTUP);  
 <script type="text/javascript">  
 // <![CDATA[  
 var timestart;  
 function wheelswitch() {  
     if (typeof(document.wheel) != 'undefined') {  
         if (typeof(document.wheel.spin) != 'undefined') {  
             var date=new Date();  
             var waited=Math.round(30-((date.getTime()-timestart)/1000));  
             document.wheel.spin.value=$message;  
         }  
     }  
    if (window.status=='|') {  
       window.status='/';  
    } else {  
       if (window.status=='/') {  
          window.status='-';  
       } else {  
          if (window.status=='-') {  
             window.status='\\\\';  
          } else {  
             if (window.status=='\\\\') { window.status='|'; }  
          }  
       }  
    }  
 }  
   
 // ---------------------------------------------------------- The wait function  
 var canceltim;  
 function wait() {  
    if ((menuloaded==1) || (tim==1)) {  
       window.status='Done.';  
       if (tim==0) {  
          clearTimeout(canceltim);  
          $configmenu  
          window.location='$lowerurl';  
       } else {  
           window.location='/adm/remote?action=collapse&url=$esclowerurl';  
       }  
    } else {  
       wheelswitch();  
       setTimeout('wait();',200);  
    }  
 }  
   
 function main() {  
    canceltim=setTimeout('tim=1;',30000);  
    window.status='-';  
    var date=new Date();  
    timestart=date.getTime();  
    wait();  
 }  
   
 // ]]>  
 </script>  
 ENDREMOTESTARTUP  
 }  
   
 sub setflags() {  
     return(<<ENDSETFLAGS);  
 <script type="text/javascript">  
 // <![CDATA[  
     menuloaded=0;  
     tim=0;  
 // ]]>  
 </script>  
 ENDSETFLAGS  
 }  
   
 sub maincall() {  
     unless ($env{'environment.remote'} eq 'on') { return ''; }  
     return(<<ENDMAINCALL);  
 <script type="text/javascript">  
 // <![CDATA[  
     main();  
 // ]]>  
 </script>  
 ENDMAINCALL  
 }  
   
 sub load_remote_msg {  
     my ($lowerurl)=@_;  
   
     unless ($env{'environment.remote'} eq 'on') { return ''; }  
   
     my $esclowerurl=&escape($lowerurl);  
     my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'  
                 ,'<a href="/adm/remote?action=collapse&amp;url='.$esclowerurl.'">'  
                 ,'</a>');  
     return(<<ENDREMOTEFORM);  
 <p>  
 <form name="wheel">  
 <input name="spin" type="text" size="60" />  
 </form>  
 </p>  
 <p>$link</p>  
 ENDREMOTEFORM  
 }  
   
 sub get_menu_name {  
     my $hostid = $Apache::lonnet::perlvar{'lonHostID'};  
     $hostid =~ s/\W//g;  
     return 'LCmenu'.$hostid;  
 }  
   
   
 sub reopenmenu {  
    unless ($env{'environment.remote'} eq 'on') { return ''; }  
    my $menuname = &get_menu_name();  
    my $nothing = &Apache::lonhtmlcommon::javascript_nothing();  
    return('window.open('.$nothing.',"'.$menuname.'","",false);');  
 }  
   
   
 sub open {  
     my $returnval='';  
     unless ($env{'environment.remote'} eq 'on') {  
         return  
         '<script type="text/javascript">'."\n"  
        .'// <![CDATA['."\n"  
        .'self.name="loncapaclient";'."\n"  
        .'// ]]>'."\n"  
        .'</script>';  
     }  
     my $menuname = &get_menu_name();  
   
 #    unless (shift eq 'unix') {  
 # resizing does not work on linux because of virtual desktop sizes  
 #       $returnval.=(<<ENDRESIZE);  
 #if (window.screen) {  
 #    self.resizeTo(screen.availWidth-215,screen.availHeight-55);  
 #    self.moveTo(190,15);  
 #}  
 #ENDRESIZE  
 #    }  
     $returnval=(<<ENDOPEN);  
 // <![CDATA[  
 window.status='Opening LON-CAPA Remote Control';  
 var menu=window.open("/res/adm/pages/menu.html?inhibitmenu=yes","$menuname",  
 "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");  
 self.name='loncapaclient';  
 // ]]>  
 ENDOPEN  
     return '<script type="text/javascript">'.$returnval.'</script>';  
 }  
   
   
 # ================================================================== Raw Config  # ================================================================== Raw Config
   
 sub clear {  sub clear {
     my ($row,$col)=@_;      my ($row,$col)=@_;
     if ($env{'environment.remote'} eq 'on') {      $inlineremote[10*$row+$col]='';
        if (($row<1) || ($row>13)) { return ''; }      return ''; 
        return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););  
     } else {  
         $inlineremote[10*$row+$col]='';  
         return '';  
     }  
 }  }
   
 # ============================================ Switch a button or create a link  # ============================================ Switch a button or create a link
Line 1237  sub switch { Line 783  sub switch {
     my $idx=10*$row+$col;      my $idx=10*$row+$col;
     $category_members{$cat}.=':'.$idx;      $category_members{$cat}.=':'.$idx;
   
     if ($env{'environment.remote'} eq 'on') {  
         if (($row<1) || ($row>13)) { return ''; }  
 # Remote  
         $img=~s/\.png$/\.gif/;  
         return "\n".  
  qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););  
     }  
   
 # Inline Menu  # Inline Menu
     if ($nobreak==2) { return ''; }      if ($nobreak==2) { return ''; }
     my $text=$top.' '.$bot;      my $text=$top.' '.$bot;
Line 1275  sub switch { Line 813  sub switch {
    }     }
     } else {      } else {
 # Inline Menu  # Inline Menu
         my @tools = (93,91,81,82,83);        $inlineremote[$idx]=
         unless ($env{'request.state'} eq 'construct') {  
             push(@tools,63);  
         }  
         if (($env{'environment.icons'} eq 'iconsonly') &&  
             (grep(/^$idx$/,@tools))) {  
             $inlineremote[$idx] =  
         '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.'</a>';  
         } else {  
             $inlineremote[$idx] =  
        '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.         '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
        '<span class="LC_menubuttons_inline_text">'.$top.'&nbsp;</span></a>';         '<span class="LC_menubuttons_inline_text">'.$top.'&nbsp;</span></a>';
         }  
     }      }
     return '';      return '';
 }  }
Line 1306  sub secondlevel { Line 834  sub secondlevel {
     return $output;      return $output;
 }  }
   
 sub openmenu {  
     my $menuname = &get_menu_name();  
     unless ($env{'environment.remote'} eq 'on') { return ''; }  
     my $nothing = &Apache::lonhtmlcommon::javascript_nothing();  
     return "window.open(".$nothing.",'".$menuname."');";  
 }  
   
 sub inlinemenu {  sub inlinemenu {
     undef(@inlineremote);      undef(@inlineremote);
     undef(%category_members);      undef(%category_members);
Line 1355  sub rawconfig { Line 876  sub rawconfig {
 #  #
     my $textualoverride=shift;      my $textualoverride=shift;
     my $output='';      my $output='';
     if ($env{'environment.remote'} eq 'on') {      return '' unless $textualoverride;
        $output.=  
  "window.status='Opening Remote Control';var swmenu=".&openmenu().  
 "\nwindow.status='Configuring Remote Control ';";  
     } else {  
         unless ($textualoverride) { return ''; }  
     }  
     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'};
Line 1536  sub rawconfig { Line 1051  sub rawconfig {
           $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);
         }          }
     }      }
     if ($env{'environment.remote'} eq 'on') {  
         $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";  
         if (&Apache::lonmsg::newmail()) {  
             $output.='swmenu.setstatus("you have","messages");';  
         }  
     }  
     return $output;      return $output;
 }  }
   
Line 1567  sub check_for_rcrs { Line 1076  sub check_for_rcrs {
     return $showreqcrs;      return $showreqcrs;
 }  }
   
 # ======================================================================= Close  
   
 sub close {  
     unless ($env{'environment.remote'} eq 'on') { return ''; }  
     my $menuname = &get_menu_name();  
     return(<<ENDCLOSE);  
 <script type="text/javascript">  
 // <![CDATA[  
 window.status='Accessing Remote Control';  
 menu=window.open("/adm/rat/empty.html","$menuname",  
                  "height=350,width=150,scrollbars=no,menubar=no");  
 window.status='Disabling Remote Control';  
 menu.active=0;  
 menu.autologout=0;  
 window.status='Closing Remote Control';  
 menu.close();  
 window.status='Done.';  
 // ]]>  
 </script>  
 ENDCLOSE  
 }  
   
 sub dc_popup_js {  sub dc_popup_js {
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                                           more => '(More ...)',                                            more => '(More ...)',
Line 1614  END Line 1101  END
   
 }  }
   
 sub countdown_toggle_js {  
     return <<"END";  
   
 function toggleCountdown() {  
     var countdownid = document.getElementById('duedatecountdown');  
     var currstyle = countdownid.style.display;  
     if (currstyle == 'inline') {  
         countdownid.style.display = 'none';  
         document.getElementById('ddcountcollapse').innerHTML='';  
         document.getElementById('ddcountexpand').innerHTML='&#9668;&nbsp;';  
     } else {  
         countdownid.style.display = 'inline';  
         document.getElementById('ddcountcollapse').innerHTML='&#9658;&nbsp;';  
         document.getElementById('ddcountexpand').innerHTML='';  
     }  
     return;  
 }  
   
 END  
 }  
   
 sub utilityfunctions {  sub utilityfunctions {
     my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));      my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
     if ($currenturl =~ m{^/adm/wrapper/ext/}      if ($currenturl =~ m{^/adm/wrapper/ext/}
Line 1669  sub utilityfunctions { Line 1135  sub utilityfunctions {
     my $esc_url=&escape($currenturl);      my $esc_url=&escape($currenturl);
     my $esc_symb=&escape($currentsymb);      my $esc_symb=&escape($currentsymb);
   
     my $countdown = &countdown_toggle_js();  
   
 return (<<ENDUTILITY)  return (<<ENDUTILITY)
   
     var currentURL=unescape("$esc_url");      var currentURL=unescape("$esc_url");
Line 1807  function open_StoredLinks_Import(rat) { Line 1271  function open_StoredLinks_Import(rat) {
    newWin.focus();     newWin.focus();
 }  }
   
 (function (\$) {  
   \$(document).ready(function () {  
     \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));  
     /*\@cc_on  
       if (!window.XMLHttpRequest) {  
         \$('.LC_hoverable').each(function () {  
           this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });  
           this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });  
         });  
       }  
     \@*/  
   });  
 }(jQuery));  
   
 $countdown  
   
 ENDUTILITY  ENDUTILITY
 }  }
   
Line 1855  sub constspaceform { Line 1303  sub constspaceform {
 ENDCONSTSPACEFORM  ENDCONSTSPACEFORM
 }  }
   
 sub get_nav_status {  
     my $navstatus="swmenu.w_loncapanav_flag=";  
     if ($env{'environment.remotenavmap'} eq 'on') {  
         $navstatus.="1";  
     } else {  
         $navstatus.="-1";  
     }  
     return $navstatus;  
 }  
   
 sub hidden_button_check {  sub hidden_button_check {
     if ( $env{'request.course.id'} eq ''      if ( $env{'request.course.id'} eq ''
          || $env{'request.role.adv'} ) {           || $env{'request.role.adv'} ) {
Line 2231  sub required_privs { Line 1669  sub required_privs {
     return $privs;      return $privs;
 }  }
   
 sub countdown_timer {  
     if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&  
         ($env{'request.filename'}=~/$LONCAPA::assess_re/) &&  
         ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) {  
         my $duedate = &Apache::lonnet::EXT("resource.0.duedate");  
         my @interval=&Apache::lonnet::EXT("resource.0.interval");  
         my $hastimeleft;  
         if (@interval > 1) {  
             my $first_access=&Apache::lonnet::get_first_access($interval[1]);  
             if ($first_access > 0) {  
                 if ($first_access+$interval[0] > time) {  
                     $hastimeleft = 1;  
                 }  
             }  
         }  
         if (($duedate && $duedate > time) ||  
             (!$duedate && $hastimeleft)) {  
             my ($collapse,$expand,$alttxt,$title,$currdisp);  
             if (@interval > 1 && $hastimeleft) {  
                 $currdisp = 'inline';  
                 $collapse = '&#9658;&nbsp;';  
             } else {  
                 $currdisp = 'none';  
                 $expand = '&#9668;&nbsp;';  
             }  
             unless ($env{'environment.icons'} eq 'iconsonly') {  
                 $alttxt = &mt('Timer');  
                 $title = $alttxt.'&nbsp;';  
             }  
             my $desc = &mt('Countdown to due date/time');  
             return <<END;  
   
 <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">  
 <span id="ddcountcollapse" class="LC_menubuttons_inline_text">  
 $collapse  
 </span></a>  
 <span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span>  
 <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">  
 <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>  
 <img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>  
 END  
         }  
     }  
     return;  
 }  
   
 # ================================================================ Main Program  # ================================================================ Main Program
   
 BEGIN {  BEGIN {
Line 2295  BEGIN { Line 1687  BEGIN {
                     } elsif ($configline=~/^prim\:/) {                      } elsif ($configline=~/^prim\:/) {
                         my @entries = (split(/\:/, $configline))[1..5];                          my @entries = (split(/\:/, $configline))[1..5];
                         push @primary_menu, \@entries;                          push @primary_menu, \@entries;
                     } elsif ($configline=~/^primsub\:/) {  
                         my ($parent,@entries) = (split(/\:/, $configline))[1..4];  
                         push (@{$primary_submenu{$parent}},\@entries);  
                     } elsif ($configline=~/^scnd\:/) {                      } elsif ($configline=~/^scnd\:/) {
                         my @entries = (split(/\:/, $configline))[1..5];                          my @entries = (split(/\:/, $configline))[1..5];
                         push @secondary_menu, \@entries;                           push @secondary_menu, \@entries; 
                     } elsif ($configline=~/^scndsub\:/) {  
                         my ($parent,@entries) = (split(/\:/, $configline))[1..4];  
                         push (@{$secondary_submenu{$parent}},\@entries);  
                     } elsif ($configline) {                      } elsif ($configline) {
                         push(@desklines,$configline);                          push(@desklines,$configline);
                     }                      }

Removed from v.1.369.2.17  
changed lines
  Added in v.1.370


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