diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-08-03 23:01:14 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-08-03 23:01:14 +0000 |
commit | 603d33649b725051391d480446011a5148bb5255 (patch) | |
tree | 16f5835a8a865943e62e35ed756ab4719a427132 | |
parent | f645ab468a57a9c8d5d5cac70c29dd0315f149d4 (diff) | |
download | brdo-603d33649b725051391d480446011a5148bb5255.tar.gz brdo-603d33649b725051391d480446011a5148bb5255.tar.bz2 |
- Patch #870292 by sun, yched: hook_field_extra_fields() results are not cached.
-rw-r--r-- | modules/field/field.crud.inc | 4 | ||||
-rw-r--r-- | modules/field/field.info.inc | 61 | ||||
-rw-r--r-- | modules/field/field.module | 66 | ||||
-rw-r--r-- | modules/field_ui/field_ui.admin.inc | 4 |
4 files changed, 67 insertions, 68 deletions
diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc index aa1ee2f34..e7fa00146 100644 --- a/modules/field/field.crud.inc +++ b/modules/field/field.crud.inc @@ -764,7 +764,7 @@ function _field_write_instance($instance, $update = FALSE) { $weights[] = $existing_instance['widget']['weight']; } } - foreach (field_extra_fields($instance['entity_type'], $instance['bundle'], 'form') as $extra) { + foreach (field_info_extra_fields($instance['entity_type'], $instance['bundle'], 'form') as $extra) { $weights[] = $extra['weight']; } $instance['widget']['weight'] = $weights ? max($weights) + 1 : 0; @@ -798,7 +798,7 @@ function _field_write_instance($instance, $update = FALSE) { $weights[] = $existing_instance['display'][$view_mode]['weight']; } } - foreach (field_extra_fields($instance['entity_type'], $instance['bundle'], 'display') as $extra) { + foreach (field_info_extra_fields($instance['entity_type'], $instance['bundle'], 'display') as $extra) { $weights[] = $extra['display'][$view_mode]['weight']; } $display['weight'] = $weights ? max($weights) + 1 : 0; diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc index 79a756766..fbc52528e 100644 --- a/modules/field/field.info.inc +++ b/modules/field/field.info.inc @@ -700,6 +700,67 @@ function field_info_instance($entity_type, $field_name, $bundle_name) { } /** + * Returns a list and settings of pseudo-field elements in a given bundle. + * + * If $context is 'form', an array with the following structure: + * @code + * array( + * 'name_of_pseudo_field_component' => array( + * 'label' => The human readable name of the component, + * 'description' => A short description of the component content, + * 'weight' => The weight of the component in edit forms, + * ), + * 'name_of_other_pseudo_field_component' => array( + * // ... + * ), + * ); + * @endcode + * + * If $context is 'display', an array with the following structure: + * @code + * array( + * 'name_of_pseudo_field_component' => array( + * 'label' => The human readable name of the component, + * 'description' => A short description of the component content, + * // One entry per view mode, including the 'default' mode: + * 'display' => array( + * 'default' => array( + * 'weight' => The weight of the component in displayed entities in + * this view mode, + * 'visibility' => Whether the component is visible or hidden in + * displayed entities in this view mode, + * ), + * 'teaser' => array( + * // ... + * ), + * ), + * ), + * 'name_of_other_pseudo_field_component' => array( + * // ... + * ), + * ); + * @endcode + * + * @param $entity_type + * The type of entity; e.g. 'node' or 'user'. + * @param $bundle + * The bundle name. + * @param $context + * The context for which the list of pseudo-fields is requested. Either + * 'form' or 'display'. + * + * @return + * The array of pseudo-field elements in the bundle. + */ +function field_info_extra_fields($entity_type, $bundle, $context) { + $info = _field_info_collate_fields(); + if (isset($info['extra_fields'][$entity_type][$bundle][$context])) { + return $info['extra_fields'][$entity_type][$bundle][$context]; + } + return array(); +} + +/** * Returns a field type's default settings. * * @param $type diff --git a/modules/field/field.module b/modules/field/field.module index 7d9e55edb..19d30540d 100644 --- a/modules/field/field.module +++ b/modules/field/field.module @@ -448,68 +448,6 @@ function field_view_mode_settings($entity_type, $bundle) { } /** - * Returns a list and settings of pseudo-field elements in a given bundle. - * - * If $context is 'form', an array with the following structure: - * @code - * array( - * 'name_of_pseudo_field_component' => array( - * 'label' => The human readable name of the component, - * 'description' => A short description of the component content, - * 'weight' => The weight of the component in edit forms, - * ), - * 'name_of_other_pseudo_field_component' => array( - * // ... - * ), - * ); - * @endcode - * - * If $context is 'display', an array with the following structure: - * @code - * array( - * 'name_of_pseudo_field_component' => array( - * 'label' => The human readable name of the component, - * 'description' => A short description of the component content, - * // One entry per view mode, including the 'default' mode: - * 'display' => array( - * 'default' => array( - * 'weight' => The weight of the component in displayed entities in - * this view mode, - * 'visibility' => Whether the component is visible or hidden in - * displayed entities in this view mode, - * ), - * 'teaser' => array( - * // ... - * ), - * ), - * ), - * 'name_of_other_pseudo_field_component' => array( - * // ... - * ), - * ); - * @endcode - * - * @param $entity_type - * The type of entity; e.g. 'node' or 'user'. - * @param $bundle - * The bundle name. - * @param $context - * The context for which the list of pseudo-fields is requested. Either - * 'form' or 'display'. - * - * @return - * The array of pseudo-field elements in the bundle. - */ -function field_extra_fields($entity_type, $bundle, $context) { - $info = _field_info_collate_fields(); - if (isset($info['extra_fields'][$entity_type][$bundle][$context])) { - return $info['extra_fields'][$entity_type][$bundle][$context]; - } - return array(); -} - - -/** * Returns the display settings to use for an instance in a given view mode. * * @param $instance @@ -557,7 +495,7 @@ function field_extra_fields_get_display($entity_type, $bundle, $view_mode) { // mode. $view_mode_settings = field_view_mode_settings($entity_type, $bundle); $actual_mode = (!empty($view_mode_settings[$view_mode]['custom_settings'])) ? $view_mode : 'default'; - $extra_fields = field_extra_fields($entity_type, $bundle, 'display'); + $extra_fields = field_info_extra_fields($entity_type, $bundle, 'display'); $displays = array(); foreach ($extra_fields as $name => $value) { @@ -583,7 +521,7 @@ function _field_extra_fields_pre_render($elements) { $bundle = $elements['#bundle']; if (isset($elements['#type']) && $elements['#type'] == 'form') { - $extra_fields = field_extra_fields($entity_type, $bundle, 'form'); + $extra_fields = field_info_extra_fields($entity_type, $bundle, 'form'); foreach ($extra_fields as $name => $settings) { if (isset($elements[$name])) { $elements[$name]['#weight'] = $settings['weight']; diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index 3cf095f13..ed3cec643 100644 --- a/modules/field_ui/field_ui.admin.inc +++ b/modules/field_ui/field_ui.admin.inc @@ -182,7 +182,7 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle $field_types = field_info_field_types(); $widget_types = field_info_widget_types(); - $extra_fields = field_extra_fields($entity_type, $bundle, 'form'); + $extra_fields = field_info_extra_fields($entity_type, $bundle, 'form'); // Store each default weight so that we can add the 'add new' rows after them. $weights = array(); @@ -709,7 +709,7 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund // Gather type information. $instances = field_info_instances($entity_type, $bundle); $field_types = field_info_field_types(); - $extra_fields = field_extra_fields($entity_type, $bundle, 'display'); + $extra_fields = field_info_extra_fields($entity_type, $bundle, 'display'); $form += array( '#entity_type' => $entity_type, |