Diff for /loncom/interface/londocs.pm between versions 1.267 and 1.270

version 1.267, 2007/01/05 18:45:40 version 1.270, 2007/01/26 23:37:53
Line 235  sub dumpcourse { Line 235  sub dumpcourse {
     my ($ext)=($_=~/\.(\w+)$/);      my ($ext)=($_=~/\.(\w+)$/);
     my $title=$hash{'title_'.$hash{      my $title=$hash{'title_'.$hash{
  'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};   'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
     $title=~s/:/:/g;  
     $r->print('<td>'.($title?$title:'&nbsp;').'</td>');      $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
     if (!$title) {      if (!$title) {
  $title=$_;   $title=$_;
Line 937  sub group_import { Line 936  sub group_import {
     $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;      $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
     my $ext = 'false';      my $ext = 'false';
     if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }      if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
     $url =~ s/:/\&colon;/g;      $url  =~ &LONCAPA::map::qtunescape($url);
     $name =~ s/:/\&colon;/g;      $name =~ &LONCAPA::map::qtunescape($name);
     $LONCAPA::map::resources[$idx] =       $LONCAPA::map::resources[$idx] = 
  join ':', ($name, $url, $ext, 'normal', 'res');   join ':', ($name, $url, $ext, 'normal', 'res');
  }   }
Line 1316  sub editor { Line 1315  sub editor {
  &Apache::lonnet::getfile($url));   &Apache::lonnet::getfile($url));
     $url=$newurl;      $url=$newurl;
  }   }
  $title=~s/\</\&lt\;/g;   $title = &LONCAPA::map::qtunescape($title);
  $title=~s/\>/\&gt\;/g;  
  $title=~s/\:/\&colon;/g;  
  my $ext='false';   my $ext='false';
  if ($url=~/^http\:\/\//) { $ext='true'; }   if ($url=~/^http\:\/\//) { $ext='true'; }
  $url=~s/\:/\&colon;/g;   $url   = &LONCAPA::map::qtunescape($url);
 # Now insert the URL at the bottom  # Now insert the URL at the bottom
                 my $newidx=&LONCAPA::map::getresidx($url);                  my $newidx=&LONCAPA::map::getresidx($url);
  $LONCAPA::map::resources[$newidx]=   $LONCAPA::map::resources[$newidx]=
Line 1373  sub editor { Line 1370  sub editor {
                     my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];                      my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
                     my ($rtitle,@rrest)=split(/\:/,                      my ($rtitle,@rrest)=split(/\:/,
                        $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]);                         $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]);
                     my $comment=                      my $comment=$env{'form.title'};
                      &HTML::Entities::decode($env{'form.title'});                      $comment = &LONCAPA::map::qtunescape($comment);
                     $comment=~s/\</\&lt\;/g;  
                     $comment=~s/\>/\&gt\;/g;  
                     $comment=~s/\:/\&colon;/g;  
     if ($comment=~/\S/) {      if ($comment=~/\S/) {
  $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=   $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
     $comment.':'.join(':',@rrest);      $comment.':'.join(':',@rrest);
     }      }
 # Devalidate title cache  # Devalidate title cache
                     my $renamed_url=$rrest[0];                      my $renamed_url=&LONCAPA::map::qtescape($rrest[0]);
 # Has the &colon;-escaping  
                     $renamed_url=~s/\&colon\;/\:/g;  
     &Apache::lonnet::devalidate_title_cache($renamed_url);      &Apache::lonnet::devalidate_title_cache($renamed_url);
                 }                  }
 # Store the changed version  # Store the changed version
Line 1456  sub editor { Line 1448  sub editor {
         foreach (@LONCAPA::map::order) {          foreach (@LONCAPA::map::order) {
            my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$_]);             my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$_]);
    $name=&LONCAPA::map::qtescape($name);     $name=&LONCAPA::map::qtescape($name);
    $url=&LONCAPA::map::qtescape($url);     $url =&LONCAPA::map::qtescape($url);
            unless ($name) {  $name=(split(/\//,$url))[-1]; }             unless ($name) {  $name=(split(/\//,$url))[-1]; }
            unless ($name) { $idx++; next; }             unless ($name) { $idx++; next; }
            $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));             $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
Line 1539  sub process_file_upload { Line 1531  sub process_file_upload {
  $codebase);   $codebase);
         my $ext='false';          my $ext='false';
         if ($url=~/^http\:\/\//) { $ext='true'; }          if ($url=~/^http\:\/\//) { $ext='true'; }
         $url=~s/\:/\&colon;/g;   $url     = &LONCAPA::map::qtunescape($url);
         my $comment=$env{'form.comment'};          my $comment=$env{'form.comment'};
         $comment=~s/\</\&lt\;/g;   $comment = &LONCAPA::map::qtunescape($comment);
         $comment=~s/\>/\&gt\;/g;  
         $comment=~s/\:/\&colon;/g;  
         if ($folder=~/^supplemental/) {          if ($folder=~/^supplemental/) {
               $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.                $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
                   $env{'user.domain'}.'___&&&___'.$comment;                    $env{'user.domain'}.'___&&&___'.$comment;
Line 1562  sub process_file_upload { Line 1552  sub process_file_upload {
                 my $total_embedded = keys(%{$allfiles});                  my $total_embedded = keys(%{$allfiles});
                 if ($total_embedded > 0) {                  if ($total_embedded > 0) {
                     my $num = 0;                      my $num = 0;
                     $$upload_output .= 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />      my $state = '
    <form name="upload_embedded" action="/adm/coursedocs"     <input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" />
                   method="post" enctype="multipart/form-data">     <input type="hidden" name="cmd" value="upload_embedded" />
    <input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" />   <input type="hidden" name="cmd" value="upload_embedded" />  
    <input type="hidden" name="newidx" value="'.$newidx.'" />     <input type="hidden" name="newidx" value="'.$newidx.'" />
    <input type="hidden" name="primaryurl" value="'.&escape($url).'" />     <input type="hidden" name="primaryurl" value="'.&escape($url).'" />
    <input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';     <input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';
                     $$upload_output .= '<b>Upload embedded files</b>:<br />      $phase_status = 'phasetwo';
    <table>';  
                     foreach my $embed_file (keys(%{$allfiles})) {                      $$upload_output .= 
                         $$upload_output .= '<tr><td>'.$embed_file.   'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.
           '<input name="embedded_item_'.$num.'" type="file" />   &ask_for_embedded_content('/adm/coursedocs',
            <input name="embedded_orig_'.$num.'" type="hidden" value="'.&escape($embed_file).'" />';    $state,$allfiles,$codebase);
                         my $attrib;  
                         if (@{$$allfiles{$embed_file}} > 1) {  
                             $attrib = join(':',@{$$allfiles{$embed_file}});  
                         } else {  
                             $attrib = $$allfiles{$embed_file}[0];  
                         }  
                         $$upload_output .=  
            '<input name="embedded_attrib_'.$num.'" type="hidden" value="'.$attrib.'" />';  
                         if (exists($$codebase{$embed_file})) {  
                             $$upload_output .=   
           '<input name="codebase_'.$num.'" type="hidden" value="'.&escape($$codebase{$embed_file}).'" />';  
                         }  
                         $$upload_output .= '</td></tr>';  
                         $num ++;  
                     }  
                     $phase_status = 'phasetwo';  
                     $$upload_output .= '</table><br />  
    <input type ="submit" value="Complete upload" />  
    </form>';  
                 } else {                  } else {
                     $$upload_output .= 'No embedded items identified<br />';                      $$upload_output .= 'No embedded items identified<br />';
                 }                  }
Line 1603  sub process_file_upload { Line 1573  sub process_file_upload {
     return $phase_status;      return $phase_status;
 }  }
   
   sub ask_for_embedded_content {
       my ($actionurl,$state,$allfiles,$codebase)=@_;
       my $upload_output = '
      <form name="upload_embedded" action="'.$actionurl.'"
                     method="post" enctype="multipart/form-data">';
       $upload_output .= $state;
       $upload_output .= '<b>Upload embedded files</b>:<br />
      <table>';
   
       my $num = 0;
       foreach my $embed_file (keys(%{$allfiles})) {
    $upload_output .= '<tr><td>'.$embed_file.'</td><td>
              <input name="embedded_item_'.$num.'" type="file" value="bob" />
              <input name="embedded_orig_'.$num.'" type="hidden" value="'.&escape($embed_file).'" />';
    my $attrib = join(':',@{$$allfiles{$embed_file}});
    $upload_output .=
       "\n\t\t".
       '<input name="embedded_attrib_'.$num.'" type="hidden" value="'.
       $attrib.'" />';
    if (exists($$codebase{$embed_file})) {
       $upload_output .= 
    "\n\t\t".
    '<input name="codebase_'.$num.'" type="hidden" value="'.
    &escape($$codebase{$embed_file}).'" />';
    }
    $upload_output .= '</td></tr>';
    $num++;
       }
       $upload_output .= '</table><br />
      <input type ="hidden" name="number_embedded_items" value="'.$num.'" />
      <input type ="submit" value="Complete upload" />
      </form>';
       return $upload_output;
   }
   
 sub process_secondary_uploads {  sub process_secondary_uploads {
     my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;      my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
     my $folder=$env{'form.folder'};      my $folder=$env{'form.folder'};
Line 1626  sub process_secondary_uploads { Line 1631  sub process_secondary_uploads {
   
 sub entryline {  sub entryline {
     my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;      my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
     $title=~s/\&colon\;/\:/g;      $title=&HTML::Entities::encode($title,'"<>&\'');
     $title=&HTML::Entities::encode(&HTML::Entities::decode(  
      &unescape($title)),'"<>&\'');  
     my $renametitle=$title;      my $renametitle=$title;
     my $foldertitle=$title;      my $foldertitle=$title;
     my $pagetitle=$title;      my $pagetitle=$title;
Line 1695  sub entryline { Line 1698  sub entryline {
  'rn' => 'Rename',   'rn' => 'Rename',
  'cp' => 'Copy');   'cp' => 'Copy');
  my $nocopy=0;   my $nocopy=0;
           my $nocut=0;
         if ($url=~/\.(page|sequence)$/) {          if ($url=~/\.(page|sequence)$/) {
     foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) {      foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) {
  my ($title,$url,$ext,$type)=split(/\:/,$_);   my ($title,$url,$ext,$type)=split(/\:/,$_);
Line 1704  sub entryline { Line 1708  sub entryline {
  }   }
     }      }
  }   }
         if ($url=~/^\/res\/lib\/templates\//) { $nocopy=1; }          if ($url=~/^\/res\/lib\/templates\//) { 
              $nocopy=1; 
              $nocut=1;
           }
         my $copylink='&nbsp;';          my $copylink='&nbsp;';
         my $cutlink='&nbsp;';          my $cutlink='&nbsp;';
         if ($env{'form.pagepath'}) {          if ($env{'form.pagepath'}) {
            unless ($nocopy) {             if (!$nocopy) {
                $copylink=(<<ENDCOPY);                 $copylink=(<<ENDCOPY);
 <a href='javascript:markcopy("$pagepath","$index","$renametitle","page","$pagesymb");'>  <a href='javascript:markcopy("$pagepath","$index","$renametitle","page","$pagesymb");'>
 <font size="-2" color="#000099">$lt{'cp'}</font></a></td>  <font size="-2" color="#000099">$lt{'cp'}</font></a></td>
 ENDCOPY  ENDCOPY
              }
              if (!$nocut) {
                $cutlink=(<<ENDCUT);                 $cutlink=(<<ENDCUT);
 <a href='javascript:cutres("$pagepath","$index","$renametitle","page","$pagesymb");'>  <a href='javascript:cutres("$pagepath","$index","$renametitle","page","$pagesymb");'>
 <font size="-2" color="#550044">$lt{'ct'}</font></a>  <font size="-2" color="#550044">$lt{'ct'}</font></a>
Line 1744  $cutlink Line 1753  $cutlink
 $copylink  $copylink
 END  END
         } else {          } else {
            unless ($nocopy) {             if (!$nocopy) {
                $copylink=(<<ENDCOPY);                 $copylink=(<<ENDCOPY);
 <a href='javascript:markcopy("$folderpath","$index","$renametitle","sequence");'>  <a href='javascript:markcopy("$folderpath","$index","$renametitle","sequence");'>
 <font size="-2" color="#000099">$lt{'cp'}</font></a></td>  <font size="-2" color="#000099">$lt{'cp'}</font></a></td>
 ENDCOPY  ENDCOPY
               }
               if (!$nocut) {
                $cutlink=(<<ENDCUT);                 $cutlink=(<<ENDCUT);
 <a href='javascript:cutres("$folderpath","$index","$renametitle","sequence");'>  <a href='javascript:cutres("$folderpath","$index","$renametitle","sequence");'>
 <font size="-2" color="#550044">$lt{'ct'}</font></a>  <font size="-2" color="#550044">$lt{'ct'}</font></a>

Removed from v.1.267  
changed lines
  Added in v.1.270


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