NAME
Perlbug::Format - Format class
DESCRIPTION
Supplies formatting methods on behalf of all objects according to the following format types:
a ascii short - minimal listings default for mail interface
A ASCII long - maximal block style listings
h html short - minimal listings default for web interface
H HTML long - maximal block style listings
i id short - minimal id style listings
I id HTML - like i, but with html links
l lean list - ascii but purely for parsing minimal data
L lean HTML - like l, but with html links
x xml short - placeholder
X XML short - placeholder
SYNOPSIS
use Perlbug::Format;
my $o_fmt = Perlbug::Format->new();
print $o_fmt->read('123')->format('a');
METHODS
- new
-
Create new Format object:
my $o_fmt = Perlbug::Format->new();
- base
-
Return application specific Perlbug::Base object, given as $o_obj->new($o_base) or new object altogether.
FORMATTING
All objects may provide their own formatting methods, these are offered as catchalls
- FORMAT
-
Wrapper for format -> FORMAT
my $formatted_str = $o_fmt->FORMAT('a'); # ([aAhHlL])...
This uses the internal object structure 'data'.
Note that you can also give these data hashes directly as in the following example:
my $formatted_str = $o_fmt->FORMAT('a', { 'this' => 'data' }, { 'ext: over' => 'here :-)' });
- format_fields
-
Format individual entries for output, handles all available objects
Certain keywords to be careful of here: keys for objects and for relations(ids, count, names)
my $h_data = $o_fmt->format_fields($h_data, [$fmt]);
- normalize
-
Returns data all on a single level
$h_bug = { 'bugid' => '19870502.007', 'user' => { 'count' => 1, 'ids' => [qw(richardf)], }
Becomes: $h_bug = { 'bugid' => '19870502.007', 'user_count' => 1, 'user_ids' => [qw(richardf)], }
my \%data = $o_fmt->normalize(\%data);
- asciify
-
Returns args generically wrapped for ascii presentation
my \%data = $o_fmt->asciify(\%data);
- htmlify
-
Returns args generically wrapped with html tags.
my \%data = $o_fmt->htmlify(\%data);
- FORMAT_ascii
-
Default format, and args, for any object
my ($top, $format, @args) = $o_fmt->FORMAT_ascii(\%data);
- FORMAT_html
-
Default html format, and args, for any object
my ($format, @args) = $o_fmt->FORMAT_html(\%data);
- max
-
Wrapper for i_MAX access
my $i_max = $o_fmt->max;
- cnt
-
Wrapper for i_CNT access
my $i_counted = $o_fmt->cnt;
- parse_addrs
-
Parse email address given into RFC-822 compatible format, also removes duplicates.
With optional address(only) or format(whole string) requested, defaults to address.
my @parsed = $o_fmt->parse_addrs(\@original_addrs, 'address|format');
FORMATTING_STYLES
The following formatting styles are supported, b<a> is the default
These methods here may be used directly against any basic table, each object is expected to provide more relevant formatting where required.
For supported types (/[ahilx]/i) see DESCRIPTION
- FORMAT_i
-
ID ascii format, no header or body.
my ($top, $format, @args) = $o_fmt->FORMAT_i(\%data);
- FORMAT_I
-
ID HTML format, no header or body.
my ($top, $format, @args) = $o_fmt->FORMAT_I(\%data);
- FORMAT_l
-
Default Lean (list) ascii format, no header or body.
my ($top, $format, @args) = $o_fmt->FORMAT_l(\%data);
- FORMAT_a
-
Default ascii format, inc. message body
my ($top, $format, @args) = $o_fmt->FORMAT_a(\%data);
- FORMAT_A
-
Default ASCII format inc. message header and body
my ($top, $format, @args) = $o_fmt->FORMAT_A(\%data);
- FORMAT_L
-
Default Lean html format
my ($top, $format, @args) = $o_fmt->FORMAT_L(\%data);
- FORMAT_h
-
Default html format
my ($top, $format, @args) = $o_fmt->FORMAT_h(\%data);
- FORMAT_H
-
Default format in block html format.
my ($top, $format, @args) = $o_fmt->FORMAT_H(\%data);
- FORMAT_x
-
Default XML format, currently just wraps FORMAT_a()
my ($top, $format, @args) = $o_fmt->FORMAT_x(\%data);
- FORMAT_X
-
Default XML format, currently just wraps FORMAT_a()
my ($top, $format, @args) = $o_fmt->FORMAT_X(\%data);
- href
-
Return list of perlbug.cgi?req=key_id&... hyperlinks to given list).
Maintains format, rng etc.
my @links = $o_fmt->href('bug_id', \@bids, 'visible element of link', [subject hint], [\@boldids]);
Or
my @links = $o_fmt->href('query&status=open', [], 'open bugs', 'Click to see open bugs', [\@boldids]);
- mailto
-
Return mailto: for a particular ticket
my $mailto = $o_fmt->mailto($h_tkt);
- popup
-
Returns appropriate (cached) popup with optional default value inserted.
my $popup = $o_fmt->popup('status', $unique_id, $default); $tkt{'group'} = $self->popup('group', $tkt{'group'}, $id.'_group'); $tkt{'osname'} = $self->popup('osname', $id.'_osname', $tkt{'osname'}); $tkt{'select'} = $cgi->checkbox(-'name'=>'bugid', -'checked' => '', -'value'=> $id); $tkt{'severity'} = $self->popup('severity', $id.'_severity', $tkt{'severity'}); $tkt{'status'} = $self->popup('status', $id.'_status', $tkt{'status'});
AUTHOR
Richard Foley perlbug@rfi.net 2000 2001
6 POD Errors
The following errors were encountered while parsing the POD:
- Around line 70:
'=item' outside of any '=over'
- Around line 108:
You forgot a '=back' before '=head1'
- Around line 113:
'=item' outside of any '=over'
- Around line 507:
You forgot a '=back' before '=head1'
- Around line 518:
'=item' outside of any '=over'
- Around line 959:
You forgot a '=back' before '=head1'