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

www lon-capa-cvs@mail.lon-capa.org
Fri, 02 Jan 2004 16:34:04 -0000


www		Fri Jan  2 11:34:04 2004 EDT

  Modified files:              
    /loncom/interface	lonhtmlcommon.pm lonmeta.pm lonsearchcat.pm 
  Log:
  Date setting improvements. Now has "not set"
  
  
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.38 loncom/interface/lonhtmlcommon.pm:1.39
--- loncom/interface/lonhtmlcommon.pm:1.38	Thu Jan  1 15:13:17 2004
+++ loncom/interface/lonhtmlcommon.pm	Fri Jan  2 11:34:03 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.38 2004/01/01 20:13:17 www Exp $
+# $Id: lonhtmlcommon.pm,v 1.39 2004/01/02 16:34:03 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -142,14 +142,21 @@
 ##############################################
 ##############################################
 sub date_setter {
-    my ($formname,$dname,$currentvalue,$special) = @_;
+    my ($formname,$dname,$currentvalue,$special,$includeempty) = @_;
     if (! defined($currentvalue) || $currentvalue eq 'now') {
-        $currentvalue = time;
+	unless ($includeempty) {
+	    $currentvalue = time;
+	} else {
+	    $currentvalue = 0;
+	}
     }
     # other potentially useful values:     wkday,yrday,is_daylight_savings
-    my ($sec,$min,$hour,$mday,$month,$year,undef,undef,undef) = 
-        localtime($currentvalue);
-    $year += 1900;
+    my ($sec,$min,$hour,$mday,$month,$year)=('','','','','','');
+    if ($currentvalue) {
+	($sec,$min,$hour,$mday,$month,$year,undef,undef,undef) = 
+	    localtime($currentvalue);
+	$year += 1900;
+    }
     my $result = "\n<!-- $dname date setting form -->\n";
     $result .= <<ENDJS;
 <script language="Javascript">
@@ -201,9 +208,10 @@
                     July    August    September October November December/;
     # Pad @Months with a bogus value to make indexing easier
     unshift(@Months,'If you can read this an error occurred');
+    if ($includeempty) { $result.="<option value=''></option>"; }
     for(my $m = 1;$m <=$#Months;$m++) {
         $result .= "      <option value=\"$m\" ";
-        $result .= "selected " if ($m-1 == $month);
+        $result .= "selected " if ($m-1 eq $month);
         $result .= "> ".&mt($Months[$m])." </option>\n";
     }
     $result .= "  </select>\n";
@@ -215,6 +223,7 @@
             "onChange=\"javascript:$dname\_checkday()\" />\n";
     $result .= "&nbsp;&nbsp;";
     $result .= "  <select name=\"$dname\_hour\" ".$special." >\n";
+    if ($includeempty) { $result.="<option value=''></option>"; }
     for (my $h = 0;$h<24;$h++) {
         $result .= "      <option value=\"$h\" ";
         $result .= "selected " if ($hour == $h);
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.54 loncom/interface/lonmeta.pm:1.55
--- loncom/interface/lonmeta.pm:1.54	Thu Jan  1 15:13:17 2004
+++ loncom/interface/lonmeta.pm	Fri Jan  2 11:34:03 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.54 2004/01/01 20:13:17 www Exp $
+# $Id: lonmeta.pm,v 1.55 2004/01/02 16:34:03 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -260,8 +260,9 @@
 # Dates
     if (($type eq 'creationdate') ||
 	($type eq 'lastrevisiondate')) {
-	return &Apache::lonlocal::locallocaltime(
-			  &Apache::lonmysql::unsqltime($value));
+	return ($value?&Apache::lonlocal::locallocaltime(
+			  &Apache::lonmysql::unsqltime($value)):
+		&mt('not available'));
     }
 # Language
     if ($type eq 'language') {
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.200 loncom/interface/lonsearchcat.pm:1.201
--- loncom/interface/lonsearchcat.pm:1.200	Thu Jan  1 15:13:17 2004
+++ loncom/interface/lonsearchcat.pm	Fri Jan  2 11:34:03 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.200 2004/01/01 20:13:17 www Exp $
+# $Id: lonsearchcat.pm,v 1.201 2004/01/02 16:34:03 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -485,7 +485,7 @@
 ENDDOCUMENT
 if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) {
     my $CatalogSearch=&mt('Catalog Search');
-    my $Statement=&mt('Enter terms or phrases separated by AND, OR, or NOT then press SEARCH below');
+    my $Statement=&searchhelp();
     $scrout.=(<<ENDDOCUMENT);
 <h1>$CatalogSearch</h1>
 <form name="loncapa_search" method="post" action="/adm/searchcat">
@@ -602,10 +602,8 @@
 <input type="button" value="$lt{'help'}" onClick="openhelp()" />
 </p>
 END
-    if (!defined($ENV{'form.viewselect'})) {
-        $ENV{'form.viewselect'} ="Detailed Citation View";
-    }
     my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search');
+    my $searchhelp=&searchhelp();
     my $scrout=<<"ENDHEADER";
 <html>
 <head>
@@ -619,8 +617,7 @@
 </script>
 </head>
 $bodytag
-Enter terms or phrases separated by search operators 
-such as AND, OR, or NOT.<br />
+$searchhelp
 <form method="post" action="/adm/searchcat" name="advsearch">
 $advanced_buttons
 $hidden_fields
@@ -628,22 +625,29 @@
 ENDHEADER
     $scrout.=&viewoptions();
     my %fields=&Apache::lonmeta::fieldnames();
-# set undefined to "any"
-    $ENV{'form.language'}='any' unless length($ENV{'form.language'});
-    $ENV{'form.domains'} = 'any' if (! exists($ENV{'form.domains'}));
-    $ENV{'form.category'}='any' if (! defined($ENV{'form.category'}));
-
 
     $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',
 	     'lowestgradelevel','highestgradelevel','mime') {
-	$scrout.='<tr><td>'.&titlefield($fields{$_}).'</td><td>'.
+	$scrout.='<tr bgcolor="#FFFFBB"><td>'.&titlefield($fields{$_}).'</td><td>'.
 	    &Apache::lonmeta::prettyinput($_,$ENV{'form.'.$_},$_,'advsearch',
 					  1,'</td><td>',$ENV{'form.'.$_.'_related'}).
 	    '</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>'. 
+	    &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',
@@ -786,6 +790,25 @@
 			(10,20,50,100,1000,10000));
     $scrout.="</td></tr></table>\n\n";
     return $scrout;
+}
+
+######################################################################
+
+=pod 
+
+=item searchhelp
+
+Inputs: none
+
+Outputs: return little blurb on how to enter searches
+
+=cut
+
+######################################################################
+######################################################################
+
+sub searchhelp {
+    return &mt('Enter terms or phrases separated by AND, OR, or NOT');
 }
 
 ######################################################################