--- loncom/interface/lonhelp.pm 2006/03/15 23:41:49 1.21
+++ loncom/interface/lonhelp.pm 2006/03/18 13:22:07 1.23
@@ -81,12 +81,13 @@ $search: '.$title.''.$quote.'';
+ }
+ }
+ }
+ closedir(DIR);
+ return ($output?'
':&mt('"[_1]" not found',$term));
+}
+
sub handler {
my $r = shift;
@@ -151,55 +184,57 @@ sub handler {
&Apache::lonlocal::get_language_handle($r);
my $text='';
if ($env{'form.searchterm'}=~/\w/) {
+ &Apache::loncommon::content_type($r,"text/html");
+ $text=&listmatches($docroot,$env{'form.searchterm'});
} 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.
-
- 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);
-
- 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'))
+ 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.
+
+ 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);
+
+ 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);
+ }
+
+ 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;