'.join("\n",map {
- my $url = &Apache::lonnet::clutter($_);
+ return '
'.join("\n",map {
+ my $url = &Apache::lonnet::clutter_with_no_wrapper($_);
my $title = &Apache::lonnet::gettitle($url);
if ($title eq '') {
$title = 'Untitled';
@@ -406,18 +537,26 @@ sub prettyprint {
# List of courses
if ($type=~/\_list/) {
my @Courses = split(/\s*\,\s*/,$value);
- my $Str;
+ my $Str='
';
+ my %descriptions;
foreach my $course (@Courses) {
- my %courseinfo = &Apache::lonnet::coursedescription($course);
+ my %courseinfo =
+ &Apache::lonnet::coursedescription($course,
+ {'one_time' => 1});
if (! exists($courseinfo{'num'}) || $courseinfo{'num'} eq '') {
next;
}
- if ($Str ne '') { $Str .= ' '; }
- $Str .= ''.
- $courseinfo{'description'}.'';
+ $courseinfo{'description'}.' ('.$courseinfo{'domain'}.
+ ')';
}
- return $Str;
+ foreach my $course (sort {lc($a) cmp lc($b)} (keys(%descriptions))) {
+ $Str .= $descriptions{$course};
+ }
+
+ return $Str.'
';
}
# No pretty print found
return $value;
@@ -461,10 +600,81 @@ sub relatedfield {
sub prettyinput {
my ($type,$value,$fieldname,$formname,
- $relatedsearchflag,$relatedsep,$relatedvalue,$size)=@_;
+ $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 {
+ if ($item ne '') {
+ $cur_values_stu .= $item.',';
+ }
+ }
+ }
+ $cur_values_stu =~ s/,$//;
+ my @key_order = sort(keys(%meta_options));
+ unshift(@key_order,'');
+ $meta_options{''} = 'Not specified';
+ $meta_options{'select_form_order'} = \@key_order;
+ } 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')
+ || (exists($env{$course_key.'.metadata.'.$type.'.added'}))) {
+
+ 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,
@@ -525,6 +735,11 @@ sub prettyinput {
",'rights')\">".&mt('Select').''.
&relatedfield(0,$relatedsearchflag,$relatedsep);
}
+ if ($type eq 'courserestricted') {
+ return (&select_course());
+ #return ('');
+ }
+
# Dates
if (($type eq 'creationdate') ||
($type eq 'lastrevisiondate')) {
@@ -547,45 +762,61 @@ sub prettyinput {
# Main Handler
sub handler {
my $r=shift;
- #
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['currentpath','changecourse']);
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+)\//);
- my $html=&Apache::lonxml::xmlbegin();
- $r->print($html.''.
- 'Catalog Information'.
- '');
+ (&Apache::lonnet::declutter($uri)=~/^($match_domain)\/($match_username)\//);
if ($uri=~m:/adm/bombs/(.*)$:) {
- $r->print(&Apache::loncommon::bodytag('Error Messages'));
+ $r->print(&Apache::loncommon::start_page('Error Messages'));
# Looking for all bombs?
&report_bombs($r,$uri);
- } elsif ($uri=~/\/portfolio\//) {
- $r->print(&Apache::loncommon::bodytag
- ('Edit Portfolio File Information','','','',$resdomain));
- if ($env{'form.metacourse'}) {
- &present_instructor_metadata($r,$uri,'portfolio');
- } else {
+ } elsif ($uri=~m|^/editupload/[^/]+/[^/]+/portfolio/|) {
+ ($resdomain,$resuser)=
+ (&Apache::lonnet::declutter($uri)=~m|^($match_domain)/($match_name)/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');
- &select_course($r);
+ } else {
+ my $fn=&Apache::lonnet::filelocation('',$uri);
+ %Apache::lonpublisher::metadatafields=();
+ %Apache::lonpublisher::metadatakeys=();
+ my $result=&Apache::lonnet::getfile($fn);
+ &Apache::lonpublisher::metaeval($result);
+ if ((!$Apache::lonpublisher::metadatafields{'courserestricted'}) ||
+ ($env{'form.changecourse'} eq 'true')) {
+ &pre_select_course($r,$uri);
+ } else {
+ &present_editable_metadata($r,$uri,'portfolio');
+ }
}
-
- } elsif ($uri=~/^\/\~/) {
+ } elsif ($uri=~m|^/editupload/[^/]+/[^/]+/groups/|) {
+ $r->print(&Apache::loncommon::start_page('Edit Group Portfolio File Catalog Information',
+ undef,
+ {'domain' => $resdomain,}));
+ &present_editable_metadata($r,$uri,'groups');
+ } elsif ($uri=~m|^/~|) {
# Construction space
- $r->print(&Apache::loncommon::bodytag
- ('Edit Catalog Information','','','',$resdomain));
+ $r->print(&Apache::loncommon::start_page('Edit Catalog Information',
+ "\n".'',
+ {'domain' => $resdomain,}));
&present_editable_metadata($r,$uri);
} else {
- $r->print(&Apache::loncommon::bodytag
- ('Catalog Information','','','',$resdomain));
+ $r->print(&Apache::loncommon::start_page('Catalog Information',
+ undef,
+ {'domain' => $resdomain,}));
&present_uneditable_metadata($r,$uri);
}
- $r->print('