Diff for /rat/lonpage.pm between versions 1.96 and 1.105

version 1.96, 2011/07/28 03:14:09 version 1.105, 2014/09/14 15:21:47
Line 36  use strict; Line 36  use strict;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon();  use Apache::loncommon();
   use Apache::lonhtmlcommon;
 use Apache::lonxml();  use Apache::lonxml();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonmenu;  use Apache::lonmenu;
Line 227  sub handler { Line 228  sub handler {
                   my %ssialink=();                    my %ssialink=();
             
                   my %cellemb=();                    my %cellemb=();
                     my %cellexternal=();
   
                   my $allscript='';                    my $allscript='';
                   my $allmeta='';                    my $allmeta='';
Line 244  sub handler { Line 246  sub handler {
                       $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));                        $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
                       foreach (@colcont) {                        foreach (@colcont) {
                           my $src=$hash{'src_'.$_};                            my $src=$hash{'src_'.$_};
   my ($extension)=($src=~/\.(\w+)$/);                            my ($extension)=($src=~/\.(\w+)$/);
     $cellexternal{$_}=($hash{'ext_'.$_} eq 'true:');
   if ($hash{'encrypted_'.$_}) {    if ($hash{'encrypted_'.$_}) {
       $src=&Apache::lonenc::encrypted($src);        $src=&Apache::lonenc::encrypted($src);
   }    }
                           $cellemb{$_}=                            $cellemb{$_}=
       &Apache::loncommon::fileembstyle($extension);        &Apache::loncommon::fileembstyle($extension);
                           if ($cellemb{$_} eq 'ssi') {                            if ($cellexternal{$_}) {
                                 unless (($target eq 'tex') || ($target eq 'tex_answer')) {
                                     $ssibody{$_} = <<ENDEXT;
   <iframe src="$src" width="100%">No iframe support!</iframe>
   ENDEXT
                                 }
                             } elsif ($cellemb{$_} eq 'ssi') {
 # --------------------------------------------------------- This is an SSI cell  # --------------------------------------------------------- This is an SSI cell
       my ($mapid,$resid)=split(/\./,$_);        my ($mapid,$resid)=split(/\./,$_);
       my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);        my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);
               
       my $prefix=$_.'_';        my $prefix=$_.'_';
                                 my $idprefix= join('_',($mapid,$resid,''));
                               my %posthash=('request.prefix' => $prefix,                                my %posthash=('request.prefix' => $prefix,
     'LONCAPA_INTERNAL_no_discussion' => 'true',      'LONCAPA_INTERNAL_no_discussion' => 'true',
     'symb' => $symb);      'symb' => $symb);
Line 361  sub handler { Line 371  sub handler {
                                   }                                    }
                                   $output=~                                    $output=~
       s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi;        s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi;
                                     $output=~
                                         s/\<((?:input|select|button|textarea)[^\>]+)id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 id="$idprefix$2" $3\>/gsi;
                                     $output=~
                                         s/(\Q<div id="msg_\E)(\Qsubmit_\E)([^"]*)(\Q" style="display:none">\E)/<input type="hidden" name="$prefix$2$3_pressed" id="$idprefix$2$3_pressed" value="" \/>$1$idprefix$2$3$4/g;
                                     $output=~
                                         s/(\Q<td class="LC_status_\E)(\Qsubmit_\E)([^\"]*)(\s*[^\"]*"\>)/$1$idprefix$2$3$4/g;
                                   if ($nuploads) {                                    if ($nuploads) {
                                       $output=~                                        $output=~
                                           s/\<(input[^\>]+name=\"\Q$prefix\EHWFILE[^\>]+)\s*id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\)]*)\>/\<$1 id="$prefix$2" $3\>/gsi;                                            s/\<(input[^\>]+name=\"\Q$prefix\EHWFILE[^\>]+)\s*id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\)]*)\>/\<$1 id="$prefix$2" $3\>/gsi;
Line 423  sub handler { Line 439  sub handler {
                           if (($nforms) && ($nuploads)) {                            if (($nforms) && ($nuploads)) {
                               $allscript .= &Apache::lonhtmlcommon::file_submissionchk_js(\%turninpaths,\%multiresps);                                $allscript .= &Apache::lonhtmlcommon::file_submissionchk_js(\%turninpaths,\%multiresps);
                           }                            }
                             if (($nforms) && (&Apache::lonhtmlcommon::htmlareabrowser())) {
                                 my %textarea_args = (
                                     dragmath => 'math',
                                 );
                                 $allscript .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);
                             }
 # ------------------------------------------------------------------ Start body  # ------------------------------------------------------------------ Start body
   $r->print(&Apache::loncommon::start_page(undef,$allscript,    $r->print(&Apache::loncommon::start_page(undef,$allscript,
    {'force_register' => 1,     {'force_register' => 1,
Line 439  sub handler { Line 461  sub handler {
                               }                                }
                               $fmtag .= ' action="'.                                $fmtag .= ' action="'.
  &Apache::lonenc::check_encrypt($requrl)   &Apache::lonenc::check_encrypt($requrl)
  .'">';   .'" id="LC_page">';
                               $r->print($fmtag);                                $r->print($fmtag);
   }    }
       } elsif (($target eq 'tex') || ($target eq 'tex_answer')) {        } elsif (($target eq 'tex') || ($target eq 'tex_answer')) {
Line 472  sub handler { Line 494  sub handler {
                           my $avespan=$lcm/($#colcont+1);                            my $avespan=$lcm/($#colcont+1);
                           for ($j=0;$j<=$#colcont;$j++) {                            for ($j=0;$j<=$#colcont;$j++) {
                               my $rid=$colcont[$j];                                my $rid=$colcont[$j];
   
       my $metainfo =&get_buttons(\%hash,$rid).'<br />';        my $metainfo =&get_buttons(\%hash,$rid).'<br />';
     unless (($target eq 'tex') || ($target eq 'tex_answer')) {      unless (($target eq 'tex') || ($target eq 'tex_answer')) {
  $r->print('<td colspan="'.$avespan.'"');   $r->print('<td colspan="'.$avespan.'"');
     }      }
                               if ($cellemb{$rid} eq 'ssi') {                                if (($cellemb{$rid} eq 'ssi') || ($cellexternal{$rid})) {
   unless (($target eq 'tex') || ($target eq 'tex_answer')) {    unless (($target eq 'tex') || ($target eq 'tex_answer')) {
       if ($ssibgcolor{$rid}) {        if ($ssibgcolor{$rid}) {
   $r->print(' bgcolor="'.    $r->print(' bgcolor="'.
Line 499  sub handler { Line 520  sub handler {
       }                     }             
       $r->print('>');        $r->print('>');
   }    }
                                   $r->print($ssibody{$rid});                                    unless (($cellexternal{$rid}) && 
                                             ($target eq 'tex') && ($target eq 'tex_answer')) {
                                         $r->print($ssibody{$rid});
                                     }
   unless (($target eq 'tex') || ($target eq 'tex_answer')) {    unless (($target eq 'tex') || ($target eq 'tex_answer')) {
       $r->print('</font>');        $r->print('</font>');
                                   }                                    }
Line 517  sub handler { Line 541  sub handler {
                                   $r->print('>'.$metainfo.'<embed src="'.                                    $r->print('>'.$metainfo.'<embed src="'.
                                     $hash{'src_'.$rid}.'"></embed>');                                      $hash{'src_'.$rid}.'"></embed>');
                               } elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) {                                } elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) {
                                   $r->print($metainfo.'<b>'.$hash{'title_'.$rid}.'</b><br />'.                                    $r->print($metainfo.'<b>'.$hash{'title_'.$rid}.'</b><br />');
                                   &mt('It is recommended that you use an up-to-date virus scanner before handling this file.').'</p><p><table>'.                                    unless ($cellemb{$rid} eq 'wrp') {
                                   &Apache::londocs::entryline(0,&mt("Click to download or use your browser's Save Link function"),'/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).'</table></p><br />');                                        $r->print(&mt('It is recommended that you use an up-to-date virus scanner before handling this file.'));
                                     }
                                     $r->print('</p><p><table>'.
                                               &Apache::londocs::entryline(0,
                                                                           &mt("Click to download or use your browser's Save Link function"),
                                                                           '/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).
                                                                           '</table></p><br />');
                               }                                }
       unless (($target eq 'tex') || ($target eq 'tex_answer')) {        unless (($target eq 'tex') || ($target eq 'tex_answer')) {
   $r->print('</td>');    $r->print('</td>');
Line 544  sub handler { Line 574  sub handler {
 # ---------------------------------------------------------------- Submit, etc.  # ---------------------------------------------------------------- Submit, etc.
                       if ($nforms) {                        if ($nforms) {
                           $r->print(                            $r->print(
                   '<input name="all_submit" value="Submit All" type="'.                    '<input name="all_submit" value="'.&mt('Submit All').'" type="'.
   (($nforms>1)?'submit':'hidden').'"></input></form>');    (($nforms>1)?'submit':'hidden').'"></input></form>');
                       }                        }
       unless (($target eq 'tex') || ($target eq 'tex_answer')) {        unless (($target eq 'tex') || ($target eq 'tex_answer')) {
Line 595  sub get_buttons { Line 625  sub get_buttons {
  $esrc=&Apache::lonenc::encrypted($esrc);   $esrc=&Apache::lonenc::encrypted($esrc);
     }      }
     if ($hash->{'src_'.$rid} !~ m-^/uploaded/-      if ($hash->{'src_'.$rid} !~ m-^/uploaded/-
           && $hash->{'src_'.$rid} !~ m{^https?://}
  && !$env{'request.enc'}   && !$env{'request.enc'}
  && ($env{'request.role.adv'}   && ($env{'request.role.adv'}
     || !$hash->{'encrypted_'.$rid})) {       || !$hash->{'encrypted_'.$rid})) { 
  $metainfo .='<a name="'.&escape($symb).'" />'.   $metainfo .='<a name="'.&escape($symb).'" />'.
     '<a href="'.$hash->{'src_'.$rid}.'.meta'.'" target="LONcatInfo">'.      '<a href="'.$hash->{'src_'.$rid}.'.meta'.'" target="LONcatInfo">'.
     '<img src="/adm/lonMisc/cat_button.png" class="LC_icon" />'.              '<img src="/res/adm/pages/catalog.png" class="LC_icon"'.
               ' alt="'.&mt('Show Metadata').'"'.
               ' title="'.&mt('Show Metadata').'" />'.
       '</a>';
       }
       if (($hash->{'src_'.$rid} !~ m{^/uploaded/}) &&
           ($hash->{'src_'.$rid} !~ m{^https?://})) {
           $metainfo .= '<a href="/adm/evaluate?postdata='.
       &escape($esrc).
       '" target="LONcatInfo">'.
               '<img src="/res/adm/pages/eval.png" class="LC_icon"'.
               ' alt="'.&mt('Provide my evaluation of this resource').'"'.
               ' title="'.&mt('Provide my evaluation of this resource').'" />'.
     '</a>';      '</a>';
     }      }
     $metainfo .= '<a href="/adm/evaluate?postdata='.      if (($hash->{'src_'.$rid}=~/$LONCAPA::assess_re/) &&
  &escape($esrc).  
  '" target="LONcatInfo">'.  
  '<img src="/adm/lonMisc/eval_button.png" class="LC_icon" />'.  
  '</a>';  
     if (($hash->{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) &&  
  ($hash->{'src_'.$rid} !~ m-^/uploaded/-)) {   ($hash->{'src_'.$rid} !~ m-^/uploaded/-)) {
   
  if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) {   if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) {
Line 616  sub get_buttons { Line 654  sub get_buttons {
  '<a href="/adm/grades?symb='.&escape($symb).   '<a href="/adm/grades?symb='.&escape($symb).
 #               '&command=submission" target="LONcatInfo">'.  #               '&command=submission" target="LONcatInfo">'.
  '&command=submission">'.   '&command=submission">'.
  '<img src="/adm/lonMisc/subm_button.png" class="LC_icon" />'.                  '<img src="/adm/lonMisc/subm_button.png" class="LC_icon"'.
                   ' alt="'.&mt('View Submissions for a Student or a Group of Students').'"'.
                   ' title="'.&mt('View Submissions for a Student or a Group of Students').'" />'.
  '</a>'.   '</a>'.
  '<a href="/adm/grades?symb='.&escape($symb).   '<a href="/adm/grades?symb='.&escape($symb).
 #               '&command=gradingmenu" target="LONcatInfo">'.  #               '&command=gradingmenu" target="LONcatInfo">'.
  '&command=gradingmenu">'.   '&command=gradingmenu">'.
  '<img src="/adm/lonMisc/pgrd_button.png" class="LC_icon" />'.                  '<img src="/res/adm/pages/pgrd.png" class="LC_icon"'.
                   ' alt="'.&mt('Content Grades').'"'.
                   ' title="'.&mt('Content Grades').'" />'.
  '</a>';   '</a>';
  }   }
  if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {   if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
Line 629  sub get_buttons { Line 671  sub get_buttons {
  '<a href="/adm/parmset?symb='.&escape($symb).   '<a href="/adm/parmset?symb='.&escape($symb).
 #               '" target="LONcatInfo">'.  #               '" target="LONcatInfo">'.
  '" >'.   '" >'.
  '<img src="/adm/lonMisc/pprm_button.png" class="LC_icon" />'.                  '<img src="/adm/lonMisc/pprm_button.png" class="LC_icon"'.
                   ' alt="'.&mt('Content Settings').'"'.
                   ' title="'.&mt('Content Settings').'" />'.
  '</a>';   '</a>';
  }   }
     }      }
       if (($env{'request.course.id'}) && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
           my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
           my $file=&Apache::lonnet::declutter($hash->{'src_'.$rid});
           my ($cfile,$home,$switchserver,$forceedit,$forceview) =
               &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,$hash->{'src_'.$rid},$symb);
           if ($cfile ne '') {
               my $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
                                                                    $forceedit,1,$symb,undef,
                                                                    &escape($env{'form.title'}));
               if ($jscall) {
                   my $icon = 'pcstr.png';
                   my $label = &mt('Edit');
                   my $title = &mt('Edit this resource');
                   my $pic = '<img src="'.&Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$icon).'"'.
                             ' class="LC_icon" alt="'.$label.'" title="'.$title.'" />';
                   $metainfo .= '&nbsp;<a href="javascript:'.$jscall.';">'.$pic.'</a>';
               }
           }
       }
     return $metainfo;      return $metainfo;
 }  }
   

Removed from v.1.96  
changed lines
  Added in v.1.105


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