function _phone_update_cck_phone_instance_settings in Phone 7.2
Helper function for migrate/update functions: convert cck_phone-6.x and cck_phone-7.x-1.x instance settings to new values.
2 calls to _phone_update_cck_phone_instance_settings()
- phone_cck_convert_admin_form_submit in phone_cck_convert/
phone_cck_convert.module - Submit handler.
- phone_content_migrate_instance_alter in ./
phone.content_migrate.inc - Implements hook_content_migrate_instance_alter().
File
- ./
phone.module, line 1319 - The phone module lets administrators use a phone number field type.
Code
function _phone_update_cck_phone_instance_settings(&$data) {
$data['module'] = 'phone';
// Widget settings
$data['widget']['module'] = 'phone';
$data['widget']['type'] = 'phone';
$data['widget']['settings']['country_code_position'] = $data['settings']['country_code_position'];
unset($data['settings']['country_code_position']);
// Instance settings
$info = phone_field_info();
// Fill in any new settings with default instance settings. These
// will be overwritten as appropriate below.
foreach ($info['phone']['settings'] as $setting => $value) {
if (!isset($data['settings'][$setting])) {
$data['settings'][$setting] = $value;
}
}
// Move country settings into country_options array
foreach (array(
'enable_default_country',
'default_country',
'all_country_codes',
'country_codes',
) as $setting) {
if (isset($data['settings'][$setting])) {
$data['settings']['country_options'][$setting] = $data['settings'][$setting];
unset($data['settings'][$setting]);
}
}
// Convert all country codes to uppercase
$data['settings']['country_options']['default_country'] = _phone_update_cck_phone_country($data['settings']['country_options']['default_country']);
$orig_list = $data['settings']['country_codes']['country_selection'];
$data['settings']['country_options']['country_codes']['country_selection'] = array();
foreach ($orig_list as $orig_country => $value) {
$country = _phone_update_cck_phone_country($orig_country);
if (!empty($country)) {
$data['settings']['country_options']['country_codes']['country_selection'][$country] = $value;
}
}
if (isset($data['settings']['enable_custom_country'])) {
// $data['settings']['enable_country_level_validation'] = $data['settings']['enable_custom_country'];
unset($data['settings']['enable_custom_country']);
}
// @todo: what about "enable_mobile" option in D6?
// Update all formatters.
foreach ($data['display'] as $context => $ddata) {
if (is_array($ddata)) {
switch ($ddata['type']) {
case 'local':
$data['display'][$context]['type'] = 'phone_national';
break;
case 'default':
default:
$data['display'][$context]['type'] = 'phone_international';
break;
}
$data['display'][$context]['settings'] = $format_info[$data[$context]['type']]['settings'];
$data['display'][$context]['settings']['country_name_position'] = 'none';
$data['display'][$context]['module'] = 'phone';
}
}
}