[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm /xml londefdef.pm lontex.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 17 Feb 2003 17:34:17 -0000


www		Mon Feb 17 12:34:17 2003 EDT

  Modified files:              
    /loncom/interface	lonmenu.pm 
    /loncom/xml	londefdef.pm lontex.pm 
  Log:
  Starting work on putting "Forward", "Backward", etc, into header of pages
  for textual mode.
  
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.39 loncom/interface/lonmenu.pm:1.40
--- loncom/interface/lonmenu.pm:1.39	Fri Feb 14 16:22:04 2003
+++ loncom/interface/lonmenu.pm	Mon Feb 17 12:34:16 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.39 2003/02/14 21:22:04 www Exp $
+# $Id: lonmenu.pm,v 1.40 2003/02/17 17:34:16 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,18 +41,19 @@
 use Apache::File;
 use vars qw(@desklines $readdesk);
 
-# ======================================================= Make the menu buttons
+# ============================= This gets called at the top of the body section
 
 sub menubuttons {
     my $forcereg=shift;
     my $target  =shift;
+    my $registration=shift;
     unless ($ENV{'browser.interface'} eq 'textual') { return ''; }
     my $output='<a href="/adm/menu">Main Menu</a><br />';
+    if ($registration) { $output.=&innerregister($forcereg,$target); }
     return $output."<hr />";
 }
 
-# ============================================== Register a URL with the remote
-
+# ====================================== This gets called in the header section
 
 sub registerurl {
     my $forcereg=shift;
@@ -73,35 +74,52 @@
          '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>';
     }
     if ($Apache::lonxml::registered && !$forcereg) { return ''; }
+    $result.=&innerregister($forcereg,$target);
+    return $result;
+}
+
+# =========== This gets called in order to register a URL, both with the Remote
+# =========== and in the body of the document
+
+sub innerregister {
+    my $forcereg=shift;
+    my $target = shift;
+    my $result = '';
+
     $Apache::lonxml::registered=1;
+
+    my $textual=($ENV{'browser.interface'} eq 'textual');
     my $reopen=&Apache::lonmenu::reopenmenu();
+
     my $newmail='';
     if (&Apache::lonmsg::newmail()) { 
-       $newmail='swmenu.setstatus("you have","messages");';
+       $newmail=($textual?'<b>You have messages</b><br />':
+                          'swmenu.setstatus("you have","messages");');
     }
-    my $timesync='swmenu.syncclock(1000*'.time.');';
+    my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
+# -- This is for URLs that actually can be registered
     if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) {
+# -- This applies to homework problems for users with grading privileges
         my $hwkadd='';
-        if ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
+        if 
+      ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
 	    if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
-		$hwkadd.=(<<ENDSUBM);
-                     swmenu.switchbutton(7,1,'subm.gif','view sub','missions','gocmd("/adm/grades","submission")',
-                     'View user submissions for this assessment resource');
-ENDSUBM
+		$hwkadd.=&switch('','',7,1,'subm.gif','view sub','missions',
+                       "gocmd('/adm/grades','submission')",
+		       'View user submissions for this assessment resource');
             }
 	    if (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) {
-		$hwkadd.=(<<ENDGRDS);
-                     swmenu.switchbutton(7,2,'pgrd.gif','problem','grades','gocmd("/adm/grades","gradingmenu")',
-                     'Modify user grades for this assessment resource');
-ENDGRDS
+		$hwkadd.=&switch('','',7,2,'pgrd.gif','problem','grades',
+                       "gocmd('/adm/grades','gradingmenu')",
+                       'Modify user grades for this assessment resource');
             }
 	    if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) {
-		$hwkadd.=(<<ENDPARM);
-                     swmenu.switchbutton(7,3,'pparm.gif','problem','parms','gocmd("/adm/parmset","set")',
-                     'Modify deadlines, etc, for this assessment resource');
-ENDPARM
+		$hwkadd.=&switch('','',7,3,'pparm.gif','problem','parms',
+                       "gocmd('/adm/parmset','set')",
+                       'Modify deadlines, etc, for this assessment resource');
             }
 	}
+# -- End Homework
         ###
         ### Determine whether or not to display the 'cstr' button for this
         ### resource
@@ -125,7 +143,7 @@
                 # Check that we are on the correct machine
                 my $home = &Apache::lonnet::homeserver($caname,$cadom);
                 if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
-                    $editbutton=&Apache::lonmenu::switch
+                    $editbutton=&switch
                         ('','',6,1,$top,,$bottom,$action,$desc);
                 }
             }
@@ -149,11 +167,11 @@
             }        
             # Finally, turn the button on or off
             if ($cfile) {
-                $editbutton=&Apache::lonmenu::switch
+                $editbutton=&switch
                     ('','',6,1,'cstr.gif','edit','resource',
                      "go('".$cfile."');","Edit this resource");
             } elsif ($editbutton eq '') {
-                $editbutton = '    swmenu.clearbut(6,1);';
+                $editbutton=&clear(6,1);
             }
         }
         ###
@@ -373,10 +391,12 @@
    } else { return ''; }
 }
 
+# ============================================ 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(..)".
+
 sub switch {
-    my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc)=@_;
+    my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_;
     $act=~s/\$uname/$uname/g;
     $act=~s/\$udom/$udom/g;
     unless ($ENV{'browser.interface'} eq 'textual') {
@@ -385,7 +405,8 @@
    } else {
        my $text=$top.' '.$bot;
        $text=~s/\- //;
-       return '<br /><a href="javascript:'.$act.';">'.$text.'</a> '.$desc;
+       return ($nobreak?'':'<br />').
+        '<a href="javascript:'.$act.';">'.$text.'</a> '.$desc;
    }
 }
 
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.114 loncom/xml/londefdef.pm:1.115
--- loncom/xml/londefdef.pm:1.114	Fri Feb 14 15:57:09 2003
+++ loncom/xml/londefdef.pm	Mon Feb 17 12:34:16 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.114 2003/02/14 20:57:09 sakharuk Exp $
+# $Id: londefdef.pm,v 1.115 2003/02/17 17:34:16 www Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -400,7 +400,7 @@
 		</form>
 EDITBUTTON
               } else {
-		$currentstring.=&Apache::lonmenu::menubuttons(undef,$target);
+		$currentstring.=&Apache::lonmenu::menubuttons(undef,$target,1);
               }
        	    } elsif ($target eq 'tex') {
               $currentstring = '\begin{document}';  
Index: loncom/xml/lontex.pm
diff -u loncom/xml/lontex.pm:1.4 loncom/xml/lontex.pm:1.5
--- loncom/xml/lontex.pm:1.4	Fri Feb 14 14:35:55 2003
+++ loncom/xml/lontex.pm	Mon Feb 17 12:34:17 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # TeX Content Handler
 #
-# $Id: lontex.pm,v 1.4 2003/02/14 19:35:55 www Exp $
+# $Id: lontex.pm,v 1.5 2003/02/17 17:34:17 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -83,7 +83,7 @@
     '" onUnload="'.
       &Apache::lonmenu::unloadevents().
     '">'.
-      &Apache::lonmenu::menubuttons(undef,'web')
+      &Apache::lonmenu::menubuttons(undef,'web',1)
   );
   $r->print(&Apache::lontexconvert::converted(\$texstring));
   $r->print('</body>');