Perlbug::Format - Format class


Perlbug documentation  | view source Contained in the Perlbug distribution.

Index


NAME

Top

Perlbug::Format - Format class

DESCRIPTION

Top

Supplies formatting methods for object data, according to the currently supported format types:

    a ascii short - minimal listings default for mail interface

    A ASCII long  - maximal block style listings

	d debug short - a|h with object attributes (unsupported)

	D debug long  - A|H with object attributes (unsupported)

    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

User rights determine what data is seen and how it will be presented pro option

Ascii:

	guest:
		user: $userid

	admin:
		user: $userid
		pass: $passwd

Html:

	<pre>
	guest:
		user: $userid

	admin:
		user: <input type=text value="$userid"> 
		pass: <input type=text value="$passwd"> 
		<submit name=change>
	</pre>

SYNOPSIS

Top

	use Perlbug::Format;

	my $o_fmt = Perlbug::Format->new();

	print $o_fmt->object('patch')->read('123')->format('l');

METHODS

Top

new

Create new Format object:

	my $o_fmt = Perlbug::Format->new();

FORMATTING

Top

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, [$i_max]]);

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)], 'user_names' => ['Richard Foley'], }

	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 - way too convoluted.

	my \%data = $o_fmt->htmlify(\%data);

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');	

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], 
		$js,
		$fmt
	);

Or

    my @links = $o_fmt->href(
		'query&status=open', 
		[], 
		'open bugs', 
		'Click to see open bugs', 
	);

mailto

Return mailto: for a particular ticket

    my $mailto = $o_fmt->mailto($h_tkt); 

AUTHOR

Top

Richard Foley perlbug@rfi.net 2000 2001


Perlbug documentation  | view source Contained in the Perlbug distribution.