Bric::Biz::ElementType - Bricolage element types
# Create new types of elements.
$element = Bric::Biz::ElementType->new($init)
$element = Bric::Biz::ElementType->lookup({id => $id})
($at_list || @ats) = Bric::Biz::ElementType->list($param)
($id_list || @ids) = Bric::Biz::ElementType->list_ids($param)
# Return the ID of this object.
$id = $element->get_id()
# Get/set this element type's name.
$element = $element->set_name( $name )
$name = $element->get_name()
# Get/set the description for this element type
$element = $element->set_description($description)
$description = $element->get_description()
# Get/set the primary output channel ID for this element type.
$element = $element->set_primary_oc_id($oc_id, $site_id);
$oc_id = $element->get_primary_oc_id($site_id);
# Attribute methods.
$val = $element->set_attr($name, $value);
$val = $element->get_attr($name);
\%val = $element->all_attr;
# Attribute metadata methods.
$val = $element->set_meta($name, $meta, $value);
$val = $element->get_meta($name, $meta);
# Manage output channels.
$element = $element->add_output_channels([$output_channel])
($oc_list || @ocs) = $element->get_output_channels()
$element = $element->delete_output_channels([$output_channel])
# Manage sites
$element = $element->add_sites([$site])
($site_list || @sites) = $element->get_sites()
$element = $element->remove_sites([$site])
# Manage the parts of an element type.
$element = $element->add_field_types($field);
$field_type = $element->new_field_type($param);
$element = $element->copy_field_type($at, $field);
($part_list || @parts) = $element->get_field_types($field);
$element = $element->del_field_types($field);
# Add, retrieve and delete containers from this element type.
$element = $element->add_containers($at || [$at]);
(@at_list || $at_list) = $element->get_containers();
$element = $element->del_containers($at || [$at]);
# Get/set the active flag.
$element = $element->activate()
$element = $element->deactivate()
(undef || 1) = $element->is_active()
# Save this element type.
$element = $element->save()
The element type class registers new type of elements that define the structures of story and media documents. Element type objects are composed of subelement types and fields, and top-level (story and media type) element types are associated with sites and output channels to define how documents based on them will be output and in what sites they can be created.
Will return a new element type object with the optional initial state
Supported Keys:
Defaults to false.
Defaults to false.
Defaults to false.
Defaults to false.
Defaults to false.
Defaults to false.
Defaults to false.
Defaults to the ID for Bric::Biz::Asset::Business::Story.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Looks up and instantiates a new Bric::Biz::ElementType object based on the Bric::Biz::ElementType object ID or name passed. If $id or $key_name is not found in the database, lookup() returns undef.
Throws:
Too many Bric::Biz::ElementType objects found.
Side Effects: NONE
Notes: NONE
This will return a list of objects that match the criteria defined.
Supported Keys:
Element ID. May use ANY for a list of possible values.
The name of the element type. Matched with case-insentive LIKE. May use ANY for a list of possible values.
The unique key name of the element type. Matched with case insensitive LIKE. May use ANY for a list of possible values.
The description of the element type. Matched with case-insentive LIKE. May use ANY for a list of possible values.
The ID of an output channel. Returned will be all ElementType objects that contain this output channel. May use ANY for a list of possible values.
The name of an ElementType::Parts::FieldType (field type) object. Returned will be all ElementType objects that reference this particular field type object. May use ANY for a list of possible values.
Boolean value for active or inactive element types.
Match elements of a particular attype. May use ANY for a list of possible values.
Match against the given site_id. May use ANY for a list of possible values.
Boolean value for top-level (story type and media type) element types.
Boolean value for media element types.
Boolean value for paginated element types.
Boolean value for fixed URI element types.
Boolean value for displayed element types.
Boolean value for related story element types.
Boolean value for related media element types.
The ID of a Bric::Util::Class object representing a business class. The ID must be for a class object representing one of Bric::Biz::Asset::Business::Story, Bric::Biz::Asset::Business::Media, or one of its subclasses. May use ANY for a list of possible values.
ElementType id for children with the specified id.
ElementType id for parents with the specified id
Throws:
This will return a list of objects that match the criteria defined. See the list() method for the allowed keys of the $param hash reference.
Throws:
NONE
Side Effects:
NONE
Notes:
NONE
Dummy method to prevent wasting time trying to AUTOLOAD DESTROY.
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:
The name of the property or attribute. Is the same as the hash key when an anonymous hash is returned.
The display name of the property or attribute.
A reference to the method that will retrieve the value of the property or attribute.
An anonymous array of arguments to pass to a call to get_meth in order to retrieve the value of the property or attribute.
A reference to the method that will set the value of the property or attribute.
An anonymous array of arguments to pass to a call to set_meth in order to set the value of the property or attribute.
The type of value the property or attribute contains. There are only three types:
If the value is a 'short' value, this hash key contains the length of the field.
The property is searchable via the list() and list_ids() methods.
The property or attribute is required.
An anonymous hash of properties used to display the property or attribute. Possible keys include:
The display field type. Possible values are
The Length, in letters, to display a text or password field.
The maximum length of the property or value - usually defined by the SQL DDL.
The number of rows to format in a textarea field.
The number of columns to format in a textarea field.
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.
my $id = $element_type->get_id;
Returns the element type object's unique database ID.
my $name = $element_type->get_name;
$element_type = $element_type->set_name($name);
Get and set the element type object's unique name.
my $description = $element_type->get_description;
$element_type = $element_type->set_description($description);
Get and set the element type object's description. The setter converts non-Unix line endings.
my $key_name = $element_type->get_key_name;
$element_type = $element_type->set_key_name($key_name);
Get and set the element type object's unique key name.
my $is_top_level = $element_type->is_top_level;
$element_type = $element_type->set_top_level($is_top_level);
The top_level attribute is a boolean that indicates whether the element type is a story type or a media type, and therefore a top-level element. In other words, elements based on it cannot be subelements of any other elements.
my $biz_type_id = $element_type->get_biz_type_id;
$element_type = $element_type->set_biz_type_id($biz_type_id);
The biz_type_id attribute is contains the ID for a Bric::Util::Class|Bric::Util::Class indicating the class of object with whic the elements based on the type can be associated. The values allowed are only those for Bric::Biz::Asset::Business::Story, Bric::Biz::Asset::Business::Media, and the latter's subclasses.
my $is_paginated = $element_type->is_paginated;
$element_type = $element_type->set_paginated($is_paginated);
The paginated attribute is a boolean that indicates whether the elements based on the element type represent pages. Paginated elements generally trigger the output of multiple files, one for each paginated element in a document, by the burner. This attribute is ignored for top level elements.
my $is_fixed_uri = $element_type->is_fixed_uri;
$element_type = $element_type->set_fixed_uri($is_fixed_uri);
The fixed_uri attribute is a boolean that indicates whether documents based on the element type will use the "URI Format" or "Fixed URI Format" of an output channel through which the document is published. This attribute is ignored for non-top level elements.
my $is_related_story = $element_type->is_related_story;
$element_type = $element_type->set_related_story($is_related_story);
The related_story attribute is a boolean that indicates whether elements based on the element type can have another story related to them.
my $is_related_media = $element_type->is_related_media;
$element_type = $element_type->set_related_media($is_related_media);
The related_media attribute is a boolean that indicates whether elements based on the element type can have another media related to them.
my $is_media = $element_type->is_media;
$element_type = $element_type->set_media($is_media);
The media attribute is a boolean that indicates whether elements based on the element type are media documents. This attribute is a redundant combination fo the biz_type_id and top_level attributes.
my $is_displayed = $element_type->is_displayed;
$element_type = $element_type->set_displayed($is_displayed);
The displayed attribute is a boolean that indicates whether elements based on the element type are displayed in the document profile when they are first created. Note that it's ignored for top-level elements.
my $biz_class_id = $element_type->get_biz_class_id;
my $biz_class_name = $element_type->get_biz_class;
$element_type->set_biz_class_id($biz_class_id);
Get and set the ID of the Bric::Util::Class object that represents the class for which elements of this type can be created. Must be the ID for either Bric::Biz::Asset::Business::Story, Bric::Biz::Asset::Business::Media, or one of its subclasses. get_biz_class() actually returns the package name of the business class represented by the biz_class_id attribute.
my $primary_oc_id = $element_type->get_primary_oc_id($site_id);
$primary_oc_id = $element_type->get_primary_oc_id($site);
$element_type->set_primary_oc_id($primary_oc_id, $site_id);
$element_type->set_primary_oc_id($primary_oc_id, $site);
Gets and sets the primary output channel within the given site for the element type. Either a site object or ID can be used. Only top-level element types have site and output channel associations.
Throws:
No site parameter passed to Bric::Biz::ElementType->set_primary_oc_id
No output channels associated with non top-level element types.
Side Effects: NONE.
Notes: NONE.
my $is_active = $element_type->is_active;
$element_type->activate;
$element_type->deactivate;
This boolean attribute indicates whether the element type is active.
my @ocs = $element_type->get_output_channels;
@ocs = $element_type->get_output_channels(@oc_ids);
my $ocs_aref = $element_type->get_output_channels;
$ocs_aref = $element_type->get_output_channels(@oc_ids);
Returns a list or array reference of output channels that have been associated with this element type. If @oc_ids is passed, then only the output channels with those IDs are returned, if they're associated with this element type.
Throws: NONE.
Side Effects: NONE.
Notes: The objects returned will be Bric::Biz::OutputChannel::Element objects, and these objects contain extra information relevant to the assocation between each output channel and this element object.
$element_type->add_output_channel($oc);
$element_type->add_output_channel($oc_id);
Adds an output channel to this element object and returns the resulting Bric::Biz::OutputChannel::Element object. Can pass in either an output channel object or an output channel ID.
Throws: NONE.
Side Effects: If a Bric::Biz::OutputChannel object is passed in as the first argument, it will be converted into a Bric::Biz::OutputChannel::Element object.
Notes: NONE.
$element_type->add_output_channels(@ocs);
$element_type->add_output_channels(\@ocs);
$element_type->add_output_channels(@oc_ids);
$element_type->add_output_channels(\@oc_ids);
This accepts a list or array reference of output channel objects or IDs to be associated with this element type.
Throws: NONE.
Side Effects: Any Bric::Biz::OutputChannel objects passed in will be converted into Bric::Biz::OutputChannel::Element objects.
Notes: NONE.
$element_type->delete_output_channels(@output_channels);
$element_type->delete_output_channels(\@output_channels);
This accepts a list or array reference of output channels and removes their association from the object.
Throws:
Cannot delete a primary output channel.
Side Effects: NONE.
Notes: NONE.
my @sites = $element_type->get_sites;
@sites = $element_type->get_sites(@site_ids);
my $sites_aref = $element_type->get_sites;
$sites_aref = $element_type->get_sites(@site_ids);
Returns a list or array reference of sites that have been asssociated with this element type. If @site_ids is passed, then only the sites with those IDs are returned, if they're associated with this element type.
Throws: NONE.
Side Effects: NONE.
Notes: The objects returned will be Bric::Biz::Site objects, and these objects contain extra information relevant to the assocation between each output channel and this element object.
$element_type->add_site($site);
$element_type->add_site($site_id);
Adds a site to this element object and returns the resulting Bric::Biz::Site object. Can pass in either an site object or a site ID.
Throws:
You can only add sites to top level objects
Cannot add sites to non top-level element types.
No such site.
Side Effects: NONE.
Notes: NONE.
$element_type->add_sites(@sites);
$element_type->add_sites(\@sites);
$element_type->add_sites(@site_ids);
$element_type->add_sites(\@site_ids);
This accepts a list or array reference of site objects or IDs to be associated with this element type.
Throws:
You can only add sites to top level objects
Couldn't find site
Side Effects: NONE.
Notes: NONE.
$element_type->remove_sites(@sites);
$element_type->remove_sites(\@sites);
Removes a list or array reference of sites from association with the element type.
Throws:
Cannot remove last site from an element type.
Side Effects: Also disassociates any output channels for the site that are associated with this element.
Notes: NONE.
my @field_types = $element_type->get_field_types;
my $field_type = $element_type->get_field_types($key_name);
@field_types = $element_type->get_data;
$field_type = $element_type->get_data($key_name);
Returns a list or array reference of the field types that the element type contains. Pass in a key name to get back a single field type.
Note: get_data() is the deprecated form of this method.
$element_type->add_field_types(@field_types);
$element_type->add_field_types(\@field_types);
$element_type->add_data(@field_types);
$element_type->add_data(\@field_types);
This takes a list of field typess and associates them with the element type object.
Note: add_data() is the deprecated form of this method.
my $field_type = $element_type->new_field_type(\%params);
$field_type = $element_type->new_data(\%params);
Adds a new field type to the element type, creating a new Bric::Biz::ElementType::Parts::FieldType object. See Bric::Biz::ElementType::Parts::FieldType for a list of the parameters to its new() method for the parameters that can be specified in the parameters hash reference passsed to new_field_type().
Note: new_data() is the deprecated form of this method.
my $field_type = $element_type->copy_field_type(\%params);
$field_type = $element_type->copy_data(\%params);
Copies the definition for a field type from another eelement type. The parameters expected in the hash reference argument are:
The field type object to copy into this element type. Required unless element_type and field_key_name have been specified.
An existing element type object from which to extract a field to copy. Required unless field_type has been specified.
The key name of a field associated with the element type passed via the element_type parameter. Required unless field_type has been specified.
Note: copy_data() is the deprecated form of this method.
$element_type->del_field_types(@field_types);
$element_type->del_field_types(\@field_types);
$element_type->del_data(@field_types);
$element_type->del_data(\@field_types);
Removes the specified field types from the element type.
Note: del_data() is the deprecated form of this method.
$element_type->add_containers(@element_types);
$element_type->add_containers(\@element_types);
$element_type->add_containers(@element_type_ids);
$element_type->add_containers(\@element_type_ids);
Add element types to the element type as subelement types. This function accepts a list or array reference of ElementTypes, or ElementType ids.
Throws: NONE.
Side Effects: Any Bric::Biz::ElementType objects passed in will be converted into Bric::Biz::ElementType::Subelement objects.
Notes: NONE.
$element_type->add_container($et);
$element_type->add_container($et_id);
Adds a subelement to this element type object and returns the resulting Bric::Biz::ElementType::Subelement object. Can pass in either an ElementType object or an ElementType ID.
Throws: NONE.
Side Effects: If a Bric::Biz::ElementType object is passed in as the first argument, it will be converted into a Bric::Biz::ElementType::Subelement object.
Notes: NONE.
my @element_types = $element_type->get_containers;
my @element_types = $element_type->get_containers(@et_ids);
my $element_types_aref = $element_type->get_containers;
my $element_types_aref = $element_type->get_containers(@et_ids);
my $element_type = $element_type->get_containers($key_name);
Returns a list or array reference of subelement element types. If @et_ids is passed, then only the subelements with those IDs are returned, if they are indeed children of this container.
Throws: NONE.
Side Effects: NONE.
Notes: The objects returned will be Bric::Biz::ElementType::Subelement objects, and these objects contain extra information relevant to the assocation between each subelement of this container, and the container itself.
$element_type->del_containers(@element_types);
$element_type->del_containers(\@element_types);
Remove subelement element types from the element type. The subelement element types will not be deactivated, just disassociated with the parent element type.
$element_type->save;
Saves changes to the element type, including its subelement element type and field type associatesions, to the database.
$val = $element_type->set_attr($name => $value);
$val = $element_type->get_attr($name);
$val = $element_type->del_attr($name);
Get/Set/Delete attributes on this element type.
$val = $element_type->set_meta($name, $field => $value);
$val = $element_type->get_meta($name => $field);
$val = $element_type->get_meta($name);
Get/Set attribute metadata on this element type. Calling the get_meta() method without $field returns all metadata names and values as a hash.
called from list and list ids this will query the db and return either ids or objects
These need documenting.
Removes this object completely from the DB. Returns 1 if active or undef otherwise
Update values in the element_type table.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Insert new values into the element_type table.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Call the list function of Bric::Biz::ElementType::Parts::Container to return a list of conainer parts of this ElementType object, or return the existing parts if weve already loaded them.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Returns the collection of output channels for this element type. The collection is a Bric::Util::Coll::OCElement object. See that class and its parent, 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.
Returns the collection of sites for this element type. The collection is a Bric::Util::Coll::Site object. See that class and its parent, 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.
Returns the collection of subelements for this element type. The collection is a Bric::Util::Coll::Subelement object. See that class and its parent, 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.
Takes an element type name and turns it into the key name. This is the name that will be used in templates and in the super bulk edit interface.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
NONE.
Michael Soderstrom <miraso@pacbell.net>
Refactored by David Wheeler <david@kineticode.com>