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

matthew lon-capa-cvs@mail.lon-capa.org
Sun, 09 May 2004 22:55:18 -0000


matthew		Sun May  9 18:55:18 2004 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
  Log:
  &parse_basic_search: Modified formatting of pretty html description of 
  search.
  &detailed_citation_view: Now lists goto, comefrom, sequsage fields, with
  links to resources.  Also formats numerical output as needed.
  
  
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.224 loncom/interface/lonsearchcat.pm:1.225
--- loncom/interface/lonsearchcat.pm:1.224	Fri May  7 14:50:14 2004
+++ loncom/interface/lonsearchcat.pm	Sun May  9 18:55:17 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.224 2004/05/07 18:50:14 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.225 2004/05/09 22:55:17 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1490,8 +1490,9 @@
                        ('title', 'author', 'subject', 'notes', 'abstract',
                         'keywords'));
     foreach my $search (&process_phrase_input($search_string)){
-        $pretty_search_string .= '<br />'.'<b>'.$search.'</b>';
         if ($ENV{'form.related'}) {
+            $pretty_search_string .= ' and <br />' if ($pretty_search_string ne '');
+            $pretty_search_string .= '<b>'.$search.'</b>';
             my @New_Words;
             ($search,@New_Words) = &related_version($search);
             next if (! $search);
@@ -1499,6 +1500,9 @@
                 $pretty_search_string .= 
                     " with related words: <b>@New_Words</b>";
             }
+        } else {
+            $pretty_search_string .= ' and ' if ($pretty_search_string ne '');
+            $pretty_search_string .= '<b>'.$search.'</b>';
         }
         #
         # Build SQL query string based on form page
@@ -1511,7 +1515,7 @@
         $pretty_search_string .= ' '.$pretty_domains_string;
     }
     $pretty_search_string .= "<br />\n";
-    $pretty_search_string =~ s:^<br />::;
+    $pretty_search_string =~ s:^<br /> and ::;
 #    &Apache::lonnet::logthis($final_query);
     return ($final_query,$pretty_search_string,
             $libraries_to_query);
@@ -2933,41 +2937,73 @@
          { name=>'copyrighttag',
            translate => '<b>Copyright/Distribution:</b>&nbsp;[_1]',},
          { name=>'count',
+           format => "%d",
            translate => '<b>Access Count:</b>&nbsp;[_1]',},
          { name=>'stdno',
+           format => "%d",
            translate => '<b>Number of Students:</b>&nbsp;[_1]',},
          { name=>'avetries',
+           format => "%.2f",
            translate => '<b>Average Tries:</b>&nbsp;[_1]',},
          { name=>'disc',
+           format => "%.2f",
            translate => '<b>Degree of Discrimination:</b>&nbsp;[_1]',},
          { name=>'difficulty',
+           format => "%.2f",
            translate => '<b>Degree of Difficulty:</b>&nbsp;[_1]',},
          { name=>'clear',
+           format => "%.2f",
            translate => '<b>Clear:</b>&nbsp;[_1]',},
          { name=>'depth',
+           format => "%.2f",
            translate => '<b>Depth:</b>&nbsp;[_1]',},
          { name=>'helpful',
+           format => "%.2f",
            translate => '<b>Helpful:</b>&nbsp;[_1]',},
          { name=>'correct',
+           format => "%.2f",
            translate => '<b>Correct:</b>&nbsp;[_1]',},
          { name=>'technical',
+           format => "%.2f",
            translate => '<b>Technical:</b>&nbsp;[_1]',},
+         { name=>'comefrom_list',
+           type => 'list',
+           translate => 'Resources that lead up to this resource in maps',},
+         { name=>'goto_list',
+           type => 'list',
+           translate => 'Resources that follow this resource in maps',},
+         { name=>'usage_list',
+           type => 'list',
+           translate => 'Resources using or importing resource',},
          ) {
-        if (exists($values{$field->{'name'}}) &&
-            $values{$field->{'name'}} ne '') {
+        next if (! exists($values{$field->{'name'}}) ||
+                 $values{$field->{'name'}} eq '');
+        if (exists($field->{'type'}) && $field->{'type'} eq 'list') {
+            $result .= '<b>'.&mt($field->{'translate'}).'</b><ul>';
+            foreach my $item (split(',',$values{$field->{'name'}})){
+                $result .= '<li>'.
+                    '<a target="search_preview" '.
+                    'href="/res/'.$item.'">'.$item.'</a></li>';
+            }
+            $result .= '</ul>';
+        } elsif (exists($field->{'format'}) && $field->{'format'} ne ''){
+            $result.= &mt($field->{'translate'},
+                          sprintf($field->{'format'},
+                                  $values{$field->{'name'}})).'<br />'."\n";
+        } else {
             if ($field->{'special'} eq 'url link') {
                 $result.= 
-                    &mt($field->{'translate'},
-                        '<a href="'.$values{'url'}.'" '.
-                            'target="search_preview">'.
-                        $values{$field->{'name'}}.
-                        '</a>');
+                     &mt($field->{'translate'},
+                         '<a href="'.$values{'url'}.'" '.
+                         'target="search_preview">'.
+                         $values{$field->{'name'}}.
+                         '</a>');
             } else {
                 $result.= &mt($field->{'translate'},
                               $values{$field->{'name'}});
             }
             $result .= "<br />\n";
-            }
+        }
     }
     $result .= "</p>";
     if (exists($values{'extrashow'}) && $values{'extrashow'} ne '') {