summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramateescu2012-01-20 22:12:41 (GMT)
committer Earl Miles2012-01-20 22:12:41 (GMT)
commit1715a1a48dfc02c540de98ee1dc54d0c825b8cf8 (patch)
treec8eb1ddf7547f52ee5821f27d78bce311a1b4df2
parentd74306e48b952183c543f52a5581f85467306f21 (diff)
Issue #1315046 by amateescu: Add get fields by type function; increase API version to compensate.
-rw-r--r--API.txt7
-rw-r--r--ctools.module2
-rw-r--r--includes/fields.inc21
3 files changed, 26 insertions, 4 deletions
diff --git a/API.txt b/API.txt
index d1eb582..4305672 100644
--- a/API.txt
+++ b/API.txt
@@ -1,13 +1,16 @@
-Current API Version: 2.0.4
+Current API Version: 2.0.5
Please note that the API version is an internal number and does not match release numbers. It is entirely possible that releases will not increase the API version number, and increasing this number too often would burden contrib module maintainers who need to keep up with API changes.
This file contains a log of changes to the API.
+API Version 2.0.5
+ Introduce ctools_fields_get_fields_by_type().
+
API Version 2.0.4
Introduce ctools_form_include_file()
API Version 2.0.3
- Introduce ctools_field_invoke_field() and
+ Introduce ctools_field_invoke_field() and ctools_field_invoke_field_default().
API Version 2.0.2
Introduce ctools_export_crud_load_multiple() and 'load multiple callback' to
diff --git a/ctools.module b/ctools.module
index eca75f2..b3acdf4 100644
--- a/ctools.module
+++ b/ctools.module
@@ -9,7 +9,7 @@
* must be implemented in the module file.
*/
-define('CTOOLS_API_VERSION', '2.0.4');
+define('CTOOLS_API_VERSION', '2.0.5');
/**
* Test the CTools API version.
diff --git a/includes/fields.inc b/includes/fields.inc
index 5e3d0e1..9b08f38 100644
--- a/includes/fields.inc
+++ b/includes/fields.inc
@@ -110,7 +110,7 @@ function ctools_fields_get_field_formatter_settings_form($field, $formatter_type
'#default_value' => $conf['delta_reversed'],
'#description' => t('(start from last values)'),
);
- }
+ }
}
/**
@@ -287,3 +287,22 @@ function ctools_field_invoke_field_default($field_name, $op, $entity_type, $enti
$options['default'] = TRUE;
return ctools_field_invoke_field($field_name, $op, $entity_type, $entity, $a, $b, $options);
}
+
+/**
+ * Returns a list of field definitions of a specified type.
+ *
+ * @param string $field_type
+ * A field type name; e.g. 'text' or 'date'.
+ *
+ * @return array
+ * An array of field definitions of the specified type, keyed by field name.
+ */
+function ctools_fields_get_fields_by_type($field_type) {
+ $fields = array();
+ foreach (field_info_fields() as $field_name => $field_info) {
+ if ($field_info['type'] == $field_type) {
+ $fields[$field_name] = $field_info;
+ }
+ }
+ return $fields;
+}