[LON-CAPA-cvs] cvs: loncom /interface lonhelp.pm
www
lon-capa-cvs@mail.lon-capa.org
Wed, 15 Mar 2006 23:41:52 -0000
www Wed Mar 15 18:41:52 2006 EDT
Modified files:
/loncom/interface lonhelp.pm
Log:
Saving my work: searchable help
Index: loncom/interface/lonhelp.pm
diff -u loncom/interface/lonhelp.pm:1.20 loncom/interface/lonhelp.pm:1.21
--- loncom/interface/lonhelp.pm:1.20 Wed Mar 15 16:55:58 2006
+++ loncom/interface/lonhelp.pm Wed Mar 15 18:41:49 2006
@@ -148,58 +148,61 @@
my $docroot = $r->dir_config('lonDocRoot');
my $serverroot = $ENV{'HTTP_HOST'};
- my $filenames = &Apache::lonnet::unescape(substr ($ENV{'REQUEST_URI'} ,
+ &Apache::lonlocal::get_language_handle($r);
+ my $text='';
+ if ($env{'form.searchterm'}=~/\w/) {
+ } else {
+ my $filenames = &Apache::lonnet::unescape(substr ($ENV{'REQUEST_URI'} ,
rindex($ENV{'REQUEST_URI'}, '/') + 1, -4));
- # Security check on the file; the whole filename must consist
- # of nothing but alphanums, ' ,, or ., or the file
- # will be "not found", no matter what.
+ # Security check on the file; the whole filename must consist
+ # of nothing but alphanums, ' ,, or ., or the file
+ # will be "not found", no matter what.
- return HTTP_NOT_FOUND if ($filenames !~ /\A[-0-9a-zA-z_'',:.]+\Z/);
-
- &Apache::lonlocal::get_language_handle($r);
+ return HTTP_NOT_FOUND if ($filenames !~ /\A[-0-9a-zA-z_'',:.]+\Z/);
- # Join together the tex files, return HTTP_NOT_FOUND if any of
- # them are not found
- my $tex = '';
- # Since in insertlist.tab I want to specify multiple files,
- # and insertlist.tab also uses commas, I need something else
- # so replace : with ,
- $filenames =~ s/:/,/g;
- my @files = split(/,/, $filenames);
+ # Join together the tex files, return HTTP_NOT_FOUND if any of
+ # them are not found
+ my $tex = '';
+ # Since in insertlist.tab I want to specify multiple files,
+ # and insertlist.tab also uses commas, I need something else
+ # so replace : with ,
+ $filenames =~ s/:/,/g;
+ my @files = split(/,/, $filenames);
- for my $filename (@files) {
- if (-e $docroot.'/adm/help/tex/'.
- &Apache::lonlocal::current_language().'/'.
- $filename.'.tex') {
- $filename=&Apache::lonlocal::current_language().'/'.$filename;
- }
- (my $file = Apache::File->new($docroot
- . '/adm/help/tex/'.$filename.'.tex'))
- or return HTTP_NOT_FOUND;
- $tex .= join('', <$file>);
- }
-
- if ($env{'browser.mathml'}) {
- &Apache::loncommon::content_type($r,'text/xml');
- &tth::ttminit();
- if ($env{'browser.unicode'}) {
- &tth::ttmoptions('-L -u1');
- } else {
- &tth::ttmoptions('-L -u0');
- }
- } else {
- &Apache::loncommon::content_type($r,"text/html");
- &tth::tthinit();
- if ($env{'browser.unicode'}) {
- &tth::tthoptions('-L -u1');
- } else {
- &tth::tthoptions('-L -u0');
- }
+ for my $filename (@files) {
+ if (-e $docroot.'/adm/help/tex/'.
+ &Apache::lonlocal::current_language().'/'.
+ $filename.'.tex') {
+ $filename=&Apache::lonlocal::current_language().'/'.$filename;
+ }
+ (my $file = Apache::File->new($docroot
+ . '/adm/help/tex/'.$filename.'.tex'))
+ or return HTTP_NOT_FOUND;
+ $tex .= join('', <$file>);
+ }
+
+ if ($env{'browser.mathml'}) {
+ &Apache::loncommon::content_type($r,'text/xml');
+ &tth::ttminit();
+ if ($env{'browser.unicode'}) {
+ &tth::ttmoptions('-L -u1');
+ } else {
+ &tth::ttmoptions('-L -u0');
+ }
+ } else {
+ &Apache::loncommon::content_type($r,"text/html");
+ &tth::tthinit();
+ if ($env{'browser.unicode'}) {
+ &tth::tthoptions('-L -u1');
+ } else {
+ &tth::tthoptions('-L -u0');
+ }
+ }
+ $text = &render($tex, $docroot, $serverroot);
}
$r->send_http_header;
- my $text = &render($tex, $docroot, $serverroot);
&servetext($r,$text);
return OK;
}