ItemType

Package: Record

class ItemType

extends Omeka_Record_AbstractRecord

implements Zend_Acl_Resource_Interface

An item type and its metadata.

Item types are like specialized element sets that only apply to Items and which can vary between items.

constant ItemType::ITEM_TYPE_NAME_MIN_CHARACTERS

Minimum length of an ItemType name.

constant ItemType::ITEM_TYPE_NAME_MAX_CHARACTERS

Maximum length of an ItemType name.

property ItemType::$name

string

Name of this ItemType.

property ItemType::$description

string

Description for this ItemType.

protected array

Records related to an ItemType.

ItemType::getElements()

Get an array of element objects associated with this item type.

Returns:array All the Element objects associated with this item type.
ItemType::getItems($count = 10, $recent = true)

Get an array of Items that have this item type.

Parameters:
  • $count (int) – The maximum number of items to return.
  • $recent (bool) – Whether the most recent items should be chosen.
Returns:

array The Item objects associated with the item type.

ItemType::_validate()

Validate this ItemType.

The name field must be between 1 and 255 characters and must be unique.

ItemType::filterPostData($post)

Filter incoming POST data from ItemType form.

Parameters:
  • $post
ItemType::_delete()

Clean up the associated records for this Item Type.

Delete all the ItemTypesElements rows joined to this type, and remove the type ID from any associated items.

ItemType::afterSave($args)

After-save hook.

Save Element records that are associated with this Item Type.

Parameters:
  • $args
ItemType::reorderElements($elementOrderingArray)

Reorder the elements for this type.

This extracts the ordering for the elements from the form’s POST, then uses the given ordering to reorder each join record from item_types_elements into a new ordering, which is then saved.

Parameters:
  • $elementOrderingArray (array) – An array of element_id => order pairs
ItemType::addElements($elements = array())

Add a set of elements to the Item Type.

Parameters:
  • $elements (array) – Either an array of elements or an array of metadata, where each entry corresponds to a new element to add to the item type. If an element exists with the same id, it will replace the old element with the new element.
ItemType::addElementById($elementId)

Add a new element to the item type, giving the Element by its ID.

Parameters:
  • $elementId
ItemType::removeElements($elements)

Remove an array of Elements from this item type

The elements will not be removed until the object is saved.

Parameters:
  • $elements (array) – An array of Element objects or element id strings
ItemType::removeElement($element)

Remove a single Element from this item type.

The element will not be removed until the object is saved.

Parameters:
  • $element (Element|string) – The element object or the element id.
ItemType::_removeElement($element)

Immediately remove a single Element from this item type.

Parameters:
  • $element (Element|string) –
ItemType::hasElement($element)

Determine whether this ItemType has a particular element.

This method does not handle elements that were added or removed without saving the item type object.

Parameters:
  • $element (Element|string) – The element object or the element id.
Returns:

bool

ItemType::totalItems()

Get the total number of items that have this item type.

Returns:int The total number of items that have this item type.
ItemType::getItemTypeElementSet()

Get the ‘Item Type’ element set.

Returns:ElementSet
ItemType::getResourceId()

Identify ItemType records as relating to the ItemTypes ACL resource.

Required by Zend_Acl_Resource_Interface.

Returns:string
ItemType::_dissociateItems()

Set items attached to this item type back to null.