Kjetil Kjernsmo > AxKit-App-TABOO-0.52 > AxKit::App::TABOO::Data::Comment

Download:
AxKit-App-TABOO-0.52.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.095   Source  

NAME ^

AxKit::App::TABOO::Data::Comment - Comment Data object for TABOO

SYNOPSIS ^

  use AxKit::App::TABOO::Data::Comment;
  $comment = AxKit::App::TABOO::Data::Comment->new();
  $comment->load(limit => {sectionid => $self->{section},
                           storyname => $self->{storyname}});
  $comment->tree;
  $comment->adduserinfo;
  $timestamp = $comment->timestamp();

DESCRIPTION ^

This Data class contains a comment, which may be posted by any registered user of the site. Each object will also contain an identifier of replies to the comment, that may be replaced with a reference to another comment object.

METHODS ^

This class implements several methods, reimplements the load method, but inherits some from AxKit::App::TABOO::Data.

new($self-dbconnectargs())>

The constructor. Nothing special.

load(what => fields, limit => {key => value, [...]}

The load method is not reimplemented but needs elaboration. It follows the convention of the load methods of the parent class, but to uniquely identify a comment, one has to set certain limits.

First one should identify the story that the comment is attached to, by giving storyname and sectionid, see AxKit::App::TABOO::Data::Story for details.

To identify the comment itself, TABOO introduces the concept of a commentpath. A commentpath is a string that identifies a comment by appending the username of the poster for each reply posted, separated by a /. In computer science terms, I think this is known as a trie. Thus, commentpaths will grow as people respond to each other's comments. For example, if user bar replies to user foo, the commentpath to bar's comment will be /foo/bar. The commenpath will typically be in the URI of a comment. If the same user post more replies to a comment, they will be suffixed with e.g. _2 for the second comment.

The commentpath, sectionid and storyname together identifies a comment.

adduserinfo()

When data has been loaded into an object of this class, it will contain a string only identifying the user who posted the comment. This method will replace that strings with a reference to a AxKit::App::TABOO::Data::User-object, containing the needed user information.

reply($comment)

This method can be used to attach a reply to a comment, or to retrieve a reply. If no argument is given, it will return the reply object if it exists. To attach a comment, give an argument which is an instance of this class or an instance of AxKit::App::TABOO::Data::Plurals::Comments.

tree([$what, $orderby])

This method has changed considerably since earlier releases. You may call it on any object of this class that has commentpath, sectionid and storyname defined. It will return an instance of the AxKit::App::TABOO::Data::Plurals::Comments class consisting of all comments in the tree with the comment in the object it was called on as root.

timestamp([($sectionid, $storyname, $commentpath)|Time::Piece])

The timestamp method will retrieve or set the timestamp of the comment. If the timestamp has been loaded earlier from the data storage (for example by the load method), you need not supply any arguments. If the timestamp is not available, you must supply the sectionid, storyname and commentpath identifiers, the method will then load it into the data structure first.

The timestamp method will return a Time::Piece object with the requested time information.

To set the timestamp, you must supply a Time::Piece object, the timestamp is set to the time given by that object.

STORED DATA ^

The data is stored in named fields, and for certain uses, it is good to know them. If you want to subclass this class, you might want to use the same names, see the documentation of AxKit::APP::TABOO::Data for more about this.

In this class it gets even more interesting, because you may pass a list of those to the load method. This is useful if you for example just want the title of the comments, not all their content.

These are the names of the stored data of this class:

XML representation ^

The write_xml() method, implemented in the parent class, can be used to create an XML representation of the data in the object. The above names will be used as element names. The xmlelement() and xmlns() methods can be used to set the name of the root element and the namespace respectively. Usually, it doesn't make sense to change the defaults, which are

BUGS/TODO ^

FORMALITIES ^

See AxKit::App::TABOO.

syntax highlighting: