[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 21 May 2004 19:27:02 -0000
This is a MIME encoded message
--albertel1085167622
Content-Type: text/plain
albertel Fri May 21 15:27:02 2004 EDT
Modified files:
/loncom/publisher lonpublisher.pm
Log:
-BUG#2994 at least
- directory publication was not correctly setting some values, like dependencies, gradelevel, MIME TYPE, etc. fixed by removving the 2 code paths and rather just haveiong the one path work for both modes, probably easier to maintian that way
--albertel1085167622
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20040521152702.txt"
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.166 loncom/publisher/lonpublisher.pm:1.167
--- loncom/publisher/lonpublisher.pm:1.166 Wed Apr 14 14:29:32 2004
+++ loncom/publisher/lonpublisher.pm Fri May 21 15:27:02 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.166 2004/04/14 18:29:32 matthew Exp $
+# $Id: lonpublisher.pm,v 1.167 2004/05/21 19:27:02 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -322,6 +322,7 @@
$value=~s/\s+$//gs;
$value=~s/\s+/ /gs;
$title=&mt($title);
+ $ENV{'form.'.$name}=$value;
return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$title:".
"</b></font></p><br />".
'<input type="text" name="'.$name.'" size=80 value="'.$value.'" />';
@@ -329,6 +330,7 @@
sub hiddenfield {
my ($name,$value)=@_;
+ $ENV{'form.'.$name}=$value;
return "\n".'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}
@@ -336,6 +338,11 @@
my ($title,$name,$value,$functionref,@idlist)=@_;
$title=&mt($title);
$value=(split(/\s*,\s*/,$value))[-1];
+ if (defined($value)) {
+ $ENV{'form.'.$name}=$value;
+ } else {
+ $ENV{'form.'.$name}=$idlist[0];
+ }
my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$title:".
'</b></font></p><br /><select name="'.$name.'">';
foreach (@idlist) {
@@ -348,6 +355,12 @@
return $selout.'</select>';
}
+sub select_level_form {
+ my ($value,$name)=@_;
+ $ENV{'form.'.$name}=$value;
+ if (!defined($value)) { $ENV{'form.'.$name}=0; }
+ return &Apache::loncommon::select_level_form($value,$name);
+}
#########################################
#########################################
@@ -1094,27 +1107,30 @@
}
# --------------------------------------------------- Now we also have keywords
# =============================================================================
-# INTERACTIVE MODE
-#
- unless ($batch) {
- $scrout.=
- '<form name="pubform" action="/adm/publish" method="post">'.
- '<p><input type="submit" value="'.&mt('Finalize Publication').'" /></p>'.
- &hiddenfield('phase','two').
- &hiddenfield('filename',$ENV{'form.filename'}).
- &hiddenfield('allmeta',&Apache::lonnet::escape($allmeta)).
- &hiddenfield('dependencies',join(',',keys %allow)).
- &textfield('Title','title',$metadatafields{'title'}).
- &textfield('Author(s)','author',$metadatafields{'author'}).
- &textfield('Subject','subject',$metadatafields{'subject'});
+# interactive mode html goes into $intr_scrout
+# batch mode throws away this HTML
+# additionally all of the field functions have a by product of setting
+# $ENV{'from.'..} so that it can be used by the phase two handler in
+# batch mode
+
+ my $intr_scrout.=
+ '<form name="pubform" action="/adm/publish" method="post">'.
+ '<p><input type="submit" value="'.&mt('Finalize Publication').'" /></p>'.
+ &hiddenfield('phase','two').
+ &hiddenfield('filename',$ENV{'form.filename'}).
+ &hiddenfield('allmeta',&Apache::lonnet::escape($allmeta)).
+ &hiddenfield('dependencies',join(',',keys %allow)).
+ &textfield('Title','title',$metadatafields{'title'}).
+ &textfield('Author(s)','author',$metadatafields{'author'}).
+ &textfield('Subject','subject',$metadatafields{'subject'});
# --------------------------------------------------- Scan content for keywords
- my $keywords_help = Apache::loncommon::help_open_topic("Publishing_Keywords");
- my $KEYWORDS=&mt('Keywords');
- my $CheckAll=&mt('check all');
- my $UncheckAll=&mt('uncheck all');
- my $keywordout=<<"END";
+ my $keywords_help = Apache::loncommon::help_open_topic("Publishing_Keywords");
+ my $KEYWORDS=&mt('Keywords');
+ my $CheckAll=&mt('check all');
+ my $UncheckAll=&mt('uncheck all');
+ my $keywordout=<<"END";
<script>
function checkAll(field) {
for (i = 0; i < field.length; i++)
@@ -1133,97 +1149,100 @@
</p>
<br />
END
- $keywordout.='<table border="2"><tr>';
- my $colcount=0;
+ $keywordout.='<table border="2"><tr>';
+ my $colcount=0;
- foreach (sort keys %keywords) {
- $keywordout.='<td><input type="checkbox" name="keywords" value="'.$_.'"';
- if ($metadatafields{'keywords'}) {
- if ($metadatafields{'keywords'}=~/\Q$_\E/) {
- $keywordout.=' checked="on"';
- }
- } elsif (&Apache::loncommon::keyword($_)) {
+ foreach (sort keys %keywords) {
+ $keywordout.='<td><input type="checkbox" name="keywords" value="'.$_.'"';
+ if ($metadatafields{'keywords'}) {
+ if ($metadatafields{'keywords'}=~/\Q$_\E/) {
$keywordout.=' checked="on"';
+ $ENV{'form.keywords'}.=$_.',';
}
- $keywordout.=' />'.$_.'</td>';
- if ($colcount>10) {
- $keywordout.="</tr><tr>\n";
- $colcount=0;
- }
- $colcount++;
+ } elsif (&Apache::loncommon::keyword($_)) {
+ $keywordout.=' checked="on"';
+ $ENV{'form.keywords'}.=$_.',';
+ }
+ $keywordout.=' />'.$_.'</td>';
+ if ($colcount>10) {
+ $keywordout.="</tr><tr>\n";
+ $colcount=0;
}
+ $colcount++;
+ }
+ $ENV{'form.keywords'}=~s/\,$//;
- $keywordout.='</tr></table>';
+ $keywordout.='</tr></table>';
- $scrout.=$keywordout;
+ $intr_scrout.=$keywordout;
- $scrout.=&textfield('Additional Keywords','addkey','');
+ $intr_scrout.=&textfield('Additional Keywords','addkey','');
- $scrout.=&textfield('Notes','notes',$metadatafields{'notes'});
+ $intr_scrout.=&textfield('Notes','notes',$metadatafields{'notes'});
- $scrout.=
- "\n<p><font color=\"#800000\" face=\"helvetica\"><b>".&mt('Abstract').":".
- "</b></font></p><br />".
- '<textarea cols="80" rows="5" name="abstract">'.
- $metadatafields{'abstract'}.'</textarea></p>';
+ $intr_scrout.=
+ "\n<p><font color=\"#800000\" face=\"helvetica\"><b>".&mt('Abstract').":".
+ "</b></font></p><br />".
+ '<textarea cols="80" rows="5" name="abstract">'.
+ $metadatafields{'abstract'}.'</textarea></p>';
- $source=~/\.(\w+)$/;
+ $source=~/\.(\w+)$/;
- $scrout.=
- "\n<p><font color=\"#800000\" face=\"helvetica\"><b>".
- &mt('Lowest Grade Level').':'.
- "</b></font></p><br />".
- &Apache::loncommon::select_level_form($metadatafields{'lowestgradelevel'},'lowestgradelevel').
- "\n<p><font color=\"#800000\" face=\"helvetica\"><b>".
- &mt('Highest Grade Level').':'.
- "</b></font></p><br />".
- &Apache::loncommon::select_level_form($metadatafields{'highestgradelevel'},'highestgradelevel').
- &textfield('Standards','standards',$metadatafields{'standards'});
+ $intr_scrout.=
+ "\n<p><font color=\"#800000\" face=\"helvetica\"><b>".
+ &mt('Lowest Grade Level').':'.
+ "</b></font></p><br />".
+ &select_level_form($metadatafields{'lowestgradelevel'},'lowestgradelevel').
+ "\n<p><font color=\"#800000\" face=\"helvetica\"><b>".
+ &mt('Highest Grade Level').':'.
+ "</b></font></p><br />".
+ &select_level_form($metadatafields{'highestgradelevel'},'highestgradelevel').
+ &textfield('Standards','standards',$metadatafields{'standards'});
- $scrout.=&hiddenfield('mime',$1);
+ $intr_scrout.=&hiddenfield('mime',$1);
- my $defaultlanguage=$metadatafields{'language'};
- $defaultlanguage =~ s/\s*notset\s*//g;
- $defaultlanguage =~ s/^,\s*//g;
- $defaultlanguage =~ s/,\s*$//g;
+ my $defaultlanguage=$metadatafields{'language'};
+ $defaultlanguage =~ s/\s*notset\s*//g;
+ $defaultlanguage =~ s/^,\s*//g;
+ $defaultlanguage =~ s/,\s*$//g;
- $scrout.=&selectbox('Language','language',
- $defaultlanguage,
- \&Apache::loncommon::languagedescription,
- (&Apache::loncommon::languageids),
- );
+ $intr_scrout.=&selectbox('Language','language',
+ $defaultlanguage,
+ \&Apache::loncommon::languagedescription,
+ (&Apache::loncommon::languageids),
+ );
- unless ($metadatafields{'creationdate'}) {
- $metadatafields{'creationdate'}=time;
- }
- $scrout.=&hiddenfield('creationdate',
- &Apache::lonmysql::unsqltime($metadatafields{'creationdate'}));
+ unless ($metadatafields{'creationdate'}) {
+ $metadatafields{'creationdate'}=time;
+ }
+ $intr_scrout.=&hiddenfield('creationdate',
+ &Apache::lonmysql::unsqltime($metadatafields{'creationdate'}));
- $scrout.=&hiddenfield('lastrevisiondate',time);
+ $intr_scrout.=&hiddenfield('lastrevisiondate',time);
- $scrout.=&textfield('Publisher/Owner','owner',
- $metadatafields{'owner'});
+ $intr_scrout.=&textfield('Publisher/Owner','owner',
+ $metadatafields{'owner'});
# -------------------------------------------------- Correct copyright for rat.
- my $defaultoption=$metadatafields{'copyright'};
- unless ($defaultoption) { $defaultoption='default'; }
- unless ($style eq 'prv') {
- if ($style eq 'rat') {
- if ($metadatafields{'copyright'} eq 'public') {
- delete $metadatafields{'copyright'};
- $defaultoption='default';
- }
- $scrout.=&selectbox('Copyright/Distribution','copyright',
- $defaultoption,
- \&Apache::loncommon::copyrightdescription,
+ my $defaultoption=$metadatafields{'copyright'};
+ unless ($defaultoption) { $defaultoption='default'; }
+ unless ($style eq 'prv') {
+ if ($style eq 'rat') {
+ if ($metadatafields{'copyright'} eq 'public') {
+ delete $metadatafields{'copyright'};
+ $defaultoption='default';
+ }
+ $intr_scrout.=&selectbox('Copyright/Distribution','copyright',
+ $defaultoption,
+ \&Apache::loncommon::copyrightdescription,
(grep !/^public$/,(&Apache::loncommon::copyrightids)));
} else {
- $scrout.=&selectbox('Copyright/Distribution','copyright',
+ $intr_scrout.=&selectbox('Copyright/Distribution','copyright',
$defaultoption,
\&Apache::loncommon::copyrightdescription,
(&Apache::loncommon::copyrightids));
@@ -1231,55 +1250,29 @@
my $copyright_help =
Apache::loncommon::help_open_topic('Publishing_Copyright');
- $scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;
- $scrout.=&textfield('Custom Distribution File','customdistributionfile',
+ $intr_scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;
+ $intr_scrout.=&textfield('Custom Distribution File','customdistributionfile',
$metadatafields{'customdistributionfile'}).
$copyright_help;
my $uctitle=&mt('Obsolete');
- $scrout.=
+ $intr_scrout.=
"\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
'</b></font> <input type="checkbox" name="obsolete" ';
if ($metadatafields{'obsolete'}) {
- $scrout.=' checked="1" ';
+ $intr_scrout.=' checked="1" ';
}
- $scrout.='/ ></p>'.
+ $intr_scrout.='/ ></p>'.
&textfield('Suggested Replacement for Obsolete File',
'obsoletereplacement',
$metadatafields{'obsoletereplacement'});
} else {
- $scrout.=&hiddenfield('copyright','private');
+ $intr_scrout.=&hiddenfield('copyright','private');
}
- return ($scrout.'<p><input type="submit" value="'.
- &mt('Finalize Publication').'" /></p></form>',0);
-# =============================================================================
-# BATCH MODE
-#
- } else {
-# Transfer metadata directly to environment for stage 2
- foreach (keys %metadatafields) {
- $ENV{'form.'.$_}=$metadatafields{$_};
- }
- $ENV{'form.addkey'}='';
- $ENV{'form.keywords'}='';
- foreach (keys %keywords) {
- if ($metadatafields{'keywords'}) {
- if ($metadatafields{'keywords'}=~/\Q$_\E/) {
- $ENV{'form.keywords'}.=$_.',';
- }
- } elsif (&Apache::loncommon::keyword($_)) {
- $ENV{'form.keywords'}.=$_.',';
- }
- }
- $ENV{'form.keywords'}=~s/\,$//;
- unless ($ENV{'form.creationdate'}) { $ENV{'form.creationdate'}=time; }
- $ENV{'form.lastrevisiondate'}=time;
- if ((($style eq 'rat') && ($ENV{'form.copyright'} eq 'public')) ||
- (!$ENV{'form.copyright'})) {
- $ENV{'form.copyright'}='default';
- }
- $ENV{'form.allmeta'}=&Apache::lonnet::escape($allmeta);
- return ($scrout,0);
+ if (!$batch) {
+ $scrout.=$intr_scrout.'<p><input type="submit" value="'.
+ &mt('Finalize Publication').'" /></p></form>';
}
+ return($scrout,0);
}
#########################################
@@ -1345,7 +1338,7 @@
%metadatafields=();
%metadatakeys=();
-
+
&metaeval(&Apache::lonnet::unescape($ENV{'form.allmeta'}));
$metadatafields{'title'}=$ENV{'form.title'};
--albertel1085167622--