Copyright/Distribution
-$content{'copyright'}
+sub prettyinput {
+ my ($type,$value,$fieldname,$formname,
+ $relatedsearchflag,$relatedsep,$relatedvalue,$size,$course_key)=@_;
+ if (! defined($size)) {
+ $size = 80;
+ }
+ my $output;
+ if (defined($course_key)
+ && exists($env{$course_key.'.metadata.'.$type.'.options'})) {
+ my $stu_add;
+ my $only_one;
+ my %meta_options;
+ my @cur_values_inst;
+ my $cur_values_stu;
+ my $values = $env{$course_key.'.metadata.'.$type.'.values'};
+ if ($env{$course_key.'.metadata.'.$type.'.options'} =~ m/stuadd/) {
+ $stu_add = 'true';
+ }
+ if ($env{$course_key.'.metadata.'.$type.'.options'} =~ m/onlyone/) {
+ $only_one = 'true';
+ }
+ # need to take instructor values out of list where instructor and student
+ # values may be mixed.
+ if ($values) {
+ foreach my $item (split(/,/,$values)) {
+ $item =~ s/^\s+//;
+ $meta_options{$item} = $item;
+ }
+ foreach my $item (split(/,/,$value)) {
+ $item =~ s/^\s+//;
+ if ($meta_options{$item}) {
+ push(@cur_values_inst,$item);
+ } else {
+ $cur_values_stu .= $item.',';
+ }
+ }
+ } else {
+ $cur_values_stu = $value;
+ }
+ if ($type eq 'courserestricted') {
+ return (&select_course());
+ # return (' ');
+ }
+ if (($type eq 'keywords') || ($type eq 'subject')
+ || ($type eq 'author')||($type eq 'notes')
+ || ($type eq 'abstract')|| ($type eq 'title')|| ($type eq 'standards')) {
+ if ($values) {
+ if ($only_one) {
+ $output .= (&Apache::loncommon::select_form($cur_values_inst[0],'new_'.$type,%meta_options));
+ } else {
+ $output .= (&Apache::loncommon::multiple_select_form('new_'.$type,\@cur_values_inst,undef,\%meta_options));
+ }
+ }
+ if ($stu_add) {
+ $output .= ' '.
+ &relatedfield(1,$relatedsearchflag,$relatedsep,$fieldname,
+ $relatedvalue);
+ }
+ return ($output);
+ }
+ if (($type eq 'lowestgradelevel') ||
+ ($type eq 'highestgradelevel')) {
+ return &Apache::loncommon::select_level_form($value,$fieldname).
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
+ }
+ return();
+ }
+ # Language
+ if ($type eq 'language') {
+ return &selectbox($fieldname,
+ $value,
+ \&Apache::loncommon::languagedescription,
+ (&Apache::loncommon::languageids)).
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
+ }
+ # Copyright
+ if ($type eq 'copyright') {
+ return &selectbox($fieldname,
+ $value,
+ \&Apache::loncommon::copyrightdescription,
+ (&Apache::loncommon::copyrightids)).
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
+ }
+ # Source Copyright
+ if ($type eq 'sourceavail') {
+ return &selectbox($fieldname,
+ $value,
+ \&Apache::loncommon::source_copyrightdescription,
+ (&Apache::loncommon::source_copyrightids)).
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
+ }
+ # Gradelevels
+ if (($type eq 'lowestgradelevel') ||
+ ($type eq 'highestgradelevel')) {
+ return &Apache::loncommon::select_level_form($value,$fieldname).
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
+ }
+ # Obsolete
+ if ($type eq 'obsolete') {
+ return ' '.
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
+ }
+ # Obsolete replacement file
+ if ($type eq 'obsoletereplacement') {
+ return '".&mt('Select').' '.
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
+ }
+ # Customdistribution file
+ if ($type eq 'customdistributionfile') {
+ return '".&mt('Select').' '.
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
+ }
+ # Source Customdistribution file
+ if ($type eq 'sourcerights') {
+ return '".&mt('Select').' '.
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
+ }
+ if ($type eq 'courserestricted') {
+ return (&select_course());
+ #return (' ');
+ }
+
+ # Dates
+ if (($type eq 'creationdate') ||
+ ($type eq 'lastrevisiondate')) {
+ return
+ &Apache::lonhtmlcommon::date_setter($formname,$fieldname,$value).
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
+ }
+ # No pretty input found
+ $value=~s/^\s+//gs;
+ $value=~s/\s+$//gs;
+ $value=~s/\s+/ /gs;
+ $value=~s/\"/\"\;/gs;
+ return
+ ' '.
+ &relatedfield(1,$relatedsearchflag,$relatedsep,$fieldname,
+ $relatedvalue);
+}
+
+# Main Handler
+sub handler {
+ my $r=shift;
+ #
+ my $uri=$r->uri;
+ #
+ # Set document type
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ return OK if $r->header_only;
+ #
+ my ($resdomain,$resuser)=
+ (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);
+
+ if ($uri=~m:/adm/bombs/(.*)$:) {
+ $r->print(&Apache::loncommon::start_page('Error Messages'));
+ # Looking for all bombs?
+ &report_bombs($r,$uri);
+ } elsif ($uri=~/\/portfolio\//) {
+ ($resdomain,$resuser)=
+ (&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|);
+ $r->print(&Apache::loncommon::start_page('Edit Portfolio File Catalog Information',
+ undef,
+ {'domain' => $resdomain,}));
+ if ($env{'form.store'}) {
+ &present_editable_metadata($r,$uri,'portfolio');
+ } else {
+ &pre_select_course($r,$uri);
+ }
+ } elsif ($uri=~/^\/\~/) {
+ # Construction space
+ $r->print(&Apache::loncommon::start_page('Edit Catalog nformation',
+ undef,
+ {'domain' => $resdomain,}));
+ &present_editable_metadata($r,$uri);
+ } else {
+ $r->print(&Apache::loncommon::start_page('Catalog Information',
+ undef,
+ {'domain' => $resdomain,}));
+ &present_uneditable_metadata($r,$uri);
+ }
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+}
+
+#####################################################
+#####################################################
+### ###
+### Report Bombs ###
+### ###
+#####################################################
+#####################################################
+sub report_bombs {
+ my ($r,$uri) = @_;
+ # Set document type
+ $uri =~ s:/adm/bombs/::;
+ $uri = &Apache::lonnet::declutter($uri);
+ $r->print(''.&Apache::lonnet::clutter($uri).' ');
+ my ($domain,$author)=($uri=~/^(\w+)\/(\w+)\//);
+ if (&Apache::loncacc::constructaccess('/~'.$author.'/',$domain)) {
+ if ($env{'form.clearbombs'}) {
+ &Apache::lonmsg::clear_author_res_msg($uri);
+ }
+ my $clear=&mt('Clear all Messages in Subdirectory');
+ $r->print(<
+
+
+ENDCLEAR
+ my %brokenurls =
+ &Apache::lonmsg::all_url_author_res_msg($author,$domain);
+ foreach (sort(keys(%brokenurls))) {
+ if ($_=~/^\Q$uri\E/) {
+ $r->print
+ (''.$_.' '.
+ &Apache::lonmsg::retrieve_author_res_msg($_).
+ ' ');
+ }
+ }
+ } else {
+ $r->print(&mt('Not authorized'));
+ }
+ return;
+}
+
+#####################################################
+#####################################################
+### ###
+### Uneditable Metadata Display ###
+### ###
+#####################################################
+#####################################################
+sub present_uneditable_metadata {
+ my ($r,$uri) = @_;
+ #
+ my %content=();
+ # Read file
+ foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
+ $content{$_}=&Apache::lonnet::metadata($uri,$_);
+ }
+ # Render Output
+ # displayed url
+ my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/);
+ $uri=~s/\.meta$//;
+ my $disuri=&Apache::lonnet::clutter($uri);
+ $disuri=~s/^\/adm\/wrapper//;
+ # version
+ my $currentversion=&Apache::lonnet::getversion($disuri);
+ my $versiondisplay='';
+ if ($thisversion) {
+ $versiondisplay=&mt('Version').': '.$thisversion.
+ ' ('.&mt('most recent version').': '.
+ ($currentversion>0 ?
+ $currentversion :
+ &mt('information not available')).')';
+ } else {
+ $versiondisplay='Version: '.$currentversion;
+ }
+ # crumbify displayed URL uri target prefix form size
+ $disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef,'+1');
+ $disuri =~ s: ::g;
+ # obsolete
+ my $obsolete=$content{'obsolete'};
+ my $obsoletewarning='';
+ if (($obsolete) && ($env{'user.adv'})) {
+ $obsoletewarning=''.
+ &mt('This resource has been marked obsolete by the author(s)').
+ '
';
+ }
+ #
+ my %lt=&fieldnames();
+ my $table='';
+ my $title = $content{'title'};
+ if (! defined($title)) {
+ $title = 'Untitled Resource';
+ }
+ foreach ('title',
+ 'author',
+ 'subject',
+ 'keywords',
+ 'notes',
+ 'abstract',
+ 'lowestgradelevel',
+ 'highestgradelevel',
+ 'standards',
+ 'mime',
+ 'language',
+ 'creationdate',
+ 'lastrevisiondate',
+ 'owner',
+ 'copyright',
+ 'customdistributionfile',
+ 'sourceavail',
+ 'sourcerights',
+ 'obsolete',
+ 'obsoletereplacement') {
+ $table.=''.$lt{$_}.
+ ' '.
+ &prettyprint($_,$content{$_}).' ';
+ delete $content{$_};
+ }
+ #
+ $r->print(<$title
+
+$disuri
+$obsoletewarning
+$versiondisplay
+
+
ENDHEAD
- delete($content{'title'});
- delete($content{'author'});
- delete($content{'subject'});
- delete($content{'keywords'});
- delete($content{'notes'});
- delete($content{'abstract'});
- delete($content{'mime'});
- delete($content{'language'});
- delete($content{'creationdate'});
- delete($content{'lastrevisiondate'});
- delete($content{'owner'});
- delete($content{'copyright'});
- if ($ENV{'user.adv'}) {
-# ------------------------------------------------------------ Dynamic Metadata
- $r->print('Dynamic Metadata (updated periodically) ');
- my %items=(
- 'count' => 'Network-wide number of accesses (hits)',
- 'course' => 'Network-wide number of courses using resource',
- 'usage' => 'Number of resources using or importing resource',
- 'clear' => 'Material presented in clear way',
- 'depth' => 'Material covered with sufficient depth',
- 'helpful' => 'Material is helpful',
- 'correct' => 'Material appears to be correct',
- 'technical' => 'Resource is technically correct',
- 'avetries' => 'Average number of tries till solved',
- 'stdno' => 'Total number of students who have worked on this problem',
- 'difficulty' => 'Degree of difficulty');
- my %dynmeta=&dynamicmeta($uri);
- $r->print(
-'