API:EPrints/MetaField
Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki
Contents
- 1 NAME
- 2 DESCRIPTION
- 2.1 new
- 2.2 final
- 2.3 set_property
- 2.4 clone
- 2.5 get_dataset
- 2.6 render_name
- 2.7 display_name
- 2.8 render_help
- 2.9 render_input_field
- 2.10 form_value
- 2.11 get_name
- 2.12 get_type
- 2.13 get_property
- 2.14 is_type
- 2.15 render_value
- 2.16 render_value_no_multiple
- 2.17 render_value_withopts
- 2.18 sort_values
- 2.19 list_values
- 2.20 most_local
- 2.21 call_property
- 2.22 value_from_sql_row
- 2.23 sql_row_from_value
- 2.24 get_sql_type
- 2.25 get_sql_index
- 2.26 render_single_value
- 2.27 render_input_field_actual
- 2.28 get_sql_names
- 2.29 is_browsable
- 2.30 get_values
- 2.31 get_id_from_value
- 2.32 get_value_label
- 2.33 ordervalue
- 3 UNDOCUMENTED METHODS
- 3.1 form_value_actual
- 3.2 form_value_basic
- 3.3 form_value_single
- 3.4 from_search_form
- 3.5 get_basic_input_elements
- 3.6 get_basic_input_ids
- 3.7 get_ids_by_value
- 3.8 get_index_codes
- 3.9 get_input_col_titles
- 3.10 get_input_elements
- 3.11 get_input_elements_single
- 3.12 get_max_input_size
- 3.13 get_property_defaults
- 3.14 get_search_conditions
- 3.15 get_search_group
- 3.16 get_sql_name
- 3.17 get_state_params
- 3.18 get_unsorted_values
- 3.19 get_value
- 3.20 get_xml_schema_type
- 3.21 is_virtual
- 3.22 ordervalue_basic
- 3.23 ordervalue_single
- 3.24 render_search_description
- 3.25 render_search_input
- 3.26 render_search_value
- 3.27 render_value_actual
- 3.28 render_xml_schema
- 3.29 render_xml_schema_type
- 3.30 set_value
- 3.31 should_reverse_order
- 3.32 split_search_value
- 3.33 to_xml
- 3.34 to_xml_basic
- 3.35 to_xml_old
- 3.36 to_xml_old_single
- 3.37 validate
NAME
EPrints::MetaField - A single metadata field.
DESCRIPTION
Theis object represents a single metadata field, not the value of that field. A field belongs (usually) to a dataset and has a large number of properties. Optional and required properties vary between types.
"type" is the most important property, it is the type of the metadata field. For example: "text", "name" or "date".
A full description of metadata types and properties is in the eprints documentation and will not be duplicated here.
new
$field = EPrints::MetaField->new( %properties )
Create a new metafield. %properties is a hash of the properties of the field, with the addition of "dataset", or if "dataset" is not set then "confid" and "repository" must be provided instead.
Some field types require certain properties to be explicitly set. See the main documentation.
final
$field->final
This method tells the metafield that it is now read only. Any call to set_property will produce a abort error.
set_property
$field->set_property( $property, $value )
Set the named property to the given value.
This should not be called on metafields unless they've been cloned first.
This method will cause an abort error if the metafield is read only.
In these cases a cloned version of the field should be used.
clone
$newfield = $field->clone
Clone the field, so the clone can be edited without affecting the original. Does not deep copy properties which are references - these should be set to new values, rather than the contents altered. Eg. don't push to a cloned options list, replace it.
get_dataset
$dataset = $field->get_dataset
Return the dataset to which this field belongs, or undef.
render_name
$xhtml = $field->render_name( $session )
Render the name of this field as an XHTML object.
display_name
$label = $field->display_name( $session )
DEPRECATED! Can't be removed because it's used in 2.2's default ArchiveRenderConfig.pm
Return the UTF-8 encoded name of this field, in the language of the $session.
render_help
$xhtml = $field->render_help( $session )
Return the help information for a user inputing some data for this field as an XHTML chunk.
render_input_field
$xhtml = $field->render_input_field( $session, $value, [$dataset], [$staff], [$hidden_fields], $obj, [$basename] )
Return the XHTML of the fields for an form which will allow a user to input metadata to this field. $value is the default value for this field.
The actual function called may be overridden from the config.
form_value
$value = $field->form_value( $session, $object, [$prefix] )
Get a value for this field from the CGI parameters, assuming that the form contained the input fields for this metadata field.
get_name
$name = $field->get_name
Return the name of this field.
get_type
$type = $field->get_type
Return the type of this field.
get_property
$value = $field->get_property( $property )
Return the value of the given property.
Special note about "required" property: It only indicates if the field is always required. You must query the dataset to check if it is required for a specific type.
is_type
$boolean = $field->is_type( @typenames )
Return true if the type of this field is one of @typenames.
render_value
$xhtml = $field->render_value( $session, $value, [$alllangs], [$nolink], $object )
Render the given value of this given string as XHTML DOM. If $alllangs is true and this is a multilang field then render all language versions, not just the current language (for editorial checking). If $nolink is true then don't make this field a link, for example subject fields might otherwise link to the subject view page.
If render_value or render_single_value properties are set then these control the rendering instead.
render_value_no_multiple
$xhtml = $field->render_value_no_multiple( $session, $value, $alllangs, $nolink, $object )
Render the XHTML for a non-multiple value. Can be either a from a non-multiple field, or a single value from a multiple field.
Usually just used internally.
render_value_withopts
$xhtml = $field->render_value_withopts( $session, $value, $nolink, $object )
Render a single value but adding the render_opts features.
This uses either the field specific render_single_value or, if one is configured, the render_single_value specified in the config.
Usually just used internally.
sort_values
$out_list = $field->sort_values( $session, $in_list )
Sorts the in_list into order, based on the "order values" of the values in the in_list. Assumes that the values are not a list of multiple values. [ [], [], [] ], but rather a list of single values.
list_values
@values = $field->list_values( $value )
Return a list of every distinct value in this field.
- for simple fields: return ( $value ) - for multiple fields: return @{$value}
This function is used by the item_matches method in Search.
most_local
$value = $field->most_local( $session, $value )
If this field is a multilang field then return the version of the value most useful for the language of the session. In order of preference: The language of the session, the default language for the repository, any language at all. If it is not a multilang field then just return $value.
call_property
$value2 = $field->call_property( $property, @args )
Call the method described by $property. Pass it the arguments and return the result.
The property may contain either a code reference, or the scalar name of a method.
value_from_sql_row
$val = $field->value_from_sql_row( $session, $row )
Shift and return the value of this field from the database input $row.
sql_row_from_value
@row = $field->sql_row_from_value( $session, $value )
Return a list of values to insert into the database based on $value.
get_sql_type
$sql = $field->get_sql_type( $session, $notnull )
Return the SQL type of this field, used for creating tables. $notnull being true indicates that this column may not be null.
get_sql_index
$sql = $field->get_sql_index
Return the columns that an index should be created over.
render_single_value
$xhtml_dom = $field->render_single_value( $session, $value )
Returns the XHTML representation of the value. The value will be non-multiple. Just the simple value.
render_input_field_actual
$xhtml = $field->render_input_field_actual( $session, $value, [$dataset], [$staff], [$hidden_fields], [$obj], [$basename] )
Return the XHTML of the fields for an form which will allow a user to input metadata to this field. $value is the default value for this field.
Unlike render_input_field, this function does not use the render_input property, even if it's set.
The $obj is the current state of the object this field is associated with, if any.
get_sql_names
@sqlnames = $field->get_sql_names
Return the names of this field's columns as they appear in a SQL table.
is_browsable
$boolean = $field->is_browsable
Return true if this field can be "browsed". ie. Used as a view.
get_values
$values = $field->get_values( $session, $dataset, %opts )
Return a reference to an array of all the values of this field. For fields like "subject" or "set" it returns all the variations. For fields like "text" return all the distinct values from the database.
Results are sorted according to the ordervalues of the $session.
get_id_from_value
$id = $field->get_id_from_value( $session, $value )
Returns a unique id for $value.
get_value_label
$xhtml = $field->get_value_label( $session, $value )
Return an XHTML DOM object describing the given value. Normally this is just the value, but in the case of something like a "set" field this returns the name of the option in the current language.
ordervalue
$ov = $field->ordervalue( $value, $session, $langid, $dataset )
Return a string representing this value which can be used to sort it into order by comparing it alphabetically.