+
+
+SIMPLECONTENT
+ return $filecontents;
+}
+
+sub verify_html {
+ my ($filecontents)=@_;
+ if ($filecontents!~/(?:\<|\<\;)(?:html|xml)[^\<]*(?:\>|\>\;)/is) {
+ return &mt('File does not have [_1] or [_2] starting tag','<html>','<xml>');
+ }
+ if ($filecontents!~/(?:\<|\<\;)\/(?:html|xml)(?:\>|\>\;)/is) {
+ return &mt('File does not have [_1] or [_2] ending tag','<html>','<xml>');
+ }
+ if ($filecontents!~/(?:\<|\<\;)(?:body|frameset)[^\<]*(?:\>|\>\;)/is) {
+ return &mt('File does not have [_1] or [_2] starting tag','<body>','<frameset>');
+ }
+ if ($filecontents!~/(?:\<|\<\;)\/(?:body|frameset)[^\<]*(?:\>|\>\;)/is) {
+ return &mt('File does not have [_1] or [_2] ending tag','<body>','<frameset>');
+ }
+ return '';
+}
+
+sub renderingoptions {
+ my %langchoices=('' => '');
+ foreach (&Apache::loncommon::languageids()) {
+ if (&Apache::loncommon::supportedlanguagecode($_)) {
+ $langchoices{&Apache::loncommon::supportedlanguagecode($_)}
+ = &Apache::loncommon::plainlanguagedescription($_);
+ }
+ }
+ my $output;
+ unless ($env{'form.forceedit'}) {
+ $output .= '
+ '.
+ &mt('Language:').' '.
+ &Apache::loncommon::select_form($env{'form.languages'},'languages',
+ %langchoices).'
+ ';
+ }
+ $output .= '
+ '.
+ &mt('Math Rendering:').' '.
+ &Apache::loncommon::select_form($env{'form.texengine'},'texengine',
+ ('' => '',
+ 'tth' => 'tth (TeX to HTML)',
+ 'jsMath' => 'jsMath',
+ 'mimetex' => 'mimetex (Convert to Images)')).'
+ ';
+ return $output;
+}
sub inserteditinfo {
- my ($filecontents,$filetype)=@_;
+ my ($filecontents, $filetype, $filename)=@_;
$filecontents = &HTML::Entities::encode($filecontents,'<>&"');
-# my $editheader='Edit below
';
my $xml_help = '';
my $initialize='';
my $textarea_id = 'filecont';
+ my $dragmath_button;
my ($add_to_onload, $add_to_onresize);
$initialize=&Apache::lonhtmlcommon::spellheader();
if ($filetype eq 'html'
@@ -1519,6 +1612,10 @@ FULLPAGE
}
FULLPAGE
+ if ($filetype eq 'html') {
+ $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
+ $dragmath_button = &Apache::lonhtmlcommon::dragmath_button('filecont',1);
+ }
}
$add_to_onload = 'initDocument();';
@@ -1528,38 +1625,57 @@ FULLPAGE
$xml_help=&Apache::loncommon::helpLatexCheatsheet();
}
- my $cleanbut = '';
-
my $titledisplay=&display_title();
+ my $wysiwyglink;
my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit',
'vi' => 'Save and View',
'dv' => 'Discard Edits and View',
'un' => 'undo',
'ed' => 'Edit');
- my $buttons=(<
-
-
-
-BUTTONS
- $buttons.=&Apache::lonhtmlcommon::spelllink('xmledit','filecont');
+ my $spelllink .=&Apache::lonhtmlcommon::spelllink('xmledit','filecont');
my $textarea_events = &Apache::edit::element_change_detection();
my $form_events = &Apache::edit::form_change_detection();
+ my $htmlerror;
+ if ($filetype eq 'html') {
+ $htmlerror=&verify_html($filecontents);
+ if ($htmlerror) {
+ $htmlerror=''.$htmlerror.'';
+ }
+ if (&Apache::lonhtmlcommon::htmlareabrowser()) {
+ if (&Apache::lonhtmlcommon::htmlareablocked()) {
+ $wysiwyglink = &Apache::lonhtmlcommon::enablelink($textarea_id);
+ } else {
+ $wysiwyglink = &Apache::lonhtmlcommon::disablelink($textarea_id);
+ }
+ }
+ }
my $editfooter=(<