[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 14 Mar 2003 15:29:46 -0000
This is a MIME encoded message
--albertel1047655786
Content-Type: text/plain
albertel Fri Mar 14 10:29:46 2003 EDT
Modified files:
/loncom/publisher lonpublisher.pm
Log:
nate
eVS: ----------------------------------------------------------------------
--albertel1047655786
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20030314102946.txt"
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.115 loncom/publisher/lonpublisher.pm:1.116
--- loncom/publisher/lonpublisher.pm:1.115 Thu Mar 13 21:26:12 2003
+++ loncom/publisher/lonpublisher.pm Fri Mar 14 10:29:46 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.115 2003/03/14 02:26:12 www Exp $
+# $Id: lonpublisher.pm,v 1.116 2003/03/14 15:29:46 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -957,90 +957,87 @@
}
# ---------------- Find and document discrepancies in the parameters and stores
- my $chparms='';
- foreach (sort keys %metadatafields) {
- if (($_=~/^parameter/) || ($_=~/^stores/)) {
- unless ($_=~/\.\w+$/) {
- unless ($oldparmstores{$_}) {
- print $logfile 'New: '.$_."\n";
- $chparms.=$_.' ';
- }
- }
- }
- }
- if ($chparms) {
- $scrout.='<p><b>New parameters or stored values:</b> '.
- $chparms;
- }
+ my $chparms='';
+ foreach (sort keys %metadatafields) {
+ if (($_=~/^parameter/) || ($_=~/^stores/)) {
+ unless ($_=~/\.\w+$/) {
+ unless ($oldparmstores{$_}) {
+ print $logfile 'New: '.$_."\n";
+ $chparms.=$_.' ';
+ }
+ }
+ }
+ }
+ if ($chparms) {
+ $scrout.='<p><b>New parameters or stored values:</b> '.$chparms;
+ }
- $chparms='';
- foreach (sort keys %oldparmstores) {
- if (($_=~/^parameter/) || ($_=~/^stores/)) {
- unless (($metadatafields{$_.'.name'}) ||
- ($metadatafields{$_.'.package'}) || ($_=~/\.\w+$/)) {
- print $logfile 'Obsolete: '.$_."\n";
- $chparms.=$_.' ';
- }
- }
- }
- if ($chparms) {
- $scrout.='<p><b>Obsolete parameters or stored values:</b> '.
- $chparms;
- }
+ $chparms='';
+ foreach (sort keys %oldparmstores) {
+ if (($_=~/^parameter/) || ($_=~/^stores/)) {
+ unless (($metadatafields{$_.'.name'}) ||
+ ($metadatafields{$_.'.package'}) || ($_=~/\.\w+$/)) {
+ print $logfile 'Obsolete: '.$_."\n";
+ $chparms.=$_.' ';
+ }
+ }
+ }
+ if ($chparms) {
+ $scrout.='<p><b>Obsolete parameters or stored values:</b> '.
+ $chparms;
+ }
# ------------------------------------------------------- Now have all metadata
- my %keywords=();
+ my %keywords=();
- if (length($content)<500000) {
- my $textonly=$content;
- $textonly=~s/\<script[^\<]+\<\/script\>//g;
- $textonly=~s/\<m\>[^\<]+\<\/m\>//g;
- $textonly=~s/\<[^\>]*\>//g;
- $textonly=~tr/A-Z/a-z/;
- $textonly=~s/[\$\&][a-z]\w*//g;
- $textonly=~s/[^a-z\s]//g;
-
- foreach ($textonly=~m/(\w+)/g) {
- unless ($nokey{$_}) {
- $keywords{$_}=1;
- }
- }
- }
+ if (length($content)<500000) {
+ my $textonly=$content;
+ $textonly=~s/\<script[^\<]+\<\/script\>//g;
+ $textonly=~s/\<m\>[^\<]+\<\/m\>//g;
+ $textonly=~s/\<[^\>]*\>//g;
+ $textonly=~tr/A-Z/a-z/;
+ $textonly=~s/[\$\&][a-z]\w*//g;
+ $textonly=~s/[^a-z\s]//g;
+
+ foreach ($textonly=~m/(\w+)/g) {
+ unless ($nokey{$_}) {
+ $keywords{$_}=1;
+ }
+ }
+ }
- foreach (split(/\W+/,$metadatafields{'keywords'})) {
- $keywords{$_}=1;
- }
+ foreach (split(/\W+/,$metadatafields{'keywords'})) {
+ $keywords{$_}=1;
+ }
# --------------------------------------------------- Now we also have keywords
# =============================================================================
# INTERACTIVE MODE
#
- unless ($batch) {
+ unless ($batch) {
$scrout.=
- '<form name="pubform" action="/adm/publish" method="post">'.
- '<p><input type="submit" value="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'});
+ '<form name="pubform" action="/adm/publish" method="post">'.
+ '<p><input type="submit" value="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 $keywordout=<<"END";
<script>
-function checkAll(field)
-{
+function checkAll(field) {
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}
-function uncheckAll(field)
-{
+function uncheckAll(field) {
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
@@ -1049,117 +1046,117 @@
<input type="button" value="check all" onclick="javascript:checkAll(document.pubform.keywords)">
<input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.pubform.keywords)">
<br />
-END
- $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'}=~/$_/) {
- $keywordout.=' checked';
- }
- } elsif (&Apache::loncommon::keyword($_)) {
- $keywordout.=' checked';
- }
- $keywordout.='>'.$_.'</td>';
- if ($colcount>10) {
- $keywordout.="</tr><tr>\n";
- $colcount=0;
- }
- $colcount++;
- }
-
+END
+ $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'}=~/$_/) {
+ $keywordout.=' checked';
+ }
+ } elsif (&Apache::loncommon::keyword($_)) {
+ $keywordout.=' checked';
+ }
+ $keywordout.='>'.$_.'</td>';
+ if ($colcount>10) {
+ $keywordout.="</tr><tr>\n";
+ $colcount=0;
+ }
+ $colcount++;
+ }
+
$keywordout.='</tr></table>';
- $scrout.=$keywordout;
+ $scrout.=$keywordout;
- $scrout.=&textfield('Additional Keywords','addkey','');
+ $scrout.=&textfield('Additional Keywords','addkey','');
- $scrout.=&textfield('Notes','notes',$metadatafields{'notes'});
+ $scrout.=&textfield('Notes','notes',$metadatafields{'notes'});
- $scrout.=
- '<p><b>Abstract:</b><br><textarea cols=80 rows=5 name=abstract>'.
- $metadatafields{'abstract'}.'</textarea>';
+ $scrout.=
+ '<p><b>Abstract:</b><br><textarea cols=80 rows=5 name=abstract>'.
+ $metadatafields{'abstract'}.'</textarea>';
$source=~/\.(\w+)$/;
$scrout.=&hiddenfield('mime',$1);
- $scrout.=&selectbox('Language','language',
- $metadatafields{'language'},
+ $scrout.=&selectbox('Language','language',
+ $metadatafields{'language'},
\&Apache::loncommon::languagedescription,
(&Apache::loncommon::languageids),
- );
+ );
- unless ($metadatafields{'creationdate'}) {
+ unless ($metadatafields{'creationdate'}) {
$metadatafields{'creationdate'}=time;
- }
- $scrout.=&hiddenfield('creationdate',
- &Apache::loncommon::unsqltime($metadatafields{'creationdate'}));
+ }
+ $scrout.=&hiddenfield('creationdate',
+ &Apache::loncommon::unsqltime($metadatafields{'creationdate'}));
+
+ $scrout.=&hiddenfield('lastrevisiondate',time);
- $scrout.=&hiddenfield('lastrevisiondate',time);
-
$scrout.=&textfield('Publisher/Owner','owner',
- $metadatafields{'owner'});
+ $metadatafields{'owner'});
# -------------------------------------------------- Correct copyright for rat.
- unless ($style eq 'prv') {
- if ($style eq 'rat') {
- if ($metadatafields{'copyright'} eq 'public') {
- delete $metadatafields{'copyright'};
+ unless ($style eq 'prv') {
+ if ($style eq 'rat') {
+ if ($metadatafields{'copyright'} eq 'public') {
+ delete $metadatafields{'copyright'};
+ }
+ $scrout.=&selectbox('Copyright/Distribution','copyright',
+ $metadatafields{'copyright'},
+ \&Apache::loncommon::copyrightdescription,
+ (grep !/^public$/,(&Apache::loncommon::copyrightids)));
+ } else {
+ $scrout.=&selectbox('Copyright/Distribution','copyright',
+ $metadatafields{'copyright'},
+ \&Apache::loncommon::copyrightdescription,
+ (&Apache::loncommon::copyrightids));
+ }
+
+ my $copyright_help =
+ Apache::loncommon::help_open_topic('Publishing_Copyright');
+ $scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;
+ $scrout.=&textfield('Custom Distribution File','customdistributionfile',
+ $metadatafields{'customdistributionfile'}).
+ $copyright_help;
+ } else {
+ $scrout.=&hiddenfield('copyright','private');
}
- $scrout.=&selectbox('Copyright/Distribution','copyright',
- $metadatafields{'copyright'},
- \&Apache::loncommon::copyrightdescription,
- (grep !/^public$/,(&Apache::loncommon::copyrightids)));
- } else {
- $scrout.=&selectbox('Copyright/Distribution','copyright',
- $metadatafields{'copyright'},
- \&Apache::loncommon::copyrightdescription,
- (&Apache::loncommon::copyrightids));
- }
-
- my $copyright_help =
- Apache::loncommon::help_open_topic('Publishing_Copyright');
- $scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;
- $scrout.=&textfield('Custom Distribution File','customdistributionfile',
- $metadatafields{'customdistributionfile'}).
- $copyright_help;
- } else {
- $scrout.=&hiddenfield('copyright','private');
- }
- return ($scrout.'<p><input type="submit" value="Finalize Publication" /></p></form>',0);
+ return ($scrout.'<p><input type="submit" value="Finalize Publication" /></p></form>',0);
# =============================================================================
# BATCH MODE
#
- } else {
+ } else {
# Transfer metadata directly to environment for stage 2
- foreach (keys %metadatafields) {
- $ENV{'form.'.$_}=$metadatafields{$_};
+ foreach (keys %metadatafields) {
+ $ENV{'form.'.$_}=$metadatafields{$_};
+ }
+ $ENV{'form.addkey'}='';
+ $ENV{'form.keywords'}='';
+ foreach (keys %keywords) {
+ if ($metadatafields{'keywords'}) {
+ if ($metadatafields{'keywords'}=~/$_/) {
+ $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);
}
- $ENV{'form.addkey'}='';
- $ENV{'form.keywords'}='';
- foreach (keys %keywords) {
- if ($metadatafields{'keywords'}) {
- if ($metadatafields{'keywords'}=~/$_/) {
- $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);
- }
}
#########################################
--albertel1047655786--