diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-12 05:22:57 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-12 05:22:57 +0000 |
commit | 8d3eaa1ccf1e7f7d20ecbb19a77e39c028a72706 (patch) | |
tree | 7dfe5c496a2dcfc8b4940e72babb48fc67112cc5 /modules/field/field.info.inc | |
parent | 33b09cc5eb6f602e8007ce4cf799b30aacc4021e (diff) | |
download | brdo-8d3eaa1ccf1e7f7d20ecbb19a77e39c028a72706.tar.gz brdo-8d3eaa1ccf1e7f7d20ecbb19a77e39c028a72706.tar.bz2 |
#560780 by quicksketch, ksenzee, Arancaytar, yched, and arianek: Added Image Field to image.module. Hellooooo, native image handling in core! :D
Diffstat (limited to 'modules/field/field.info.inc')
-rw-r--r-- | modules/field/field.info.inc | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc index 8b273da6a..f229a1d39 100644 --- a/modules/field/field.info.inc +++ b/modules/field/field.info.inc @@ -507,14 +507,48 @@ function field_info_bundle_entity($bundle) { /** * Return array of all field data, keyed by field name. * + * @param $bundle_type + * (optional) The bundle type on which to filter the list of fields. In the + * case of nodes, this is the node type. + * @param $field + * (optional) A field array or name on which to filter the list. + * @param $field_type + * (optional) A field type on which to filter the list. * @return * An array of Field objects. Each Field object has an additional * property, bundles, which is an array of all the bundles to which * this field belongs. */ -function field_info_fields() { - $info = _field_info_collate_fields(); - return $info['fields']; +function field_info_fields($bundle_type = NULL, $field = NULL, $field_type = NULL) { + // Build the list of fields to be used for retrieval. + if (isset($field)) { + if (is_string($field)) { + $field = field_info_field($field); + } + $fields = array($field['field_name'] => $field); + } + elseif (isset($bundle_type)) { + $instances = field_info_instances($bundle_type); + $fields = array(); + foreach ($instances as $field_name => $instance) { + $fields[$field_name] = field_info_field($field_name); + } + } + else { + $info = _field_info_collate_fields(); + $fields = $info['fields']; + } + + // If a field type was given, filter the list down to fields of that type. + if (isset($field_type)) { + foreach ($fields as $key => $field) { + if ($field['type'] != $field_type) { + unset($fields[$key]); + } + } + } + + return $fields; } /** |