Diff for /loncom/interface/lonhelp.pm between versions 1.29 and 1.42

version 1.29, 2006/06/30 03:50:02 version 1.42, 2013/12/18 01:23:21
Line 57  sub processLabelName { Line 57  sub processLabelName {
   
 # Serve out the text  # Serve out the text
 sub servetext {  sub servetext {
     my ($r,$text) = @_;      my ($r,$uri,$text,$is_mobile,$firstfile) = @_;
     my $bugs=&Apache::loncommon::help_open_bug('Documentation');      my $bugs;
     my $start_page=      my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],
  &Apache::loncommon::start_page('LON-CAPA Help',undef,                                                $env{'request.role.domain'});
        {'only_body' => 1,});      if (ref($helpconfig{'helpsettings'}) eq 'HASH') {
     my $end_page=          if ($helpconfig{'helpsettings'}{'submitbugs'} eq '1') {
  &Apache::loncommon::end_page();              $bugs = &Apache::loncommon::help_open_bug('Documentation',&mt('Report a documentation bug'));
     my $header=&mt('LON-CAPA Help');          }
       }
       my %lt = &Apache::lonlocal::texthash(
                                              header  => 'LON-CAPA Help',
                                              search  => 'Search LON-CAPA help',
                                              query   => 'Search',
                                           );
     $r->print(<<HEADER);      $r->print(<<HEADER);
     $start_page  
     <h3 style="font: sans-serif"><img align="right" alt="help logo"      <h3 style="font: sans-serif"><img align="right" alt="help logo"
     src="/adm/help/gif/lonhelpheader.gif"/>$header</h3><hr />$bugs      src="/adm/help/gif/lonhelpheader.gif" />$lt{'header'}</h3><hr />
     <!-- BEGIN -->      <!-- BEGIN -->
 HEADER  HEADER
       if ($is_mobile) {
     $r->print($text);          my $width = 500;
           my $height = 400;
           my $machine = &Apache::lonnet::absolute_url();
           $r->print(&Apache::loncommon::nicescroll_javascript('helpwrapper',
                                                               {cursorcolor => '#00F',
                                                                railalign => 'right',
                                                                railoffset => '{top:5,left:40}'},
                                                                undef,1,$machine.$firstfile));
           $r->print('<div id="helpwrapper" style="height:'.$height.'px; width:'.$width.'px; overflow: auto;">'.
                     $text.
                     '</div>');
       } else {
           $r->print($text);
       }
   
     if (&Apache::lonnavmaps::advancedUser()) {      if (&Apache::lonnavmaps::advancedUser()) {
  my $search=&mt('Search LON-CAPA help');          $r->print(<<FOOTER);
  my $about=&mt('About LON-CAPA help and More Help');      <hr /><div class="LC_left_float">
         my $query=&mt('Search');      <form action="$uri" method="post">
  my $uri = $r->uri;      <fieldset><legend>$lt{'search'}</legend>
  $r->print(<<FOOTER);      <input type="text" name="searchterm" size="40" />
     <hr /><form action="$uri" method="post">      <input type="submit" value="$lt{'query'}" />
 $search: <input type="text" name="searchterm" size="40" /><input type="submit" value="$query" />      </fieldset>
 </form>      </form>
 <br />      </div>
 <a href="/adm/help/abouthelp.html">$about</a>      <div class=""LC_left_float">
       </div>
       <div style="padding:0;clear:both;margin:0;border:0"></div>
   $bugs
 FOOTER  FOOTER
    
     }      }
   
     $r->print(<<ENDBODY);      $r->print(<<ENDBODY);
     <!-- END -->      <!-- END -->
     $end_page  
 ENDBODY  ENDBODY
   
 }  }
Line 99  ENDBODY Line 118  ENDBODY
 # Render takes a tex fragment, transforms it for TtH, and returns the  # Render takes a tex fragment, transforms it for TtH, and returns the
 # HTML equivalent  # HTML equivalent
 sub render {  sub render {
     my ($tex, $docroot, $serverroot) = @_;      my ($tex, $docroot) = @_;
     tie (my %fragmentLabels, 'GDBM_File', $docroot . '/adm/help/fragmentLabels.gdbm', 0, 0);      tie (my %fragmentLabels, 'GDBM_File', $docroot . '/adm/help/fragmentLabels.gdbm', 0, 0);
   
     # This tells TtH what to do with captions, labels, and other      # This tells TtH what to do with captions, labels, and other
Line 111  sub render { Line 130  sub render {
     # absolute paths for use with help.loncapa.org      # absolute paths for use with help.loncapa.org
     $tex =~ s|  \\ref\{([^}]*)\}      $tex =~ s|  \\ref\{([^}]*)\}
              |               |
               if (not(exists($fragmentLabels{$1}))) {                my $label=$1;
           &Apache::lonnet::logthis("ERROR: $1 not a valid help label");                my $icon='/adm/help/help.png';
               };                my $ext;
              '\\begin{html}<a href="http://' . $serverroot ."/adm/help/".                if ($1!~/\.hlp$/) {
               substr($fragmentLabels{$1}, 0, -4) .                    if (($1 =~ /^\w+\.manual\.pdf$/) && (-e $docroot.'/adm/help/'.$1)) {
               '.hlp#' . &processLabelName($1) .                        $icon = '/adm/lonIcons/pdf.gif';
              '"><img src="http://' . $serverroot . '/adm/help/gif/smallHelp.gif" border="0" /></a>' .                    } elsif ((!exists($fragmentLabels{$1})) && ($1!~/\.hlp$/)) {
                &Apache::lonnet::logthis("ERROR: $1 not a valid help label");
                        $label='Error';
                     } else {
                        $label=substr($fragmentLabels{$1}, 0, -4);
                        $ext = '.hlp#' . &processLabelName($1);
     }
         } else {
     $label=~s/\.hlp$//;
                     $ext = '.hlp#' . &processLabelName($1);
         }
                '\\begin{html}<a href="/adm/help/'.
                 $label .
                 $ext . 
                '"><img src="'.$icon.'" border="0" /></a>' .
              '\\end{html}'               '\\end{html}'
              |gxe;               |gxe;
   
Line 126  sub render { Line 159  sub render {
   
     # Figures leftover without captions      # Figures leftover without captions
     $tex =~ s|  \\includegraphics(\[[^]]*\])*\{([^}]*)\}      $tex =~ s|  \\includegraphics(\[[^]]*\])*\{([^}]*)\}
              |  '\\begin{html}<img src="http://' . $serverroot . '/adm/help/gif/' . $2 . '.gif" border="2"'.               |  '\\begin{html}<img src="/adm/help/gif/' . $2 . '.gif" border="2"'.
                 ' bordercolor="#000000"/>\\end{html}'                  ' bordercolor="#000000"/>\\end{html}'
              |gxe;               |gxe;
   
Line 143  sub render { Line 176  sub render {
     # just duck the issue...      # just duck the issue...
   
     $tex =~ s/Figure 0://g;      $tex =~ s/Figure 0://g;
      $tex.=$Apache::lontexconvert::errorstring;      $tex.=$Apache::lontexconvert::errorstring;
     untie %fragmentLabels;      untie %fragmentLabels;
   
     return $tex;      return $tex;
Line 188  sub handler { Line 221  sub handler {
      my $r = shift;       my $r = shift;
   
      my $docroot = $r->dir_config('lonDocRoot');       my $docroot = $r->dir_config('lonDocRoot');
      my $serverroot = $ENV{'HTTP_HOST'};  
   
      &Apache::lonlocal::get_language_handle($r);       &Apache::lonlocal::get_language_handle($r);
      &Apache::loncommon::content_type($r,"text/html");       &Apache::loncommon::content_type($r,"text/html");
        my $caller;
        if ($env{'form.searchterm'}=~/\w/) {
           $caller = 'search';
        }
        my $starthash = {
              only_body   => 1,
              add_entries => {
                               'onload' => "javascript:expand_div('$caller');",
                             },
        };
   
        my $firstfile;
        my $start_page=
    &Apache::loncommon::start_page('LON-CAPA Help',undef,$starthash);
      my $text='';       my $text='';
        my $uri = $r->uri;
      if ($env{'form.searchterm'}=~/\w/) {       if ($env{'form.searchterm'}=~/\w/) {
  ($text,my $matches)=&listmatches($docroot,$env{'form.searchterm'},&Apache::lonlocal::current_language().'/');   ($text,my $matches)=&listmatches($docroot,$env{'form.searchterm'},&Apache::lonlocal::current_language().'/');
          if ($matches) {           if ($matches) {
Line 204  sub handler { Line 251  sub handler {
              $text=&listmatches($docroot,$env{'form.searchterm'});                $text=&listmatches($docroot,$env{'form.searchterm'}); 
          }           }
      } else {       } else {
  my $filenames = &unescape(substr ($ENV{'REQUEST_URI'} ,            my $filenames = &unescape(substr($uri,rindex($uri,'/')+1,-4));
    rindex($ENV{'REQUEST_URI'}, '/') + 1, -4));  
       
  # Security check on the file; the whole filename must consist   # Security check on the file; the whole filename must consist
  # of nothing but alphanums, ' ,, or ., or the file   # of nothing but alphanums, ' ,, or ., or the file
Line 221  sub handler { Line 267  sub handler {
  # so replace : with ,   # so replace : with ,
  $filenames =~ s/:/,/g;   $filenames =~ s/:/,/g;
  my @files = split(/,/, $filenames);   my @files = split(/,/, $filenames);
              $firstfile = '/adm/help/'.$files[0].'.hlp';
   
  for my $filename (@files) {   for my $filename (@files) {
      if (-e $docroot.'/adm/help/tex/'.       if (-e $docroot.'/adm/help/tex/'.
  &Apache::lonlocal::current_language().'/'.   &Apache::lonlocal::current_language().'/'.
Line 234  sub handler { Line 281  sub handler {
      $tex .= join('', <$file>);       $tex .= join('', <$file>);
  }   }
   
  $text = &render($tex, $docroot, $serverroot);   $text = &render($tex, $docroot);
      }       }
   
      $r->send_http_header;       $r->send_http_header;
      &servetext($r,$text);       $r->print($start_page);
        &servetext($r,$uri,$text,$env{'browser.mobile'},$firstfile);
        $r->print(&Apache::loncommon::end_page());
   
      return OK;       return OK;
 }  }
   

Removed from v.1.29  
changed lines
  Added in v.1.42


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