Diff for /loncom/xml/lonxml.pm between versions 1.494.4.3 and 1.502

version 1.494.4.3, 2010/01/28 18:46:47 version 1.502, 2009/11/30 21:29:41
Line 111  use Apache::loncacc(); Line 111  use Apache::loncacc();
 use Apache::lonmaxima();  use Apache::lonmaxima();
 use Apache::lonr();  use Apache::lonr();
 use Apache::lonlocal;  use Apache::lonlocal;
   use Apache::lonhtmlcommon();
   
 #====================================   Main subroutine: xmlparse    #====================================   Main subroutine: xmlparse  
   
Line 1043  sub get_id { Line 1044  sub get_id {
     my ($parstack,$safeeval)=@_;      my ($parstack,$safeeval)=@_;
     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);      my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
     if ($env{'request.state'} eq 'construct' && $id =~ /([._]|[^\w\d\s[:punct:]])/) {      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; }      if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
     return $id;      return $id;
Line 1548  sub renderingoptions { Line 1549  sub renderingoptions {
     }      }
     my $output;      my $output;
     unless ($env{'form.forceedit'}) {      unless ($env{'form.forceedit'}) {
        $output .=         $output .= '  
            '<span class="LC_nobreak">'.             <span class="LC_nobreak">'.
            &mt('Language:').' '.             &mt('Language:').' '.
            &Apache::loncommon::select_form(             &Apache::loncommon::select_form($env{'form.languages'},'languages',
                $env{'form.languages'},                                             %langchoices).'
                'languages',             </span>';
                &Apache::lonlocal::texthash(%langchoices)).  
            '</span>';  
     }      }
     $output .=      $output .= '
      ' <span class="LC_nobreak">'.       <span class="LC_nobreak">'.
        &mt('Math Rendering:').' '.         &mt('Math Rendering:').' '.
        &Apache::loncommon::select_form(         &Apache::loncommon::select_form($env{'form.texengine'},'texengine',
            $env{'form.texengine'},                                                       ('' => '',
            'texengine',                                                        'tth' => 'tth (TeX to HTML)',
            &Apache::lonlocal::texthash                                                        'jsMath' => 'jsMath',
                (''        => '',                                                        'mimetex' => 'mimetex (Convert to Images)')).'
                 'tth'     => 'tth (TeX to HTML)',       </span>';
                 'jsMath'  => 'jsMath',  
                 'mimetex' => 'mimetex (Convert to Images)')).  
      '</span>';  
     return $output;      return $output;
 }  }
   
Line 1616  FULLPAGE Line 1612  FULLPAGE
     }      }
 </script>  </script>
 FULLPAGE  FULLPAGE
           if ($filetype eq 'html') {            if ($filetype eq 'html' || $filetype eq 'tex') {
               $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');                $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
               $dragmath_button = &Apache::lonhtmlcommon::dragmath_button('filecont',1);                $dragmath_button = &Apache::lonhtmlcommon::dragmath_button('filecont',1);
           }            }
Line 1630  FULLPAGE Line 1626  FULLPAGE
       }        }
   
       my $titledisplay=&display_title();        my $titledisplay=&display_title();
         my $wysiwyglink;
       my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit',        my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit',
  'vi' => 'Save and View',   'vi' => 'Save and View',
  'dv' => 'Discard Edits and View',   'dv' => 'Discard Edits and View',
Line 1644  FULLPAGE Line 1641  FULLPAGE
           if ($htmlerror) {            if ($htmlerror) {
               $htmlerror='<span class="LC_error">'.$htmlerror.'</span>';                $htmlerror='<span class="LC_error">'.$htmlerror.'</span>';
           }            }
             if (&Apache::lonhtmlcommon::htmlareabrowser()) {
                 if (&Apache::lonhtmlcommon::htmlareablocked()) {
                     $wysiwyglink = &Apache::lonhtmlcommon::enablelink($textarea_id);
                 } else {
                     $wysiwyglink = &Apache::lonhtmlcommon::disablelink($textarea_id);
                 }
             }
       }        }
       my $editfooter=(<<ENDFOOTER);        my $editfooter=(<<ENDFOOTER);
 $initialize  $initialize
Line 1668  $initialize Line 1672  $initialize
   </div>    </div>
   <textarea $textarea_events style="width:100%" cols="80" rows="44" name="filecont" id="filecont">$filecontents</textarea>    <textarea $textarea_events style="width:100%" cols="80" rows="44" name="filecont" id="filecont">$filecontents</textarea>
   <div id="LC_aftertextarea">    <div id="LC_aftertextarea">
       $wysiwyglink
     <br />      <br />
     $titledisplay      $titledisplay
   </div>    </div>
Line 1716  sub handler { Line 1721  sub handler {
  $request->set_last_modified(&Apache::lonnet::metadata($request->uri,   $request->set_last_modified(&Apache::lonnet::metadata($request->uri,
       'lastrevisiondate'));        'lastrevisiondate'));
     }      }
     # Embedded Flash movies (e.g., from Camtasia) served from https will not display in IE      # Embedded Flash movies from Camtasia served from https will not display in IE
     #   if XML config file has expired from cache.      #   if XML config file has expired from cache.    
     if ($ENV{'SERVER_PORT'} == 443) {      if ($ENV{'SERVER_PORT'} == 443) {
         if ($request->uri =~ /\.xml$/) {          if ($request->uri =~ /\.xml$/) {
             my ($httpbrowser,$clientbrowser) =              my ($httpbrowser,$clientbrowser) =
Line 1737  sub handler { Line 1742  sub handler {
   
   
     my $file=&Apache::lonnet::filelocation("",$request->uri);      my $file=&Apache::lonnet::filelocation("",$request->uri);
     my $filetype;      my ($filetype,$breadcrumbtext);
     if ($file =~ /\.(sty|css|js|txt)$/) {      if ($file =~ /\.(sty|css|js|txt|tex)$/) {
  $filetype=$1;   $filetype=$1;
     } else {      } else {
  $filetype='html';   $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.  # Edit action? Save file.
Line 1762  sub handler { Line 1780  sub handler {
     if ($filecontents eq -1) {      if ($filecontents eq -1) {
  my $start_page=&Apache::loncommon::start_page('File Error');   my $start_page=&Apache::loncommon::start_page('File Error');
  my $end_page=&Apache::loncommon::end_page();   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);   $result=(<<ENDNOTFOUND);
 $start_page  $start_page
 <b>$fnf: $file</b>  $errormsg
 $end_page  $end_page
 ENDNOTFOUND  ENDNOTFOUND
         $filecontents='';          $filecontents='';
Line 1774  ENDNOTFOUND Line 1795  ENDNOTFOUND
  $filecontents=&createnewsty();   $filecontents=&createnewsty();
             } elsif ($filetype eq 'js') {              } elsif ($filetype eq 'js') {
                 $filecontents=&createnewjs();                  $filecontents=&createnewjs();
             } elsif (($filetype ne 'css') && ($filetype ne 'txt')) {              } elsif ($filetype ne 'css' && $filetype ne 'txt' && $filetype ne 'tex') {
  $filecontents=&createnewhtml();   $filecontents=&createnewhtml();
     }      }
     $env{'form.editmode'}='Edit'; #force edit mode      $env{'form.editmode'}='Edit'; #force edit mode
Line 1798  ENDNOTFOUND Line 1819  ENDNOTFOUND
     # up if it did      # up if it did
         &Apache::structuretags::reset_problem_globals();          &Apache::structuretags::reset_problem_globals();
         &Apache::lonhomework::finished_parsing();          &Apache::lonhomework::finished_parsing();
               } elsif ($filetype eq 'tex') {
                   $result .= &Apache::lontexconvert::converted(\$filecontents);
             } else {              } else {
                 $result = $filecontents;                  $result = $filecontents;
             }              }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
     ['rawmode']);      ['rawmode']);
     if ($env{'form.rawmode'}) { $result = $filecontents; }      if ($env{'form.rawmode'}) { $result = $filecontents; }
     if ($filetype ne 'html') {              if ($filetype ne 'html') {
                 my $nochgview = 1;                   my $nochgview = 1;
  my $controls =                  my $controls = '';
     ($env{'request.state'} eq 'construct') ? &Apache::londefdef::edit_controls($nochgview)                      if ($env{'request.state'} eq 'construct') {
                                            : '';                          $controls = &Apache::loncommon::head_subbox(
                 if ($filetype ne 'sty') {                                          &Apache::loncommon::CSTR_pageheader()
                                          .&Apache::londefdef::edit_controls($nochgview));
                       }
                   if ($filetype ne 'sty' && $filetype ne 'tex') {
                     $result =~ s/</&lt;/g;                      $result =~ s/</&lt;/g;
                     $result =~ s/>/&gt;/g;                      $result =~ s/>/&gt;/g;
                     $result = '<table class="LC_sty_begin">'.                      $result = '<table class="LC_sty_begin">'.
Line 1817  ENDNOTFOUND Line 1843  ENDNOTFOUND
                               '</pre></b></td></tr></table>';                                '</pre></b></td></tr></table>';
                 }                  }
                 if ($env{'environment.remote'} eq 'off') {                  if ($env{'environment.remote'} eq 'off') {
                     my %options = ('bgcolor' => '#FFFFFF');                      my $brcrum;
     $result =                       if ($env{'request.state'} eq 'construct') {
         &Apache::loncommon::start_page(undef,undef,\%options).                          $brcrum = [{'href' => &Apache::loncommon::authorspace(),
         $controls.                                      'text' => 'Construction Space'},
         $result.                                     {'href' => '',
         &Apache::loncommon::end_page();                                      'text' => $breadcrumbtext}];
                       } 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 {                  } else {
                     $result = $controls.$result;                      $result = $controls.$result;
                 }                  }
             }              }
  }          }
     }      }
   
 #  #
Line 1844  ENDNOTFOUND Line 1880  ENDNOTFOUND
   
     my %options =       my %options = 
  ('add_entries' =>   ('add_entries' =>
                    {'onresize' => $add_to_onresize,                     {'onresize'     => $add_to_onresize,
     'onload'   => $add_to_onload,   });                      'onload'       => $add_to_onload,   });
               my $header;
               if ($env{'request.state'} eq 'construct') {
                   $options{'bread_crumbs'} = [{
                               'href' => &Apache::loncommon::authorspace(),
                               'text' => 'Construction Space'},
                              {'href' => '',
                               'text' => $breadcrumbtext}];
                   $header = &Apache::loncommon::head_subbox(
                                 &Apache::loncommon::CSTR_pageheader());
               }
     if ($env{'environment.remote'} ne 'off') {      if ($env{'environment.remote'} ne 'off') {
  $options{'bgcolor'}   = '#FFFFFF';   $options{'bgcolor'}   = '#FFFFFF';
  $options{'only_body'} = 1;   $options{'only_body'} = 1;
Line 1856  ENDNOTFOUND Line 1901  ENDNOTFOUND
  &Apache::loncommon::resize_textarea_js();   &Apache::loncommon::resize_textarea_js();
     my $start_page = &Apache::loncommon::start_page(undef,$js,      my $start_page = &Apache::loncommon::start_page(undef,$js,
     \%options);      \%options);
     $result=$start_page.              $result = $start_page
  &Apache::lonxml::message_location().                       .$header
  $edit_info.                       .&Apache::lonxml::message_location()
  &Apache::loncommon::end_page();                       .$edit_info
                        .&Apache::loncommon::end_page();
         }          }
     }      }
     if ($filetype eq 'html') { &writeallows($request->uri); }      if ($filetype eq 'html') { &writeallows($request->uri); }
       
     &Apache::lonxml::add_messages(\$result);      &Apache::lonxml::add_messages(\$result);
     $request->print($result);      $request->print($result);
           

Removed from v.1.494.4.3  
changed lines
  Added in v.1.502


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