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

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

revision 1065 by dpavlin, Mon Nov 19 16:33:09 2007 UTC revision 1066 by dpavlin, Tue Nov 27 22:31:09 2007 UTC
# Line 7  our @EXPORT = qw/ Line 7  our @EXPORT = qw/
7          _debug          _debug
8          _pack_subfields_hash          _pack_subfields_hash
9    
10            to
11          search_display search display sorted          search_display search display sorted
12    
13          rec1 rec2 rec          rec1 rec2 rec
# Line 52  WebPAC::Normalize - describe normalisato Line 53  WebPAC::Normalize - describe normalisato
53    
54  =cut  =cut
55    
56  our $VERSION = '0.35';  our $VERSION = '0.36';
57    
58  =head1 SYNOPSIS  =head1 SYNOPSIS
59    
# Line 269  sub _debug { Line 270  sub _debug {
270    
271  Those functions generally have to first in your normalization file.  Those functions generally have to first in your normalization file.
272    
273    =head2 to
274    
275    Generic way to set values for some name
276    
277      to('field-name', 'name-value' => rec('200','a') );
278    
279    There are many helpers defined below which might be easier to use.
280    
281    =cut
282    
283    sub to {
284            my $type = shift or confess "need type -- BUG?";
285            my $name = shift or confess "needs name as first argument";
286            my @o = grep { defined($_) && $_ ne '' } @_;
287            return unless (@o);
288            $out->{$name}->{$type} = \@o;
289    }
290    
291  =head2 search_display  =head2 search_display
292    
293  Define output for L<search> and L<display> at the same time  Define output for L<search> and L<display> at the same time
294    
295    search_display('Title', rec('200','a') );    search_display('Title', rec('200','a') );
296    
   
297  =cut  =cut
298    
299  sub search_display {  sub search_display {
# Line 288  sub search_display { Line 306  sub search_display {
306    
307  =head2 tag  =head2 tag
308    
309  Old name for L<search_display>, but supported  Old name for L<search_display>, it will probably be removed at one point.
310    
311  =cut  =cut
312    
# Line 304  Define output just for I<display> Line 322  Define output just for I<display>
322    
323  =cut  =cut
324    
325  sub _field {  sub display { to( 'display', @_ ) }
         my $type = shift or confess "need type -- BUG?";  
         my $name = shift or confess "needs name as first argument";  
         my @o = grep { defined($_) && $_ ne '' } @_;  
         return unless (@o);  
         $out->{$name}->{$type} = \@o;  
 }  
   
 sub display { _field( 'display', @_ ) }  
326    
327  =head2 search  =head2 search
328    
# Line 322  Prepare values just for I<search> Line 332  Prepare values just for I<search>
332    
333  =cut  =cut
334    
335  sub search { _field( 'search', @_ ) }  sub search { to( 'search', @_ ) }
336    
337  =head2 sorted  =head2 sorted
338    
# Line 332  Insert into lists which will be automati Line 342  Insert into lists which will be automati
342    
343  =cut  =cut
344    
345  sub sorted { _field( 'sorted', @_ ) }  sub sorted { to( 'sorted', @_ ) }
   
346    
347    
348  =head1 Functions to extract data from input  =head1 Functions to extract data from input

Legend:
Removed from v.1065  
changed lines
  Added in v.1066

  ViewVC Help
Powered by ViewVC 1.1.26