A content object is an element of a web page, such as text, html, stylesheets, scripts, images, or downloadable files. This module provides methods to act on generic content objects.
This is part of the ExSite content stack, so it inherits from the ContentData (and then ContentBase) class, and is in turn inherited by Page.
new()
(This method is actually inherited from ExSite::ContentBase.)
setup()
setupContent()
Instantiate and/or configure a content object. %option
includes the
the configuration parameters, described below.
Usage:
my $content = new ExSite::Content(%option);
$content->setup(%option);
$content->setupContent(%option);
setup
and setupContent
are synonymous; they are used to setup or
reconfigure an existing Content object. new()
instantiates a new content
object (this method is actually inherited from ExSite::ContentBase
).
%option
is used to pass the content description information that
allows the object to be configured. It can include the following content
description parameters:
The setup methods are normally invoked automatically by the class constructor method new()
, which receives the same %option
parameters.
authtype()
Returns the content/authorization type, ie. ``editorial'' or ``design'', which determines who is allowed to update the content.
authorize()
Returns TRUE if the current user is permitted to update the content. This depends on the the user's access level, and their admin key for the current section, which determines their access privileges.
update()
This creates a new revision of the content; it is synonymous with
ExSite::ContentData::make_content_data()
.
rollback()
This removes the most recent revision of the content.
count()
Returns the number of revisions on file for this content.
NB: modifying means changing the content attributes, not updating the
content. The latter operation is done by calling the update()
method.
validate()
my @errors = $content->validate($data);
if (@errors == 0) { # content is OK }
Returns TRUE if the values in the the $data
hashref comprise a
valid and legal content description. Returns an array of error
messages, which will be empty if the content validates.
make()
make_content()
$content->make($data,$revision,$opt);
Creates a new content object, with the attributes given in the
$data
hashref. If the user is permitted to create new content
objects and the attributes validate, then the content record will be
created.
If $revision
is defined, then a ContentData object will be created
as well, using the content_data description in $revision
, and any
extra options in $opt. These are passed to
ExSite::ContentData::make_content_data()
.
delete()
Removes the content object from the system. Attempts to unpublish its files, as well.