/[webpac2]/Webpacus/lib/Webpacus/Model/WebPAC.pm
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 /Webpacus/lib/Webpacus/Model/WebPAC.pm

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

revision 405 by dpavlin, Sun Feb 19 22:40:40 2006 UTC revision 420 by dpavlin, Sun Mar 12 21:50:26 2006 UTC
# Line 239  sub search { Line 239  sub search {
239          $cond->set_max( $page * $max );          $cond->set_max( $page * $max );
240    
241          my $result = $self->{est_node}->search($cond, $args->{depth});          my $result = $self->{est_node}->search($cond, $args->{depth});
242            if (! $result) {
243                    $self->{log}->fatal("search didn't return result");
244                    return;
245            }
246          my $hits = $result->doc_num;          my $hits = $result->doc_num;
247    
248          $times->{est} += time() - $t;          $times->{est} += time() - $t;
# Line 246  sub search { Line 250  sub search {
250          $log->debug( sprintf("search took %.6fs and returned $hits hits.", $times->{est}) );          $log->debug( sprintf("search took %.6fs and returned $hits hits.", $times->{est}) );
251    
252          $self->{hints} = $result->{hints};          $self->{hints} = $result->{hints};
253          $log->dumper($self->{hints}, 'hints' );          $log->dumper($self->{hints}, 'original hints' );
254    
255          #          #
256          # fetch results          # fetch results
# Line 364  sub hints { Line 368  sub hints {
368                  }                  }
369          }          }
370    
371            $self->{log}->dumper($hints, 'model hints' );
372    
373          return $hints;          return $hints;
374  }  }
375    
# Line 460  sub list_nodes { Line 466  sub list_nodes {
466                          my $node = $1;                          my $node = $1;
467                          $self->setup_site( $node );                          $self->setup_site( $node );
468                          $self->{est_node}->_set_info;                          $self->{est_node}->_set_info;
469                            $label = decode('UTF-8', $label);
470                          push @nodes, {                          push @nodes, {
471                                  name => $node,                                  name => $node,
472                                  label => $label,                                  label => $label,
# Line 478  sub list_nodes { Line 485  sub list_nodes {
485          return @nodes;          return @nodes;
486  }  }
487    
 =cut  
   
   
488  =head2 save_html  =head2 save_html
489    
490    $m->save_html( '/full/path/to/file', $content );    $m->save_html( '/full/path/to/file', $content );
# Line 552  It also has follwing template toolikit f Line 556  It also has follwing template toolikit f
556    
557  =cut  =cut
558    
559    # Escape <, >, & and ", and to produce valid XML
560    my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');  
561    my $escape_re  = join '|' => keys %escape;
562    
563  sub apply {  sub apply {
564          my $self = shift;          my $self = shift;
565    
# Line 599  C<d('FieldName','delimiter')>, where C<d Line 607  C<d('FieldName','delimiter')>, where C<d
607                          if (ref($v) eq 'ARRAY') {                          if (ref($v) eq 'ARRAY') {
608                                  if ($#{$v} == 0) {                                  if ($#{$v} == 0) {
609                                          $v = $v->[0];                                          $v = $v->[0];
610                                            $v =~ s/($escape_re)/$escape{$1}/g;
611                                  } else {                                  } else {
612                                          $join = $default_delimiter->{$type} unless defined($join);                                          $join = $default_delimiter->{$type} unless defined($join);
613                                          $v = join($join, @{$v});                                          $v = join($join, map {
614                                                    s/($escape_re)/$escape{$1}/g;
615                                            } @{$v});
616                                  }                                  }
617                          } else {                          } else {
618                                  warn("TT filter $type(): field $name values aren't ARRAY, ignoring");                                  warn("TT filter $type(): field $name values aren't ARRAY, ignoring");

Legend:
Removed from v.405  
changed lines
  Added in v.420

  ViewVC Help
Powered by ViewVC 1.1.26