- Patch #567092 by rcross, yched, bjaspan: merge hook_field_formatter_info() and hook_theme().
parent
a3f776f4d4
commit
c33da192c1
|
@ -663,14 +663,25 @@ function hook_field_widget_error($element, $error) {
|
|||
* of drupal_render() on the render structure built by field_attach_view().
|
||||
*
|
||||
* The name of the theme hook invoked when displaying the values is derived
|
||||
* from formatter type names, following the pattern:
|
||||
* field_formatter_FORMATTER_NAME
|
||||
* The module implementing the formatters needs to register those theme hooks
|
||||
* using hook_theme().
|
||||
* from formatter type names, using the pattern field_formatter_FORMATTER_NAME.
|
||||
* field.module takes care of exposing the corresponding theme functions
|
||||
* through hook_theme(). Specifically, field.module defines the theme
|
||||
* hook:
|
||||
*
|
||||
* @code
|
||||
* 'field_formatter_FORMATTER_NAME' => array(
|
||||
* 'arguments' => array('element' => NULL),
|
||||
* )
|
||||
* @code
|
||||
*
|
||||
* If a formatter requires a different theme hook definition,
|
||||
* implement hook_theme_registry_alter().
|
||||
*
|
||||
* @see hook_field_formatter_info().
|
||||
* @see hook_field_formatter_info_alter().
|
||||
* @see theme_field_formatter_FORMATTER_NAME().
|
||||
* @see hook_theme().
|
||||
* @see hook_theme_registry_alter().
|
||||
*
|
||||
* @return
|
||||
* An array describing the formatter types implemented by the module.
|
||||
|
|
|
@ -153,8 +153,7 @@ function field_help($path, $arg) {
|
|||
*/
|
||||
function field_theme() {
|
||||
$path = drupal_get_path('module', 'field') . '/theme';
|
||||
|
||||
return array(
|
||||
$items = array(
|
||||
'field' => array(
|
||||
'template' => 'field',
|
||||
'arguments' => array('element' => NULL),
|
||||
|
@ -164,6 +163,13 @@ function field_theme() {
|
|||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
);
|
||||
$field_formatters = field_info_formatter_types(NULL);
|
||||
foreach ($field_formatters as $key => $field_formatter) {
|
||||
$items["field_formatter_$key"] = array(
|
||||
'arguments' => array('element' => NULL),
|
||||
);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,20 +6,6 @@
|
|||
* Defines list field types that can be used with the Options module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implement hook_theme().
|
||||
*/
|
||||
function list_theme() {
|
||||
return array(
|
||||
'field_formatter_list_default' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
'field_formatter_list_key' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_field_info().
|
||||
*/
|
||||
|
|
|
@ -12,12 +12,18 @@
|
|||
function number_theme() {
|
||||
return array(
|
||||
'number' => array('arguments' => array('element' => NULL)),
|
||||
'field_formatter_number_integer' => array('arguments' => array('element' => NULL), 'function' => 'theme_field_formatter_number'),
|
||||
'field_formatter_number_decimal' => array('arguments' => array('element' => NULL), 'function' => 'theme_field_formatter_number'),
|
||||
'field_formatter_number_unformatted' => array('arguments' => array('element' => NULL)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_theme_alter().
|
||||
*/
|
||||
function number_theme_registry_alter(&$theme_registry) {
|
||||
// The number_integer and number_decimal formatters use the same function.
|
||||
$theme_registry['field_formatter_number_integer']['function'] = 'theme_field_formatter_number';
|
||||
$theme_registry['field_formatter_number_decimal']['function'] = 'theme_field_formatter_number';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_field_info().
|
||||
*/
|
||||
|
@ -204,7 +210,7 @@ function number_field_is_empty($item, $field) {
|
|||
*/
|
||||
function number_field_formatter_info() {
|
||||
return array(
|
||||
'number_integer' => array(
|
||||
'number_default' => array(
|
||||
'label' => t('default'),
|
||||
'field types' => array('number_integer'),
|
||||
'settings' => array(
|
||||
|
|
|
@ -17,18 +17,6 @@ function text_theme() {
|
|||
'text_textfield' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
'field_formatter_text_default' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
'field_formatter_text_plain' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
'field_formatter_text_trimmed' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
'field_formatter_text_summary_or_trimmed' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,15 +85,6 @@ function file_theme() {
|
|||
'file_upload_help' => array(
|
||||
'arguments' => array('upload_validators' => NULL),
|
||||
),
|
||||
'field_formatter_file_default' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
'field_formatter_file_table' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
'field_formatter_file_url_plain' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,12 +91,6 @@ function taxonomy_theme() {
|
|||
'taxonomy_overview_terms' => array(
|
||||
'arguments' => array('form' => array()),
|
||||
),
|
||||
'field_formatter_taxonomy_term_link' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
'field_formatter_taxonomy_term_plain' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
'taxonomy_autocomplete' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue