[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonmenu.pm /xml lonxml.pm

raeburn raeburn@source.lon-capa.org
Mon, 30 Nov 2009 21:29:47 -0000


raeburn		Mon Nov 30 21:29:47 2009 EDT

  Modified files:              
    /loncom/xml	lonxml.pm 
    /loncom/interface	loncommon.pm lonmenu.pm 
  Log:
  - Breadcrumbs displayed in standard location when displaying or editing
    .txt, .js, .css or .tex files in Construction Space.
  - Use different anem for editor in breadcrumb trail depending on type of file.
  - Bug 4936
    - Can edit .tex files in Construction Space. 
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.501 loncom/xml/lonxml.pm:1.502
--- loncom/xml/lonxml.pm:1.501	Mon Nov 30 21:17:41 2009
+++ loncom/xml/lonxml.pm	Mon Nov 30 21:29:41 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.501 2009/11/30 21:17:41 raeburn Exp $
+# $Id: lonxml.pm,v 1.502 2009/11/30 21:29:41 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1612,7 +1612,7 @@
     }
 </script>
 FULLPAGE
-          if ($filetype eq 'html') {
+          if ($filetype eq 'html' || $filetype eq 'tex') {
               $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
               $dragmath_button = &Apache::lonhtmlcommon::dragmath_button('filecont',1);
           }
@@ -1742,12 +1742,25 @@
 
 
     my $file=&Apache::lonnet::filelocation("",$request->uri);
-    my $filetype;
-    if ($file =~ /\.(sty|css|js|txt)$/) {
+    my ($filetype,$breadcrumbtext);
+    if ($file =~ /\.(sty|css|js|txt|tex)$/) {
 	$filetype=$1;
     } else {
 	$filetype='html';
     }
+    if ($filetype eq 'sty') {
+        $breadcrumbtext = 'Style File Editor';
+    } elsif ($filetype eq 'js') {
+        $breadcrumbtext = 'Javascript Editor';
+    } elsif ($filetype eq 'css') {
+        $breadcrumbtext = 'CSS Editor';
+    } elsif ($filetype eq 'txt') {
+        $breadcrumbtext = 'Text Editor';
+    } elsif ($filetype eq 'tex') {
+        $breadcrumbtext = 'TeX Editor';
+    } else {
+        $breadcrumbtext = 'HTML Editor';
+    }
 
 #
 # Edit action? Save file.
@@ -1782,7 +1795,7 @@
 		$filecontents=&createnewsty();
             } elsif ($filetype eq 'js') {
                 $filecontents=&createnewjs();
-            } elsif (($filetype ne 'css') && ($filetype ne 'txt')) {
+            } elsif ($filetype ne 'css' && $filetype ne 'txt' && $filetype ne 'tex') {
 		$filecontents=&createnewhtml();
 	    }
 	    $env{'form.editmode'}='Edit'; #force edit mode
@@ -1806,6 +1819,8 @@
 	    # up if it did
 	        &Apache::structuretags::reset_problem_globals();
 	        &Apache::lonhomework::finished_parsing();
+            } elsif ($filetype eq 'tex') {
+                $result .= &Apache::lontexconvert::converted(\$filecontents);
             } else {
                 $result = $filecontents;
             }
@@ -1813,14 +1828,14 @@
 						    ['rawmode']);
 	    if ($env{'form.rawmode'}) { $result = $filecontents; }
             if ($filetype ne 'html') {
-                my $nochgview = 1; 
+                my $nochgview = 1;
                 my $controls = '';
                     if ($env{'request.state'} eq 'construct') {
                         $controls = &Apache::loncommon::head_subbox(
                                         &Apache::loncommon::CSTR_pageheader()
                                        .&Apache::londefdef::edit_controls($nochgview));
                     }
-                if ($filetype ne 'sty') {
+                if ($filetype ne 'sty' && $filetype ne 'tex') {
                     $result =~ s/</&lt;/g;
                     $result =~ s/>/&gt;/g;
                     $result = '<table class="LC_sty_begin">'.
@@ -1833,7 +1848,7 @@
                         $brcrum = [{'href' => &Apache::loncommon::authorspace(),
                                     'text' => 'Construction Space'},
                                    {'href' => '',
-                                    'text' => 'Editor'}];
+                                    'text' => $breadcrumbtext}];
                     } else {
                         $brcrum = ''; # FIXME: Where are we?
                     }
@@ -1873,7 +1888,7 @@
                             'href' => &Apache::loncommon::authorspace(),
                             'text' => 'Construction Space'},
                            {'href' => '',
-                            'text' => 'HTML Editor'}];
+                            'text' => $breadcrumbtext}];
                 $header = &Apache::loncommon::head_subbox(
                               &Apache::loncommon::CSTR_pageheader());
             }
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.919 loncom/interface/loncommon.pm:1.920
--- loncom/interface/loncommon.pm:1.919	Mon Nov 23 21:45:18 2009
+++ loncom/interface/loncommon.pm	Mon Nov 30 21:29:47 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.919 2009/11/23 21:45:18 raeburn Exp $
+# $Id: loncommon.pm,v 1.920 2009/11/30 21:29:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4549,8 +4549,13 @@
         if($env{'user.name'} ne 'public' && $env{'user.domain'} ne 'public'){
             $bodytag .= Apache::lonmenu::secondary_menu();
             $bodytag .= Apache::lonmenu::serverform();
-            $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); 
-            $bodytag .= Apache::lonmenu::innerregister($forcereg) if $forcereg;
+            $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
+            if ($env{'request.state'} eq 'construct') {
+                $bodytag .= &Apache::lonmenu::innerregister($forcereg,'',
+                                $args->{'bread_crumbs'});
+            } elsif ($forcereg) { 
+                $bodytag .= &Apache::lonmenu::innerregister($forcereg);
+            }
         }else{
             # this is to seperate menu from content when there's no secondary
             # menu. Especially needed for public accessible ressources.
@@ -6770,6 +6775,11 @@
     # Don't add anything more if only_body wanted
     return $result if $args->{'only_body'};
 
+    #Breadcrumbs for Construction Space provided by &bodytag. 
+    if (($env{'environment.remote'} eq 'off') && ($env{'request.state'} eq 'construct')) {
+        return $result;
+    }
+ 
     #Breadcrumbs
     if (exists($args->{'bread_crumbs'}) or exists($args->{'bread_crumbs_component'})) {
 		&Apache::lonhtmlcommon::clear_breadcrumbs();
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.307 loncom/interface/lonmenu.pm:1.308
--- loncom/interface/lonmenu.pm:1.307	Mon Nov 30 06:23:32 2009
+++ loncom/interface/lonmenu.pm	Mon Nov 30 21:29:47 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.307 2009/11/30 06:23:32 raeburn Exp $
+# $Id: lonmenu.pm,v 1.308 2009/11/30 21:29:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -512,7 +512,7 @@
 }
 
 sub innerregister {
-    my ($forcereg, $titletable) = @_;
+    my ($forcereg,$titletable,$bread_crumbs) = @_;
     my $result = '';
     my ($uname,$thisdisfn);
     my $const_space = ($env{'request.state'} eq 'construct');
@@ -753,6 +753,14 @@
 s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
 ENDMENUITEMS
             }
+            if ($noremote) {
+                if (ref($bread_crumbs) eq 'ARRAY') {
+                    &Apache::lonhtmlcommon::clear_breadcrumbs();
+                    foreach my $crumb (@{$bread_crumbs}){
+                        &Apache::lonhtmlcommon::add_breadcrumb($crumb);
+                    }
+                }
+            }
         } elsif ( defined($env{'request.course.id'}) && 
 		 $env{'request.symb'} ne '' ) {
 #