--- loncom/interface/lonmeta.pm 2005/03/17 21:32:17 1.94 +++ loncom/interface/lonmeta.pm 2005/10/25 18:46:03 1.117 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.94 2005/03/17 21:32:17 banghart Exp $ +# $Id: lonmeta.pm,v 1.117 2005/10/25 18:46:03 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -17,7 +17,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # @@ -31,9 +31,9 @@ package Apache::lonmeta; use strict; use LONCAPA::lonmetadata(); use Apache::Constants qw(:common); -use Apache::lonnet(); +use Apache::lonnet; use Apache::loncommon(); -use Apache::lonhtmlcommon(); +use Apache::lonhtmlcommon(); use Apache::lonmsg; use Apache::lonpublisher; use Apache::lonlocal; @@ -288,6 +288,42 @@ sub fieldnames { return &Apache::lonlocal::texthash(%fields); } +sub select_course { + my ($r)=@_; + my %courses; + foreach my $key (keys (%env)) { + if ($key =~ m/\.metadata\./) { + $key =~ m/^course\.(.+)(\.metadata.+$)/; + my $course = $1; + my $coursekey = 'course.'.$course.'.description'; + my $value = $env{$coursekey}; + $courses{$coursekey} = $value; + } + } + $r->print('
'. &mt('This resource has been marked obsolete by the author(s)'). '
'; @@ -681,7 +757,7 @@ $versiondisplay $table ENDHEAD - if ($ENV{'user.adv'}) { + if ($env{'user.adv'}) { &print_dynamic_metadata($r,$uri,\%content); } return; @@ -822,8 +898,8 @@ sub print_dynamic_metadata { $r->print(''.$lt{$_}.': '. - &prettyinput($_, + if ($env{'form.metacourse'}) { + # handle restrictions here + $env{'form.metacourse'} =~ m/(^.+)\.description$/; + my $key_base = $1; + if ($env{$key_base.'.metadata.'.$_.'.options'} =~ m/active/) { + $output.=('
'.$lt{$_}.': '. + &prettyinput($_, + $Apache::lonpublisher::metadatafields{$_}, + 'new_'.$_,'defaultmeta',undef,undef,undef,undef,$key_base).'
'); + } + } else { + $output.=(''.$lt{$_}.': '. + &prettyinput($_, $Apache::lonpublisher::metadatafields{$_}, 'new_'.$_,'defaultmeta').'
'); + } } - if ($ENV{'form.store'}) { + if ($env{'form.store'}) { my $mfh; - my $formname='store'; + my $formname='store'; my $file_content; + foreach my $meta_field (keys %env) { + if (&Apache::loncommon::get_env_multiple('form.keywords')) { + $Apache::lonpublisher::metadatafields{'coursekeyword'} = + join (', ', &Apache::loncommon::get_env_multiple('form.keywords')); + } + } foreach (sort keys %Apache::lonpublisher::metadatafields) { next if ($_ =~ /\./); my $unikey=$_; @@ -989,11 +1106,10 @@ ENDEDIT if ($fn =~ /\/portfolio\//) { $fn =~ /\/portfolio\/(.*)$/; my $new_fn = '/'.$1; - $ENV{'form.'.$formname}=$file_content; - $ENV{'form.'.$formname.'.filename'}=$new_fn; + $env{'form.'.$formname}=$file_content; + $env{'form.'.$formname.'.filename'}=$new_fn; &Apache::lonnet::userfileupload('uploaddoc','', - 'portfolio'.$ENV{'form.currentpath'}); - my $status =&Apache::lonnet::userfileupload($formname,'','portfolio'); + 'portfolio'.$env{'form.currentpath'}); if (&Apache::lonnet::userfileupload($formname,'','portfolio') eq 'error: no uploaded file') { $r->print(''. &mt('Could not write metadata').', '. @@ -1010,6 +1126,9 @@ ENDEDIT &mt('FAIL').'
'); } else { print $mfh $file_content; + $r->print(''.&mt('Wrote Metadata'). + ' '.&Apache::lonlocal::locallocaltime(time). + '
'); } } } @@ -1022,3 +1141,5 @@ ENDEDIT 1; __END__ + +