NAME

Krang::Template - Interface for managing template objects


SYNOPSIS

 # create a new template
 my $template = pkg('Template')->new(category    => $category,
                                     content     => '<tmpl_var test>',
                                     filename    => 'test.tmpl');
 # save contents of the object to the DB.
 $template->save();
 # put the object back into circulation for other users
 $template->checkin();
 # checkout object to work on it
 $template->checkout();
 # saves to the db again, increments version field of the object
 $template->save();
 # use this template for testing, will override deployed versions of the
 # same template
 $template->mark_for_testing();
 # no longer use this template for testing
 $template->unmark_for_testing();
 # Mark the template as having been deployed to the Krang publish path.
 # unsets testing flag in the database
 $template->mark_as_deployed();
 # Mark the template as not existing in the publish path.
 # unsets deployed, deploy_version, deploy_date.
 $template->mark_as_undeployed();
 # reverts to template revision specified by $version
 $template->revert( $version );
 # deploy template
 $template->deploy
 # remove all references to the object in the template and
 # template_version tables
 $template->delete();
 # returns array of template objects matching criteria in %params
 my @templates = pkg('Template')->find( %params );
 # Get permissions for this object
 $template->may_see() || croak("Not allowed to see");
 $template->may_edit() || croak("Not allowed to edit");


DESCRIPTION

Templates determine the form of this system's output. This module provides a means to check in, check out, edit, revert, save, and search Template objects.

A template is either associated with an element class and hence determines its formatting or it may serve as some manner of miscellaneous utility whether formatting or otherwise. Template data, i.e. the 'content' field, is, at present, intended to be in HTML::Template format. All template filenames will end in the extension '.tmpl'. Users have the ability to revert to any previous version of a template.

This module interfaces or will interface with Krang::CGI::Template, Krang::Burner, the FTP interface, and the SOAP interface.


INTERFACE

FIELDS

This module employs Krang::MethodMaker to provide accessors for all and mutators for some of the object's fields. The fields can be accessed and set in the following manner:

 # accessor
 $value = $template_obj->readable_field();
 # mutator
 $template->obj->readable_and_writeable_field( $value );

The four read/write fields for the object are:

The remaining read-only fields are:

METHODS


TO DO

 * Prevent duplicate template objects and paths once pkg('Category') is
   completed


SEE ALSO

Krang, Krang::DB, Krang::Log