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

www lon-capa-cvs@mail.lon-capa.org
Fri, 02 Jan 2004 19:23:48 -0000


www		Fri Jan  2 14:23:48 2004 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonmeta.pm lonsearchcat.pm 
  Log:
  Domain and file category selection included again - adv search form done
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.168 loncom/interface/loncommon.pm:1.169
--- loncom/interface/loncommon.pm:1.168	Tue Dec 30 15:47:23 2003
+++ loncom/interface/loncommon.pm	Fri Jan  2 14:23:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.168 2003/12/30 20:47:23 albertel Exp $
+# $Id: loncommon.pm,v 1.169 2004/01/02 19:23:47 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -726,11 +726,40 @@
     my @domains;
     my %seen;
     foreach (sort values(%Apache::lonnet::hostdom)) {
-        push (@domains,$_) unless $seen{$_}++;
+	push (@domains,$_) unless $seen{$_}++;
     }
     return @domains;
 }
 
+# ------------------------------------------
+
+sub domain_select {
+    my ($name,$value,$multiple)=@_;
+    my %domains=map { 
+	$_ => $_.' '.$Apache::lonnet::domaindescription{$_} 
+    } &get_domains;
+    if ($multiple) {
+	$domains{''}=&mt('Any domain');
+	return &multiple_select_form($name,$value,%domains);
+    } else {
+	return &select_form($name,$value,%domains);
+    }
+}
+
+sub multiple_select_form {
+    my ($name,$value,%hash)=@_;
+    my %selected = map { $_ => 1 } ref($value)?@{$value}:($value);
+    my $output='';
+    my $size =(scalar keys %hash<4?scalar keys %hash:4);
+    $output.="\n<select name='$name' size='$size' multiple='1'>";
+    foreach (sort keys %hash) {
+        $output.="<option name='$_'".
+            ($selected{$_}?' selected="1"' :'').">$hash{$_}</option>\n";
+    }
+    $output.="</select>\n";
+    return $output;
+}
+
 #-------------------------------------------
 
 =pod
@@ -1639,6 +1668,14 @@
 
 sub fileembstyle {
     return $fe{lc(shift(@_))};
+}
+
+
+sub filecategoryselect {
+    my ($name,$value)=@_;
+    return &select_form($name,$value,
+			'' => &mt('Any category'),
+			map { $_,$_ } sort(keys(%category_extensions)));
 }
 
 =pod
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.55 loncom/interface/lonmeta.pm:1.56
--- loncom/interface/lonmeta.pm:1.55	Fri Jan  2 11:34:03 2004
+++ loncom/interface/lonmeta.pm	Fri Jan  2 14:23:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.55 2004/01/02 16:34:03 www Exp $
+# $Id: lonmeta.pm,v 1.56 2004/01/02 19:23:47 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -212,6 +212,8 @@
     return &Apache::lonlocal::texthash(
 				   'title' => 'Title',
 				   'author' =>'Author(s)',
+				   'authorspace' => 'Author Space',
+				   'modifyinguser' => 'Last Modifying User',
 				   'subject' => 'Subject',
 				   'keywords' => 'Keyword(s)',
 				   'notes' => 'Notes',
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.201 loncom/interface/lonsearchcat.pm:1.202
--- loncom/interface/lonsearchcat.pm:1.201	Fri Jan  2 11:34:03 2004
+++ loncom/interface/lonsearchcat.pm	Fri Jan  2 14:23:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.201 2004/01/02 16:34:03 www Exp $
+# $Id: lonsearchcat.pm,v 1.202 2004/01/02 19:23:47 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -629,83 +629,36 @@
     $scrout.='<table>';
     $scrout.="<tr><th>".&mt('Field').'</th><th>'.&mt('Value').'</th><th>'
 	.&mt('Related').'<br />'.&mt('Words')."</td></tr>\n";
-    foreach ('title','author','keywords','notes','abstract','standards',
+    foreach ('title','author','owner','authorspace','modifyinguser',
+	     'keywords','notes','abstract','standards',
 	     'lowestgradelevel','highestgradelevel','mime') {
 	$scrout.='<tr bgcolor="#FFFFBB"><td>'.&titlefield($fields{$_}).'</td><td>'.
 	    &Apache::lonmeta::prettyinput($_,$ENV{'form.'.$_},$_,'advsearch',
 					  1,'</td><td>',$ENV{'form.'.$_.'_related'}).
 	    '</td></tr>';
     }
+    $scrout.='<tr bgcolor="#FFFFBB"><td>'.
+	&titlefield(&mt('MIME Type Category')).'</td><td>'. 
+	    &Apache::loncommon::filecategoryselect('category',
+						   $ENV{'form.category'}).
+	    '</td><td>&nbsp;</td></td></tr>';
+    $scrout.='<tr bgcolor="#FFFFBB"><td>'.
+	&titlefield(&mt('Limit Search to Domains')).'</td><td>'. 
+	    &Apache::loncommon::domain_select('domains',
+						   $ENV{'form.domains'},1).
+	    '</td><td>&nbsp;</td></td></tr>';
     my %dates=&Apache::lonlocal::texthash('creationdatestart'     => 'Creation Date After',
 				  	  'creationdateend'       => 'Creation Date Before',
 					  'lastrevisiondatestart' => 'Last Revision Date After',
 					  'lastrevisiondateend'   => 'Last Revision Date Before');
     foreach (sort keys %dates) {
-	$scrout.='<tr><td>'.&titlefield($dates{$_}).'</td><td>'. 
+	$scrout.='<tr bgcolor="#FFFFBB"><td>'.&titlefield($dates{$_}).'</td><td>'. 
 	    &Apache::lonhtmlcommon::date_setter('advsearch',$_,0,'',1).
 	    '</td><td>&nbsp;</td></td></tr>';
     }
-    
-
 
-    # Hack - an empty table row.
-    $scrout.="<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
-#    $scrout.=&searchphrasefield('file<br />extension','extension',
-#                        $ENV{'form.extension'});
-#    $scrout.="<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
-#    $scrout.=&searchphrasefield('publisher<br />owner','owner',
-	#			$ENV{'form.owner'});
     $scrout.="</table>\n";
-#    $scrout.=&Apache::lonmeta::selectbox('File Category','category',
-#			$ENV{'form.category'},
-#			'any','Any category',
-#			undef,
-#			(&Apache::loncommon::filecategories()));
-    #----------------------------------------------------------------
-    # Allow restriction to multiple domains.
-    #   I make the crazy assumption that there will never be a domain 'any'.
-    #
-    my @allowed_domains = (ref($ENV{'form.domains'}) ? @{$ENV{'form.domains'}} 
-                           :  ($ENV{'form.domains'}) );
-    my %domain_hash = ();
-    foreach (@allowed_domains) {
-        $domain_hash{$_}++;
-    }
-    my @domains =&Apache::loncommon::get_domains();
-    # adjust the size of the select box
-    my $size = 4;
-    $size = (scalar @domains < ($size - 1) ? scalar @domains + 1 : $size);
-    $scrout.="\n".&titlefield(&mt('Domain to be searched')).
-            '<select name="domains" size="'.$size.'" multiple>'."\n".
-                '<option name="any" value="any" '.
-                    ($domain_hash{'any'}? 'selected ' :'').
-                        '>all domains</option>'."\n";
-    foreach my $dom (sort @domains) {
-        $scrout.="<option name=\"$dom\" ".
-            ($domain_hash{$dom} ? 'selected ' :'').">$dom</option>\n";
-    }
-    $scrout.="</select>\n";
-
-# ------------------------------------------- Compute customized metadata field
-#    $scrout.=<<CUSTOMMETADATA;
-#<p>
-#<font color="#800000" face="helvetica"><b>LIMIT BY SPECIAL METADATA FIELDS:</b>
-#</font>
-#For resource-specific metadata, enter in an expression in the form of 
-#<i>key</i>=<i>value</i> separated by operators such as AND, OR or NOT.<br />
-#<b>Example:</b> grandmother=75 OR grandfather=85
-#<br />
-#CUSTOMMETADATA
-#    $scrout.=&simpletextfield('custommetadata',$ENV{'form.custommetadata'});
-#    $scrout.=<<CUSTOMSHOW;
-#<p>
-#<font color="#800000" face="helvetica"><b>SHOW SPECIAL METADATA FIELDS:</b>
-#</font>
-#Enter in a space-separated list of special metadata fields to show
-#in a fielded listing for each record result.
-#<br />
-#CUSTOMSHOW
-#    $scrout.=&simpletextfield('customshow',$ENV{'form.customshow'});
+
     $scrout.=<<ENDDOCUMENT;
 $advanced_buttons
 </form>