Package: Record\Mixin
Record mixin class for associating elements, element texts and their corresponding behaviors to a record.
ElementText records stored in the order they were retrieved from the database.
ElementText records indexed by the element_id.
Element records indexed by set name and element name, so it looks like:
$elements[‘Dublin Core’][‘Title’] = Element instance;
Element records indexed by ID.
List of elements that were output on the form. This can be used to determine the DELETE SQL to use to reset the elements when saving the form.
Set of ElementText records to save when submitting the form. These will only be saved to the database if they successfully validate.
Whether the elements and texts have been loaded yet.
Sets of Element records indexed by record type.
Omeka_Record_AbstractRecord callback for afterSave. Saves the ElementText records once the associated record is saved. Adds the record’s element texts to the search text.
Parameters: |
|
---|
Get the database object from the associated record.
Returns: | Omeka_Db |
---|
Get the class name of the associated record (Item, File, etc.).
Returns: | string Type of record |
---|
Load all the ElementText records for the given record (Item, File, etc.). These will be indexed by [element_id].
Also load all the Element records and index those by their name and setname.
Parameters: |
|
---|---|
Returns: | void |
Parameters: |
|
---|
Retrieve all of the ElementText records for the given record.
Returns: | array Set of ElementText records for the record. |
---|
Retrieve all of the Element records for the given record.
Returns: | array All Elements that apply to the record’s type. |
---|
Retrieve all of the record’s ElementTexts for the given Element.
Parameters: |
|
---|---|
Returns: | array Set of ElementText records. |
Retrieve all of the record’s ElementTexts for the given element name and element set name.
Parameters: |
|
---|---|
Returns: | array Set of ElementText records. |
Retrieve all of the record’s ElementTexts, in order.
Returns: | array Set of ElementText records. |
---|
Retrieve the Element records for the given ElementSet.
Parameters: |
|
---|---|
Returns: | array Set of Element records |
Retrieve ALL the Element records for the object, organized by ElementSet. For example, $elements[‘Dublin Core’] = array(Element instance, Element instance, ...)
Returns: | array Set of Element records |
---|
Retrieve the Element record corresponding to the given element name and element set name.
Parameters: |
|
---|---|
Returns: | Element |
Retrieve the Element with the given ID.
Parameters: |
|
---|---|
Returns: | Element |
Index a set of ElementTexts based on element ID.
Parameters: |
|
---|---|
Returns: | array The provided ElementTexts, indexed by element ID. |
Index a set of Elements based on their name. The result is a doubly associative array, with the first key being element set name and the second being element name.
i.e., $indexed[‘Dublin Core’][‘Creator’] = Element instance
Parameters: |
|
---|---|
Returns: | array The provided Elements, indexed as described |
Indexes the elements returned by element ID.
Parameters: |
|
---|---|
Returns: | array |
Add a string of text for an element.
Creates a new ElementText record, populates it with the specified text value and assigns it to the element.
saveElementTexts() must be called after this in order to save the elementtexts to the database.
Parameters: |
|
---|
Add element texts for a record based on a formatted array of values. The array must be formatted as follows:
'Element Set Name' =>
array('Element Name' =>
array(array('text' => 'foo', 'html' => false)))
Since 1.4, the array can also be formatted thusly:
array(
array('element_id' => 1,
'text' => 'foo',
'html' => false)
)
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
The application flow is thus:
Parameters: |
|
---|
The POST should have a key called “Elements” that contains an array that is keyed to an element’s ID. That array should contain all the text values for that element. For example:
<code>
array(‘Elements’ =>array(‘50’ => array(array(‘text’ => ‘Foobar’, //element id 50, e.g. DC:Title’html’ => 0)),‘41’ => array(array(‘text’ => ‘<p>Baz baz baz</p>’, //element id 41, e.g. DC:Description’html’ => 1))))
</code>
Parameters: |
|
---|
Retrieve a text string for an element from POSTed form data.
Parameters: |
|
---|---|
Returns: | string |
Validate all the elements one by one. This is potentially a lot slower than batch processing the form, but it gives the added bonus of being able to encapsulate the logic for validation of Elements.
Return whether the given ElementText record is valid.
Parameters: |
|
---|---|
Returns: | boolean |
Save all ElementText records that were associated with a record.
Typically called in the afterSave() hook for a record.
Delete all the element texts for element_id’s that have been provided.
Parameters: |
|
---|---|
Returns: | boolean |
Delete all the element texts assigned to the current record ID.
Returns: | boolean |
---|
Returns whether or not the record has at least 1 element text
Parameters: |
|
---|---|
Returns: | boolean |
Returns the number of element texts for the record
Parameters: |
|
---|---|
Returns: | boolean |