/[webpac2]/trunk/vhost/webpac2.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/vhost/webpac2.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1174 by dpavlin, Sun Apr 26 00:07:58 2009 UTC revision 1176 by dpavlin, Wed Apr 29 18:06:15 2009 UTC
# Line 182  if ( my $search = param('search') ) { Line 182  if ( my $search = param('search') ) {
182          my $swish = SWISH::API->new( "$dir/../var/swish/$database" );          my $swish = SWISH::API->new( "$dir/../var/swish/$database" );
183          $swish->abort_last_error if $swish->Error;          $swish->abort_last_error if $swish->Error;
184    
         my $pager = Data::Page->new;  
         $pager->$_( param($_) ) foreach ( qw/entries_per_page current_page/ );  
   
         dump_yaml( 'pager', $pager );  
   
185          my @search = ();          my @search = ();
186          if ( $search =~ m{(=|"|AND|OR)} ) {          if ( $search =~ m{(=|"|AND|OR)} ) {
187                  push @search, $search;                  push @search, $search;
# Line 224  if ( my $search = param('search') ) { Line 219  if ( my $search = param('search') ) {
219    
220          dump_yaml( 'swish_results', $swish_results );          dump_yaml( 'swish_results', $swish_results );
221    
222            my $pager = Data::Page->new;
223            $pager->$_( param($_) ) foreach ( qw/entries_per_page current_page/ );
224          $pager->total_entries( $swish_results->hits );          $pager->total_entries( $swish_results->hits );
225    
226          $swish_results->seek_result( $pager->first );          dump_yaml( 'pager', $pager );
227    
228            $swish_results->seek_result( $pager->first - 1 );
229    
230          if ( ! $pager->total_entries ) {          if ( ! $pager->total_entries ) {
231                  my $no_results = 'No results for search <b>%s</b>';                  my $no_results = 'No results for search <b>%s</b>';
# Line 241  if ( my $search = param('search') ) { Line 240  if ( my $search = param('search') ) {
240    
241                  print qq|<ul class="pager">$pager_html</ul>\n\n| if $pager_html;                  print qq|<ul class="pager">$pager_html</ul>\n\n| if $pager_html;
242    
243                  my $start = $pager->first;                  my $nr = $pager->first;
244                  print qq|<ol start=$start>\n|;                  print qq|<ol start=$nr>\n|;
245    
246                  my $limit = $pager->entries_on_this_page;                  my $limit = $pager->entries_on_this_page;
247    
248                    my $nr = 1;
249    
250                  while ( my $result = $swish_results->next_result ) {                  while ( my $result = $swish_results->next_result ) {
                         last if $limit-- == 0;  
251    
252                          my $data = from_json $result->property('data');                          my $data = from_json $result->property('data');
253    
254                          dump_yaml( 'data', $data );                          dump_yaml( 'data', $data );
255    
256                          print qq|<li>|;                          my $li_class = '';
257                            $li_class = qq| class="z"| if $nr++ % 2 == 0;
258                            print qq|<li$li_class>|;
259                          foreach my $attr ( @attr ) {                          foreach my $attr ( @attr ) {
260                                  next unless defined $data->{$attr};                                  next unless defined $data->{$attr};
261                                  my $v = $data->{$attr};                                  my $v = $data->{$attr};
# Line 268  if ( my $search = param('search') ) { Line 270  if ( my $search = param('search') ) {
270                                  print qq|<div><label>$label</label><span class=$attr>$v</span></div>\n|;                                  print qq|<div><label>$label</label><span class=$attr>$v</span></div>\n|;
271                          }                          }
272                          print qq|</li>\n|;                          print qq|</li>\n|;
273    
274                            last if $nr++ == $pager->last;
275                  }                  }
276                  print qq|</ol>\n\n|;                  print qq|</ol>\n\n|;
277    

Legend:
Removed from v.1174  
changed lines
  Added in v.1176

  ViewVC Help
Powered by ViewVC 1.1.26