[LON-CAPA-cvs] cvs: loncom /interface lonsearchcat.pm

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 26 Jun 2002 18:19:41 -0000


matthew		Wed Jun 26 14:19:41 2002 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
  Log:
  &advanced_search_form
      Added file categories selection list.
  &selectbox
      Removed <br /> between text and selection form.
  &output_results
      Handle the file categories via mime type.  Currently the mime fill-in 
          form and the file categories selection box are mutually exclusive, 
          with the latter overriding the former.
  
  
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.130 loncom/interface/lonsearchcat.pm:1.131
--- loncom/interface/lonsearchcat.pm:1.130	Wed Jun 26 12:04:13 2002
+++ loncom/interface/lonsearchcat.pm	Wed Jun 26 14:19:41 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.130 2002/06/26 16:04:13 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.131 2002/06/26 18:19:41 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -273,7 +273,7 @@
 $hidden
 <h3>Basic Search</h3>
 <p>
-Enter terms or quoted phrases separated by AND, OR, or NOT 
+Enter terms or phrases separated by AND, OR, or NOT 
 then press SEARCH below.
 </p>
 <p>
@@ -346,7 +346,7 @@
 <img align='right' src='/adm/lonIcons/lonlogos.gif' />
 <h1>Advanced Catalog Search</h1>
 <hr />
-Enter terms or quoted phrases separated by search operators 
+Enter terms or phrases separated by search operators 
 such as AND, OR, or NOT.<br />
 <form method="post" action="/adm/searchcat">
 $advanced_buttons
@@ -388,12 +388,12 @@
     $scrout.=&searchphrasefield('publisher<br />owner','owner',
 				$ENV{'form.owner'});
     $scrout.="</table>\n";
-#    $ENV{'form.mime'}='any' unless length($ENV{'form.mime'});
-#    $scrout.=&selectbox('Limit by MIME type','mime',
-#			$ENV{'form.mime'},
-#			'any','Any type',
-#			\&{Apache::loncommon::filedescriptionex},
-#			(&Apache::loncommon::fileextensions));
+    $ENV{'form.category'}='any' unless length($ENV{'form.category'});
+    $scrout.=&selectbox('Limit by file category','category',
+			$ENV{'form.category'},
+			'any','Any category',
+			undef,
+			(&Apache::loncommon::filecategories()));
     $ENV{'form.language'}='any' unless length($ENV{'form.language'});
     $scrout.=&selectbox('Limit by language','language',
 			$ENV{'form.language'},'any','Any Language',
@@ -667,7 +667,7 @@
     if (! defined($functionref)) { $functionref = sub { $_[0]}; }
     my $uctitle=uc($title);
     my $selout="\n".'<p><font color="#800000" face="helvetica">'.
-        '<b>'.$uctitle.':</b></font><br /><select name="'.$name.'">';
+        '<b>'.$uctitle.': </b></font><select name="'.$name.'">';
     foreach ($anyvalue,@idlist) {
         $selout.='<option value="'.$_.'"';
         if ($_ eq $default and !/^any$/) {
@@ -706,7 +706,7 @@
 		   'lastrevisiondatestart_year','lastrevisiondateend_month',
 		   'lastrevisiondateend_day','lastrevisiondateend_year',
 		   'notes','abstract','mime','language','owner',
-		   'custommetadata','customshow') {
+		   'custommetadata','customshow','category') {
 	$ENV{"form.$field"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }
     foreach ('mode','form','element') {
@@ -715,6 +715,12 @@
 	$ENV{"form.$_"}=&Apache::lonnet::unescape($ENV{"form.$_"});
 	$ENV{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }
+    # Preprocess the category form element.
+    if ($ENV{'form.category'} ne 'any') {
+        my @extensions = &Apache::loncommon::filecategorytypes
+            ($ENV{'form.category'});
+        $ENV{'form.mime'} = join ' OR ',@extensions;
+    }
     # Check to see if enough information was filled in
     for my $field ('title','author','subject','keywords','url','version',
 		   'notes','abstract','mime','language','owner',
@@ -735,15 +741,12 @@
 		       'keywords','version','owner','mime') {
 	if ($ENV{'form.'.$field}) {
 	    push @queries,&build_SQL_query($field,$ENV{'form.'.$field});
-	}
+        }
     }
     # Evaluate option lists
     if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') {
 	push @queries,"(language like \"$ENV{'form.language'}\")";
     }
-#    if ($ENV{'form.mime'} and $ENV{'form.mime'} ne 'any') {
-#	push @queries,"(mime like \"$ENV{'form.mime'}\")";
-#    }
     if ($ENV{'form.copyright'} and $ENV{'form.copyright'} ne 'any') {
 	push @queries,"(copyright like \"$ENV{'form.copyright'}\")";
     }