summaryrefslogtreecommitdiff
path: root/modules/field/field.info.inc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-09-11 00:03:42 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-09-11 00:03:42 +0000
commit7cc3d92d65cccf7e09943312b7fa28642372d4c9 (patch)
tree0bc09ca5d76dc48f67935304bb1a9c24c0ea8b73 /modules/field/field.info.inc
parent3b21e82a3770c61ad64062204c33911c42e19d7e (diff)
downloadbrdo-7cc3d92d65cccf7e09943312b7fa28642372d4c9.tar.gz
brdo-7cc3d92d65cccf7e09943312b7fa28642372d4c9.tar.bz2
#616240 follow-up by yched, dereine, marvil07: Make Field UI screens extensible from contrib - part II.
Diffstat (limited to 'modules/field/field.info.inc')
-rw-r--r--modules/field/field.info.inc41
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc
index fbc52528e..f435d99a6 100644
--- a/modules/field/field.info.inc
+++ b/modules/field/field.info.inc
@@ -761,6 +761,47 @@ function field_info_extra_fields($entity_type, $bundle, $context) {
}
/**
+ * Returns the maximum weight of all the components in an entity.
+ *
+ * This includes fields, 'extra_fields', and other components added by
+ * third-party modules (e.g. field_group).
+ *
+ * @param $entity_type
+ * The type of entity; e.g. 'node' or 'user'.
+ * @param $bundle
+ * The bundle name.
+ * @param $context
+ * The context for which the maximum weight is requested. Either 'form', or
+ * the name of a view mode.
+ * @return
+ * The maximum weight of the entity's components, or NULL if no components
+ * were found.
+ */
+function field_info_max_weight($entity_type, $bundle, $context) {
+ $weights = array();
+
+ // Collect weights for fields.
+ foreach (field_info_instances($entity_type, $bundle) as $instance) {
+ if ($context == 'form') {
+ $weights[] = $instance['widget']['weight'];
+ }
+ else {
+ $weights[] = $instance['display'][$context]['weight'];
+ }
+ }
+ // Collect weights for extra fields.
+ foreach (field_info_extra_fields($entity_type, $bundle, $context) as $extra) {
+ $weights[] = $extra['weight'];
+ }
+
+ // Let other modules feedback about their own additions.
+ $weights = array_merge($weights, module_invoke_all('field_info_max_weight', $entity_type, $bundle, $context));
+ $max_weight = $weights ? max($weights) : NULL;
+
+ return $max_weight;
+}
+
+/**
* Returns a field type's default settings.
*
* @param $type