+
+
+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',
+ &Apache::lonlocal::texthash(%langchoices)).
+ ' ';
+ }
+ $output .=
+ ' '.
+ &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)')).
+ ' ';
+ return $output;
+}
sub inserteditinfo {
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 +1617,10 @@ FULLPAGE
}
FULLPAGE
+ if ($filetype eq 'html' || $filetype eq 'tex') {
+ $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
+ $dragmath_button = &Apache::lonhtmlcommon::dragmath_button('filecont',1);
+ }
}
$add_to_onload = 'initDocument();';
@@ -1529,6 +1631,7 @@ FULLPAGE
}
my $titledisplay=&display_title();
+ my $wysiwyglink;
my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit',
'vi' => 'Save and View',
'dv' => 'Discard Edits and View',
@@ -1537,6 +1640,20 @@ FULLPAGE
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=(<
@@ -1551,7 +1668,7 @@ $initialize
- $spelllink
+ $dragmath_button $spelllink $htmlerror
@@ -1560,6 +1677,7 @@ $initialize
+ $wysiwyglink
$titledisplay
@@ -1598,9 +1716,8 @@ sub get_target {
sub handler {
my $request=shift;
-
+
my $target=&get_target();
-
$Apache::lonxml::debug=$env{'user.debug'};
&Apache::loncommon::content_type($request,'text/html');
@@ -1609,18 +1726,47 @@ sub handler {
$request->set_last_modified(&Apache::lonnet::metadata($request->uri,
'lastrevisiondate'));
}
+ # 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) =
+ &Apache::loncommon::decode_user_agent($request);
+ if ($clientbrowser =~ /^explorer$/i) {
+ delete $request->headers_out->{'Cache-control'};
+ delete $request->headers_out->{'Pragma'};
+ my $expiration = time + 60;
+ my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime($expiration));
+ $request->headers_out->set("Expires" => $date);
+ }
+ }
+ }
$request->send_http_header;
return OK if $request->header_only;
my $file=&Apache::lonnet::filelocation("",$request->uri);
- my $filetype;
- if ($file =~ /\.sty$/) {
- $filetype='sty';
+ 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.
#
@@ -1628,6 +1774,9 @@ sub handler {
if ($env{'form.savethisfile'} || $env{'form.viewmode'} || $env{'form.Undo'}) {
my $html_file=&Apache::lonnet::getfile($file);
my $error = &Apache::lonhomework::handle_save_or_undo($request, \$html_file, \$env{'form.filecont'});
+ if ($env{'form.savethisfile'}) {
+ $env{'form.editmode'}='Edit'; #force edit mode
+ }
}
}
my %mystyle;
@@ -1636,17 +1785,22 @@ 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=''
+ .&mt('File not found: [_1]'
+ ,''.$file.' ')
+ .'
';
$result=(<$fnf: $file
+$errormsg
$end_page
ENDNOTFOUND
$filecontents='';
if ($env{'request.state'} ne 'published') {
if ($filetype eq 'sty') {
$filecontents=&createnewsty();
- } else {
+ } elsif ($filetype eq 'js') {
+ $filecontents=&createnewjs();
+ } elsif ($filetype ne 'css' && $filetype ne 'txt' && $filetype ne 'tex') {
$filecontents=&createnewhtml();
}
$env{'form.editmode'}='Edit'; #force edit mode
@@ -1662,28 +1816,67 @@ ENDNOTFOUND
['editmode']);
}
if (!$env{'form.editmode'} || $env{'form.viewmode'} || $env{'form.discardview'}) {
- &Apache::structuretags::reset_problem_globals();
- $result = &Apache::lonxml::xmlparse($request,$target,$filecontents,
- '',%mystyle);
+ if ($filetype eq 'html' || $filetype eq 'sty') {
+ &Apache::structuretags::reset_problem_globals();
+ $result = &Apache::lonxml::xmlparse($request,$target,
+ $filecontents,'',%mystyle);
# .html files may contain or need to clean
# up if it did
- &Apache::structuretags::reset_problem_globals();
- &Apache::lonhomework::finished_parsing();
+ &Apache::structuretags::reset_problem_globals();
+ &Apache::lonhomework::finished_parsing();
+ } elsif ($filetype eq 'tex') {
+ $result = &Apache::lontexconvert::converted(\$filecontents,
+ $env{'form.texengine'});
+ if ($env{'form.return_only_error_and_warning_counts'}) {
+ if (&verify_html(''.$result.'')) {
+ $errorcount++;
+ }
+ $result = "$errorcount:$warningcount";
+ }
+ } else {
+ $result = $filecontents;
+ }
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['rawmode']);
if ($env{'form.rawmode'}) { $result = $filecontents; }
- if ($filetype eq 'sty') {
- my $controls =
- ($env{'request.state'} eq 'construct') ? &Apache::londefdef::edit_controls()
- : '';
- my %options = ('bgcolor' => '#FFFFFF');
- $result =
- &Apache::loncommon::start_page(undef,undef,\%options).
- $controls.
- $result.
- &Apache::loncommon::end_page();
- }
- }
+ if (($filetype ne 'html') &&
+ (!$env{'form.return_only_error_and_warning_counts'})) {
+ 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' && $filetype ne 'tex') {
+ $result =~ s/</g;
+ $result =~ s/>/>/g;
+ $result = '';
+ }
+ if ($env{'environment.remote'} eq 'off') {
+ my $brcrum;
+ if ($env{'request.state'} eq 'construct') {
+ $brcrum = [{'href' => &Apache::loncommon::authorspace(),
+ 'text' => 'Construction Space'},
+ {'href' => '',
+ '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 {
+ $result = $controls.$result;
+ }
+ }
+ }
}
#
@@ -1700,9 +1893,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' => $breadcrumbtext}];
+ $header = &Apache::loncommon::head_subbox(
+ &Apache::loncommon::CSTR_pageheader());
+ }
if ($env{'environment.remote'} ne 'off') {
$options{'bgcolor'} = '#FFFFFF';
$options{'only_body'} = 1;
@@ -1712,14 +1914,15 @@ 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); }
-
+
&Apache::lonxml::add_messages(\$result);
$request->print($result);
@@ -1734,7 +1937,8 @@ sub display_title {
$title = $env{'request.filename'};
$title = substr($title, rindex($title, '/') + 1);
}
- $result = "";
+ $result = "";
}
return $result;
}
@@ -1771,6 +1975,8 @@ sub error {
$errorcount++;
+ $Apache::lonxml::internal_error=1;
+
if (defined($Apache::inputtags::part)) {
if ( @Apache::inputtags::response ) {
push(@errors,
@@ -1787,18 +1993,22 @@ sub error {
if ( &show_error_warn_msg() ) {
# If printing in construction space, put the error inside
push(@Apache::lonxml::error_messages,
- $Apache::lonxml::warnings_error_header.
- "ERROR: ".join(" \n",@errors)." \n");
+ $Apache::lonxml::warnings_error_header
+ .''
+ .''.&mt('ERROR:').' '.join(" \n",@errors)
+ ."
\n");
$Apache::lonxml::warnings_error_header='';
} else {
my $errormsg;
my ($symb)=&Apache::lonnet::symbread();
if ( !$symb ) {
#public or browsers
- $errormsg=&mt("An error occured while processing this resource. The author has been notified.");
+ $errormsg=&mt("An error occurred while processing this resource. The author has been notified.");
}
my $host=$Apache::lonnet::perlvar{'lonHostID'};
- push(@errors, "The error occurred on host $host ");
+ push(@errors,
+ &mt("The error occurred on host [_1]",
+ "$host "));
my $msg = join(' ', @errors);
@@ -1832,9 +2042,9 @@ sub error {
}
}
if ($env{'request.role.adv'}) {
- $errormsg=&mt("An error occured while processing this resource. The course personnel ([_1]) and the author have been notified.",join(', ',@userlist));
+ $errormsg=&mt("An error occurred while processing this resource. The course personnel ([_1]) and the author have been notified.",join(', ',@userlist));
} else {
- $errormsg=&mt("An error occured while processing this resource. The instructor has been notified.");
+ $errormsg=&mt("An error occurred while processing this resource. The instructor has been notified.");
}
}
push(@Apache::lonxml::error_messages,"$errormsg ");
@@ -1847,8 +2057,11 @@ sub warning {
if ($env{'form.grade_target'} ne 'tex') {
if ( &show_error_warn_msg() ) {
push(@Apache::lonxml::warning_messages,
- $Apache::lonxml::warnings_error_header.
- "W ARNING: ".join(' ',@_)." \n");
+ $Apache::lonxml::warnings_error_header
+ .''
+ .&mt('[_1]W[_2]ARNING','',' ').": ".join(' ',@_)
+ ."
\n"
+ );
$Apache::lonxml::warnings_error_header='';
}
}
@@ -2073,7 +2286,109 @@ sub get_tag {
return $insertlist{"$tagnum.tag"};
}
+############################################################
+# PDF-FORM-METHODS
+
+=pod
+
+=item &print_pdf_radiobutton(fieldname, value, text)
+
+Returns a latexline to generate a PDF-Form-Radiobutton with Text.
+
+$fieldname: PDF internalname of the radiobutton
+$value: Value of radiobutton (read when dumping the PDF data)
+$text: Text on the rightside of the radiobutton
+
+=cut
+sub print_pdf_radiobutton {
+ my $result = '';
+ my ($fieldName, $value, $text) = @_;
+ $result .= '\begin{tabularx}{\textwidth}{p{0cm}X}'."\n";
+ $result .= '\radioButton[\symbolchoice{circle}]{'.
+ $fieldName.'}{10bp}{10bp}{'.$value.'}&'.$text."\n";
+ $result .= '\end{tabularx}' . "\n";
+ $result .= '\hspace{2mm}' . "\n";
+ return $result;
+}
+
+
+=pod
+
+=item &print_pdf_start_combobox(fieldname)
+
+Starts a latexline to generate a PDF-Form-Combobox with text.
+
+$fieldname: PDF internal name of the Combobox
+
+=cut
+sub print_pdf_start_combobox {
+ my $result;
+ my ($fieldName) = @_;
+ $result .= '\begin{tabularx}{\textwidth}{p{2.5cm}X}'."\n";
+ $result .= '\comboBox[]{'.$fieldName.'}{2.3cm}{14bp}{'; #
+
+ return $result;
+}
+
+
+=pod
+
+=item &print_pdf_add_combobox_option(options)
+
+Generates a latexline to add Options to a PDF-Form-ComboBox.
+
+$option: PDF internal name of the Combobox-Option
+
+=cut
+sub print_pdf_add_combobox_option {
+
+ my $result;
+ my ($option) = @_;
+
+ $result .= '('.$option.')';
+
+ return $result;
+}
+
+
+=pod
+
+=item &print_pdf_end_combobox(text) {
+
+Returns latexcode to end a PDF-Form-Combobox with text.
+
+=cut
+sub print_pdf_end_combobox {
+ my $result;
+ my ($text) = @_;
+
+ $result .= '}&'.$text."\\\\\n";
+ $result .= '\end{tabularx}' . "\n";
+ $result .= '\hspace{2mm}' . "\n";
+ return $result;
+}
+
+
+=pod
+
+=item &print_pdf_hiddenField(fieldname, user, domain)
+
+Returns a latexline to generate a PDF-Form-hiddenField with userdata.
+
+$fieldname label for hiddentextfield
+$user: name of user
+$domain: domain of user
+
+=cut
+sub print_pdf_hiddenfield {
+ my $result;
+ my ($fieldname, $user, $domain) = @_;
+
+ $result .= '\textField [\F{\FHidden}\F{-\FPrint}\V{'.$domain.'&'.$user.'}]{'.$fieldname.'}{0in}{0in}'."\n";
+
+ return $result;
+}
+
1;
__END__
-