[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm

matthew lon-capa-cvs@mail.lon-capa.org
Sun, 14 Apr 2002 16:25:39 -0000


matthew		Sun Apr 14 12:25:39 2002 EDT

  Modified files:              
    /loncom/publisher	lonpublisher.pm 
  Log:
  Added 'check all' and 'uncheck all' buttons for keywords.
  
  
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.76 loncom/publisher/lonpublisher.pm:1.77
--- loncom/publisher/lonpublisher.pm:1.76	Wed Apr 10 11:28:45 2002
+++ loncom/publisher/lonpublisher.pm	Sun Apr 14 12:25:39 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.76 2002/04/10 15:28:45 albertel Exp $
+# $Id: lonpublisher.pm,v 1.77 2002/04/14 16:25:39 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -556,7 +556,7 @@
 # ------------------------------------------------------- Now have all metadata
 
         $scrout.=
-     '<form action="/adm/publish" method="post">'.
+     '<form name="pubform" action="/adm/publish" method="post">'.
        '<p><input type="submit" value="Finalize Publication" /></p>'.
           &hiddenfield('phase','two').
           &hiddenfield('filename',$ENV{'form.filename'}).
@@ -568,7 +568,26 @@
 
 # --------------------------------------------------- Scan content for keywords
 
-	my $keywordout='<p><b>Keywords:</b><br><table border=2><tr>';
+	my $keywordout=<<"END";
+<script>
+function checkAll(field)
+{
+    for (i = 0; i < field.length; i++)
+        field[i].checked = true ;
+}
+
+function uncheckAll(field)
+{
+    for (i = 0; i < field.length; i++)
+        field[i].checked = false ;
+}
+</script>
+<p><b>Keywords:</b> 
+<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;
         my %keywords=();
         
@@ -594,7 +613,7 @@
             }
 
             foreach (sort keys %keywords) {
-                $keywordout.='<td><input type=checkbox name="key.'.$_.'"';
+                $keywordout.='<td><input type=checkbox name="keywords" value="'.$_.'"';
                 if ($metadatafields{'keywords'}) {
                    if ($metadatafields{'keywords'}=~/$_/) { 
                       $keywordout.=' checked'; 
@@ -669,7 +688,6 @@
     my ($source,$target,$style,$distarget)=@_;
     my $logfile;
     my $scrout='';
-
     unless ($logfile=Apache::File->new('>>'.$source.'.log')) {
 	return 
          '<font color=red>No write permission to user directory, FAIL</font>';
@@ -696,10 +714,9 @@
      $metadatafields{'dependencies'}=$ENV{'form.dependencies'};
 
      my $allkeywords=$ENV{'form.addkey'};
-     foreach (keys %ENV) {
-         if ($_=~/^form\.key\.(\w+)/) {
-	     $allkeywords.=','.$1;
-         }
+     my @Keywords = @{$ENV{'form.keywords'}};
+     foreach (@Keywords) {
+         $allkeywords.=','.$_;
      }
      $allkeywords=~s/\W+/\,/;
      $allkeywords=~s/^\,//;