Diff for /loncom/interface/loncommon.pm between versions 1.103 and 1.109

version 1.103, 2003/06/06 02:24:49 version 1.109, 2003/07/17 18:10:53
Line 549  sub help_open_topic { Line 549  sub help_open_topic {
     my ($topic, $text, $stayOnPage, $width, $height) = @_;      my ($topic, $text, $stayOnPage, $width, $height) = @_;
     $text = "" if (not defined $text);      $text = "" if (not defined $text);
     $stayOnPage = 0 if (not defined $stayOnPage);      $stayOnPage = 0 if (not defined $stayOnPage);
     if ($ENV{'browser.interface'} eq 'textual') {      if ($ENV{'browser.interface'} eq 'textual' ||
    $ENV{'environment.remote'} eq 'off' ) {
  $stayOnPage=1;   $stayOnPage=1;
     }      }
     $width = 350 if (not defined $width);      $width = 350 if (not defined $width);
Line 586  ENDTEMPLATE Line 587  ENDTEMPLATE
   
 }  }
   
   # This is a quicky function for Latex cheatsheet editing, since it 
   # appears in at least four places
   sub helpLatexCheatsheet {
       my $other = shift;
       my $addOther = '';
       if ($other) {
    $addOther = Apache::loncommon::help_open_topic($other, shift,
          undef, undef, 600) .
      '</td><td>';
       }
       return '<table><tr><td>'.
    $addOther .
    &Apache::loncommon::help_open_topic("Greek_Symbols",'Greek Symbols',
       undef,undef,600)
    .'</td><td>'.
    &Apache::loncommon::help_open_topic("Other_Symbols",'Other Symbols',
       undef,undef,600)
    .'</td></tr></table>';
   }
   
 =pod  =pod
   
 =item csv_translate($text)   =item csv_translate($text) 
Line 1332  sub aboutmewrapper { Line 1353  sub aboutmewrapper {
   
   
 sub syllabuswrapper {  sub syllabuswrapper {
     my ($link,$un,$do,$tf)=@_;      my ($linktext,$coursedir,$domain,$fontcolor)=@_;
     if ($tf) { $link='<font color="'.$tf.'">'.$link.'</font>'; }      if ($fontcolor) { 
     return "<a href='/public/$do/$un/syllabus'>$link</a>";          $linktext='<font color="'.$fontcolor.'">'.$linktext.'</font>'; 
       }
       return "<a href='/public/$domain/$coursedir/syllabus'>$linktext</a>";
 }  }
   
 # ---------------------------------------------------------------- Language IDs  # ---------------------------------------------------------------- Language IDs
Line 1358  sub display_languages { Line 1381  sub display_languages {
     $languages{$_}=1;      $languages{$_}=1;
         }          }
     }      }
       if ($ENV{'course.'.$ENV{'request.course.id'}.'.languages'}) {
    foreach (split(/\s*(\,|\;|\:)\s*/,
    $ENV{'course.'.$ENV{'request.course.id'}.'.languages'})) {
       $languages{$_}=1;
           }
       }
     &get_unprocessed_cgi($ENV{'QUERY_STRING'},['displaylanguage']);      &get_unprocessed_cgi($ENV{'QUERY_STRING'},['displaylanguage']);
     if ($ENV{'form.displaylanguage'}) {      if ($ENV{'form.displaylanguage'}) {
  foreach (split(/\s*(\,|\;|\:)\s*/,$ENV{'form.displaylanguage'})) {   foreach (split(/\s*(\,|\;|\:)\s*/,$ENV{'form.displaylanguage'})) {
Line 1485  sub get_previous_attempt { Line 1514  sub get_previous_attempt {
   }    }
 }  }
   
   sub relative_to_absolute {
       my ($url,$output)=@_;
       my $parser=HTML::TokeParser->new(\$output);
       my $token;
       my $thisdir=$url;
       my @rlinks=();
       while ($token=$parser->get_token) {
    if ($token->[0] eq 'S') {
       if ($token->[1] eq 'a') {
    if ($token->[2]->{'href'}) {
       $rlinks[$#rlinks+1]=$token->[2]->{'href'};
    }
       } elsif ($token->[1] eq 'img' || $token->[1] eq 'embed' ) {
    $rlinks[$#rlinks+1]=$token->[2]->{'src'};
       } elsif ($token->[1] eq 'base') {
    $thisdir=$token->[2]->{'href'};
       }
    }
       }
       $thisdir=~s-/[^/]*$--;
       foreach (@rlinks) {
    unless (($_=~/^http:\/\//i) ||
    ($_=~/^\//) ||
    ($_=~/^javascript:/i) ||
    ($_=~/^mailto:/i) ||
    ($_=~/^\#/)) {
       my $newlocation=&Apache::lonnet::hreflocation($thisdir,$_);
       $output=~s/(\"|\'|\=\s*)$_(\"|\'|\s|\>)/$1$newlocation$2/;
    }
       }
   # -------------------------------------------------- Deal with Applet codebases
       $output=~s/(\<applet[^\>]+)(codebase\=[^\S\>]+)*([^\>]*)\>/$1.($2?$2:' codebase="'.$thisdir.'"').$3.'>'/gei;
       return $output;
   }
   
 sub get_student_view {  sub get_student_view {
   my ($symb,$username,$domain,$courseid,$target) = @_;    my ($symb,$username,$domain,$courseid,$target) = @_;
   my ($map,$id,$feedurl) = split(/___/,$symb);    my ($map,$id,$feedurl) = split(/___/,$symb);
Line 1496  sub get_student_view { Line 1560  sub get_student_view {
   }    }
   if ($target eq 'tex') {$moreenv{'form.grade_target'} = 'tex';}    if ($target eq 'tex') {$moreenv{'form.grade_target'} = 'tex';}
   &Apache::lonnet::appenv(%moreenv);    &Apache::lonnet::appenv(%moreenv);
   my $userview=&Apache::lonnet::ssi('/res/'.$feedurl);    $feedurl=&Apache::lonnet::clutter($feedurl);
     my $userview=&Apache::lonnet::ssi_body($feedurl);
   &Apache::lonnet::delenv('form.grade_');    &Apache::lonnet::delenv('form.grade_');
   foreach my $element (@elements) {    foreach my $element (@elements) {
     $ENV{'form.grade_'.$element}=$old{$element};      $ENV{'form.grade_'.$element}=$old{$element};
Line 1508  sub get_student_view { Line 1573  sub get_student_view {
   $userview=~s/\<head\>//gi;    $userview=~s/\<head\>//gi;
   $userview=~s/\<\/head\>//gi;    $userview=~s/\<\/head\>//gi;
   $userview=~s/action\s*\=/would_be_action\=/gi;    $userview=~s/action\s*\=/would_be_action\=/gi;
     $userview=&relative_to_absolute($feedurl,$userview);
   return $userview;    return $userview;
 }  }
   

Removed from v.1.103  
changed lines
  Added in v.1.109


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