NAME

Bric::Biz::Keyword - A general class to manage keywords.

VERSION

$Revision: 1.10.2.1 $

DATE

$Date: 2002/09/04 21:08:51 $

SYNOPSIS

use Bric::Biz::Keyword;

# Create a new keyword object.
my $key = new Bric::Biz::Keyword($init);

# Lookup an existing keyword.
my $key = new Bric::Biz::Keyword($key_id);

# Create a list of keyword objects.
my $key = list Bric::Biz::Keyword($param);

# Get/set the keyword name. 
$name    = $key->get_name();
$success = $key->set_name($name);

# Get/set the screen (display) name.
$screen  = $key->get_screen_name();
$success = $key->set_screen_name($screen);

# Mark this keyword inactive
$success = $key->delete();

# Save this asset to the database.
$success = $key->save();

# Link a keyword with a story (or media object or category) 
$key->associate($story);

# Break the link between a keyword and a story (or media object or category)a
$key->dissociate($story);

DESCRIPTION

The Keyword module allows assets to be characterized by a set of topical keywords. These keywords can be used to group assets or during a search on a particular topic.

INTERFACE

Constructors

$obj = Bric::Biz::Keyword->new(\%init);

Creates a new keyword and keyword object. Keys for %init are:

name

The name of this keyword - required.

screen_name

The way this name should be displayed on screen (ie name='George', screen name='George Washington'). If not specified name will be used for screen_name.

sort_name

The word used to sort keywords. If not specified then name will be used for sort_name.

*

Throws: NONE

Side Effects: NONE

Notes: NONE

$obj = Bric::Biz::Keyword->lookup({ id => $key_id });
$obj = Bric::Biz::Keyword->lookup({ name => "key name" });

Retrieves a single existing keyword from the database. Takes either a keyword ID or the keyword name.

Throws:

Side Effects: NONE

Notes: NONE

@objs = list Bric::Biz::Keyword($param);

Searches for keywords returning matches ordered by sort_name. The possible keys to $param are the following;

name

Search for keywords by name. Matched with LIKE.

screen_name

Search for keywords by screen name. Matched with LIKE.

sort_name

Search for keywords by sort name. Matched with LIKE.

active

Search for keywords by active flag. If you don't set this flag then active => 1 is implicitely used.

synonyms

Returns all the synonyms for the given keyword or keyword ID. Cannot be legally combined with the object param.

object

Returns all keywords for a given object - may be a Bric::Biz::Category, Bric::Biz::Asse::Business::Media or a Bric::Biz::Asse::Business::Story object. Cannot be legally combined with the synonyms param.

Throws:

Side Effects: NONE

Notes: NONE

$success = $key->delete;

Marks a keyword inactive in the database. Equivalent to calling set_active(0).

Throws: NONE

Side Effects: NONE

Notes: NONE

Public Class Methods

$val = my_meths->{$key}->[0]->($obj);

Introspect this object.

Throws:

NONE

Side Effects:

NONE

Notes:

NONE

Public Instance Methods

$key->associate($obj)

Associates a keyword with an object. The object must by of a type that supports keywords - currently Bric::Biz::Asset::Business::Story, Bric::Biz::Asset:::Business::Media and Bric::Biz::Category. This call commits the change directly to the database. There is no need to call save() afterward.

Returns 0 if $key is already associated with $obj, 1 if a new relationship was created.

Throws:

Side Effects: NONE

Notes: Cannot be called on an unsaved keyword. Call save() first.

$key->dissociate($obj)

Dissociates a keyword from an object. The object must by of a type that supports keywords - currently Bric::Biz::Asset::Business::Story, Bric::Biz::Asset:::Business::Media and Bric::Biz::Category. This call commits the change directly to the database. There is no need to call save() afterward.

Returns 0 if $key is not associated with $obj, 1 if the relationship was successfully removed.

Throws:

Unsupported object type : $ref.

Side Effects: NONE

Notes: Cannot be called on an unsaved keyword. Call save() first.

$name = $key->get_name();

Returns the name of this keyword

Throws: NONE

Side Effects: NONE

Notes: NONE

$name = $key->set_name($name);

Sets the name of this keyword

Throws: NONE

Side Effects: NONE

Notes: NONE

$name = $key->get_screen_name();

Returns the screen name of this keyword. The screen name is how the synonym should be displayed on screen (i.e. name='george' screen_name='Washington, George')

Throws: NONE

Side Effects: NONE

Notes: NONE

$name = $key->set_screen_name($name);

Sets the screen name of this keyword.

Throws: NONE

Side Effects: NONE

Notes: NONE

$state = $key->get_state();

Deprecated alias for get_active().

Throws: NONE

Side Effects: NONE

Notes: NONE

$state = $key->set_state();

Deprecated alias for set_active().

Throws: NONE

Side Effects: NONE

Notes: NONE

$success = $key->save;

Save the keyword to the database.

Throws:

"Unable to save";

Side Effects:

Will give default values to screen_name and sort_name if they are not set.

Notes: NONE

Private Methods

Private Class Methods

NONE

Private Instance Methods

$keywords = _select_keywords($where, $bind)
@keywords = _select_keywords($where, $bind)

Selects keywords from the database given an SQL where clause and a ref to an array of bind parameters. Returns fully constructed Bric::Biz::Keyword objects.

$self->_update_keyword()

Updates the keyword object in the database.

$self->_update_keyword()

Inserts the new keyword object into the database.

($table, $field) = _get_db_data_for_object($obj)

Returns the correct relationship table and field name for a given supported object. For example, for a story object it returns ("story_keyword", "story_id").

Throws:

Unsupported object type : $ref.

Side Effects: NONE

Notes: NONE

NOTES

NONE

AUTHOR

"Garth Webb" <garth@perijove.com> Bricolage Engineering

Sam Tregar <stregar@about-inc.com>

SEE ALSO

Bric

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 380:

You forgot a '=back' before '=head2'

Around line 386:

'=item' outside of any '=over'

Around line 454:

You forgot a '=back' before '=head2'

Around line 460:

'=item' outside of any '=over'

Around line 678:

You forgot a '=back' before '=head2'