Diff for /loncom/interface/lonmeta.pm between versions 1.159 and 1.169

version 1.159, 2006/06/23 00:28:43 version 1.169, 2006/08/16 18:02:01
Line 170  sub authordisplay { Line 170  sub authordisplay {
     my ($aname,$adom)=@_;      my ($aname,$adom)=@_;
     return &Apache::loncommon::aboutmewrapper      return &Apache::loncommon::aboutmewrapper
         (&Apache::loncommon::plainname($aname,$adom),          (&Apache::loncommon::plainname($aname,$adom),
          $aname,$adom,'preview').' <tt>['.$aname.'@'.$adom.']</tt>';           $aname,$adom,'preview').' <tt>['.$aname.':'.$adom.']</tt>';
 }  }
   
 # Pretty display  # Pretty display
Line 287  sub portfolio_linked_path { Line 287  sub portfolio_linked_path {
     if ($group) {      if ($group) {
  $start = "groups/$group/".$start;   $start = "groups/$group/".$start;
     }      }
     my $result = &Apache::portfolio::make_anchor($port_path,$start,'/',      my %anchor_fields = (
  undef,undef,undef,$group);          'selectfile'  => $start,
               'currentpath' => '/'
       );
       my $result = &Apache::portfolio::make_anchor($port_path,\%anchor_fields,$start);
     my $fullpath = '/';      my $fullpath = '/';
     my (undef,@tree) = split('/',$path);      my (undef,@tree) = split('/',$path);
     my $filename = pop(@tree);      my $filename = pop(@tree);
     foreach my $dir (@tree) {      foreach my $dir (@tree) {
  $fullpath .= $dir.'/';   $fullpath .= $dir.'/';
  $result .= '/';   $result .= '/';
  $result .= &Apache::portfolio::make_anchor($port_path,$dir,$fullpath,   my %anchor_fields = (
    undef,undef,undef,$group);              'selectfile'  => $dir,
               'currentpath' => $fullpath
           );
    $result .= &Apache::portfolio::make_anchor($port_path,\%anchor_fields,$dir);
     }      }
     $result .= "/$filename";      $result .= "/$filename";
     return $result;      return $result;
Line 316  sub get_port_path_and_group { Line 321  sub get_port_path_and_group {
     } else {      } else {
  $port_path = '/adm/portfolio';   $port_path = '/adm/portfolio';
     }      }
       if ($env{'form.group'} ne $group) {
    $env{'form.group'} = $group;
       }
     return ($port_path,$group);      return ($port_path,$group);
 }  }
   
Line 357  sub pre_select_course { Line 365  sub pre_select_course {
     $r->print('<p>'.&mt('If you would like to associate this resource ([_1]) with a current or previous course, please select one from the list below, otherwise select, \'None\'','<tt>'.$res_uri.'</tt>').'</p>');      $r->print('<p>'.&mt('If you would like to associate this resource ([_1]) with a current or previous course, please select one from the list below, otherwise select, \'None\'','<tt>'.$res_uri.'</tt>').'</p>');
     $output = &select_course();      $output = &select_course();
     $r->print($output.'<br /><input type="submit" name="store" value="'.      $r->print($output.'<br /><input type="submit" name="store" value="'.
                   &mt('Associate Resource With Selected Course').'">');                    &mt('Associate Resource With Selected Course').'" />');
       $r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />');
       $r->print('<input type="hidden" name="associate" value="true" />');
     $r->print('</form>');      $r->print('</form>');
           
     my ($port_path,$group) = &get_port_path_and_group($uri);      my ($port_path,$group) = &get_port_path_and_group($uri);
     $r->print('<br /><br /><form method="POST" action="'.$port_path.'">'.      my $group_input;
       if ($group) {
           $group_input = '<input type="hidden" name="group" value="'.$group.'" />';
       } 
       $r->print('<br /><br /><form method="post" action="'.$port_path.'">'.
               '<input type="hidden" name="currentpath" value="'.$path.'" />'.                '<input type="hidden" name="currentpath" value="'.$path.'" />'.
       '<input type="hidden" name="group" value="'.$group.'" />'.        $group_input.
       '<input type="submit" name="cancel" value="'.&mt('Cancel').'">'.        '<input type="submit" name="cancel" value="'.&mt('Cancel').'" />'.
       '</form>');        '</form>');
   
     return;      return;
Line 706  sub prettyinput { Line 720  sub prettyinput {
 sub handler {  sub handler {
     my $r=shift;      my $r=shift;
     #      #
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
            ['currentpath']);
     my $uri=$r->uri;      my $uri=$r->uri;
     #      #
     # Set document type      # Set document type
Line 715  sub handler { Line 731  sub handler {
     #      #
     my ($resdomain,$resuser)=      my ($resdomain,$resuser)=
         (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);          (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);
   
     if ($uri=~m:/adm/bombs/(.*)$:) {      if ($uri=~m:/adm/bombs/(.*)$:) {
         $r->print(&Apache::loncommon::start_page('Error Messages'));          $r->print(&Apache::loncommon::start_page('Error Messages'));
         # Looking for all bombs?          # Looking for all bombs?
         &report_bombs($r,$uri);          &report_bombs($r,$uri);
     } elsif ($uri=~/\/portfolio\//) {      } elsif ($uri=~m|^/editupload/[^/]+/[^/]+/portfolio/|) {
     ($resdomain,$resuser)=      ($resdomain,$resuser)=
     (&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|);   (&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|);
         $r->print(&Apache::loncommon::start_page('Edit Portfolio File Catalog Information',          $r->print(&Apache::loncommon::start_page('Edit Portfolio File Catalog Information',
  undef,   undef,
  {'domain' => $resdomain,}));   {'domain' => $resdomain,}));
Line 731  sub handler { Line 746  sub handler {
         } else {          } else {
             &pre_select_course($r,$uri);              &pre_select_course($r,$uri);
         }          }
     } elsif ($uri=~/^\/\~/) {       } elsif ($uri=~m|^/~|) { 
         # Construction space          # Construction space
         $r->print(&Apache::loncommon::start_page('Edit Catalog nformation',          $r->print(&Apache::loncommon::start_page('Edit Catalog nformation',
  undef,   undef,
Line 797  ENDCLEAR Line 812  ENDCLEAR
 sub present_uneditable_metadata {  sub present_uneditable_metadata {
     my ($r,$uri) = @_;      my ($r,$uri) = @_;
     #      #
       my $uploaded = ($uri =~ m|/uploaded/|);
     my %content=();      my %content=();
     # Read file      # Read file
     foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {      foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
Line 809  sub present_uneditable_metadata { Line 825  sub present_uneditable_metadata {
     my $disuri=&Apache::lonnet::clutter($uri);      my $disuri=&Apache::lonnet::clutter($uri);
     $disuri=~s/^\/adm\/wrapper//;      $disuri=~s/^\/adm\/wrapper//;
     # version      # version
     my $currentversion=&Apache::lonnet::getversion($disuri);  
     my $versiondisplay='';      my $versiondisplay='';
     if ($thisversion) {      if (!$uploaded) {
         $versiondisplay=&mt('Version').': '.$thisversion.   my $currentversion=&Apache::lonnet::getversion($disuri);
             ' ('.&mt('most recent version').': '.   if ($thisversion) {
             ($currentversion>0 ?       $versiondisplay=&mt('Version').': '.$thisversion.
              $currentversion   :   ' ('.&mt('most recent version').': '.
              &mt('information not available')).')';   ($currentversion>0 ? 
     } else {   $currentversion   :
         $versiondisplay='Version: '.$currentversion;   &mt('information not available')).')';
    } else {
       $versiondisplay='Version: '.$currentversion;
    }
     }      }
     # crumbify displayed URL               uri     target prefix form  size      # crumbify displayed URL               uri     target prefix form  size
     $disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef,'+1');      $disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef,'+1');
Line 838  sub present_uneditable_metadata { Line 856  sub present_uneditable_metadata {
     if (! defined($title)) {      if (! defined($title)) {
         $title = 'Untitled Resource';          $title = 'Untitled Resource';
     }      }
     foreach ('title',       my @fields;
              'author',       if ($uploaded) {
              'subject',    @fields = ('title','author','subject','keywords','notes','abstract',
              'keywords',      'lowestgradelevel','highestgradelevel','standards','mime',
              'notes',      'owner');
              'abstract',      } else {
              'lowestgradelevel',   @fields = ('title', 
              'highestgradelevel',     'author', 
              'standards',      'subject', 
              'mime',      'keywords', 
              'language',      'notes', 
              'creationdate',      'abstract',
              'lastrevisiondate',      'lowestgradelevel',
              'owner',      'highestgradelevel',
              'copyright',      'standards', 
              'customdistributionfile',     'mime', 
              'sourceavail',     'language', 
              'sourcerights',      'creationdate', 
              'obsolete',      'lastrevisiondate', 
              'obsoletereplacement') {     'owner', 
         $table.='<tr><td bgcolor="#AAAAAA">'.$lt{$_}.     'copyright', 
      'customdistributionfile',
      'sourceavail',
      'sourcerights', 
      'obsolete', 
      'obsoletereplacement');
       }
       foreach my $field (@fields) {
           $table.='<tr><td bgcolor="#AAAAAA">'.$lt{$field}.
             '</td><td bgcolor="#CCCCCC">'.              '</td><td bgcolor="#CCCCCC">'.
             &prettyprint($_,$content{$_}).'</td></tr>';              &prettyprint($field,$content{$field}).'</td></tr>';
         delete $content{$_};          delete($content{$field});
     }      }
     #      #
     $r->print(<<ENDHEAD);      $r->print(<<ENDHEAD);
Line 875  $versiondisplay Line 901  $versiondisplay
 $table  $table
 </table>  </table>
 ENDHEAD  ENDHEAD
     if ($env{'user.adv'}) {      if (!$uploaded && $env{'user.adv'}) {
         &print_dynamic_metadata($r,$uri,\%content);          &print_dynamic_metadata($r,$uri,\%content);
     }      }
     return;      return;
Line 1121  sub present_editable_metadata { Line 1147  sub present_editable_metadata {
  my $goback=&mt('Back to Source File');   my $goback=&mt('Back to Source File');
         $r->print(<<ENDBOMBS);          $r->print(<<ENDBOMBS);
 <h1>$disuri</h1>  <h1>$disuri</h1>
 <form method="post" name="defaultmeta">  <form method="post" action="" name="defaultmeta">
 ENDBOMBS  ENDBOMBS
         if ($showdel) {          if ($showdel) {
     $r->print(<<ENDDEL);      $r->print(<<ENDDEL);
Line 1151  ENDDEL Line 1177  ENDDEL
         }          }
         $r->print(<<ENDEDIT);          $r->print(<<ENDEDIT);
 <h1>$displayfile</h1>  <h1>$displayfile</h1>
 <form method="post" name="defaultmeta">  <form method="post" action="" name="defaultmeta">
 ENDEDIT  ENDEDIT
         $r->print('<script language="JavaScript">'.          $r->print('<script type="JavaScript">'.
                   &Apache::loncommon::browser_and_searcher_javascript().                    &Apache::loncommon::browser_and_searcher_javascript().
                   '</script>');                    '</script>');
         my %lt=&fieldnames($file_type);          my %lt=&fieldnames($file_type);
  my $output;   my $output;
  my @fields;   my @fields;
  if ($file_type eq 'portfolio') {   if ($file_type eq 'portfolio') {
     @fields =  ('author','title','subject','keywords','abstract','notes','lowestgradelevel',      @fields =  ('author','title','subject','keywords','abstract',
    'notes','lowestgradelevel',
                 'highestgradelevel','standards');                  'highestgradelevel','standards');
  } else {   } else {
     @fields = ('author','title','subject','keywords','abstract','notes',      @fields = ('author','title','subject','keywords','abstract','notes',
Line 1179  ENDEDIT Line 1206  ENDEDIT
         }                     }           
         if (! $Apache::lonpublisher::metadatafields{'copyright'}) {          if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
                 $Apache::lonpublisher::metadatafields{'copyright'}=                  $Apache::lonpublisher::metadatafields{'copyright'}=
                 'default';      'default';
         }          }
  if ($file_type eq 'portfolio') {   if ($file_type eq 'portfolio') {
       if (! $Apache::lonpublisher::metadatafields{'mime'}) {
                   ($Apache::lonpublisher::metadatafields{'mime'}) =
       ( $target=~/\.(\w+)$/ );
       }
       if (! $Apache::lonpublisher::metadatafields{'owner'}) {
    $Apache::lonpublisher::metadatafields{'owner'} =
       $env{'user.name'}.':'.$env{'user.domain'};
       }
   
     if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {      if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {
  $r->print(&mt('Associated with course [_1]','<strong>'.$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.".description"}.   $r->print(&mt('Associated with course [_1]','<strong>'.$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.".description"}.
       '</strong>').'<br />');        '</strong>').'<br />');
Line 1250  ENDEDIT Line 1286  ENDEDIT
     if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/portfolio/|) {      if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/portfolio/|) {
  my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|);   my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|);
                 $r->print(&store_portfolio_metadata($formname,$file_content,$path,                  $r->print(&store_portfolio_metadata($formname,$file_content,$path,
                                                     $new_fn));                                                          $new_fn));
                   unless ($env{'form.associate'}) {
                       $r->print(&Apache::portfolio::done("return",'/adm/portfolio'));
                       return;
                   }  
             } elsif ($fn =~  m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/groups/\w+/portfolio/|) {              } elsif ($fn =~  m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/groups/\w+/portfolio/|) {
                 my ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|);                  my ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|);
                 $r->print(&store_portfolio_metadata($formname,$file_content,$path,$new_fn));                  $r->print(&store_portfolio_metadata($formname,$file_content,$path,$new_fn));
                   unless ($env{'form.associate'}) {
                       $r->print(&Apache::portfolio::done("return",'/adm/portfolio'));
                       return;
                   }  
     } else {      } else {
  if (!  ($mfh=Apache::File->new('>'.$fn))) {   if (!  ($mfh=Apache::File->new('>'.$fn))) {
     $r->print('<p><font color="red">'.      $r->print('<p><font color="red">'.
Line 1265  ENDEDIT Line 1309  ENDEDIT
       ' '.&Apache::lonlocal::locallocaltime(time).        ' '.&Apache::lonlocal::locallocaltime(time).
       '</font></p>');        '</font></p>');
  }   }
                   unless ($env{'form.associate'}) {
                       $r->print(&Apache::portfolio::done("return",'/adm/portfolio'));
                       return;
                   }  
     }      }
  }   }
   
  $r->print($output.'<br /><input type="submit" name="store" value="'.   $r->print($output.'<br /><input type="submit" name="store" value="'.
                   &mt('Store Catalog Information').'">');                    &mt('Store Catalog Information').'" />');
   
  if ($file_type eq 'portfolio') {   if ($file_type eq 'portfolio') {
     my ($port_path,$group) = &get_port_path_and_group($uri);      my ($port_path,$group) = &get_port_path_and_group($uri);
             if ($group) {              if ($group) {
                 $r->print('<input type="hidden" name="group" value="'.$group.'" />');                  $r->print('<input type="hidden" name="group" value="'.$group.'" />');
             }              }
               $r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />');
     $r->print('</form>      $r->print('</form>
                <br /><br /><form method="POST" action="'.$port_path.'">'.                 <br /><br /><form method="post" action="'.$port_path.'">'.
       '<input type="hidden" name="group" value="'.$group.'" />'.        '<input type="hidden" name="group" value="'.$group.'" />'.
       '<input type="hidden" name="currentpath" value="'.$path.'" />'.        '<input type="hidden" name="currentpath" value="'.$path.'" />'.
       '<input type="submit" name="cancel" value="'.&mt('Discard Edits and Return to Portfolio').'">');        '<input type="submit" name="cancel" value="'.&mt('Discard Edits and Return to Portfolio').'" />');
  }   }
     }      }
           

Removed from v.1.159  
changed lines
  Added in v.1.169


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