Diff for /loncom/interface/londocs.pm between versions 1.454 and 1.466

version 1.454, 2011/07/04 13:01:53 version 1.466, 2011/11/27 22:51:28
Line 176  sub dumpcourse { Line 176  sub dumpcourse {
     $newfilename=&clean($newfilename);      $newfilename=&clean($newfilename);
     $newfilename.='.'.$ext;      $newfilename.='.'.$ext;
     my @dirs=split(/\//,$newfilename);      my @dirs=split(/\//,$newfilename);
     my $path='/home/'.$ca.'/public_html';      my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
     my $makepath=$path;      my $makepath=$path;
     my $fail=0;      my $fail=0;
     for (my $i=0;$i<$#dirs;$i++) {      for (my $i=0;$i<$#dirs;$i++) {
Line 681  sub build_package { Line 681  sub build_package {
                     $currdirpath = 'Top';                      $currdirpath = 'Top';
                     my $pcslist = $curRes->map_hierarchy();                      my $pcslist = $curRes->map_hierarchy();
                     if ($pcslist ne '') {                      if ($pcslist ne '') {
                         foreach my $pc (split(/,/,$pcslist)) {                          foreach my $pc (split(/,/,$pcslist),$curRes->map_pc()) {
                               next if ($pc <= 1);
                             my $res = $navmap->getByMapPc($pc);                              my $res = $navmap->getByMapPc($pc);
                             if (ref($res)) {                              if (ref($res)) {
                                 my $encloser = $res->title();                                  my $encloser = $res->title();
Line 896  sub replicate_content { Line 897  sub replicate_content {
                              grade_courseid => $cdom.'_'.$cnum,                               grade_courseid => $cdom.'_'.$cnum,
                              grade_domain   => $env{'user.domain'},                               grade_domain   => $env{'user.domain'},
                              grade_username => $env{'user.name'},                               grade_username => $env{'user.name'},
                              grade_imsexport => 1,                                grade_imsexport => 1,
                                instructor_comments => 'hide',
                            );                             );
                 my $feedurl=&Apache::lonnet::clutter($url);                  my $feedurl=&Apache::lonnet::clutter($url);
                 my ($userview,$response)=&Apache::lonnet::ssi_body($feedurl,%form);                  my ($userview,$response)=&Apache::lonnet::ssi_body($feedurl,%form);
Line 917  sub replicate_content { Line 919  sub replicate_content {
                                     $foilcounter ++;                                      $foilcounter ++;
                                 } elsif ($line =~ m{(|\Q</label>\E)\Q<br />Correct:<b><label>\E}) {                                  } elsif ($line =~ m{(|\Q</label>\E)\Q<br />Correct:<b><label>\E}) {
                                     $foilcounter ++;                                      $foilcounter ++;
                                     $mc_answer = $alphabet[$foilcounter];                                      $mc_answer = $alphabet[$foilcounter-1];
                                 } elsif ($line !~ m{</label><br />}) {                                  } elsif ($line !~ m{\Q</label>\E(|\Q</b>\E)\Q<br />\E}) {
                                     $line =~ s/^(\s+|\s+)$//g;                                      $line =~ s/^(\s+|\s+)$//g;
                                     $line =~ s{^\Q<b>\E([^<]+)\Q</b>\E$}{1};                                      $line =~ s{^\Q<b>\E([^<]+)\Q</b>\E$}{1};
                                     push(@tosave,$line);                                      $tosave[$foilcounter] .= $line.' ';
                                 }                                  }
                                 $content = join("\t",@tosave);                                  $content = join("\t",@tosave);
                                 if ($mc_answer) {                                  if ($mc_answer) {
Line 929  sub replicate_content { Line 931  sub replicate_content {
                                 }                                  }
                             }                              }
                             if (@tosave) {                              if (@tosave) {
                                 $content = $currdirpath."\t".$title."\t".join("\t",@tosave);                                  my $qtype;
                                 if ($mc_answer) {                                  if ($mc_answer) {
                                     $content .= "\t".$mc_answer."\n";                                      $qtype = 'MC';
                                 }                                  }
                                   $content = $currdirpath."\t".$title."\t$qtype\t".join("\t",@tosave);
                                   if ($mc_answer) {
                                       $content .= "\t".$mc_answer;
                                   } 
                                   $content .= "\n";
                             }                              }
                         } else {                          } else {
                             $content = '<html><body>'.$content.'</body></html>';                              $content = '<html><body>'.$content.'</body></html>';
Line 1570  sub handle_edit_cmd { Line 1577  sub handle_edit_cmd {
   
     if ($cmd eq 'del') {      if ($cmd eq 'del') {
  if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&   if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
     ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {      ($url!~/$LONCAPA::assess_page_seq_re/)) {
     &Apache::lonnet::removeuploadedurl($url);      &Apache::lonnet::removeuploadedurl($url);
  } else {   } else {
     &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);      &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
Line 1606  sub handle_edit_cmd { Line 1613  sub handle_edit_cmd {
 }  }
   
 sub editor {  sub editor {
     my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype)=@_;      my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
           $supplementalflag,$orderhash)=@_;
     my $container= ($env{'form.pagepath'}) ? 'page'      my $container= ($env{'form.pagepath'}) ? 'page'
                            : 'sequence';                             : 'sequence';
   
Line 1735  sub editor { Line 1743  sub editor {
         $r->print('</div>');          $r->print('</div>');
     }      }
   
     my $output;        my ($to_show,$output);
   
     &Apache::loncommon::start_data_table_count(); #setup a row counter       &Apache::loncommon::start_data_table_count(); #setup a row counter 
     foreach my $res (@LONCAPA::map::order) {      foreach my $res (@LONCAPA::map::order) {
Line 1752  sub editor { Line 1760  sub editor {
     &Apache::loncommon::end_data_table_count();      &Apache::loncommon::end_data_table_count();
           
     if ($shown) {      if ($shown) {
         $r->print(&Apache::loncommon::start_scrollbox('900px','880px','400px')          $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
                  .&Apache::loncommon::start_data_table());                    .&Apache::loncommon::start_data_table(undef,'contentlist');
         if ($allowed) {          if ($allowed) {
             $r->print(&Apache::loncommon::start_data_table_header_row()              $to_show .= &Apache::loncommon::start_data_table_header_row()
                      .'<th colspan="2">'.&mt('Move').'</th>'                       .'<th colspan="2">'.&mt('Move').'</th>'
                      .'<th>'.&mt('Actions').'</th>'                       .'<th>'.&mt('Actions').'</th>'
                      .'<th colspan="2">'.&mt('Document').'</th>');                       .'<th colspan="2">'.&mt('Document').'</th>';
             if ($folder !~ /^supplemental/) {              if ($folder !~ /^supplemental/) {
                 $r->print('<th colspan="4">'.&mt('Settings').'</th>');                  $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
             }              }
             $r->print(&Apache::loncommon::end_data_table_header_row());              $to_show .= &Apache::loncommon::end_data_table_header_row();
         }          }
         $r->print($output          $to_show .= $output.' '
                  .&Apache::loncommon::end_data_table()                   .&Apache::loncommon::end_data_table()
                  .&Apache::loncommon::end_scrollbox()                   .'<br style="line-height:2px;" />'
         );                   .&Apache::loncommon::end_scrollbox();
     } else {      } else {
         $r->print('<p class="LC_info">'          $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
                    .'<div class="LC_info" id="contentlist">'
                  .&mt('Currently no documents.')                   .&mt('Currently no documents.')
                  .'</p>'                   .'</div>'
         );                   .&Apache::loncommon::end_scrollbox();
       }
       my $tid = 1;
       if ($supplementalflag) {
           $tid = 2;
     }      }
     if ($allowed) {      if ($allowed) {
           $r->print(&generate_edit_table($tid,$orderhash,$to_show));
         &print_paste_buffer($r,$container);          &print_paste_buffer($r,$container);
       } else {
           $r->print($to_show);
     }      }
     return;      return;
 }  }
Line 1805  sub process_file_upload { Line 1821  sub process_file_upload {
             $LONCAPA::map::resources[1]='';              $LONCAPA::map::resources[1]='';
         }          }
         if ($fatal) {          if ($fatal) {
             $$upload_output = '<p><span class="LC_error">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</span></p>';              $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
             return;              return;
         }          }
         my $destination = 'docs/';          my $destination = 'docs/';
Line 1831  sub process_file_upload { Line 1847  sub process_file_upload {
         } else {          } else {
             my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});              my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
                           
             $$upload_output = '<p><span class="LC_error">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</span></p>';              $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
             return;              return;
         }          }
         my $ext='false';          my $ext='false';
Line 1850  sub process_file_upload { Line 1866  sub process_file_upload {
         ($errtext,$fatal)=&storemap($coursenum,$coursedom,          ($errtext,$fatal)=&storemap($coursenum,$coursedom,
     $folder.'.'.$container);      $folder.'.'.$container);
         if ($fatal) {          if ($fatal) {
             $$upload_output = '<p><span class="LC_error">'.$errtext.'</span></p>';              $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
             return;              return;
         } else {          } else {
             if ($parseaction eq 'parse' && $mimetype eq 'text/html') {              if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
Line 1877  sub process_file_upload { Line 1893  sub process_file_upload {
                 } else {                  } else {
                     $$upload_output .= &mt('No embedded items identified').'<br />';                      $$upload_output .= &mt('No embedded items identified').'<br />';
                 }                  }
                   $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
             }              }
         }          }
     }      }
Line 2203  END Line 2220  END
     $form_start      $form_start
     <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>      <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
     $form_end      $form_end
   </td>      <br />
   <td class="LC_docs_entry_parameter">  
     $form_start      $form_start
     <label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>      <label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
     $form_end      $form_end
   </td>    </td>
   <td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>    <td class="LC_docs_entry_parameter">$form_start $parameterset $form_end<br />
   <td class="LC_docs_entry_parameter">$form_start $parameterset $form_end</td>                                        $form_start $rand_order_text $form_end</td>
 ENDPARMS  ENDPARMS
     }      }
     $line.=&Apache::loncommon::end_data_table_row();      $line.=&Apache::loncommon::end_data_table_row();
Line 2615  ENDHEADERS Line 2631  ENDHEADERS
                     $r->print(' <a href="/adm/diff?filename='.                      $r->print(' <a href="/adm/diff?filename='.
       &Apache::lonnet::clutter($root.'.'.$extension).        &Apache::lonnet::clutter($root.'.'.$extension).
       '&versionone='.$prevvers.        '&versionone='.$prevvers.
       '">'.&mt('Diffs').'</a>');        '" target="diffs">'.&mt('Diffs').'</a>');
  }   }
  $r->print('</span><br />');   $r->print('</span><br />');
                 if (++$entries_count % $entries_per_col == 0) {                  if (++$entries_count % $entries_per_col == 0) {
Line 2745  sub startContentScreen { Line 2761  sub startContentScreen {
   
     if ($allowed) {      if ($allowed) {
         $r->print('<li '.(($mode eq 'docs')?' class="active"':'').          $r->print('<li '.(($mode eq 'docs')?' class="active"':'').
                '><a href="/adm/coursedocs?forcestandard=1"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Editor').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>');                 ' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Editor').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>');
     }      }
     $r->print('<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Search').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>');      $r->print('<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Search').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>');
     $r->print('<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Index').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>');      $r->print('<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Index').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>');
     $r->print('<li '.(($mode eq 'supdocs')?' class="active"':'').      $r->print('<li '.(($mode eq 'supdocs')?' class="active"':'').
            '><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Documents').'</b></a></li>');             '><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Documents').'</b></a></li>');
     $r->print('</ul>');      $r->print('</ul>');
     $r->print('<div class="LC_Box" style="clear:both;margin:0;">'      $r->print('<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'
              .'<div id="maincoursedoc" style="margin:0 0;padding:0 0;">');               .'<div id="maincoursedoc" style="margin:0 0;padding:0 0">');
     $r->print('<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">');      $r->print('<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">');
 }  }
   
Line 2829  sub handler { Line 2845  sub handler {
 #  #
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['folderpath','pagepath',                                              ['folderpath','pagepath',
                                              'pagesymb','forcesupplement','forcestandard']);                                               'pagesymb','forcesupplement','forcestandard',
                                                'symb','command']);
   
 # standard=1: this is a "new-style" course with an uploaded map as top level  # standard=1: this is a "new-style" course with an uploaded map as top level
 # standard=2: this is a "old-style" course, and there is nothing we can do  # standard=2: this is a "old-style" course, and there is nothing we can do
Line 2852  sub handler { Line 2869  sub handler {
   
     my $script='';      my $script='';
     my $showdoc=0;      my $showdoc=0;
       my $addentries = {};
     my $containertag;      my $containertag;
     my $uploadtag;      my $uploadtag;
   
   # Do we directly jump somewhere?
   
      if ($env{'form.command'} eq 'direct') {
          my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
          if ($resurl=~/\.(sequence|page)$/) {
              $mapurl=$resurl;
          }
          my $maptitle = &Apache::lonnet::gettitle($mapurl);
          $mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1};
          my $type=$2;
          my $path='default&'.&Apache::lonhtmlcommon::entity_encode('Main Course Documents').
                   '&default&...::::&'.
                   &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
                           &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
          if ($type eq 'sequence') {
              $env{'form.folderpath'}=$path;
              $env{'form.pagepath'}='';
          } else {
              $env{'form.pagepath'}=$path;
              $env{'form.folderpath'}='';
          }
      }
   
 # Where do we store these for when we come back?  # Where do we store these for when we come back?
     my $stored_folderpath='docs_folderpath';      my $stored_folderpath='docs_folderpath';
     if ($supplementalflag) {      if ($supplementalflag) {
        $stored_folderpath='docs_sup_folderpath';         $stored_folderpath='docs_sup_folderpath';
     }      }
          
 # No folderpath, no pagepath, see if we have something stored  # No folderpath, no pagepath, see if we have something stored
     if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {      if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
         &Apache::loncommon::restore_course_settings($stored_folderpath,          &Apache::loncommon::restore_course_settings($stored_folderpath,
Line 2952  sub handler { Line 2993  sub handler {
     $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");      $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
   
     if ($allowed) {      if ($allowed) {
  $script .= &editing_js($udom,$uname);          my @tabids;
           if ($supplementalflag) {
               @tabids = ('002','ee2','ff2');
           } else {
               @tabids = ('aa1','bb1','cc1','ff1');
               unless ($env{'form.pagepath'}) {
                   unshift(@tabids,'001');
                   push(@tabids,('dd1','ee1'));
               }
           }
           my $tabidstr = join("','",@tabids);
    $script .= &editing_js($udom,$uname).
                      &resize_contentdiv_js($tabidstr);
           $addentries = {
                           onload   => "javascript:resize_contentdiv('contentscroll','1','1');",
                         };
     }      }
 # -------------------------------------------------------------------- Body tag  # -------------------------------------------------------------------- Body tag
     $script = '<script type="text/javascript">'."\n"      $script = '<script type="text/javascript">'."\n"
Line 2968  sub handler { Line 3024  sub handler {
             href=>"/adm/coursedocs",text=>"$crstype Contents"});              href=>"/adm/coursedocs",text=>"$crstype Contents"});
   
         $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,          $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
                                                  {'force_register' => $showdoc,})                                                   {'force_register' => $showdoc,
                                                     'add_entries'    => $addentries,
                                                    })
                  .&Apache::loncommon::help_open_menu('','',273,'RAT')                   .&Apache::loncommon::help_open_menu('','',273,'RAT')
                  .&Apache::lonhtmlcommon::breadcrumbs(                   .&Apache::lonhtmlcommon::breadcrumbs(
                      'Editing the Table of Contents for your '.$crstype,                       'Editing the Table of Contents for your '.$crstype,
Line 3077  FIUP Line 3135  FIUP
  </label>   </label>
 CHBO  CHBO
   
     my $fileuploada = "<input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}";      my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}";
  my $fileuploadform=(<<FUFORM);   my $fileuploadform=(<<FUFORM);
  <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">   <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
  <input type="hidden" name="active" value="aa" />   <input type="hidden" name="active" value="aa" />
  $fileupload   $fileupload
  <br />   <br />
  $lt{'title'}:<br />   $lt{'title'}:<br />
  <input type="text" size="80" name="comment" />   <input type="text" size="60" name="comment" />
  $uploadtag   $uploadtag
  <input type="hidden" name="cmd" value="upload_default" />   <input type="hidden" name="cmd" value="upload_default" />
  <br />   <br />
  <span class="LC_nobreak">   <span class="LC_nobreak" style="float:left">
  $checkbox   $checkbox
  </span>   </span>
 FUFORM  FUFORM
     $fileuploadform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$fileuploada,{class => 'LC_menubuttons_inline_text'})).'</form>';      $fileuploadform .= $fileuploada.'</form>';
   
  my $simpleeditdefaultform=(<<SEDFFORM);   my $simpleeditdefaultform=(<<SEDFFORM);
  <form action="/adm/coursedocs" method="post" name="simpleeditdefault">   <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
Line 3105  SEDFFORM Line 3163  SEDFFORM
  );   );
  $simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma));   $simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma));
  $simpleeditdefaultform .=(<<SEDFFORM);   $simpleeditdefaultform .=(<<SEDFFORM);
  <hr />   <hr id="bb_hrule" style="width:0px;text-align:left;margin-left:0" />
  <p>  
  $lt{'copm'}<br />   $lt{'copm'}<br />
  <input type="text" size="40" name="importmap" /><br />   <input type="text" size="40" name="importmap" /><br />
  <span class="LC_nobreak"><input type="button"   <span class="LC_nobreak" style="float:left"><input type="button"
  onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"   onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
  value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />   value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
  $help{'Load_Map'}</span>   $help{'Load_Map'}</span>
  </p>  
  </form>   </form>
 SEDFFORM  SEDFFORM
   
Line 3360  NGFFORM Line 3416  NGFFORM
         my @importdoc = (          my @importdoc = (
         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform},          {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform},
         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},);          {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},);
         $fileuploadform =  &create_form_ul(&create_list_elements(@importdoc)) . '<hr/>' . $fileuploadform;          $fileuploadform =  &create_form_ul(&create_list_elements(@importdoc)) . '<hr id="cc_hrule" style="width:0px;text-align:left;margin-left:0" />' . $fileuploadform;
   
         @gradingforma=(          @gradingforma=(
         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},          {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
Line 3401  unless ($env{'form.pagepath'}) { Line 3457  unless ($env{'form.pagepath'}) {
   
  $hadchanges=0;   $hadchanges=0;
        unless ($supplementalflag) {         unless ($supplementalflag) {
           my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);            my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                                 $supplementalflag,\%orderhash);
           if ($error) {            if ($error) {
              $r->print('<p><span class="LC_error">'.$error.'</span></p>');               $r->print('<p><span class="LC_error">'.$error.'</span></p>');
           }            }
Line 3410  unless ($env{'form.pagepath'}) { Line 3467  unless ($env{'form.pagepath'}) {
           }            }
   
           &changewarning($r,'');            &changewarning($r,'');
           $r->print(&generate_edit_table('1',\%orderhash));  
         }          }
       }
  }  
   
 # Supplemental documents start here  # Supplemental documents start here
   
Line 3507  my @supimportdoc = ( Line 3562  my @supimportdoc = (
  {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />'   {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />'
             =>$supnewextform},              =>$supnewextform},
         );          );
 $supupdocform =  &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr/>' . $supupdocform;  $supupdocform =  &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr id="ee_hrule" style="width:0px;text-align:left;margin-left:0" />' . $supupdocform;
 my %suporderhash = (  my %suporderhash = (
  '00' => ['Supnewfolder', $supnewfolderform],   '00' => ['Supnewfolder', $supnewfolderform],
                 'ee' => ['Import Documents',$supupdocform],                  'ee' => ['Import Documents',$supupdocform],
                 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))]                  'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))]
                 );                  );
         if ($supplementalflag) {          if ($supplementalflag) {
            my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);             my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                                  $supplementalflag,\%suporderhash);
            if ($error) {             if ($error) {
               $r->print('<p><span class="LC_error">'.$error.'</span></p>');                $r->print('<p><span class="LC_error">'.$error.'</span></p>');
            }             }
            $r->print(&generate_edit_table('2',\%suporderhash));  
         }          }
     } elsif ($supplementalflag) {      } elsif ($supplementalflag) {
         my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);          my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                               $supplementalflag);
         if ($error) {          if ($error) {
             $r->print('<p><span class="LC_error">'.$error.'</span></p>');              $r->print('<p><span class="LC_error">'.$error.'</span></p>');
         }          }
Line 3624  sub generate_admin_options { Line 3680  sub generate_admin_options {
   
   
 sub generate_edit_table {  sub generate_edit_table {
     my ($tid,$orderhash_ref) = @_;      my ($tid,$orderhash_ref,$to_show) = @_;
     return unless(ref($orderhash_ref) eq 'HASH');      return unless(ref($orderhash_ref) eq 'HASH');
     my %orderhash = %{$orderhash_ref};      my %orderhash = %{$orderhash_ref};
     my $form;      my $form;
Line 3633  sub generate_edit_table { Line 3689  sub generate_edit_table {
     if($env{'form.active'} ne ''){      if($env{'form.active'} ne ''){
         $activetab = $env{'form.active'};          $activetab = $env{'form.active'};
     }      }
     $form = '<div class="LC_Box" style="margin-right:0">';      $form = '<div class="LC_Box" style="margin:0;">'.
     $form .= '<ul id="navigation'.$tid.'" class="LC_TabContent">';               '<ul id="navigation'.$tid.'" class="LC_TabContent">';
     foreach my $name (sort(keys(%orderhash))){      foreach my $name (reverse(sort(keys(%orderhash)))) {
         if($name ne '00'){          if($name ne '00'){
             if($activetab eq '' || $activetab ne $name){              if($activetab eq '' || $activetab ne $name){
                $active = '';                 $active = '';
             }elsif($activetab eq $name){              }elsif($activetab eq $name){
                $active = 'class="active"';                 $active = 'class="active"';
             }              }
             $form .= '<li '.$active              $form .= '<li style="float:right" '.$active
                 .' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"'                  .' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"'
                 .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>';                  .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>';
         } else {          } else {
     $form .= '<li '.$active.'>'.${$orderhash{$name}}[1].'</li>';      $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>';
   
  }   }
     }      }
     $form .= '</ul>';      $form .= '</ul>';
     $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; clear: both;">';      $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">';
   
       if ($to_show ne '') {
           $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>';
       }
     foreach my $field (keys(%orderhash)){      foreach my $field (keys(%orderhash)){
  if($field ne '00'){   if($field ne '00'){
             if($activetab eq '' || $activetab ne $field){              if($activetab eq '' || $activetab ne $field){
                 $active = 'style="display: none;"';                  $active = 'style="display: none;float:left"';
             }elsif($activetab eq $field){              }elsif($activetab eq $field){
                 $active = 'style="display:block;"';                  $active = 'style="display:block;float:left"';
             }              }
             $form .= '<div id="'.$field.$tid.'"'              $form .= '<div id="'.$field.$tid.'"'
                     .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]                      .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
Line 3936  function showPage(current, pageId, nav, Line 3996  function showPage(current, pageId, nav,
  current.className = 'active';   current.className = 'active';
  currentData = document.getElementById(pageId);   currentData = document.getElementById(pageId);
  currentData.style.display = 'block';   currentData.style.display = 'block';
           activeTab = pageId;
         if (nav == 'mainnav') {          if (nav == 'mainnav') {
             var storedpath = "$docs_folderpath";              var storedpath = "$docs_folderpath";
             if (storedpath == '') {              if (storedpath == '') {
Line 3970  function showPage(current, pageId, nav, Line 4031  function showPage(current, pageId, nav,
                 }                  }
             }              }
         }          }
           resize_contentdiv('contentscroll','1','0');
  return false;   return false;
 }  }
   
Line 3982  function injectData(current, hiddenField Line 4044  function injectData(current, hiddenField
   
 ENDNEWSCRIPT  ENDNEWSCRIPT
 }  }
   
   sub resize_contentdiv_js {
       my ($tabidstr) = @_;
       my $viewport_js = &Apache::loncommon::viewport_geometry_js();
       return <<ENDRESIZESCRIPT;
   
   window.onresize=resizeContentEditor;
   
   var activeTab;
   
   $viewport_js
   
   function resize_contentdiv(scrollboxname,chkw,chkh) {
       var scrollboxid = 'div_'+scrollboxname;
       var scrolltableid = 'table_'+scrollboxname;
       var scrollbox;
       var scrolltable;
   
       if (document.getElementById("contenteditor") == null) {
           return;
       }
   
       if (document.getElementById(scrollboxid) == null) {
           return;
       } else {
           scrollbox = document.getElementById(scrollboxid);
       }
   
       if (document.getElementById(scrolltableid) == null) {
           return;
       } else {
           scrolltable = document.getElementById(scrolltableid);
       }
   
       init_geometry();
       var vph = Geometry.getViewportHeight();
       var vpw = Geometry.getViewportWidth();
   
       var alltabs = ['$tabidstr'];
       var listwchange;
       if (chkw == 1) {
           var contenteditorw = document.getElementById("contenteditor").offsetWidth;
           var contentlistw;
           var contentlistid = document.getElementById("contentlist");
           if (contentlistid != null) {
               contentlistw = document.getElementById("contentlist").offsetWidth;
           }
           var contentlistwstart = contentlistw;
   
           var scrollboxw = scrollbox.offsetWidth;
           var scrollboxscrollw = scrollbox.scrollWidth;
   
           var offsetw = parseInt(vpw * 0.015);
           var paddingw = parseInt(vpw * 0.09);
   
           var minscrollboxw = 250;
   
           var maxtabw = 0;
           var actabw = 0;
           for (var i=0; i<alltabs.length; i++) {
               if (activeTab == alltabs[i]) {
                   actabw = document.getElementById(alltabs[i]).offsetWidth;
                   if (actabw > maxtabw) {
                       maxtabw = actabw;
                   }
               } else {
                   if (document.getElementById(alltabs[i]) != null) {
                       var thistab = document.getElementById(alltabs[i]);
                       thistab.style.visibility = 'hidden';
                       thistab.style.display = 'block';
                       var tabw = document.getElementById(alltabs[i]).offsetWidth;
                       thistab.style.display = 'none';
                       thistab.style.visibility = '';
                       if (tabw > maxtabw) {
                           maxtabw = tabw;
                       }
                   }
               }
           }
   
           if (maxtabw > 0) {
               var newscrollboxw;
               if (maxtabw+paddingw+scrollboxscrollw<contenteditorw) {
                   newscrollboxw = contenteditorw-paddingw-maxtabw;
                   if (newscrollboxw < minscrollboxw) {
                       newscrollboxw = minscrollboxw;
                   }
                   scrollbox.style.width = newscrollboxw+"px";
                   if (newscrollboxw != scrollboxw) {
                       var newcontentlistw = newscrollboxw-offsetw;
                       contentlistid.style.width = newcontentlistw+"px";
                   }
               } else {
                   newscrollboxw = contenteditorw-paddingw-maxtabw;
                   if (newscrollboxw < minscrollboxw) {
                       newscrollboxw = minscrollboxw;
                   }
                   scrollbox.style.width = newscrollboxw+"px";
                   if (newscrollboxw != scrollboxw) {
                       var newcontentlistw = newscrollboxw-offsetw;
                       contentlistid.style.width = newcontentlistw+"px";
                   }
               }
   
               if (newscrollboxw != scrollboxw) {
                   var newscrolltablew = newscrollboxw+offsetw;
                   scrolltable.style.width = newscrolltablew+"px";
               }
           }
   
           if (contentlistid.offsetWidth != contentlistwstart) {
               listwchange = 1;
           }
   
           if (activeTab == 'cc1') {
               if (document.getElementById('cc_hrule') != null) {
                   document.getElementById('cc_hrule').style.width=actabw+"px";
               }
           } else {
               if (activeTab == 'bb1') {
                   if (document.getElementById('bb_hrule') != null) {
                       document.getElementById('bb_hrule').style.width=actabw+"px";
                   }
               } else {
                   if (activeTab == 'ee2') {
                       if (document.getElementById('ee_hrule') != null) {
                           document.getElementById('ee_hrule').style.width=actabw+"px";
                       }
                   }
               }
           }
       }
       if ((chkh == 1) || (listwchange)) {
           var primaryheight = document.getElementById("LC_nav_bar").offsetHeight;
           var secondaryheight = document.getElementById("LC_secondary_menu").offsetHeight;
           var crumbsheight = document.getElementById("LC_breadcrumbs").offsetHeight;
           var dccidheight = document.getElementById("dccid").offsetHeight;
   
           var uploadresultheight = 0;
           if (document.getElementById("uploadfileresult") != null) {
               uploadresultheight = document.getElementById("uploadfileresult").offsetHeight;
           }
           var tabbedheight = document.getElementById("tabbededitor").offsetHeight;
           var contenteditorheight = document.getElementById("contenteditor").offsetHeight;
           var scrollboxheight = scrollbox.offsetHeight;
           var scrollboxscrollheight = scrollbox.scrollHeight;
           var freevspace = vph-(primaryheight+secondaryheight+crumbsheight+dccidheight+uploadresultheight+tabbedheight+contenteditorheight);
   
           var minvscrollbox = 200;
           var offsetv = 20;
           var newscrollboxheight;
           if (freevspace < 0) {
               newscrollboxheight = scrollboxheight+freevspace-offsetv;
               if (newscrollboxheight < minvscrollbox) {
                   newscrollboxheight = minvscrollbox;
               }
               scrollbox.style.height = newscrollboxheight + "px";
           } else {
               if (scrollboxscrollheight > scrollboxheight) {
                   if (freevspace > offsetv) {
                       newscrollboxheight = scrollboxheight+freevspace-offsetv;
                       if (newscrollboxheight < minvscrollbox) {
                           newscrollboxheight = minvscrollbox;
                       }
                       scrollbox.style.height = newscrollboxheight+"px";
                   }
               }
           }
           scrollboxheight = scrollbox.offsetHeight;
           var contentlistheight = document.getElementById("contentlist").offsetHeight;
   
           if (scrollboxscrollheight <= scrollboxheight) {
               if ((contentlistheight+offsetv)<scrollboxheight) {
                   newscrollheight = contentlistheight+offsetv;
                   scrollbox.style.height = newscrollheight+"px";
               }
           }
       }
       return;
   }
   
   function resizeContentEditor() {
       var timer;
       clearTimeout(timer)
       timer=setTimeout('resize_contentdiv("contentscroll","1","1")',500);
   }
   
   ENDRESIZESCRIPT
       return;
   }
   
 1;  1;
 __END__  __END__
   

Removed from v.1.454  
changed lines
  Added in v.1.466


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