Diff for /loncom/interface/lonmeta.pm between versions 1.250 and 1.255

version 1.250, 2013/05/03 14:00:58 version 1.255, 2023/03/28 23:17:18
Line 389  sub select_course { Line 389  sub select_course {
                     &mt('You can choose to transfer data from the added fields to the "Notes" field if you are planning to change the course association.').'<br /><br />'.                      &mt('You can choose to transfer data from the added fields to the "Notes" field if you are planning to change the course association.').'<br /><br />'.
                     &Apache::loncommon::start_data_table().                      &Apache::loncommon::start_data_table().
                     &Apache::loncommon::start_data_table_header_row().                      &Apache::loncommon::start_data_table_header_row().
                     '<th>Copy to notes?</th>'."\n".                      '<th>'.&mt('Copy to notes?').'</th>'."\n".
                     '<th>Field name</th>'."\n".                      '<th>'.&mt('Field Name').'</th>'."\n".
                     '<th>Values</th>'."\n".                      '<th>'.&mt('Values').'</th>'."\n".
                     &Apache::loncommon::end_data_table_header_row().                      &Apache::loncommon::end_data_table_header_row().
                     $transfernotes.                      $transfernotes.
                     &Apache::loncommon::end_data_table().'<br />';                      &Apache::loncommon::end_data_table().'<br />';
Line 455  sub prettyprint { Line 455  sub prettyprint {
     }      }
     # MIME      # MIME
     if ($type eq 'mime') {      if ($type eq 'mime') {
         return '<img src="'.&Apache::loncommon::icon($value).'" />&nbsp;'.          return '<img src="'.&Apache::loncommon::icon($value).'" alt="" />&nbsp;'.
             &Apache::loncommon::filedescription($value);              &Apache::loncommon::filedescription($value);
     }      }
     # Person      # Person
Line 550  sub direct { Line 550  sub direct {
 }  }
   
 sub selectbox {  sub selectbox {
     my ($name,$value,$functionref,@idlist)=@_;      my ($name,$value,$readonly,$functionref,@idlist)=@_;
     if (! defined($functionref)) {      if (! defined($functionref)) {
         $functionref=\&direct;          $functionref=\&direct;
     }      }
       my $disabled;
       if ($readonly) {
           $disabled = ' disabled="disabled"';
       }
     my $selout='<select name="'.$name.'">';      my $selout='<select name="'.$name.'">';
     foreach my $id (@idlist) {      foreach my $id (@idlist) {
         $selout.='<option value="'.$id.'"';          $selout.='<option value="'.$id.'"'.$disabled;
         if ($id eq $value) {          if ($id eq $value) {
     $selout.=' selected="selected">'.&{$functionref}($id).'</option>';      $selout.=' selected="selected">'.&{$functionref}($id).'</option>';
         } else {          } else {
Line 582  sub relatedfield { Line 586  sub relatedfield {
 }  }
   
 sub prettyinput {  sub prettyinput {
     my ($type,$value,$fieldname,$formname,      my ($type,$value,$readonly,$fieldname,$formname,
  $relatedsearchflag,$relatedsep,$relatedvalue,$size,$course_key)=@_;   $relatedsearchflag,$relatedsep,$relatedvalue,$size,$course_key)=@_;
     if (! defined($size)) {      if (! defined($size)) {
         $size = 80;          $size = 80;
Line 661  sub prettyinput { Line 665  sub prettyinput {
     # Language      # Language
     if ($type eq 'language') {      if ($type eq 'language') {
  return &selectbox($fieldname,   return &selectbox($fieldname,
   $value,    $value,'',
   \&Apache::loncommon::languagedescription,    \&Apache::loncommon::languagedescription,
   (&Apache::loncommon::languageids)).    (&Apache::loncommon::languageids)).
                               &relatedfield(0,$relatedsearchflag,$relatedsep);                                &relatedfield(0,$relatedsearchflag,$relatedsep);
Line 669  sub prettyinput { Line 673  sub prettyinput {
     # Copyright      # Copyright
     if ($type eq 'copyright') {      if ($type eq 'copyright') {
  return &selectbox($fieldname,   return &selectbox($fieldname,
   $value,    $value,$readonly,
   \&Apache::loncommon::copyrightdescription,    \&Apache::loncommon::copyrightdescription,
   (&Apache::loncommon::copyrightids)).    (&Apache::loncommon::copyrightids)).
                               &relatedfield(0,$relatedsearchflag,$relatedsep);                                &relatedfield(0,$relatedsearchflag,$relatedsep);
Line 677  sub prettyinput { Line 681  sub prettyinput {
     # Source Copyright      # Source Copyright
     if ($type eq 'sourceavail') {      if ($type eq 'sourceavail') {
  return &selectbox($fieldname,   return &selectbox($fieldname,
   $value,    $value,'',
   \&Apache::loncommon::source_copyrightdescription,    \&Apache::loncommon::source_copyrightdescription,
   (&Apache::loncommon::source_copyrightids)).    (&Apache::loncommon::source_copyrightids)).
                               &relatedfield(0,$relatedsearchflag,$relatedsep);                                &relatedfield(0,$relatedsearchflag,$relatedsep);
Line 704  sub prettyinput { Line 708  sub prettyinput {
     }      }
     # Customdistribution file      # Customdistribution file
     if ($type eq 'customdistributionfile') {      if ($type eq 'customdistributionfile') {
  return '<input type="text" name="'.$fieldname.          my $disabled;
     '" size="60" value="'.$value.'" /><a href="javascript:openbrowser'.          if ($readonly) {
     "('".$formname."','".$fieldname."'".              $disabled = ' disabled="disabled"';
     ",'rights')\">".&mt('Select').'</a>'.          }
             &relatedfield(0,$relatedsearchflag,$relatedsep);           my $output;
    $output = '<input type="text" name="'.$fieldname.
       '" size="60" value="'.$value.'"'.$disabled.' />';
           unless ($readonly) {
               $output .= '<a href="javascript:openbrowser'.
                  "('".$formname."','".$fieldname."'".
                  ",'rights')\">".&mt('Select').'</a>';
           }
           $output .= &relatedfield(0,$relatedsearchflag,$relatedsep);
           return $output;
     }      }
     # Source Customdistribution file      # Source Customdistribution file
     if ($type eq 'sourcerights') {      if ($type eq 'sourcerights') {
Line 763  sub pageheader { Line 776  sub pageheader {
 sub handler {  sub handler {
     my $r=shift;      my $r=shift;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
          ['currentpath','changecourse']);           ['currentpath','changecourse','modal']);
     my $uri=$r->uri;      my $uri=$r->uri;
     #      #
     # Set document type      # Set document type
Line 778  sub handler { Line 791  sub handler {
   
     if ($env{'request.state'} eq 'construct') {      if ($env{'request.state'} eq 'construct') {
         &Apache::lonhtmlcommon::add_breadcrumb({          &Apache::lonhtmlcommon::add_breadcrumb({
             'text'  => 'Construction Space',              'text'  => 'Authoring Space',
             'href'  => &Apache::loncommon::authorspace($uri),              'href'  => &Apache::loncommon::authorspace($uri),
         });          });
     }      }
Line 829  sub handler { Line 842  sub handler {
         $r->print(&pageheader());          $r->print(&pageheader());
         &present_editable_metadata($r,$uri,'groups');              &present_editable_metadata($r,$uri,'groups');    
     } elsif ($uri=~m|^/priv|) {       } elsif ($uri=~m|^/priv|) { 
         # Construction space          # Authoring space
         &Apache::lonhtmlcommon::add_breadcrumb({          &Apache::lonhtmlcommon::add_breadcrumb({
             'text'  => 'Edit Metadata',              'text'  => 'Edit Metadata',
             'href'  => '',              'href'  => '',
Line 854  sub handler { Line 867  sub handler {
                 'only_body' => 1,})                  'only_body' => 1,})
            .'<h1>'.&mt('Metadata').'</h1>'             .'<h1>'.&mt('Metadata').'</h1>'
         );          );
           if ($env{'form.modal'}) {
               my $width = 500;
               my $height = 400;
               my $machine = &Apache::lonnet::absolute_url();
               $r->print(&Apache::loncommon::nicescroll_javascript('metadatawrapper',
                                                                   {cursorcolor => '#00F',
                                                                    railalign => 'right',
                                                                    railoffset => '{top:5,left:40}'},
                                                                    undef,1,$machine.$uri));
               $r->print('<div id="metadatawrapper" style="height:'.$height.'px; width:'.$width.'px; overflow: auto;">');
           }
         &present_uneditable_metadata($r,$uri);          &present_uneditable_metadata($r,$uri);
           if ($env{'form.modal'}) {
               $r->print('</div>');
           }
     }      }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
     return OK;      return OK;
Line 1122  sub print_dynamic_metadata { Line 1149  sub print_dynamic_metadata {
         if (exists($dynmeta{'stats'})) {          if (exists($dynmeta{'stats'})) {
             my $table=&Apache::loncommon::start_data_table()              my $table=&Apache::loncommon::start_data_table()
                      .&Apache::loncommon::start_data_table_header_row()                       .&Apache::loncommon::start_data_table_header_row()
        .'<th>'.&mt('Domain').'</th>'
                      .'<th>'.&mt('Course').'</th>'                       .'<th>'.&mt('Course').'</th>'
                      .'<th>'.&mt('Section(s)').'</th>'                       .'<th>'.&mt('Section(s)').'</th>'
                      .'<th>'.&mt('Num Students').'</th>'                       .'<th>'.&mt('Num Students').'</th>'
Line 1142  sub print_dynamic_metadata { Line 1170  sub print_dynamic_metadata {
                     next;                      next;
                 }                  }
                 $table .= &Apache::loncommon::start_data_table_row();                  $table .= &Apache::loncommon::start_data_table_row();
    $table .=
       '<td><span class="LC_nobreak">'.$courseinfo{'domain'}.'</span></td>';
                 $table .=                   $table .= 
                     '<td><span class="LC_nobreak">'.$courseinfo{'description'}.'</span></td>';                      '<td><span class="LC_nobreak">'.$courseinfo{'description'}.'</span></td>';
                 $table .=                   $table .= 
Line 1292  sub print_dynamic_metadata { Line 1322  sub print_dynamic_metadata {
 #####################################################  #####################################################
 sub present_editable_metadata {  sub present_editable_metadata {
     my ($r,$uri,$file_type) = @_;      my ($r,$uri,$file_type) = @_;
     # Construction Space Call      # Authoring Space Call
     # Header      # Header
     my $disuri=$uri;      my $disuri=$uri;
       my ($courseauthor,$crsaurights,$readonly);
       if ($env{'request.course.id'}) {
           my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
           if ($uri =~ m{^\Q/priv/$cdom/$cnum/\E}) {
               $courseauthor = $cnum.':'.$cdom;
               $crsaurights = "/res/$cdom/$cnum/default.rights";
               $readonly = 1;
           }
       }
     my $fn=&Apache::lonnet::filelocation('',$uri);      my $fn=&Apache::lonnet::filelocation('',$uri);
     $disuri=~s{^/\~}{/priv/};      $disuri=~s{^/\~}{/priv/};
     $disuri=~s/\.meta$//;      $disuri=~s/\.meta$//;
Line 1456  ENDEDIT Line 1496  ENDEDIT
        'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',         'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
        'obsolete','obsoletereplacement');         'obsolete','obsoletereplacement');
         }          }
           if ($courseauthor) {
               $Apache::lonpublisher::metadatafields{'copyright'}='custom';
               $Apache::lonpublisher::metadatafields{'customdistributionfile'}=$crsaurights;
           }
         if (! $Apache::lonpublisher::metadatafields{'copyright'}) {          if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
                 $Apache::lonpublisher::metadatafields{'copyright'}=                  $Apache::lonpublisher::metadatafields{'copyright'}=
     'default';      'default';
Line 1537  ENDEDIT Line 1581  ENDEDIT
                     $output .= &Apache::lonhtmlcommon::row_title($lt{$field_name})                      $output .= &Apache::lonhtmlcommon::row_title($lt{$field_name})
                               .&prettyinput($field_name,                                .&prettyinput($field_name,
    $Apache::lonpublisher::metadatafields{$field_name},     $Apache::lonpublisher::metadatafields{$field_name},
                     'new_'.$field_name,'defaultmeta',                      $readonly,'new_'.$field_name,'defaultmeta',
                     undef,undef,undef,undef,                      undef,undef,undef,undef,
                                                     $Apache::lonpublisher::metadatafields{'courserestricted'});                                                      $Apache::lonpublisher::metadatafields{'courserestricted'});
                     $output .= &Apache::lonhtmlcommon::row_closure($rowcount == $last?1:0);                      $output .= &Apache::lonhtmlcommon::row_closure($rowcount == $last?1:0);
                  }                   }
             } else {              } else {
   
                     $output .= &Apache::lonhtmlcommon::row_title($lt{$field_name})                      $output .= &Apache::lonhtmlcommon::row_title($lt{$field_name})
                               .&prettyinput($field_name,                                .&prettyinput($field_name,
    $Apache::lonpublisher::metadatafields{$field_name},     $Apache::lonpublisher::metadatafields{$field_name},
                                            'new_'.$field_name,'defaultmeta')                                             $readonly,'new_'.$field_name,'defaultmeta')
                               .&Apache::lonhtmlcommon::row_closure($rowcount == $last?1:0);                                .&Apache::lonhtmlcommon::row_closure($rowcount == $last?1:0);
                                 
             }              }

Removed from v.1.250  
changed lines
  Added in v.1.255


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