Bric::Biz::Category(3pUser Contributed Perl DocumentatiBric::Biz::Category(3p)



NAME
       Bric::Biz::Category - A module to group assets into categories.

VERSION
       $LastChangedRevision$

DATE
       $LastChangedDate: 2007-06-14 10:40:30 +0200 (Thu, 14 Jun 2007) $

SYNOPSIS
        # Return a new category object.
        my $cat = Bric::Biz::Category->new($init);

        # Look up an existing category object.
        my $cat = Bric::Biz::Category->lookup({'id' => $cat_id});

        # Search for a list of categories.
        my @cats = Bric::Biz::Category->list($crit);

        # Attribute accessors.
        my $id = $cat->get_id;
        my $name = $cat->get_name;
        $cat = $cat->set_name($name);
        my $desc = $cat->get_description;
        $cat = $cat->set_description($desc);
        my $site_id = $cat->get_site_id;
        $cat = $cat->set_site_id($site_id);

        # Return a list of child categories of this category.
        @cats   = $cat->get_children();
        # Return the parent of this category.
        $parent = $cat->get_parent();

        # Attribute methods.
        $val = $element->set_attr($name, $value);
        $val = $element->get_attr($name);
        $val = $element->set_meta($name, $field, $value);
        $val = $element->get_meta($name, $field);

        # Ad string methods
        $txt = $element->get_ad_string;
        $element->set_ad_string($value);
        $txt = $element->get_ad_string2;
        $element->set_ad_string2($value);

        # Add/Delete child categories for this category.
        $cat->add_child([$cat || $cat_id]);
        $cat->del_child([$cat || $cat_id]);

        # Manage keyword associations.
        @keys = $cat->get_keywords;
        $cat->add_keywords(@keywords);
        $cat->del_keywords(@keywords);

        # Save information for this category to the database.
        $cat->save;

DESCRIPTION
       Allows assets to be grouped into categories. In addition to assets a
       category can contain other categories, allowing a hierarchical layout
       of categories and assets. New categories will inherit group memberships
       and asset group permissions from their parents, but those relationships
       will thereafter be independent of the parent's.

INTERFACE
   Constructors
       $obj = new Bric::Biz::Category($init);
           Create a new object of type Bric::Biz::Category. Once "save()"d,
           the new category will have the same group memberships as the
           parent, and have the same permissions granted to its asset group as
           are granted to the parent's asset group.

           Keys for $init are:

           o   name

               The name for this category.

           o   site_id

               The ID for the site this category is in.

           o   description

               A description of this category

           o   directory

               The directory name this category should be associated with.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       @objs = Bric::Biz::Category->lookup({ id => $cat_id });
       @objs = Bric::Biz::Category->lookup({ uri => $uri });
           Return an object given an ID or URI, both of which are unique
           across URIs.

           Throws:

           o   Too many category objects found.

           Side Effects:

           NONE

           Notes:

           NONE

       @objs = list Bric::Biz::Category($crit);
           Return a list of category objects based on certain criteria

           Criteria keys:

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

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

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

           uri The category URI. May use "ANY" for a list of possible values.

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

           parent_id
               The ID category of a parent category. May use "ANY" for a list
               of possible values.

           grp_id
               The ID of a Bric::Util::Grp object to which the category
               belongs. May use "ANY" for a list of possible values.

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

           Throws:

           "Method not implemented"

           Side Effects:

           NONE

           Notes:

           This is the default list constructor which should be overridden in
           all derived classes even if it just calls 'die'.

   Destructors
       $cat->DESTROY()
           Deletes the object.

           Throws: NONE.

           Side Effects: NONE.

           Notes: NONE.

   Public Class Methods
       my $meths = Bric::Biz::Category->my_meths
       my (@meths || $meths_aref) = Bric::Biz::Category->my_meths(TRUE)
       my (@meths || $meths_aref) = Bric::Biz::Category->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.

       my (@person_ids || $person_ids_aref) =
       Bric::Biz::Person->list_ids($params)
           Returns a list or anonymous array of Bric::Biz::Category object IDs
           based on the search criteria passed via an anonymous hash. The
           supported lookup keys are the same as those for "list()".

           Throws: NONE.

           Side Effects: NONE.

           Notes: NONE.

       $cat = Bric::Biz::Category->site_root_category($site || $site_id)
       $cat_id = Bric::Biz::Category->site_root_category_id($site || $site_id)
       $cat = $cat->site_root_category()
       $cat_id = $cat->site_root_category_id()
           Return the root category and the root category ID for a particular
           site.  If called as an instance method the site or site ID is not
           necessary;  that information will be pulled from $cat->get_site_id.

           Returns the category or category ID of the root category for this
           site.

           Throws:

           o   Could not determine the site ID for the current site.

           Side Effects: NONE.

           Notes: NONE.

   Public Instance Methods
       @objs = $cat->ancestry();
           Return all the parent category of this category

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       my $path = $cat->ancestry_path();
           An alias for get_uri().

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       my $uri = $cat->get_uri();
           Returns the list of ancestors for this category formatted into a
           URI.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       my $path = $cat->ancestry_dir();
           Returns the list of ancestors for this category formatted into a
           localized directory structure.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       my $dir = $cat->set_directory($dir);
           Sets this category's directory.

           Throws:

           NONE

           Side Effects:

           Sets the _update_uri flag, which means that when the category's
           information is saved to the database, the URI field needs to be
           updated for itself and all its children.

           Notes:

           NONE

       my $dir = $cat->set_parent_id($parent_id);
           Sets this category's parent ID, making it a child of that category.

           Throws:

           NONE

           Side Effects:

           Sets the _update_uri flag, which means that when the category's
           information is saved to the database, the URI field needs to be
           updated for itself and all its children.

           Notes:

           NONE

       $val = $element->set_ad_string($value);
       $self = $element->get_ad_string;
       $val = $element->set_ad_string2($value);
       $self = $element->get_ad_string2;
           Get/Set ad strings on this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $name = $cat->get_id;
           Return the ID of this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $name = $cat->get_name;
           Return the name of this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $self = $cat->set_name($name);
           Sets the name of this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $name = $cat->get_site_id;
           Return the site ID for this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $name = $cat->set_site_id($id);
           Set the site ID for this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $desc = $cat->get_description;
           Returns the description of this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $self = $cat->set_description($desc);
           Sets the description of this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

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

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $val = $element->set_meta($name, $field, $value);
       $val = $element->get_meta($name, $field);
           Get/Set attribute metadata on this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       @keys = $cat->get_keywords;
       @keys = $cat->get_keywords(@keyword_ids);
           Returns a list of keyword objects associated with this category. If
           passed a list of keyword IDs, it will return only those keyword
           objects.

           Throws: NONE

           Side Effects: NONE

           Notes: The old "keywords()" method has been deprecated. Please use
           "get_keywords()", instead.

       @cats = $cat->get_children;
           Returns the children of this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       my $parent = $cat->get_parent;
           Returns the parent of this category or undef if it is a top level
           category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $success = $cat->add_child([$cat || $cat_id]);
           Addes a category as a child of this category.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $cat = $cat->add_keywords(@keywords);
       $cat = $cat->add_keywords(\@keywords);
       $cat = $cat->add_keywords(@keyword_ids);
       $cat = $cat->add_keywords(\@keyword_ids);
           Associates a each of the keyword in a list or array reference of
           keywords with the category object.

           Throws: NONE.

           Side Effects: NONE

           Notes: The old "add_keyword()" method has been deprecated. Please
           use "add_keywords()", instead.

       $cat = $cat->del_keywords(@keywords);
       $cat = $cat->del_keywords(\@keywords);
       $cat = $cat->del_keywords(@keyword_ids);
       $cat = $cat->del_keywords(\@keyword_ids);
           Dissociates a list or array reference of keyword objects or IDs
           from the category object.

           Throws: NONE.

           Side Effects: NONE

           Notes: The old "del_keyword()" method has been deprecated. Please
           use "del_keywords()", instead.

       $att = $att->is_root_category;
           Return whether this is a root category or not

           Throws: NONE

           Side Effects: NONE

           Notes: NONE

       $att = $att->is_active;
       $att = $att->activate;
       $att = $att->deactivate;
           Get/Set the active flag.

           Throws:

           NONE

           Side Effects:

           NONE

           Notes:

           NONE

       $cat = $cat->save
           Save this category

           Throws: NONE.

           Side Effects: A new category will automatically be added to the
           same category groups as its parent, and permissions will be granted
           to its asset group exactly as they are granted to the parent.

           Notes: NONE.

   Private Methods
       NONE.

   Private Class Methods
       NONE

   Private Instance Methods
       Several that need documenting!

       _do_list
       _save_attr
       _load_grp
       _update_category
       _insert_category
       my $kw_coll = &$get_kw_coll($self)
           Returns the collection of keywords for this category. The
           collection is a Bric::Util::Coll::Keyword object. See that class
           and its parent, Bric::Util::Coll, for interface details.

           Throws:

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

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

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

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

           Side Effects: NONE.

           Notes: NONE.

NOTES
       NONE.

AUTHOR
       Garth Webb <garth@perijove.com>

       Jeff "japhy" Pinyan <japhy@pobox.com>

       David Wheeler <david@justatheory.com>

SEE ALSO
       perl, Bric::Util::Grp::Category, Bric, Bric::Biz::Keyword,
       Bric::Biz::Asset



perl v5.12.2                      2007-06-14           Bric::Biz::Category(3p)
