Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
603d3364
Commit
603d3364
authored
Aug 03, 2010
by
Dries Buytaert
Browse files
- Patch
#870292
by sun, yched: hook_field_extra_fields() results are not cached.
parent
f645ab46
Changes
4
Hide whitespace changes
Inline
Side-by-side
modules/field/field.crud.inc
View file @
603d3364
...
...
@@ -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
;
...
...
modules/field/field.info.inc
View file @
603d3364
...
...
@@ -699,6 +699,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.
*
...
...
modules/field/field.module
View file @
603d3364
...
...
@@ -447,68 +447,6 @@ function field_view_mode_settings($entity_type, $bundle) {
return
$cache
[
$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.
*
...
...
@@ -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'
];
...
...
modules/field_ui/field_ui.admin.inc
View file @
603d3364
...
...
@@ -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
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment