/[webpac2]/trunk/lib/WebPAC/Output/TT.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 /trunk/lib/WebPAC/Output/TT.pm

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

revision 341 by dpavlin, Mon Jan 2 11:37:08 2006 UTC revision 376 by dpavlin, Sun Jan 8 22:41:45 2006 UTC
# Line 16  WebPAC::Output::TT - use Template Toolki Line 16  WebPAC::Output::TT - use Template Toolki
16    
17  =head1 VERSION  =head1 VERSION
18    
19  Version 0.06  Version 0.07
20    
21  =cut  =cut
22    
23  our $VERSION = '0.06';  our $VERSION = '0.07';
24    
25  =head1 SYNOPSIS  =head1 SYNOPSIS
26    
# Line 45  By default, Template Toolkit will C<EVAL Line 45  By default, Template Toolkit will C<EVAL
45    
46  sub new {  sub new {
47          my $class = shift;          my $class = shift;
48          my $self = {@_};          my $self = {@_};
49          bless($self, $class);          bless($self, $class);
50    
51          my $log = $self->_get_logger;          my $log = $self->_get_logger;
52    
53          # create Template toolkit instance          # create Template toolkit instance
54          $self->{'tt'} = Template->new(          $self->{'tt'} = Template->new(
55                  INCLUDE_PATH => $self->{'include_path'},                  INCLUDE_PATH => $self->{'include_path'},
56                  FILTERS => $self->{'filter'},                  #FILTERS => $self->{'filters'},
57                  EVAL_PERL => 1,                  EVAL_PERL => 1,
58          );          );
59                    
60          $log->logdie("can't create TT object: $Template::ERROR") unless ($self->{'tt'});          $log->logdie("can't create TT object: $Template::ERROR") unless ($self->{'tt'});
61    
62          $log->debug("filters defined: ",Dumper($self->{'filter'}));          $log->debug("filters defined: ",Dumper($self->{'filters'}));
63    
64          $self ? return $self : return undef;          $self ? return $self : return undef;
65  }  }
# Line 196  filter to return links to search, usage Line 196  filter to return links to search, usage
196    
197                                          my $s;                                          my $s;
198                                          if ($s_el > 0) {                                          if ($s_el > 0) {
199                                                  $s = $item->{'search'}->[$i] || die "can't find value $i for type search in field $search";                                                  $s = $item->{'search'}->[$i];
200                                                    die "can't find value $i for type search in field $search" unless (defined($s));
201                                          } else {                                          } else {
202                                                  $s = $item->{'search'}->[0];                                                  $s = $item->{'search'}->[0];
203                                          }                                          }
204                                          #$s =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;                                          #$s =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;
205                                          $s = __quotemeta( $s );                                          $s = __quotemeta( $s );
206    
207                                          my $d = $item->{'display'}->[$i] || die "can't find value $i for type display in field $display";                                          my $d = $item->{'display'}->[$i];
208                                                    die "can't find value $i for type display in field $display" unless (defined($d));
209    
210                                          my $template_arg = '';                                          my $template_arg = '';
211                                          $template_arg = qq{,'$template'} if ($template);                                          $template_arg = qq{,'$template'} if ($template);
212    
213                                          push @html, qq{<a href="#" onclick="return search_via_link('$search','$s'${template_arg})">$d</a>};                                          if ($s && ! $d) {
214                                                    $d = $s;
215                                            } elsif (! $s && $d) {
216                                                    $s = $d;
217                                            }
218    
219                                            push @html, qq{<a href="#" onclick="return search_via_link('$search','$s'${template_arg})">$d</a>} if ($s && $d);
220                                  }                                  }
221    
222                                  return join($delimiter, @html);                                  return join($delimiter, @html);
# Line 268  Used to re-submit search request and loa Line 276  Used to re-submit search request and loa
276                  return "load_template($template); return false;";                  return "load_template($template); return false;";
277          };          };
278    
279            if ($self->{filters}) {
280                    $args->{f} = $self->{filters};
281                    $log->debug("using f.filters");
282            }
283    
284          my $out;          my $out;
285    
286          $self->{'tt'}->process(          $self->{'tt'}->process(

Legend:
Removed from v.341  
changed lines
  Added in v.376

  ViewVC Help
Powered by ViewVC 1.1.26