DBIx::HTMLView::PostSet - A set posts as in a search result for example


NAME

  DBIx::HTMLView::PostSet - A set posts as in a search result for example


SYNOPSIS

my $post_set=$table->list; # Get a PostSet $post_set->view_html; # view it

$post_set=$table->list; # Get a new one as the old now is used while (defined $post=$self->get_next) { # Process $post... }

$post_set=DBIx::HTMLView::PostSet->new($table) # Create a PostSet in save mode $post_set->add($post);


DESCRIPTION

This a class representing a set of object as for example a result of a search. The object can either be in save mode or in no-save mode. A PostSet object in no-save mode will be able to itterate through the posts once and then they are gone. The posts are never stored, but retrieved from the db when you ask for the next one and then trashed if you don't save them. In save mode this class will star by dowbloading all the posts from the db into memory to allow more advanced manipulations.

$post_set=DBIx:.HTMLView::PostSet->new($tab, $sth, $save)

Creates a new PostSet object for posts from the table $tab (a DBIx::HTMlView::Table object). If $sth is a reference it's supposed to be the result of a DBI execute call with a select command. The posts returned from the db will be the ones represented by this set.

If $save is defined to a false value the object will be created in no-save mode, otherview in save mode. See the DESCRIPTION.

$post_set->rows

Returns the number of rows (posts) in this PostSet as reported by the $sth->rows DBI function.

$post_set->got_post($post)

Returns true if $post has been returned earlier in this set (in which case we won't return it again). Or if we are in save mode returns true if the post is within the set. $post should be a DBIx::HTMLView::Post object.

$post_set->do_got_post

Marks $post (a DBIx::HTMLView::Post object) as a returned post. See $post_set->got_post.

$post_set->tab

Returns the table (a DBIx::HTMLView::Table object) this set of posts belongs to.

$post_set->get_next

Returns the next post (a DBIx::HTMLView::Post object) in the set. The first one will be returned if this method has not been called before.

$post_set->save_mode

Returns true if we are in save mode.

$post_set->add($post)

Adds the post $post (a DBIx::HTMLView::Post object) to the set.

$post_set->posts

Returns an array of DBIx::HTMLView::Post object representing the posts in the set or dies if there is no posts or if we are not in save mode with ``No posts!'' and ``Not in save mode'' respectivly.

$post_set->first

Returns the first post of this set, or dies with ``No posts!'' if there is no posts. If we are in no-save mode it can be called once before any next_post calls are done, after that it will die with ``Not in save mode''.

$post_set->view_html

Returns a string that can be used to view the entire set of posts in html format.

$post->view_fmt($fmt_name, $fmt)

Returns a string represeting this set of posts in the format named by $fmt_name. as returned by DBIx::HTMLView::list_fmt($fmt_name). If $fmt is specified it will be used as the fmt strings instead of looking up a default one.

If the fmt stringit contains a <node>...</node> construct the ... part will be repeated once for every post and passed as $fmt param to view_fmt of DBIx::HTMLView::Post. Curretly we only support one <node>...</node> construct in the fmt. If ... is ``'', undef will be passed as fmt to the Post, thereby using default Post fmts.

$fmt_name is passed on to the Post objects who the passes it on to the fld objects, so it can be used to specify how the flds should be represented even if you use a custom fmt passed to $fmt.

 DBIx::HTMLView::PostSet - A set posts as in a search result for example