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 |
|
|
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: |
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); |
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( |