<<

NAME

C4::Creators::Template - A class for creating and manipulating template objects in Koha

ABSTRACT

This module provides methods for creating, retrieving, and otherwise manipulating label template objects used by Koha.

METHODS

new()

    Invoking the I<new> method constructs a new template object containing the default values for a template.
    The following parameters are optionally accepted as key => value pairs:

        C<profile_id>           A valid profile id to be assciated with this template. NOTE: The profile must exist in the database and B<not> be assigned to another template.
        C<template_code>        A template code. ie. 'Avery 5160 | 1 x 2-5/8'
        C<template_desc>        A readable description of the template. ie. '3 columns, 10 rows of labels'
        C<page_width>           The width of the page measured in the units supplied by the units parameter in this template.
        C<page_height>          The height of the page measured in the same units.
        C<label_width>          The width of a single label on the page this template applies to.
        C<label_height>         The height of a single label on the page.
        C<top_text_margin>      The measure of the top margin on a single label on the page.
        C<left_text_margin>     The measure of the left margin on a single label on the page.
        C<top_margin>           The measure of the top margin of the page.
        C<left_margin>          The measure of the left margin of the page.
        C<cols>                 The number of columns of labels on the page.
        C<rows>                 The number of rows of labels on the page.
        C<col_gap>              The measure of the gap between the columns of labels on the page.
        C<row_gap>              The measure of the gap between the rows of labels on the page.
        C<units>                The units of measure used for this template. These B<must> match the measures you supply above or
                                bad things will happen to your document. NOTE: The only supported units at present are:
. POINT = Postscript Points (This is the base unit in the Koha label creator.)
. AGATE = Adobe Agates (5.1428571 points per)
. INCH = US Inches (72 points per)
. MM = SI Millimeters (2.83464567 points per)
. CM = SI Centimeters (28.3464567 points per)
    example:
        my $template = Template->new(); # Creates and returns a new template object with the defaults

        my $template = C4::Labels::Template->new(profile_id => 1, page_width => 8.5, page_height => 11.0, units => 'INCH'); # Creates and returns a new template object using
            the supplied values to override the defaults

    B<NOTE:> This template is I<not> written to the database untill save() is invoked. You have been warned!

retrieve(template_id => $template_id)

    Invoking the I<retrieve> method constructs a new template object containing the current values for template_id. The method returns
    a new object upon success and -1 upon failure. Errors are logged to the Apache log. Two further options may be accessed. See the example
    below for further description.

    examples:

        C<my $template = C4::Labels::Template->retrieve(template_id => 1); # Retrieves template record 1 and returns an object containing the record>

        C<my $template = C4::Labels::Template->retrieve(template_id => 1, convert => 1); # Retrieves template record 1, converts the units to points,
            and returns an object containing the record>

        C<my $template = C4::Labels::Template->retrieve(template_id => 1, profile_id => 1); # Retrieves template record 1, converts the units
            to points, applies the currently associated profile id, and returns an object containing the record.>

delete()

    Invoking the delete method attempts to delete the template from the database. The method returns -1 upon failure. Errors are logged to the Apache log.
    NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that template from the database. See the example below.

    examples:
        C<my $exitstat = $template->delete(); # to delete the record behind the $template object>
        C<my $exitstat = C4::Labels::Template::delete(template_id => 1); # to delete template record 1>

save()

    Invoking the I<save> method attempts to insert the template into the database if the template is new and update the existing template record if
    the template exists. The method returns the new record template_id upon success and -1 upon failure (This avoids template_ids conflicting with a
    record template_id of 1). Errors are logged to the Apache log.

    example:
        C<my $template_id = $template->save(); # to save the record behind the $template object>

get_attr($attribute)

    Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.

    example:
        C<my $value = $template->get_attr($attribute);>

set_attr(attribute => value, attribute_2 => value)

    Invoking the I<set_attr> method will set the value of the supplied attributes to the supplied values. The method accepts key/value pairs separated by
    commas.

    example:
        C<$template->set_attr(attribute => value);>

get_label_position($start_label)

    Invoking the I<get_label_position> method will return the row, column coordinates on the starting page and the lower left x,y coordinates on the starting
    label for the template object.

    examples:
        C<my ($row_count, $col_count, $llx, $lly) = $template->get_label_position($start_label);>

AUTHOR

Chris Nighswonger <cnighswonger AT foundations DOT edu>

COPYRIGHT

Copyright 2009 Foundations Bible College.

LICENSE

This file is part of Koha.

Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

You should have received a copy of the GNU General Public License along with Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

DISCLAIMER OF WARRANTY

Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

<<