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

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

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.33   Source  

NAME ^

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

SYNOPSIS ^

  use AxKit::App::TABOO::Data::Story;
  $story = AxKit::App::TABOO::Data::Story->new(@dbconnectargs);
  $story->load(what => '*', limit => {sectionid => $sectionid, storyname => $storyname});
  $story->adduserinfo();
  $story->addcatinfo();
  $timestamp = $story->timestamp();
  $lasttimestamp = $story->lasttimestamp();
  $story->timestamp($lasttimestamp);

DESCRIPTION ^

This Data class contains a story, as posted by the editors of a site.

METHODS ^

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

new(@dbconnectargs)

The constructor. Nothing special.

load(what => fields, limit => {sectionid => value, storyname => value, [...]})

This class reimplements the load method, to support the fact that some data may be stored as arrays in the datastore. It shares the API of the parent class. It is useful to note, however, that there are two fields that you most likely would want to specify for the common use of retrieving a specific story:

  • The sectionid which the story has been posted to. Typically, this string will be taken directly from the URI. The use of sections makes it possible to divide the site in different ways. Sections are a type of category, specifically stsec, but they are not intended to be like the categ types. Rather, one can have sections with "small news", i.e. blatant rip-offs of other news sites with a few comments added, or longer articles with more unique content.
  • storyname is a unique identifier for the story. This too will typically be derived from the URI directly.

It is of course possible to identify a single story by a completely different set of parameters, and you can do that too, but it is not a very common thing to do.

adduserinfo()

When data has been loaded into an object of this class, it will contain a string only identifying a user. This method will replace those strings (for the user posting the article, and for the submitter who sent the article to the site) with a reference to a AxKit::App::TABOO::Data::User-object, containing the needed user information.

addcatinfo()

Similarly to adding user info, this method will also add category information, for different types of categories, again by creating a reference to a AxKit::App::TABOO::Data::Category-object and calling its load-method with the string from the data loaded by the story as argument.

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

The timestamp method will retrieve or set the timestamp of the story. 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 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.

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

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

This does exactly the same as the timestamp method, but instead returns the lasttimestamp, which is intended to show when anything connected to the story (which may include comments) last changed.

It may require arguments like the timestamp method does, and it will return a Time::Piece object.

editorok([($sectionid, $storyname)])

This is similar to the timestamp method in interface, but can't be used to set the value, only retrieves it. It returns the editorok, which is a boolean variable that says can be used to see if an editor has approved a story.

It takes arguments like the timestamp method does, and it will return 1 if the story has been approved, 0 if not.

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 don't want to load all data, in those cases where you don't need all the data that the object can hold.

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(), xmlns() and xmlprefix() methods can be used to set the name of the root element, the namespace URI and namespace prefix respectively. Usually, it doesn't make sense to change the defaults, that are

BUGS/TODO ^

There is a quirk in the load method. I use SQL3 arrays in the underlying database, but the database driver doesn't support this. So, there is a very hackish ad hoc implementation to parse the arrays in that method. It is in fact the only reason why this class reimplements the load method. It works partly for reading, but just with DBD::Pg greater than 1.32.

FORMALITIES ^

See AxKit::App::TABOO.

syntax highlighting: