--- loncom/xml/londefdef.pm	2009/03/31 10:12:45	1.399
+++ loncom/xml/londefdef.pm	2009/10/01 15:31:24	1.411
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.399 2009/03/31 10:12:45 foxr Exp $
+# $Id: londefdef.pm,v 1.411 2009/10/01 15:31:24 bisitz Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -538,36 +538,69 @@ sub start_body {
 	
 	my $extra_head = &generate_css_links();
 
+    # Breadcrumbs
+    &Apache::lonhtmlcommon::clear_breadcrumbs();
+    if ($env{'request.state'} eq 'construct') {
+        &Apache::lonhtmlcommon::add_breadcrumb({
+            'text'  => 'Construction Space',
+            'href'  => &Apache::loncommon::authorspace(),
+        });
+        &Apache::lonhtmlcommon::add_breadcrumb({
+            'text'  => 'HTML Editor',
+            'href'  => '',
+        });
+    } else {
+        # FIXME Where are we?
+    }
+
 	$currentstring = 
 	    &Apache::loncommon::start_page($Apache::londefdef::title,
 					   $Apache::londefdef::head
 					      .$extra_head,
 					   {'add_entries'    => $token->[2],
-					    'no_title'       => 1,
+#					    'no_title'       => 1,
 					    'force_register' => 1});
 
-	if ($env{'request.state'} ne 'published') {
-	    $currentstring.=&Apache::lonmenu::constspaceform();
-	    $currentstring.=&Apache::londefdef::edit_controls();
-	}
-	$currentstring.=&Apache::lonxml::message_location();
+    $currentstring .= &Apache::lonhtmlcommon::breadcrumbs();
+
+        my $header = '';
+        if ($env{'request.state'} ne 'published' &&
+            $env{'request.state'} ne 'construct') {
+            $header=&Apache::lonmenu::constspaceform();
+        }
+        if ($env{'request.state'} ne 'published') {
+            $header.=&Apache::londefdef::edit_controls();
+        }
+        if ($env{'request.state'} eq 'construct') {
+            $currentstring.=&Apache::loncommon::head_subbox(
+                                &Apache::loncommon::CSTR_pageheader()
+                               .$header);
+        }
+        $currentstring.=&Apache::lonxml::message_location();
     } elsif ($target eq 'tex') {
-	$currentstring = '\begin{document}';  
-    } 
+        $currentstring = '';   #  '\begin{document}' is in header.
+    }
+
     return $currentstring;
 }
 
 sub edit_controls {
+    my ($nochgview) = @_;
     my $result .= '
 <form method="post">
-<div class="LC_edit_problem_header">
+<div class="LC_edit_problem_header">';
+    unless ($nochgview) {
+        $result .= '
 <div class="LC_edit_problem_header_row1">'.
 &Apache::lonxml::renderingoptions().'
 <input type="submit" name="changeproblemmode" value="'.&mt('Change View').'" />
+</div>';
+    }
+    $result .= '
+<div><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" /></div>
 </div>
-<div class="LC_edit_problem_header_edit_row"><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" /></div></div>
 </form>
-<br />';
+';
     return $result;
 }
 
@@ -1344,10 +1377,6 @@ sub start_font {
     my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {
 	my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
-	if ($face!~/symbol/i) {
-	    if (($env{'browser.fontenhance'} eq 'on') || 
-		($env{'browser.blackwhite'} eq 'on')) { return ''; }
-	}
 	$currentstring = $token->[4];     
     }  elsif ($target eq 'tex') {
 	my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
@@ -1612,6 +1641,26 @@ sub start_a {
 	my $href=&Apache::lonxml::get_param('href',$parstack,$safeeval,
 					    undef,1);
 	$currentstring=&Apache::lonenc::encrypt_ref($token,{'href'=>$href});
+        if ($href =~ /\S/) {
+            if ($href !~ m{^https?://}) {
+                my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
+                my $linkurl;
+                if ($href =~ m{^/uploaded/}) {
+                    $linkurl = $href;
+                } elsif ($href =~ m{^[^/]}) {
+                    my $path = $url;
+                    $path  =~ s{[^/]*$}{};
+                    $linkurl = $path.$href;
+                }
+                if ($linkurl =~ m{^/uploaded/}) {
+                    if (!&Apache::lonnet::allowed('bre',$linkurl)) {
+                        if (&Apache::lonnet::is_on_map($url)) {
+                            &Apache::lonxml::extlink($linkurl);
+                        }
+                    }
+                }
+            }
+        }
     }
     return $currentstring;
 }
@@ -3483,7 +3532,7 @@ sub start_frameset {
 	    &Apache::loncommon::start_page($Apache::londefdef::title,
 					   $Apache::londefdef::head,
 					   {'add_entries'    => $token->[2],
-					    'no_title'       => 1,
+#					    'no_title'       => 1,
 					    'force_register' => 1,
 					    'frameset'       => 1,});
 
@@ -4762,12 +4811,15 @@ sub is_inside_of {
 #
 sub latex_header
 {
+    my ($mode) = @_;
     my $currentstring = '';
 
     $currentstring .= 
+	"\n% &Apache::lonxml::londefdef \n" .
 	'\documentclass[letterpaper,twoside]{article}\raggedbottom';
     if (($env{'form.latex_type'}=~'batchmode') ||
-	(!$env{'request.role.adv'})) {$currentstring .='\batchmode';} 
+	(!$env{'request.role.adv'}) || 
+	($mode eq 'batchmode')) {$currentstring .='\batchmode';} 
     $currentstring .= '\newcommand{\keephidden}[1]{}'.
 	'\renewcommand{\deg}{$^{\circ}$}'.
 	'\usepackage{multirow}'.
@@ -4795,8 +4847,14 @@ sub latex_header
 	'\usepackage{amssymb}'.
 	'\usepackage{amsfonts}'.
 	'\usepackage{amsthm}'.
-	'\usepackage{amscd}';
-    
+	'\usepackage{amscd}'
+        .'\usepackage{picins}\usepackage{calc}'."\n". # From lonprintout.pm
+	'\usepackage[T1]{fontenc}'."\n".
+	'\usepackage{lmodern}'."\n".
+	'\usepackage[postscript]{ucs}'."\n".
+	'\usepackage[utf8x]{inputenc}'."\n".
+	'\usepackage{pifont}'  . "\n";
+	
     if($env{'form.pdfFormFields'} eq 'yes') {
 	$currentstring .= '\usepackage{hyperref}'.
 	    '\usepackage{eforms}'.
@@ -4805,6 +4863,7 @@ sub latex_header
     
         $currentstring .= '\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}'.
                           '\renewenvironment{theindex}{\begin{list}{}{{\vskip 1mm \noindent \large\textbf{Index}} \newline \setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.01in}\setlength{\itemsep}{0.1in}\setlength{\parsep}{-0.02in}\setlength{\belowdisplayskip}{0.01in}\setlength{\abovedisplayskip}{0.01in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.01in}}}{\end{list}}';
+    $currentstring .= '\begin{document}';
     
     return $currentstring;