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

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

revision 201 by dpavlin, Thu Dec 1 13:58:04 2005 UTC revision 318 by dpavlin, Fri Dec 23 22:52:48 2005 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.03  Version 0.06
20    
21  =cut  =cut
22    
23  our $VERSION = '0.03';  our $VERSION = '0.06';
24    
25  =head1 SYNOPSIS  =head1 SYNOPSIS
26    
# Line 71  Create output from in-memory data struct Line 71  Create output from in-memory data struct
71    
72   my $text = $tt->apply(   my $text = $tt->apply(
73          template => 'text.tt',          template => 'text.tt',
74          data => $ds          data => $ds,
75            record_uri => 'database/prefix/mfn',
76   );   );
77    
78  It also has follwing template toolikit filter routies defined:  It also has follwing template toolikit filter routies defined:
# Line 201  filter to return links to search, usage Line 202  filter to return links to search, usage
202    
203                                          my $d = $item->{'display'}->[$i] || die "can't find value $i for type display in field $display";                                          my $d = $item->{'display'}->[$i] || die "can't find value $i for type display in field $display";
204    
205                                          push @html, <<__JS_LINK_SEARCH__                                          push @html, qq{<a href="#" onclick="return search_via_link('$search','$s')">$d</a>};
 <a href="#" onclick="new Ajax.Updater( 'results',  '/search/results?$search=$s', { asynchronous: 1,onLoading: function(request){show_searching();},onLoaded: function(request){hide_searching();} } ) ; return false">$d</a>  
 __JS_LINK_SEARCH__  
206                                  }                                  }
207    
208                                  return join($delimiter, @html);                                  return join($delimiter, @html);
# Line 223  __JS_LINK_SEARCH__ Line 222  __JS_LINK_SEARCH__
222    
223          $args->{'search'} = tt_filter_search($args);          $args->{'search'} = tt_filter_search($args);
224    
225    =head3 load_rec
226    
227    Used mostly for onClick events like this:
228    
229      <a href="#" onClick="[% load_rec( record_uri, 'template_name.tt') %]>foo</a>
230    
231    It will automatically do sanity checking and create correct JavaScript code.
232    
233    =cut
234    
235            $args->{'load_rec'} = sub {
236                    my @errors;
237    
238                    my $record_uri = shift or push @errors, "record_uri missing";
239                    my $template = shift or push @errors, "template missing";
240    
241                    if ($record_uri !~ m#^[^/]+/[^/]+/[^/]+$#) {
242                            push @errors, "invalid format of record_uri: $record_uri";
243                    }
244    
245                    if (@errors) {
246                            return "Logger.error('errors in load_rec: " . join(", ", @errors) . "'); return false;";
247                    } else {
248                            return "load_rec('$record_uri','$template'); return false;";
249                    }
250            };
251    
252    =head3 load_template
253    
254    Used to re-submit search request and load results in different template
255    
256      <a href="#" onClick="[% load_template( 'template_name.tt' ) %]">bar</a>
257    
258    =cut
259    
260            $args->{'load_template'} = sub {
261                    my $template = shift or return "Logger.error('load_template missing template name!'); return false;";
262                    return "load_template($template); return false;";
263            };
264    
265          my $out;          my $out;
266    
267          $self->{'tt'}->process(          $self->{'tt'}->process(

Legend:
Removed from v.201  
changed lines
  Added in v.318

  ViewVC Help
Powered by ViewVC 1.1.26