summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2009-09-09 21:21:54 (GMT)
committerDries Buytaert2009-09-09 21:21:54 (GMT)
commitc33da192c13a357bf0c75bd556457da78f991a68 (patch)
treefc3e1b8fd377ba322bd58f3d7277ca21869390aa
parenta3f776f4d4620faa3fbe93656358a1ad96b290f9 (diff)
- Patch #567092 by rcross, yched, bjaspan: merge hook_field_formatter_info() and hook_theme().
-rw-r--r--modules/field/field.api.php19
-rw-r--r--modules/field/field.module10
-rw-r--r--modules/field/modules/list/list.module14
-rw-r--r--modules/field/modules/number/number.module14
-rw-r--r--modules/field/modules/text/text.module12
-rw-r--r--modules/file/file.module9
-rw-r--r--modules/taxonomy/taxonomy.module6
7 files changed, 33 insertions, 51 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php
index a06880d..47c2da2 100644
--- a/modules/field/field.api.php
+++ b/modules/field/field.api.php
@@ -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.
diff --git a/modules/field/field.module b/modules/field/field.module
index 05ebb84..ef27a06 100644
--- a/modules/field/field.module
+++ b/modules/field/field.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;
}
/**
diff --git a/modules/field/modules/list/list.module b/modules/field/modules/list/list.module
index f827272..9f29b21 100644
--- a/modules/field/modules/list/list.module
+++ b/modules/field/modules/list/list.module
@@ -7,20 +7,6 @@
*/
/**
- * 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().
*/
function list_field_info() {
diff --git a/modules/field/modules/number/number.module b/modules/field/modules/number/number.module
index c9d0942..dafe254 100644
--- a/modules/field/modules/number/number.module
+++ b/modules/field/modules/number/number.module
@@ -12,13 +12,19 @@
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().
*/
function number_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(
diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module
index 5bbe876..d6653d8 100644
--- a/modules/field/modules/text/text.module
+++ b/modules/field/modules/text/text.module
@@ -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),
- ),
);
}
diff --git a/modules/file/file.module b/modules/file/file.module
index 4af5bae..2354294 100644
--- a/modules/file/file.module
+++ b/modules/file/file.module
@@ -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),
- ),
);
}
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 6621361..039b7bc 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -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),
),