function ds_extras_ds_field_settings_alter in Display Suite 7.2
Same name and namespace in other branches
- 7 modules/ds_extras/ds_extras.admin.inc \ds_extras_ds_field_settings_alter()
Implements hook_ds_field_settings_alter().
File
- modules/
ds_extras/ ds_extras.module, line 898 - Display Suite extras main functions.
Code
function ds_extras_ds_field_settings_alter(&$field_settings, $form, &$form_state) {
$fields = $form_state['values']['fields'];
$default_field_function = variable_get('ft-default', 'theme_field');
$wrappers = array(
'ow' => t('Wrapper'),
'fis' => t('Field items'),
'fi' => t('Field item'),
);
foreach ($fields as $key => $field) {
// Make sure we need to save anything for this field.
if (_ds_field_valid($key, $field, $form_state)) {
continue;
}
// Get the values.
$values = isset($form_state['formatter_settings'][$key]['ft']) ? $form_state['formatter_settings'][$key]['ft'] : array();
if (empty($values)) {
continue;
}
$field_settings[$key]['formatter_settings']['ft'] = array();
// Theme output function.
$function = isset($values['func']) ? $values['func'] : $default_field_function;
if ($function != $default_field_function) {
$field_settings[$key]['formatter_settings']['ft']['func'] = $function;
}
// Field classes.
if ($function != 'theme_ds_field_expert' && $function != 'theme_ds_field_reset' && isset($values['classes'])) {
$classes = is_array($values['classes']) ? implode(' ', $values['classes']) : $values['classes'];
if (!empty($classes)) {
$field_settings[$key]['formatter_settings']['ft']['classes'] = $classes;
}
}
// Label.
if (isset($form_state['values']['fields'][$key]['label'])) {
if (!empty($values['lb'])) {
$field_settings[$key]['formatter_settings']['ft']['lb'] = $values['lb'];
}
if (!empty($values['lb-el']) && $function == 'theme_ds_field_expert') {
$field_settings[$key]['formatter_settings']['ft']['lb-el'] = check_plain($values['lb-el']);
}
if (!empty($values['lb-cl']) && $function == 'theme_ds_field_expert') {
$field_settings[$key]['formatter_settings']['ft']['lb-cl'] = check_plain($values['lb-cl']);
}
if (!empty($values['lb-at']) && $function == 'theme_ds_field_expert') {
$field_settings[$key]['formatter_settings']['ft']['lb-at'] = filter_xss($values['lb-at']);
}
if (!empty($values['lb-def-at']) && $function == 'theme_ds_field_expert') {
$field_settings[$key]['formatter_settings']['ft']['lb-def-at'] = TRUE;
}
if (!empty($values['lb-col'])) {
$field_settings[$key]['formatter_settings']['ft']['lb-col'] = TRUE;
}
// label wrapper
if (!empty($values['lbw'])) {
$field_settings[$key]['formatter_settings']['ft']['lbw'] = $values['lbw'];
}
if (!empty($values['lbw-el']) && $function == 'theme_ds_field_expert') {
$field_settings[$key]['formatter_settings']['ft']['lbw-el'] = check_plain($values['lbw-el']);
}
if (!empty($values['lbw-cl']) && $function == 'theme_ds_field_expert') {
$field_settings[$key]['formatter_settings']['ft']['lbw-cl'] = check_plain($values['lbw-cl']);
}
if (!empty($values['lbw-at']) && $function == 'theme_ds_field_expert') {
$field_settings[$key]['formatter_settings']['ft']['lbw-at'] = filter_xss($values['lbw-at']);
}
}
if (!empty($values['prefix'])) {
$field_settings[$key]['formatter_settings']['ft']['prefix'] = $values['prefix'];
}
if (!empty($values['suffix'])) {
$field_settings[$key]['formatter_settings']['ft']['suffix'] = $values['suffix'];
}
// Custom field configuration.
if ($function == 'theme_ds_field_expert') {
foreach ($wrappers as $wrapper_key => $title) {
if (!empty($values[$wrapper_key])) {
// Enable.
$field_settings[$key]['formatter_settings']['ft'][$wrapper_key] = TRUE;
// Element.
$field_settings[$key]['formatter_settings']['ft'][$wrapper_key . '-el'] = !empty($values[$wrapper_key . '-el']) ? check_plain($values[$wrapper_key . '-el']) : 'div';
// Classes.
$field_settings[$key]['formatter_settings']['ft'][$wrapper_key . '-cl'] = !empty($values[$wrapper_key . '-cl']) ? check_plain($values[$wrapper_key . '-cl']) : '';
// Default Classes.
if (in_array($wrapper_key, array(
'ow',
'lb',
))) {
$field_settings[$key]['formatter_settings']['ft'][$wrapper_key . '-def-cl'] = !empty($values[$wrapper_key . '-def-cl']) ? TRUE : FALSE;
}
// Attributes.
$field_settings[$key]['formatter_settings']['ft'][$wrapper_key . '-at'] = !empty($values[$wrapper_key . '-at']) ? filter_xss($values[$wrapper_key . '-at']) : '';
// Default attributes.
$field_settings[$key]['formatter_settings']['ft'][$wrapper_key . '-def-at'] = !empty($values[$wrapper_key . '-def-at']) ? TRUE : FALSE;
// Odd even class.
if ($wrapper_key == 'fi') {
$field_settings[$key]['formatter_settings']['ft'][$wrapper_key . '-odd-even'] = !empty($values[$wrapper_key . '-odd-even']) ? TRUE : FALSE;
$field_settings[$key]['formatter_settings']['ft'][$wrapper_key . '-first-last'] = !empty($values[$wrapper_key . '-first-last']) ? TRUE : FALSE;
}
}
}
}
}
}