Diff for /loncom/interface/londocs.pm between versions 1.498 and 1.511

version 1.498, 2012/10/02 18:08:12 version 1.511, 2012/11/29 20:37:07
Line 41  use Apache::lonclonecourse; Line 41  use Apache::lonclonecourse;
 use Apache::lonnavmaps;  use Apache::lonnavmaps;
 use Apache::lonnavdisplay();  use Apache::lonnavdisplay();
 use Apache::lonuserstate();  use Apache::lonuserstate();
   use Apache::lonextresedit();
 use HTML::Entities;  use HTML::Entities;
 use HTML::TokeParser;  use HTML::TokeParser;
 use GDBM_File;  use GDBM_File;
Line 312  sub group_import { Line 313  sub group_import {
     return &storemap($coursenum, $coursedom, $folder.'.'.$container,1);      return &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
 }  }
   
 sub breadcrumbs {  
     my ($allowed,$crstype)=@_;  
     &Apache::lonhtmlcommon::clear_breadcrumbs();  
     my (@folders);  
     if ($env{'form.pagepath'}) {  
         @folders = split('&',$env{'form.pagepath'});  
     } else {  
         @folders=split('&',$env{'form.folderpath'});  
     }  
     my $folderpath;  
     my $cpinfo='';  
     my $plain='';  
     my $randompick=-1;  
     my $isencrypted=0;  
     my $ishidden=0;  
     my $is_random_order=0;  
     while (@folders) {  
  my $folder=shift(@folders);  
     my $foldername=shift(@folders);  
  if ($folderpath) {$folderpath.='&';}  
  $folderpath.=$folder.'&'.$foldername;  
         my $url;  
         if ($allowed) {  
             $url = '/adm/coursedocs?folderpath=';  
         } else {  
             $url = '/adm/supplemental?folderpath=';  
         }  
  $url .= &escape($folderpath);  
  my $name=&unescape($foldername);  
 # randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername  
   $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;  
  if ($1 ne '') {  
            $randompick=$1;  
         } else {  
            $randompick=-1;  
         }  
         if ($2) { $ishidden=1; }  
         if ($3) { $isencrypted=1; }  
  if ($4 ne '') { $is_random_order = 1; }  
         if ($folder eq 'supplemental') {  
             $name = &mt('Supplemental '.$crstype.' Content');  
         }  
  &Apache::lonhtmlcommon::add_breadcrumb(  
       {'href'=>$url.$cpinfo,  
        'title'=>$name,  
        'text'=>$name,  
        'no_mt'=>1,  
        });  
  $plain.=$name.' > ';  
     }  
     $plain=~s/\&gt\;\s*$//;  
     return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',  
        undef, undef, 1 ),$randompick,$ishidden,  
                                                $isencrypted,$plain,$is_random_order);  
 }  
   
 sub log_docs {  sub log_docs {
     return &Apache::lonnet::write_log('course','docslog',@_);      return &Apache::lonnet::write_log('course','docslog',@_);
 }  }
Line 455  sub docs_change_log { Line 400  sub docs_change_log {
         if ($folderpath eq '') {          if ($folderpath eq '') {
             $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents'));              $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents'));
         }          }
         $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';          $pathitem = '<input type="hidden" name="folderpath" value="'.
                       &HTML::Entities::encode($folderpath,'<>&"').'" />';
     }      }
     my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";      my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
     my $jumpto = $readfile;      my $jumpto = $readfile;
Line 464  sub docs_change_log { Line 410  sub docs_change_log {
     if ($supplementalflag) {      if ($supplementalflag) {
         $tid = 2;          $tid = 2;
     }      }
     my ($breadcrumbtrail) = &breadcrumbs($allowed,$crstype);      my ($breadcrumbtrail) = 
           &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
     $r->print($breadcrumbtrail.      $r->print($breadcrumbtrail.
               &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,                &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
               $readfile));                $readfile));
Line 1744  sub handle_edit_cmd { Line 1691  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,$iconpath)=@_;          $supplementalflag,$orderhash,$iconpath,$pathitem)=@_;
     my $container= ($env{'form.pagepath'}) ? 'page'      my $container= ($env{'form.pagepath'}) ? 'page'
                            : 'sequence';                             : 'sequence';
       my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order);
     my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =      if ($allowed) {
         &breadcrumbs($allowed,$crstype);          (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
     $r->print($breadcrumbtrail);              &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
           $r->print($breadcrumbtrail);
       }
   
     my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";      my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
   
Line 1829  sub editor { Line 1778  sub editor {
  if (defined($item)) {   if (defined($item)) {
     my ($name,$url,$residx)=      my ($name,$url,$residx)=
  map {&unescape($_)} split(/\=/,$item);   map {&unescape($_)} split(/\=/,$item);
                       if ($url=~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
                           my ($suffix,$errortxt,$locknotfreed) = 
                               &newmap_suffix($1,$2,$coursedom,$coursenum);
                           if ($locknotfreed) {
                               $r->print($locknotfreed);
                           }
                           if ($suffix) {
                               $url =~ s/_new\./_$suffix./; 
                           } else {
                               return $errortxt;
                           }
                       }
     push(@imports, [$name, $url, $residx]);      push(@imports, [$name, $url, $residx]);
  }   }
     }      }
Line 1900  sub editor { Line 1861  sub editor {
         unless ($name) {  $name=(split(/\//,$url))[-1]; }          unless ($name) {  $name=(split(/\//,$url))[-1]; }
         unless ($name) { $idx++; next; }          unless ($name) { $idx++; next; }
         $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,          $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
                               $coursenum,$crstype);                                $coursenum,$coursedom,$crstype,
                                 $pathitem,$supplementalflag);
         $idx++;          $idx++;
         $shown++;          $shown++;
     }      }
     &Apache::loncommon::end_data_table_count();      &Apache::loncommon::end_data_table_count();
       
     if ($shown) {      if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) {
         $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')          if ($shown) {
                   .&Apache::loncommon::start_data_table(undef,'contentlist');              if ($allowed) {
         if ($allowed) {                  $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
             $to_show .= &Apache::loncommon::start_data_table_header_row()                            .&Apache::loncommon::start_data_table(undef,'contentlist')
                      .'<th colspan="2">'.&mt('Move').'</th>'                            .&Apache::loncommon::start_data_table_header_row()
                      .'<th>'.&mt('Actions').'</th>'                            .'<th colspan="2">'.&mt('Move').'</th>'
                      .'<th colspan="2">'.&mt('Document').'</th>';                            .'<th>'.&mt('Actions').'</th>'
             if ($folder !~ /^supplemental/) {                            .'<th colspan="2">'.&mt('Document').'</th>';
                 $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';                  if ($folder !~ /^supplemental/) {
                       $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
                   }
                   $to_show .= &Apache::loncommon::end_data_table_header_row()
                              .$output.' '
                              .&Apache::loncommon::end_data_table()
                              .'<br style="line-height:2px;" />'
                              .&Apache::loncommon::end_scrollbox();
               } else {
                   $to_show = '<table><tr><td>'.&Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT')
                              .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
                              .'<td align="left"><ul id="LC_toolbar">'
                              .'<li><a href="/adm/coursedocs?forcesupplement=1" '
                              .'id="LC_content_toolbar_edittoplevel" '
                              .'class="LC_toolbarItem" '
                              .'title="'.&mt('Supplemental Content Editor').'">'
                              .'</a></li></ul></td></tr></table><br />'
                              .&Apache::loncommon::start_data_table('LC_tableOfContent')
                              .$output.' '
                              .&Apache::loncommon::end_data_table();
             }              }
             $to_show .= &Apache::loncommon::end_data_table_header_row();          } else {
               $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
                          .'<div class="LC_info" id="contentlist">'
                          .&mt('Currently no documents.')
                          .'</div>'
                          .&Apache::loncommon::end_scrollbox();
         }          }
         $to_show .= $output.' '  
                  .&Apache::loncommon::end_data_table()  
                  .'<br style="line-height:2px;" />'  
                  .&Apache::loncommon::end_scrollbox();  
     } else {      } else {
         $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')          if ($shown) {
                  .'<div class="LC_info" id="contentlist">'              $to_show = '<div>'
                  .&mt('Currently no documents.')                        .&Apache::loncommon::start_data_table('LC_tableOfContent')
                  .'</div>'                        .$output
                  .&Apache::loncommon::end_scrollbox();                        .&Apache::loncommon::end_data_table()
                         .'</div>';
           } else {
               $to_show = '<div class="LC_info" id="contentlist">'
                         .&mt('Currently no documents.')
                         .'</div>'
           }
     }      }
     my $tid = 1;      my $tid = 1;
     if ($supplementalflag) {      if ($supplementalflag) {
Line 1940  sub editor { Line 1928  sub editor {
                                        $readfile));                                         $readfile));
         &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);          &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
     } else {      } else {
         if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {  
             #Function Box for Supplemental Content for users with mdc priv.  
             my $funcname = &mt('Folder Editor');  
             $r->print(  
                 &Apache::loncommon::head_subbox(  
                     &Apache::lonhtmlcommon::start_funclist().  
                     &Apache::lonhtmlcommon::add_item_funclist(  
                         '<a href="/adm/coursedocs?command=direct&forcesupplement=1&'.  
                         'supppath='.&HTML::Entities::encode($env{'form.folderpath'}).'">'.  
                         '<img src="/res/adm/pages/docs.png" alt="'.$funcname.'" class="LC_icon" />'.  
                         '<span class="LC_menubuttons_inline_text">'.$funcname.'</span></a>').  
                           &Apache::lonhtmlcommon::end_funclist()));  
         }  
         $r->print($to_show);          $r->print($to_show);
     }      }
     return;      return;
Line 2117  sub is_supplemental_title { Line 2092  sub is_supplemental_title {
 # --------------------------------------------------------------- An entry line  # --------------------------------------------------------------- An entry line
   
 sub entryline {  sub entryline {
     my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;      my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
           $crstype,$pathitem,$supplementalflag)=@_;
     my ($foldertitle,$pagetitle,$renametitle);      my ($foldertitle,$pagetitle,$renametitle);
     if (&is_supplemental_title($title)) {      if (&is_supplemental_title($title)) {
  ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);   ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
Line 2131  sub entryline { Line 2107  sub entryline {
   
     my $orderidx=$LONCAPA::map::order[$index];      my $orderidx=$LONCAPA::map::order[$index];
   
   
     $renametitle=~s/\\/\\\\/g;      $renametitle=~s/\\/\\\\/g;
     $renametitle=~s/\&quot\;/\\\"/g;      $renametitle=~s/\&quot\;/\\\"/g;
     $renametitle=~s/ /%20/g;      $renametitle=~s/ /%20/g;
Line 2150  sub entryline { Line 2125  sub entryline {
         $type = $container = 'page';          $type = $container = 'page';
         $esc_path=&escape($env{'form.pagepath'});          $esc_path=&escape($env{'form.pagepath'});
  $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');   $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
         $symb=&escape($env{'form.pagesymb'});  
     }      }
     my $cpinfo='';      my $isexternal;
       if ($residx) {
           my $currurl = $url;
           $currurl =~ s{^http(|s)(&colon;|:)//}{/adm/wrapper/ext/};
           if ($currurl =~ m{^/adm/wrapper/ext/}) {
               $isexternal = 1;
           }
           if (!$supplementalflag) {
               my $path = 'uploaded/'.
                          $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
                          $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
               $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
                                                    $residx,
                                                    &Apache::lonnet::declutter($currurl));
           }
       }
       my %lt;
     if ($allowed) {      if ($allowed) {
  my $incindex=$index+1;   my $incindex=$index+1;
  my $selectbox='';   my $selectbox='';
Line 2175  sub entryline { Line 2165  sub entryline {
     }      }
     $selectbox.='</select>';      $selectbox.='</select>';
  }   }
  my %lt=&Apache::lonlocal::texthash(   %lt=&Apache::lonlocal::texthash(
                 'up' => 'Move Up',                  'up' => 'Move Up',
  'dw' => 'Move Down',   'dw' => 'Move Down',
  'rm' => 'Remove',   'rm' => 'Remove',
                 'ct' => 'Cut',                  'ct' => 'Cut',
  'rn' => 'Rename',   'rn' => 'Rename',
  'cp' => 'Copy');   'cp' => 'Copy',
                   'ex' => 'External Resource',
                   'ed' => 'Edit',
                   'pr' => 'Preview',
                   'sv' => 'Save',
                   'ul' => 'URL',
                   'ti' => 'Title', 
                   );
  my $nocopy=0;   my $nocopy=0;
         my $nocut=0;          my $nocut=0;
         my $noremove=0;          my $noremove=0;
Line 2242  sub entryline { Line 2239  sub entryline {
                 $nocopy=1;                  $nocopy=1;
             }              }
         }          }
         my $copylink='&nbsp;';          my ($copylink,$cutlink,$removelink,$renamelink);
         my $cutlink='&nbsp;';  
         my $removelink='&nbsp;';  
   
  my $skip_confirm = 0;   my $skip_confirm = 0;
  if ( $folder =~ /^supplemental/   if ( $folder =~ /^supplemental/
      || ($url =~ m{( /smppg$       || ($url =~ m{( /smppg$
Line 2253  sub entryline { Line 2247  sub entryline {
     |/aboutme$      |/aboutme$
     |/navmaps$      |/navmaps$
     |/bulletinboard$      |/bulletinboard$
     |\.html$      |\.html$)}x)
     |^/adm/wrapper/ext)}x)) {               || $isexternal) {
     $skip_confirm = 1;      $skip_confirm = 1;
  }   }
   
  if (!$nocopy) {   if ($nocopy) {
               $copylink=(<<ENDCOPY);
   <span style="visibility: hidden;">$lt{'cp'}</span>
   ENDCOPY
           } else {
     $copylink=(<<ENDCOPY);      $copylink=(<<ENDCOPY);
 <a href="javascript:markcopy('$esc_path','$index','$renametitle','$container','$symb','$folder');" class="LC_docs_copy">$lt{'cp'}</a>  <a href="javascript:markcopy('$esc_path','$index','$renametitle','$container','$symb','$folder');" class="LC_docs_copy">$lt{'cp'}</a>
 ENDCOPY  ENDCOPY
         }          }
  if (!$nocut) {   if ($nocut) {
               $cutlink=(<<ENDCUT);
   <span style="visibility: hidden;">$lt{'ct'}</span>
   ENDCUT
           } else {
     $cutlink=(<<ENDCUT);      $cutlink=(<<ENDCUT);
 <a href="javascript:cutres('$esc_path','$index','$renametitle','$container','$symb','$folder',$skip_confirm);" class="LC_docs_cut">$lt{'ct'}</a>  <a href="javascript:cutres('$esc_path','$index','$renametitle','$container','$symb','$folder',$skip_confirm);" class="LC_docs_cut">$lt{'ct'}</a>
 ENDCUT  ENDCUT
         }          }
         if (!$noremove) {          if ($noremove) {
               $removelink=(<<ENDREM);
   <span style="visibility: hidden;">$lt{'rm'}</a>
   ENDREM
           } else {
             $removelink=(<<ENDREM);              $removelink=(<<ENDREM);
 <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>  <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
 ENDREM  ENDREM
         }          }
           $renamelink=(<<ENDREN);
   <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
   ENDREN
  $form_start = '   $form_start = '
    <form action="/adm/coursedocs" method="post">     <form action="/adm/coursedocs" method="post">
 ';  ';
Line 2286  END Line 2295  END
  $line.=(<<END);   $line.=(<<END);
 <td>  <td>
 <div class="LC_docs_entry_move">  <div class="LC_docs_entry_move">
   <a href='/adm/coursedocs?cmd=up_$index&amp;${type}path=$esc_path&amp;${type}symb=$symb$cpinfo'>    <a href='/adm/coursedocs?cmd=up_$index&amp;${type}path=$esc_path&amp;${type}symb=$symb'>
     <img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" />      <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
   </a>    </a>
 </div>  </div>
 <div class="LC_docs_entry_move">  <div class="LC_docs_entry_move">
   <a href='/adm/coursedocs?cmd=down_$index&amp;${type}path=$esc_path&amp;${type}symb=$symb$cpinfo'>    <a href='/adm/coursedocs?cmd=down_$index&amp;${type}path=$esc_path&amp;${type}symb=$symb'>
     <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" />      <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
   </a>    </a>
 </div>  </div>
 </td>  </td>
Line 2302  END Line 2311  END
    $selectbox     $selectbox
    $form_end     $form_end
 </td>  </td>
 <td class="LC_docs_entry_commands">  <td class="LC_docs_entry_commands"><span class="LC_nobreak">
 $removelink  $removelink
   $renamelink
 $cutlink  $cutlink
    <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>  
 $copylink  $copylink
   </span>
 </td>  </td>
 END  END
   
Line 2343  END Line 2353  END
  }   }
     }      }
   
       my $editlink;
     my $orig_url = $url;      my $orig_url = $url;
     $orig_url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};      $orig_url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};
     my $external = ($url=~s{^http(|s)(&colon;|:)//}{/adm/wrapper/ext/});      $url=~s{^http(|s)(&colon;|:)//}{/adm/wrapper/ext/};
     if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {      if (!$supplementalflag && $residx && $symb) {
  my $symb=&Apache::lonnet::symbclean(          if ($container eq 'page') {
           &Apache::lonnet::declutter('uploaded/'.              $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
            $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.              $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
            $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.          } 
            '.sequence').          if ((!$isfolder) && (!$ispage)) {
            '___'.$residx.'___'.      (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
    &Apache::lonnet::declutter($url));      $url=&Apache::lonnet::clutter($url);
  (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);      if ($url=~/^\/*uploaded\//) {
  $url=&Apache::lonnet::clutter($url);          $url=~/\.(\w+)$/;
  if ($url=~/^\/*uploaded\//) {          my $embstyle=&Apache::loncommon::fileembstyle($1);
     $url=~/\.(\w+)$/;          if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
     my $embstyle=&Apache::loncommon::fileembstyle($1);      $url='/adm/wrapper'.$url;
     if (($embstyle eq 'img') || ($embstyle eq 'emb')) {          } elsif ($embstyle eq 'ssi') {
  $url='/adm/wrapper'.$url;      #do nothing with these
     } elsif ($embstyle eq 'ssi') {          } elsif ($url!~/\.(sequence|page)$/) {
  #do nothing with these      $url='/adm/coursedocs/showdoc'.$url;
     } elsif ($url!~/\.(sequence|page)$/) {          }
  $url='/adm/coursedocs/showdoc'.$url;      } elsif ($url=~m|^/ext/|) {
           $url='/adm/wrapper'.$url;
     }      }
  } elsif ($url=~m|^/ext/|) {              if (&Apache::lonnet::symbverify($symb,$url)) {
     $url='/adm/wrapper'.$url;          $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
     $external = 1;              } else {
  }                  $url='';
         if (&Apache::lonnet::symbverify($symb,$url)) {              }
     $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);  
         } else {  
             $url='';  
         }  
  if ($container eq 'page') {  
     my $symb=$env{'form.pagesymb'};  
   
     $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);  
     $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);  
  }   }
     }      }
     my ($rand_pick_text,$rand_order_text);      my ($rand_pick_text,$rand_order_text);
Line 2387  END Line 2390  END
  my $foldername=&escape($foldertitle);   my $foldername=&escape($foldertitle);
  my $folderpath=$env{'form.folderpath'};   my $folderpath=$env{'form.folderpath'};
  if ($folderpath) { $folderpath.='&' };   if ($folderpath) { $folderpath.='&' };
           if (!$allowed && $supplementalflag) {
               $folderpath.=$folderarg.'&'.$foldername;
               $url.='folderpath='.&escape($folderpath);
           } else {
 # Append randompick number, hidden, and encrypted with ":" to foldername,  # Append randompick number, hidden, and encrypted with ":" to foldername,
 # so it gets transferred between levels  # so it gets transferred between levels
  $folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,      $folderpath.=$folderarg.'&'.$foldername.
                                                 ':'.(&LONCAPA::map::getparameter($orderidx,
                                               'parameter_randompick'))[0]                                                'parameter_randompick'))[0]
                                                .':'.((&LONCAPA::map::getparameter($orderidx,                                                 .':'.((&LONCAPA::map::getparameter($orderidx,
                                               'parameter_hiddenresource'))[0]=~/^yes$/i)                                                'parameter_hiddenresource'))[0]=~/^yes$/i)
Line 2397  END Line 2405  END
                                               'parameter_encrypturl'))[0]=~/^yes$/i)                                                'parameter_encrypturl'))[0]=~/^yes$/i)
                                                .':'.((&LONCAPA::map::getparameter($orderidx,                                                 .':'.((&LONCAPA::map::getparameter($orderidx,
                                               'parameter_randomorder'))[0]=~/^yes$/i);                                                'parameter_randomorder'))[0]=~/^yes$/i);
  $url.='folderpath='.&escape($folderpath).$cpinfo;      $url.='folderpath='.&escape($folderpath);
         my $rpicknum = (&LONCAPA::map::getparameter($orderidx,              my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
                                                    'parameter_randompick'))[0];                                                          'parameter_randompick'))[0];
         my $rpckchk;              my $rpckchk;
         if ($rpicknum) {              if ($rpicknum) {
             $rpckchk = ' checked="checked"';                  $rpckchk = ' checked="checked"';
         }              }
         my $formname = 'edit_rpick_'.$orderidx;              my $formname = 'edit_rpick_'.$orderidx;
  $rand_pick_text =       $rand_pick_text = 
 '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".  '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
 $form_common."\n".  $form_common."\n".
 '<span class="LC_nobreak"><label><input type="checkbox" name="randpickon_'.$orderidx.'" id="rpick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="randompick_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" />';  '<span class="LC_nobreak"><label><input type="checkbox" name="randpickon_'.$orderidx.'" id="rpick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="randompick_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" />';
         if ($rpicknum ne '') {              if ($rpicknum ne '') {
             $rand_pick_text .= ':&nbsp;<a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';                  $rand_pick_text .= ':&nbsp;<a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
         }              }
         $rand_pick_text .= '</span></form>';              $rand_pick_text .= '</span></form>';
     my $ro_set=         my $ro_set=
     ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');          ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
  $rand_order_text =       $rand_order_text = 
 $form_start.  $form_start.
 $form_common.'  $form_common.'
 <span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="'."this.form.changeparms.value='randomorder';this.form.submit()".'" '.$ro_set.' /> '.&mt('Random Order').' </label></span></form>';  <span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="'."this.form.changeparms.value='randomorder';this.form.submit()".'" '.$ro_set.' /> '.&mt('Random Order').' </label></span></form>';
           }
       } elsif ($supplementalflag && !$allowed) {
           $url .= ($url =~ /\?/) ? '&amp;':'?';
           $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
           if ($title) {
               $url .= '&amp;title='.&HTML::Entities::encode($renametitle,'<>&"');
           }
           if ($isexternal && $orderidx) {
               $url .= '&amp;idx='.$orderidx;
           }
     }      }
     if ($ispage) {      if ($ispage) {
         my $pagename=&escape($pagetitle);          my $pagename=&escape($pagetitle);
Line 2426  $form_common.' Line 2444  $form_common.'
         my $folderpath=$env{'form.folderpath'};          my $folderpath=$env{'form.folderpath'};
         if ($folderpath) { $pagepath = $folderpath.'&' };          if ($folderpath) { $pagepath = $folderpath.'&' };
         $pagepath.=$pagearg.'&'.$pagename;          $pagepath.=$pagearg.'&'.$pagename;
  my $symb=$env{'form.pagesymb'};  
  if (!$symb) {  
     my $path='uploaded/'.  
  $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.  
  $env{'course.'.$env{'request.course.id'}.'.num'}.'/';  
     $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',  
        $residx,  
        $path.$pagearg.'.page');  
  }  
  $url.='pagepath='.&escape($pagepath).   $url.='pagepath='.&escape($pagepath).
     '&amp;pagesymb='.&escape($symb).$cpinfo;      '&amp;pagesymb='.&escape($symb);
     }      }
     if (($external) && ($allowed)) {      if ($allowed) {
  my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';          my $fileloc = 
  $external = '&nbsp;<a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';              &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
     } else {          if ($isexternal) {
  undef($external);              $editlink = '&nbsp;'.
                   &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
           } elsif (!$isfolder && !$ispage) {
               my ($cfile,$home,$switchserver,$forceedit,$forceview) = 
                   &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
               if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
                   my $jscall = 
                       &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
                                                               $switchserver,
                                                               $forceedit,
                                                               undef,$symb,
                                                               &escape($env{'form.folderpath'}),
                                                               $renametitle);
                   if ($jscall) {
                       $editlink = '&nbsp;<a class="LC_docs_ext_edit" href="javascript:'.
                                   $jscall.'" >'.&mt('Edit').'</a>';
                   }
               }
           }
     }      }
     my $reinit;      my $reinit;
     if ($crstype eq 'Community') {      if ($crstype eq 'Community') {
Line 2468  $form_common.' Line 2495  $form_common.'
     } else {      } else {
        $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';         $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
     }      }
     $line.=$external."</td>";      $line.=$editlink."</td>";
     $rand_pick_text = '&nbsp;' if ($rand_pick_text eq '');      $rand_pick_text = '&nbsp;' if ($rand_pick_text eq '');
     $rand_order_text = '&nbsp;' if ($rand_order_text eq '');      $rand_order_text = '&nbsp;' if ($rand_order_text eq '');
     if (($allowed) && ($folder!~/^supplemental/)) {      if (($allowed) && ($folder!~/^supplemental/)) {
Line 2499  ENDPARMS Line 2526  ENDPARMS
     return $line;      return $line;
 }  }
   
   sub newmap_suffix {
       my ($area,$container,$coursedom,$coursenum) = @_;
       my ($prefix,$idtype,$errtext,$locknotfreed);
       $prefix = 'docs';
       if ($area eq 'supplemental') {
           $prefix = 'supp';
       }
       $prefix .= $container;
       $idtype = 'concat';
       my ($suffix,$freedlock,$error) =
           &Apache::lonnet::get_timebased_id($prefix,'num','uploadedmaps',
                                             $coursedom,$coursenum);
       if (!$suffix) {
           $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
           if ($error) {
               $errtext .= '<br />'.$error;
           }
       }
       if ($freedlock ne 'ok') {
           $locknotfreed = '<div class="LC_error">'.&mt('There was a problem removing a lockfile. This will prevent creation of additional folders or composite pages in this course.  Please contact the domain coordinator for your LON-CAPA domain.').'</div>';
       }
       return ($suffix,$errtext,$locknotfreed);
   }
   
 =pod  =pod
   
 =item tiehash()  =item tiehash()
Line 3031  sub init_breadcrumbs { Line 3082  sub init_breadcrumbs {
 sub create_list_elements {  sub create_list_elements {
    my @formarr = @_;     my @formarr = @_;
    my $list = '';     my $list = '';
    for my $button (@formarr){     foreach my $button (@formarr){
         for my $picture(keys %$button) {          foreach my $picture (keys(%{$button})) {
             $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});              $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
         }          }
    }     }
    return $list;     return $list;
Line 3103  sub handler { Line 3154  sub handler {
                'Adding_External_Resource','Navigate_Content',                 'Adding_External_Resource','Navigate_Content',
                'Adding_Folders','Docs_Overview', 'Load_Map',                 'Adding_Folders','Docs_Overview', 'Load_Map',
                'Supplemental','Score_Upload_Form','Adding_Pages',                 'Supplemental','Score_Upload_Form','Adding_Pages',
                'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',                 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
                          'Uploading_From_Harddrive',
                'Check_Resource_Versions','Verify_Content') {                 'Check_Resource_Versions','Verify_Content') {
  $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);   $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
     }      }
Line 3165  sub handler { Line 3217  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',
                                              'tools','symb','command']);                                               'tools','symb','command','supppath']);
   
 # 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 3194  sub handler { Line 3246  sub handler {
     my $addentries = {};      my $addentries = {};
     my $container;      my $container;
     my $containertag;      my $containertag;
     my $uploadtag;      my $pathitem;
   
 # Do we directly jump somewhere?  # Do we directly jump somewhere?
   
Line 3235  sub handler { Line 3287  sub handler {
                        }                         }
                    }                     }
                }                 }
                $path .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.                 $path =~ s/^\&//;
                     &Apache::lonhtmlcommon::entity_encode($mapresobj->title()).                 my $maptitle = $mapresobj->title();
                  if ($mapurl eq 'default') {
                      $maptitle = 'Main Course Documents';
                  }
                  $path .= ($path ne '')? '&' : ''.
                       &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
                       &Apache::lonhtmlcommon::entity_encode($maptitle).
                     ':'.$mapresobj->randompick().                      ':'.$mapresobj->randompick().
                     ':'.$mapresobj->randomout().                      ':'.$mapresobj->randomout().
                     ':'.$mapresobj->encrypted().                      ':'.$mapresobj->encrypted().
                     ':'.$mapresobj->randomorder();                      ':'.$mapresobj->randomorder();
            } else {             } else {
                my $maptitle = &Apache::lonnet::gettitle($mapurl);                 my $maptitle = &Apache::lonnet::gettitle($mapurl);
                $path = '&default&...::::'.                 if ($mapurl eq 'default') {
                    '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.                     $maptitle = 'Main Course Documents';
                    &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';                 }
                  $path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
                          &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
              }
              unless ($mapurl eq 'default') {
                  $path = 'default&'.
                          &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
                          '::::&'.$path;
            }             }
            $path = 'default&'.  
                    &Apache::lonhtmlcommon::entity_encode('Main Course Documents').  
                    $path;  
            if ($type eq 'sequence') {             if ($type eq 'sequence') {
                $env{'form.folderpath'}=$path;                 $env{'form.folderpath'}=$path;
                $env{'form.pagepath'}='';                 $env{'form.pagepath'}='';
Line 3276  sub handler { Line 3338  sub handler {
        $stored_folderpath='docs_sup_folderpath';         $stored_folderpath='docs_sup_folderpath';
     }      }
   
 # No folderpath, no pagepath, see if we have something stored  # No folderpath, no pagepath, and in edit mode, see if we have something stored
     if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {      if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'}) && $allowed) {
         &Apache::loncommon::restore_course_settings($stored_folderpath,          &Apache::loncommon::restore_course_settings($stored_folderpath,
                                               {'folderpath' => 'scalar'});                                            {'folderpath' => 'scalar'});
     }      }
         
 # If we are not allowed to make changes, all we can see are supplemental docs  # If we are not allowed to make changes, all we can see are supplemental docs
Line 3311  sub handler { Line 3373  sub handler {
   
 # Store this  # Store this
     unless ($toolsflag) {      unless ($toolsflag) {
         &Apache::loncommon::store_course_settings($stored_folderpath,          if ($allowed) {
                                                   {'pagepath' => 'scalar',              &Apache::loncommon::store_course_settings($stored_folderpath,
                                                    'folderpath' => 'scalar'});                                                        {'pagepath' => 'scalar',
                                                          'folderpath' => 'scalar'});
           }
         if ($env{'form.folderpath'}) {          if ($env{'form.folderpath'}) {
     my (@folderpath)=split('&',$env{'form.folderpath'});      my (@folderpath)=split('&',$env{'form.folderpath'});
     $env{'form.foldername'}=&unescape(pop(@folderpath));      $env{'form.foldername'}=&unescape(pop(@folderpath));
Line 3327  sub handler { Line 3391  sub handler {
             $container='page';              $container='page';
             $containertag = '<input type="hidden" name="pagepath" value="" />'.              $containertag = '<input type="hidden" name="pagepath" value="" />'.
                     '<input type="hidden" name="pagesymb" value="" />';                      '<input type="hidden" name="pagesymb" value="" />';
             $uploadtag =               $pathitem = 
                 '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.                  '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
         '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'.          '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'.
                 '<input type="hidden" name="folderpath" value="" />';                  '<input type="hidden" name="folderpath" value="" />';
Line 3341  sub handler { Line 3405  sub handler {
                 }                  }
             }              }
             $containertag = '<input type="hidden" name="folderpath" value="" />';              $containertag = '<input type="hidden" name="folderpath" value="" />';
             $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';              $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
         }          }
         if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {          if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
            $showdoc='/'.$1;             $showdoc='/'.$1;
Line 3389  sub handler { Line 3453  sub handler {
     $script .= &editing_js($udom,$uname,$supplementalflag).      $script .= &editing_js($udom,$uname,$supplementalflag).
                        &history_tab_js().                         &history_tab_js().
                        &inject_data_js().                         &inject_data_js().
                        &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr);                         &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr).
                          &Apache::lonextresedit::extedit_javascript();
             $addentries = {              $addentries = {
                             onload   => "javascript:resize_scrollbox('contentscroll','1','1');",                              onload   => "javascript:resize_scrollbox('contentscroll','1','1');",
                           };                            };
Line 3397  sub handler { Line 3462  sub handler {
         if ($env{'docs.markedcopy_url'}) {          if ($env{'docs.markedcopy_url'}) {
             $script .= &paste_popup_js();               $script .= &paste_popup_js(); 
         }          }
           my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
                                &mt('Switch server?');
           
   
     }      }
 # -------------------------------------------------------------------- Body tag  # -------------------------------------------------------------------- Body tag
     $script = '<script type="text/javascript">'."\n"      $script = '<script type="text/javascript">'."\n"
Line 3407  sub handler { Line 3476  sub handler {
   
     # Breadcrumbs      # Breadcrumbs
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     unless ($showdoc) {  
       if ($showdoc) {
           $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
                                                   {'force_register' => $showdoc,}));
       } elsif ($r->uri eq '/adm/supplemental') {
           my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
           $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
                                                   {'bread_crumbs' => $brcrum,}));
       } else {
         &Apache::lonhtmlcommon::add_breadcrumb({          &Apache::lonhtmlcommon::add_breadcrumb({
             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,                                                   {'add_entries'    => $addentries}
                                                   'add_entries'    => $addentries,                                                  )
                                                  })  
                  .&Apache::loncommon::help_open_menu('','',273,'RAT')                   .&Apache::loncommon::help_open_menu('','',273,'RAT')
                  .&Apache::lonhtmlcommon::breadcrumbs(                   .&Apache::lonhtmlcommon::breadcrumbs(
                      'Editing '.$crstype.' Contents',                       'Editing '.$crstype.' Contents',
                      'Docs_Adding_Course_Doc')                       'Docs_Adding_Course_Doc')
         );          );
     } else {  
         $r->print(&Apache::loncommon::start_page("$crstype documents",undef,  
                                                 {'force_register' => $showdoc,}));  
     }      }
   
   my %allfiles = ();    my %allfiles = ();
Line 3489  sub handler { Line 3562  sub handler {
                 'upls' => 'Upload a new supplemental '.lc($crstype).' document',                  'upls' => 'Upload a new supplemental '.lc($crstype).' document',
                 'impp' => 'Import a document',                  'impp' => 'Import a document',
  'copm' => 'All documents out of a published map into this folder',   'copm' => 'All documents out of a published map into this folder',
                 'upld' => 'Import Document',                  'upfi' => 'Upload File',
                   'upld' => 'Import Content',
                 'srch' => 'Search',                  'srch' => 'Search',
                 'impo' => 'Import',                  'impo' => 'Import',
  'lnks' => 'Import from Stored Links',   'lnks' => 'Import from Stored Links',
                   'impm' => 'Import from Assembled Map',
                 'selm' => 'Select Map',                  'selm' => 'Select Map',
                 'load' => 'Load Map',                  'load' => 'Load Map',
                 'reco' => 'Recover Deleted Documents',                  'reco' => 'Recover Deleted Documents',
Line 3512  sub handler { Line 3587  sub handler {
  'abou' => 'Personal Information Page for a User',   'abou' => 'Personal Information Page for a User',
                 'imsf' => 'IMS Import',                  'imsf' => 'IMS Import',
                 'imsl' => 'Import IMS package',                  'imsl' => 'Import IMS package',
                   'cms'  => 'Origin of IMS package',
                   'se'   => 'Select',
                 'file' =>  'File',                  'file' =>  'File',
                 'title' => 'Title',                  'title' => 'Title',
                 'comment' => 'Comment',                  'comment' => 'Comment',
                   'url'  => 'URL',
                   'prev' => 'Preview',
                   'lnk'  => 'Add Link', 
                 'parse' => 'Upload embedded images/multimedia files if HTML file',                  'parse' => 'Upload embedded images/multimedia files if HTML file',
  'nd' => 'Upload Document',   'nd' => 'Upload Document',
  'pm' => 'Published Map',   'pm' => 'Published Map',
Line 3535  FIUP Line 3615  FIUP
  <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}   <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
  </label>   </label>
 CHBO  CHBO
           my $imsfolder = $env{'form.folder'};
           if ($imsfolder eq '') {
               $imsfolder = 'default';  
           }
           my $imspform=(<<IMSFORM);
           <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
           $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
           <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
           <fieldset id="uploadimsform" style="display: none;" />
           <legend>$lt{'imsf'}</legend>
           $fileupload
           <br />
           <p>
           $lt{'cms'}:&nbsp; 
           <select name="source">
           <option value="-1" selected="selected">$lt{'se'}</option>
           <option value="bb5">Blackboard 5</option>
           <option value="bb6">Blackboard 6</option>
           <option value="angel5">ANGEL 5.5</option>
           <option value="webctce4">WebCT 4 Campus Edition</option>
           </select>
           <input type="hidden" name="folder" value="$imsfolder" />
           </p>
           <input type="hidden" name="phase" value="one" />
           <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
           </fieldset>
           </form>
   IMSFORM
   
     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">          <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
           $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
           <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
           <fieldset id="uploaddocform" style="display: none;" />
           <legend>$lt{'upfi'}</legend>
  <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="60" name="comment" />   <input type="text" size="60" name="comment" />
  $uploadtag   $pathitem
  <input type="hidden" name="cmd" value="upload_default" />   <input type="hidden" name="cmd" value="upload_default" />
  <br />   <br />
  <span class="LC_nobreak" style="float:left">   <span class="LC_nobreak" style="float:left">
  $checkbox   $checkbox
  </span>   </span>
           <br clear="all" />
           <input type="submit" value="$lt{'upld'}" />
           </fieldset>
           </form>
 FUFORM  FUFORM
     $fileuploadform .= $fileuploada.'</form>';  
   
  my $simpleeditdefaultform=(<<SEDFFORM);   my $importpubform=(<<SEDFFORM);
  <form action="/adm/coursedocs" method="post" name="simpleeditdefault">          <a class="LC_menubuttons_link" href="javascript:toggleMap();">
           $lt{'impm'}</a>$help{'Load_Map'}
    <form action="/adm/coursedocs" method="post" name="mapimportform">
           <fieldset id="importmapform" style="display: none;" />
           <legend>$lt{'impm'}</legend>
  <input type="hidden" name="active" value="bb" />   <input type="hidden" name="active" value="bb" />
           $lt{'copm'}<br />
           <span class="LC_nobreak">
           <input type="text" name="importmap" size="40" value="" 
           onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" />
           &nbsp;<a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a><br />
           <input type="submit" name="loadmap" value="$lt{'load'}" />
           </fieldset>
           </form>
   
 SEDFFORM  SEDFFORM
  my @simpleeditdefaultforma = (    my @importpubforma = (
  { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'"  onclick="javascript:groupsearch()" />' => "$uploadtag<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" },   { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'"  onclick="javascript:groupsearch()" />' => $pathitem."<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" },
  { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'"  onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" },   { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'"  onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" },
  { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" },   { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" },
           { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap();" />' => $importpubform }
  );   );
  $simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma));   $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
  $simpleeditdefaultform .=(<<SEDFFORM);          my $extresourcesform =
  <hr id="bb_hrule" style="width:0px;text-align:left;margin-left:0" />              &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
  $lt{'copm'}<br />                                                   $help{'Adding_External_Resource'});
  <input type="text" size="40" name="importmap" /><br />  
  <span class="LC_nobreak" style="float:left"><input type="button"  
  onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"  
  value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />  
  $help{'Load_Map'}</span>  
  </form>  
 SEDFFORM  
   
       my $extresourcesform=(<<ERFORM);  
       <form action="/adm/coursedocs" method="post" name="newext">  
       $uploadtag  
       <input type="hidden" name="importdetail" value="" />  
       <a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'}  
       </form>  
 ERFORM  
   
   
     if ($allowed) {      if ($allowed) {
         my $folder = $env{'form.folder'};          my $folder = $env{'form.folder'};
         if ($folder eq '') {          if ($folder eq '') {
Line 3599  ERFORM Line 3710  ERFORM
  </form>   </form>
   
 HIDDENFORM  HIDDENFORM
         $r->print(&makesimpleeditform($uploadtag)."\n".          $r->print(&makesimpleeditform($pathitem)."\n".
                   &makedocslogform($uploadtag."\n".                    &makedocslogform($pathitem."\n".
                                    '<input type="hidden" name="folder" value="'.                                     '<input type="hidden" name="folder" value="'.
                                    $env{'form.folder'}.'" />'."\n"));                                     $env{'form.folder'}.'" />'."\n"));
     }      }
   
 # Generate the tabs  # Generate the tabs
     my $mode;      my ($mode,$needs_end);
     if (($supplementalflag) && (!$allowed)) {      if (($supplementalflag) && (!$allowed)) {
         &Apache::lonnavdisplay::startContentScreen($r,'supplemental');          my @folders = split('&',$env{'form.folderpath'});
           unless (@folders > 2) {
               &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
               $needs_end = 1;
           }
     } else {      } else {
         $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));          $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
           $needs_end = 1;
     }      }
   
 #  #
Line 3623  HIDDENFORM Line 3739  HIDDENFORM
            $folder='default';             $folder='default';
    $savefolderpath = $env{'form.folderpath'};     $savefolderpath = $env{'form.folderpath'};
    $env{'form.folderpath'}='default&'.&escape(&mt('Content'));     $env{'form.folderpath'}='default&'.&escape(&mt('Content'));
            $uploadtag = '<input type="hidden" name="folderpath" value="'.             $pathitem = '<input type="hidden" name="folderpath" value="'.
        &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';         &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
        }         }
        my $postexec='';         my $postexec='';
Line 3637  HIDDENFORM Line 3753  HIDDENFORM
        } else {         } else {
            #$postexec='self.close();';             #$postexec='self.close();';
        }         }
        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.         my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
                      '.sequence';         my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
        my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.  
                      '.page';  
  my $container='sequence';   my $container='sequence';
  if ($env{'form.pagepath'}) {   if ($env{'form.pagepath'}) {
     $container='page';      $container='page';
  }   }
  my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;   my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
   
  my $imspform=(<<IMSPFORM);  
  <form action="/adm/imsimportdocs" method="post" name="ims">  
  <input type="hidden" name="folder" value="$folder" />  
  <a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a>  
  </form>  
 IMSPFORM  
   
  my $newnavform=(<<NNFORM);   my $newnavform=(<<NNFORM);
  <form action="/adm/coursedocs" method="post" name="newnav">   <form action="/adm/coursedocs" method="post" name="newnav">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail"    <input type="hidden" name="importdetail" 
  value="$lt{'navc'}=/adm/navmaps" />   value="$lt{'navc'}=/adm/navmaps" />
  <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>   <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
Line 3667  NNFORM Line 3774  NNFORM
  my $newsmppageform=(<<NSPFORM);   my $newsmppageform=(<<NSPFORM);
  <form action="/adm/coursedocs" method="post" name="newsmppg">   <form action="/adm/coursedocs" method="post" name="newsmppg">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>   <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
  $help{'Simple Page'}   $help{'Simple Page'}
Line 3677  NSPFORM Line 3784  NSPFORM
  my $newsmpproblemform=(<<NSPROBFORM);   my $newsmpproblemform=(<<NSPROBFORM);
  <form action="/adm/coursedocs" method="post" name="newsmpproblem">   <form action="/adm/coursedocs" method="post" name="newsmpproblem">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>   <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
  $help{'Simple Problem'}   $help{'Simple Problem'}
Line 3688  NSPROBFORM Line 3795  NSPROBFORM
  my $newdropboxform=(<<NDBFORM);   my $newdropboxform=(<<NDBFORM);
  <form action="/adm/coursedocs" method="post" name="newdropbox">   <form action="/adm/coursedocs" method="post" name="newdropbox">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>   <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
  </form>   </form>
Line 3697  NDBFORM Line 3804  NDBFORM
  my $newexuploadform=(<<NEXUFORM);   my $newexuploadform=(<<NEXUFORM);
  <form action="/adm/coursedocs" method="post" name="newexamupload">   <form action="/adm/coursedocs" method="post" name="newexamupload">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>   <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
  $help{'Score_Upload_Form'}   $help{'Score_Upload_Form'}
Line 3707  NEXUFORM Line 3814  NEXUFORM
  my $newbulform=(<<NBFORM);   my $newbulform=(<<NBFORM);
  <form action="/adm/coursedocs" method="post" name="newbul">   <form action="/adm/coursedocs" method="post" name="newbul">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>   <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
  $help{'Bulletin Board'}   $help{'Bulletin Board'}
Line 3717  NBFORM Line 3824  NBFORM
  my $newaboutmeform=(<<NAMFORM);   my $newaboutmeform=(<<NAMFORM);
  <form action="/adm/coursedocs" method="post" name="newaboutme">   <form action="/adm/coursedocs" method="post" name="newaboutme">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail"    <input type="hidden" name="importdetail" 
  value="$plainname=/adm/$udom/$uname/aboutme" />   value="$plainname=/adm/$udom/$uname/aboutme" />
  <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>   <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
Line 3728  NAMFORM Line 3835  NAMFORM
  my $newaboutsomeoneform=(<<NASOFORM);   my $newaboutsomeoneform=(<<NASOFORM);
  <form action="/adm/coursedocs" method="post" name="newaboutsomeone">   <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>   <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
  </form>   </form>
Line 3738  NASOFORM Line 3845  NASOFORM
  my $newrosterform=(<<NROSTFORM);   my $newrosterform=(<<NROSTFORM);
  <form action="/adm/coursedocs" method="post" name="newroster">   <form action="/adm/coursedocs" method="post" name="newroster">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail"    <input type="hidden" name="importdetail" 
  value="$lt{'rost'}=/adm/viewclasslist" />   value="$lt{'rost'}=/adm/viewclasslist" />
  <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>   <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
Line 3770  NPFORM Line 3877  NPFORM
   
  $newfolderform=(<<NFFORM);   $newfolderform=(<<NFFORM);
  <form action="/adm/coursedocs" method="post" name="newfolder">   <form action="/adm/coursedocs" method="post" name="newfolder">
  <input type="hidden" name="folderpath" value="$path" />   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <input type="hidden" name="active" value="aa" />   <input type="hidden" name="active" value="aa" />
  <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}   <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
Line 3780  NFFORM Line 3887  NFFORM
  my $newsylform=(<<NSYLFORM);   my $newsylform=(<<NSYLFORM);
  <form action="/adm/coursedocs" method="post" name="newsyl">   <form action="/adm/coursedocs" method="post" name="newsyl">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail"    <input type="hidden" name="importdetail" 
  value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />   value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
  <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>   <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
Line 3792  NSYLFORM Line 3899  NSYLFORM
  my $newgroupfileform=(<<NGFFORM);   my $newgroupfileform=(<<NGFFORM);
  <form action="/adm/coursedocs" method="post" name="newgroupfiles">   <form action="/adm/coursedocs" method="post" name="newgroupfiles">
  <input type="hidden" name="active" value="cc" />   <input type="hidden" name="active" value="cc" />
  $uploadtag   $pathitem
  <input type="hidden" name="importdetail"   <input type="hidden" name="importdetail"
  value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />   value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
  <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>   <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
Line 3809  NGFFORM Line 3916  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="toggleUpload(\'ext\');" />'=>$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:toggleUpload(\'ims\');" />'=>$imspform},
         $fileuploadform =  &create_form_ul(&create_list_elements(@importdoc)) . '<hr id="cc_hrule" style="width:0px;text-align:left;margin-left:0" />' . $fileuploadform;          {'<img class="LC_noBorder_LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform,
           });
           $fileuploadform =  &create_form_ul(&create_list_elements(@importdoc));
   
         @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 3832  NGFFORM Line 3941  NGFFORM
   
 my %orderhash = (  my %orderhash = (
                 'aa' => ['Import Content',$fileuploadform],                  'aa' => ['Import Content',$fileuploadform],
                 'bb' => ['Published Content',$simpleeditdefaultform],                  'bb' => ['Published Content',$importpubform],
                 'cc' => ['Grading Resources',$gradingform],                  'cc' => ['Grading Resources',$gradingform],
                 );                  );
 unless ($env{'form.pagepath'}) {  unless ($env{'form.pagepath'}) {
Line 3844  unless ($env{'form.pagepath'}) { Line 3953  unless ($env{'form.pagepath'}) {
  $hadchanges=0;   $hadchanges=0;
        unless (($supplementalflag || $toolsflag)) {         unless (($supplementalflag || $toolsflag)) {
           my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,            my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                               $supplementalflag,\%orderhash,$iconpath);                                $supplementalflag,\%orderhash,$iconpath,$pathitem);
           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 3869  unless ($env{'form.pagepath'}) { Line 3978  unless ($env{'form.pagepath'}) {
   $env{'form.folderpath'} = $savefolderpath;    $env{'form.folderpath'} = $savefolderpath;
        }         }
        $env{'form.pagepath'} = '';         $env{'form.pagepath'} = '';
          $pathitem = '<input type="hidden" name="folderpath" value="'.
                       &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
        if ($allowed) {         if ($allowed) {
    my $folderseq=     my $folderseq=
        '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.         '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
        '.sequence';  
   
    my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');  
   
  my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}";  
  my $supupdocform=(<<SUPDOCFORM);   my $supupdocform=(<<SUPDOCFORM);
           <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
           $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
  <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">   <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
           <fieldset id="uploadsuppdocform" style="display: none;" />
           <legend>$lt{'upfi'}</legend>
  <input type="hidden" name="active" value="ee" />   <input type="hidden" name="active" value="ee" />
  $fileupload   $fileupload
  <br />   <br />
Line 3890  unless ($env{'form.pagepath'}) { Line 4001  unless ($env{'form.pagepath'}) {
  $lt{'comment'}:<br />   $lt{'comment'}:<br />
  <textarea cols="50" rows="4" name="comment"></textarea>   <textarea cols="50" rows="4" name="comment"></textarea>
  <br />   <br />
  <input type="hidden" name="folderpath" value="$path" />   $pathitem
  <input type="hidden" name="cmd" value="upload_supplemental" />   <input type="hidden" name="cmd" value="upload_supplemental" />
           <input type='submit' value="$lt{'upld'}" />
           </form>
 SUPDOCFORM  SUPDOCFORM
  $supupdocform .=  &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>";  
   
  my $supnewfolderform=(<<SNFFORM);   my $supnewfolderform=(<<SNFFORM);
  <form action="/adm/coursedocs" method="post" name="supnewfolder">   <form action="/adm/coursedocs" method="post" name="supnewfolder">
  <input type="hidden" name="active" value="ee" />   <input type="hidden" name="active" value="ee" />
  <input type="hidden" name="folderpath" value="$path" />          $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>    <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a> 
  $help{'Adding_Folders'}   $help{'Adding_Folders'}
  </form>   </form>
 SNFFORM  SNFFORM
   
           my $supextform =
  my $supnewextform=(<<SNEFORM);              &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
  <form action="/adm/coursedocs" method="post" name="supnewext">                                                   $help{'Adding_External_Resource'});
  <input type="hidden" name="active" value="ff" />  
  <input type="hidden" name="folderpath" value="$path" />  
  <input type="hidden" name="importdetail" value="" />  
  <a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'}  
  </form>  
 SNEFORM  
   
  my $supnewsylform=(<<SNSFORM);   my $supnewsylform=(<<SNSFORM);
  <form action="/adm/coursedocs" method="post" name="supnewsyl">   <form action="/adm/coursedocs" method="post" name="supnewsyl">
  <input type="hidden" name="active" value="ff" />   <input type="hidden" name="active" value="ff" />
  <input type="hidden" name="folderpath" value="$path" />          $pathitem
  <input type="hidden" name="importdetail"    <input type="hidden" name="importdetail" 
  value="Syllabus=/public/$coursedom/$coursenum/syllabus" />   value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
  <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>   <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
Line 3929  SNSFORM Line 4035  SNSFORM
  my $supnewaboutmeform=(<<SNAMFORM);   my $supnewaboutmeform=(<<SNAMFORM);
  <form action="/adm/coursedocs" method="post" name="supnewaboutme">   <form action="/adm/coursedocs" method="post" name="supnewaboutme">
  <input type="hidden" name="active" value="ff" />   <input type="hidden" name="active" value="ff" />
  <input type="hidden" name="folderpath" value="$path" />          $pathitem
  <input type="hidden" name="importdetail"    <input type="hidden" name="importdetail" 
  value="$plainname=/adm/$udom/$uname/aboutme" />   value="$plainname=/adm/$udom/$uname/aboutme" />
  <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>   <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
Line 3945  my @specialdocs = ( Line 4051  my @specialdocs = (
             =>$supnewaboutmeform},              =>$supnewaboutmeform},
  );   );
 my @supimportdoc = (  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="toggleUpload(\'suppext\')" />'
             =>$supnewextform},              =>$supextform},
         );                  {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
 $supupdocform =  &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr id="ee_hrule" style="width:0px;text-align:left;margin-left:0" />' . $supupdocform;              =>$supupdocform},
                      );
   
   $supupdocform =  &create_form_ul(&create_list_elements(@supimportdoc));
 my %suporderhash = (  my %suporderhash = (
  '00' => ['Supnewfolder', $supnewfolderform],   '00' => ['Supnewfolder', $supnewfolderform],
                 'ee' => ['Import Content',$supupdocform],                  'ee' => ['Import Content',$supupdocform],
Line 3956  my %suporderhash = ( Line 4065  my %suporderhash = (
                 );                  );
         if ($supplementalflag) {          if ($supplementalflag) {
            my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,             my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                                $supplementalflag,\%suporderhash,$iconpath);                                 $supplementalflag,\%suporderhash,$iconpath,$pathitem);
            if ($error) {             if ($error) {
               $r->print('<p><span class="LC_error">'.$error.'</span></p>');                $r->print('<p><span class="LC_error">'.$error.'</span></p>');
            }             }
         }          }
     } elsif ($supplementalflag) {      } elsif ($supplementalflag) {
         my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,          my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                             $supplementalflag,'',$iconpath);                              $supplementalflag,'',$iconpath,$pathitem);
         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(&endContentScreen());      if ($needs_end) {
           $r->print(&endContentScreen());
       }
   
     if ($allowed) {      if ($allowed) {
  $r->print('   $r->print('
Line 4263  sub generate_edit_table { Line 4374  sub generate_edit_table {
                $active = 'class="active"';                 $active = 'class="active"';
             }              }
             $form .= '<li style="float:right" '.$active              $form .= '<li style="float:right" '.$active
                 .' 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>'."\n";                  .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n";
         } else {          } else {
     $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";      $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
Line 4320  sub editing_js { Line 4430  sub editing_js {
                                           p_ctr2a => 'Cut[_98]',                                            p_ctr2a => 'Cut[_98]',
                                           p_ctr2b => '?[_98]',                                            p_ctr2b => '?[_98]',
                                           rpck    => 'Enter number to pick (e.g., 3)',                                            rpck    => 'Enter number to pick (e.g., 3)',
                                             imsfile => 'You must choose an IMS package for import',
                                             imscms  => 'You must select which Course Management System was the source of the IMS package',
                                             invurl  => 'Invalid URL',
                                             titbl   => 'Title is blank',
                                         );                                          );
   
     my $crstype = &Apache::loncommon::course_type();      my $crstype = &Apache::loncommon::course_type();
Line 4339  sub editing_js { Line 4453  sub editing_js {
         $backtourl = '/adm/supplemental';          $backtourl = '/adm/supplemental';
     }      }
   
       my $fieldsets = "'ext','doc','ims'";
       if ($supplementalflag) {
           $fieldsets = "'suppext','suppdoc'";
       }
   
     return <<ENDNEWSCRIPT;      return <<ENDNEWSCRIPT;
 function makenewfolder(targetform,folderseq) {  function makenewfolder(targetform,folderseq) {
     var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');      var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
Line 4356  function makenewpage(targetform,folderse Line 4475  function makenewpage(targetform,folderse
     }      }
 }  }
   
 function makenewext(targetname) {  
     this.document.forms.extimport.useform.value=targetname;  
     this.document.forms.extimport.title.value='';  
     this.document.forms.extimport.url.value='';  
     this.document.forms.extimport.residx.value='';  
     window.open('/adm/rat/extpickframe.html');  
 }  
   
 function edittext(targetname,residx,title,url) {  
     this.document.forms.extimport.useform.value=targetname;  
     this.document.forms.extimport.residx.value=residx;  
     this.document.forms.extimport.url.value=url;  
     this.document.forms.extimport.title.value=title;  
     window.open('/adm/rat/extpickframe.html');  
 }  
   
 function makeexamupload() {  function makeexamupload() {
    var title=prompt('$lt{"p_mxu"}');     var title=prompt('$lt{"p_mxu"}');
    if (title) {     if (title) {
Line 4436  function makeabout() { Line 4539  function makeabout() {
 }  }
 }  }
   
 function makeims() {  function toggleUpload(caller) {
 var caller = document.forms.ims.folder.value;      var blocks = Array($fieldsets);
 var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";      for (var i=0; i<blocks.length; i++) {
 newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");          var disp = 'none';
 newWindow.location.href = newlocation;          if (caller == blocks[i]) {
               var curr = document.getElementById('upload'+caller+'form').style.display;
               if (curr == 'none') {
                   disp='block';
               }
           }
           document.getElementById('upload'+blocks[i]+'form').style.display=disp;
       }
       resize_scrollbox('contentscroll','1','1');
       return;
 }  }
   
 function finishpick() {  function toggleMap() {
 var title=this.document.forms.extimport.title.value;      var disp = 'none';
 var url=this.document.forms.extimport.url.value;      if (document.getElementById('importmapform')) {
 var form=this.document.forms.extimport.useform.value;          var curr = document.getElementById('importmapform').style.display;
 var residx=this.document.forms.extimport.residx.value;          if (curr == 'none') {
 eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');              disp='block';
           }
           document.getElementById('importmapform').style.display=disp;
           resize_scrollbox('contentscroll','1','1');
       }
       return;
   }
   
   function makeims(imsform) {
       if ((imsform.uploaddoc.value == '')  || (!imsform.uploaddoc.value)) {
           alert("$lt{'imsfile'}");
           return;
       }
       if (imsform.source.selectedIndex == 0) {
           alert("$lt{'imscms'}");
           return;
       }
       newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
       imsform.submit();
 }  }
   
 function changename(folderpath,index,oldtitle,container,pagesymb) {  function changename(folderpath,index,oldtitle,container,pagesymb) {
Line 4602  function showPage(current, pageId, nav, Line 4732  function showPage(current, pageId, nav,
  currentData = document.getElementById(pageId);   currentData = document.getElementById(pageId);
  currentData.style.display = 'block';   currentData.style.display = 'block';
         activeTab = pageId;          activeTab = pageId;
           toggleUpload();
           toggleMap();
         if (nav == 'mainnav') {          if (nav == 'mainnav') {
             var storedpath = "$docs_folderpath";              var storedpath = "$docs_folderpath";
             if (storedpath == '') {              if (storedpath == '') {

Removed from v.1.498  
changed lines
  Added in v.1.511


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