The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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:

  • 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.

  • image - the URL of an image that you want to associate with the story.

  • primcat - the primary category. You want to classify the story into one primary category.

  • seccat - the secondary categories. May be an array, so you can classify the story into any number of categories. This may be useful when you try to find relevant articles but searching along different paths.

  • freesubject - free categories. The primary categories are intended to be controlled vocabularies, whereas free subjects can be used and created more ad hoc. Also an array, you can have any number of such categories.

  • editorok - a boolean variable indicated if an editor has approved the story for publishing.

  • title - the main title of the story.

  • minicontent - Intended to be used as a summary or introduction to a story. Typically, the minicontent will be shown on a front page, where a visitor clicks happily along to read the full story.

  • content - the full story text.

  • username - the username of the user who actually does the posting of hte story. Would usually be an editor.

  • submitterid - the username of the user who submitted the article to the site for review and posting.

  • linktext - "Read More" makes a bad link text. Link texts should be meaningful when read out of context, and this should contain such a text.

  • timestamp - typically the time when the story was posted. See also the timestamp() method.

  • lasttimestamp - typically the time when something attached to the story was last changed, for example when a comment was last submitted. See also the lasttimestamp() method.

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

  • story

  • http://www.kjetil.kjernsmo.net/software/TABOO/NS/Story/Output

  • story

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.