Bric::Biz::ElementType::Parts::FieldType(3)

NAME
Bric::Biz::ElementType::Parts::FieldType - Bricolage Field Type management

VERSION
$LastChangedRevision$

DATE
$LastChangedDate: 2005-10-25 05:07:41 +0200 (Tue, 25 Oct 2005) $

SYNOPSIS
 $field = Bric::Biz::ElementType::Parts::FieldType->new( $initial_state )

 $field = Bric::Biz::ElementType::Parts::FieldType->lookup( { id => $id } )

 ($field_list || @fields) = Bric::Biz::ElementType::Parts::FieldType->list($criteria)

 ($ids || @ids) = Bric::Biz::ElementType::Parts::FieldType->list_ids($criteria)

 $id    = $field->get_id()

 # Get/Set the name of this field.
 $field = $field->set_key_name($name)
 $name  = $field->get_key_name()

 # Get/set the description for this field.
 $field = $field->set_description($description)
 $desc  = $field->get_description()

 # Get/Set the maximum length for the data in this field.
 $field = $field->set_max_length($max_length)
 $max   = $field->get_max_length()

 # Get/Set whether this field is required or not.
 $field       = $field->set_required(1 || undef)
 (1 || undef) = $field->get_required()

 # Get/Set the quantifier flag.
 $field      = $field->set_quantifier( $quantifier )
 $quantifier = $field->get_quantifier()

 # Get/Set the data type (or SQL type) of this field.
 $field    = $field->set_sql_type();
 $sql_type = $field->get_sql_type()

 # Set the active flag for this field.
 $field       = $field->activate()
 $field       = $field->deactivate()
 (undef || 1) = $field->is_active()

 (undef || $self) = $field->remove()

 $field = $field->save()

DESCRIPTION
This class holds the data about data that will eventualy populate Published Assets. The "key_name" and "description" fields can be set as can a number of rules.

The max length field. This will allow someone to set the max length allowed for their field. It will have a rule set upon it so that the max length will not be greater than any available storage. The field length will map to what ever storarge is available for a field just larger than the one listed ( Thought needs to be given how to handle those that change their length after data has been entered as it might switch storage catagories)

The quantifier field will state whether the field may be repeated indefinitely, zero or more times, zero or one, one, or an arbitrary number of times.

the sql type will map to a type in the DB ( varchar or date )

INTERFACE

  Constructors

$field = Bric::Biz::ElementType::Parts::FieldType->new( $initial_state )
    Creates a new element type Field Part with the values associated with the initial state

    Supported Keys:

    •   element_type_id (required)

    •   meta_object

    •   key_name

    •   description

    •   place

    •   required

    •   quantifier

    •   sql_type

    •   active

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$field = $field->copy($at_id);
    Makes a copy of itself and passes back a new object. The only argument is an element type ID. This needs to be passed since a field of one name cannot be inserted twice into the same element type.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$field = Bric::Biz::ElementType::Parts::FieldType->lookup({ id => $id })
    Returns an existing element type field object that has the id that was given as an argument

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

($parts || @parts) = Bric::Biz::ElementType::Parts::FieldType->list($params)
    Returns a list or array refeference of field objects that match the criteria in the $params hash reference. Supported criteria are:

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

    element_type_id
        The ID of the Bric::Biz::ElementType object with which the field is associated. May use "ANY" for a list of possible values.

    key_name
        The field key name. May use "ANY" for a list of possible values.

    name
        The field name. May use "ANY" for a list of possible values.

    description
        The field description. May use "ANY" for a list of possible values.

    place
        The field place relative to other fields in the same element type. May use "ANY" for a list of possible values.

    quantifier
        Boolean value indicating whether the field is single or can be multiple.

    autopopulated
        Boolean value indicating whether the field's value is autopopulated by a media document.

    max_length
        The maximum length of the field. May use "ANY" for a list of possible values.

    required
        Boolean value indicating whether or not the field is always included in an element.

    sql_type
        Indicates how the field value should be stored in the database. Possible values are "short", "blob", and "date". May use "ANY" for a list of possible values.

    widget_type
        A string indicating what widget should be used to display the field in user interfaces. May use "ANY" for a list of possible values.

    precision
        An inteteger indicating the precision of the field's value. Should be set only when the "widget_type" is set to "date". May use "ANY" for a list of possible values.

    cols
        The number of columns to use to display the field. Should only be set when the "widget_type" is set to "textarea" or "wysiwyg". May use "ANY" for a list of possible values.

    rows
        The number of rows to use to display the field. Should only be set when the "widget_type" is set to "textarea" or "wysiwyg". May use "ANY" for a list of possible values.

    length
        The length to use in the display of the field. Should only be set when the "widget_type" is set to "text". May use "ANY" for a list of possible values.

    multiple
        A boolean value indicating whether or not the field may store multiple values. Should only be set to a true value when the "widget_type" is set to "select".

    default_val
        A string indicating the default value for the field. May use "ANY" for a list of possible values.

    active
        Boolean valule indicating whether or not the field is active.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

my $data_href = Bric::Biz::Site->href($params);
    Returns an anonymous hash of data objects based on the search parameters passed via an anonymous hash. The hash keys will be the site IDs, and the values will be the corresponding data elements. The supported lookup keys are the same as those for "list()".

    Throws:

    Exception::DA

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

  Public Class Methods

$meths = Bric::Biz::ElementType->my_meths
(@meths || $meths_aref) = Bric::Biz::ElementType->my_meths(TRUE)
my (@meths || $meths_aref) = Bric::Biz::ElementType->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: Not yet written.

($ids || @ids) = Bric::Biz::ElementType::Parts::Field->list_ids($params)
    Returns the ids of the field objects that match the given criteria in the $params hash reference. See "list()" for a list of supported parameters.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

  Public Instance Methods

$id = $field->get_id()
    Returns the database id of the field object.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$name = $field->get_name()
    Gets the name of the field.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_name($name)
    Sets the name of the field.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$key_name = $field->get_key_name()
    Returns the key name.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_key_name($key_name)
    Sets the key name for this field.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$description = $field->get_description()
    Return the human readable description field

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_description($description)
    Sets the human readable descripton for this field

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$max_length $field->get_max_length()
    Return the max length that has been registered

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_max_length($max_length)
    Set the max length in chars for this field

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$required = $field->get_required()
    Return the required flag for this field

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_required($required)
    Set the flag to make this field required ( default is not)

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$repeatable = $field->get_quantifier()
    Return the repeatablity flag

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_quantifier($repeatable)
    Sets the boolean attribute that indicates whether or not the field is repeatable within the element.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$data_type = $field->get_data_type()
    Returns the database datatype

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_data_type($data_type)
    Returns the database datatype

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$widget_type = $field->get_widget_type()
    Returns a string indicating how to display the field in a UI.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_widget_type($widget_type)
    Sets the attribute indicating how to display the field in a UI. Possible values are:

    text
    textarea
    select
    pulldown
    radio
    checkbox
    codeselect
    wysiwyg
    date

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$precision = $field->get_precision()
    Returns an inteteger indicating the precision of the field's value. Should be set only when the "widget_type" is set to "date".

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_precision($precision)
    Sets the precision for "widget_type" "date". See Bric::Util::Time for documentation of the available precisions.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_cols($cols)
    Sets the number of columns to use in displaying the field in a UI. Should only be set to a non-zero value if the "widget_type" attribute is set to "textarea" or "wysiwyg".

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$cols = $field->set_cols()
    Returns the number of columns to use in display the field in a UI.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_rows($rows)
    Sets the number of rows to use in displaying the field in a UI. Should only be set to a non-zero value if the "widget_type" attribute is set to "textarea" or "wysiwyg".

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$rows = $field->set_rows()
    Returns the number of rows to use in display the field in a UI.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_length($length)
    Sets the length to use in displaying the field in a UI. Should only be set to a non-zero value if the "widget_type" attribute is set to "text".

    Thlength: NONE.

    Side Effects: NONE.

    Notes: NONE.

$length = $field->set_length()
    Returns the number of length to use in display the field in a UI.

    Thlength: NONE.

    Side Effects: NONE.

    Notes: NONE.

$multiple = $field->get_multiple()
    Returns boolean value indicating whether the field can have multiple values.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_multiple($multiple)
    Sets boolean value indicating whether the field can have multiple values. Should only be set to a true value if the "widget_type" is "select".

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$default_val = $field->get_default_val()
    Returns the default value for the field.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_default_val($default_val)
    Sets the default value for the field.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$vals = $field->get_vals()
    Returns a string representing the possible values for the field.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$field = $field->set_vals($vals)
    Sets a list of values that can be used for the field. Each potential value should be listed on a single line, with a label following the value, separated by a comma and optional whitespace. Commas in the value or the label should be escaped. For example:

      larry,  Wall\, Larry
      damian, Conway\, Damian
      chip,   Salzenberg\, Chip

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$val = $data->set_attr($name, $value);
$val = $data->get_attr($name);
    Get/Set attributes on this element type.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$val = $data->set_meta($name, $field, $value);
$val = $data->get_meta($name, $field);
$val = $data->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.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$field = $field->activate()
    Activates the field type object.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$field = $field->deactivate()
    Deactivates the field type object.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

(undef || 1) = $field->is_active()
    Returns 1 if active or undef otherwise

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

(undef || $self) = $field->remove()
    Removes this object completely from the DB. Returns true if active or false otherwise.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$field = $field->save()
    Saves the changes made to the database

    Throws:

    NONE

    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:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

  Private Instance Methods
Needing to be documented.

_get_attr_obj
_update_data
    Update the field_type table.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

_insert_data
    Insert rows into the field_type table.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

  Private Functions
NONE

NOTES
NONE

AUTHOR
michael soderstrom ( miraso@pacbell.net )

SEE ALSO
perl,Bric,Bric::Biz::Asset::Business::Story,Bric::Biz::ElementType,