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('*', $commentpath, $sectionid, $commentname);
$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()
-
The constructor. Nothing special.
load($what, $commentpath, $section, $storyname)
-
The load method is reimplemented to support a more elaborate scheme for identifying comments, as well as the ability of selecting a subset of data to load. It now takes four arguments, three of them are identical to those of AxKit::App::TABOO::Data::Story.
The first is a comma-separated list of fields from the data storage, see "STORED DATA" for details and available values. For all fields, use
'*'
.The second is a commentpath. Conceptually, a commentpath is a string that identifies a comment by appending the username of the poster for each reply posted, separated by a
/
. 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.The third parameter is a word identifying a section which the story has been posted to. Typically, this string will be taken directly from the URI.
The fourth parameter is a unique identifier for the story. This too will typically be derived from the URI directly.
The $commentpath, $section amd $storyname together identifies a comment.
When loaded, the comment object will also contain an array of commentpaths of the replies to the comment. There is currently no method to retrieve this array, but you shouldn't need to.
tree($what)
-
Once you've
load()
ed the object, you may call this method on it. It will replace the commentpath array with references to the objects, and does it recursively, so you'll have references with references (etc) to all comments that are below this comment. Furthermore, it callsadduserinfo()
(below) on all the objects, so after having calledtree()
on an object, you should have everything that's intersting in there.Like
load()
,tree($what)
takes an argument, a comma-separated list of fields from the data storage, see "STORED DATA" available values. For all fields, use'*'
. root($section, $storyname)
-
The
/
commentpath does not refer to a comment. The root is simply not a comment, so you can'tload( ... , '/', ... , ...)
. To address this problem, the root method returns a reference to an array containing all the commentpaths of comments attached directly to a story. You may then run through the array and callload
on each element in the array. It takes two arguments, an identifier for the section and for the story, seeload()
. 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 string with a reference to a AxKit::App::TABOO::Data::User-object, and that object's
load_name
method will be called. After this has been done, the story will effectively have all the user information it needs. timestamp([($section, $storyname)])
-
The timestamp method will retrieve 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 section and storyname 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.
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:
commentpath - the identifying commentpath, as described above.
storyname - an identifier for the story, a simple word you use to retrieve the desired object.
sectionid - an identifier for the section, also a simple word you use to retrieve the desired object.
title - the title for the comment chosen by the poster.
content - the full comment text.
timestamp - typically the time when the comment was posted. See also the
timestamp()
method.username - the username of the user who posted the comment.
FORMALITIES
See AxKit::App::TABOO.