Diff for /loncom/interface/lonsearchcat.pm between versions 1.240 and 1.241

version 1.240, 2005/03/21 21:01:15 version 1.241, 2005/03/22 21:15:42
Line 1545  sub parse_advanced_search { Line 1545  sub parse_advanced_search {
     } elsif ($customquery) {      } elsif ($customquery) {
         $query = '';          $query = '';
     }      }
     &Apache::lonnet::logthis('advanced query = '.$/.$query);      #&Apache::lonnet::logthis('advanced query = '.$/.$query);
     return ($query,$customquery,$customshow,$libraries_to_query,      return ($query,$customquery,$customshow,$libraries_to_query,
             $pretty_search_string);              $pretty_search_string);
 }  }
Line 1658  sub parse_basic_search { Line 1658  sub parse_basic_search {
     }      }
     $pretty_search_string .= "<br />\n";      $pretty_search_string .= "<br />\n";
     $pretty_search_string =~ s:^<br /> and ::;      $pretty_search_string =~ s:^<br /> and ::;
     &Apache::lonnet::logthis('simple search final query = '.$/.$final_query);      #&Apache::lonnet::logthis('simple search final query = '.$/.$final_query);
     return ($final_query,$pretty_search_string,      return ($final_query,$pretty_search_string,
             $libraries_to_query);              $libraries_to_query);
 }  }
Line 2685  sub display_results { Line 2685  sub display_results {
               );                );
     #      #
     # Build sorting selector      # Build sorting selector
     my @field_order =  ('default',      my @fields = 
                         'title',          (
                         'author',           {key=>'default' },
                         'subject',           {key=>'title' },
                         'url',           {key =>'author' },
                         'keywords',           {key =>'subject'},
                         'version',           {key =>'url',desc=>'URL'},
                         'language',           {key =>'keywords'},
                         'creationdate'=>,           {key =>'language'},
                         'lastrevisiondate',           {key =>'creationdate'},
                         'owner',           {key =>'lastrevisiondate'},
                         'copyright',           {key =>'owner'},
                         'authorspace',           {key =>'copyright'},
                         'lowestgradeleve',           {key =>'authorspace'},
                         'highestgradelevel',           {key =>'lowestgradelevel'},
                         'standards',           {key =>'highestgradelevel'},
                         'count',           {key =>'standards',desc=>'Standards'},
                         'stdno',           {key =>'count',desc=>'Number of accesses'},
                         'avetries',           {key =>'stdno',desc=>'Students Attempting'},
                         'difficulty',           {key =>'avetries',desc=>'Average Number of Tries'},
                         'disc',           {key =>'difficulty',desc=>'Mean Degree of Difficulty'},
                         'clear',           {key =>'disc',desc=>'Mean Degree of Discrimination'},
                         'technical',           {key =>'clear',desc=>'Evaluation: Clear'},
                         'correct',           {key =>'technical',desc=>'Evaluation: Technically Correct'},
                         'helpful',           {key =>'correct',desc=>'Evaluation: Material is Correct'},
                         'depth',           {key =>'helpful',desc=>'Evaluation: Material is Helpful'},
                         );                                                         {key =>'depth',desc=>'Evaluation: Material has Depth'},
     my %sort_fields = ('default'     => 'Default',           );
                        'title'       => 'Title',      my %fieldnames = &Apache::lonmeta::fieldnames();
                        'author'      => 'Author',      my @field_order;
                        'subject'     => 'Subject',      foreach my $field_data (@fields) {
                        'url'         => 'URL',          push(@field_order,$field_data->{'key'});
                        'keywords'    => 'Keywords',          if (! exists($field_data->{'desc'})) {
                        'version'     => 'Version',              $field_data->{'desc'}=$fieldnames{$field_data->{'key'}};
                        'language'    => 'Language',          } else {
                        'creationdate'=> 'Creation Date',              if (! defined($field_data->{'desc'})) {
                        'lastrevisiondate' => 'Last Revision Date',                  $field_data->{'desc'} = ucfirst($field_data->{'key'});
                        'owner'       => 'Owner',              }
                        'copyright'   => 'Copyright',              $field_data->{'desc'} = &mt($field_data->{'desc'});
                        'authorspace' => 'Authorspace',          }
                        'lowestgradeleve' => 'Lowest Grade Level',      }
                        'highestgradelevel' => 'Highest Grade Level',      my %sort_fields = map {$_->{'key'},$_->{'desc'}} @fields;
                        'standards'   => 'Standards',      $sort_fields{'select_form_order'} = \@field_order;
                        'count'       => 'Number of Accesses',      $ENV{'form.sortorder'} = 'asc' if (! exists($ENV{'form.sortorder'}));
                        'stdno'       => 'Students Attempting',      my $sortform = &mt('Sort by [_1] [_2]',
                        'avetries'    => 'Average Number of Tries',  
                        'difficulty'  => 'Mean Degree of Difficulty',  
                        'disc'        => 'Mean Degree of Discrimination',  
                        'clear'       => 'Evaluation: Clear',  
                        'technical'   => 'Evaluation: Technically Correct',  
                        'correct'     => 'Evaluation: Material is Correct',  
                        'helpful'     => 'Evaluation: Material is Helpful',  
                        'depth'       => 'Evaluation: Material has Depth',  
                        'select_form_order' => \@field_order,  
                        );  
   
     my $sortform = &mt('Sort by [_1]',  
                        &Apache::loncommon::select_form($ENV{'form.sortfield'},                         &Apache::loncommon::select_form($ENV{'form.sortfield'},
                                                       'sortfield',                                                        'sortfield',
                                                       %sort_fields));                                                        %sort_fields),
                          &Apache::loncommon::select_form($ENV{'form.sortorder'},
                                                         'sortorder',
                                                         (asc =>&mt('Ascending'),
                                                          desc=>&mt('Descending')
                                                          ))
                          );
     ##      ##
     ## Output links (if necessary) for 'prev' and 'next' pages.      ## Output links (if necessary) for 'prev' and 'next' pages.
     $r->print      $r->print
         ('<table width="100%"><tr><td width="25%" align="right">'.          ('<table width="100%"><tr><td width="25%" align="right">'.
          $sortform.           '<nobr>'.$sortform.'</nobr>'.
          '</td><td width="25%" align="right">'.           '</td><td width="25%" align="right">'.
          &prev_next_buttons($min,$ENV{'form.show'},$total_results).           &prev_next_buttons($min,$ENV{'form.show'},$total_results).
          '</td><td align="right">'.           '</td><td align="right">'.
Line 2769  sub display_results { Line 2763  sub display_results {
     ##      ##
     ## Get results from MySQL table      ## Get results from MySQL table
     my $sort_command  = 'id>='.$min.' AND id<='.$max;      my $sort_command  = 'id>='.$min.' AND id<='.$max;
       my $order;
       if (exists($ENV{'form.sortorder'})) {
           if ($ENV{'form.sortorder'} eq 'asc') {
               $order = 'ASC';
           } elsif ($ENV{'form.sortorder'} eq 'desc') {
               $order = 'DESC';
           } else {
               $order = '';
           }
       } else {
           $order = '';
       }
     if ($ENV{'form.sortfield'} ne 'default' &&       if ($ENV{'form.sortfield'} ne 'default' && 
         exists($sort_fields{$ENV{'form.sortfield'}})) {          exists($sort_fields{$ENV{'form.sortfield'}})) {
         $sort_command = $ENV{'form.sortfield'}.' IS NOT NULL '.          $sort_command = $ENV{'form.sortfield'}.' IS NOT NULL '.
             'ORDER BY '.$ENV{'form.sortfield'}.              'ORDER BY '.$ENV{'form.sortfield'}.' '.$order.
             '  LIMIT '.($min-1).','.($max-$min);              '  LIMIT '.($min-1).','.($max-$min);
     }      }
     my @Results = &Apache::lonmysql::get_rows($table,$sort_command);      my @Results = &Apache::lonmysql::get_rows($table,$sort_command);
Line 3336  sub detailed_citation_view { Line 3342  sub detailed_citation_view {
 sub summary_view {  sub summary_view {
     my ($prefix,%values) = @_;      my ($prefix,%values) = @_;
     my $icon=&Apache::loncommon::icon($values{'url'});      my $icon=&Apache::loncommon::icon($values{'url'});
     my $result=<<END;      my $result=qq{$prefix<img src="$icon" />};
 $prefix<img src="$icon" />&nbsp;      if (exists($ENV{'form.sortfield'}) && 
           $ENV{'form.sortfield'} !~ /^(default|
                                        author|
                                        url|
                                        title|
                                        owner|
                                        lastrevisiondate|
                                        copyright)$/x) {
           my $tmp = $values{$ENV{'form.sortfield'}};
           if (! defined($tmp)) { $tmp = 'undefined'; }
           $result .= '&nbsp;'.$tmp.'&nbsp;';
       }
       $result.=<<END;
 <a href="http://$ENV{'HTTP_HOST'}$values{'url'}"   <a href="http://$ENV{'HTTP_HOST'}$values{'url'}" 
    target='search_preview'>$values{'author'}</a><br />     target='search_preview'>$values{'title'}</a><br />
 $values{'title'}<br />  $values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}<br />
 $values{'owner'} -- $values{'lastrevisiondate'}<br />  
 $values{'copyrighttag'}<br />  $values{'copyrighttag'}<br />
 $values{'extrashow'}  $values{'extrashow'}
 </p>  </p>
Line 3364  END Line 3381  END
 sub compact_view {  sub compact_view {
     my ($prefix,%values) = @_;      my ($prefix,%values) = @_;
     my $result =       my $result = 
         $prefix.'<img src="'.&Apache::loncommon::icon($values{'url'}).          $prefix.'<img src="'.&Apache::loncommon::icon($values{'url'}).'">';
         '">&nbsp;<a href="'.$values{'url'}.'" target="search_preview">'.      if (exists($ENV{'form.sortfield'}) && 
           $ENV{'form.sortfield'} !~ /^(default|author|url|title)$/) {
           my $tmp = $values{$ENV{'form.sortfield'}};
           if (! defined($tmp)) { $tmp = 'undefined'; }
           $result .= '&nbsp;'.$tmp.'&nbsp;';
       }
       $result.='&nbsp;<a href="'.$values{'url'}.'" target="search_preview">'.
         $values{'title'}.'</a>'.('&nbsp;'x2).          $values{'title'}.'</a>'.('&nbsp;'x2).
         '<b>'.$values{'author'}.'</b><br />';          '<b>'.$values{'author'}.'</b><br />';
     return $result;      return $result;

Removed from v.1.240  
changed lines
  Added in v.1.241


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>