Diff for /loncom/interface/lonsimplepage.pm between versions 1.16 and 1.26

version 1.16, 2004/02/13 15:01:29 version 1.26, 2005/06/06 02:29:46
Line 40  use Apache::lonxml; Line 40  use Apache::lonxml;
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     $r->content_type('text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
       my $target=$env{'form.grade_target'};
 # ------------------------------------------------------------ Print the screen  # ------------------------------------------------------------ Print the screen
     if ($ENV{'form.grade_target'} ne 'tex') {      if ($target ne 'tex') {
    my $html=&Apache::lonxml::xmlbegin();
  $r->print(<<ENDDOCUMENT);   $r->print(<<ENDDOCUMENT);
 <html>  $html
 <head>  <head>
 <title>The LearningOnline Network with CAPA</title>  <title>The LearningOnline Network with CAPA</title>
 ENDDOCUMENT  ENDDOCUMENT
     } else {      } else {
  $r->print(&Apache::lonprintout::print_latex_header($ENV{'form.latex_type'}));   $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
     }       } 
     my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);      my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);
 # Is this even in a course?  # Is this even in a course?
     unless ($ENV{'request.course.id'}) {      unless ($env{'request.course.id'}) {
  if ($ENV{'form.grade_target'} ne 'tex') {   if ($target ne 'tex') {
     $r->print('</head><body>Not in a course</body></html>');      $r->print('</head><body>Not in a course</body></html>');
     return OK;      return OK;
  } else {   } else {
Line 72  ENDDOCUMENT Line 73  ENDDOCUMENT
         return OK;          return OK;
     }      }
   
     my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};      my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};      my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
   
 # --------------------------------------------------------- The syllabus fields  # --------------------------------------------------------- The syllabus fields
     my %syllabusfields=&Apache::lonlocal::texthash(      my %syllabusfields=&Apache::lonlocal::texthash(
Line 87  ENDDOCUMENT Line 88  ENDDOCUMENT
                         ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register']);                          ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register']);
 # ----------------------------------------------------- Force menu registration  # ----------------------------------------------------- Force menu registration
     my $addentries='';      my $addentries='';
     if ($ENV{'form.register'}) {      if ($env{'form.register'}) {
        $addentries=' onLoad="'.&Apache::lonmenu::loadevents().         $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
    '" onUnload="'.&Apache::lonmenu::unloadevents().'"';     '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
        $r->print(&Apache::lonmenu::registerurl(1));         $r->print(&Apache::lonmenu::registerurl(1));
     }      }
 # --------------------------------------------------------------- Force Student  # --------------------------------------------------------------- Force Student
     my $forcestudent='';      my $forcestudent='';
     if ($ENV{'form.forcestudent'} ||$ENV{'form.grade_target'} eq 'tex' ) { $forcestudent='student'; };      if ($env{'form.forcestudent'} || $target eq 'tex' ) { $forcestudent='student'; };
      my $forceedit='';       my $forceedit='';
      if ($ENV{'form.forceedit'}) { $forceedit='edit'; }       if ($env{'form.forceedit'}) { $forceedit='edit'; }
   
   
     my %syllabus=&Apache::lonnet::dump('smppage_'.$marker,$dom,$crs);      my %syllabus=&Apache::lonnet::dump('smppage_'.$marker,$dom,$crs);
                 
 # --------------------------------------- There is such a user, get environment  # --------------------------------------- There is such a user, get environment
   
     if ($ENV{'form.grade_target'} ne 'tex') {      if ($target ne 'tex') {
  $r->print('</head>'.&Apache::loncommon::bodytag   $r->print(&Apache::lonhtmlcommon::htmlareaheaders().
   ("Course Page",$forcestudent,$addentries,'',$dom,$ENV{'form.register'}));    '</head>'.&Apache::loncommon::bodytag
     ("Course Page",$forcestudent,$addentries,'',$dom,$env{'form.register'}));
     }      }
   
     my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});      my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
     my $privileged=$allowed;      my $privileged=$allowed;
     if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {      if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {
  $forcestudent='student';   $forcestudent='student';
     }      }
   
        if ($forcestudent) { $allowed=0; }      if ($forcestudent or $target eq 'tex') { $allowed=0; }
        
     if ($ENV{'form.grade_target'} ne 'tex') {      if ($allowed) {
  if ($allowed) {   $r->print('<p>'.
     $r->print('<p>'.    &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'<br /><a href="'.$r->uri.'?forcestudent=1"><font size="+1">'.&mt('Show Student View').'</font></a>'.
                    &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'<br /><a href="'.$r->uri.'?forcestudent=1"><font size="+1">'.&mt('Show Student View').'</font></a>'.    &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');
                    &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');      } elsif ($privileged and $target ne 'tex') {
    } elsif ($privileged) {   $r->print('<a href="'.$r->uri.'?forceedit=edit"><font size="+1">'.&mt('Edit').'</font></a>');
        $r->print('<a href="'.$r->uri.'?forceedit=edit"><font size="+1">'.&mt('Edit').'</font></a>');      } 
            }       if (($env{'form.uploaddoc.filename'} and $target ne 'tex') &&
        }   ($env{'form.storeupl'}) && ($allowed)) {
       if (($ENV{'form.uploaddoc.filename'}) &&   if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
           ($ENV{'form.storeupl'}) && ($allowed)) {      if ($syllabus{'uploaded.photourl'}) {
    if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {   &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
              $syllabus{'uploaded.photourl'}=      }
                  &Apache::lonnet::userfileupload('uploaddoc',1);      $syllabus{'uploaded.photourl'}=
    }   &Apache::lonnet::userfileupload('uploaddoc',1,'simplepage');
           $syllabus{'uploaded.lastmodified'}=time;   }
           &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);   $syllabus{'uploaded.lastmodified'}=time;
        }   &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
        if (($allowed) && ($ENV{'form.storesyl'})) {      }
    foreach (keys %syllabusfields) {      if (($allowed) && ($env{'form.storesyl'})) {
                my $field=$ENV{'form.'.$_};   foreach (keys %syllabusfields) {
                $field=~s/\s+$//s;      my $field=$env{'form.'.$_};
                $field=&Apache::lonfeedback::clear_out_html($field,1);      chomp($field);
        $syllabus{$_}=$field;      $field=~s/\s+$//s;
            }      $field=~s/^\s+//s;
            $syllabus{'uploaded.lastmodified'}=time;      $field=~s/\<br\s*\/*\>$//s;
            &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);      $field=&Apache::lonfeedback::clear_out_html($field,1);
        }      $syllabus{$_}=$field;
    }
    $syllabus{'uploaded.lastmodified'}=time;
    &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
       }
   
 # ---------------------------------------------------------------- Get syllabus  # ---------------------------------------------------------------- Get syllabus
     if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {      if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
        if ($syllabus{'uploaded.photourl'}) {   if ($syllabus{'uploaded.photourl'}) {
    if ($ENV{'form.grade_target'} ne 'tex') {      &Apache::lonnet::allowuploaded('/adm/smppg',
        $r->print('<img src="'.     $syllabus{'uploaded.photourl'});
  &Apache::lonnet::tokenwrapper($syllabus{'uploaded.photourl'}).      
  '" align="right" />');      my $image='<img src="'.$syllabus{'uploaded.photourl'}.'"
    }                              align="right" />';
        }      if ($target eq 'tex') {
        if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) {   $image=&Apache::lonxml::xmlparse($r,'tex',$image);
            $r->print(      }
  '<form method="post" enctype="multipart/form-data">'.      $r->print($image);
  '<input type="hidden" name="forceedit" value="edit" />'.   }
          '<h3>Upload a Photo</h3>'.   if ($allowed) {
          '<input type="file" name="uploaddoc" size="50">'.      $r->print(
          '<input type="submit" name="storeupl" value="Upload">'.        '<form method="post" enctype="multipart/form-data">'.
  '</form><form method="post">');        '<input type="hidden" name="forceedit" value="edit" />'.
        }        '<h3>Upload a Photo</h3>'.
        foreach (sort keys %syllabusfields) {        '<input type="file" name="uploaddoc" size="50">'.
           if (($syllabus{$_}) || ($allowed)) {        '<input type="submit" name="storeupl" value="Upload">'.
               my $message=$syllabus{$_};        '</form><form method="post">');
               $message=~s/\n/\<br \/\>/g;   }
               $message   foreach (sort keys %syllabusfields) {
         =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;      if (($syllabus{$_}) || ($allowed)) {
       $message=&Apache::lontexconvert::msgtexconverted($message);   my $message=$syllabus{$_};
             unless ($_ eq 'aaa_title') {   &Apache::lonfeedback::newline_to_br(\$message);
  if (($_ ne 'bbb_content') || ($allowed)) {   $message
     if ($ENV{'form.grade_target'} ne 'tex') {      =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
  $r->print('<h3>'.$syllabusfields{$_}.'</h3>');   $message=&Apache::lontexconvert::msgtexconverted($message);
     } else {   if ($allowed) {
  my $safeinit;      $message=&Apache::lonspeller::markeduptext($message);
  $r->print(&Apache::lonxml::xmlparse($r,'tex','<h3>'.$syllabusfields{$_}.'</h3>'));  
     }  
  }   }
  if ($ENV{'form.grade_target'} ne 'tex') {   unless ($_ eq 'aaa_title') {
     $r->print('<blockquote>'.      if (($_ ne 'bbb_content') || ($allowed)) {
       $message.'</blockquote>');   if ($target ne 'tex') {
  } else {      $r->print('<h3>'.$syllabusfields{$_}.'</h3>');
    } else {
       my $safeinit;
       $r->print(&Apache::lonxml::xmlparse($r,'tex','<h3>'.$syllabusfields{$_}.'</h3>'));
    }
       }
       if ($target ne 'tex') {
    $r->print('<blockquote>'.
     $message.'</blockquote>');
       } else {
  my $safeinit;   my $safeinit;
  $r->print(&Apache::lonxml::xmlparse($r,'tex',$message));   $r->print(&Apache::lonxml::xmlparse($r,'tex',$message));
  }      }
                  if ($allowed) {      if ($allowed) {
      if ($ENV{'form.grade_target'} ne 'tex') {   if ($target ne 'tex') {
  $r->print('<br /><textarea cols="80" rows="20" name="'.$_.'">'.      $r->print('<br /><textarea cols="80" rows="24" name="'.$_.'" id="'.$_.'">'.
    $syllabus{$_}.        $syllabus{$_}.
                            '</textarea><input type="submit" name="storesyl" value="Store" />');        '</textarea><input type="submit" name="storesyl" value="Store" />');
      } else {   } else {
  my $safeinit;      my $safeinit;
  $r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit));      $r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit));
      }   }
         }      }
     } else {  
  if ($ENV{'form.grade_target'} ne 'tex') {  
     $r->print('<h1>'.$message.'</h1>');  
  } else {   } else {
     my $safeinit;      if ($target ne 'tex') {
     $r->print(&Apache::lonxml::xmlparse($r,'tex','<h1>'.$message.'</h1>'));   $r->print('<h1>'.$message.'</h1>');
  }  
                 if ($allowed) {  
     if ($ENV{'form.grade_target'} ne 'tex') {  
  $r->print(  
     '<br />Title<br /><textarea cols="80" rows="2" name="'.$_.'">'.  
     $syllabus{$_}.  
                             '</textarea><input type="submit" name="storesyl" value="Store" />');  
     } else {      } else {
  my $safeinit;   my $safeinit;
  $r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit));   $r->print(&Apache::lonxml::xmlparse($r,'tex','<h1>'.$message.'</h1>'));
       }
       if ($allowed) {
    if ($env{'form.grade_target'} ne 'tex') {
       $r->print(
         '<br />Title<br /><textarea cols="80" rows="2" name="'.$_.'">'.
         $syllabus{$_}.
         '</textarea><input type="submit" name="storesyl" value="Store" />');
    } else {
       my $safeinit;
       $r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit));
    }
     }      }
                 }   }
             }      }
   }   }
        }   if ($allowed && ($env{'form.grade_target'} ne 'tex')) {
        if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) {      $r->print(&Apache::lonhtmlcommon::htmlareaselectactive
    $r->print('</form>');        ('bbb_content').'</form>');
        }   }
        if ($ENV{'form.grade_target'} ne 'tex') {$r->print('</p>');}   if ($env{'form.grade_target'} ne 'tex') {$r->print('</p>');}
     } else {      } else {
        $r->print('<p>No page information provided.</p>');   $r->print('<p>No page information provided.</p>');
     }      }
     if ($ENV{'form.grade_target'} ne 'tex') {      if ($env{'form.grade_target'} ne 'tex') {
  $r->print('</body></html>');   $r->print('</body></html>');
     } else {      } else {
  $r->print('\end{document}');   $r->print('\end{document}');

Removed from v.1.16  
changed lines
  Added in v.1.26


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