Diff for /loncom/interface/lonsyllabus.pm between versions 1.127 and 1.130

version 1.127, 2013/05/16 20:03:51 version 1.130, 2013/08/27 03:00:38
Line 73  sub handler { Line 73  sub handler {
     my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);      my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
     my $crstype = &Apache::loncommon::course_type();      my $crstype = &Apache::loncommon::course_type();
   
 # ------------------------------------------------------------ Print the screen  
   
     if ($target eq 'tex') {  
         $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));  
     }  
   
 # --------------------------------------------------------------- Force Student  # --------------------------------------------------------------- Force Student
     my ($forceedit,$forcestudent);      my ($forceedit,$forcestudent);
     if ($env{'form.forceedit'}) { $forceedit=1; }      if ($env{'form.forceedit'}) { $forceedit=1; }
Line 124  sub handler { Line 118  sub handler {
                 if ($filecontents eq -1) {                  if ($filecontents eq -1) {
                     $r->print(&mt('Syllabus file unavailable'));                      $r->print(&mt('Syllabus file unavailable'));
                 } elsif ($filetype eq 'tex') {                  } elsif ($filetype eq 'tex') {
                     my $result = &Apache::lontexconvert::converted(\$filecontents,                      if ($target eq 'tex') {
                                                                 $env{'form.texengine'});                          $r->print($filecontents);
                     my %args;                      } else {
                     &get_breadcrumbs($cdom,$cnum,$crstype,\%args);                          my $result = &Apache::lontexconvert::converted(\$filecontents,
                     $r->print(&Apache::loncommon::start_page("Syllabus",undef,\%args).                                                                         $env{'form.texengine'});
                               $result.                          my %args;
                               &Apache::loncommon::end_page());                          &get_breadcrumbs($cdom,$cnum,$crstype,\%args);
                           $r->print(&Apache::loncommon::start_page("Syllabus",undef,\%args).
                                     $result.
                                     &Apache::loncommon::end_page());
                       }
                 } else {                  } else {
                     my %mystyle;                      my %mystyle;
                       unless ($target eq 'tex') {
                           $target = 'web';
                       }
                     &Apache::structuretags::reset_problem_globals();                      &Apache::structuretags::reset_problem_globals();
                     my $oldfile = $env{'request.filename'};                      my $oldfile = $env{'request.filename'};
                     $env{'request.filename'} = $item;                      $env{'request.filename'} = $item;
                     my $result = &Apache::lonxml::xmlparse($r,'web',$filecontents,                      my $result = &Apache::lonxml::xmlparse($r,$target,$filecontents,
                                                            '',%mystyle);                                                             '',%mystyle);
                     &Apache::structuretags::reset_problem_globals();                      &Apache::structuretags::reset_problem_globals();
                     &Apache::lonhomework::finished_parsing();                      &Apache::lonhomework::finished_parsing();
Line 145  sub handler { Line 146  sub handler {
                     $r->print($result);                      $r->print($result);
                 }                  }
             } else {              } else {
                 $r->print(&Apache::lonwrapper::wrapper($item));                  if ($target eq 'tex') {
                       $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}).
                                 ' \strut \\\\ \textbf{'.&mt('Syllabus').'} \strut \\\\ '.
                                 &mt('Unsupported file type.').' \strut \\\\ '.
                                 &mt('Print the syllabus directly from your web browser').
                                 '\end{document}');
                   } else {
                       $r->print(&Apache::lonwrapper::wrapper($item));
                   }
             }              }
             return OK;              return OK;
         }          }
     } elsif ($external=~/\w/) {      } elsif ($external=~/\w/) {
         unless ($allowed && $forceedit) {          unless ($allowed && $forceedit) {
             $r->print(&Apache::lonwrapper::wrapper($external));              if ($target eq 'tex') {
                   $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}).
                            ' \strut \\\\ \textbf{'.&mt('Syllabus').'} \strut \\\\ '.$external.' '.
                            ' \strut \\\\ '.&mt('Print the syllabus directly from your web browser').
                            '\end{document}');
               } else {
                   $r->print(&Apache::lonwrapper::wrapper($external));
               }
             return OK;              return OK;
         }          }
     }      }
   
   # ------------------------------------------------------------ Print the screen
   
       if ($target eq 'tex') {
           $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
       }
   
 # ------------------------------ The buck stops here: internal syllabus display  # ------------------------------ The buck stops here: internal syllabus display
 # --------------------------------------------------------- The syllabus fields  # --------------------------------------------------------- The syllabus fields
Line 406  sub handler { Line 427  sub handler {
     }      }
 # ---------------------------------------------------------------- Get syllabus  # ---------------------------------------------------------------- Get syllabus
     if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {      if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
         if ($allowed) {  
             $r->print('<form method="post" action="">');  
         }  
   
  my $url_include_handler = sub {   my $url_include_handler = sub {
  my ($r, $field, $message, $group, $data_ref, $fields_ref, $target, $allowed, $display) = @_;   my ($r, $field, $message, $group, $data_ref, $fields_ref, $target, $allowed, $display) = @_;
  my %data = %{$data_ref};   my %data = %{$data_ref};
Line 456  sub handler { Line 473  sub handler {
  $target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML, \%custom_hash,   $target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML, \%custom_hash,
                         undef,\%displayfields,\%noshow);                          undef,\%displayfields,\%noshow);
         if ($allowed) {          if ($allowed) {
             $r->print('</form>'.              $r->print('</div></form>'.
             &Apache::lonhtmlcommon::htmlareaselectactive());              &Apache::lonhtmlcommon::htmlareaselectactive());
         }          }
     } else {      } else {
Line 1011  sub get_personnel { Line 1028  sub get_personnel {
                 }                  }
                 if ($allowed) {                  if ($allowed) {
                     my $item = '<span class="LC_nobreak"><label>'.                      my $item = '<span class="LC_nobreak"><label>'.
                                '<input type="checkbox" name="hideuser" value="'.$element.'&'.$puname.':'.$pudom.'"'.$checked.' />'.                                 '<input type="checkbox" name="hideuser" value="'.$element.'&amp;'.$puname.':'.$pudom.'"'.$checked.' />'.
                                &Apache::loncommon::aboutmewrapper($courseperson                                 &Apache::loncommon::aboutmewrapper($courseperson
 ,  ,
                                                $puname,$pudom).                                                 $puname,$pudom).
Line 1040  sub get_personnel { Line 1057  sub get_personnel {
         }          }
         if ($target ne 'tex') {          if ($target ne 'tex') {
             if ($allowed) {              if ($allowed) {
                 $r->print(&Apache::loncommon::end_data_table_row());                  $r->print('</td>'.&Apache::loncommon::end_data_table_row());
             } else {              } else {
                 my $lastclose=$element eq $lastpers?1:0;                  my $lastclose=$element eq $lastpers?1:0;
                 $r->print(&Apache::lonhtmlcommon::row_closure($lastclose));                  $r->print(&Apache::lonhtmlcommon::row_closure($lastclose));
Line 1067  sub save_changes { Line 1084  sub save_changes {
     unless ((ref($syllabus) eq 'HASH') && (ref($syllabusfields) eq 'HASH')) {      unless ((ref($syllabus) eq 'HASH') && (ref($syllabusfields) eq 'HASH')) {
         return ($earlyout,$uploaded,$external,$minimal,$output);          return ($earlyout,$uploaded,$external,$minimal,$output);
     }      }
     if ($env{'form.deleteuploaded'}) {      if (($env{'form.deleteuploaded_file'}) || ($env{'form.deleteuploaded_minimal'})) {
         my %storehash;          my %storehash;
         if (($env{'form.choice'} eq 'file') &&           if (($env{'form.choice'} eq 'file') && 
             ($env{'form.deleteuploaded'} eq 'file') && ($uploaded =~ /\w/)) {              ($env{'form.deleteuploaded_file'}) && ($uploaded =~ /\w/)) {
             &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.uploadedsyllabus');              &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.uploadedsyllabus');
             &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.externalsyllabus');              &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.externalsyllabus');
             $storehash{'uploadedsyllabus'} = '';              $storehash{'uploadedsyllabus'} = '';
Line 1079  sub save_changes { Line 1096  sub save_changes {
             undef($uploaded);              undef($uploaded);
             undef($external);              undef($external);
         } elsif (($env{'form.choice'} eq 'minimal') &&          } elsif (($env{'form.choice'} eq 'minimal') &&
                  ($env{'form.deleteuploaded'} eq 'minimal') && ($minimal =~ /\w/)) {                   ($env{'form.deleteuploaded_minimal'}) && ($minimal =~ /\w/)) {
             &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.externalsyllabus');              &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.externalsyllabus');
             &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.minimalsyllabus');              &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.minimalsyllabus');
             $storehash{'externalsyllabus'} = '';              $storehash{'externalsyllabus'} = '';
Line 1367  sub update_syllabus_env { Line 1384  sub update_syllabus_env {
         $storehash{'updatedsyllabus'} = $now;          $storehash{'updatedsyllabus'} = $now;
         &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.updatedsyllabus' => $now          &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.updatedsyllabus' => $now
 });  });
   
     } elsif ($saved eq 'url') {      } elsif ($saved eq 'url') {
         my $prefix = &home_http_host($cdom,$cnum);          my $prefix = &home_http_host($cdom,$cnum);
         if ($external =~ m{^\Q$prefix/uploaded/$cdom/$cnum/portfolio/syllabus/\E(.+)$}) {          if ($external =~ m{^\Q$prefix/uploaded/$cdom/$cnum/portfolio/syllabus/\E(.+)$}) {
Line 1399  sub update_syllabus_env { Line 1415  sub update_syllabus_env {
     if (@envkeys > 0) {      if (@envkeys > 0) {
         foreach my $item (@envkeys) {          foreach my $item (@envkeys) {
             my $key = $item.'syllabus';              my $key = $item.'syllabus';
             if ($courseenv->{$key}) {              if ($courseenv->{$key} ne '') {
                 &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.'.$key);                  &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.'.$key);
                 $storehash{$key} = '';                  $storehash{$key} = '';
             }              }
Line 1527  sub editfile_button { Line 1543  sub editfile_button {
     }      }
     $output .= '      $output .= '
                 <input type="button" value="'.$deltext.'" onclick="javascript:dodelete('."'$context'".');" name="del_'.$context.'" />                  <input type="button" value="'.$deltext.'" onclick="javascript:dodelete('."'$context'".');" name="del_'.$context.'" />
                 <input type="hidden" value="" name="deleteuploaded" />                  <input type="hidden" value="" name="deleteuploaded_'.$context.'" id="deleteuploaded_'.$context.'" />
     ';      ';
     return $output;      return $output;
 }  }
Line 1545  sub editbutton_js { Line 1561  sub editbutton_js {
                       document.location.href = url+'?editmode=1&forceedit=1';                        document.location.href = url+'?editmode=1&forceedit=1';
                   }                    }
                   function dodelete(caller,url) {                    function dodelete(caller,url) {
                       document.syllabus.deleteuploaded.value=caller;                        if (document.getElementById('deleteuploaded_'+caller)) {
                       if (caller == 'minimal') {                            document.getElementById('deleteuploaded_'+caller).value=1;
                           if (confirm("$lt{'min'}"+"\\n"+"$lt{'noundo'}")) {                            if (caller == 'minimal') {
                               document.syllabus.submit();                                if (confirm("$lt{'min'}"+"\\n"+"$lt{'noundo'}")) {
                                     document.syllabus.submit();
                                 }
                           }                            }
                       }                            if (caller == 'file') {
                       if (caller == 'file') {                                if (confirm("$lt{'file'}"+"\\n"+"$lt{'noundo'}")) {
                           if (confirm("$lt{'file'}"+"\\n"+"$lt{'noundo'}")) {                                    document.syllabus.submit();
                               document.syllabus.submit();                                }
                           }                            }
                       }                        }
                       return;                           return;   

Removed from v.1.127  
changed lines
  Added in v.1.130


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