summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Ferran (aka Markus)2009-07-15 13:50:52 (GMT)
committer Marc Ferran (aka Markus)2009-07-15 13:50:52 (GMT)
commitda76b44c0641c5a496f01da9b5ab7eb9d07639a5 (patch)
tree2cc4d6b6e3a97a870243e25726aa52e78d6e53a1
parent2bf68002b51232d113a272dac6fa408f43385878 (diff)
- #417122 by quicksketch: allow drupal_alter on field and widget settings.
-rw-r--r--CHANGELOG.txt3
-rw-r--r--content.install2
-rw-r--r--content.module2
-rw-r--r--includes/content.admin.inc16
-rw-r--r--includes/content.crud.inc53
-rw-r--r--includes/views/content.views.inc3
-rw-r--r--includes/views/content.views_convert.inc3
7 files changed, 42 insertions, 40 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 6b185ec..9b22307 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -11,12 +11,13 @@ Features:
- #505278 Panels 3 and multiple node type fields.
- #495582 Reviewed Panels 3 integration (prep work for combo / multigroups).
Implementation of fieldgroup_view_group() that can be used to render field groups.
+- #417122 by quicksketch: allow drupal_alter on field and widget settings.
Bugfixes:
- #482774 Update breaks when CCK is disabled.
- #479994 by quicksketch: fix "add more' button with devel.module's query logging (multigroup).
- #499696 by DeFr - Noderefernce / Userreference: fix Views mode when the view has exposed filters.
-- #498924 - #multiple FAPI attribute is used for a radios and checkboxes in content export forms.
+- #498924 #multiple FAPI attribute is used for a radios and checkboxes in content export forms.
- #409144 Review extra elements for node edit form provided by core modules.
- #361473 CCK fieldgroup panels doesn't respect CCK field privacy settings.
- #515984 Multiple field delta ORDER BY incorrect.
diff --git a/content.install b/content.install
index 863e0e6..9faaac4 100644
--- a/content.install
+++ b/content.install
@@ -69,7 +69,7 @@ function content_types_install() {
if (!empty($field['module']) && !empty($field['widget_module'])) {
$field['widget_settings'] = unserialize($field['widget_settings']);
$field['display_settings'] = unserialize($field['display_settings']);
- $field['columns'] = module_invoke($field['module'], 'field_settings', 'database columns', $field);
+ $field['columns'] = (array) module_invoke($field['module'], 'field_settings', 'database columns', $field);
$field = content_field_instance_expand($field);
$fields[$field['type_name']][$field['field_name']] = $field;
}
diff --git a/content.module b/content.module
index 4d3428e..7ae3adc 100644
--- a/content.module
+++ b/content.module
@@ -631,7 +631,7 @@ function content_associate_fields($module) {
foreach ($types as $type_name => $fields) {
foreach ($fields as $field) {
if ($field['module'] == $module && !in_array($field['field_name'], $fields_set)) {
- $columns = module_invoke($field['module'], 'field_settings', 'database columns', $field);
+ $columns = (array) module_invoke($field['module'], 'field_settings', 'database columns', $field);
db_query("UPDATE {". content_field_tablename() ."} SET db_columns = '%s' WHERE field_name = '%s'", serialize($columns), $field['field_name']);
$fields_set[] = $field['field_name'];
}
diff --git a/includes/content.admin.inc b/includes/content.admin.inc
index 280bf46..93ef4cd 100644
--- a/includes/content.admin.inc
+++ b/includes/content.admin.inc
@@ -1029,10 +1029,11 @@ function content_field_edit_form(&$form_state, $type_name, $field_name) {
'#type' => 'hidden',
'#default_value' => $field['widget']['weight'],
);
- $additions = module_invoke($widget_type['module'], 'widget_settings', 'form', $field['widget']);
- if (is_array($additions)) {
- $form['widget'] = array_merge($form['widget'], $additions);
- }
+
+ $additions = (array) module_invoke($widget_type['module'], 'widget_settings', 'form', $field['widget']);
+ drupal_alter('widget_settings', $additions, 'form', $field['widget']);
+ $form['widget'] = array_merge($form['widget'], $additions);
+
$form['widget']['description'] = array(
'#type' => 'textarea',
'#title' => t('Help text'),
@@ -1148,10 +1149,9 @@ function content_field_edit_form(&$form_state, $type_name, $field_name) {
'#value' => serialize($field),
);
- $additions = module_invoke($field_type['module'], 'field_settings', 'form', $field);
- if (is_array($additions)) {
- $form['field'] = array_merge($form['field'], $additions);
- }
+ $additions = (array) module_invoke($field_type['module'], 'field_settings', 'form', $field);
+ drupal_alter('field_settings', $additions, 'form', $field);
+ $form['field'] = array_merge($form['field'], $additions);
$form['submit'] = array(
'#type' => 'submit',
diff --git a/includes/content.crud.inc b/includes/content.crud.inc
index 63b18ec..2942940 100644
--- a/includes/content.crud.inc
+++ b/includes/content.crud.inc
@@ -42,9 +42,9 @@ function content_field_default_values($field_type) {
$field['active'] = 1;
}
- $field['columns'] = module_invoke($module, 'field_settings', 'database columns', $field);
+ $field['columns'] = (array) module_invoke($module, 'field_settings', 'database columns', $field);
// Ensure columns always default to NULL values.
- foreach ((array) $field['columns'] as $column_name => $column) {
+ foreach ($field['columns'] as $column_name => $column) {
$field['columns'][$column_name]['not null'] = FALSE;
}
@@ -53,11 +53,10 @@ function content_field_default_values($field_type) {
$field['db_storage'] = CONTENT_DB_STORAGE_PER_CONTENT_TYPE;
// Make sure field settings all have an index in the array.
- $setting_names = module_invoke($module, 'field_settings', 'save', $field);
- if (is_array($setting_names)) {
- foreach ($setting_names as $setting) {
- $field[$setting] = NULL;
- }
+ $setting_names = (array) module_invoke($module, 'field_settings', 'save', $field);
+ drupal_alter('field_settings', $setting_names, 'save', $field);
+ foreach ($setting_names as $setting) {
+ $field[$setting] = NULL;
}
return $field;
}
@@ -93,9 +92,10 @@ function content_instance_default_values($field_name, $type_name, $widget_type)
}
// Make sure widget settings all have an index in the array.
- $settings_names = module_invoke($module, 'widget_settings', 'save', $widget);
+ $settings_names = (array) module_invoke($module, 'widget_settings', 'save', $widget);
+ drupal_alter('widget_settings', $settings_names, 'save', $widget);
$widget['widget_settings'] = array();
- foreach ((array) $settings_names as $name) {
+ foreach ($settings_names as $name) {
$widget['widget_settings'][$name] = NULL;
}
return $widget;
@@ -399,14 +399,14 @@ function content_field_instance_update($field, $rebuild = TRUE) {
function _content_field_write($field, $op = 'update') {
// Rearrange the data to create the global_settings array.
$field['global_settings'] = array();
- $setting_names = module_invoke($field['module'], 'field_settings', 'save', $field);
- if (is_array($setting_names)) {
- foreach ($setting_names as $setting) {
- // Unlike _content_field_instance_write() and 'widget_settings', 'global_settings'
- // is never preexisting, so we take no particular precautions here.
- $field['global_settings'][$setting] = isset($field[$setting]) ? $field[$setting] : '';
- unset($field[$setting]);
- }
+ $setting_names = (array) module_invoke($field['module'], 'field_settings', 'save', $field);
+ drupal_alter('field_settings', $setting_names, 'save', $field);
+
+ foreach ($setting_names as $setting) {
+ // Unlike _content_field_instance_write() and 'widget_settings', 'global_settings'
+ // is never preexisting, so we take no particular precautions here.
+ $field['global_settings'][$setting] = isset($field[$setting]) ? $field[$setting] : '';
+ unset($field[$setting]);
}
// 'columns' is a reserved word in MySQL4, so our column is named 'db_columns'.
$field['db_columns'] = $field['columns'];
@@ -435,16 +435,15 @@ function _content_field_instance_write($field, $op = 'update') {
$field = content_field_instance_collapse($field);
// Rearrange the data to create the widget_settings array.
- $setting_names = module_invoke($field['widget_module'], 'widget_settings', 'save', $field);
- if (is_array($setting_names)) {
- foreach ($setting_names as $setting) {
- // In some cases (when the updated $field was originally read from
- // the db, as opposed to gathered from the values of a form), the values
- // are already in the right place, we take care to not wipe them.
- if (isset($field[$setting])) {
- $field['widget_settings'][$setting] = $field[$setting];
- unset($field[$setting]);
- }
+ $setting_names = (array) module_invoke($field['widget_module'], 'widget_settings', 'save', $field);
+ drupal_alter('widget_settings', $setting_names, 'save', $field);
+ foreach ($setting_names as $setting) {
+ // In some cases (when the updated $field was originally read from
+ // the db, as opposed to gathered from the values of a form), the values
+ // are already in the right place, we take care to not wipe them.
+ if (isset($field[$setting])) {
+ $field['widget_settings'][$setting] = $field[$setting];
+ unset($field[$setting]);
}
}
diff --git a/includes/views/content.views.inc b/includes/views/content.views.inc
index eecea7b..684d1b6 100644
--- a/includes/views/content.views.inc
+++ b/includes/views/content.views.inc
@@ -140,7 +140,8 @@ function content_views_data() {
$data = array();
foreach (content_fields() as $field) {
$module = $field['module'];
- $result = module_invoke($module, 'field_settings', 'views data', $field);
+ $result = (array) module_invoke($module, 'field_settings', 'views data', $field);
+ drupal_alter('field_settings', $result, 'views data', $field);
if (empty($result)) {
$result = content_views_field_views_data($field);
}
diff --git a/includes/views/content.views_convert.inc b/includes/views/content.views_convert.inc
index b83119d..aaa94f9 100644
--- a/includes/views/content.views_convert.inc
+++ b/includes/views/content.views_convert.inc
@@ -22,7 +22,8 @@ function content_views_convert($display, $type, &$view, $views_field) {
foreach ($types as $ctype) {
foreach ($ctype['fields'] as $field) {
$module = $field['module'];
- $result = module_invoke($module, 'field_settings', 'views data', $field);
+ $result = (array) module_invoke($module, 'field_settings', 'views data', $field);
+ drupal_alter('field_settings', $result, 'views data', $field);
if (empty($result)) {
// The views field name had the column name appended,
// like field_name_value or field_username_uid.