--- loncom/xml/lonxml.pm	2010/10/01 14:21:55	1.494.4.5
+++ loncom/xml/lonxml.pm	2009/10/15 21:12:51	1.500
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.494.4.5 2010/10/01 14:21:55 raeburn Exp $
+# $Id: lonxml.pm,v 1.500 2009/10/15 21:12:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -243,7 +243,7 @@ sub tokeninputfield {
         document.tokeninput.barcode.value='';
     }  
 </script>
-<form method="post" name="tokeninput" action="">
+<form method="post" name="tokeninput">
 <table border="2" bgcolor="#FFFFBB">
 <tr><th>DocID Checkin</th></tr>
 <tr><td>
@@ -251,7 +251,7 @@ sub tokeninputfield {
 <tr>
 <td>Scan in Barcode</td>
 <td><input type="text" size="22" name="barcode" 
-onchange="updatetoken()"/></td>
+onChange="updatetoken()"/></td>
 </tr>
 <tr><td><i>or</i> Type in DocID</td>
 <td>
@@ -260,7 +260,7 @@ onchange="updatetoken()"/></td>
 <input type="text" size="5" name="codetwo" />
 <b><font size="+2">*</font></b>
 <input type="text" size="10" name="codethree" value="$defhost" 
-onchange="this.value=this.value.toUpperCase()" />
+onChange="this.value=this.value.toUpperCase()" />
 </td></tr>
 </table>
 </td></tr>
@@ -1043,7 +1043,7 @@ sub get_id {
     my ($parstack,$safeeval)=@_;
     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
     if ($env{'request.state'} eq 'construct' && $id =~ /([._]|[^\w\d\s[:punct:]])/) {
-	&error(&mt("ID [_1] contains invalid characters, IDs are only allowed to contain letters, numbers, spaces and -",'<tt>'.$id.'</tt>'));
+	&error(&mt('ID [_1] contains invalid characters. IDs are only allowed to contain letters, numbers, spaces and -','"<tt>'.$id.'</tt>"'));
     }
     if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
     return $id;
@@ -1523,25 +1523,17 @@ SIMPLECONTENT
 
 sub verify_html {
     my ($filecontents)=@_;
-    my ($is_html,$is_xml);
-    if ($filecontents =~/(?:\<|\&lt\;)\?xml[^\<]*\?(?:\>|\&gt\;)/is) {
-        $is_xml = 1;
-    } elsif ($filecontents =~/(?:\<|\&lt\;)html(?:\s+[^\<]+|\s*)(?:\>|\&gt\;)/is) {
-        $is_html = 1;
-    }
-    unless ($is_xml || $is_html) {
-        return &mt('File does not have [_1] or [_2] starting tag','&lt;html&gt;','&lt;?xml ?&gt;');
-    }
-    if ($is_html) {
-        if ($filecontents!~/(?:\<|\&lt\;)\/html(?:\>|\&gt\;)/is) {
-            return &mt('File does not have [_1] ending tag','&lt;html&gt;');
-        }
-        if ($filecontents!~/(?:\<|\&lt\;)(?:body|frameset)[^\<]*(?:\>|\&gt\;)/is) {
-            return &mt('File does not have [_1] or [_2] starting tag','&lt;body&gt;','&lt;frameset&gt;');
-        }
-        if ($filecontents!~/(?:\<|\&lt\;)\/(?:body|frameset)[^\<]*(?:\>|\&gt\;)/is) {
-            return &mt('File does not have [_1] or [_2] ending tag','&lt;body&gt;','&lt;frameset&gt;');
-        }
+    if ($filecontents!~/(?:\<|\&lt\;)(?:html|xml)[^\<]*(?:\>|\&gt\;)/is) {
+       return &mt('File does not have [_1] or [_2] starting tag','&lt;html&gt;','&lt;xml&gt;');
+    }
+    if ($filecontents!~/(?:\<|\&lt\;)\/(?:html|xml)(?:\>|\&gt\;)/is) {
+       return &mt('File does not have [_1] or [_2] ending tag','&lt;html&gt;','&lt;xml&gt;');
+    }
+    if ($filecontents!~/(?:\<|\&lt\;)(?:body|frameset)[^\<]*(?:\>|\&gt\;)/is) {
+       return &mt('File does not have [_1] or [_2] starting tag','&lt;body&gt;','&lt;frameset&gt;');
+    }
+    if ($filecontents!~/(?:\<|\&lt\;)\/(?:body|frameset)[^\<]*(?:\>|\&gt\;)/is) {
+       return &mt('File does not have [_1] or [_2] ending tag','&lt;body&gt;','&lt;frameset&gt;');
     }
     return '';
 }
@@ -1556,27 +1548,22 @@ sub renderingoptions {
     }
     my $output;
     unless ($env{'form.forceedit'}) {
-       $output .=
-           '<span class="LC_nobreak">'.
+       $output .= '  
+           <span class="LC_nobreak">'.
            &mt('Language:').' '.
-           &Apache::loncommon::select_form(
-               $env{'form.languages'},
-               'languages',
-               &Apache::lonlocal::texthash(%langchoices)).
-           '</span>';
+           &Apache::loncommon::select_form($env{'form.languages'},'languages',
+                                           %langchoices).'
+           </span>';
     }
-    $output .=
-     ' <span class="LC_nobreak">'.
+    $output .= '
+     <span class="LC_nobreak">'.
        &mt('Math Rendering:').' '.
-       &Apache::loncommon::select_form(
-           $env{'form.texengine'},
-           'texengine',
-           &Apache::lonlocal::texthash
-               (''        => '',
-                'tth'     => 'tth (TeX to HTML)',
-                'jsMath'  => 'jsMath',
-                'mimetex' => 'mimetex (Convert to Images)')).
-     '</span>';
+       &Apache::loncommon::select_form($env{'form.texengine'},'texengine',
+                                                     ('' => '',
+                                                      'tth' => 'tth (TeX to HTML)',
+                                                      'jsMath' => 'jsMath',
+                                                      'mimetex' => 'mimetex (Convert to Images)')).'
+     </span>';
     return $output;
 }
 
@@ -1724,8 +1711,8 @@ sub handler {
 	$request->set_last_modified(&Apache::lonnet::metadata($request->uri,
 							      'lastrevisiondate'));
     }
-    # Embedded Flash movies (e.g., from Camtasia) served from https will not display in IE
-    #   if XML config file has expired from cache.
+    # Embedded Flash movies from Camtasia served from https will not display in IE
+    #   if XML config file has expired from cache.    
     if ($ENV{'SERVER_PORT'} == 443) {
         if ($request->uri =~ /\.xml$/) {
             my ($httpbrowser,$clientbrowser) =
@@ -1770,10 +1757,13 @@ sub handler {
     if ($filecontents eq -1) {
 	my $start_page=&Apache::loncommon::start_page('File Error');
 	my $end_page=&Apache::loncommon::end_page();
-	my $fnf=&mt('File not found');
+        my $errormsg='<p class="LC_error">'
+                    .&mt('File not found: [_1]'
+                        ,'<span class="LC_filename">'.$file.'</span>')
+                    .'</p>';
 	$result=(<<ENDNOTFOUND);
 $start_page
-<b>$fnf: $file</b>
+$errormsg
 $end_page
 ENDNOTFOUND
         $filecontents='';
@@ -1812,11 +1802,14 @@ ENDNOTFOUND
 	    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 						    ['rawmode']);
 	    if ($env{'form.rawmode'}) { $result = $filecontents; }
-	    if ($filetype ne 'html') {
+            if ($filetype ne 'html') {
                 my $nochgview = 1; 
-		my $controls =
-		    ($env{'request.state'} eq 'construct') ? &Apache::londefdef::edit_controls($nochgview)
-		                                           : '';
+                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') {
                     $result =~ s/</&lt;/g;
                     $result =~ s/>/&gt;/g;
@@ -1825,17 +1818,27 @@ ENDNOTFOUND
                               '</pre></b></td></tr></table>';
                 }
                 if ($env{'environment.remote'} eq 'off') {
-                    my %options = ('bgcolor' => '#FFFFFF');
-		    $result = 
-		        &Apache::loncommon::start_page(undef,undef,\%options).
-		        $controls.
-		        $result.
-		        &Apache::loncommon::end_page();
+                    my $brcrum;
+                    if ($env{'request.state'} eq 'construct') {
+                        $brcrum = [{'href' => &Apache::loncommon::authorspace(),
+                                    'text' => 'Construction Space'},
+                                   {'href' => '',
+                                    'text' => 'Editor'}];
+                    } else {
+                        $brcrum = ''; # FIXME: Where are we?
+                    }
+                    my %options = ('bread_crumbs' => $brcrum,
+                                   'bgcolor'      => '#FFFFFF');
+                    $result =
+                        &Apache::loncommon::start_page(undef,undef,\%options)
+                       .$controls
+                       .$result
+                       .&Apache::loncommon::end_page();
                 } else {
                     $result = $controls.$result;
                 }
             }
-	}
+        }
     }
 
 #
@@ -1852,9 +1855,18 @@ ENDNOTFOUND
 
 	    my %options = 
 		('add_entries' =>
-                   {'onresize' => $add_to_onresize,
-		    'onload'   => $add_to_onload,   });
-
+                   {'onresize'     => $add_to_onresize,
+                    'onload'       => $add_to_onload,   });
+            my $header;
+            if ($env{'request.state'} eq 'construct') {
+                $options{'bread_crumbs'} = [{
+                            'href' => &Apache::loncommon::authorspace(),
+                            'text' => 'Construction Space'},
+                           {'href' => '',
+                            'text' => 'HTML Editor'}];
+                $header = &Apache::loncommon::head_subbox(
+                              &Apache::loncommon::CSTR_pageheader());
+            }
 	    if ($env{'environment.remote'} ne 'off') {
 		$options{'bgcolor'}   = '#FFFFFF';
 		$options{'only_body'} = 1;
@@ -1864,10 +1876,11 @@ ENDNOTFOUND
 		&Apache::loncommon::resize_textarea_js();
 	    my $start_page = &Apache::loncommon::start_page(undef,$js,
 							    \%options);
-	    $result=$start_page.
-		&Apache::lonxml::message_location().
-		$edit_info.
-		&Apache::loncommon::end_page();
+            $result = $start_page
+                     .$header
+                     .&Apache::lonxml::message_location()
+                     .$edit_info
+                     .&Apache::loncommon::end_page();
         }
     }
     if ($filetype eq 'html') { &writeallows($request->uri); }