3 * @file content_migrate.text.inc
4 * Code to implement hook_content_migrate_field_alter, content_migrate_instance_alter() and content_migrate_data_record_alter()
5 * on behalf of the former text module, moved into a separate file for efficiency.
9 * Implements hook_content_migrate_field_alter().
11 * Use this to tweak the conversion of field settings
12 * from the D6 style to the D7 style for specific
13 * situations not handled by basic conversion,
14 * as when field types or settings are changed.
16 function content_migrate_text_field_alter(&$field_value, $instance_value) {
17 switch ($field_value['type']) {
20 // Text fields are translatable.
21 $field_value['translatable'] = TRUE
;
23 // The max_length field can no longer be empty
24 // or it will create a SQL error.
25 if (empty($field_value['settings']['max_length'])) {
26 $field_value['settings']['max_length'] = 255;
29 // Text fields using optionwidgets are
31 switch ($instance_value['widget']['type']) {
32 case
'optionwidgets_buttons':
33 case
'optionwidgets_select':
34 $field_value['type'] = 'list_text';
35 $field_value['module'] = 'list';
38 case
'optionwidgets_onoff':
39 $field_value['type'] = 'list_boolean';
40 $field_value['module'] = 'list';
44 $field_value['type'] = 'text_long';
45 unset($field_value['settings']['max_length']);
50 // The allowed values list should now be stored as an array.
51 switch ($field_value['type']) {
54 $allowed_values = array();
55 if (!empty($field_value['settings']['allowed_values'])) {
56 $allowed_values = content_migrate_extract_allowed_values($field_value['settings']['allowed_values'], $field_value['type']);
58 $field_value['settings']['allowed_values'] = $allowed_values;
69 * Implements hook_content_migrate_instance_alter().
71 * Use this to tweak the conversion of instance or widget settings
72 * from the D6 style to the D7 style for specific
73 * situations not handled by basic conversion, as when
74 * formatter or widget names or settings are changed.
76 function content_migrate_text_instance_alter(&$instance_value, $field_value) {
77 switch ($field_value['module']) {
79 // The formatter names changed, all are prefixed
81 foreach ($instance_value['display'] as
$context => $settings) {
82 $instance_value['display'][$context]['type'] = 'text_'.
$settings['type'];