Bric::Biz::OutputChannel(3)

NAME
Bric::Biz::OutputChannel - Bricolage Output Channels.

VERSION
$LastChangedRevision$

DATE
$LastChangedDate: 2006-05-12 07:54:43 -0700 (Fri, 12 May 2006) $

SYNOPSIS
  use Bric::Biz::OutputChannel;

  # Constructors.
  $oc = Bric::Biz::OutputChannel->new($init);
  $oc = Bric::Biz::OutputChannel->lookup({ id => $id});
  my $ocs_aref = Bric::Biz::OutputChannel->list($params);
  my @ocs = Bric::Biz::OutputChannel->list($params);

  # Class Methods.
  my $id_aref = Bric::Biz::OutputChannel->list_ids($params);
  my @ids = Bric::Biz::OutputChannel->list_ids($params);

  # Instance Methods.
  $id = $oc->get_id;
  my $name = $oc->get_name;
  $oc = $oc->set_name( $name );
  my $description = $oc->get_description;
  $oc = $oc->set_description($description);
  if ($oc->get_primary) { # do stuff }
  $oc = $oc->set_primary(1); # or pass undef.
  my $site_id = $oc->get_site_id;
  $site = $site->set_site_id($site_id);
  my $protocol = $oc->get_protocol;
  $site = $site->set_protocol($protocol);

  # URI Format instance methods.
  my $uri_format = $oc->get_uri_format;
  $oc->set_uri_format($uri_format);
  my $fixed_uri_format = $oc->get_fixed_uri_format;
  $oc->set_fixed_uri_format($uri_fixed_format);
  my $uri_case = $oc->get_uri_case;
  $oc->set_uri_case($uri_case);
  if ($oc->can_use_slug) { # do stuff }
  $oc->use_slug_on;
  $oc->use_slug_off;

  # Output Channel Includes instance methods.
  my @ocs = $oc->get_includes;
  $oc->set_includes(@ocs);
  $oc->add_includes(@ocs);
  $oc->del_includes(@ocs);

  # Active instance methods.
  $oc = $oc->activate;
  $oc = $oc->deactivate;
  $oc = $oc->is_active;

  # Persistence methods.
  $oc = $oc->save;

DESCRIPTION
Holds information about the output channels that will be associated with templates and elements.

PUBLIC INTERFACE

  Public Constructors

$oc = Bric::Biz::OutputChannel->new( $initial_state )
    Instantiates a Bric::Biz::OutputChannel object. An anonymous hash of initial values may be passed. The supported initial value keys are:

    *   name

    *   site_id

    *   description

    *   active (default is active, pass undef to make a new inactive Output Channel)

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$oc = Bric::Biz::OutputChannel->lookup({ id => $id })
$oc = Bric::Biz::OutputChannel->lookup({ name => $name, site_id => $id})
    Looks up and instantiates a new Bric::Biz::OutputChannel object based on an Bric::Biz::OutputChannel object ID or name. If no output channelobject is found in the database, "lookup()" returns "undef".

    Throws:

    *   Missing required parameter 'id' or 'name'/'site_id'.

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: NONE.

    Notes: NONE.

($ocs_aref || @ocs) = Bric::Biz::OutputChannel->list( $criteria )
    Returns a list or anonymous array of Bric::Biz::OutputChannel objects based on the search parameters passed via an anonymous hash. The supported lookup keys are:

    id  Output channel ID. May use "ANY" for a list of possible values.

    name
        The name of the output channel. May use "ANY" for a list of possible values.

    description
        Description of the output channel. May use "ANY" for a list of possible values.

    site_id
        The ID of the Bric::Biz::Site object with which the output channel is associated. May use "ANY" for a list of possible values.

    protocol
        The protocol or scheme for files published to an output channel, such as "http://". May use "ANY" for a list of possible values.

    server_type_id
        The ID of a Bric::Dest::ServerType (destination) with which output channels may be associated. May use "ANY" for a list of possible values.

    include_parent_id
        The ID of an output channel that includes other output channels, to get a list of those includes. May use "ANY" for a list of possible values.

    story_instance_id
        The ID of a story with which output channels may be associated. May use "ANY" for a list of possible values.

    media_instance_id
        The ID of a media document with which output channels may be associated. May use "ANY" for a list of possible values.

    uri_format
        The URI format of an output channel. May use "ANY" for a list of possible values.

    fixed_uri_format
        The fixed URI format of an output channel. May use "ANY" for a list of possible values.

    uri_case
        The URI case of an output channel. May use "ANY" for a list of possible values.

    use_slug
        A boolean indicating whether story slugs should be used for file names in an output channel.

    burner
        A burner constant as exported by this class. May use "ANY" for a list of possible values.

    active
        A boolean indicating whether or not an output channel is active.

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: NONE.

    Notes: NONE.

$ocs_href = Bric::Biz::OutputChannel->href( $criteria )
    Returns an anonymous hash of Output Channel objects, where each hash key is an Output Channel ID, and each value is Output Channel object that corresponds to that ID. Takes the same arguments as list().

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: NONE.

    Notes: NONE.

  Destructors

$self->DESTROY
    Dummy method to prevent wasting time trying to AUTOLOAD DESTROY.

  Public Class Methods

($id_aref || @ids) = Bric::Biz::OutputChannel->list_ids( $criteria )
    Returns a list or anonymous array of Bric::Biz::OutputChannel object IDs based on the search criteria passed via an anonymous hash. The supported lookup keys are the same as for list().

    Throws:

    *   Unable to prepare SQL statement.

    *   Unable to connect to database.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: NONE.

    Notes: NONE.

my $meths = Bric::Biz::OutputChannel->my_meths
my (@meths || $meths_aref) = Bric::Biz::OutputChannel->my_meths(TRUE)
my (@meths || $meths_aref) = Bric::Biz::OutputChannel->my_meths(0, TRUE)
    Returns an anonymous hash of introspection data for this object. If called with a true argument, it will return an ordered list or anonymous array of introspection data. If a second true argument is passed instead of a first, then a list or anonymous array of introspection data will be returned for properties that uniquely identify an object (excluding "id", which is assumed).

    Each hash key is the name of a property or attribute of the object. The value for a hash key is another anonymous hash containing the following keys:

    name
        The name of the property or attribute. Is the same as the hash key when an anonymous hash is returned.

    disp
        The display name of the property or attribute.

    get_meth
        A reference to the method that will retrieve the value of the property or attribute.

    get_args
        An anonymous array of arguments to pass to a call to get_meth in order to retrieve the value of the property or attribute.

    set_meth
        A reference to the method that will set the value of the property or attribute.

    set_args
        An anonymous array of arguments to pass to a call to set_meth in order to set the value of the property or attribute.

    type
        The type of value the property or attribute contains. There are only three types:

        short
        date
        blob
    len If the value is a 'short' value, this hash key contains the length of the field.

    search
        The property is searchable via the list() and list_ids() methods.

    req The property or attribute is required.

    props
        An anonymous hash of properties used to display the property or attribute. Possible keys include:

        type
            The display field type. Possible values are

            text
            textarea
            password
            hidden
            radio
            checkbox
            select
        length
            The Length, in letters, to display a text or password field.

        maxlength
            The maximum length of the property or value - usually defined by the SQL DDL.

    rows
        The number of rows to format in a textarea field.

    cols
        The number of columns to format in a textarea field.

    vals
        An anonymous hash of key/value pairs reprsenting the values and display names to use in a select list.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

  Public Instance Methods

$id = $oc->get_id
    Returns the OutputChannel's unique ID.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$oc = $oc->set_name( $name )
    Sets the name of the Output Channel.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$name = $oc->get_name()
    Returns the name of the Output Channel.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$oc = $oc->set_description( $description )
    Sets the description of the Output Channel.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$description = $oc->get_description()
    Returns the description of the Output Channel.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$id = $oc->get_site_id()
    Returns the ID of the site this OC is a part of

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$id = $oc->set_site_id($id)
    Set the ID this OC should be a part of

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$proto = $oc->get_protocol()
    Returns the protocol for this OC (http://, ftp://, etc)

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$proto = $oc->set_protocol($proto)
    Set the protocol for this OC

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$oc = $oc->set_filename($filename)
    Sets the filename that will be used in the names of files burned into this Output Channel.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$filename = $oc->get_filename
$filename = $oc->get_filename($asset)
    Gets the filename that will be used in the names of files burned into this Output Channel. Defaults to the value of the DEFAULT_FILENAME configuration directive if unset. The value of the "uri_case" property affects the case of the filename returned. If <$asset> is passed in, then "get_filename()" will return the proper filename for that asset based on the value of the "use_slug" property and on the class of the asset object.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$oc = $oc->set_file_ext($file_ext)
    Sets the filename extension that will be used in the names of files burned into this Output Channel.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$file_ext = $oc->get_file_ext
    Gets the filename extension that will be used in the names of files burned into this Output Channel. Defaults to the value of the DEFAULT_FILE_EXT configuration directive if unset. The case of the file extension returned is affected by the value of the "uri_case" property.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$oc = $oc->set_primary( undef || 1)
    Set the flag that indicates whether or not this is the primary Output Channel.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

(undef || 1 ) = $oc->get_primary
    Returns true if this is the primary Output Channel and false (undef) if it is not.

    Throws: NONE.

    Side Effects: NONE.

    Notes: Only one Output channel can be the primary output channel.

$oc = $oc->set_uri_format($uri_format)
    Sets the URI format for documents output in this Output Channel. URI formats are made up of a number of possible parts, that can be arranged in any combination and order of any of the following parts:

    %{categories}
        The category URI. This is the only part that is required in all formats.

    %{slug}
        The story slug. Not used for media URIs.

    %{uuid}
        The document UUID.

    %{base64_uuid}
        The base64-encoded document UUID.

    %{hex_uuid}
        The hex representation of the document UUID.

    *   Arbitrary strings. You can even ignore the "uri_prefix" and "uri_suffix" attributes, if you like.

    %Y  The four-digit cover date year.

    %m  The two-digit cover date month.

    %d  The two-digit cover date month.

    etc.
        Any other DateTime-supproted "strftime" format.

    Throws:

    *   No URI Format value specified.

    *   Invalid URI Format tokens.

    Side Effects: NONE.

    Notes: NONE.

my $format = $oc->get_uri_format
    Returns the URI format for documents output in this Output Channel.

    Throws: NONE.

    Side Effects: NONE.

    Notes: Only one Output channel can be the uri_format output channel.

$oc = $oc->set_fixed_uri_format($uri_format)
    Sets the fixed URI format for documents output in this Output Channel.

    Throws:

    *   No Fixed URI Format value specified.

    *   Invalid Fixed URI Format tokens.

    Side Effects: NONE.

    Notes: NONE.

(undef || 1 ) = $oc->can_use_slug
    Returns true if this is Output Channel can use the "slug" property of a story as the filename for files output for the story.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$oc = $oc->use_slug_on
    Sets the "use_slug" property to a true value.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$oc = $oc->use_slug_off
    Sets the "use_slug" property to a false value.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$burner = $oc->get_burner
    Returns the burner with which the output channel is associated.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$oc = $oc->set_burner($burner)
    Sets the value corresponding to the burner with which this output channel is associated. The value must correspond to one of the burner constants exportable by this class:

    BURNER_MASON
    BURNER_TEMPLATE
    BURNER_TT
    BURNER_PHP

    ##############################################################################

my @inc = $oc->get_includes
my $inc_aref = $oc->get_includes
    Returns a list or anonymous array of Bric::Biz::OutputChannel objects that constitute the include list for this OutputChannel. Templates not found in this OutputChannel will be sought in this list of OutputChannels, looking at each one in the order in which it was returned from this method.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    *   Incorrect number of args to Bric::_set().

    *   Bric::set() - Problems setting fields.

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: NONE.

    Notes: NONE.

$job = $job->add_includes(@ocs)
    Adds Output Channels to this to the include list for this Output Channel. Output Channels added to the include list via this method will be appended to the end of the include list. The order can only be changed by resetting the entire include list via the set_includes() method. Call save() to save the relationship.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    *   Incorrect number of args to Bric::_set().

    *   Bric::set() - Problems setting fields.

    Side Effects: NONE.

    Notes: Uses Bric::Util::Coll::Server internally.

$self = $job->del_includes(@ocs)
    Deletes Output Channels from the include list. Call save() to save the deletes to the database.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    *   Incorrect number of args to Bric::_set().

    *   Bric::set() - Problems setting fields.

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: NONE.

    Notes: NONE.

$self = $self->set_includes(@ocs);
    Sets the list of Output channels to set as the include list for this Output Channel. Any existing Output Channels in the includes list will be removed from the list. To add Output Channels to the include list without deleting the existing ones, use add_includes().

    Throws:

    *   Output Channel cannot include itself.

    Side Effects: NONE.

    Notes: NONE.

$self = $oc->activate
    Activates the Bric::Biz::OutputChannel object. Call $oc->save to make the change persistent. Bric::Biz::OutputChannel objects instantiated by new() are active by default.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$self = $oc->deactivate
    Deactivates (deletes) the Bric::Biz::OutputChannel object. Call $oc->save to make the change persistent.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$self = $oc->is_active
    Returns $self (true) if the Bric::Biz::OutputChannel object is active, and undef (false) if it is not.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$self = $oc->save
    Saves any changes to the Bric::Biz::OutputChannel object. Returns $self on success and undef on failure.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to execute SQL statement.

    *   Unable to select row.

    *   Incorrect number of args to _set.

    *   Bric::_set() - Problems setting fields.

    Side Effects: NONE.

    Notes: NONE.

PRIVATE

  Private Class Methods

_do_list
    Called by list and list ids this does the brunt of their work.

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: NONE.

    Notes: NONE.

  Private Instance Methods

_do_update()
    Will perform the update to the database after being called from save.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to execute SQL statement.

    *   Unable to select row.

    *   Incorrect number of args to _set.

    *   Bric::_set() - Problems setting fields.

    Side Effects: NONE.

    Notes: NONE.

_do_insert
    Will do the insert to the database after being called by save

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to execute SQL statement.

    *   Unable to select row.

    *   Incorrect number of args to _set.

    *   Bric::_set() - Problems setting fields.

    Side Effects: NONE.

    Notes: NONE.

  Private Functions

my $inc_coll = &$get_inc($self)
    Returns the collection of Output Channels that costitute the includes. The collection a Bric::Util::Coll::OCInclude object. See Bric::Util::Coll for interface details.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    *   Unable to prepare SQL statement.

    *   Unable to connect to database.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    *   Incorrect number of args to Bric::_set().

    *   Bric::set() - Problems setting fields.

    Side Effects: NONE.

    Notes: NONE.

my $uri_format = $parse_uri_format->($name, $format)
    Parses a URI format as passed to "set_uri_format()" or "set_fixed_uri_format()" and returns it if it parses properly. If it doesn't, it throws an exception. The $name attribute is used in the exceptions.

    Throws:

    *   No URI Format value specified.

    *   Invalid URI Format tokens.

    Side Effects: NONE.

    Notes: NONE.

NOTES
NONE.

AUTHORS
Michael Soderstrom <miraso@pacbell.net>

David Wheeler <david@kineticode.com>

SEE ALSO
perl, Bric, Bric::Biz::Asset::Business, Bric::Biz::ElementType, Bric::Biz::Asset::Template.